...
This commit is contained in:
parent
4364d1316a
commit
bb4469527a
16
Makefile
Normal file
16
Makefile
Normal file
@ -0,0 +1,16 @@
|
||||
default:
|
||||
@echo "Please read Makefile for available targets"
|
||||
|
||||
# Very bad. But i had no choice! its internal!
|
||||
vendor_tsgo:
|
||||
@mkdir -p ./kitcom/internal/tsgo
|
||||
@git clone --depth 1 https://github.com/microsoft/typescript-go
|
||||
@echo Renaming packages...
|
||||
@find ./typescript-go/internal -type file -name "*.go" -exec sed -i -e 's!"github.com/microsoft/typescript-go/internal!"efprojects.com/kitten-ipc/kitcom/internal/tsgo!g' {} \;
|
||||
@cp -r ./typescript-go/internal/* ./kitcom/internal/tsgo
|
||||
@git add ./kitcom/internal/
|
||||
@echo Cleaning up...
|
||||
@rm -rf @rm -rf typescript-go
|
||||
echo Successfully copied tsgo code and renamed packages.
|
||||
|
||||
.PHONY: vendor_tsgo
|
||||
20
go.work.sum
20
go.work.sum
@ -1,14 +1,26 @@
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/matryer/moq v0.6.0 h1:FCccG09c3o4cg3gnrZ+7ty5Pa/sjmN24BMHp/0pwhjQ=
|
||||
github.com/matryer/moq v0.6.0/go.mod h1:iEVhY/XBwFG/nbRyEf0oV+SqnTHZJ5wectzx7yT+y98=
|
||||
github.com/peter-evans/patience v0.3.0 h1:rX0JdJeepqdQl1Sk9c9uvorjYYzL2TfgLX1adqYm9cA=
|
||||
github.com/peter-evans/patience v0.3.0/go.mod h1:Kmxu5sY1NmBLFSStvXjX1wS9mIv7wMcP/ubucyMOAu0=
|
||||
github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
|
||||
github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
|
||||
golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ=
|
||||
golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc=
|
||||
golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA=
|
||||
golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w=
|
||||
golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
|
||||
golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
|
||||
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
|
||||
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
|
||||
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/telemetry v0.0.0-20251008203120-078029d740a8 h1:LvzTn0GQhWuvKH/kVRS3R3bVAsdQWI7hvfLHGgh9+lU=
|
||||
golang.org/x/telemetry v0.0.0-20251008203120-078029d740a8/go.mod h1:Pi4ztBfryZoJEkyFTI5/Ocsu2jXyDr6iSdgJiYE/uwE=
|
||||
golang.org/x/term v0.35.0 h1:bZBVKBudEyhRcajGcNc3jIfWPqV4y/Kt2XcoigOWtDQ=
|
||||
golang.org/x/term v0.35.0/go.mod h1:TPGtkTLesOwf2DE8CgVYiZinHAOuy5AYUYT1lENIZnA=
|
||||
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=
|
||||
golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s=
|
||||
mvdan.cc/gofumpt v0.9.1 h1:p5YT2NfFWsYyTieYgwcQ8aKV3xRvFH4uuN/zB2gBbMQ=
|
||||
mvdan.cc/gofumpt v0.9.1/go.mod h1:3xYtNemnKiXaTh6R4VtlqDATFwBbdXI8lJvH/4qk7mw=
|
||||
|
||||
@ -2,4 +2,9 @@ module efprojects.com/kitten-ipc/kitcom
|
||||
|
||||
go 1.25.1
|
||||
|
||||
require golang.org/x/tools v0.38.0 // indirect
|
||||
require (
|
||||
github.com/go-json-experiment/json v0.0.0-20250910080747-cc2cfa0554c3 // indirect
|
||||
golang.org/x/sync v0.17.0 // indirect
|
||||
golang.org/x/sys v0.37.0 // indirect
|
||||
golang.org/x/text v0.29.0 // indirect
|
||||
)
|
||||
|
||||
@ -1,2 +1,16 @@
|
||||
golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
|
||||
golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
|
||||
github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ=
|
||||
github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||
github.com/go-json-experiment/json v0.0.0-20250910080747-cc2cfa0554c3 h1:02WINGfSX5w0Mn+F28UyRoSt9uvMhKguwWMlOAh6U/0=
|
||||
github.com/go-json-experiment/json v0.0.0-20250910080747-cc2cfa0554c3/go.mod h1:uNVvRXArCGbZ508SxYYTC5v1JWoz2voff5pm25jU1Ok=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/microsoft/typescript-go v0.0.0-20251013215234-fd15f297d473 h1:LdsGx1nLOzsu2a1QORtbhZLaAlrQTbMKq3MlpuU3cCQ=
|
||||
github.com/microsoft/typescript-go v0.0.0-20251013215234-fd15f297d473/go.mod h1:/yWoZzcFKn2eQjB4E+kfEhQ/iGVrFKYswH1ZW+jWZu8=
|
||||
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
|
||||
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
|
||||
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
|
||||
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
|
||||
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
|
||||
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
|
||||
|
||||
320
kitcom/internal/tsgo/api/api.go
Normal file
320
kitcom/internal/tsgo/api/api.go
Normal file
@ -0,0 +1,320 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/api/encoder"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/astnav"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/checker"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ls"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/project"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/project/logging"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/tsoptions"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/vfs"
|
||||
"github.com/go-json-experiment/json"
|
||||
)
|
||||
|
||||
type handleMap[T any] map[Handle[T]]*T
|
||||
|
||||
type APIInit struct {
|
||||
Logger logging.Logger
|
||||
FS vfs.FS
|
||||
SessionOptions *project.SessionOptions
|
||||
}
|
||||
|
||||
type API struct {
|
||||
logger logging.Logger
|
||||
session *project.Session
|
||||
|
||||
projects map[Handle[project.Project]]tspath.Path
|
||||
filesMu sync.Mutex
|
||||
files handleMap[ast.SourceFile]
|
||||
symbolsMu sync.Mutex
|
||||
symbols handleMap[ast.Symbol]
|
||||
typesMu sync.Mutex
|
||||
types handleMap[checker.Type]
|
||||
}
|
||||
|
||||
func NewAPI(init *APIInit) *API {
|
||||
api := &API{
|
||||
session: project.NewSession(&project.SessionInit{
|
||||
Logger: init.Logger,
|
||||
FS: init.FS,
|
||||
Options: init.SessionOptions,
|
||||
}),
|
||||
projects: make(map[Handle[project.Project]]tspath.Path),
|
||||
files: make(handleMap[ast.SourceFile]),
|
||||
symbols: make(handleMap[ast.Symbol]),
|
||||
types: make(handleMap[checker.Type]),
|
||||
}
|
||||
|
||||
return api
|
||||
}
|
||||
|
||||
func (api *API) HandleRequest(ctx context.Context, method string, payload []byte) ([]byte, error) {
|
||||
params, err := unmarshalPayload(method, payload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
switch Method(method) {
|
||||
case MethodRelease:
|
||||
if id, ok := params.(*string); ok {
|
||||
return nil, api.releaseHandle(*id)
|
||||
} else {
|
||||
return nil, fmt.Errorf("expected string for release handle, got %T", params)
|
||||
}
|
||||
case MethodGetSourceFile:
|
||||
params := params.(*GetSourceFileParams)
|
||||
sourceFile, err := api.GetSourceFile(params.Project, params.FileName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return encoder.EncodeSourceFile(sourceFile, string(FileHandle(sourceFile)))
|
||||
case MethodParseConfigFile:
|
||||
return encodeJSON(api.ParseConfigFile(params.(*ParseConfigFileParams).FileName))
|
||||
case MethodLoadProject:
|
||||
return encodeJSON(api.LoadProject(ctx, params.(*LoadProjectParams).ConfigFileName))
|
||||
case MethodGetSymbolAtPosition:
|
||||
params := params.(*GetSymbolAtPositionParams)
|
||||
return encodeJSON(api.GetSymbolAtPosition(ctx, params.Project, params.FileName, int(params.Position)))
|
||||
case MethodGetSymbolsAtPositions:
|
||||
params := params.(*GetSymbolsAtPositionsParams)
|
||||
return encodeJSON(core.TryMap(params.Positions, func(position uint32) (any, error) {
|
||||
return api.GetSymbolAtPosition(ctx, params.Project, params.FileName, int(position))
|
||||
}))
|
||||
case MethodGetSymbolAtLocation:
|
||||
params := params.(*GetSymbolAtLocationParams)
|
||||
return encodeJSON(api.GetSymbolAtLocation(ctx, params.Project, params.Location))
|
||||
case MethodGetSymbolsAtLocations:
|
||||
params := params.(*GetSymbolsAtLocationsParams)
|
||||
return encodeJSON(core.TryMap(params.Locations, func(location Handle[ast.Node]) (any, error) {
|
||||
return api.GetSymbolAtLocation(ctx, params.Project, location)
|
||||
}))
|
||||
case MethodGetTypeOfSymbol:
|
||||
params := params.(*GetTypeOfSymbolParams)
|
||||
return encodeJSON(api.GetTypeOfSymbol(ctx, params.Project, params.Symbol))
|
||||
case MethodGetTypesOfSymbols:
|
||||
params := params.(*GetTypesOfSymbolsParams)
|
||||
return encodeJSON(core.TryMap(params.Symbols, func(symbol Handle[ast.Symbol]) (any, error) {
|
||||
return api.GetTypeOfSymbol(ctx, params.Project, symbol)
|
||||
}))
|
||||
default:
|
||||
return nil, fmt.Errorf("unhandled API method %q", method)
|
||||
}
|
||||
}
|
||||
|
||||
func (api *API) Close() {
|
||||
api.session.Close()
|
||||
}
|
||||
|
||||
func (api *API) ParseConfigFile(configFileName string) (*ConfigFileResponse, error) {
|
||||
configFileName = api.toAbsoluteFileName(configFileName)
|
||||
configFileContent, ok := api.session.FS().ReadFile(configFileName)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("could not read file %q", configFileName)
|
||||
}
|
||||
configDir := tspath.GetDirectoryPath(configFileName)
|
||||
tsConfigSourceFile := tsoptions.NewTsconfigSourceFileFromFilePath(configFileName, api.toPath(configFileName), configFileContent)
|
||||
parsedCommandLine := tsoptions.ParseJsonSourceFileConfigFileContent(
|
||||
tsConfigSourceFile,
|
||||
api.session,
|
||||
configDir,
|
||||
nil, /*existingOptions*/
|
||||
configFileName,
|
||||
nil, /*resolutionStack*/
|
||||
nil, /*extraFileExtensions*/
|
||||
nil, /*extendedConfigCache*/
|
||||
)
|
||||
return &ConfigFileResponse{
|
||||
FileNames: parsedCommandLine.FileNames(),
|
||||
Options: parsedCommandLine.CompilerOptions(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (api *API) LoadProject(ctx context.Context, configFileName string) (*ProjectResponse, error) {
|
||||
project, err := api.session.OpenProject(ctx, api.toAbsoluteFileName(configFileName))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
data := NewProjectResponse(project)
|
||||
api.projects[data.Id] = project.ConfigFilePath()
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (api *API) GetSymbolAtPosition(ctx context.Context, projectId Handle[project.Project], fileName string, position int) (*SymbolResponse, error) {
|
||||
projectPath, ok := api.projects[projectId]
|
||||
if !ok {
|
||||
return nil, errors.New("project ID not found")
|
||||
}
|
||||
snapshot, release := api.session.Snapshot()
|
||||
defer release()
|
||||
project := snapshot.ProjectCollection.GetProjectByPath(projectPath)
|
||||
if project == nil {
|
||||
return nil, errors.New("project not found")
|
||||
}
|
||||
|
||||
languageService := ls.NewLanguageService(project.GetProgram(), snapshot)
|
||||
symbol, err := languageService.GetSymbolAtPosition(ctx, fileName, position)
|
||||
if err != nil || symbol == nil {
|
||||
return nil, err
|
||||
}
|
||||
data := NewSymbolResponse(symbol)
|
||||
api.symbolsMu.Lock()
|
||||
defer api.symbolsMu.Unlock()
|
||||
api.symbols[data.Id] = symbol
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (api *API) GetSymbolAtLocation(ctx context.Context, projectId Handle[project.Project], location Handle[ast.Node]) (*SymbolResponse, error) {
|
||||
projectPath, ok := api.projects[projectId]
|
||||
if !ok {
|
||||
return nil, errors.New("project ID not found")
|
||||
}
|
||||
snapshot, release := api.session.Snapshot()
|
||||
defer release()
|
||||
project := snapshot.ProjectCollection.GetProjectByPath(projectPath)
|
||||
if project == nil {
|
||||
return nil, errors.New("project not found")
|
||||
}
|
||||
|
||||
fileHandle, pos, kind, err := parseNodeHandle(location)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
api.filesMu.Lock()
|
||||
defer api.filesMu.Unlock()
|
||||
sourceFile, ok := api.files[fileHandle]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("file %q not found", fileHandle)
|
||||
}
|
||||
token := astnav.GetTokenAtPosition(sourceFile, pos)
|
||||
if token == nil {
|
||||
return nil, fmt.Errorf("token not found at position %d in file %q", pos, sourceFile.FileName())
|
||||
}
|
||||
node := ast.FindAncestorKind(token, kind)
|
||||
if node == nil {
|
||||
return nil, fmt.Errorf("node of kind %s not found at position %d in file %q", kind.String(), pos, sourceFile.FileName())
|
||||
}
|
||||
languageService := ls.NewLanguageService(project.GetProgram(), snapshot)
|
||||
symbol := languageService.GetSymbolAtLocation(ctx, node)
|
||||
if symbol == nil {
|
||||
return nil, nil
|
||||
}
|
||||
data := NewSymbolResponse(symbol)
|
||||
api.symbolsMu.Lock()
|
||||
defer api.symbolsMu.Unlock()
|
||||
api.symbols[data.Id] = symbol
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (api *API) GetTypeOfSymbol(ctx context.Context, projectId Handle[project.Project], symbolHandle Handle[ast.Symbol]) (*TypeResponse, error) {
|
||||
projectPath, ok := api.projects[projectId]
|
||||
if !ok {
|
||||
return nil, errors.New("project ID not found")
|
||||
}
|
||||
snapshot, release := api.session.Snapshot()
|
||||
defer release()
|
||||
project := snapshot.ProjectCollection.GetProjectByPath(projectPath)
|
||||
if project == nil {
|
||||
return nil, errors.New("project not found")
|
||||
}
|
||||
|
||||
api.symbolsMu.Lock()
|
||||
defer api.symbolsMu.Unlock()
|
||||
symbol, ok := api.symbols[symbolHandle]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("symbol %q not found", symbolHandle)
|
||||
}
|
||||
languageService := ls.NewLanguageService(project.GetProgram(), snapshot)
|
||||
t := languageService.GetTypeOfSymbol(ctx, symbol)
|
||||
if t == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return NewTypeData(t), nil
|
||||
}
|
||||
|
||||
func (api *API) GetSourceFile(projectId Handle[project.Project], fileName string) (*ast.SourceFile, error) {
|
||||
projectPath, ok := api.projects[projectId]
|
||||
if !ok {
|
||||
return nil, errors.New("project ID not found")
|
||||
}
|
||||
snapshot, release := api.session.Snapshot()
|
||||
defer release()
|
||||
project := snapshot.ProjectCollection.GetProjectByPath(projectPath)
|
||||
if project == nil {
|
||||
return nil, errors.New("project not found")
|
||||
}
|
||||
|
||||
sourceFile := project.GetProgram().GetSourceFile(fileName)
|
||||
if sourceFile == nil {
|
||||
return nil, fmt.Errorf("source file %q not found", fileName)
|
||||
}
|
||||
api.filesMu.Lock()
|
||||
defer api.filesMu.Unlock()
|
||||
api.files[FileHandle(sourceFile)] = sourceFile
|
||||
return sourceFile, nil
|
||||
}
|
||||
|
||||
func (api *API) releaseHandle(handle string) error {
|
||||
switch handle[0] {
|
||||
case handlePrefixProject:
|
||||
projectId := Handle[project.Project](handle)
|
||||
_, ok := api.projects[projectId]
|
||||
if !ok {
|
||||
return fmt.Errorf("project %q not found", handle)
|
||||
}
|
||||
delete(api.projects, projectId)
|
||||
case handlePrefixFile:
|
||||
fileId := Handle[ast.SourceFile](handle)
|
||||
api.filesMu.Lock()
|
||||
defer api.filesMu.Unlock()
|
||||
_, ok := api.files[fileId]
|
||||
if !ok {
|
||||
return fmt.Errorf("file %q not found", handle)
|
||||
}
|
||||
delete(api.files, fileId)
|
||||
case handlePrefixSymbol:
|
||||
symbolId := Handle[ast.Symbol](handle)
|
||||
api.symbolsMu.Lock()
|
||||
defer api.symbolsMu.Unlock()
|
||||
_, ok := api.symbols[symbolId]
|
||||
if !ok {
|
||||
return fmt.Errorf("symbol %q not found", handle)
|
||||
}
|
||||
delete(api.symbols, symbolId)
|
||||
case handlePrefixType:
|
||||
typeId := Handle[checker.Type](handle)
|
||||
api.typesMu.Lock()
|
||||
defer api.typesMu.Unlock()
|
||||
_, ok := api.types[typeId]
|
||||
if !ok {
|
||||
return fmt.Errorf("type %q not found", handle)
|
||||
}
|
||||
delete(api.types, typeId)
|
||||
default:
|
||||
return fmt.Errorf("unhandled handle type %q", handle[0])
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (api *API) toAbsoluteFileName(fileName string) string {
|
||||
return tspath.GetNormalizedAbsolutePath(fileName, api.session.GetCurrentDirectory())
|
||||
}
|
||||
|
||||
func (api *API) toPath(fileName string) tspath.Path {
|
||||
return tspath.ToPath(fileName, api.session.GetCurrentDirectory(), api.session.FS().UseCaseSensitiveFileNames())
|
||||
}
|
||||
|
||||
func encodeJSON(v any, err error) ([]byte, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return json.Marshal(v)
|
||||
}
|
||||
815
kitcom/internal/tsgo/api/encoder/encoder.go
Normal file
815
kitcom/internal/tsgo/api/encoder/encoder.go
Normal file
@ -0,0 +1,815 @@
|
||||
package encoder
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
)
|
||||
|
||||
const (
|
||||
NodeOffsetKind = iota * 4
|
||||
NodeOffsetPos
|
||||
NodeOffsetEnd
|
||||
NodeOffsetNext
|
||||
NodeOffsetParent
|
||||
NodeOffsetData
|
||||
// NodeSize is the number of bytes that represents a single node in the encoded format.
|
||||
NodeSize
|
||||
)
|
||||
|
||||
const (
|
||||
NodeDataTypeChildren uint32 = iota << 30
|
||||
NodeDataTypeString
|
||||
NodeDataTypeExtendedData
|
||||
)
|
||||
|
||||
const (
|
||||
NodeDataTypeMask uint32 = 0xc0_00_00_00
|
||||
NodeDataChildMask uint32 = 0x00_00_00_ff
|
||||
NodeDataStringIndexMask uint32 = 0x00_ff_ff_ff
|
||||
)
|
||||
|
||||
const (
|
||||
SyntaxKindNodeList uint32 = 1<<32 - 1
|
||||
)
|
||||
|
||||
const (
|
||||
HeaderOffsetMetadata = iota * 4
|
||||
HeaderOffsetStringOffsets
|
||||
HeaderOffsetStringData
|
||||
HeaderOffsetExtendedData
|
||||
HeaderOffsetNodes
|
||||
HeaderSize
|
||||
)
|
||||
|
||||
const (
|
||||
ProtocolVersion uint8 = 1
|
||||
)
|
||||
|
||||
// Source File Binary Format
|
||||
// =========================
|
||||
//
|
||||
// The following defines a protocol for serializing TypeScript SourceFile objects to a compact binary format. All integer
|
||||
// values are little-endian.
|
||||
//
|
||||
// Overview
|
||||
// --------
|
||||
//
|
||||
// The format comprises six sections:
|
||||
//
|
||||
// | Section | Length | Description |
|
||||
// | ------------------ | ------------------ | ---------------------------------------------------------------------------------------- |
|
||||
// | Header | 20 bytes | Contains byte offsets to the start of each section. |
|
||||
// | String offsets | 8 bytes per string | Pairs of starting byte offsets and ending byte offsets into the **string data** section. |
|
||||
// | String data | variable | UTF-8 encoded string data. |
|
||||
// | Extended node data | variable | Extra data for some kinds of nodes. |
|
||||
// | Nodes | 24 bytes per node | Defines the AST structure of the file, with references to strings and extended data. |
|
||||
//
|
||||
// Header (20 bytes)
|
||||
// -----------------
|
||||
//
|
||||
// The header contains the following fields:
|
||||
//
|
||||
// | Byte offset | Type | Field |
|
||||
// | ----------- | ------ | ----------------------------------------- |
|
||||
// | 0 | uint8 | Protocol version |
|
||||
// | 1-4 | | Reserved |
|
||||
// | 4-8 | uint32 | Byte offset to string offsets section |
|
||||
// | 8-12 | uint32 | Byte offset to string data section |
|
||||
// | 12-16 | uint32 | Byte offset to extended node data section |
|
||||
// | 16-20 | uint32 | Byte offset to nodes section |
|
||||
//
|
||||
// String offsets (8 bytes per string)
|
||||
// -----------------------------------
|
||||
//
|
||||
// Each string offset entry consists of two 4-byte unsigned integers, representing the start and end byte offsets into the
|
||||
// **string data** section.
|
||||
//
|
||||
// String data (variable)
|
||||
// ----------------------
|
||||
//
|
||||
// The string data section contains UTF-8 encoded string data. In typical cases, the entirety of the string data is the
|
||||
// source file text, and individual nodes with string properties reference their positional slice of the file text. In
|
||||
// cases where a node's string property is not equal to the slice of file text at its position, the unique string is
|
||||
// appended to the string data section after the file text.
|
||||
//
|
||||
// Extended node data (variable)
|
||||
// -----------------------------
|
||||
//
|
||||
// The extended node data section contains additional data for specific node types. The length and meaning of each entry
|
||||
// is defined by the node type.
|
||||
//
|
||||
// Currently, the only node types that use this section are `TemplateHead`, `TemplateMiddle`, `TemplateTail`, and
|
||||
// `SourceFile`. The extended data format for the first three is:
|
||||
//
|
||||
// | Byte offset | Type | Field |
|
||||
// | ----------- | ------ | ------------------------------------------------ |
|
||||
// | 0-4 | uint32 | Index of `text` in the string offsets section |
|
||||
// | 4-8 | uint32 | Index of `rawText` in the string offsets section |
|
||||
// | 8-12 | uint32 | Value of `templateFlags` |
|
||||
//
|
||||
// and for `SourceFile` is:
|
||||
//
|
||||
// | Byte offset | Type | Field |
|
||||
// | ----------- | ------ | ------------------------------------------------- |
|
||||
// | 0-4 | uint32 | Index of `text` in the string offsets section |
|
||||
// | 4-8 | uint32 | Index of `fileName` in the string offsets section |
|
||||
// | 8-12 | uint32 | Index of `id` in the string offsets section |
|
||||
//
|
||||
// Nodes (24 bytes per node)
|
||||
// -------------------------
|
||||
//
|
||||
// The nodes section contains the AST structure of the file. Nodes are represented in a flat array in source order,
|
||||
// heavily inspired by https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-11/. Each node has the following
|
||||
// structure:
|
||||
//
|
||||
// | Byte offset | Type | Field |
|
||||
// | ----------- | ------ | -------------------------- |
|
||||
// | 0-4 | uint32 | Kind |
|
||||
// | 4-8 | uint32 | Pos |
|
||||
// | 8-12 | uint32 | End |
|
||||
// | 12-16 | uint32 | Node index of next sibling |
|
||||
// | 16-20 | uint32 | Node index of parent |
|
||||
// | 20-24 | | Node data |
|
||||
//
|
||||
// The first 24 bytes of the nodes section are zeros representing a nil node, such that nodes without a parent or next
|
||||
// sibling can unambiuously use `0` for those indices.
|
||||
//
|
||||
// NodeLists are represented as normal nodes with the special `kind` value `0xff_ff_ff_ff`. They are considered the parent
|
||||
// of their contents in the encoded format. A client reconstructing an AST similar to TypeScript's internal representation
|
||||
// should instead set the `parent` pointers of a NodeList's children to the NodeList's parent. A NodeList's `data` field
|
||||
// is the uint32 length of the list, and does not use one of the data types described below.
|
||||
//
|
||||
// For node types other than NodeList, the node data field encodes one of the following, determined by the first 2 bits of
|
||||
// the field:
|
||||
//
|
||||
// | Value | Data type | Description |
|
||||
// | ----- | --------- | ------------------------------------------------------------------------------------ |
|
||||
// | 0b00 | Children | Disambiguates which named properties of the node its children should be assigned to. |
|
||||
// | 0b01 | String | The index of the node's string property in the **string offsets** section. |
|
||||
// | 0b10 | Extended | The byte offset of the node's extended data into the **extended node data** section. |
|
||||
// | 0b11 | Reserved | Reserved for future use. |
|
||||
//
|
||||
// In all node data types, the remaining 6 bits of the first byte are used to encode booleans specific to the node type:
|
||||
//
|
||||
// | Node type | Bits 2-5 | Bit 1 | Bit 0 |
|
||||
// | ------------------------- | -------- | ------------- | ------------------------------- |
|
||||
// | `ImportSpecifier` | | | `isTypeOnly` |
|
||||
// | `ImportClause` | | | `isTypeOnly` |
|
||||
// | `ExportSpecifier` | | | `isTypeOnly` |
|
||||
// | `ImportEqualsDeclaration` | | | `isTypeOnly` |
|
||||
// | `ExportDeclaration` | | | `isTypeOnly` |
|
||||
// | `ImportTypeNode` | | | `isTypeOf` |
|
||||
// | `ExportAssignment` | | | `isExportEquals` |
|
||||
// | `Block` | | | `multiline` |
|
||||
// | `ArrayLiteralExpression` | | | `multiline` |
|
||||
// | `ObjectLiteralExpression` | | | `multiline` |
|
||||
// | `JsxText` | | | `containsOnlyTriviaWhiteSpaces` |
|
||||
// | `JSDocTypeLiteral` | | | `isArrayType` |
|
||||
// | `JsDocPropertyTag` | | `isNameFirst` | `isBracketed` |
|
||||
// | `JsDocParameterTag` | | `isNameFirst` | `isBracketed` |
|
||||
// | `VariableDeclarationList` | | is `const` | is `let` |
|
||||
// | `ImportAttributes` | | is `assert` | `multiline` |
|
||||
//
|
||||
// The remaining 3 bytes of the node data field vary by data type:
|
||||
//
|
||||
// ### Children (0b00)
|
||||
//
|
||||
// If a node has fewer children than its type allows, additional data is needed to determine which properties the children
|
||||
// correspond to. The last byte of the 4-byte data field is a bitmask representing the child properties of the node type,
|
||||
// in visitor order, where `1` indicates that the child at that property is present and `0` indicates that the property is
|
||||
// nil. For example, a `MethodDeclaration` has the following child properties:
|
||||
//
|
||||
// | Property name | Bit position |
|
||||
// | -------------- | ------------ |
|
||||
// | modifiers | 0 |
|
||||
// | asteriskToken | 1 |
|
||||
// | name | 2 |
|
||||
// | postfixToken | 3 |
|
||||
// | typeParameters | 4 |
|
||||
// | parameters | 5 |
|
||||
// | returnType | 6 |
|
||||
// | body | 7 |
|
||||
//
|
||||
// A bitmask with value `0b01100101` would indicate that the next four direct descendants (i.e., node records that have a
|
||||
// `parent` set to the node index of the `MethodDeclaration`) of the node are its `modifiers`, `name`, `parameters`, and
|
||||
// `body` properties, in that order. The remaining properties are nil. (To reconstruct the node with named properties, the
|
||||
// client must consult a static table of each node type's child property names.)
|
||||
//
|
||||
// The bitmask may be zero for node types that can only have a single child, since no disambiguation is needed.
|
||||
// Additionally, the children data type may be used for nodes that can never have children, but do not require other
|
||||
// data types.
|
||||
//
|
||||
// ### String (0b01)
|
||||
//
|
||||
// The string data type is used for nodes with a single string property. (Currently, the name of that property is always
|
||||
// `text`.) The last three bytes of the 4-byte data field form a single 24-bit unsigned integer (i.e.,
|
||||
// `uint32(0x00_ff_ff_ff & node.data)`) _N_ that is an index into the **string offsets** section. The *N*th 32-bit
|
||||
// unsigned integer in the **string offsets** section is the byte offset of the start of the string in the **string data**
|
||||
// section, and the *N+1*th 32-bit unsigned integer is the byte offset of the end of the string in the
|
||||
// **string data** section.
|
||||
//
|
||||
// ### Extended (0b10)
|
||||
//
|
||||
// The extended data type is used for nodes with properties that don't fit into either the children or string data types.
|
||||
// The last three bytes of the 4-byte data field form a single 24-bit unsigned integer (i.e.,
|
||||
// `uint32(0x00_ff_ff_ff & node.data)`) _N_ that is a byte offset into the **extended node data** section. The length and
|
||||
// meaning of the data at that offset is defined by the node type. See the **Extended node data** section for details on
|
||||
// the format of the extended data for specific node types.
|
||||
|
||||
func EncodeSourceFile(sourceFile *ast.SourceFile, id string) ([]byte, error) {
|
||||
var parentIndex, nodeCount, prevIndex uint32
|
||||
var extendedData []byte
|
||||
strs := newStringTable(sourceFile.Text(), sourceFile.TextCount)
|
||||
nodes := make([]byte, 0, (sourceFile.NodeCount+1)*NodeSize)
|
||||
|
||||
visitor := &ast.NodeVisitor{
|
||||
Hooks: ast.NodeVisitorHooks{
|
||||
VisitNodes: func(nodeList *ast.NodeList, visitor *ast.NodeVisitor) *ast.NodeList {
|
||||
if nodeList == nil || len(nodeList.Nodes) == 0 {
|
||||
return nodeList
|
||||
}
|
||||
|
||||
nodeCount++
|
||||
if prevIndex != 0 {
|
||||
// this is the next sibling of `prevNode`
|
||||
b0, b1, b2, b3 := uint8(nodeCount), uint8(nodeCount>>8), uint8(nodeCount>>16), uint8(nodeCount>>24)
|
||||
nodes[prevIndex*NodeSize+NodeOffsetNext+0] = b0
|
||||
nodes[prevIndex*NodeSize+NodeOffsetNext+1] = b1
|
||||
nodes[prevIndex*NodeSize+NodeOffsetNext+2] = b2
|
||||
nodes[prevIndex*NodeSize+NodeOffsetNext+3] = b3
|
||||
}
|
||||
|
||||
nodes = appendUint32s(nodes, SyntaxKindNodeList, uint32(nodeList.Pos()), uint32(nodeList.End()), 0, parentIndex, uint32(len(nodeList.Nodes)))
|
||||
|
||||
saveParentIndex := parentIndex
|
||||
|
||||
currentIndex := nodeCount
|
||||
prevIndex = 0
|
||||
parentIndex = currentIndex
|
||||
visitor.VisitSlice(nodeList.Nodes)
|
||||
prevIndex = currentIndex
|
||||
parentIndex = saveParentIndex
|
||||
|
||||
return nodeList
|
||||
},
|
||||
VisitModifiers: func(modifiers *ast.ModifierList, visitor *ast.NodeVisitor) *ast.ModifierList {
|
||||
if modifiers != nil && len(modifiers.Nodes) > 0 {
|
||||
visitor.Hooks.VisitNodes(&modifiers.NodeList, visitor)
|
||||
}
|
||||
return modifiers
|
||||
},
|
||||
},
|
||||
}
|
||||
visitor.Visit = func(node *ast.Node) *ast.Node {
|
||||
nodeCount++
|
||||
if prevIndex != 0 {
|
||||
// this is the next sibling of `prevNode`
|
||||
b0, b1, b2, b3 := uint8(nodeCount), uint8(nodeCount>>8), uint8(nodeCount>>16), uint8(nodeCount>>24)
|
||||
nodes[prevIndex*NodeSize+NodeOffsetNext+0] = b0
|
||||
nodes[prevIndex*NodeSize+NodeOffsetNext+1] = b1
|
||||
nodes[prevIndex*NodeSize+NodeOffsetNext+2] = b2
|
||||
nodes[prevIndex*NodeSize+NodeOffsetNext+3] = b3
|
||||
}
|
||||
|
||||
nodes = appendUint32s(nodes, uint32(node.Kind), uint32(node.Pos()), uint32(node.End()), 0, parentIndex, getNodeData(node, strs, &extendedData))
|
||||
|
||||
saveParentIndex := parentIndex
|
||||
|
||||
currentIndex := nodeCount
|
||||
prevIndex = 0
|
||||
parentIndex = currentIndex
|
||||
visitor.VisitEachChild(node)
|
||||
prevIndex = currentIndex
|
||||
parentIndex = saveParentIndex
|
||||
return node
|
||||
}
|
||||
|
||||
nodes = appendUint32s(nodes, 0, 0, 0, 0, 0, 0)
|
||||
|
||||
nodeCount++
|
||||
parentIndex++
|
||||
nodes = appendUint32s(nodes, uint32(sourceFile.Kind), uint32(sourceFile.Pos()), uint32(sourceFile.End()), 0, 0, getSourceFileData(sourceFile, id, strs, &extendedData))
|
||||
|
||||
visitor.VisitEachChild(sourceFile.AsNode())
|
||||
|
||||
metadata := uint32(ProtocolVersion) << 24
|
||||
offsetStringTableOffsets := HeaderSize
|
||||
offsetStringTableData := HeaderSize + len(strs.offsets)*4
|
||||
offsetExtendedData := offsetStringTableData + strs.stringLength()
|
||||
offsetNodes := offsetExtendedData + len(extendedData)
|
||||
|
||||
header := []uint32{
|
||||
metadata,
|
||||
uint32(offsetStringTableOffsets),
|
||||
uint32(offsetStringTableData),
|
||||
uint32(offsetExtendedData),
|
||||
uint32(offsetNodes),
|
||||
}
|
||||
|
||||
var headerBytes, strsBytes []byte
|
||||
headerBytes = appendUint32s(nil, header...)
|
||||
strsBytes = strs.encode()
|
||||
|
||||
return slices.Concat(
|
||||
headerBytes,
|
||||
strsBytes,
|
||||
extendedData,
|
||||
nodes,
|
||||
), nil
|
||||
}
|
||||
|
||||
func appendUint32s(buf []byte, values ...uint32) []byte {
|
||||
for _, value := range values {
|
||||
var err error
|
||||
if buf, err = binary.Append(buf, binary.LittleEndian, value); err != nil {
|
||||
// The only error binary.Append can return is for values that are not fixed-size.
|
||||
// This can never happen here, since we are always appending uint32.
|
||||
panic(fmt.Sprintf("failed to append uint32: %v", err))
|
||||
}
|
||||
}
|
||||
return buf
|
||||
}
|
||||
|
||||
func getSourceFileData(sourceFile *ast.SourceFile, id string, strs *stringTable, extendedData *[]byte) uint32 {
|
||||
t := NodeDataTypeExtendedData
|
||||
extendedDataOffset := len(*extendedData)
|
||||
textIndex := strs.add(sourceFile.Text(), sourceFile.Kind, sourceFile.Pos(), sourceFile.End())
|
||||
fileNameIndex := strs.add(sourceFile.FileName(), 0, 0, 0)
|
||||
idIndex := strs.add(id, 0, 0, 0)
|
||||
*extendedData = appendUint32s(*extendedData, textIndex, fileNameIndex, idIndex)
|
||||
return t | uint32(extendedDataOffset)
|
||||
}
|
||||
|
||||
func getNodeData(node *ast.Node, strs *stringTable, extendedData *[]byte) uint32 {
|
||||
t := getNodeDataType(node)
|
||||
switch t {
|
||||
case NodeDataTypeChildren:
|
||||
return t | getNodeDefinedData(node) | uint32(getChildrenPropertyMask(node))
|
||||
case NodeDataTypeString:
|
||||
return t | getNodeDefinedData(node) | recordNodeStrings(node, strs)
|
||||
case NodeDataTypeExtendedData:
|
||||
return t | getNodeDefinedData(node) | recordExtendedData(node, strs, extendedData)
|
||||
default:
|
||||
panic("unreachable")
|
||||
}
|
||||
}
|
||||
|
||||
func getNodeDataType(node *ast.Node) uint32 {
|
||||
switch node.Kind {
|
||||
case ast.KindJsxText,
|
||||
ast.KindIdentifier,
|
||||
ast.KindPrivateIdentifier,
|
||||
ast.KindStringLiteral,
|
||||
ast.KindNumericLiteral,
|
||||
ast.KindBigIntLiteral,
|
||||
ast.KindRegularExpressionLiteral,
|
||||
ast.KindNoSubstitutionTemplateLiteral,
|
||||
ast.KindJSDocText:
|
||||
return NodeDataTypeString
|
||||
case ast.KindTemplateHead,
|
||||
ast.KindTemplateMiddle,
|
||||
ast.KindTemplateTail,
|
||||
ast.KindSourceFile:
|
||||
return NodeDataTypeExtendedData
|
||||
default:
|
||||
return NodeDataTypeChildren
|
||||
}
|
||||
}
|
||||
|
||||
// getChildrenPropertyMask returns a mask of which children properties are present in the node.
|
||||
// It is defined for node kinds that have more than one property that is a pointer to a child node.
|
||||
// Example: QualifiedName has two children properties: Left and Right, which are visited in that order.
|
||||
// result&1 is non-zero if Left is present, and result&2 is non-zero if Right is present. If the client
|
||||
// knows that QualifiedName has properties ["Left", "Right"] and sees an encoded node with only one
|
||||
// child, it can use the mask to determine which property is present.
|
||||
func getChildrenPropertyMask(node *ast.Node) uint8 {
|
||||
switch node.Kind {
|
||||
case ast.KindQualifiedName:
|
||||
n := node.AsQualifiedName()
|
||||
return (boolToByte(n.Left != nil) << 0) | (boolToByte(n.Right != nil) << 1)
|
||||
case ast.KindTypeParameter:
|
||||
n := node.AsTypeParameter()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.Name() != nil) << 1) | (boolToByte(n.Constraint != nil) << 2) | (boolToByte(n.DefaultType != nil) << 3)
|
||||
case ast.KindIfStatement:
|
||||
n := node.AsIfStatement()
|
||||
return (boolToByte(n.Expression != nil) << 0) | (boolToByte(n.ThenStatement != nil) << 1) | (boolToByte(n.ElseStatement != nil) << 2)
|
||||
case ast.KindDoStatement:
|
||||
n := node.AsDoStatement()
|
||||
return (boolToByte(n.Statement != nil) << 0) | (boolToByte(n.Expression != nil) << 1)
|
||||
case ast.KindWhileStatement:
|
||||
n := node.AsWhileStatement()
|
||||
return (boolToByte(n.Expression != nil) << 0) | (boolToByte(n.Statement != nil) << 1)
|
||||
case ast.KindForStatement:
|
||||
n := node.AsForStatement()
|
||||
return (boolToByte(n.Initializer != nil) << 0) | (boolToByte(n.Condition != nil) << 1) | (boolToByte(n.Incrementor != nil) << 2) | (boolToByte(n.Statement != nil) << 3)
|
||||
case ast.KindForInStatement, ast.KindForOfStatement:
|
||||
n := node.AsForInOrOfStatement()
|
||||
return (boolToByte(n.AwaitModifier != nil) << 0) | (boolToByte(n.Initializer != nil) << 1) | (boolToByte(n.Expression != nil) << 2) | (boolToByte(n.Statement != nil) << 3)
|
||||
case ast.KindWithStatement:
|
||||
n := node.AsWithStatement()
|
||||
return (boolToByte(n.Expression != nil) << 0) | (boolToByte(n.Statement != nil) << 1)
|
||||
case ast.KindSwitchStatement:
|
||||
n := node.AsSwitchStatement()
|
||||
return (boolToByte(n.Expression != nil) << 0) | (boolToByte(n.CaseBlock != nil) << 1)
|
||||
case ast.KindCaseClause, ast.KindDefaultClause:
|
||||
n := node.AsCaseOrDefaultClause()
|
||||
return (boolToByte(n.Expression != nil) << 0) | (boolToByte(n.Statements != nil) << 1)
|
||||
case ast.KindTryStatement:
|
||||
n := node.AsTryStatement()
|
||||
return (boolToByte(n.TryBlock != nil) << 0) | (boolToByte(n.CatchClause != nil) << 1) | (boolToByte(n.FinallyBlock != nil) << 2)
|
||||
case ast.KindCatchClause:
|
||||
n := node.AsCatchClause()
|
||||
return (boolToByte(n.VariableDeclaration != nil) << 0) | (boolToByte(n.Block != nil) << 1)
|
||||
case ast.KindLabeledStatement:
|
||||
n := node.AsLabeledStatement()
|
||||
return (boolToByte(n.Label != nil) << 0) | (boolToByte(n.Statement != nil) << 1)
|
||||
case ast.KindVariableStatement:
|
||||
n := node.AsVariableStatement()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.DeclarationList != nil) << 1)
|
||||
case ast.KindVariableDeclaration:
|
||||
n := node.AsVariableDeclaration()
|
||||
return (boolToByte(n.Name() != nil) << 0) | (boolToByte(n.ExclamationToken != nil) << 1) | (boolToByte(n.Type != nil) << 2) | (boolToByte(n.Initializer != nil) << 3)
|
||||
case ast.KindParameter:
|
||||
n := node.AsParameterDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.DotDotDotToken != nil) << 1) | (boolToByte(n.Name() != nil) << 2) | (boolToByte(n.QuestionToken != nil) << 3) | (boolToByte(n.Type != nil) << 4) | (boolToByte(n.Initializer != nil) << 5)
|
||||
case ast.KindBindingElement:
|
||||
n := node.AsBindingElement()
|
||||
return (boolToByte(n.DotDotDotToken != nil) << 0) | (boolToByte(n.PropertyName != nil) << 1) | (boolToByte(n.Name() != nil) << 2) | (boolToByte(n.Initializer != nil) << 3)
|
||||
case ast.KindFunctionDeclaration:
|
||||
n := node.AsFunctionDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.AsteriskToken != nil) << 1) | (boolToByte(n.Name() != nil) << 2) | (boolToByte(n.TypeParameters != nil) << 3) | (boolToByte(n.Parameters != nil) << 4) | (boolToByte(n.Type != nil) << 5) | (boolToByte(n.Body != nil) << 6)
|
||||
case ast.KindInterfaceDeclaration:
|
||||
n := node.AsInterfaceDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.Name() != nil) << 1) | (boolToByte(n.TypeParameters != nil) << 2) | (boolToByte(n.HeritageClauses != nil) << 3) | (boolToByte(n.Members != nil) << 4)
|
||||
case ast.KindTypeAliasDeclaration:
|
||||
n := node.AsTypeAliasDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.Name() != nil) << 1) | (boolToByte(n.TypeParameters != nil) << 2) | (boolToByte(n.Type != nil) << 3)
|
||||
case ast.KindEnumMember:
|
||||
n := node.AsEnumMember()
|
||||
return (boolToByte(n.Name() != nil) << 0) | (boolToByte(n.Initializer != nil) << 1)
|
||||
case ast.KindEnumDeclaration:
|
||||
n := node.AsEnumDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.Name() != nil) << 1) | (boolToByte(n.Members != nil) << 2)
|
||||
case ast.KindModuleDeclaration:
|
||||
n := node.AsModuleDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.Name() != nil) << 1) | (boolToByte(n.Body != nil) << 2)
|
||||
case ast.KindImportEqualsDeclaration:
|
||||
n := node.AsImportEqualsDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.Name() != nil) << 1) | (boolToByte(n.ModuleReference != nil) << 2)
|
||||
case ast.KindImportDeclaration, ast.KindJSImportDeclaration:
|
||||
n := node.AsImportDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.ImportClause != nil) << 1) | (boolToByte(n.ModuleSpecifier != nil) << 2) | (boolToByte(n.Attributes != nil) << 3)
|
||||
case ast.KindImportSpecifier:
|
||||
n := node.AsImportSpecifier()
|
||||
return (boolToByte(n.PropertyName != nil) << 0) | (boolToByte(n.Name() != nil) << 1)
|
||||
case ast.KindImportClause:
|
||||
n := node.AsImportClause()
|
||||
return (boolToByte(n.Name() != nil) << 0) | (boolToByte(n.NamedBindings != nil) << 1)
|
||||
case ast.KindExportAssignment, ast.KindJSExportAssignment:
|
||||
n := node.AsExportAssignment()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.Expression != nil) << 1)
|
||||
case ast.KindNamespaceExportDeclaration:
|
||||
n := node.AsNamespaceExportDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.Name() != nil) << 1)
|
||||
case ast.KindExportDeclaration:
|
||||
n := node.AsExportDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.ExportClause != nil) << 1) | (boolToByte(n.ModuleSpecifier != nil) << 2) | (boolToByte(n.Attributes != nil) << 3)
|
||||
case ast.KindExportSpecifier:
|
||||
n := node.AsExportSpecifier()
|
||||
return (boolToByte(n.PropertyName != nil) << 0) | (boolToByte(n.Name() != nil) << 1)
|
||||
case ast.KindCallSignature:
|
||||
n := node.AsCallSignatureDeclaration()
|
||||
return (boolToByte(n.TypeParameters != nil) << 0) | (boolToByte(n.Parameters != nil) << 1) | (boolToByte(n.Type != nil) << 2)
|
||||
case ast.KindConstructSignature:
|
||||
n := node.AsConstructSignatureDeclaration()
|
||||
return (boolToByte(n.TypeParameters != nil) << 0) | (boolToByte(n.Parameters != nil) << 1) | (boolToByte(n.Type != nil) << 2)
|
||||
case ast.KindConstructor:
|
||||
n := node.AsConstructorDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.TypeParameters != nil) << 1) | (boolToByte(n.Parameters != nil) << 2) | (boolToByte(n.Type != nil) << 3) | (boolToByte(n.Body != nil) << 4)
|
||||
case ast.KindGetAccessor:
|
||||
n := node.AsGetAccessorDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.Name() != nil) << 1) | (boolToByte(n.TypeParameters != nil) << 2) | (boolToByte(n.Parameters != nil) << 3) | (boolToByte(n.Type != nil) << 4) | (boolToByte(n.Body != nil) << 5)
|
||||
case ast.KindSetAccessor:
|
||||
n := node.AsSetAccessorDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.Name() != nil) << 1) | (boolToByte(n.TypeParameters != nil) << 2) | (boolToByte(n.Parameters != nil) << 3) | (boolToByte(n.Type != nil) << 4) | (boolToByte(n.Body != nil) << 5)
|
||||
case ast.KindIndexSignature:
|
||||
n := node.AsIndexSignatureDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.Parameters != nil) << 1) | (boolToByte(n.Type != nil) << 2)
|
||||
case ast.KindMethodSignature:
|
||||
n := node.AsMethodSignatureDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.Name() != nil) << 1) | (boolToByte(n.PostfixToken != nil) << 2) | (boolToByte(n.TypeParameters != nil) << 3) | (boolToByte(n.Parameters != nil) << 4) | (boolToByte(n.Type != nil) << 5)
|
||||
case ast.KindMethodDeclaration:
|
||||
n := node.AsMethodDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.AsteriskToken != nil) << 1) | (boolToByte(n.Name() != nil) << 2) | (boolToByte(n.PostfixToken != nil) << 3) | (boolToByte(n.TypeParameters != nil) << 4) | (boolToByte(n.Parameters != nil) << 5) | (boolToByte(n.Type != nil) << 6) | (boolToByte(n.Body != nil) << 7)
|
||||
case ast.KindPropertySignature:
|
||||
n := node.AsPropertySignatureDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.Name() != nil) << 1) | (boolToByte(n.PostfixToken != nil) << 2) | (boolToByte(n.Type != nil) << 3) | (boolToByte(n.Initializer != nil) << 4)
|
||||
case ast.KindPropertyDeclaration:
|
||||
n := node.AsPropertyDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.Name() != nil) << 1) | (boolToByte(n.PostfixToken != nil) << 2) | (boolToByte(n.Type != nil) << 3) | (boolToByte(n.Initializer != nil) << 4)
|
||||
case ast.KindBinaryExpression:
|
||||
n := node.AsBinaryExpression()
|
||||
return (boolToByte(n.Left != nil) << 0) | (boolToByte(n.OperatorToken != nil) << 1) | (boolToByte(n.Right != nil) << 2)
|
||||
case ast.KindYieldExpression:
|
||||
n := node.AsYieldExpression()
|
||||
return (boolToByte(n.AsteriskToken != nil) << 0) | (boolToByte(n.Expression != nil) << 1)
|
||||
case ast.KindArrowFunction:
|
||||
n := node.AsArrowFunction()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.TypeParameters != nil) << 1) | (boolToByte(n.Parameters != nil) << 2) | (boolToByte(n.Type != nil) << 3) | (boolToByte(n.EqualsGreaterThanToken != nil) << 4) | (boolToByte(n.Body != nil) << 5)
|
||||
case ast.KindFunctionExpression:
|
||||
n := node.AsFunctionExpression()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.AsteriskToken != nil) << 1) | (boolToByte(n.Name() != nil) << 2) | (boolToByte(n.TypeParameters != nil) << 3) | (boolToByte(n.Parameters != nil) << 4) | (boolToByte(n.Type != nil) << 5) | (boolToByte(n.Body != nil) << 6)
|
||||
case ast.KindAsExpression:
|
||||
n := node.AsAsExpression()
|
||||
return (boolToByte(n.Expression != nil) << 0) | (boolToByte(n.Type != nil) << 1)
|
||||
case ast.KindSatisfiesExpression:
|
||||
n := node.AsSatisfiesExpression()
|
||||
return (boolToByte(n.Expression != nil) << 0) | (boolToByte(n.Type != nil) << 1)
|
||||
case ast.KindConditionalExpression:
|
||||
n := node.AsConditionalExpression()
|
||||
return (boolToByte(n.Condition != nil) << 0) | (boolToByte(n.QuestionToken != nil) << 1) | (boolToByte(n.WhenTrue != nil) << 2) | (boolToByte(n.ColonToken != nil) << 3) | (boolToByte(n.WhenFalse != nil) << 4)
|
||||
case ast.KindPropertyAccessExpression:
|
||||
n := node.AsPropertyAccessExpression()
|
||||
return (boolToByte(n.Expression != nil) << 0) | (boolToByte(n.QuestionDotToken != nil) << 1) | (boolToByte(n.Name() != nil) << 2)
|
||||
case ast.KindElementAccessExpression:
|
||||
n := node.AsElementAccessExpression()
|
||||
return (boolToByte(n.Expression != nil) << 0) | (boolToByte(n.QuestionDotToken != nil) << 1) | (boolToByte(n.ArgumentExpression != nil) << 2)
|
||||
case ast.KindCallExpression:
|
||||
n := node.AsCallExpression()
|
||||
return (boolToByte(n.Expression != nil) << 0) | (boolToByte(n.QuestionDotToken != nil) << 1) | (boolToByte(n.TypeArguments != nil) << 2) | (boolToByte(n.Arguments != nil) << 3)
|
||||
case ast.KindNewExpression:
|
||||
n := node.AsNewExpression()
|
||||
return (boolToByte(n.Expression != nil) << 0) | (boolToByte(n.TypeArguments != nil) << 1) | (boolToByte(n.Arguments != nil) << 2)
|
||||
case ast.KindTemplateExpression:
|
||||
n := node.AsTemplateExpression()
|
||||
return (boolToByte(n.Head != nil) << 0) | (boolToByte(n.TemplateSpans != nil) << 1)
|
||||
case ast.KindTemplateSpan:
|
||||
n := node.AsTemplateSpan()
|
||||
return (boolToByte(n.Expression != nil) << 0) | (boolToByte(n.Literal != nil) << 1)
|
||||
case ast.KindTaggedTemplateExpression:
|
||||
n := node.AsTaggedTemplateExpression()
|
||||
return (boolToByte(n.Tag != nil) << 0) | (boolToByte(n.QuestionDotToken != nil) << 1) | (boolToByte(n.TypeArguments != nil) << 2) | (boolToByte(n.Template != nil) << 3)
|
||||
case ast.KindPropertyAssignment:
|
||||
n := node.AsPropertyAssignment()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.Name() != nil) << 1) | (boolToByte(n.PostfixToken != nil) << 2) | (boolToByte(n.Initializer != nil) << 3)
|
||||
case ast.KindShorthandPropertyAssignment:
|
||||
n := node.AsShorthandPropertyAssignment()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.Name() != nil) << 1) | (boolToByte(n.PostfixToken != nil) << 2) | (boolToByte(n.EqualsToken != nil) << 3) | (boolToByte(n.ObjectAssignmentInitializer != nil) << 4)
|
||||
case ast.KindTypeAssertionExpression:
|
||||
n := node.AsTypeAssertion()
|
||||
return (boolToByte(n.Type != nil) << 0) | (boolToByte(n.Expression != nil) << 1)
|
||||
case ast.KindConditionalType:
|
||||
n := node.AsConditionalTypeNode()
|
||||
return (boolToByte(n.CheckType != nil) << 0) | (boolToByte(n.ExtendsType != nil) << 1) | (boolToByte(n.TrueType != nil) << 2) | (boolToByte(n.FalseType != nil) << 3)
|
||||
case ast.KindIndexedAccessType:
|
||||
n := node.AsIndexedAccessTypeNode()
|
||||
return (boolToByte(n.ObjectType != nil) << 0) | (boolToByte(n.IndexType != nil) << 1)
|
||||
case ast.KindTypeReference:
|
||||
n := node.AsTypeReferenceNode()
|
||||
return (boolToByte(n.TypeName != nil) << 0) | (boolToByte(n.TypeArguments != nil) << 1)
|
||||
case ast.KindExpressionWithTypeArguments:
|
||||
n := node.AsExpressionWithTypeArguments()
|
||||
return (boolToByte(n.Expression != nil) << 0) | (boolToByte(n.TypeArguments != nil) << 1)
|
||||
case ast.KindTypePredicate:
|
||||
n := node.AsTypePredicateNode()
|
||||
return (boolToByte(n.AssertsModifier != nil) << 0) | (boolToByte(n.ParameterName != nil) << 1) | (boolToByte(n.Type != nil) << 2)
|
||||
case ast.KindImportType:
|
||||
n := node.AsImportTypeNode()
|
||||
return (boolToByte(n.Argument != nil) << 0) | (boolToByte(n.Attributes != nil) << 1) | (boolToByte(n.Qualifier != nil) << 2) | (boolToByte(n.TypeArguments != nil) << 3)
|
||||
case ast.KindImportAttribute:
|
||||
n := node.AsImportAttribute()
|
||||
return (boolToByte(n.Name() != nil) << 0) | (boolToByte(n.Value != nil) << 1)
|
||||
case ast.KindTypeQuery:
|
||||
n := node.AsTypeQueryNode()
|
||||
return (boolToByte(n.ExprName != nil) << 0) | (boolToByte(n.TypeArguments != nil) << 1)
|
||||
case ast.KindMappedType:
|
||||
n := node.AsMappedTypeNode()
|
||||
return (boolToByte(n.ReadonlyToken != nil) << 0) | (boolToByte(n.TypeParameter != nil) << 1) | (boolToByte(n.NameType != nil) << 2) | (boolToByte(n.QuestionToken != nil) << 3) | (boolToByte(n.Type != nil) << 4) | (boolToByte(n.Members != nil) << 5)
|
||||
case ast.KindNamedTupleMember:
|
||||
n := node.AsNamedTupleMember()
|
||||
return (boolToByte(n.DotDotDotToken != nil) << 0) | (boolToByte(n.Name() != nil) << 1) | (boolToByte(n.QuestionToken != nil) << 2) | (boolToByte(n.Type != nil) << 3)
|
||||
case ast.KindFunctionType:
|
||||
n := node.AsFunctionTypeNode()
|
||||
return (boolToByte(n.TypeParameters != nil) << 0) | (boolToByte(n.Parameters != nil) << 1) | (boolToByte(n.Type != nil) << 2)
|
||||
case ast.KindConstructorType:
|
||||
n := node.AsConstructorTypeNode()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.TypeParameters != nil) << 1) | (boolToByte(n.Parameters != nil) << 2) | (boolToByte(n.Type != nil) << 3)
|
||||
case ast.KindTemplateLiteralType:
|
||||
n := node.AsTemplateLiteralTypeNode()
|
||||
return (boolToByte(n.Head != nil) << 0) | (boolToByte(n.TemplateSpans != nil) << 1)
|
||||
case ast.KindTemplateLiteralTypeSpan:
|
||||
n := node.AsTemplateLiteralTypeSpan()
|
||||
return (boolToByte(n.Type != nil) << 0) | (boolToByte(n.Literal != nil) << 1)
|
||||
case ast.KindJsxElement:
|
||||
n := node.AsJsxElement()
|
||||
return (boolToByte(n.OpeningElement != nil) << 0) | (boolToByte(n.Children != nil) << 1) | (boolToByte(n.ClosingElement != nil) << 2)
|
||||
case ast.KindJsxNamespacedName:
|
||||
n := node.AsJsxNamespacedName()
|
||||
return (boolToByte(n.Name() != nil) << 0) | (boolToByte(n.Namespace != nil) << 1)
|
||||
case ast.KindJsxOpeningElement:
|
||||
n := node.AsJsxOpeningElement()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.TypeArguments != nil) << 1) | (boolToByte(n.Attributes != nil) << 2)
|
||||
case ast.KindJsxSelfClosingElement:
|
||||
n := node.AsJsxSelfClosingElement()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.TypeArguments != nil) << 1) | (boolToByte(n.Attributes != nil) << 2)
|
||||
case ast.KindJsxFragment:
|
||||
n := node.AsJsxFragment()
|
||||
return (boolToByte(n.OpeningFragment != nil) << 0) | (boolToByte(n.Children != nil) << 1) | (boolToByte(n.ClosingFragment != nil) << 2)
|
||||
case ast.KindJsxAttribute:
|
||||
n := node.AsJsxAttribute()
|
||||
return (boolToByte(n.Name() != nil) << 0) | (boolToByte(n.Initializer != nil) << 1)
|
||||
case ast.KindJsxExpression:
|
||||
n := node.AsJsxExpression()
|
||||
return (boolToByte(n.DotDotDotToken != nil) << 0) | (boolToByte(n.Expression != nil) << 1)
|
||||
case ast.KindJSDoc:
|
||||
n := node.AsJSDoc()
|
||||
return (boolToByte(n.Comment != nil) << 0) | (boolToByte(n.Tags != nil) << 1)
|
||||
case ast.KindJSDocTypeTag:
|
||||
n := node.AsJSDocTypeTag()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.TypeExpression != nil) << 1) | (boolToByte(n.Comment != nil) << 2)
|
||||
case ast.KindJSDocTag:
|
||||
n := node.AsJSDocUnknownTag()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.Comment != nil) << 1)
|
||||
case ast.KindJSDocTemplateTag:
|
||||
n := node.AsJSDocTemplateTag()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.Constraint != nil) << 1) | (boolToByte(n.TypeParameters != nil) << 2) | (boolToByte(n.Comment != nil) << 3)
|
||||
case ast.KindJSDocReturnTag:
|
||||
n := node.AsJSDocReturnTag()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.TypeExpression != nil) << 1) | (boolToByte(n.Comment != nil) << 2)
|
||||
case ast.KindJSDocPublicTag:
|
||||
n := node.AsJSDocPublicTag()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.Comment != nil) << 1)
|
||||
case ast.KindJSDocPrivateTag:
|
||||
n := node.AsJSDocPrivateTag()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.Comment != nil) << 1)
|
||||
case ast.KindJSDocProtectedTag:
|
||||
n := node.AsJSDocProtectedTag()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.Comment != nil) << 1)
|
||||
case ast.KindJSDocReadonlyTag:
|
||||
n := node.AsJSDocReadonlyTag()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.Comment != nil) << 1)
|
||||
case ast.KindJSDocOverrideTag:
|
||||
n := node.AsJSDocOverrideTag()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.Comment != nil) << 1)
|
||||
case ast.KindJSDocDeprecatedTag:
|
||||
n := node.AsJSDocDeprecatedTag()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.Comment != nil) << 1)
|
||||
case ast.KindJSDocSeeTag:
|
||||
n := node.AsJSDocSeeTag()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.NameExpression != nil) << 1) | (boolToByte(n.Comment != nil) << 2)
|
||||
case ast.KindJSDocImplementsTag:
|
||||
n := node.AsJSDocImplementsTag()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.ClassName != nil) << 1) | (boolToByte(n.Comment != nil) << 2)
|
||||
case ast.KindJSDocAugmentsTag:
|
||||
n := node.AsJSDocAugmentsTag()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.ClassName != nil) << 1) | (boolToByte(n.Comment != nil) << 2)
|
||||
case ast.KindJSDocSatisfiesTag:
|
||||
n := node.AsJSDocSatisfiesTag()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.TypeExpression != nil) << 1) | (boolToByte(n.Comment != nil) << 2)
|
||||
case ast.KindJSDocThisTag:
|
||||
n := node.AsJSDocThisTag()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.TypeExpression != nil) << 1) | (boolToByte(n.Comment != nil) << 2)
|
||||
case ast.KindJSDocImportTag:
|
||||
n := node.AsJSDocImportTag()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.ImportClause != nil) << 1) | (boolToByte(n.ModuleSpecifier != nil) << 2) | (boolToByte(n.Attributes != nil) << 3) | (boolToByte(n.Comment != nil) << 4)
|
||||
case ast.KindJSDocCallbackTag:
|
||||
n := node.AsJSDocCallbackTag()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.TypeExpression != nil) << 1) | (boolToByte(n.FullName != nil) << 2) | (boolToByte(n.Comment != nil) << 3)
|
||||
case ast.KindJSDocOverloadTag:
|
||||
n := node.AsJSDocOverloadTag()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.TypeExpression != nil) << 1) | (boolToByte(n.Comment != nil) << 2)
|
||||
case ast.KindJSDocTypedefTag:
|
||||
n := node.AsJSDocTypedefTag()
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.TypeExpression != nil) << 1) | (boolToByte(n.Name() != nil) << 2) | (boolToByte(n.Comment != nil) << 3)
|
||||
case ast.KindJSDocSignature:
|
||||
n := node.AsJSDocSignature()
|
||||
return (boolToByte(n.TypeParameters != nil) << 0) | (boolToByte(n.Parameters != nil) << 1) | (boolToByte(n.Type != nil) << 2)
|
||||
case ast.KindClassStaticBlockDeclaration:
|
||||
n := node.AsClassStaticBlockDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.Body != nil) << 1)
|
||||
case ast.KindClassDeclaration:
|
||||
n := node.AsClassDeclaration()
|
||||
return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.Name() != nil) << 1) | (boolToByte(n.TypeParameters != nil) << 2) | (boolToByte(n.HeritageClauses != nil) << 3) | (boolToByte(n.Members != nil) << 4)
|
||||
case ast.KindJSDocParameterTag, ast.KindJSDocPropertyTag:
|
||||
n := node.AsJSDocParameterOrPropertyTag()
|
||||
if n.IsNameFirst {
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.Name() != nil) << 1) | (boolToByte(n.TypeExpression != nil) << 2) | (boolToByte(n.Comment != nil) << 3)
|
||||
}
|
||||
return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.TypeExpression != nil) << 1) | (boolToByte(n.Name() != nil) << 2) | (boolToByte(n.Comment != nil) << 3)
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
func getNodeDefinedData(node *ast.Node) uint32 {
|
||||
switch node.Kind {
|
||||
case ast.KindJSDocTypeLiteral:
|
||||
n := node.AsJSDocTypeLiteral()
|
||||
return uint32(boolToByte(n.IsArrayType)) << 24
|
||||
case ast.KindImportSpecifier:
|
||||
n := node.AsImportSpecifier()
|
||||
return uint32(boolToByte(n.IsTypeOnly)) << 24
|
||||
case ast.KindImportClause:
|
||||
n := node.AsImportClause()
|
||||
return uint32(boolToByte(n.PhaseModifier == ast.KindTypeKeyword))<<24 | uint32(boolToByte(n.PhaseModifier == ast.KindDeferKeyword))<<25
|
||||
case ast.KindExportSpecifier:
|
||||
n := node.AsExportSpecifier()
|
||||
return uint32(boolToByte(n.IsTypeOnly)) << 24
|
||||
case ast.KindImportType:
|
||||
n := node.AsImportTypeNode()
|
||||
return uint32(boolToByte(n.IsTypeOf)) << 24
|
||||
case ast.KindImportEqualsDeclaration:
|
||||
n := node.AsImportEqualsDeclaration()
|
||||
return uint32(boolToByte(n.IsTypeOnly)) << 24
|
||||
case ast.KindExportAssignment:
|
||||
n := node.AsExportAssignment()
|
||||
return uint32(boolToByte(n.IsExportEquals)) << 24
|
||||
case ast.KindExportDeclaration:
|
||||
n := node.AsExportDeclaration()
|
||||
return uint32(boolToByte(n.IsTypeOnly)) << 24
|
||||
case ast.KindBlock:
|
||||
n := node.AsBlock()
|
||||
return uint32(boolToByte(n.Multiline)) << 24
|
||||
case ast.KindArrayLiteralExpression:
|
||||
n := node.AsArrayLiteralExpression()
|
||||
return uint32(boolToByte(n.MultiLine)) << 24
|
||||
case ast.KindObjectLiteralExpression:
|
||||
n := node.AsObjectLiteralExpression()
|
||||
return uint32(boolToByte(n.MultiLine)) << 24
|
||||
case ast.KindJSDocParameterTag, ast.KindJSDocPropertyTag:
|
||||
n := node.AsJSDocParameterOrPropertyTag()
|
||||
return uint32(boolToByte(n.IsBracketed))<<24 | uint32(boolToByte(n.IsNameFirst))<<25
|
||||
case ast.KindJsxText:
|
||||
n := node.AsJsxText()
|
||||
return uint32(boolToByte(n.ContainsOnlyTriviaWhiteSpaces)) << 24
|
||||
case ast.KindVariableDeclarationList:
|
||||
n := node.AsVariableDeclarationList()
|
||||
return uint32(n.Flags & (ast.NodeFlagsLet | ast.NodeFlagsConst) << 24)
|
||||
case ast.KindImportAttributes:
|
||||
n := node.AsImportAttributes()
|
||||
return uint32(boolToByte(n.MultiLine))<<24 | uint32(boolToByte(n.Token == ast.KindAssertKeyword))<<25
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func recordNodeStrings(node *ast.Node, strs *stringTable) uint32 {
|
||||
switch node.Kind {
|
||||
case ast.KindJsxText:
|
||||
return strs.add(node.AsJsxText().Text, node.Kind, node.Pos(), node.End())
|
||||
case ast.KindIdentifier:
|
||||
return strs.add(node.AsIdentifier().Text, node.Kind, node.Pos(), node.End())
|
||||
case ast.KindPrivateIdentifier:
|
||||
return strs.add(node.AsPrivateIdentifier().Text, node.Kind, node.Pos(), node.End())
|
||||
case ast.KindStringLiteral:
|
||||
return strs.add(node.AsStringLiteral().Text, node.Kind, node.Pos(), node.End())
|
||||
case ast.KindNumericLiteral:
|
||||
return strs.add(node.AsNumericLiteral().Text, node.Kind, node.Pos(), node.End())
|
||||
case ast.KindBigIntLiteral:
|
||||
return strs.add(node.AsBigIntLiteral().Text, node.Kind, node.Pos(), node.End())
|
||||
case ast.KindRegularExpressionLiteral:
|
||||
return strs.add(node.AsRegularExpressionLiteral().Text, node.Kind, node.Pos(), node.End())
|
||||
case ast.KindNoSubstitutionTemplateLiteral:
|
||||
return strs.add(node.AsNoSubstitutionTemplateLiteral().Text, node.Kind, node.Pos(), node.End())
|
||||
case ast.KindJSDocText:
|
||||
return strs.add(node.AsJSDocText().Text(), node.Kind, node.Pos(), node.End())
|
||||
default:
|
||||
panic(fmt.Sprintf("Unexpected node kind %v", node.Kind))
|
||||
}
|
||||
}
|
||||
|
||||
func recordExtendedData(node *ast.Node, strs *stringTable, extendedData *[]byte) uint32 {
|
||||
offset := uint32(len(*extendedData))
|
||||
var text, rawText string
|
||||
var templateFlags uint32
|
||||
switch node.Kind {
|
||||
case ast.KindTemplateTail:
|
||||
n := node.AsTemplateTail()
|
||||
text = n.Text
|
||||
rawText = n.RawText
|
||||
templateFlags = uint32(n.TemplateFlags)
|
||||
case ast.KindTemplateMiddle:
|
||||
n := node.AsTemplateMiddle()
|
||||
text = n.Text
|
||||
rawText = n.RawText
|
||||
templateFlags = uint32(n.TemplateFlags)
|
||||
case ast.KindTemplateHead:
|
||||
n := node.AsTemplateHead()
|
||||
text = n.Text
|
||||
rawText = n.RawText
|
||||
templateFlags = uint32(n.TemplateFlags)
|
||||
}
|
||||
textIndex := strs.add(text, node.Kind, node.Pos(), node.End())
|
||||
rawTextIndex := strs.add(rawText, node.Kind, node.Pos(), node.End())
|
||||
*extendedData = appendUint32s(*extendedData, textIndex, rawTextIndex, templateFlags)
|
||||
return offset
|
||||
}
|
||||
|
||||
func boolToByte(b bool) byte {
|
||||
if b {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
94
kitcom/internal/tsgo/api/encoder/encoder_test.go
Normal file
94
kitcom/internal/tsgo/api/encoder/encoder_test.go
Normal file
@ -0,0 +1,94 @@
|
||||
package encoder_test
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/api/encoder"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/parser"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/repo"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/testutil/baseline"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
func TestEncodeSourceFile(t *testing.T) {
|
||||
t.Parallel()
|
||||
sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{
|
||||
FileName: "/test.ts",
|
||||
Path: "/test.ts",
|
||||
}, "import { bar } from \"bar\";\nexport function foo<T, U>(a: string, b: string): any {}\nfoo();", core.ScriptKindTS)
|
||||
t.Run("baseline", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
buf, err := encoder.EncodeSourceFile(sourceFile, "")
|
||||
assert.NilError(t, err)
|
||||
|
||||
str := formatEncodedSourceFile(buf)
|
||||
baseline.Run(t, "encodeSourceFile.txt", str, baseline.Options{
|
||||
Subfolder: "api",
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkEncodeSourceFile(b *testing.B) {
|
||||
repo.SkipIfNoTypeScriptSubmodule(b)
|
||||
filePath := filepath.Join(repo.TypeScriptSubmodulePath, "src/compiler/checker.ts")
|
||||
fileContent, err := os.ReadFile(filePath)
|
||||
assert.NilError(b, err)
|
||||
sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{
|
||||
FileName: "/checker.ts",
|
||||
Path: "/checker.ts",
|
||||
}, string(fileContent), core.ScriptKindTS)
|
||||
|
||||
for b.Loop() {
|
||||
_, err := encoder.EncodeSourceFile(sourceFile, "")
|
||||
assert.NilError(b, err)
|
||||
}
|
||||
}
|
||||
|
||||
func readUint32(buf []byte, offset int) uint32 {
|
||||
return binary.LittleEndian.Uint32(buf[offset : offset+4])
|
||||
}
|
||||
|
||||
func formatEncodedSourceFile(encoded []byte) string {
|
||||
var result strings.Builder
|
||||
var getIndent func(parentIndex uint32) string
|
||||
offsetNodes := readUint32(encoded, encoder.HeaderOffsetNodes)
|
||||
offsetStringOffsets := readUint32(encoded, encoder.HeaderOffsetStringOffsets)
|
||||
offsetStrings := readUint32(encoded, encoder.HeaderOffsetStringData)
|
||||
getIndent = func(parentIndex uint32) string {
|
||||
if parentIndex == 0 {
|
||||
return ""
|
||||
}
|
||||
return " " + getIndent(readUint32(encoded, int(offsetNodes)+int(parentIndex)*encoder.NodeSize+encoder.NodeOffsetParent))
|
||||
}
|
||||
j := 1
|
||||
for i := int(offsetNodes) + encoder.NodeSize; i < len(encoded); i += encoder.NodeSize {
|
||||
kind := readUint32(encoded, i+encoder.NodeOffsetKind)
|
||||
pos := readUint32(encoded, i+encoder.NodeOffsetPos)
|
||||
end := readUint32(encoded, i+encoder.NodeOffsetEnd)
|
||||
parentIndex := readUint32(encoded, i+encoder.NodeOffsetParent)
|
||||
result.WriteString(getIndent(parentIndex))
|
||||
if kind == encoder.SyntaxKindNodeList {
|
||||
result.WriteString("NodeList")
|
||||
} else {
|
||||
result.WriteString(ast.Kind(kind).String())
|
||||
}
|
||||
if ast.Kind(kind) == ast.KindIdentifier || ast.Kind(kind) == ast.KindStringLiteral {
|
||||
stringIndex := readUint32(encoded, i+encoder.NodeOffsetData) & encoder.NodeDataStringIndexMask
|
||||
strStart := readUint32(encoded, int(offsetStringOffsets+stringIndex*4))
|
||||
strEnd := readUint32(encoded, int(offsetStringOffsets+stringIndex*4)+4)
|
||||
str := string(encoded[offsetStrings+strStart : offsetStrings+strEnd])
|
||||
result.WriteString(fmt.Sprintf(" \"%s\"", str))
|
||||
}
|
||||
fmt.Fprintf(&result, " [%d, %d), i=%d, next=%d", pos, end, j, encoded[i+encoder.NodeOffsetNext])
|
||||
result.WriteString("\n")
|
||||
j++
|
||||
}
|
||||
return result.String()
|
||||
}
|
||||
68
kitcom/internal/tsgo/api/encoder/stringtable.go
Normal file
68
kitcom/internal/tsgo/api/encoder/stringtable.go
Normal file
@ -0,0 +1,68 @@
|
||||
package encoder
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
)
|
||||
|
||||
type stringTable struct {
|
||||
fileText string
|
||||
otherStrings *strings.Builder
|
||||
// offsets are pos/end pairs
|
||||
offsets []uint32
|
||||
}
|
||||
|
||||
func newStringTable(fileText string, stringCount int) *stringTable {
|
||||
builder := &strings.Builder{}
|
||||
return &stringTable{
|
||||
fileText: fileText,
|
||||
otherStrings: builder,
|
||||
offsets: make([]uint32, 0, stringCount*2),
|
||||
}
|
||||
}
|
||||
|
||||
func (t *stringTable) add(text string, kind ast.Kind, pos int, end int) uint32 {
|
||||
index := uint32(len(t.offsets))
|
||||
if kind == ast.KindSourceFile {
|
||||
t.offsets = append(t.offsets, uint32(pos), uint32(end))
|
||||
return index
|
||||
}
|
||||
length := len(text)
|
||||
if end-pos > 0 {
|
||||
// pos includes leading trivia, but we can usually infer the actual start of the
|
||||
// string from the kind and end
|
||||
endOffset := 0
|
||||
if kind == ast.KindStringLiteral || kind == ast.KindTemplateTail || kind == ast.KindNoSubstitutionTemplateLiteral {
|
||||
endOffset = 1
|
||||
}
|
||||
end = end - endOffset
|
||||
start := end - length
|
||||
fileSlice := t.fileText[start:end]
|
||||
if fileSlice == text {
|
||||
t.offsets = append(t.offsets, uint32(start), uint32(end))
|
||||
return index
|
||||
}
|
||||
}
|
||||
// no exact match, so we need to add it to the string table
|
||||
offset := len(t.fileText) + t.otherStrings.Len()
|
||||
t.otherStrings.WriteString(text)
|
||||
t.offsets = append(t.offsets, uint32(offset), uint32(offset+length))
|
||||
return index
|
||||
}
|
||||
|
||||
func (t *stringTable) encode() []byte {
|
||||
result := make([]byte, 0, t.encodedLength())
|
||||
result = appendUint32s(result, t.offsets...)
|
||||
result = append(result, t.fileText...)
|
||||
result = append(result, t.otherStrings.String()...)
|
||||
return result
|
||||
}
|
||||
|
||||
func (t *stringTable) stringLength() int {
|
||||
return len(t.fileText) + t.otherStrings.Len()
|
||||
}
|
||||
|
||||
func (t *stringTable) encodedLength() int {
|
||||
return len(t.offsets)*4 + len(t.fileText) + t.otherStrings.Len()
|
||||
}
|
||||
218
kitcom/internal/tsgo/api/proto.go
Normal file
218
kitcom/internal/tsgo/api/proto.go
Normal file
@ -0,0 +1,218 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/checker"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/project"
|
||||
"github.com/go-json-experiment/json"
|
||||
"github.com/go-json-experiment/json/jsontext"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrInvalidRequest = errors.New("api: invalid request")
|
||||
ErrClientError = errors.New("api: client error")
|
||||
)
|
||||
|
||||
type Method string
|
||||
|
||||
type Handle[T any] string
|
||||
|
||||
const (
|
||||
handlePrefixProject = 'p'
|
||||
handlePrefixSymbol = 's'
|
||||
handlePrefixType = 't'
|
||||
handlePrefixFile = 'f'
|
||||
handlePrefixNode = 'n'
|
||||
)
|
||||
|
||||
func ProjectHandle(p *project.Project) Handle[project.Project] {
|
||||
return createHandle[project.Project](handlePrefixProject, p.Name())
|
||||
}
|
||||
|
||||
func SymbolHandle(symbol *ast.Symbol) Handle[ast.Symbol] {
|
||||
return createHandle[ast.Symbol](handlePrefixSymbol, ast.GetSymbolId(symbol))
|
||||
}
|
||||
|
||||
func TypeHandle(t *checker.Type) Handle[checker.Type] {
|
||||
return createHandle[checker.Type](handlePrefixType, t.Id())
|
||||
}
|
||||
|
||||
func FileHandle(file *ast.SourceFile) Handle[ast.SourceFile] {
|
||||
return createHandle[ast.SourceFile](handlePrefixFile, ast.GetNodeId(file.AsNode()))
|
||||
}
|
||||
|
||||
func NodeHandle(node *ast.Node) Handle[ast.Node] {
|
||||
fileHandle := FileHandle(ast.GetSourceFileOfNode(node))
|
||||
return Handle[ast.Node](fmt.Sprintf("%s.%d.%d", fileHandle, node.Pos(), node.Kind))
|
||||
}
|
||||
|
||||
func parseNodeHandle(handle Handle[ast.Node]) (Handle[ast.SourceFile], int, ast.Kind, error) {
|
||||
parts := strings.SplitN(string(handle), ".", 3)
|
||||
if len(parts) != 3 {
|
||||
return "", 0, 0, fmt.Errorf("invalid node handle %q", handle)
|
||||
}
|
||||
|
||||
fileHandle := Handle[ast.SourceFile](parts[0])
|
||||
pos, err := strconv.ParseInt(parts[1], 10, 32)
|
||||
if err != nil {
|
||||
return "", 0, 0, fmt.Errorf("invalid node handle %q: %w", handle, err)
|
||||
}
|
||||
kind, err := strconv.ParseInt(parts[2], 10, 16)
|
||||
if err != nil {
|
||||
return "", 0, 0, fmt.Errorf("invalid node handle %q: %w", handle, err)
|
||||
}
|
||||
return fileHandle, int(pos), ast.Kind(kind), nil
|
||||
}
|
||||
|
||||
func createHandle[T any](prefix rune, id any) Handle[T] {
|
||||
return Handle[T](fmt.Sprintf("%c%016x", prefix, id))
|
||||
}
|
||||
|
||||
const (
|
||||
MethodConfigure Method = "configure"
|
||||
MethodRelease Method = "release"
|
||||
|
||||
MethodParseConfigFile Method = "parseConfigFile"
|
||||
MethodLoadProject Method = "loadProject"
|
||||
MethodGetSymbolAtPosition Method = "getSymbolAtPosition"
|
||||
MethodGetSymbolsAtPositions Method = "getSymbolsAtPositions"
|
||||
MethodGetSymbolAtLocation Method = "getSymbolAtLocation"
|
||||
MethodGetSymbolsAtLocations Method = "getSymbolsAtLocations"
|
||||
MethodGetTypeOfSymbol Method = "getTypeOfSymbol"
|
||||
MethodGetTypesOfSymbols Method = "getTypesOfSymbols"
|
||||
MethodGetSourceFile Method = "getSourceFile"
|
||||
)
|
||||
|
||||
var unmarshalers = map[Method]func([]byte) (any, error){
|
||||
MethodRelease: unmarshallerFor[string],
|
||||
MethodParseConfigFile: unmarshallerFor[ParseConfigFileParams],
|
||||
MethodLoadProject: unmarshallerFor[LoadProjectParams],
|
||||
MethodGetSourceFile: unmarshallerFor[GetSourceFileParams],
|
||||
MethodGetSymbolAtPosition: unmarshallerFor[GetSymbolAtPositionParams],
|
||||
MethodGetSymbolsAtPositions: unmarshallerFor[GetSymbolsAtPositionsParams],
|
||||
MethodGetSymbolAtLocation: unmarshallerFor[GetSymbolAtLocationParams],
|
||||
MethodGetSymbolsAtLocations: unmarshallerFor[GetSymbolsAtLocationsParams],
|
||||
MethodGetTypeOfSymbol: unmarshallerFor[GetTypeOfSymbolParams],
|
||||
MethodGetTypesOfSymbols: unmarshallerFor[GetTypesOfSymbolsParams],
|
||||
}
|
||||
|
||||
type ConfigureParams struct {
|
||||
Callbacks []string `json:"callbacks"`
|
||||
LogFile string `json:"logFile"`
|
||||
}
|
||||
|
||||
type ParseConfigFileParams struct {
|
||||
FileName string `json:"fileName"`
|
||||
}
|
||||
|
||||
type ConfigFileResponse struct {
|
||||
FileNames []string `json:"fileNames"`
|
||||
Options *core.CompilerOptions `json:"options"`
|
||||
}
|
||||
|
||||
type LoadProjectParams struct {
|
||||
ConfigFileName string `json:"configFileName"`
|
||||
}
|
||||
|
||||
type ProjectResponse struct {
|
||||
Id Handle[project.Project] `json:"id"`
|
||||
ConfigFileName string `json:"configFileName"`
|
||||
RootFiles []string `json:"rootFiles"`
|
||||
CompilerOptions *core.CompilerOptions `json:"compilerOptions"`
|
||||
}
|
||||
|
||||
func NewProjectResponse(project *project.Project) *ProjectResponse {
|
||||
return &ProjectResponse{
|
||||
Id: ProjectHandle(project),
|
||||
ConfigFileName: project.Name(),
|
||||
RootFiles: project.CommandLine.FileNames(),
|
||||
CompilerOptions: project.CommandLine.CompilerOptions(),
|
||||
}
|
||||
}
|
||||
|
||||
type GetSymbolAtPositionParams struct {
|
||||
Project Handle[project.Project] `json:"project"`
|
||||
FileName string `json:"fileName"`
|
||||
Position uint32 `json:"position"`
|
||||
}
|
||||
|
||||
type GetSymbolsAtPositionsParams struct {
|
||||
Project Handle[project.Project] `json:"project"`
|
||||
FileName string `json:"fileName"`
|
||||
Positions []uint32 `json:"positions"`
|
||||
}
|
||||
|
||||
type GetSymbolAtLocationParams struct {
|
||||
Project Handle[project.Project] `json:"project"`
|
||||
Location Handle[ast.Node] `json:"location"`
|
||||
}
|
||||
|
||||
type GetSymbolsAtLocationsParams struct {
|
||||
Project Handle[project.Project] `json:"project"`
|
||||
Locations []Handle[ast.Node] `json:"locations"`
|
||||
}
|
||||
|
||||
type SymbolResponse struct {
|
||||
Id Handle[ast.Symbol] `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Flags uint32 `json:"flags"`
|
||||
CheckFlags uint32 `json:"checkFlags"`
|
||||
}
|
||||
|
||||
func NewSymbolResponse(symbol *ast.Symbol) *SymbolResponse {
|
||||
return &SymbolResponse{
|
||||
Id: SymbolHandle(symbol),
|
||||
Name: symbol.Name,
|
||||
Flags: uint32(symbol.Flags),
|
||||
CheckFlags: uint32(symbol.CheckFlags),
|
||||
}
|
||||
}
|
||||
|
||||
type GetTypeOfSymbolParams struct {
|
||||
Project Handle[project.Project] `json:"project"`
|
||||
Symbol Handle[ast.Symbol] `json:"symbol"`
|
||||
}
|
||||
|
||||
type GetTypesOfSymbolsParams struct {
|
||||
Project Handle[project.Project] `json:"project"`
|
||||
Symbols []Handle[ast.Symbol] `json:"symbols"`
|
||||
}
|
||||
|
||||
type TypeResponse struct {
|
||||
Id Handle[checker.Type] `json:"id"`
|
||||
Flags uint32 `json:"flags"`
|
||||
}
|
||||
|
||||
func NewTypeData(t *checker.Type) *TypeResponse {
|
||||
return &TypeResponse{
|
||||
Id: TypeHandle(t),
|
||||
Flags: uint32(t.Flags()),
|
||||
}
|
||||
}
|
||||
|
||||
type GetSourceFileParams struct {
|
||||
Project Handle[project.Project] `json:"project"`
|
||||
FileName string `json:"fileName"`
|
||||
}
|
||||
|
||||
func unmarshalPayload(method string, payload jsontext.Value) (any, error) {
|
||||
unmarshaler, ok := unmarshalers[Method(method)]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unknown API method %q", method)
|
||||
}
|
||||
return unmarshaler(payload)
|
||||
}
|
||||
|
||||
func unmarshallerFor[T any](data []byte) (any, error) {
|
||||
var v T
|
||||
if err := json.Unmarshal(data, &v); err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal %T: %w", (*T)(nil), err)
|
||||
}
|
||||
return &v, nil
|
||||
}
|
||||
497
kitcom/internal/tsgo/api/server.go
Normal file
497
kitcom/internal/tsgo/api/server.go
Normal file
@ -0,0 +1,497 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/bundled"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/lsp/lsproto"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/project"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/project/logging"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/vfs"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/vfs/osvfs"
|
||||
"github.com/go-json-experiment/json"
|
||||
)
|
||||
|
||||
//go:generate go tool golang.org/x/tools/cmd/stringer -type=MessageType -output=stringer_generated.go
|
||||
//go:generate go tool mvdan.cc/gofumpt -w stringer_generated.go
|
||||
|
||||
type MessageType uint8
|
||||
|
||||
const (
|
||||
MessageTypeUnknown MessageType = iota
|
||||
MessageTypeRequest
|
||||
MessageTypeCallResponse
|
||||
MessageTypeCallError
|
||||
MessageTypeResponse
|
||||
MessageTypeError
|
||||
MessageTypeCall
|
||||
)
|
||||
|
||||
func (m MessageType) IsValid() bool {
|
||||
return m >= MessageTypeRequest && m <= MessageTypeCall
|
||||
}
|
||||
|
||||
type MessagePackType uint8
|
||||
|
||||
const (
|
||||
MessagePackTypeFixedArray3 MessagePackType = 0x93
|
||||
MessagePackTypeBin8 MessagePackType = 0xC4
|
||||
MessagePackTypeBin16 MessagePackType = 0xC5
|
||||
MessagePackTypeBin32 MessagePackType = 0xC6
|
||||
MessagePackTypeU8 MessagePackType = 0xCC
|
||||
)
|
||||
|
||||
type Callback int
|
||||
|
||||
const (
|
||||
CallbackDirectoryExists Callback = 1 << iota
|
||||
CallbackFileExists
|
||||
CallbackGetAccessibleEntries
|
||||
CallbackReadFile
|
||||
CallbackRealpath
|
||||
)
|
||||
|
||||
type ServerOptions struct {
|
||||
In io.Reader
|
||||
Out io.Writer
|
||||
Err io.Writer
|
||||
Cwd string
|
||||
DefaultLibraryPath string
|
||||
}
|
||||
|
||||
var _ vfs.FS = (*Server)(nil)
|
||||
|
||||
type Server struct {
|
||||
r *bufio.Reader
|
||||
w *bufio.Writer
|
||||
stderr io.Writer
|
||||
|
||||
cwd string
|
||||
newLine string
|
||||
fs vfs.FS
|
||||
defaultLibraryPath string
|
||||
|
||||
callbackMu sync.Mutex
|
||||
enabledCallbacks Callback
|
||||
logger logging.Logger
|
||||
api *API
|
||||
|
||||
requestId int
|
||||
}
|
||||
|
||||
func NewServer(options *ServerOptions) *Server {
|
||||
if options.Cwd == "" {
|
||||
panic("Cwd is required")
|
||||
}
|
||||
|
||||
server := &Server{
|
||||
r: bufio.NewReader(options.In),
|
||||
w: bufio.NewWriter(options.Out),
|
||||
stderr: options.Err,
|
||||
cwd: options.Cwd,
|
||||
fs: bundled.WrapFS(osvfs.FS()),
|
||||
defaultLibraryPath: options.DefaultLibraryPath,
|
||||
}
|
||||
logger := logging.NewLogger(options.Err)
|
||||
server.logger = logger
|
||||
server.api = NewAPI(&APIInit{
|
||||
Logger: logger,
|
||||
FS: server,
|
||||
SessionOptions: &project.SessionOptions{
|
||||
CurrentDirectory: options.Cwd,
|
||||
DefaultLibraryPath: options.DefaultLibraryPath,
|
||||
PositionEncoding: lsproto.PositionEncodingKindUTF8,
|
||||
LoggingEnabled: true,
|
||||
},
|
||||
})
|
||||
return server
|
||||
}
|
||||
|
||||
// DefaultLibraryPath implements APIHost.
|
||||
func (s *Server) DefaultLibraryPath() string {
|
||||
return s.defaultLibraryPath
|
||||
}
|
||||
|
||||
// FS implements APIHost.
|
||||
func (s *Server) FS() vfs.FS {
|
||||
return s
|
||||
}
|
||||
|
||||
// GetCurrentDirectory implements APIHost.
|
||||
func (s *Server) GetCurrentDirectory() string {
|
||||
return s.cwd
|
||||
}
|
||||
|
||||
func (s *Server) Run() error {
|
||||
for {
|
||||
messageType, method, payload, err := s.readRequest("")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch messageType {
|
||||
case MessageTypeRequest:
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
stack := debug.Stack()
|
||||
err = fmt.Errorf("panic handling request: %v\n%s", r, string(stack))
|
||||
if fatalErr := s.sendError(method, err); fatalErr != nil {
|
||||
panic("fatal error sending panic response")
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
result, err := s.handleRequest(method, payload)
|
||||
|
||||
if err != nil {
|
||||
if err := s.sendError(method, err); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := s.sendResponse(method, result); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("%w: expected request, received: %s", ErrInvalidRequest, messageType.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) readRequest(expectedMethod string) (messageType MessageType, method string, payload []byte, err error) {
|
||||
t, err := s.r.ReadByte()
|
||||
if err != nil {
|
||||
return messageType, method, payload, err
|
||||
}
|
||||
if MessagePackType(t) != MessagePackTypeFixedArray3 {
|
||||
return messageType, method, payload, fmt.Errorf("%w: expected message to be encoded as fixed 3-element array (0x93), received: 0x%2x", ErrInvalidRequest, t)
|
||||
}
|
||||
t, err = s.r.ReadByte()
|
||||
if err != nil {
|
||||
return messageType, method, payload, err
|
||||
}
|
||||
if MessagePackType(t) != MessagePackTypeU8 {
|
||||
return messageType, method, payload, fmt.Errorf("%w: expected first element of message tuple to be encoded as unsigned 8-bit int (0xcc), received: 0x%2x", ErrInvalidRequest, t)
|
||||
}
|
||||
rawMessageType, err := s.r.ReadByte()
|
||||
if err != nil {
|
||||
return messageType, method, payload, err
|
||||
}
|
||||
messageType = MessageType(rawMessageType)
|
||||
if !messageType.IsValid() {
|
||||
return messageType, method, payload, fmt.Errorf("%w: unknown message type: %d", ErrInvalidRequest, messageType)
|
||||
}
|
||||
rawMethod, err := s.readBin()
|
||||
if err != nil {
|
||||
return messageType, method, payload, err
|
||||
}
|
||||
method = string(rawMethod)
|
||||
if expectedMethod != "" && method != expectedMethod {
|
||||
return messageType, method, payload, fmt.Errorf("%w: expected method %q, received %q", ErrInvalidRequest, expectedMethod, method)
|
||||
}
|
||||
payload, err = s.readBin()
|
||||
return messageType, method, payload, err
|
||||
}
|
||||
|
||||
func (s *Server) readBin() ([]byte, error) {
|
||||
// https://github.com/msgpack/msgpack/blob/master/spec.md#bin-format-family
|
||||
t, err := s.r.ReadByte()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var size uint
|
||||
switch MessagePackType(t) {
|
||||
case MessagePackTypeBin8:
|
||||
var size8 uint8
|
||||
if err = binary.Read(s.r, binary.BigEndian, &size8); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
size = uint(size8)
|
||||
case MessagePackTypeBin16:
|
||||
var size16 uint16
|
||||
if err = binary.Read(s.r, binary.BigEndian, &size16); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
size = uint(size16)
|
||||
case MessagePackTypeBin32:
|
||||
var size32 uint32
|
||||
if err = binary.Read(s.r, binary.BigEndian, &size32); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
size = uint(size32)
|
||||
default:
|
||||
return nil, fmt.Errorf("%w: expected binary data length (0xc4-0xc6), received: 0x%2x", ErrInvalidRequest, t)
|
||||
}
|
||||
payload := make([]byte, size)
|
||||
bytesRead, err := io.ReadFull(s.r, payload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if bytesRead != int(size) {
|
||||
return nil, fmt.Errorf("%w: expected %d bytes, read %d", ErrInvalidRequest, size, bytesRead)
|
||||
}
|
||||
return payload, nil
|
||||
}
|
||||
|
||||
func (s *Server) enableCallback(callback string) error {
|
||||
switch callback {
|
||||
case "directoryExists":
|
||||
s.enabledCallbacks |= CallbackDirectoryExists
|
||||
case "fileExists":
|
||||
s.enabledCallbacks |= CallbackFileExists
|
||||
case "getAccessibleEntries":
|
||||
s.enabledCallbacks |= CallbackGetAccessibleEntries
|
||||
case "readFile":
|
||||
s.enabledCallbacks |= CallbackReadFile
|
||||
case "realpath":
|
||||
s.enabledCallbacks |= CallbackRealpath
|
||||
default:
|
||||
return fmt.Errorf("unknown callback: %s", callback)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) handleRequest(method string, payload []byte) ([]byte, error) {
|
||||
s.requestId++
|
||||
switch method {
|
||||
case "configure":
|
||||
return nil, s.handleConfigure(payload)
|
||||
case "echo":
|
||||
return payload, nil
|
||||
default:
|
||||
return s.api.HandleRequest(core.WithRequestID(context.Background(), strconv.Itoa(s.requestId)), method, payload)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) handleConfigure(payload []byte) error {
|
||||
var params *ConfigureParams
|
||||
if err := json.Unmarshal(payload, ¶ms); err != nil {
|
||||
return fmt.Errorf("%w: %w", ErrInvalidRequest, err)
|
||||
}
|
||||
for _, callback := range params.Callbacks {
|
||||
if err := s.enableCallback(callback); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// !!!
|
||||
if params.LogFile != "" {
|
||||
// s.logger.SetFile(params.LogFile)
|
||||
} else {
|
||||
// s.logger.SetFile("")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) sendResponse(method string, result []byte) error {
|
||||
return s.writeMessage(MessageTypeResponse, method, result)
|
||||
}
|
||||
|
||||
func (s *Server) sendError(method string, err error) error {
|
||||
return s.writeMessage(MessageTypeError, method, []byte(err.Error()))
|
||||
}
|
||||
|
||||
func (s *Server) writeMessage(messageType MessageType, method string, payload []byte) error {
|
||||
if err := s.w.WriteByte(byte(MessagePackTypeFixedArray3)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.w.WriteByte(byte(MessagePackTypeU8)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.w.WriteByte(byte(messageType)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.writeBin([]byte(method)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.writeBin(payload); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.w.Flush()
|
||||
}
|
||||
|
||||
func (s *Server) writeBin(payload []byte) error {
|
||||
length := len(payload)
|
||||
if length < 256 {
|
||||
if err := s.w.WriteByte(byte(MessagePackTypeBin8)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.w.WriteByte(byte(length)); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if length < 1<<16 {
|
||||
if err := s.w.WriteByte(byte(MessagePackTypeBin16)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := binary.Write(s.w, binary.BigEndian, uint16(length)); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := s.w.WriteByte(byte(MessagePackTypeBin32)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := binary.Write(s.w, binary.BigEndian, uint32(length)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_, err := s.w.Write(payload)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Server) call(method string, payload any) ([]byte, error) {
|
||||
s.callbackMu.Lock()
|
||||
defer s.callbackMu.Unlock()
|
||||
jsonPayload, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = s.writeMessage(MessageTypeCall, method, jsonPayload); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
messageType, _, responsePayload, err := s.readRequest(method)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if messageType != MessageTypeCallResponse && messageType != MessageTypeCallError {
|
||||
return nil, fmt.Errorf("%w: expected call-response or call-error, received: %s", ErrInvalidRequest, messageType.String())
|
||||
}
|
||||
|
||||
if messageType == MessageTypeCallError {
|
||||
return nil, fmt.Errorf("%w: %s", ErrClientError, responsePayload)
|
||||
}
|
||||
|
||||
return responsePayload, nil
|
||||
}
|
||||
|
||||
// DirectoryExists implements vfs.FS.
|
||||
func (s *Server) DirectoryExists(path string) bool {
|
||||
if s.enabledCallbacks&CallbackDirectoryExists != 0 {
|
||||
result, err := s.call("directoryExists", path)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if len(result) > 0 {
|
||||
return string(result) == "true"
|
||||
}
|
||||
}
|
||||
return s.fs.DirectoryExists(path)
|
||||
}
|
||||
|
||||
// FileExists implements vfs.FS.
|
||||
func (s *Server) FileExists(path string) bool {
|
||||
if s.enabledCallbacks&CallbackFileExists != 0 {
|
||||
result, err := s.call("fileExists", path)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if len(result) > 0 {
|
||||
return string(result) == "true"
|
||||
}
|
||||
}
|
||||
return s.fs.FileExists(path)
|
||||
}
|
||||
|
||||
// GetAccessibleEntries implements vfs.FS.
|
||||
func (s *Server) GetAccessibleEntries(path string) vfs.Entries {
|
||||
if s.enabledCallbacks&CallbackGetAccessibleEntries != 0 {
|
||||
result, err := s.call("getAccessibleEntries", path)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if len(result) > 0 {
|
||||
var rawEntries *struct {
|
||||
Files []string `json:"files"`
|
||||
Directories []string `json:"directories"`
|
||||
}
|
||||
if err := json.Unmarshal(result, &rawEntries); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if rawEntries != nil {
|
||||
return vfs.Entries{
|
||||
Files: rawEntries.Files,
|
||||
Directories: rawEntries.Directories,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return s.fs.GetAccessibleEntries(path)
|
||||
}
|
||||
|
||||
// ReadFile implements vfs.FS.
|
||||
func (s *Server) ReadFile(path string) (contents string, ok bool) {
|
||||
if s.enabledCallbacks&CallbackReadFile != 0 {
|
||||
data, err := s.call("readFile", path)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if string(data) == "null" {
|
||||
return "", false
|
||||
}
|
||||
if len(data) > 0 {
|
||||
var result string
|
||||
if err := json.Unmarshal(data, &result); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return result, true
|
||||
}
|
||||
}
|
||||
return s.fs.ReadFile(path)
|
||||
}
|
||||
|
||||
// Realpath implements vfs.FS.
|
||||
func (s *Server) Realpath(path string) string {
|
||||
if s.enabledCallbacks&CallbackRealpath != 0 {
|
||||
data, err := s.call("realpath", path)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if len(data) > 0 {
|
||||
var result string
|
||||
if err := json.Unmarshal(data, &result); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
return s.fs.Realpath(path)
|
||||
}
|
||||
|
||||
// UseCaseSensitiveFileNames implements vfs.FS.
|
||||
func (s *Server) UseCaseSensitiveFileNames() bool {
|
||||
return s.fs.UseCaseSensitiveFileNames()
|
||||
}
|
||||
|
||||
// WriteFile implements vfs.FS.
|
||||
func (s *Server) WriteFile(path string, data string, writeByteOrderMark bool) error {
|
||||
return s.fs.WriteFile(path, data, writeByteOrderMark)
|
||||
}
|
||||
|
||||
// WalkDir implements vfs.FS.
|
||||
func (s *Server) WalkDir(root string, walkFn vfs.WalkDirFunc) error {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
// Stat implements vfs.FS.
|
||||
func (s *Server) Stat(path string) vfs.FileInfo {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
// Remove implements vfs.FS.
|
||||
func (s *Server) Remove(path string) error {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
// Chtimes implements vfs.FS.
|
||||
func (s *Server) Chtimes(path string, aTime time.Time, mTime time.Time) error {
|
||||
panic("unimplemented")
|
||||
}
|
||||
29
kitcom/internal/tsgo/api/stringer_generated.go
Normal file
29
kitcom/internal/tsgo/api/stringer_generated.go
Normal file
@ -0,0 +1,29 @@
|
||||
// Code generated by "stringer -type=MessageType -output=stringer_generated.go"; DO NOT EDIT.
|
||||
|
||||
package api
|
||||
|
||||
import "strconv"
|
||||
|
||||
func _() {
|
||||
// An "invalid array index" compiler error signifies that the constant values have changed.
|
||||
// Re-run the stringer command to generate them again.
|
||||
var x [1]struct{}
|
||||
_ = x[MessageTypeUnknown-0]
|
||||
_ = x[MessageTypeRequest-1]
|
||||
_ = x[MessageTypeCallResponse-2]
|
||||
_ = x[MessageTypeCallError-3]
|
||||
_ = x[MessageTypeResponse-4]
|
||||
_ = x[MessageTypeError-5]
|
||||
_ = x[MessageTypeCall-6]
|
||||
}
|
||||
|
||||
const _MessageType_name = "MessageTypeUnknownMessageTypeRequestMessageTypeCallResponseMessageTypeCallErrorMessageTypeResponseMessageTypeErrorMessageTypeCall"
|
||||
|
||||
var _MessageType_index = [...]uint8{0, 18, 36, 59, 79, 98, 114, 129}
|
||||
|
||||
func (i MessageType) String() string {
|
||||
if i >= MessageType(len(_MessageType_index)-1) {
|
||||
return "MessageType(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _MessageType_name[_MessageType_index[i]:_MessageType_index[i+1]]
|
||||
}
|
||||
11118
kitcom/internal/tsgo/ast/ast.go
Normal file
11118
kitcom/internal/tsgo/ast/ast.go
Normal file
File diff suppressed because it is too large
Load Diff
35
kitcom/internal/tsgo/ast/checkflags.go
Normal file
35
kitcom/internal/tsgo/ast/checkflags.go
Normal file
@ -0,0 +1,35 @@
|
||||
package ast
|
||||
|
||||
// CheckFlags
|
||||
|
||||
type CheckFlags uint32
|
||||
|
||||
const (
|
||||
CheckFlagsNone CheckFlags = 0
|
||||
CheckFlagsInstantiated CheckFlags = 1 << 0 // Instantiated symbol
|
||||
CheckFlagsSyntheticProperty CheckFlags = 1 << 1 // Property in union or intersection type
|
||||
CheckFlagsSyntheticMethod CheckFlags = 1 << 2 // Method in union or intersection type
|
||||
CheckFlagsReadonly CheckFlags = 1 << 3 // Readonly transient symbol
|
||||
CheckFlagsReadPartial CheckFlags = 1 << 4 // Synthetic property present in some but not all constituents
|
||||
CheckFlagsWritePartial CheckFlags = 1 << 5 // Synthetic property present in some but only satisfied by an index signature in others
|
||||
CheckFlagsHasNonUniformType CheckFlags = 1 << 6 // Synthetic property with non-uniform type in constituents
|
||||
CheckFlagsHasLiteralType CheckFlags = 1 << 7 // Synthetic property with at least one literal type in constituents
|
||||
CheckFlagsContainsPublic CheckFlags = 1 << 8 // Synthetic property with public constituent(s)
|
||||
CheckFlagsContainsProtected CheckFlags = 1 << 9 // Synthetic property with protected constituent(s)
|
||||
CheckFlagsContainsPrivate CheckFlags = 1 << 10 // Synthetic property with private constituent(s)
|
||||
CheckFlagsContainsStatic CheckFlags = 1 << 11 // Synthetic property with static constituent(s)
|
||||
CheckFlagsLate CheckFlags = 1 << 12 // Late-bound symbol for a computed property with a dynamic name
|
||||
CheckFlagsReverseMapped CheckFlags = 1 << 13 // Property of reverse-inferred homomorphic mapped type
|
||||
CheckFlagsOptionalParameter CheckFlags = 1 << 14 // Optional parameter
|
||||
CheckFlagsRestParameter CheckFlags = 1 << 15 // Rest parameter
|
||||
CheckFlagsDeferredType CheckFlags = 1 << 16 // Calculation of the type of this symbol is deferred due to processing costs, should be fetched with `getTypeOfSymbolWithDeferredType`
|
||||
CheckFlagsHasNeverType CheckFlags = 1 << 17 // Synthetic property with at least one never type in constituents
|
||||
CheckFlagsMapped CheckFlags = 1 << 18 // Property of mapped type
|
||||
CheckFlagsStripOptional CheckFlags = 1 << 19 // Strip optionality in mapped property
|
||||
CheckFlagsUnresolved CheckFlags = 1 << 20 // Unresolved type alias symbol
|
||||
CheckFlagsIsDiscriminantComputed CheckFlags = 1 << 21 // IsDiscriminant flags has been computed
|
||||
CheckFlagsIsDiscriminant CheckFlags = 1 << 22 // Discriminant property
|
||||
CheckFlagsSynthetic = CheckFlagsSyntheticProperty | CheckFlagsSyntheticMethod
|
||||
CheckFlagsNonUniformAndLiteral = CheckFlagsHasNonUniformType | CheckFlagsHasLiteralType
|
||||
CheckFlagsPartial = CheckFlagsReadPartial | CheckFlagsWritePartial
|
||||
)
|
||||
86
kitcom/internal/tsgo/ast/deepclone.go
Normal file
86
kitcom/internal/tsgo/ast/deepclone.go
Normal file
@ -0,0 +1,86 @@
|
||||
package ast
|
||||
|
||||
import "efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
|
||||
// Ideally, this would get cached on the node factory so there's only ever one set of closures made per factory
|
||||
func getDeepCloneVisitor(f *NodeFactory, syntheticLocation bool) *NodeVisitor {
|
||||
var visitor *NodeVisitor
|
||||
visitor = NewNodeVisitor(
|
||||
func(node *Node) *Node {
|
||||
visited := visitor.VisitEachChild(node)
|
||||
if visited != node {
|
||||
if syntheticLocation {
|
||||
visited.Loc = core.NewTextRange(-1, -1)
|
||||
}
|
||||
return visited
|
||||
}
|
||||
c := node.Clone(f) // forcibly clone leaf nodes, which will then cascade new nodes/arrays upwards via `update` calls
|
||||
// In strada, `factory.cloneNode` was dynamic and did _not_ clone positions for any "special cases", meanwhile
|
||||
// Node.Clone in corsa reliably uses `Update` calls for all nodes and so copies locations by default.
|
||||
// Deep clones are done to copy a node across files, so here, we explicitly make the location range synthetic on all cloned nodes
|
||||
if syntheticLocation {
|
||||
c.Loc = core.NewTextRange(-1, -1)
|
||||
}
|
||||
return c
|
||||
},
|
||||
f,
|
||||
NodeVisitorHooks{
|
||||
VisitNodes: func(nodes *NodeList, v *NodeVisitor) *NodeList {
|
||||
if nodes == nil {
|
||||
return nil
|
||||
}
|
||||
visited := v.VisitNodes(nodes)
|
||||
var newList *NodeList
|
||||
if visited != nodes {
|
||||
newList = visited
|
||||
} else {
|
||||
newList = nodes.Clone(v.Factory)
|
||||
}
|
||||
if syntheticLocation {
|
||||
newList.Loc = core.NewTextRange(-1, -1)
|
||||
if nodes.HasTrailingComma() {
|
||||
newList.Nodes[len(newList.Nodes)-1].Loc = core.NewTextRange(-2, -2)
|
||||
}
|
||||
}
|
||||
return newList
|
||||
},
|
||||
VisitModifiers: func(nodes *ModifierList, v *NodeVisitor) *ModifierList {
|
||||
if nodes == nil {
|
||||
return nil
|
||||
}
|
||||
visited := v.VisitModifiers(nodes)
|
||||
var newList *ModifierList
|
||||
if visited != nodes {
|
||||
newList = visited
|
||||
} else {
|
||||
newList = nodes.Clone(v.Factory)
|
||||
}
|
||||
if syntheticLocation {
|
||||
newList.Loc = core.NewTextRange(-1, -1)
|
||||
if nodes.HasTrailingComma() {
|
||||
newList.Nodes[len(newList.Nodes)-1].Loc = core.NewTextRange(-2, -2)
|
||||
}
|
||||
}
|
||||
return newList
|
||||
},
|
||||
},
|
||||
)
|
||||
return visitor
|
||||
}
|
||||
|
||||
func (f *NodeFactory) DeepCloneNode(node *Node) *Node {
|
||||
return getDeepCloneVisitor(f, true /*syntheticLocation*/).VisitNode(node)
|
||||
}
|
||||
|
||||
func (f *NodeFactory) DeepCloneReparse(node *Node) *Node {
|
||||
if node != nil {
|
||||
node = getDeepCloneVisitor(f, false /*syntheticLocation*/).VisitNode(node)
|
||||
SetParentInChildren(node)
|
||||
node.Flags |= NodeFlagsReparsed
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
func (f *NodeFactory) DeepCloneReparseModifiers(modifiers *ModifierList) *ModifierList {
|
||||
return getDeepCloneVisitor(f, false /*syntheticLocation*/).VisitModifiers(modifiers)
|
||||
}
|
||||
599
kitcom/internal/tsgo/ast/deepclone_test.go
Normal file
599
kitcom/internal/tsgo/ast/deepclone_test.go
Normal file
@ -0,0 +1,599 @@
|
||||
package ast_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/testutil/parsetestutil"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
type NodeComparisonWorkItem struct {
|
||||
original *ast.Node
|
||||
copy *ast.Node
|
||||
}
|
||||
|
||||
func getChildren(node *ast.Node) []*ast.Node {
|
||||
children := []*ast.Node{}
|
||||
node.VisitEachChild(ast.NewNodeVisitor(func(node *ast.Node) *ast.Node {
|
||||
children = append(children, node)
|
||||
return node
|
||||
}, nil, ast.NodeVisitorHooks{}))
|
||||
return children
|
||||
}
|
||||
|
||||
func TestDeepCloneNodeSanityCheck(t *testing.T) {
|
||||
t.Parallel()
|
||||
data := []struct {
|
||||
title string
|
||||
input string
|
||||
jsx bool
|
||||
}{
|
||||
{title: "StringLiteral#1", input: `;"test"`},
|
||||
{title: "StringLiteral#2", input: `;'test'`},
|
||||
{title: "NumericLiteral", input: `0`},
|
||||
{title: "BigIntLiteral", input: `0n`},
|
||||
{title: "BooleanLiteral#1", input: `true`},
|
||||
{title: "BooleanLiteral#2", input: `false`},
|
||||
{title: "NoSubstitutionTemplateLiteral", input: "``"},
|
||||
{title: "RegularExpressionLiteral#1", input: `/a/`},
|
||||
{title: "RegularExpressionLiteral#2", input: `/a/g`},
|
||||
{title: "NullLiteral", input: `null`},
|
||||
{title: "ThisExpression", input: `this`},
|
||||
{title: "SuperExpression", input: `super()`},
|
||||
{title: "ImportExpression", input: `import()`},
|
||||
{title: "PropertyAccess#1", input: `a.b`},
|
||||
{title: "PropertyAccess#2", input: `a.#b`},
|
||||
{title: "PropertyAccess#3", input: `a?.b`},
|
||||
{title: "PropertyAccess#4", input: `a?.b.c`},
|
||||
{title: "PropertyAccess#5", input: `1..b`},
|
||||
{title: "PropertyAccess#6", input: `1.0.b`},
|
||||
{title: "PropertyAccess#7", input: `0x1.b`},
|
||||
{title: "PropertyAccess#8", input: `0b1.b`},
|
||||
{title: "PropertyAccess#9", input: `0o1.b`},
|
||||
{title: "PropertyAccess#10", input: `10e1.b`},
|
||||
{title: "PropertyAccess#11", input: `10E1.b`},
|
||||
{title: "ElementAccess#1", input: `a[b]`},
|
||||
{title: "ElementAccess#2", input: `a?.[b]`},
|
||||
{title: "ElementAccess#3", input: `a?.[b].c`},
|
||||
{title: "CallExpression#1", input: `a()`},
|
||||
{title: "CallExpression#2", input: `a<T>()`},
|
||||
{title: "CallExpression#3", input: `a(b)`},
|
||||
{title: "CallExpression#4", input: `a<T>(b)`},
|
||||
{title: "CallExpression#5", input: `a(b).c`},
|
||||
{title: "CallExpression#6", input: `a<T>(b).c`},
|
||||
{title: "CallExpression#7", input: `a?.(b)`},
|
||||
{title: "CallExpression#8", input: `a?.<T>(b)`},
|
||||
{title: "CallExpression#9", input: `a?.(b).c`},
|
||||
{title: "CallExpression#10", input: `a?.<T>(b).c`},
|
||||
{title: "CallExpression#11", input: `a<T, U>()`},
|
||||
{title: "CallExpression#12", input: `a<T,>()`},
|
||||
{title: "NewExpression#1", input: `new a`},
|
||||
{title: "NewExpression#2", input: `new a.b`},
|
||||
{title: "NewExpression#3", input: `new a()`},
|
||||
{title: "NewExpression#4", input: `new a.b()`},
|
||||
{title: "NewExpression#5", input: `new a<T>()`},
|
||||
{title: "NewExpression#6", input: `new a.b<T>()`},
|
||||
{title: "NewExpression#7", input: `new a(b)`},
|
||||
{title: "NewExpression#8", input: `new a.b(c)`},
|
||||
{title: "NewExpression#9", input: `new a<T>(b)`},
|
||||
{title: "NewExpression#10", input: `new a.b<T>(c)`},
|
||||
{title: "NewExpression#11", input: `new a(b).c`},
|
||||
{title: "NewExpression#12", input: `new a<T>(b).c`},
|
||||
{title: "TaggedTemplateExpression#1", input: "tag``"},
|
||||
{title: "TaggedTemplateExpression#2", input: "tag<T>``"},
|
||||
{title: "TypeAssertionExpression#1", input: `<T>a`},
|
||||
{title: "FunctionExpression#1", input: `(function(){})`},
|
||||
{title: "FunctionExpression#2", input: `(function f(){})`},
|
||||
{title: "FunctionExpression#3", input: `(function*f(){})`},
|
||||
{title: "FunctionExpression#4", input: `(async function f(){})`},
|
||||
{title: "FunctionExpression#5", input: `(async function*f(){})`},
|
||||
{title: "FunctionExpression#6", input: `(function<T>(){})`},
|
||||
{title: "FunctionExpression#7", input: `(function(a){})`},
|
||||
{title: "FunctionExpression#8", input: `(function():T{})`},
|
||||
{title: "ArrowFunction#1", input: `a=>{}`},
|
||||
{title: "ArrowFunction#2", input: `()=>{}`},
|
||||
{title: "ArrowFunction#3", input: `(a)=>{}`},
|
||||
{title: "ArrowFunction#4", input: `<T>(a)=>{}`},
|
||||
{title: "ArrowFunction#5", input: `async a=>{}`},
|
||||
{title: "ArrowFunction#6", input: `async()=>{}`},
|
||||
{title: "ArrowFunction#7", input: `async<T>()=>{}`},
|
||||
{title: "ArrowFunction#8", input: `():T=>{}`},
|
||||
{title: "ArrowFunction#9", input: `()=>a`},
|
||||
{title: "DeleteExpression", input: `delete a`},
|
||||
{title: "TypeOfExpression", input: `typeof a`},
|
||||
{title: "VoidExpression", input: `void a`},
|
||||
{title: "AwaitExpression", input: `await a`},
|
||||
{title: "PrefixUnaryExpression#1", input: `+a`},
|
||||
{title: "PrefixUnaryExpression#2", input: `++a`},
|
||||
{title: "PrefixUnaryExpression#3", input: `+ +a`},
|
||||
{title: "PrefixUnaryExpression#4", input: `+ ++a`},
|
||||
{title: "PrefixUnaryExpression#5", input: `-a`},
|
||||
{title: "PrefixUnaryExpression#6", input: `--a`},
|
||||
{title: "PrefixUnaryExpression#7", input: `- -a`},
|
||||
{title: "PrefixUnaryExpression#8", input: `- --a`},
|
||||
{title: "PrefixUnaryExpression#9", input: `+-a`},
|
||||
{title: "PrefixUnaryExpression#10", input: `+--a`},
|
||||
{title: "PrefixUnaryExpression#11", input: `-+a`},
|
||||
{title: "PrefixUnaryExpression#12", input: `-++a`},
|
||||
{title: "PrefixUnaryExpression#13", input: `~a`},
|
||||
{title: "PrefixUnaryExpression#14", input: `!a`},
|
||||
{title: "PostfixUnaryExpression#1", input: `a++`},
|
||||
{title: "PostfixUnaryExpression#2", input: `a--`},
|
||||
{title: "BinaryExpression#1", input: `a,b`},
|
||||
{title: "BinaryExpression#2", input: `a+b`},
|
||||
{title: "BinaryExpression#3", input: `a**b`},
|
||||
{title: "BinaryExpression#4", input: `a instanceof b`},
|
||||
{title: "BinaryExpression#5", input: `a in b`},
|
||||
{title: "ConditionalExpression", input: `a?b:c`},
|
||||
{title: "TemplateExpression#1", input: "`a${b}c`"},
|
||||
{title: "TemplateExpression#2", input: "`a${b}c${d}e`"},
|
||||
{title: "YieldExpression#1", input: `(function*() { yield })`},
|
||||
{title: "YieldExpression#2", input: `(function*() { yield a })`},
|
||||
{title: "YieldExpression#3", input: `(function*() { yield*a })`},
|
||||
{title: "SpreadElement", input: `[...a]`},
|
||||
{title: "ClassExpression#1", input: `(class {})`},
|
||||
{title: "ClassExpression#2", input: `(class a {})`},
|
||||
{title: "ClassExpression#3", input: `(class<T>{})`},
|
||||
{title: "ClassExpression#4", input: `(class a<T>{})`},
|
||||
{title: "ClassExpression#5", input: `(class extends b {})`},
|
||||
{title: "ClassExpression#6", input: `(class a extends b {})`},
|
||||
{title: "ClassExpression#7", input: `(class implements b {})`},
|
||||
{title: "ClassExpression#8", input: `(class a implements b {})`},
|
||||
{title: "ClassExpression#9", input: `(class implements b, c {})`},
|
||||
{title: "ClassExpression#10", input: `(class a implements b, c {})`},
|
||||
{title: "ClassExpression#11", input: `(class extends b implements c, d {})`},
|
||||
{title: "ClassExpression#12", input: `(class a extends b implements c, d {})`},
|
||||
{title: "ClassExpression#13", input: `(@a class {})`},
|
||||
{title: "OmittedExpression", input: `[,]`},
|
||||
{title: "ExpressionWithTypeArguments", input: `a<T>`},
|
||||
{title: "AsExpression", input: `a as T`},
|
||||
{title: "SatisfiesExpression", input: `a satisfies T`},
|
||||
{title: "NonNullExpression", input: `a!`},
|
||||
{title: "MetaProperty#1", input: `new.target`},
|
||||
{title: "MetaProperty#2", input: `import.meta`},
|
||||
{title: "ArrayLiteralExpression#1", input: `[]`},
|
||||
{title: "ArrayLiteralExpression#2", input: `[a]`},
|
||||
{title: "ArrayLiteralExpression#3", input: `[a,]`},
|
||||
{title: "ArrayLiteralExpression#4", input: `[,a]`},
|
||||
{title: "ArrayLiteralExpression#5", input: `[...a]`},
|
||||
{title: "ObjectLiteralExpression#1", input: `({})`},
|
||||
{title: "ObjectLiteralExpression#2", input: `({a,})`},
|
||||
{title: "ShorthandPropertyAssignment", input: `({a})`},
|
||||
{title: "PropertyAssignment", input: `({a:b})`},
|
||||
{title: "SpreadAssignment", input: `({...a})`},
|
||||
{title: "Block", input: `{}`},
|
||||
{title: "VariableStatement#1", input: `var a`},
|
||||
{title: "VariableStatement#2", input: `let a`},
|
||||
{title: "VariableStatement#3", input: `const a = b`},
|
||||
{title: "VariableStatement#4", input: `using a = b`},
|
||||
{title: "VariableStatement#5", input: `await using a = b`},
|
||||
{title: "EmptyStatement", input: `;`},
|
||||
{title: "IfStatement#1", input: `if(a);`},
|
||||
{title: "IfStatement#2", input: `if(a);else;`},
|
||||
{title: "IfStatement#3", input: `if(a);else{}`},
|
||||
{title: "IfStatement#4", input: `if(a);else if(b);`},
|
||||
{title: "IfStatement#5", input: `if(a);else if(b) {}`},
|
||||
{title: "IfStatement#6", input: `if(a) {}`},
|
||||
{title: "IfStatement#7", input: `if(a) {} else;`},
|
||||
{title: "IfStatement#8", input: `if(a) {} else {}`},
|
||||
{title: "IfStatement#9", input: `if(a) {} else if(b);`},
|
||||
{title: "IfStatement#10", input: `if(a) {} else if(b){}`},
|
||||
{title: "DoStatement#1", input: `do;while(a);`},
|
||||
{title: "DoStatement#2", input: `do {} while(a);`},
|
||||
{title: "WhileStatement#1", input: `while(a);`},
|
||||
{title: "WhileStatement#2", input: `while(a) {}`},
|
||||
{title: "ForStatement#1", input: `for(;;);`},
|
||||
{title: "ForStatement#2", input: `for(a;;);`},
|
||||
{title: "ForStatement#3", input: `for(var a;;);`},
|
||||
{title: "ForStatement#4", input: `for(;a;);`},
|
||||
{title: "ForStatement#5", input: `for(;;a);`},
|
||||
{title: "ForStatement#6", input: `for(;;){}`},
|
||||
{title: "ForInStatement#1", input: `for(a in b);`},
|
||||
{title: "ForInStatement#2", input: `for(var a in b);`},
|
||||
{title: "ForInStatement#3", input: `for(a in b){}`},
|
||||
{title: "ForOfStatement#1", input: `for(a of b);`},
|
||||
{title: "ForOfStatement#2", input: `for(var a of b);`},
|
||||
{title: "ForOfStatement#3", input: `for(a of b){}`},
|
||||
{title: "ForOfStatement#4", input: `for await(a of b);`},
|
||||
{title: "ForOfStatement#5", input: `for await(var a of b);`},
|
||||
{title: "ForOfStatement#6", input: `for await(a of b){}`},
|
||||
{title: "ContinueStatement#1", input: `continue`},
|
||||
{title: "ContinueStatement#2", input: `continue a`},
|
||||
{title: "BreakStatement#1", input: `break`},
|
||||
{title: "BreakStatement#2", input: `break a`},
|
||||
{title: "ReturnStatement#1", input: `return`},
|
||||
{title: "ReturnStatement#2", input: `return a`},
|
||||
{title: "WithStatement#1", input: `with(a);`},
|
||||
{title: "WithStatement#2", input: `with(a){}`},
|
||||
{title: "SwitchStatement", input: `switch (a) {}`},
|
||||
{title: "CaseClause#1", input: `switch (a) {case b:}`},
|
||||
{title: "CaseClause#2", input: `switch (a) {case b:;}`},
|
||||
{title: "DefaultClause#1", input: `switch (a) {default:}`},
|
||||
{title: "DefaultClause#2", input: `switch (a) {default:;}`},
|
||||
{title: "LabeledStatement", input: `a:;`},
|
||||
{title: "ThrowStatement", input: `throw a`},
|
||||
{title: "TryStatement#1", input: `try {} catch {}`},
|
||||
{title: "TryStatement#2", input: `try {} finally {}`},
|
||||
{title: "TryStatement#3", input: `try {} catch {} finally {}`},
|
||||
{title: "DebuggerStatement", input: `debugger`},
|
||||
{title: "FunctionDeclaration#1", input: `export default function(){}`},
|
||||
{title: "FunctionDeclaration#2", input: `function f(){}`},
|
||||
{title: "FunctionDeclaration#3", input: `function*f(){}`},
|
||||
{title: "FunctionDeclaration#4", input: `async function f(){}`},
|
||||
{title: "FunctionDeclaration#5", input: `async function*f(){}`},
|
||||
{title: "FunctionDeclaration#6", input: `function f<T>(){}`},
|
||||
{title: "FunctionDeclaration#7", input: `function f(a){}`},
|
||||
{title: "FunctionDeclaration#8", input: `function f():T{}`},
|
||||
{title: "FunctionDeclaration#9", input: `function f();`},
|
||||
{title: "ClassDeclaration#1", input: `class a {}`},
|
||||
{title: "ClassDeclaration#2", input: `class a<T>{}`},
|
||||
{title: "ClassDeclaration#3", input: `class a extends b {}`},
|
||||
{title: "ClassDeclaration#4", input: `class a implements b {}`},
|
||||
{title: "ClassDeclaration#5", input: `class a implements b, c {}`},
|
||||
{title: "ClassDeclaration#6", input: `class a extends b implements c, d {}`},
|
||||
{title: "ClassDeclaration#7", input: `export default class {}`},
|
||||
{title: "ClassDeclaration#8", input: `export default class<T>{}`},
|
||||
{title: "ClassDeclaration#9", input: `export default class extends b {}`},
|
||||
{title: "ClassDeclaration#10", input: `export default class implements b {}`},
|
||||
{title: "ClassDeclaration#11", input: `export default class implements b, c {}`},
|
||||
{title: "ClassDeclaration#12", input: `export default class extends b implements c, d {}`},
|
||||
{title: "ClassDeclaration#13", input: `@a class b {}`},
|
||||
{title: "ClassDeclaration#14", input: `@a export class b {}`},
|
||||
{title: "ClassDeclaration#15", input: `export @a class b {}`},
|
||||
{title: "InterfaceDeclaration#1", input: `interface a {}`},
|
||||
{title: "InterfaceDeclaration#2", input: `interface a<T>{}`},
|
||||
{title: "InterfaceDeclaration#3", input: `interface a extends b {}`},
|
||||
{title: "InterfaceDeclaration#4", input: `interface a extends b, c {}`},
|
||||
{title: "TypeAliasDeclaration#1", input: `type a = b`},
|
||||
{title: "TypeAliasDeclaration#2", input: `type a<T> = b`},
|
||||
{title: "EnumDeclaration#1", input: `enum a{}`},
|
||||
{title: "EnumDeclaration#2", input: `enum a{b}`},
|
||||
{title: "EnumDeclaration#3", input: `enum a{b=c}`},
|
||||
{title: "ModuleDeclaration#1", input: `module a{}`},
|
||||
{title: "ModuleDeclaration#2", input: `module a.b{}`},
|
||||
{title: "ModuleDeclaration#3", input: `module "a";`},
|
||||
{title: "ModuleDeclaration#4", input: `module "a"{}`},
|
||||
{title: "ModuleDeclaration#5", input: `namespace a{}`},
|
||||
{title: "ModuleDeclaration#6", input: `namespace a.b{}`},
|
||||
{title: "ModuleDeclaration#7", input: `global;`},
|
||||
{title: "ModuleDeclaration#8", input: `global{}`},
|
||||
{title: "ImportEqualsDeclaration#1", input: `import a = b`},
|
||||
{title: "ImportEqualsDeclaration#2", input: `import a = b.c`},
|
||||
{title: "ImportEqualsDeclaration#3", input: `import a = require("b")`},
|
||||
{title: "ImportEqualsDeclaration#4", input: `export import a = b`},
|
||||
{title: "ImportEqualsDeclaration#5", input: `export import a = require("b")`},
|
||||
{title: "ImportEqualsDeclaration#6", input: `import type a = b`},
|
||||
{title: "ImportEqualsDeclaration#7", input: `import type a = b.c`},
|
||||
{title: "ImportEqualsDeclaration#8", input: `import type a = require("b")`},
|
||||
{title: "ImportDeclaration#1", input: `import "a"`},
|
||||
{title: "ImportDeclaration#2", input: `import a from "b"`},
|
||||
{title: "ImportDeclaration#3", input: `import type a from "b"`},
|
||||
{title: "ImportDeclaration#4", input: `import * as a from "b"`},
|
||||
{title: "ImportDeclaration#5", input: `import type * as a from "b"`},
|
||||
{title: "ImportDeclaration#6", input: `import {} from "b"`},
|
||||
{title: "ImportDeclaration#7", input: `import type {} from "b"`},
|
||||
{title: "ImportDeclaration#8", input: `import { a } from "b"`},
|
||||
{title: "ImportDeclaration#9", input: `import type { a } from "b"`},
|
||||
{title: "ImportDeclaration#8", input: `import { a as b } from "c"`},
|
||||
{title: "ImportDeclaration#9", input: `import type { a as b } from "c"`},
|
||||
{title: "ImportDeclaration#10", input: `import { "a" as b } from "c"`},
|
||||
{title: "ImportDeclaration#11", input: `import type { "a" as b } from "c"`},
|
||||
{title: "ImportDeclaration#12", input: `import a, {} from "b"`},
|
||||
{title: "ImportDeclaration#13", input: `import a, * as b from "c"`},
|
||||
{title: "ImportDeclaration#14", input: `import {} from "a" with {}`},
|
||||
{title: "ImportDeclaration#15", input: `import {} from "a" with { b: "c" }`},
|
||||
{title: "ImportDeclaration#16", input: `import {} from "a" with { "b": "c" }`},
|
||||
{title: "ExportAssignment#1", input: `export = a`},
|
||||
{title: "ExportAssignment#2", input: `export default a`},
|
||||
{title: "NamespaceExportDeclaration", input: `export as namespace a`},
|
||||
{title: "ExportDeclaration#1", input: `export * from "a"`},
|
||||
{title: "ExportDeclaration#2", input: `export type * from "a"`},
|
||||
{title: "ExportDeclaration#3", input: `export * as a from "b"`},
|
||||
{title: "ExportDeclaration#4", input: `export type * as a from "b"`},
|
||||
{title: "ExportDeclaration#5", input: `export { } from "a"`},
|
||||
{title: "ExportDeclaration#6", input: `export type { } from "a"`},
|
||||
{title: "ExportDeclaration#7", input: `export { a } from "b"`},
|
||||
{title: "ExportDeclaration#8", input: `export { type a } from "b"`},
|
||||
{title: "ExportDeclaration#9", input: `export type { a } from "b"`},
|
||||
{title: "ExportDeclaration#10", input: `export { a as b } from "c"`},
|
||||
{title: "ExportDeclaration#11", input: `export { type a as b } from "c"`},
|
||||
{title: "ExportDeclaration#12", input: `export type { a as b } from "c"`},
|
||||
{title: "ExportDeclaration#13", input: `export { a as "b" } from "c"`},
|
||||
{title: "ExportDeclaration#14", input: `export { type a as "b" } from "c"`},
|
||||
{title: "ExportDeclaration#15", input: `export type { a as "b" } from "c"`},
|
||||
{title: "ExportDeclaration#16", input: `export { "a" } from "b"`},
|
||||
{title: "ExportDeclaration#17", input: `export { type "a" } from "b"`},
|
||||
{title: "ExportDeclaration#18", input: `export type { "a" } from "b"`},
|
||||
{title: "ExportDeclaration#19", input: `export { "a" as b } from "c"`},
|
||||
{title: "ExportDeclaration#20", input: `export { type "a" as b } from "c"`},
|
||||
{title: "ExportDeclaration#21", input: `export type { "a" as b } from "c"`},
|
||||
{title: "ExportDeclaration#22", input: `export { "a" as "b" } from "c"`},
|
||||
{title: "ExportDeclaration#23", input: `export { type "a" as "b" } from "c"`},
|
||||
{title: "ExportDeclaration#24", input: `export type { "a" as "b" } from "c"`},
|
||||
{title: "ExportDeclaration#25", input: `export { }`},
|
||||
{title: "ExportDeclaration#26", input: `export type { }`},
|
||||
{title: "ExportDeclaration#27", input: `export { a }`},
|
||||
{title: "ExportDeclaration#28", input: `export { type a }`},
|
||||
{title: "ExportDeclaration#29", input: `export type { a }`},
|
||||
{title: "ExportDeclaration#30", input: `export { a as b }`},
|
||||
{title: "ExportDeclaration#31", input: `export { type a as b }`},
|
||||
{title: "ExportDeclaration#32", input: `export type { a as b }`},
|
||||
{title: "ExportDeclaration#33", input: `export { a as "b" }`},
|
||||
{title: "ExportDeclaration#34", input: `export { type a as "b" }`},
|
||||
{title: "ExportDeclaration#35", input: `export type { a as "b" }`},
|
||||
{title: "ExportDeclaration#36", input: `export {} from "a" with {}`},
|
||||
{title: "ExportDeclaration#37", input: `export {} from "a" with { b: "c" }`},
|
||||
{title: "ExportDeclaration#38", input: `export {} from "a" with { "b": "c" }`},
|
||||
{title: "KeywordTypeNode#1", input: `type T = any`},
|
||||
{title: "KeywordTypeNode#2", input: `type T = unknown`},
|
||||
{title: "KeywordTypeNode#3", input: `type T = never`},
|
||||
{title: "KeywordTypeNode#4", input: `type T = void`},
|
||||
{title: "KeywordTypeNode#5", input: `type T = undefined`},
|
||||
{title: "KeywordTypeNode#6", input: `type T = null`},
|
||||
{title: "KeywordTypeNode#7", input: `type T = object`},
|
||||
{title: "KeywordTypeNode#8", input: `type T = string`},
|
||||
{title: "KeywordTypeNode#9", input: `type T = symbol`},
|
||||
{title: "KeywordTypeNode#10", input: `type T = number`},
|
||||
{title: "KeywordTypeNode#11", input: `type T = bigint`},
|
||||
{title: "KeywordTypeNode#12", input: `type T = boolean`},
|
||||
{title: "KeywordTypeNode#13", input: `type T = intrinsic`},
|
||||
{title: "TypePredicateNode#1", input: `function f(): asserts a`},
|
||||
{title: "TypePredicateNode#2", input: `function f(): asserts a is b`},
|
||||
{title: "TypePredicateNode#3", input: `function f(): asserts this`},
|
||||
{title: "TypePredicateNode#4", input: `function f(): asserts this is b`},
|
||||
{title: "TypeReferenceNode#1", input: `type T = a`},
|
||||
{title: "TypeReferenceNode#2", input: `type T = a.b`},
|
||||
{title: "TypeReferenceNode#3", input: `type T = a<U>`},
|
||||
{title: "TypeReferenceNode#4", input: `type T = a.b<U>`},
|
||||
{title: "FunctionTypeNode#1", input: `type T = () => a`},
|
||||
{title: "FunctionTypeNode#2", input: `type T = <T>() => a`},
|
||||
{title: "FunctionTypeNode#3", input: `type T = (a) => b`},
|
||||
{title: "ConstructorTypeNode#1", input: `type T = new () => a`},
|
||||
{title: "ConstructorTypeNode#2", input: `type T = new <T>() => a`},
|
||||
{title: "ConstructorTypeNode#3", input: `type T = new (a) => b`},
|
||||
{title: "ConstructorTypeNode#4", input: `type T = abstract new () => a`},
|
||||
{title: "TypeQueryNode#1", input: `type T = typeof a`},
|
||||
{title: "TypeQueryNode#2", input: `type T = typeof a.b`},
|
||||
{title: "TypeQueryNode#3", input: `type T = typeof a<U>`},
|
||||
{title: "TypeLiteralNode#1", input: `type T = {}`},
|
||||
{title: "TypeLiteralNode#2", input: `type T = {a}`},
|
||||
{title: "ArrayTypeNode", input: `type T = a[]`},
|
||||
{title: "TupleTypeNode#1", input: `type T = []`},
|
||||
{title: "TupleTypeNode#2", input: `type T = [a]`},
|
||||
{title: "TupleTypeNode#3", input: `type T = [a,]`},
|
||||
{title: "RestTypeNode", input: `type T = [...a]`},
|
||||
{title: "OptionalTypeNode", input: `type T = [a?]`},
|
||||
{title: "NamedTupleMember#1", input: `type T = [a: b]`},
|
||||
{title: "NamedTupleMember#2", input: `type T = [a?: b]`},
|
||||
{title: "NamedTupleMember#3", input: `type T = [...a: b]`},
|
||||
{title: "UnionTypeNode#1", input: `type T = a | b`},
|
||||
{title: "UnionTypeNode#2", input: `type T = a | b | c`},
|
||||
{title: "UnionTypeNode#3", input: `type T = | a | b`},
|
||||
{title: "IntersectionTypeNode#1", input: `type T = a & b`},
|
||||
{title: "IntersectionTypeNode#2", input: `type T = a & b & c`},
|
||||
{title: "IntersectionTypeNode#3", input: `type T = & a & b`},
|
||||
{title: "ConditionalTypeNode", input: `type T = a extends b ? c : d`},
|
||||
{title: "InferTypeNode#1", input: `type T = a extends infer b ? c : d`},
|
||||
{title: "InferTypeNode#2", input: `type T = a extends infer b extends c ? d : e`},
|
||||
{title: "ParenthesizedTypeNode", input: `type T = (U)`},
|
||||
{title: "ThisTypeNode", input: `type T = this`},
|
||||
{title: "TypeOperatorNode#1", input: `type T = keyof U`},
|
||||
{title: "TypeOperatorNode#2", input: `type T = readonly U[]`},
|
||||
{title: "TypeOperatorNode#3", input: `type T = unique symbol`},
|
||||
{title: "IndexedAccessTypeNode", input: `type T = a[b]`},
|
||||
{title: "MappedTypeNode#1", input: `type T = { [a in b]: c }`},
|
||||
{title: "MappedTypeNode#2", input: `type T = { [a in b as c]: d }`},
|
||||
{title: "MappedTypeNode#3", input: `type T = { readonly [a in b]: c }`},
|
||||
{title: "MappedTypeNode#4", input: `type T = { +readonly [a in b]: c }`},
|
||||
{title: "MappedTypeNode#5", input: `type T = { -readonly [a in b]: c }`},
|
||||
{title: "MappedTypeNode#6", input: `type T = { [a in b]?: c }`},
|
||||
{title: "MappedTypeNode#7", input: `type T = { [a in b]+?: c }`},
|
||||
{title: "MappedTypeNode#8", input: `type T = { [a in b]-?: c }`},
|
||||
{title: "MappedTypeNode#9", input: `type T = { [a in b]: c; d }`},
|
||||
{title: "LiteralTypeNode#1", input: `type T = null`},
|
||||
{title: "LiteralTypeNode#2", input: `type T = true`},
|
||||
{title: "LiteralTypeNode#3", input: `type T = false`},
|
||||
{title: "LiteralTypeNode#4", input: `type T = ""`},
|
||||
{title: "LiteralTypeNode#5", input: "type T = ''"},
|
||||
{title: "LiteralTypeNode#6", input: "type T = ``"},
|
||||
{title: "LiteralTypeNode#7", input: `type T = 0`},
|
||||
{title: "LiteralTypeNode#8", input: `type T = 0n`},
|
||||
{title: "LiteralTypeNode#9", input: `type T = -0`},
|
||||
{title: "LiteralTypeNode#10", input: `type T = -0n`},
|
||||
{title: "TemplateTypeNode#1", input: "type T = `a${b}c`"},
|
||||
{title: "TemplateTypeNode#2", input: "type T = `a${b}c${d}e`"},
|
||||
{title: "ImportTypeNode#1", input: `type T = import(a)`},
|
||||
{title: "ImportTypeNode#2", input: `type T = import(a).b`},
|
||||
{title: "ImportTypeNode#3", input: `type T = import(a).b<U>`},
|
||||
{title: "ImportTypeNode#4", input: `type T = typeof import(a)`},
|
||||
{title: "ImportTypeNode#5", input: `type T = typeof import(a).b`},
|
||||
{title: "ImportTypeNode#6", input: `type T = import(a, { with: { } })`},
|
||||
{title: "ImportTypeNode#6", input: `type T = import(a, { with: { b: "c" } })`},
|
||||
{title: "ImportTypeNode#7", input: `type T = import(a, { with: { "b": "c" } })`},
|
||||
{title: "PropertySignature#1", input: "interface I {a}"},
|
||||
{title: "PropertySignature#2", input: "interface I {readonly a}"},
|
||||
{title: "PropertySignature#3", input: "interface I {\"a\"}"},
|
||||
{title: "PropertySignature#4", input: "interface I {'a'}"},
|
||||
{title: "PropertySignature#5", input: "interface I {0}"},
|
||||
{title: "PropertySignature#6", input: "interface I {0n}"},
|
||||
{title: "PropertySignature#7", input: "interface I {[a]}"},
|
||||
{title: "PropertySignature#8", input: "interface I {a?}"},
|
||||
{title: "PropertySignature#9", input: "interface I {a: b}"},
|
||||
{title: "MethodSignature#1", input: "interface I {a()}"},
|
||||
{title: "MethodSignature#2", input: "interface I {\"a\"()}"},
|
||||
{title: "MethodSignature#3", input: "interface I {'a'()}"},
|
||||
{title: "MethodSignature#4", input: "interface I {0()}"},
|
||||
{title: "MethodSignature#5", input: "interface I {0n()}"},
|
||||
{title: "MethodSignature#6", input: "interface I {[a]()}"},
|
||||
{title: "MethodSignature#7", input: "interface I {a?()}"},
|
||||
{title: "MethodSignature#8", input: "interface I {a<T>()}"},
|
||||
{title: "MethodSignature#9", input: "interface I {a(): b}"},
|
||||
{title: "MethodSignature#10", input: "interface I {a(b): c}"},
|
||||
{title: "CallSignature#1", input: "interface I {()}"},
|
||||
{title: "CallSignature#2", input: "interface I {():a}"},
|
||||
{title: "CallSignature#3", input: "interface I {(p)}"},
|
||||
{title: "CallSignature#4", input: "interface I {<T>()}"},
|
||||
{title: "ConstructSignature#1", input: "interface I {new ()}"},
|
||||
{title: "ConstructSignature#2", input: "interface I {new ():a}"},
|
||||
{title: "ConstructSignature#3", input: "interface I {new (p)}"},
|
||||
{title: "ConstructSignature#4", input: "interface I {new <T>()}"},
|
||||
{title: "IndexSignatureDeclaration#1", input: "interface I {[a]}"},
|
||||
{title: "IndexSignatureDeclaration#2", input: "interface I {[a: b]}"},
|
||||
{title: "IndexSignatureDeclaration#3", input: "interface I {[a: b]: c}"},
|
||||
{title: "PropertyDeclaration#1", input: "class C {a}"},
|
||||
{title: "PropertyDeclaration#2", input: "class C {readonly a}"},
|
||||
{title: "PropertyDeclaration#3", input: "class C {static a}"},
|
||||
{title: "PropertyDeclaration#4", input: "class C {accessor a}"},
|
||||
{title: "PropertyDeclaration#5", input: "class C {\"a\"}"},
|
||||
{title: "PropertyDeclaration#6", input: "class C {'a'}"},
|
||||
{title: "PropertyDeclaration#7", input: "class C {0}"},
|
||||
{title: "PropertyDeclaration#8", input: "class C {0n}"},
|
||||
{title: "PropertyDeclaration#9", input: "class C {[a]}"},
|
||||
{title: "PropertyDeclaration#10", input: "class C {#a}"},
|
||||
{title: "PropertyDeclaration#11", input: "class C {a?}"},
|
||||
{title: "PropertyDeclaration#12", input: "class C {a!}"},
|
||||
{title: "PropertyDeclaration#13", input: "class C {a: b}"},
|
||||
{title: "PropertyDeclaration#14", input: "class C {a = b}"},
|
||||
{title: "PropertyDeclaration#15", input: "class C {@a b}"},
|
||||
{title: "MethodDeclaration#1", input: "class C {a()}"},
|
||||
{title: "MethodDeclaration#2", input: "class C {\"a\"()}"},
|
||||
{title: "MethodDeclaration#3", input: "class C {'a'()}"},
|
||||
{title: "MethodDeclaration#4", input: "class C {0()}"},
|
||||
{title: "MethodDeclaration#5", input: "class C {0n()}"},
|
||||
{title: "MethodDeclaration#6", input: "class C {[a]()}"},
|
||||
{title: "MethodDeclaration#7", input: "class C {#a()}"},
|
||||
{title: "MethodDeclaration#8", input: "class C {a?()}"},
|
||||
{title: "MethodDeclaration#9", input: "class C {a<T>()}"},
|
||||
{title: "MethodDeclaration#10", input: "class C {a(): b}"},
|
||||
{title: "MethodDeclaration#11", input: "class C {a(b): c}"},
|
||||
{title: "MethodDeclaration#12", input: "class C {a() {} }"},
|
||||
{title: "MethodDeclaration#13", input: "class C {@a b() {} }"},
|
||||
{title: "MethodDeclaration#14", input: "class C {static a() {} }"},
|
||||
{title: "MethodDeclaration#15", input: "class C {async a() {} }"},
|
||||
{title: "GetAccessorDeclaration#1", input: "class C {get a()}"},
|
||||
{title: "GetAccessorDeclaration#2", input: "class C {get \"a\"()}"},
|
||||
{title: "GetAccessorDeclaration#3", input: "class C {get 'a'()}"},
|
||||
{title: "GetAccessorDeclaration#4", input: "class C {get 0()}"},
|
||||
{title: "GetAccessorDeclaration#5", input: "class C {get 0n()}"},
|
||||
{title: "GetAccessorDeclaration#6", input: "class C {get [a]()}"},
|
||||
{title: "GetAccessorDeclaration#7", input: "class C {get #a()}"},
|
||||
{title: "GetAccessorDeclaration#8", input: "class C {get a(): b}"},
|
||||
{title: "GetAccessorDeclaration#9", input: "class C {get a(b): c}"},
|
||||
{title: "GetAccessorDeclaration#10", input: "class C {get a() {} }"},
|
||||
{title: "GetAccessorDeclaration#11", input: "class C {@a get b() {} }"},
|
||||
{title: "GetAccessorDeclaration#12", input: "class C {static get a() {} }"},
|
||||
{title: "SetAccessorDeclaration#1", input: "class C {set a()}"},
|
||||
{title: "SetAccessorDeclaration#2", input: "class C {set \"a\"()}"},
|
||||
{title: "SetAccessorDeclaration#3", input: "class C {set 'a'()}"},
|
||||
{title: "SetAccessorDeclaration#4", input: "class C {set 0()}"},
|
||||
{title: "SetAccessorDeclaration#5", input: "class C {set 0n()}"},
|
||||
{title: "SetAccessorDeclaration#6", input: "class C {set [a]()}"},
|
||||
{title: "SetAccessorDeclaration#7", input: "class C {set #a()}"},
|
||||
{title: "SetAccessorDeclaration#8", input: "class C {set a(): b}"},
|
||||
{title: "SetAccessorDeclaration#9", input: "class C {set a(b): c}"},
|
||||
{title: "SetAccessorDeclaration#10", input: "class C {set a() {} }"},
|
||||
{title: "SetAccessorDeclaration#11", input: "class C {@a set b() {} }"},
|
||||
{title: "SetAccessorDeclaration#12", input: "class C {static set a() {} }"},
|
||||
{title: "ConstructorDeclaration#1", input: "class C {constructor()}"},
|
||||
{title: "ConstructorDeclaration#2", input: "class C {constructor(): b}"},
|
||||
{title: "ConstructorDeclaration#3", input: "class C {constructor(b): c}"},
|
||||
{title: "ConstructorDeclaration#4", input: "class C {constructor() {} }"},
|
||||
{title: "ConstructorDeclaration#5", input: "class C {@a constructor() {} }"},
|
||||
{title: "ConstructorDeclaration#6", input: "class C {private constructor() {} }"},
|
||||
{title: "ClassStaticBlockDeclaration", input: "class C {static { }}"},
|
||||
{title: "SemicolonClassElement#1", input: "class C {;}"},
|
||||
{title: "ParameterDeclaration#1", input: "function f(a)"},
|
||||
{title: "ParameterDeclaration#2", input: "function f(a: b)"},
|
||||
{title: "ParameterDeclaration#3", input: "function f(a = b)"},
|
||||
{title: "ParameterDeclaration#4", input: "function f(a?)"},
|
||||
{title: "ParameterDeclaration#5", input: "function f(...a)"},
|
||||
{title: "ParameterDeclaration#6", input: "function f(this)"},
|
||||
{title: "ParameterDeclaration#7", input: "function f(a,)"},
|
||||
{title: "ObjectBindingPattern#1", input: "function f({})"},
|
||||
{title: "ObjectBindingPattern#2", input: "function f({a})"},
|
||||
{title: "ObjectBindingPattern#3", input: "function f({a = b})"},
|
||||
{title: "ObjectBindingPattern#4", input: "function f({a: b})"},
|
||||
{title: "ObjectBindingPattern#5", input: "function f({a: b = c})"},
|
||||
{title: "ObjectBindingPattern#6", input: "function f({\"a\": b})"},
|
||||
{title: "ObjectBindingPattern#7", input: "function f({'a': b})"},
|
||||
{title: "ObjectBindingPattern#8", input: "function f({0: b})"},
|
||||
{title: "ObjectBindingPattern#9", input: "function f({[a]: b})"},
|
||||
{title: "ObjectBindingPattern#10", input: "function f({...a})"},
|
||||
{title: "ObjectBindingPattern#11", input: "function f({a: {}})"},
|
||||
{title: "ObjectBindingPattern#12", input: "function f({a: []})"},
|
||||
{title: "ArrayBindingPattern#1", input: "function f([])"},
|
||||
{title: "ArrayBindingPattern#2", input: "function f([,])"},
|
||||
{title: "ArrayBindingPattern#3", input: "function f([a])"},
|
||||
{title: "ArrayBindingPattern#4", input: "function f([a, b])"},
|
||||
{title: "ArrayBindingPattern#5", input: "function f([a, , b])"},
|
||||
{title: "ArrayBindingPattern#6", input: "function f([a = b])"},
|
||||
{title: "ArrayBindingPattern#7", input: "function f([...a])"},
|
||||
{title: "ArrayBindingPattern#8", input: "function f([{}])"},
|
||||
{title: "ArrayBindingPattern#9", input: "function f([[]])"},
|
||||
{title: "TypeParameterDeclaration#1", input: "function f<T>();"},
|
||||
{title: "TypeParameterDeclaration#2", input: "function f<in T>();"},
|
||||
{title: "TypeParameterDeclaration#3", input: "function f<T extends U>();"},
|
||||
{title: "TypeParameterDeclaration#4", input: "function f<T = U>();"},
|
||||
{title: "TypeParameterDeclaration#5", input: "function f<T extends U = V>();"},
|
||||
{title: "TypeParameterDeclaration#6", input: "function f<T, U>();"},
|
||||
{title: "TypeParameterDeclaration#7", input: "function f<T,>();"},
|
||||
{title: "JsxElement1", input: "<a></a>"},
|
||||
{title: "JsxElement2", input: "<this></this>"},
|
||||
{title: "JsxElement3", input: "<a:b></a:b>"},
|
||||
{title: "JsxElement4", input: "<a.b></a.b>"},
|
||||
{title: "JsxElement5", input: "<a<b>></a>"},
|
||||
{title: "JsxElement6", input: "<a b></a>"},
|
||||
{title: "JsxElement7", input: "<a>b</a>"},
|
||||
{title: "JsxElement8", input: "<a>{b}</a>"},
|
||||
{title: "JsxElement9", input: "<a><b></b></a>"},
|
||||
{title: "JsxElement10", input: "<a><b /></a>"},
|
||||
{title: "JsxElement11", input: "<a><></></a>"},
|
||||
{title: "JsxSelfClosingElement1", input: "<a />"},
|
||||
{title: "JsxSelfClosingElement2", input: "<this />"},
|
||||
{title: "JsxSelfClosingElement3", input: "<a:b />"},
|
||||
{title: "JsxSelfClosingElement4", input: "<a.b />"},
|
||||
{title: "JsxSelfClosingElement5", input: "<a<b> />"},
|
||||
{title: "JsxSelfClosingElement6", input: "<a b/>"},
|
||||
{title: "JsxFragment1", input: "<></>"},
|
||||
{title: "JsxFragment2", input: "<>b</>"},
|
||||
{title: "JsxFragment3", input: "<>{b}</>"},
|
||||
{title: "JsxFragment4", input: "<><b></b></>"},
|
||||
{title: "JsxFragment5", input: "<><b /></>"},
|
||||
{title: "JsxFragment6", input: "<><></></>"},
|
||||
{title: "JsxAttribute1", input: "<a b/>"},
|
||||
{title: "JsxAttribute2", input: "<a b:c/>"},
|
||||
{title: "JsxAttribute3", input: "<a b=\"c\"/>"},
|
||||
{title: "JsxAttribute4", input: "<a b='c'/>"},
|
||||
{title: "JsxAttribute5", input: "<a b={c}/>"},
|
||||
{title: "JsxAttribute6", input: "<a b=<c></c>/>"},
|
||||
{title: "JsxAttribute7", input: "<a b=<c />/>"},
|
||||
{title: "JsxAttribute8", input: "<a b=<></>/>"},
|
||||
{title: "JsxSpreadAttribute", input: "<a {...b}/>"},
|
||||
}
|
||||
for _, rec := range data {
|
||||
t.Run("Clone "+rec.title, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
factory := &ast.NodeFactory{}
|
||||
file := parsetestutil.ParseTypeScript(rec.input, false).AsNode()
|
||||
clone := factory.DeepCloneNode(file.AsNode()).AsNode()
|
||||
|
||||
work := []NodeComparisonWorkItem{{file, clone}}
|
||||
|
||||
for len(work) > 0 {
|
||||
nextWork := []NodeComparisonWorkItem{}
|
||||
for _, item := range work {
|
||||
assert.Assert(t, item.original != item.copy)
|
||||
originalChildren := getChildren(item.original)
|
||||
copyChildren := getChildren(item.copy)
|
||||
assert.Equal(t, len(originalChildren), len(copyChildren))
|
||||
for i, child := range originalChildren {
|
||||
nextWork = append(nextWork, NodeComparisonWorkItem{child, copyChildren[i]})
|
||||
}
|
||||
}
|
||||
work = nextWork
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
272
kitcom/internal/tsgo/ast/diagnostic.go
Normal file
272
kitcom/internal/tsgo/ast/diagnostic.go
Normal file
@ -0,0 +1,272 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"maps"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/diagnostics"
|
||||
)
|
||||
|
||||
// Diagnostic
|
||||
|
||||
type Diagnostic struct {
|
||||
file *SourceFile
|
||||
loc core.TextRange
|
||||
code int32
|
||||
category diagnostics.Category
|
||||
message string
|
||||
messageChain []*Diagnostic
|
||||
relatedInformation []*Diagnostic
|
||||
reportsUnnecessary bool
|
||||
reportsDeprecated bool
|
||||
skippedOnNoEmit bool
|
||||
}
|
||||
|
||||
func (d *Diagnostic) File() *SourceFile { return d.file }
|
||||
func (d *Diagnostic) Pos() int { return d.loc.Pos() }
|
||||
func (d *Diagnostic) End() int { return d.loc.End() }
|
||||
func (d *Diagnostic) Len() int { return d.loc.Len() }
|
||||
func (d *Diagnostic) Loc() core.TextRange { return d.loc }
|
||||
func (d *Diagnostic) Code() int32 { return d.code }
|
||||
func (d *Diagnostic) Category() diagnostics.Category { return d.category }
|
||||
func (d *Diagnostic) Message() string { return d.message }
|
||||
func (d *Diagnostic) MessageChain() []*Diagnostic { return d.messageChain }
|
||||
func (d *Diagnostic) RelatedInformation() []*Diagnostic { return d.relatedInformation }
|
||||
func (d *Diagnostic) ReportsUnnecessary() bool { return d.reportsUnnecessary }
|
||||
func (d *Diagnostic) ReportsDeprecated() bool { return d.reportsDeprecated }
|
||||
func (d *Diagnostic) SkippedOnNoEmit() bool { return d.skippedOnNoEmit }
|
||||
|
||||
func (d *Diagnostic) SetFile(file *SourceFile) { d.file = file }
|
||||
func (d *Diagnostic) SetLocation(loc core.TextRange) { d.loc = loc }
|
||||
func (d *Diagnostic) SetCategory(category diagnostics.Category) { d.category = category }
|
||||
func (d *Diagnostic) SetSkippedOnNoEmit() { d.skippedOnNoEmit = true }
|
||||
|
||||
func (d *Diagnostic) SetMessageChain(messageChain []*Diagnostic) *Diagnostic {
|
||||
d.messageChain = messageChain
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *Diagnostic) AddMessageChain(messageChain *Diagnostic) *Diagnostic {
|
||||
if messageChain != nil {
|
||||
d.messageChain = append(d.messageChain, messageChain)
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *Diagnostic) SetRelatedInfo(relatedInformation []*Diagnostic) *Diagnostic {
|
||||
d.relatedInformation = relatedInformation
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *Diagnostic) AddRelatedInfo(relatedInformation *Diagnostic) *Diagnostic {
|
||||
if relatedInformation != nil {
|
||||
d.relatedInformation = append(d.relatedInformation, relatedInformation)
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *Diagnostic) Clone() *Diagnostic {
|
||||
result := *d
|
||||
return &result
|
||||
}
|
||||
|
||||
func NewDiagnosticWith(
|
||||
file *SourceFile,
|
||||
loc core.TextRange,
|
||||
code int32,
|
||||
category diagnostics.Category,
|
||||
message string,
|
||||
messageChain []*Diagnostic,
|
||||
relatedInformation []*Diagnostic,
|
||||
reportsUnnecessary bool,
|
||||
reportsDeprecated bool,
|
||||
skippedOnNoEmit bool,
|
||||
) *Diagnostic {
|
||||
return &Diagnostic{
|
||||
file: file,
|
||||
loc: loc,
|
||||
code: code,
|
||||
category: category,
|
||||
message: message,
|
||||
messageChain: messageChain,
|
||||
relatedInformation: relatedInformation,
|
||||
reportsUnnecessary: reportsUnnecessary,
|
||||
reportsDeprecated: reportsDeprecated,
|
||||
skippedOnNoEmit: skippedOnNoEmit,
|
||||
}
|
||||
}
|
||||
|
||||
func NewDiagnostic(file *SourceFile, loc core.TextRange, message *diagnostics.Message, args ...any) *Diagnostic {
|
||||
return &Diagnostic{
|
||||
file: file,
|
||||
loc: loc,
|
||||
code: message.Code(),
|
||||
category: message.Category(),
|
||||
message: message.Format(args...),
|
||||
reportsUnnecessary: message.ReportsUnnecessary(),
|
||||
reportsDeprecated: message.ReportsDeprecated(),
|
||||
}
|
||||
}
|
||||
|
||||
func NewDiagnosticChain(chain *Diagnostic, message *diagnostics.Message, args ...any) *Diagnostic {
|
||||
if chain != nil {
|
||||
return NewDiagnostic(chain.file, chain.loc, message, args...).AddMessageChain(chain).SetRelatedInfo(chain.relatedInformation)
|
||||
}
|
||||
return NewDiagnostic(nil, core.TextRange{}, message, args...)
|
||||
}
|
||||
|
||||
func NewCompilerDiagnostic(message *diagnostics.Message, args ...any) *Diagnostic {
|
||||
return NewDiagnostic(nil, core.UndefinedTextRange(), message, args...)
|
||||
}
|
||||
|
||||
type DiagnosticsCollection struct {
|
||||
fileDiagnostics map[string][]*Diagnostic
|
||||
nonFileDiagnostics []*Diagnostic
|
||||
}
|
||||
|
||||
func (c *DiagnosticsCollection) Add(diagnostic *Diagnostic) {
|
||||
if diagnostic.File() != nil {
|
||||
fileName := diagnostic.File().FileName()
|
||||
if c.fileDiagnostics == nil {
|
||||
c.fileDiagnostics = make(map[string][]*Diagnostic)
|
||||
}
|
||||
c.fileDiagnostics[fileName] = core.InsertSorted(c.fileDiagnostics[fileName], diagnostic, CompareDiagnostics)
|
||||
} else {
|
||||
c.nonFileDiagnostics = core.InsertSorted(c.nonFileDiagnostics, diagnostic, CompareDiagnostics)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *DiagnosticsCollection) Lookup(diagnostic *Diagnostic) *Diagnostic {
|
||||
var diagnostics []*Diagnostic
|
||||
if diagnostic.File() != nil {
|
||||
diagnostics = c.fileDiagnostics[diagnostic.File().FileName()]
|
||||
} else {
|
||||
diagnostics = c.nonFileDiagnostics
|
||||
}
|
||||
if i, ok := slices.BinarySearchFunc(diagnostics, diagnostic, CompareDiagnostics); ok {
|
||||
return diagnostics[i]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *DiagnosticsCollection) GetGlobalDiagnostics() []*Diagnostic {
|
||||
return c.nonFileDiagnostics
|
||||
}
|
||||
|
||||
func (c *DiagnosticsCollection) GetDiagnosticsForFile(fileName string) []*Diagnostic {
|
||||
return c.fileDiagnostics[fileName]
|
||||
}
|
||||
|
||||
func (c *DiagnosticsCollection) GetDiagnostics() []*Diagnostic {
|
||||
fileNames := slices.Collect(maps.Keys(c.fileDiagnostics))
|
||||
slices.Sort(fileNames)
|
||||
diagnostics := slices.Clip(c.nonFileDiagnostics)
|
||||
for _, fileName := range fileNames {
|
||||
diagnostics = append(diagnostics, c.fileDiagnostics[fileName]...)
|
||||
}
|
||||
return diagnostics
|
||||
}
|
||||
|
||||
func getDiagnosticPath(d *Diagnostic) string {
|
||||
if d.File() != nil {
|
||||
return d.File().FileName()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func EqualDiagnostics(d1, d2 *Diagnostic) bool {
|
||||
return EqualDiagnosticsNoRelatedInfo(d1, d2) &&
|
||||
slices.EqualFunc(d1.RelatedInformation(), d2.RelatedInformation(), EqualDiagnostics)
|
||||
}
|
||||
|
||||
func EqualDiagnosticsNoRelatedInfo(d1, d2 *Diagnostic) bool {
|
||||
return getDiagnosticPath(d1) == getDiagnosticPath(d2) &&
|
||||
d1.Loc() == d2.Loc() &&
|
||||
d1.Code() == d2.Code() &&
|
||||
d1.Message() == d2.Message() &&
|
||||
slices.EqualFunc(d1.MessageChain(), d2.MessageChain(), equalMessageChain)
|
||||
}
|
||||
|
||||
func equalMessageChain(c1, c2 *Diagnostic) bool {
|
||||
return c1.Code() == c2.Code() &&
|
||||
c1.Message() == c2.Message() &&
|
||||
slices.EqualFunc(c1.MessageChain(), c2.MessageChain(), equalMessageChain)
|
||||
}
|
||||
|
||||
func compareMessageChainSize(c1, c2 []*Diagnostic) int {
|
||||
c := len(c2) - len(c1)
|
||||
if c != 0 {
|
||||
return c
|
||||
}
|
||||
for i := range c1 {
|
||||
c = compareMessageChainSize(c1[i].MessageChain(), c2[i].MessageChain())
|
||||
if c != 0 {
|
||||
return c
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func compareMessageChainContent(c1, c2 []*Diagnostic) int {
|
||||
for i := range c1 {
|
||||
c := strings.Compare(c1[i].Message(), c2[i].Message())
|
||||
if c != 0 {
|
||||
return c
|
||||
}
|
||||
if c1[i].MessageChain() != nil {
|
||||
c = compareMessageChainContent(c1[i].MessageChain(), c2[i].MessageChain())
|
||||
if c != 0 {
|
||||
return c
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func compareRelatedInfo(r1, r2 []*Diagnostic) int {
|
||||
c := len(r2) - len(r1)
|
||||
if c != 0 {
|
||||
return c
|
||||
}
|
||||
for i := range r1 {
|
||||
c = CompareDiagnostics(r1[i], r2[i])
|
||||
if c != 0 {
|
||||
return c
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func CompareDiagnostics(d1, d2 *Diagnostic) int {
|
||||
c := strings.Compare(getDiagnosticPath(d1), getDiagnosticPath(d2))
|
||||
if c != 0 {
|
||||
return c
|
||||
}
|
||||
c = d1.Loc().Pos() - d2.Loc().Pos()
|
||||
if c != 0 {
|
||||
return c
|
||||
}
|
||||
c = d1.Loc().End() - d2.Loc().End()
|
||||
if c != 0 {
|
||||
return c
|
||||
}
|
||||
c = int(d1.Code()) - int(d2.Code())
|
||||
if c != 0 {
|
||||
return c
|
||||
}
|
||||
c = strings.Compare(d1.Message(), d2.Message())
|
||||
if c != 0 {
|
||||
return c
|
||||
}
|
||||
c = compareMessageChainSize(d1.MessageChain(), d2.MessageChain())
|
||||
if c != 0 {
|
||||
return c
|
||||
}
|
||||
c = compareMessageChainContent(d1.MessageChain(), d2.MessageChain())
|
||||
if c != 0 {
|
||||
return c
|
||||
}
|
||||
return compareRelatedInfo(d1.RelatedInformation(), d2.RelatedInformation())
|
||||
}
|
||||
75
kitcom/internal/tsgo/ast/flow.go
Normal file
75
kitcom/internal/tsgo/ast/flow.go
Normal file
@ -0,0 +1,75 @@
|
||||
package ast
|
||||
|
||||
// FlowFlags
|
||||
|
||||
type FlowFlags uint32
|
||||
|
||||
const (
|
||||
FlowFlagsUnreachable FlowFlags = 1 << 0 // Unreachable code
|
||||
FlowFlagsStart FlowFlags = 1 << 1 // Start of flow graph
|
||||
FlowFlagsBranchLabel FlowFlags = 1 << 2 // Non-looping junction
|
||||
FlowFlagsLoopLabel FlowFlags = 1 << 3 // Looping junction
|
||||
FlowFlagsAssignment FlowFlags = 1 << 4 // Assignment
|
||||
FlowFlagsTrueCondition FlowFlags = 1 << 5 // Condition known to be true
|
||||
FlowFlagsFalseCondition FlowFlags = 1 << 6 // Condition known to be false
|
||||
FlowFlagsSwitchClause FlowFlags = 1 << 7 // Switch statement clause
|
||||
FlowFlagsArrayMutation FlowFlags = 1 << 8 // Potential array mutation
|
||||
FlowFlagsCall FlowFlags = 1 << 9 // Potential assertion call
|
||||
FlowFlagsReduceLabel FlowFlags = 1 << 10 // Temporarily reduce antecedents of label
|
||||
FlowFlagsReferenced FlowFlags = 1 << 11 // Referenced as antecedent once
|
||||
FlowFlagsShared FlowFlags = 1 << 12 // Referenced as antecedent more than once
|
||||
FlowFlagsLabel = FlowFlagsBranchLabel | FlowFlagsLoopLabel
|
||||
FlowFlagsCondition = FlowFlagsTrueCondition | FlowFlagsFalseCondition
|
||||
)
|
||||
|
||||
// FlowNode
|
||||
|
||||
type FlowNode struct {
|
||||
Flags FlowFlags
|
||||
Node *Node // Associated AST node
|
||||
Antecedent *FlowNode // Antecedent for all but FlowLabel
|
||||
Antecedents *FlowList // Linked list of antecedents for FlowLabel
|
||||
}
|
||||
|
||||
type FlowList struct {
|
||||
Flow *FlowNode
|
||||
Next *FlowList
|
||||
}
|
||||
|
||||
type FlowLabel = FlowNode
|
||||
|
||||
// FlowSwitchClauseData (synthetic AST node for FlowFlagsSwitchClause)
|
||||
|
||||
type FlowSwitchClauseData struct {
|
||||
NodeBase
|
||||
SwitchStatement *Node
|
||||
ClauseStart int32 // Start index of case/default clause range
|
||||
ClauseEnd int32 // End index of case/default clause range
|
||||
}
|
||||
|
||||
func NewFlowSwitchClauseData(switchStatement *Node, clauseStart int, clauseEnd int) *Node {
|
||||
node := &FlowSwitchClauseData{}
|
||||
node.SwitchStatement = switchStatement
|
||||
node.ClauseStart = int32(clauseStart)
|
||||
node.ClauseEnd = int32(clauseEnd)
|
||||
return newNode(KindUnknown, node, NodeFactoryHooks{})
|
||||
}
|
||||
|
||||
func (node *FlowSwitchClauseData) IsEmpty() bool {
|
||||
return node.ClauseStart == node.ClauseEnd
|
||||
}
|
||||
|
||||
// FlowReduceLabelData (synthetic AST node for FlowFlagsReduceLabel)
|
||||
|
||||
type FlowReduceLabelData struct {
|
||||
NodeBase
|
||||
Target *FlowLabel // Target label
|
||||
Antecedents *FlowList // Temporary antecedent list
|
||||
}
|
||||
|
||||
func NewFlowReduceLabelData(target *FlowLabel, antecedents *FlowList) *Node {
|
||||
node := &FlowReduceLabelData{}
|
||||
node.Target = target
|
||||
node.Antecedents = antecedents
|
||||
return newNode(KindUnknown, node, NodeFactoryHooks{})
|
||||
}
|
||||
6
kitcom/internal/tsgo/ast/ids.go
Normal file
6
kitcom/internal/tsgo/ast/ids.go
Normal file
@ -0,0 +1,6 @@
|
||||
package ast
|
||||
|
||||
type (
|
||||
NodeId uint64
|
||||
SymbolId uint64
|
||||
)
|
||||
430
kitcom/internal/tsgo/ast/kind.go
Normal file
430
kitcom/internal/tsgo/ast/kind.go
Normal file
@ -0,0 +1,430 @@
|
||||
package ast
|
||||
|
||||
//go:generate go tool golang.org/x/tools/cmd/stringer -type=Kind -output=kind_stringer_generated.go
|
||||
//go:generate go tool mvdan.cc/gofumpt -w kind_stringer_generated.go
|
||||
|
||||
type Kind int16
|
||||
|
||||
const (
|
||||
KindUnknown Kind = iota
|
||||
KindEndOfFile
|
||||
KindSingleLineCommentTrivia
|
||||
KindMultiLineCommentTrivia
|
||||
KindNewLineTrivia
|
||||
KindWhitespaceTrivia
|
||||
KindConflictMarkerTrivia
|
||||
KindNonTextFileMarkerTrivia
|
||||
KindNumericLiteral
|
||||
KindBigIntLiteral
|
||||
KindStringLiteral
|
||||
KindJsxText
|
||||
KindJsxTextAllWhiteSpaces
|
||||
KindRegularExpressionLiteral
|
||||
KindNoSubstitutionTemplateLiteral
|
||||
// Pseudo-literals
|
||||
KindTemplateHead
|
||||
KindTemplateMiddle
|
||||
KindTemplateTail
|
||||
// Punctuation
|
||||
KindOpenBraceToken
|
||||
KindCloseBraceToken
|
||||
KindOpenParenToken
|
||||
KindCloseParenToken
|
||||
KindOpenBracketToken
|
||||
KindCloseBracketToken
|
||||
KindDotToken
|
||||
KindDotDotDotToken
|
||||
KindSemicolonToken
|
||||
KindCommaToken
|
||||
KindQuestionDotToken
|
||||
KindLessThanToken
|
||||
KindLessThanSlashToken
|
||||
KindGreaterThanToken
|
||||
KindLessThanEqualsToken
|
||||
KindGreaterThanEqualsToken
|
||||
KindEqualsEqualsToken
|
||||
KindExclamationEqualsToken
|
||||
KindEqualsEqualsEqualsToken
|
||||
KindExclamationEqualsEqualsToken
|
||||
KindEqualsGreaterThanToken
|
||||
KindPlusToken
|
||||
KindMinusToken
|
||||
KindAsteriskToken
|
||||
KindAsteriskAsteriskToken
|
||||
KindSlashToken
|
||||
KindPercentToken
|
||||
KindPlusPlusToken
|
||||
KindMinusMinusToken
|
||||
KindLessThanLessThanToken
|
||||
KindGreaterThanGreaterThanToken
|
||||
KindGreaterThanGreaterThanGreaterThanToken
|
||||
KindAmpersandToken
|
||||
KindBarToken
|
||||
KindCaretToken
|
||||
KindExclamationToken
|
||||
KindTildeToken
|
||||
KindAmpersandAmpersandToken
|
||||
KindBarBarToken
|
||||
KindQuestionToken
|
||||
KindColonToken
|
||||
KindAtToken
|
||||
KindQuestionQuestionToken
|
||||
/** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */
|
||||
KindBacktickToken
|
||||
/** Only the JSDoc scanner produces HashToken. The normal scanner produces PrivateIdentifier. */
|
||||
KindHashToken
|
||||
// Assignments
|
||||
KindEqualsToken
|
||||
KindPlusEqualsToken
|
||||
KindMinusEqualsToken
|
||||
KindAsteriskEqualsToken
|
||||
KindAsteriskAsteriskEqualsToken
|
||||
KindSlashEqualsToken
|
||||
KindPercentEqualsToken
|
||||
KindLessThanLessThanEqualsToken
|
||||
KindGreaterThanGreaterThanEqualsToken
|
||||
KindGreaterThanGreaterThanGreaterThanEqualsToken
|
||||
KindAmpersandEqualsToken
|
||||
KindBarEqualsToken
|
||||
KindBarBarEqualsToken
|
||||
KindAmpersandAmpersandEqualsToken
|
||||
KindQuestionQuestionEqualsToken
|
||||
KindCaretEqualsToken
|
||||
// Identifiers and PrivateIdentifier
|
||||
KindIdentifier
|
||||
KindPrivateIdentifier
|
||||
KindJSDocCommentTextToken
|
||||
// Reserved words
|
||||
KindBreakKeyword
|
||||
KindCaseKeyword
|
||||
KindCatchKeyword
|
||||
KindClassKeyword
|
||||
KindConstKeyword
|
||||
KindContinueKeyword
|
||||
KindDebuggerKeyword
|
||||
KindDefaultKeyword
|
||||
KindDeleteKeyword
|
||||
KindDoKeyword
|
||||
KindElseKeyword
|
||||
KindEnumKeyword
|
||||
KindExportKeyword
|
||||
KindExtendsKeyword
|
||||
KindFalseKeyword
|
||||
KindFinallyKeyword
|
||||
KindForKeyword
|
||||
KindFunctionKeyword
|
||||
KindIfKeyword
|
||||
KindImportKeyword
|
||||
KindInKeyword
|
||||
KindInstanceOfKeyword
|
||||
KindNewKeyword
|
||||
KindNullKeyword
|
||||
KindReturnKeyword
|
||||
KindSuperKeyword
|
||||
KindSwitchKeyword
|
||||
KindThisKeyword
|
||||
KindThrowKeyword
|
||||
KindTrueKeyword
|
||||
KindTryKeyword
|
||||
KindTypeOfKeyword
|
||||
KindVarKeyword
|
||||
KindVoidKeyword
|
||||
KindWhileKeyword
|
||||
KindWithKeyword
|
||||
// Strict mode reserved words
|
||||
KindImplementsKeyword
|
||||
KindInterfaceKeyword
|
||||
KindLetKeyword
|
||||
KindPackageKeyword
|
||||
KindPrivateKeyword
|
||||
KindProtectedKeyword
|
||||
KindPublicKeyword
|
||||
KindStaticKeyword
|
||||
KindYieldKeyword
|
||||
// Contextual keywords
|
||||
KindAbstractKeyword
|
||||
KindAccessorKeyword
|
||||
KindAsKeyword
|
||||
KindAssertsKeyword
|
||||
KindAssertKeyword
|
||||
KindAnyKeyword
|
||||
KindAsyncKeyword
|
||||
KindAwaitKeyword
|
||||
KindBooleanKeyword
|
||||
KindConstructorKeyword
|
||||
KindDeclareKeyword
|
||||
KindGetKeyword
|
||||
KindImmediateKeyword
|
||||
KindInferKeyword
|
||||
KindIntrinsicKeyword
|
||||
KindIsKeyword
|
||||
KindKeyOfKeyword
|
||||
KindModuleKeyword
|
||||
KindNamespaceKeyword
|
||||
KindNeverKeyword
|
||||
KindOutKeyword
|
||||
KindReadonlyKeyword
|
||||
KindRequireKeyword
|
||||
KindNumberKeyword
|
||||
KindObjectKeyword
|
||||
KindSatisfiesKeyword
|
||||
KindSetKeyword
|
||||
KindStringKeyword
|
||||
KindSymbolKeyword
|
||||
KindTypeKeyword
|
||||
KindUndefinedKeyword
|
||||
KindUniqueKeyword
|
||||
KindUnknownKeyword
|
||||
KindUsingKeyword
|
||||
KindFromKeyword
|
||||
KindGlobalKeyword
|
||||
KindBigIntKeyword
|
||||
KindOverrideKeyword
|
||||
KindOfKeyword
|
||||
KindDeferKeyword // LastKeyword and LastToken and LastContextualKeyword
|
||||
// Parse tree nodes
|
||||
// Names
|
||||
KindQualifiedName
|
||||
KindComputedPropertyName
|
||||
// Signature elements
|
||||
KindTypeParameter
|
||||
KindParameter
|
||||
KindDecorator
|
||||
// TypeMember
|
||||
KindPropertySignature
|
||||
KindPropertyDeclaration
|
||||
KindMethodSignature
|
||||
KindMethodDeclaration
|
||||
KindClassStaticBlockDeclaration
|
||||
KindConstructor
|
||||
KindGetAccessor
|
||||
KindSetAccessor
|
||||
KindCallSignature
|
||||
KindConstructSignature
|
||||
KindIndexSignature
|
||||
// Type
|
||||
KindTypePredicate
|
||||
KindTypeReference
|
||||
KindFunctionType
|
||||
KindConstructorType
|
||||
KindTypeQuery
|
||||
KindTypeLiteral
|
||||
KindArrayType
|
||||
KindTupleType
|
||||
KindOptionalType
|
||||
KindRestType
|
||||
KindUnionType
|
||||
KindIntersectionType
|
||||
KindConditionalType
|
||||
KindInferType
|
||||
KindParenthesizedType
|
||||
KindThisType
|
||||
KindTypeOperator
|
||||
KindIndexedAccessType
|
||||
KindMappedType
|
||||
KindLiteralType
|
||||
KindNamedTupleMember
|
||||
KindTemplateLiteralType
|
||||
KindTemplateLiteralTypeSpan
|
||||
KindImportType
|
||||
// Binding patterns
|
||||
KindObjectBindingPattern
|
||||
KindArrayBindingPattern
|
||||
KindBindingElement
|
||||
// Expression
|
||||
KindArrayLiteralExpression
|
||||
KindObjectLiteralExpression
|
||||
KindPropertyAccessExpression
|
||||
KindElementAccessExpression
|
||||
KindCallExpression
|
||||
KindNewExpression
|
||||
KindTaggedTemplateExpression
|
||||
KindTypeAssertionExpression
|
||||
KindParenthesizedExpression
|
||||
KindFunctionExpression
|
||||
KindArrowFunction
|
||||
KindDeleteExpression
|
||||
KindTypeOfExpression
|
||||
KindVoidExpression
|
||||
KindAwaitExpression
|
||||
KindPrefixUnaryExpression
|
||||
KindPostfixUnaryExpression
|
||||
KindBinaryExpression
|
||||
KindConditionalExpression
|
||||
KindTemplateExpression
|
||||
KindYieldExpression
|
||||
KindSpreadElement
|
||||
KindClassExpression
|
||||
KindOmittedExpression
|
||||
KindExpressionWithTypeArguments
|
||||
KindAsExpression
|
||||
KindNonNullExpression
|
||||
KindMetaProperty
|
||||
KindSyntheticExpression
|
||||
KindSatisfiesExpression
|
||||
// Misc
|
||||
KindTemplateSpan
|
||||
KindSemicolonClassElement
|
||||
// Element
|
||||
KindBlock
|
||||
KindEmptyStatement
|
||||
KindVariableStatement
|
||||
KindExpressionStatement
|
||||
KindIfStatement
|
||||
KindDoStatement
|
||||
KindWhileStatement
|
||||
KindForStatement
|
||||
KindForInStatement
|
||||
KindForOfStatement
|
||||
KindContinueStatement
|
||||
KindBreakStatement
|
||||
KindReturnStatement
|
||||
KindWithStatement
|
||||
KindSwitchStatement
|
||||
KindLabeledStatement
|
||||
KindThrowStatement
|
||||
KindTryStatement
|
||||
KindDebuggerStatement
|
||||
KindVariableDeclaration
|
||||
KindVariableDeclarationList
|
||||
KindFunctionDeclaration
|
||||
KindClassDeclaration
|
||||
KindInterfaceDeclaration
|
||||
KindTypeAliasDeclaration
|
||||
KindEnumDeclaration
|
||||
KindModuleDeclaration
|
||||
KindModuleBlock
|
||||
KindCaseBlock
|
||||
KindNamespaceExportDeclaration
|
||||
KindImportEqualsDeclaration
|
||||
KindImportDeclaration
|
||||
KindImportClause
|
||||
KindNamespaceImport
|
||||
KindNamedImports
|
||||
KindImportSpecifier
|
||||
KindExportAssignment
|
||||
KindExportDeclaration
|
||||
KindNamedExports
|
||||
KindNamespaceExport
|
||||
KindExportSpecifier
|
||||
KindMissingDeclaration
|
||||
// Module references
|
||||
KindExternalModuleReference
|
||||
// JSX
|
||||
KindJsxElement
|
||||
KindJsxSelfClosingElement
|
||||
KindJsxOpeningElement
|
||||
KindJsxClosingElement
|
||||
KindJsxFragment
|
||||
KindJsxOpeningFragment
|
||||
KindJsxClosingFragment
|
||||
KindJsxAttribute
|
||||
KindJsxAttributes
|
||||
KindJsxSpreadAttribute
|
||||
KindJsxExpression
|
||||
KindJsxNamespacedName
|
||||
// Clauses
|
||||
KindCaseClause
|
||||
KindDefaultClause
|
||||
KindHeritageClause
|
||||
KindCatchClause
|
||||
// Import attributes
|
||||
KindImportAttributes
|
||||
KindImportAttribute
|
||||
// Property assignments
|
||||
KindPropertyAssignment
|
||||
KindShorthandPropertyAssignment
|
||||
KindSpreadAssignment
|
||||
// Enum
|
||||
KindEnumMember
|
||||
// Top-level nodes
|
||||
KindSourceFile
|
||||
KindBundle
|
||||
// JSDoc nodes
|
||||
KindJSDocTypeExpression
|
||||
KindJSDocNameReference
|
||||
KindJSDocMemberName // C#p
|
||||
KindJSDocAllType // The * type
|
||||
KindJSDocNullableType
|
||||
KindJSDocNonNullableType
|
||||
KindJSDocOptionalType
|
||||
KindJSDocVariadicType
|
||||
KindJSDoc
|
||||
KindJSDocText
|
||||
KindJSDocTypeLiteral
|
||||
KindJSDocSignature
|
||||
KindJSDocLink
|
||||
KindJSDocLinkCode
|
||||
KindJSDocLinkPlain
|
||||
KindJSDocTag
|
||||
KindJSDocAugmentsTag
|
||||
KindJSDocImplementsTag
|
||||
KindJSDocDeprecatedTag
|
||||
KindJSDocPublicTag
|
||||
KindJSDocPrivateTag
|
||||
KindJSDocProtectedTag
|
||||
KindJSDocReadonlyTag
|
||||
KindJSDocOverrideTag
|
||||
KindJSDocCallbackTag
|
||||
KindJSDocOverloadTag
|
||||
KindJSDocParameterTag
|
||||
KindJSDocReturnTag
|
||||
KindJSDocThisTag
|
||||
KindJSDocTypeTag
|
||||
KindJSDocTemplateTag
|
||||
KindJSDocTypedefTag
|
||||
KindJSDocSeeTag
|
||||
KindJSDocPropertyTag
|
||||
KindJSDocSatisfiesTag
|
||||
KindJSDocImportTag
|
||||
// Synthesized list
|
||||
KindSyntaxList
|
||||
// Reparsed JS nodes
|
||||
KindJSTypeAliasDeclaration
|
||||
KindJSExportAssignment
|
||||
KindCommonJSExport
|
||||
KindJSImportDeclaration
|
||||
// Transformation nodes
|
||||
KindNotEmittedStatement
|
||||
KindPartiallyEmittedExpression
|
||||
KindCommaListExpression
|
||||
KindSyntheticReferenceExpression
|
||||
KindNotEmittedTypeElement
|
||||
// Enum value count
|
||||
KindCount
|
||||
// Markers
|
||||
KindFirstAssignment = KindEqualsToken
|
||||
KindLastAssignment = KindCaretEqualsToken
|
||||
KindFirstCompoundAssignment = KindPlusEqualsToken
|
||||
KindLastCompoundAssignment = KindCaretEqualsToken
|
||||
KindFirstReservedWord = KindBreakKeyword
|
||||
KindLastReservedWord = KindWithKeyword
|
||||
KindFirstKeyword = KindBreakKeyword
|
||||
KindLastKeyword = KindDeferKeyword
|
||||
KindFirstFutureReservedWord = KindImplementsKeyword
|
||||
KindLastFutureReservedWord = KindYieldKeyword
|
||||
KindFirstTypeNode = KindTypePredicate
|
||||
KindLastTypeNode = KindImportType
|
||||
KindFirstPunctuation = KindOpenBraceToken
|
||||
KindLastPunctuation = KindCaretEqualsToken
|
||||
KindFirstToken = KindUnknown
|
||||
KindLastToken = KindLastKeyword
|
||||
KindFirstLiteralToken = KindNumericLiteral
|
||||
KindLastLiteralToken = KindNoSubstitutionTemplateLiteral
|
||||
KindFirstTemplateToken = KindNoSubstitutionTemplateLiteral
|
||||
KindLastTemplateToken = KindTemplateTail
|
||||
KindFirstBinaryOperator = KindLessThanToken
|
||||
KindLastBinaryOperator = KindCaretEqualsToken
|
||||
KindFirstStatement = KindVariableStatement
|
||||
KindLastStatement = KindDebuggerStatement
|
||||
KindFirstNode = KindQualifiedName
|
||||
KindFirstJSDocNode = KindJSDocTypeExpression
|
||||
KindLastJSDocNode = KindJSDocImportTag
|
||||
KindFirstJSDocTagNode = KindJSDocTag
|
||||
KindLastJSDocTagNode = KindJSDocImportTag
|
||||
KindFirstContextualKeyword = KindAbstractKeyword
|
||||
KindLastContextualKeyword = KindDeferKeyword
|
||||
KindComment = KindSingleLineCommentTrivia | KindMultiLineCommentTrivia
|
||||
KindFirstTriviaToken = KindSingleLineCommentTrivia
|
||||
KindLastTriviaToken = KindConflictMarkerTrivia
|
||||
)
|
||||
378
kitcom/internal/tsgo/ast/kind_stringer_generated.go
Normal file
378
kitcom/internal/tsgo/ast/kind_stringer_generated.go
Normal file
File diff suppressed because one or more lines are too long
53
kitcom/internal/tsgo/ast/modifierflags.go
Normal file
53
kitcom/internal/tsgo/ast/modifierflags.go
Normal file
@ -0,0 +1,53 @@
|
||||
package ast
|
||||
|
||||
type ModifierFlags uint32
|
||||
|
||||
const (
|
||||
ModifierFlagsNone ModifierFlags = 0
|
||||
// Syntactic/JSDoc modifiers
|
||||
ModifierFlagsPublic ModifierFlags = 1 << 0 // Property/Method
|
||||
ModifierFlagsPrivate ModifierFlags = 1 << 1 // Property/Method
|
||||
ModifierFlagsProtected ModifierFlags = 1 << 2 // Property/Method
|
||||
ModifierFlagsReadonly ModifierFlags = 1 << 3 // Property/Method
|
||||
ModifierFlagsOverride ModifierFlags = 1 << 4 // Override method
|
||||
// Syntactic-only modifiers
|
||||
ModifierFlagsExport ModifierFlags = 1 << 5 // Declarations
|
||||
ModifierFlagsAbstract ModifierFlags = 1 << 6 // Class/Method/ConstructSignature
|
||||
ModifierFlagsAmbient ModifierFlags = 1 << 7 // Declarations (declare keyword)
|
||||
ModifierFlagsStatic ModifierFlags = 1 << 8 // Property/Method
|
||||
ModifierFlagsAccessor ModifierFlags = 1 << 9 // Property
|
||||
ModifierFlagsAsync ModifierFlags = 1 << 10 // Property/Method/Function
|
||||
ModifierFlagsDefault ModifierFlags = 1 << 11 // Function/Class (export default declaration)
|
||||
ModifierFlagsConst ModifierFlags = 1 << 12 // Const enum
|
||||
ModifierFlagsIn ModifierFlags = 1 << 13 // Contravariance modifier
|
||||
ModifierFlagsOut ModifierFlags = 1 << 14 // Covariance modifier
|
||||
ModifierFlagsDecorator ModifierFlags = 1 << 15 // Contains a decorator
|
||||
// JSDoc-only modifiers
|
||||
ModifierFlagsDeprecated ModifierFlags = 1 << 16 // Deprecated tag
|
||||
// Cache-only JSDoc-modifiers. Should match order of Syntactic/JSDoc modifiers, above.
|
||||
ModifierFlagsJSDocPublic ModifierFlags = 1 << 23 // if this value changes, `selectEffectiveModifierFlags` must change accordingly
|
||||
ModifierFlagsJSDocPrivate ModifierFlags = 1 << 24
|
||||
ModifierFlagsJSDocProtected ModifierFlags = 1 << 25
|
||||
ModifierFlagsJSDocReadonly ModifierFlags = 1 << 26
|
||||
ModifierFlagsJSDocOverride ModifierFlags = 1 << 27
|
||||
ModifierFlagsHasComputedJSDocModifiers ModifierFlags = 1 << 28 // Indicates the computed modifier flags include modifiers from JSDoc.
|
||||
ModifierFlagsHasComputedFlags ModifierFlags = 1 << 29 // Modifier flags have been computed
|
||||
|
||||
ModifierFlagsSyntacticOrJSDocModifiers = ModifierFlagsPublic | ModifierFlagsPrivate | ModifierFlagsProtected | ModifierFlagsReadonly | ModifierFlagsOverride
|
||||
ModifierFlagsSyntacticOnlyModifiers = ModifierFlagsExport | ModifierFlagsAmbient | ModifierFlagsAbstract | ModifierFlagsStatic | ModifierFlagsAccessor | ModifierFlagsAsync | ModifierFlagsDefault | ModifierFlagsConst | ModifierFlagsIn | ModifierFlagsOut | ModifierFlagsDecorator
|
||||
ModifierFlagsSyntacticModifiers = ModifierFlagsSyntacticOrJSDocModifiers | ModifierFlagsSyntacticOnlyModifiers
|
||||
ModifierFlagsJSDocCacheOnlyModifiers = ModifierFlagsJSDocPublic | ModifierFlagsJSDocPrivate | ModifierFlagsJSDocProtected | ModifierFlagsJSDocReadonly | ModifierFlagsJSDocOverride
|
||||
ModifierFlagsJSDocOnlyModifiers = ModifierFlagsDeprecated
|
||||
ModifierFlagsNonCacheOnlyModifiers = ModifierFlagsSyntacticOrJSDocModifiers | ModifierFlagsSyntacticOnlyModifiers | ModifierFlagsJSDocOnlyModifiers
|
||||
|
||||
ModifierFlagsAccessibilityModifier = ModifierFlagsPublic | ModifierFlagsPrivate | ModifierFlagsProtected
|
||||
// Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property.
|
||||
ModifierFlagsParameterPropertyModifier = ModifierFlagsAccessibilityModifier | ModifierFlagsReadonly | ModifierFlagsOverride
|
||||
ModifierFlagsNonPublicAccessibilityModifier = ModifierFlagsPrivate | ModifierFlagsProtected
|
||||
|
||||
ModifierFlagsTypeScriptModifier = ModifierFlagsAmbient | ModifierFlagsPublic | ModifierFlagsPrivate | ModifierFlagsProtected | ModifierFlagsReadonly | ModifierFlagsAbstract | ModifierFlagsConst | ModifierFlagsOverride | ModifierFlagsIn | ModifierFlagsOut
|
||||
ModifierFlagsExportDefault = ModifierFlagsExport | ModifierFlagsDefault
|
||||
ModifierFlagsAll = ModifierFlagsExport | ModifierFlagsAmbient | ModifierFlagsPublic | ModifierFlagsPrivate | ModifierFlagsProtected | ModifierFlagsStatic | ModifierFlagsReadonly | ModifierFlagsAbstract | ModifierFlagsAccessor | ModifierFlagsAsync | ModifierFlagsDefault | ModifierFlagsConst | ModifierFlagsDeprecated | ModifierFlagsOverride | ModifierFlagsIn | ModifierFlagsOut | ModifierFlagsDecorator
|
||||
ModifierFlagsModifier = ModifierFlagsAll & ^ModifierFlagsDecorator
|
||||
ModifierFlagsJavaScript = ModifierFlagsExport | ModifierFlagsStatic | ModifierFlagsAccessor | ModifierFlagsAsync | ModifierFlagsDefault
|
||||
)
|
||||
65
kitcom/internal/tsgo/ast/nodeflags.go
Normal file
65
kitcom/internal/tsgo/ast/nodeflags.go
Normal file
@ -0,0 +1,65 @@
|
||||
package ast
|
||||
|
||||
type NodeFlags uint32
|
||||
|
||||
const (
|
||||
NodeFlagsNone NodeFlags = 0
|
||||
NodeFlagsLet NodeFlags = 1 << 0 // Variable declaration
|
||||
NodeFlagsConst NodeFlags = 1 << 1 // Variable declaration
|
||||
NodeFlagsUsing NodeFlags = 1 << 2 // Variable declaration
|
||||
NodeFlagsReparsed NodeFlags = 1 << 3 // Node was synthesized during parsing
|
||||
NodeFlagsSynthesized NodeFlags = 1 << 4 // Node was synthesized during transformation
|
||||
NodeFlagsOptionalChain NodeFlags = 1 << 5 // Chained MemberExpression rooted to a pseudo-OptionalExpression
|
||||
NodeFlagsExportContext NodeFlags = 1 << 6 // Export context (initialized by binding)
|
||||
NodeFlagsContainsThis NodeFlags = 1 << 7 // Interface contains references to "this"
|
||||
NodeFlagsHasImplicitReturn NodeFlags = 1 << 8 // If function implicitly returns on one of codepaths (initialized by binding)
|
||||
NodeFlagsHasExplicitReturn NodeFlags = 1 << 9 // If function has explicit reachable return on one of codepaths (initialized by binding)
|
||||
NodeFlagsDisallowInContext NodeFlags = 1 << 10 // If node was parsed in a context where 'in-expressions' are not allowed
|
||||
NodeFlagsYieldContext NodeFlags = 1 << 11 // If node was parsed in the 'yield' context created when parsing a generator
|
||||
NodeFlagsDecoratorContext NodeFlags = 1 << 12 // If node was parsed as part of a decorator
|
||||
NodeFlagsAwaitContext NodeFlags = 1 << 13 // If node was parsed in the 'await' context created when parsing an async function
|
||||
NodeFlagsDisallowConditionalTypesContext NodeFlags = 1 << 14 // If node was parsed in a context where conditional types are not allowed
|
||||
NodeFlagsThisNodeHasError NodeFlags = 1 << 15 // If the parser encountered an error when parsing the code that created this node
|
||||
NodeFlagsJavaScriptFile NodeFlags = 1 << 16 // If node was parsed in a JavaScript
|
||||
NodeFlagsThisNodeOrAnySubNodesHasError NodeFlags = 1 << 17 // If this node or any of its children had an error
|
||||
NodeFlagsHasAggregatedChildData NodeFlags = 1 << 18 // If we've computed data from children and cached it in this node
|
||||
|
||||
// These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid
|
||||
// walking the tree if the flags are not set. However, these flags are just a approximation
|
||||
// (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared.
|
||||
// During editing, if a dynamic import is removed, incremental parsing will *NOT* clear this flag.
|
||||
// This means that the tree will always be traversed during module resolution, or when looking for external module indicators.
|
||||
// However, the removal operation should not occur often and in the case of the
|
||||
// removal, it is likely that users will add the import anyway.
|
||||
// The advantage of this approach is its simplicity. For the case of batch compilation,
|
||||
// we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used.
|
||||
NodeFlagsPossiblyContainsDynamicImport NodeFlags = 1 << 19
|
||||
NodeFlagsPossiblyContainsImportMeta NodeFlags = 1 << 20
|
||||
|
||||
NodeFlagsHasJSDoc NodeFlags = 1 << 21 // If node has preceding JSDoc comment(s)
|
||||
NodeFlagsJSDoc NodeFlags = 1 << 22 // If node was parsed inside jsdoc
|
||||
NodeFlagsAmbient NodeFlags = 1 << 23 // If node was inside an ambient context -- a declaration file, or inside something with the `declare` modifier.
|
||||
NodeFlagsInWithStatement NodeFlags = 1 << 24 // If any ancestor of node was the `statement` of a WithStatement (not the `expression`)
|
||||
NodeFlagsJsonFile NodeFlags = 1 << 25 // If node was parsed in a Json
|
||||
NodeFlagsDeprecated NodeFlags = 1 << 26 // If has '@deprecated' JSDoc tag
|
||||
|
||||
NodeFlagsBlockScoped = NodeFlagsLet | NodeFlagsConst | NodeFlagsUsing
|
||||
NodeFlagsConstant = NodeFlagsConst | NodeFlagsUsing
|
||||
NodeFlagsAwaitUsing = NodeFlagsConst | NodeFlagsUsing // Variable declaration (NOTE: on a single node these flags would otherwise be mutually exclusive)
|
||||
|
||||
NodeFlagsReachabilityCheckFlags = NodeFlagsHasImplicitReturn | NodeFlagsHasExplicitReturn
|
||||
|
||||
// Parsing context flags
|
||||
NodeFlagsContextFlags NodeFlags = NodeFlagsDisallowInContext | NodeFlagsDisallowConditionalTypesContext | NodeFlagsYieldContext | NodeFlagsDecoratorContext | NodeFlagsAwaitContext | NodeFlagsJavaScriptFile | NodeFlagsInWithStatement | NodeFlagsAmbient
|
||||
|
||||
// Exclude these flags when parsing a Type
|
||||
NodeFlagsTypeExcludesFlags NodeFlags = NodeFlagsYieldContext | NodeFlagsAwaitContext
|
||||
|
||||
// Represents all flags that are potentially set once and
|
||||
// never cleared on SourceFiles which get re-used in between incremental parses.
|
||||
// See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`.
|
||||
NodeFlagsPermanentlySetIncrementalFlags NodeFlags = NodeFlagsPossiblyContainsDynamicImport | NodeFlagsPossiblyContainsImportMeta
|
||||
|
||||
// The following flags repurpose other NodeFlags as different meanings for Identifier nodes
|
||||
NodeFlagsIdentifierHasExtendedUnicodeEscape NodeFlags = NodeFlagsContainsThis // Indicates whether the identifier contains an extended unicode escape sequence
|
||||
)
|
||||
168
kitcom/internal/tsgo/ast/parseoptions.go
Normal file
168
kitcom/internal/tsgo/ast/parseoptions.go
Normal file
@ -0,0 +1,168 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
)
|
||||
|
||||
type JSDocParsingMode int
|
||||
|
||||
const (
|
||||
JSDocParsingModeParseAll JSDocParsingMode = iota
|
||||
JSDocParsingModeParseNone
|
||||
JSDocParsingModeParseForTypeErrors
|
||||
JSDocParsingModeParseForTypeInfo
|
||||
)
|
||||
|
||||
type SourceFileParseOptions struct {
|
||||
FileName string
|
||||
Path tspath.Path
|
||||
CompilerOptions core.SourceFileAffectingCompilerOptions
|
||||
ExternalModuleIndicatorOptions ExternalModuleIndicatorOptions
|
||||
JSDocParsingMode JSDocParsingMode
|
||||
}
|
||||
|
||||
func GetSourceFileAffectingCompilerOptions(fileName string, options *core.CompilerOptions) core.SourceFileAffectingCompilerOptions {
|
||||
// Declaration files are not parsed/bound differently depending on compiler options.
|
||||
if tspath.IsDeclarationFileName(fileName) {
|
||||
return core.SourceFileAffectingCompilerOptions{}
|
||||
}
|
||||
return options.SourceFileAffecting()
|
||||
}
|
||||
|
||||
type ExternalModuleIndicatorOptions struct {
|
||||
jsx bool
|
||||
force bool
|
||||
}
|
||||
|
||||
func GetExternalModuleIndicatorOptions(fileName string, options *core.CompilerOptions, metadata SourceFileMetaData) ExternalModuleIndicatorOptions {
|
||||
if tspath.IsDeclarationFileName(fileName) {
|
||||
return ExternalModuleIndicatorOptions{}
|
||||
}
|
||||
|
||||
switch options.GetEmitModuleDetectionKind() {
|
||||
case core.ModuleDetectionKindForce:
|
||||
// All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
|
||||
return ExternalModuleIndicatorOptions{force: true}
|
||||
case core.ModuleDetectionKindLegacy:
|
||||
// Files are modules if they have imports, exports, or import.meta
|
||||
return ExternalModuleIndicatorOptions{}
|
||||
case core.ModuleDetectionKindAuto:
|
||||
// If module is nodenext or node16, all esm format files are modules
|
||||
// If jsx is react-jsx or react-jsxdev then jsx tags force module-ness
|
||||
// otherwise, the presence of import or export statments (or import.meta) implies module-ness
|
||||
return ExternalModuleIndicatorOptions{
|
||||
jsx: options.Jsx == core.JsxEmitReactJSX || options.Jsx == core.JsxEmitReactJSXDev,
|
||||
force: isFileForcedToBeModuleByFormat(fileName, options, metadata),
|
||||
}
|
||||
default:
|
||||
return ExternalModuleIndicatorOptions{}
|
||||
}
|
||||
}
|
||||
|
||||
var isFileForcedToBeModuleByFormatExtensions = []string{tspath.ExtensionCjs, tspath.ExtensionCts, tspath.ExtensionMjs, tspath.ExtensionMts}
|
||||
|
||||
func isFileForcedToBeModuleByFormat(fileName string, options *core.CompilerOptions, metadata SourceFileMetaData) bool {
|
||||
// Excludes declaration files - they still require an explicit `export {}` or the like
|
||||
// for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
|
||||
// that aren't esm-mode (meaning not in a `type: module` scope).
|
||||
if GetImpliedNodeFormatForEmitWorker(fileName, options.GetEmitModuleKind(), metadata) == core.ModuleKindESNext || tspath.FileExtensionIsOneOf(fileName, isFileForcedToBeModuleByFormatExtensions) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func SetExternalModuleIndicator(file *SourceFile, opts ExternalModuleIndicatorOptions) {
|
||||
file.ExternalModuleIndicator = getExternalModuleIndicator(file, opts)
|
||||
}
|
||||
|
||||
func getExternalModuleIndicator(file *SourceFile, opts ExternalModuleIndicatorOptions) *Node {
|
||||
if file.ScriptKind == core.ScriptKindJSON {
|
||||
return nil
|
||||
}
|
||||
|
||||
if node := isFileProbablyExternalModule(file); node != nil {
|
||||
return node
|
||||
}
|
||||
|
||||
if file.IsDeclarationFile {
|
||||
return nil
|
||||
}
|
||||
|
||||
if opts.jsx {
|
||||
if node := isFileModuleFromUsingJSXTag(file); node != nil {
|
||||
return node
|
||||
}
|
||||
}
|
||||
|
||||
if opts.force {
|
||||
return file.AsNode()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func isFileProbablyExternalModule(sourceFile *SourceFile) *Node {
|
||||
for _, statement := range sourceFile.Statements.Nodes {
|
||||
if isAnExternalModuleIndicatorNode(statement) {
|
||||
return statement
|
||||
}
|
||||
}
|
||||
return getImportMetaIfNecessary(sourceFile)
|
||||
}
|
||||
|
||||
func isAnExternalModuleIndicatorNode(node *Node) bool {
|
||||
return HasSyntacticModifier(node, ModifierFlagsExport) ||
|
||||
IsImportEqualsDeclaration(node) && IsExternalModuleReference(node.AsImportEqualsDeclaration().ModuleReference) ||
|
||||
IsImportDeclaration(node) || IsExportAssignment(node) || IsExportDeclaration(node)
|
||||
}
|
||||
|
||||
func getImportMetaIfNecessary(sourceFile *SourceFile) *Node {
|
||||
if sourceFile.AsNode().Flags&NodeFlagsPossiblyContainsImportMeta != 0 {
|
||||
return findChildNode(sourceFile.AsNode(), IsImportMeta)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func findChildNode(root *Node, check func(*Node) bool) *Node {
|
||||
var result *Node
|
||||
var visit func(*Node) bool
|
||||
visit = func(node *Node) bool {
|
||||
if check(node) {
|
||||
result = node
|
||||
return true
|
||||
}
|
||||
return node.ForEachChild(visit)
|
||||
}
|
||||
visit(root)
|
||||
return result
|
||||
}
|
||||
|
||||
func isFileModuleFromUsingJSXTag(file *SourceFile) *Node {
|
||||
return walkTreeForJSXTags(file.AsNode())
|
||||
}
|
||||
|
||||
// This is a somewhat unavoidable full tree walk to locate a JSX tag - `import.meta` requires the same,
|
||||
// but we avoid that walk (or parts of it) if at all possible using the `PossiblyContainsImportMeta` node flag.
|
||||
// Unfortunately, there's no `NodeFlag` space to do the same for JSX.
|
||||
func walkTreeForJSXTags(node *Node) *Node {
|
||||
var found *Node
|
||||
|
||||
var visitor func(node *Node) bool
|
||||
visitor = func(node *Node) bool {
|
||||
if found != nil {
|
||||
return true
|
||||
}
|
||||
if node.SubtreeFacts()&SubtreeContainsJsx == 0 {
|
||||
return false
|
||||
}
|
||||
if IsJsxOpeningElement(node) || IsJsxFragment(node) {
|
||||
found = node
|
||||
return true
|
||||
}
|
||||
return node.ForEachChild(visitor)
|
||||
}
|
||||
visitor(node)
|
||||
|
||||
return found
|
||||
}
|
||||
714
kitcom/internal/tsgo/ast/precedence.go
Normal file
714
kitcom/internal/tsgo/ast/precedence.go
Normal file
@ -0,0 +1,714 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type OperatorPrecedence int
|
||||
|
||||
const (
|
||||
// Expression:
|
||||
// AssignmentExpression
|
||||
// Expression `,` AssignmentExpression
|
||||
OperatorPrecedenceComma OperatorPrecedence = iota
|
||||
// NOTE: `Spread` is higher than `Comma` due to how it is parsed in |ElementList|
|
||||
// SpreadElement:
|
||||
// `...` AssignmentExpression
|
||||
OperatorPrecedenceSpread
|
||||
// AssignmentExpression:
|
||||
// ConditionalExpression
|
||||
// YieldExpression
|
||||
// ArrowFunction
|
||||
// AsyncArrowFunction
|
||||
// LeftHandSideExpression `=` AssignmentExpression
|
||||
// LeftHandSideExpression AssignmentOperator AssignmentExpression
|
||||
//
|
||||
// NOTE: AssignmentExpression is broken down into several precedences due to the requirements
|
||||
// of the parenthesizer rules.
|
||||
// AssignmentExpression: YieldExpression
|
||||
// YieldExpression:
|
||||
// `yield`
|
||||
// `yield` AssignmentExpression
|
||||
// `yield` `*` AssignmentExpression
|
||||
OperatorPrecedenceYield
|
||||
// AssignmentExpression: LeftHandSideExpression `=` AssignmentExpression
|
||||
// AssignmentExpression: LeftHandSideExpression AssignmentOperator AssignmentExpression
|
||||
// AssignmentOperator: one of
|
||||
// `*=` `/=` `%=` `+=` `-=` `<<=` `>>=` `>>>=` `&=` `^=` `|=` `**=`
|
||||
OperatorPrecedenceAssignment
|
||||
// NOTE: `Conditional` is considered higher than `Assignment` here, but in reality they have
|
||||
// the same precedence.
|
||||
// AssignmentExpression: ConditionalExpression
|
||||
// ConditionalExpression:
|
||||
// ShortCircuitExpression
|
||||
// ShortCircuitExpression `?` AssignmentExpression `:` AssignmentExpression
|
||||
OperatorPrecedenceConditional
|
||||
// LogicalORExpression:
|
||||
// LogicalANDExpression
|
||||
// LogicalORExpression `||` LogicalANDExpression
|
||||
OperatorPrecedenceLogicalOR
|
||||
// LogicalANDExpression:
|
||||
// BitwiseORExpression
|
||||
// LogicalANDExprerssion `&&` BitwiseORExpression
|
||||
OperatorPrecedenceLogicalAND
|
||||
// BitwiseORExpression:
|
||||
// BitwiseXORExpression
|
||||
// BitwiseORExpression `|` BitwiseXORExpression
|
||||
OperatorPrecedenceBitwiseOR
|
||||
// BitwiseXORExpression:
|
||||
// BitwiseANDExpression
|
||||
// BitwiseXORExpression `^` BitwiseANDExpression
|
||||
OperatorPrecedenceBitwiseXOR
|
||||
// BitwiseANDExpression:
|
||||
// EqualityExpression
|
||||
// BitwiseANDExpression `&` EqualityExpression
|
||||
OperatorPrecedenceBitwiseAND
|
||||
// EqualityExpression:
|
||||
// RelationalExpression
|
||||
// EqualityExpression `==` RelationalExpression
|
||||
// EqualityExpression `!=` RelationalExpression
|
||||
// EqualityExpression `===` RelationalExpression
|
||||
// EqualityExpression `!==` RelationalExpression
|
||||
OperatorPrecedenceEquality
|
||||
// RelationalExpression:
|
||||
// ShiftExpression
|
||||
// RelationalExpression `<` ShiftExpression
|
||||
// RelationalExpression `>` ShiftExpression
|
||||
// RelationalExpression `<=` ShiftExpression
|
||||
// RelationalExpression `>=` ShiftExpression
|
||||
// RelationalExpression `instanceof` ShiftExpression
|
||||
// RelationalExpression `in` ShiftExpression
|
||||
// [+TypeScript] RelationalExpression `as` Type
|
||||
OperatorPrecedenceRelational
|
||||
// ShiftExpression:
|
||||
// AdditiveExpression
|
||||
// ShiftExpression `<<` AdditiveExpression
|
||||
// ShiftExpression `>>` AdditiveExpression
|
||||
// ShiftExpression `>>>` AdditiveExpression
|
||||
OperatorPrecedenceShift
|
||||
// AdditiveExpression:
|
||||
// MultiplicativeExpression
|
||||
// AdditiveExpression `+` MultiplicativeExpression
|
||||
// AdditiveExpression `-` MultiplicativeExpression
|
||||
OperatorPrecedenceAdditive
|
||||
// MultiplicativeExpression:
|
||||
// ExponentiationExpression
|
||||
// MultiplicativeExpression MultiplicativeOperator ExponentiationExpression
|
||||
// MultiplicativeOperator: one of `*`, `/`, `%`
|
||||
OperatorPrecedenceMultiplicative
|
||||
// ExponentiationExpression:
|
||||
// UnaryExpression
|
||||
// UpdateExpression `**` ExponentiationExpression
|
||||
OperatorPrecedenceExponentiation
|
||||
// UnaryExpression:
|
||||
// UpdateExpression
|
||||
// `delete` UnaryExpression
|
||||
// `void` UnaryExpression
|
||||
// `typeof` UnaryExpression
|
||||
// `+` UnaryExpression
|
||||
// `-` UnaryExpression
|
||||
// `~` UnaryExpression
|
||||
// `!` UnaryExpression
|
||||
// AwaitExpression
|
||||
// UpdateExpression: // TODO: Do we need to investigate the precedence here?
|
||||
// `++` UnaryExpression
|
||||
// `--` UnaryExpression
|
||||
OperatorPrecedenceUnary
|
||||
// UpdateExpression:
|
||||
// LeftHandSideExpression
|
||||
// LeftHandSideExpression `++`
|
||||
// LeftHandSideExpression `--`
|
||||
OperatorPrecedenceUpdate
|
||||
// LeftHandSideExpression:
|
||||
// NewExpression
|
||||
// NewExpression:
|
||||
// MemberExpression
|
||||
// `new` NewExpression
|
||||
OperatorPrecedenceLeftHandSide
|
||||
// LeftHandSideExpression:
|
||||
// OptionalExpression
|
||||
// OptionalExpression:
|
||||
// MemberExpression OptionalChain
|
||||
// CallExpression OptionalChain
|
||||
// OptionalExpression OptionalChain
|
||||
OperatorPrecedenceOptionalChain
|
||||
// LeftHandSideExpression:
|
||||
// CallExpression
|
||||
// CallExpression:
|
||||
// CoverCallExpressionAndAsyncArrowHead
|
||||
// SuperCall
|
||||
// ImportCall
|
||||
// CallExpression Arguments
|
||||
// CallExpression `[` Expression `]`
|
||||
// CallExpression `.` IdentifierName
|
||||
// CallExpression TemplateLiteral
|
||||
// MemberExpression:
|
||||
// PrimaryExpression
|
||||
// MemberExpression `[` Expression `]`
|
||||
// MemberExpression `.` IdentifierName
|
||||
// MemberExpression TemplateLiteral
|
||||
// SuperProperty
|
||||
// MetaProperty
|
||||
// `new` MemberExpression Arguments
|
||||
OperatorPrecedenceMember
|
||||
// TODO: JSXElement?
|
||||
// PrimaryExpression:
|
||||
// `this`
|
||||
// IdentifierReference
|
||||
// Literal
|
||||
// ArrayLiteral
|
||||
// ObjectLiteral
|
||||
// FunctionExpression
|
||||
// ClassExpression
|
||||
// GeneratorExpression
|
||||
// AsyncFunctionExpression
|
||||
// AsyncGeneratorExpression
|
||||
// RegularExpressionLiteral
|
||||
// TemplateLiteral
|
||||
OperatorPrecedencePrimary
|
||||
// PrimaryExpression:
|
||||
// CoverParenthesizedExpressionAndArrowParameterList
|
||||
OperatorPrecedenceParentheses
|
||||
OperatorPrecedenceLowest = OperatorPrecedenceComma
|
||||
OperatorPrecedenceHighest = OperatorPrecedenceParentheses
|
||||
OperatorPrecedenceDisallowComma = OperatorPrecedenceYield
|
||||
// ShortCircuitExpression:
|
||||
// LogicalORExpression
|
||||
// CoalesceExpression
|
||||
// CoalesceExpression:
|
||||
// CoalesceExpressionHead `??` BitwiseORExpression
|
||||
// CoalesceExpressionHead:
|
||||
// CoalesceExpression
|
||||
// BitwiseORExpression
|
||||
OperatorPrecedenceCoalesce = OperatorPrecedenceLogicalOR
|
||||
// -1 is lower than all other precedences. Returning it will cause binary expression
|
||||
// parsing to stop.
|
||||
OperatorPrecedenceInvalid OperatorPrecedence = -1
|
||||
)
|
||||
|
||||
func getOperator(expression *Expression) Kind {
|
||||
switch expression.Kind {
|
||||
case KindBinaryExpression:
|
||||
return expression.AsBinaryExpression().OperatorToken.Kind
|
||||
case KindPrefixUnaryExpression:
|
||||
return expression.AsPrefixUnaryExpression().Operator
|
||||
case KindPostfixUnaryExpression:
|
||||
return expression.AsPostfixUnaryExpression().Operator
|
||||
default:
|
||||
return expression.Kind
|
||||
}
|
||||
}
|
||||
|
||||
// Gets the precedence of an expression
|
||||
func GetExpressionPrecedence(expression *Expression) OperatorPrecedence {
|
||||
operator := getOperator(expression)
|
||||
var flags OperatorPrecedenceFlags
|
||||
if expression.Kind == KindNewExpression && expression.AsNewExpression().Arguments == nil {
|
||||
flags = OperatorPrecedenceFlagsNewWithoutArguments
|
||||
} else if IsOptionalChain(expression) {
|
||||
flags = OperatorPrecedenceFlagsOptionalChain
|
||||
}
|
||||
return GetOperatorPrecedence(expression.Kind, operator, flags)
|
||||
}
|
||||
|
||||
type OperatorPrecedenceFlags int
|
||||
|
||||
const (
|
||||
OperatorPrecedenceFlagsNone OperatorPrecedenceFlags = 0
|
||||
OperatorPrecedenceFlagsNewWithoutArguments OperatorPrecedenceFlags = 1 << 0
|
||||
OperatorPrecedenceFlagsOptionalChain OperatorPrecedenceFlags = 1 << 1
|
||||
)
|
||||
|
||||
// Gets the precedence of an operator
|
||||
func GetOperatorPrecedence(nodeKind Kind, operatorKind Kind, flags OperatorPrecedenceFlags) OperatorPrecedence {
|
||||
switch nodeKind {
|
||||
case KindCommaListExpression:
|
||||
return OperatorPrecedenceComma
|
||||
case KindSpreadElement:
|
||||
return OperatorPrecedenceSpread
|
||||
case KindYieldExpression:
|
||||
return OperatorPrecedenceYield
|
||||
// !!! By necessity, this differs from the old compiler to better align with ParenthesizerRules. consider backporting
|
||||
case KindArrowFunction:
|
||||
return OperatorPrecedenceAssignment
|
||||
case KindConditionalExpression:
|
||||
return OperatorPrecedenceConditional
|
||||
case KindBinaryExpression:
|
||||
switch operatorKind {
|
||||
case KindCommaToken:
|
||||
return OperatorPrecedenceComma
|
||||
|
||||
case KindEqualsToken,
|
||||
KindPlusEqualsToken,
|
||||
KindMinusEqualsToken,
|
||||
KindAsteriskAsteriskEqualsToken,
|
||||
KindAsteriskEqualsToken,
|
||||
KindSlashEqualsToken,
|
||||
KindPercentEqualsToken,
|
||||
KindLessThanLessThanEqualsToken,
|
||||
KindGreaterThanGreaterThanEqualsToken,
|
||||
KindGreaterThanGreaterThanGreaterThanEqualsToken,
|
||||
KindAmpersandEqualsToken,
|
||||
KindCaretEqualsToken,
|
||||
KindBarEqualsToken,
|
||||
KindBarBarEqualsToken,
|
||||
KindAmpersandAmpersandEqualsToken,
|
||||
KindQuestionQuestionEqualsToken:
|
||||
return OperatorPrecedenceAssignment
|
||||
|
||||
default:
|
||||
return GetBinaryOperatorPrecedence(operatorKind)
|
||||
}
|
||||
// TODO: Should prefix `++` and `--` be moved to the `Update` precedence?
|
||||
case KindTypeAssertionExpression,
|
||||
KindNonNullExpression,
|
||||
KindPrefixUnaryExpression,
|
||||
KindTypeOfExpression,
|
||||
KindVoidExpression,
|
||||
KindDeleteExpression,
|
||||
KindAwaitExpression:
|
||||
return OperatorPrecedenceUnary
|
||||
|
||||
case KindPostfixUnaryExpression:
|
||||
return OperatorPrecedenceUpdate
|
||||
|
||||
// !!! By necessity, this differs from the old compiler to better align with ParenthesizerRules. consider backporting
|
||||
case KindPropertyAccessExpression, KindElementAccessExpression:
|
||||
if flags&OperatorPrecedenceFlagsOptionalChain != 0 {
|
||||
return OperatorPrecedenceOptionalChain
|
||||
}
|
||||
return OperatorPrecedenceMember
|
||||
|
||||
case KindCallExpression:
|
||||
if flags&OperatorPrecedenceFlagsOptionalChain != 0 {
|
||||
return OperatorPrecedenceOptionalChain
|
||||
}
|
||||
return OperatorPrecedenceMember
|
||||
|
||||
// !!! By necessity, this differs from the old compiler to better align with ParenthesizerRules. consider backporting
|
||||
case KindNewExpression:
|
||||
if flags&OperatorPrecedenceFlagsNewWithoutArguments != 0 {
|
||||
return OperatorPrecedenceLeftHandSide
|
||||
}
|
||||
return OperatorPrecedenceMember
|
||||
|
||||
// !!! By necessity, this differs from the old compiler to better align with ParenthesizerRules. consider backporting
|
||||
case KindTaggedTemplateExpression, KindMetaProperty, KindExpressionWithTypeArguments:
|
||||
return OperatorPrecedenceMember
|
||||
|
||||
case KindAsExpression,
|
||||
KindSatisfiesExpression:
|
||||
return OperatorPrecedenceRelational
|
||||
|
||||
case KindThisKeyword,
|
||||
KindSuperKeyword,
|
||||
KindImportKeyword,
|
||||
KindIdentifier,
|
||||
KindPrivateIdentifier,
|
||||
KindNullKeyword,
|
||||
KindTrueKeyword,
|
||||
KindFalseKeyword,
|
||||
KindNumericLiteral,
|
||||
KindBigIntLiteral,
|
||||
KindStringLiteral,
|
||||
KindArrayLiteralExpression,
|
||||
KindObjectLiteralExpression,
|
||||
KindFunctionExpression,
|
||||
KindClassExpression,
|
||||
KindRegularExpressionLiteral,
|
||||
KindNoSubstitutionTemplateLiteral,
|
||||
KindTemplateExpression,
|
||||
KindOmittedExpression,
|
||||
KindJsxElement,
|
||||
KindJsxSelfClosingElement,
|
||||
KindJsxFragment:
|
||||
return OperatorPrecedencePrimary
|
||||
|
||||
// !!! By necessity, this differs from the old compiler to support emit. consider backporting
|
||||
case KindParenthesizedExpression:
|
||||
return OperatorPrecedenceParentheses
|
||||
|
||||
default:
|
||||
return OperatorPrecedenceInvalid
|
||||
}
|
||||
}
|
||||
|
||||
// Gets the precedence of a binary operator
|
||||
func GetBinaryOperatorPrecedence(operatorKind Kind) OperatorPrecedence {
|
||||
switch operatorKind {
|
||||
case KindQuestionQuestionToken:
|
||||
return OperatorPrecedenceCoalesce
|
||||
case KindBarBarToken:
|
||||
return OperatorPrecedenceLogicalOR
|
||||
case KindAmpersandAmpersandToken:
|
||||
return OperatorPrecedenceLogicalAND
|
||||
case KindBarToken:
|
||||
return OperatorPrecedenceBitwiseOR
|
||||
case KindCaretToken:
|
||||
return OperatorPrecedenceBitwiseXOR
|
||||
case KindAmpersandToken:
|
||||
return OperatorPrecedenceBitwiseAND
|
||||
case KindEqualsEqualsToken, KindExclamationEqualsToken, KindEqualsEqualsEqualsToken, KindExclamationEqualsEqualsToken:
|
||||
return OperatorPrecedenceEquality
|
||||
case KindLessThanToken, KindGreaterThanToken, KindLessThanEqualsToken, KindGreaterThanEqualsToken,
|
||||
KindInstanceOfKeyword, KindInKeyword, KindAsKeyword, KindSatisfiesKeyword:
|
||||
return OperatorPrecedenceRelational
|
||||
case KindLessThanLessThanToken, KindGreaterThanGreaterThanToken, KindGreaterThanGreaterThanGreaterThanToken:
|
||||
return OperatorPrecedenceShift
|
||||
case KindPlusToken, KindMinusToken:
|
||||
return OperatorPrecedenceAdditive
|
||||
case KindAsteriskToken, KindSlashToken, KindPercentToken:
|
||||
return OperatorPrecedenceMultiplicative
|
||||
case KindAsteriskAsteriskToken:
|
||||
return OperatorPrecedenceExponentiation
|
||||
}
|
||||
// -1 is lower than all other precedences. Returning it will cause binary expression
|
||||
// parsing to stop.
|
||||
return OperatorPrecedenceInvalid
|
||||
}
|
||||
|
||||
// Gets the leftmost expression of an expression, e.g. `a` in `a.b`, `a[b]`, `a++`, `a+b`, `a?b:c`, `a as B`, etc.
|
||||
func GetLeftmostExpression(node *Expression, stopAtCallExpressions bool) *Expression {
|
||||
for {
|
||||
switch node.Kind {
|
||||
case KindPostfixUnaryExpression:
|
||||
node = node.AsPostfixUnaryExpression().Operand
|
||||
continue
|
||||
case KindBinaryExpression:
|
||||
node = node.AsBinaryExpression().Left
|
||||
continue
|
||||
case KindConditionalExpression:
|
||||
node = node.AsConditionalExpression().Condition
|
||||
continue
|
||||
case KindTaggedTemplateExpression:
|
||||
node = node.AsTaggedTemplateExpression().Tag
|
||||
continue
|
||||
case KindCallExpression:
|
||||
if stopAtCallExpressions {
|
||||
return node
|
||||
}
|
||||
fallthrough
|
||||
case KindAsExpression,
|
||||
KindElementAccessExpression,
|
||||
KindPropertyAccessExpression,
|
||||
KindNonNullExpression,
|
||||
KindPartiallyEmittedExpression,
|
||||
KindSatisfiesExpression:
|
||||
node = node.Expression()
|
||||
continue
|
||||
}
|
||||
return node
|
||||
}
|
||||
}
|
||||
|
||||
type TypePrecedence int32
|
||||
|
||||
const (
|
||||
// Conditional precedence (lowest)
|
||||
//
|
||||
// Type[Extends]:
|
||||
// ConditionalType[?Extends]
|
||||
//
|
||||
// ConditionalType[Extends]:
|
||||
// [~Extends] UnionType `extends` Type[+Extends] `?` Type[~Extends] `:` Type[~Extends]
|
||||
//
|
||||
TypePrecedenceConditional TypePrecedence = iota
|
||||
|
||||
// JSDoc precedence (optional and variadic types)
|
||||
//
|
||||
// JSDocType:
|
||||
// `...`? Type `=`?
|
||||
TypePrecedenceJSDoc
|
||||
|
||||
// Function precedence
|
||||
//
|
||||
// Type[Extends]:
|
||||
// ConditionalType[?Extends]
|
||||
// FunctionType[?Extends]
|
||||
// ConstructorType[?Extends]
|
||||
//
|
||||
// ConditionalType[Extends]:
|
||||
// UnionType
|
||||
//
|
||||
// FunctionType[Extends]:
|
||||
// TypeParameters? ArrowParameters `=>` Type[?Extends]
|
||||
//
|
||||
// ConstructorType[Extends]:
|
||||
// `abstract`? TypeParameters? ArrowParameters `=>` Type[?Extends]
|
||||
//
|
||||
TypePrecedenceFunction
|
||||
|
||||
// Union precedence
|
||||
//
|
||||
// UnionType:
|
||||
// `|`? UnionTypeNoBar
|
||||
//
|
||||
// UnionTypeNoBar:
|
||||
// IntersectionType
|
||||
// UnionTypeNoBar `|` IntersectionType
|
||||
//
|
||||
TypePrecedenceUnion
|
||||
|
||||
// Intersection precedence
|
||||
//
|
||||
// IntersectionType:
|
||||
// `&`? IntersectionTypeNoAmpersand
|
||||
//
|
||||
// IntersectionTypeNoAmpersand:
|
||||
// TypeOperator
|
||||
// IntersectionTypeNoAmpersand `&` TypeOperator
|
||||
//
|
||||
TypePrecedenceIntersection
|
||||
|
||||
// TypeOperator precedence
|
||||
//
|
||||
// TypeOperator:
|
||||
// PostfixType
|
||||
// InferType
|
||||
// `keyof` TypeOperator
|
||||
// `unique` TypeOperator
|
||||
// `readonly` PostfixType
|
||||
//
|
||||
// InferType:
|
||||
// `infer` BindingIdentifier
|
||||
// `infer` BindingIdentifier `extends` Type[+Extends]
|
||||
//
|
||||
TypePrecedenceTypeOperator
|
||||
|
||||
// Postfix precedence
|
||||
//
|
||||
// PostfixType:
|
||||
// NonArrayType
|
||||
// OptionalType
|
||||
// ArrayType
|
||||
// IndexedAccessType
|
||||
//
|
||||
// OptionalType:
|
||||
// PostfixType `?`
|
||||
//
|
||||
// ArrayType:
|
||||
// PostfixType `[` `]`
|
||||
//
|
||||
// IndexedAccessType:
|
||||
// PostfixType `[` Type[~Extends] `]`
|
||||
//
|
||||
TypePrecedencePostfix
|
||||
|
||||
// NonArray precedence (highest)
|
||||
//
|
||||
// NonArrayType:
|
||||
// KeywordType
|
||||
// LiteralType
|
||||
// ThisType
|
||||
// ImportType
|
||||
// TypeQuery
|
||||
// MappedType
|
||||
// TypeLiteral
|
||||
// TupleType
|
||||
// ParenthesizedType
|
||||
// TypePredicate
|
||||
// TypeReference
|
||||
// TemplateType
|
||||
//
|
||||
// KeywordType: one of
|
||||
// `any` `unknown` `string` `number` `bigint`
|
||||
// `symbol` `boolean` `undefined` `never` `object`
|
||||
// `intrinsic` `void`
|
||||
//
|
||||
// LiteralType:
|
||||
// StringLiteral
|
||||
// NoSubstitutionTemplateLiteral
|
||||
// NumericLiteral
|
||||
// BigIntLiteral
|
||||
// `-` NumericLiteral
|
||||
// `-` BigIntLiteral
|
||||
// `true`
|
||||
// `false`
|
||||
// `null`
|
||||
//
|
||||
// ThisType:
|
||||
// `this`
|
||||
//
|
||||
// ImportType:
|
||||
// `typeof`? `import` `(` Type[~Extends] `,`? `)` ImportTypeQualifier? TypeArguments?
|
||||
// `typeof`? `import` `(` Type[~Extends] `,` ImportTypeAttributes `,`? `)` ImportTypeQualifier? TypeArguments?
|
||||
//
|
||||
// ImportTypeQualifier:
|
||||
// `.` EntityName
|
||||
//
|
||||
// ImportTypeAttributes:
|
||||
// `{` `with` `:` ImportAttributes `,`? `}`
|
||||
//
|
||||
// TypeQuery:
|
||||
//
|
||||
// MappedType:
|
||||
// `{` MappedTypePrefix? MappedTypePropertyName MappedTypeSuffix? `:` Type[~Extends] `;` `}`
|
||||
//
|
||||
// MappedTypePrefix:
|
||||
// `readonly`
|
||||
// `+` `readonly`
|
||||
// `-` `readonly`
|
||||
//
|
||||
// MappedTypePropertyName:
|
||||
// `[` BindingIdentifier `in` Type[~Extends] `]`
|
||||
// `[` BindingIdentifier `in` Type[~Extends] `as` Type[~Extends] `]`
|
||||
//
|
||||
// MappedTypeSuffix:
|
||||
// `?`
|
||||
// `+` `?`
|
||||
// `-` `?`
|
||||
//
|
||||
// TypeLiteral:
|
||||
// `{` TypeElementList `}`
|
||||
//
|
||||
// TypeElementList:
|
||||
// [empty]
|
||||
// TypeElementList TypeElement
|
||||
//
|
||||
// TypeElement:
|
||||
// PropertySignature
|
||||
// MethodSignature
|
||||
// IndexSignature
|
||||
// CallSignature
|
||||
// ConstructSignature
|
||||
//
|
||||
// PropertySignature:
|
||||
// PropertyName `?`? TypeAnnotation? `;`
|
||||
//
|
||||
// MethodSignature:
|
||||
// PropertyName `?`? TypeParameters? `(` FormalParameterList `)` TypeAnnotation? `;`
|
||||
// `get` PropertyName TypeParameters? `(` FormalParameterList `)` TypeAnnotation? `;` // GetAccessor
|
||||
// `set` PropertyName TypeParameters? `(` FormalParameterList `)` TypeAnnotation? `;` // SetAccessor
|
||||
//
|
||||
// IndexSignature:
|
||||
// `[` IdentifierName`]` TypeAnnotation `;`
|
||||
//
|
||||
// CallSignature:
|
||||
// TypeParameters? `(` FormalParameterList `)` TypeAnnotation? `;`
|
||||
//
|
||||
// ConstructSignature:
|
||||
// `new` TypeParameters? `(` FormalParameterList `)` TypeAnnotation? `;`
|
||||
//
|
||||
// TupleType:
|
||||
// `[` `]`
|
||||
// `[` NamedTupleElementTypes `,`? `]`
|
||||
// `[` TupleElementTypes `,`? `]`
|
||||
//
|
||||
// NamedTupleElementTypes:
|
||||
// NamedTupleMember
|
||||
// NamedTupleElementTypes `,` NamedTupleMember
|
||||
//
|
||||
// NamedTupleMember:
|
||||
// IdentifierName `?`? `:` Type[~Extends]
|
||||
// `...` IdentifierName `:` Type[~Extends]
|
||||
//
|
||||
// TupleElementTypes:
|
||||
// TupleElementType
|
||||
// TupleElementTypes `,` TupleElementType
|
||||
//
|
||||
// TupleElementType:
|
||||
// Type[~Extends]
|
||||
// OptionalType
|
||||
// RestType
|
||||
//
|
||||
// RestType:
|
||||
// `...` Type[~Extends]
|
||||
//
|
||||
// ParenthesizedType:
|
||||
// `(` Type[~Extends] `)`
|
||||
//
|
||||
// TypePredicate:
|
||||
// `asserts`? TypePredicateParameterName
|
||||
// `asserts`? TypePredicateParameterName `is` Type[~Extends]
|
||||
//
|
||||
// TypePredicateParameterName:
|
||||
// `this`
|
||||
// IdentifierReference
|
||||
//
|
||||
// TypeReference:
|
||||
// EntityName TypeArguments?
|
||||
//
|
||||
// TemplateType:
|
||||
// TemplateHead Type[~Extends] TemplateTypeSpans
|
||||
//
|
||||
// TemplateTypeSpans:
|
||||
// TemplateTail
|
||||
// TemplateTypeMiddleList TemplateTail
|
||||
//
|
||||
// TemplateTypeMiddleList:
|
||||
// TemplateMiddle Type[~Extends]
|
||||
// TemplateTypeMiddleList TemplateMiddle Type[~Extends]
|
||||
//
|
||||
// TypeArguments:
|
||||
// `<` TypeArgumentList `,`? `>`
|
||||
//
|
||||
// TypeArgumentList:
|
||||
// Type[~Extends]
|
||||
// TypeArgumentList `,` Type[~Extends]
|
||||
//
|
||||
TypePrecedenceNonArray
|
||||
|
||||
TypePrecedenceLowest = TypePrecedenceConditional
|
||||
TypePrecedenceHighest = TypePrecedenceNonArray
|
||||
)
|
||||
|
||||
// Gets the precedence of a TypeNode
|
||||
func GetTypeNodePrecedence(n *TypeNode) TypePrecedence {
|
||||
switch n.Kind {
|
||||
case KindConditionalType:
|
||||
return TypePrecedenceConditional
|
||||
case KindJSDocOptionalType, KindJSDocVariadicType:
|
||||
return TypePrecedenceJSDoc
|
||||
case KindFunctionType, KindConstructorType:
|
||||
return TypePrecedenceFunction
|
||||
case KindUnionType:
|
||||
return TypePrecedenceUnion
|
||||
case KindIntersectionType:
|
||||
return TypePrecedenceIntersection
|
||||
case KindTypeOperator:
|
||||
return TypePrecedenceTypeOperator
|
||||
case KindInferType:
|
||||
if n.AsInferTypeNode().TypeParameter.AsTypeParameter().Constraint != nil {
|
||||
// `infer T extends U` must be treated as FunctionType precedence as the `extends` clause eagerly consumes
|
||||
// TypeNode
|
||||
return TypePrecedenceFunction
|
||||
}
|
||||
return TypePrecedenceTypeOperator
|
||||
case KindIndexedAccessType, KindArrayType, KindOptionalType:
|
||||
return TypePrecedencePostfix
|
||||
case KindTypeQuery:
|
||||
// TypeQuery is actually a NonArrayType, but we treat it as the same
|
||||
// precedence as PostfixType
|
||||
return TypePrecedencePostfix
|
||||
case KindAnyKeyword,
|
||||
KindUnknownKeyword,
|
||||
KindStringKeyword,
|
||||
KindNumberKeyword,
|
||||
KindBigIntKeyword,
|
||||
KindSymbolKeyword,
|
||||
KindBooleanKeyword,
|
||||
KindUndefinedKeyword,
|
||||
KindNeverKeyword,
|
||||
KindObjectKeyword,
|
||||
KindIntrinsicKeyword,
|
||||
KindVoidKeyword,
|
||||
KindJSDocAllType,
|
||||
KindJSDocNullableType,
|
||||
KindJSDocNonNullableType,
|
||||
KindLiteralType,
|
||||
KindTypePredicate,
|
||||
KindTypeReference,
|
||||
KindTypeLiteral,
|
||||
KindTupleType,
|
||||
KindRestType,
|
||||
KindParenthesizedType,
|
||||
KindThisType,
|
||||
KindMappedType,
|
||||
KindNamedTupleMember,
|
||||
KindTemplateLiteralType,
|
||||
KindImportType:
|
||||
return TypePrecedenceNonArray
|
||||
default:
|
||||
panic(fmt.Sprintf("unhandled TypeNode: %v", n.Kind))
|
||||
}
|
||||
}
|
||||
131
kitcom/internal/tsgo/ast/subtreefacts.go
Normal file
131
kitcom/internal/tsgo/ast/subtreefacts.go
Normal file
@ -0,0 +1,131 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
)
|
||||
|
||||
type SubtreeFacts int32
|
||||
|
||||
const (
|
||||
// Facts
|
||||
// - Flags used to indicate that a node or subtree contains syntax relevant to a specific transform
|
||||
|
||||
SubtreeContainsTypeScript SubtreeFacts = 1 << iota
|
||||
SubtreeContainsJsx
|
||||
SubtreeContainsESDecorators
|
||||
SubtreeContainsUsing
|
||||
SubtreeContainsClassStaticBlocks
|
||||
SubtreeContainsESClassFields
|
||||
SubtreeContainsLogicalAssignments
|
||||
SubtreeContainsNullishCoalescing
|
||||
SubtreeContainsOptionalChaining
|
||||
SubtreeContainsMissingCatchClauseVariable
|
||||
SubtreeContainsESObjectRestOrSpread // subtree has a `...` somewhere inside it, never cleared
|
||||
SubtreeContainsForAwaitOrAsyncGenerator
|
||||
SubtreeContainsAnyAwait
|
||||
SubtreeContainsExponentiationOperator
|
||||
|
||||
// Markers
|
||||
// - Flags used to indicate that a node or subtree contains a particular kind of syntax.
|
||||
|
||||
SubtreeContainsLexicalThis
|
||||
SubtreeContainsLexicalSuper
|
||||
SubtreeContainsRestOrSpread // marker on any `...` - cleared on binding pattern exit
|
||||
SubtreeContainsObjectRestOrSpread // marker on any `{...x}` - cleared on most scope exits
|
||||
SubtreeContainsAwait
|
||||
SubtreeContainsDynamicImport
|
||||
SubtreeContainsClassFields
|
||||
SubtreeContainsDecorators
|
||||
SubtreeContainsIdentifier
|
||||
|
||||
SubtreeFactsComputed // NOTE: This should always be last
|
||||
SubtreeFactsNone SubtreeFacts = 0
|
||||
|
||||
// Aliases (unused, for documentation purposes only - correspond to combinations in transformers/estransforms/definitions.go)
|
||||
|
||||
SubtreeContainsESNext = SubtreeContainsESDecorators | SubtreeContainsUsing
|
||||
SubtreeContainsES2022 = SubtreeContainsClassStaticBlocks | SubtreeContainsESClassFields
|
||||
SubtreeContainsES2021 = SubtreeContainsLogicalAssignments
|
||||
SubtreeContainsES2020 = SubtreeContainsNullishCoalescing | SubtreeContainsOptionalChaining
|
||||
SubtreeContainsES2019 = SubtreeContainsMissingCatchClauseVariable
|
||||
SubtreeContainsES2018 = SubtreeContainsESObjectRestOrSpread | SubtreeContainsForAwaitOrAsyncGenerator
|
||||
SubtreeContainsES2017 = SubtreeContainsAnyAwait
|
||||
SubtreeContainsES2016 = SubtreeContainsExponentiationOperator
|
||||
|
||||
// Scope Exclusions
|
||||
// - Bitmasks that exclude flags from propagating out of a specific context
|
||||
// into the subtree flags of their container.
|
||||
|
||||
SubtreeExclusionsNode = SubtreeFactsComputed
|
||||
SubtreeExclusionsEraseable = ^SubtreeContainsTypeScript
|
||||
SubtreeExclusionsOuterExpression = SubtreeExclusionsNode
|
||||
SubtreeExclusionsPropertyAccess = SubtreeExclusionsNode
|
||||
SubtreeExclusionsElementAccess = SubtreeExclusionsNode
|
||||
SubtreeExclusionsArrowFunction = SubtreeExclusionsNode | SubtreeContainsAwait | SubtreeContainsObjectRestOrSpread
|
||||
SubtreeExclusionsFunction = SubtreeExclusionsNode | SubtreeContainsLexicalThis | SubtreeContainsLexicalSuper | SubtreeContainsAwait | SubtreeContainsObjectRestOrSpread
|
||||
SubtreeExclusionsConstructor = SubtreeExclusionsNode | SubtreeContainsLexicalThis | SubtreeContainsLexicalSuper | SubtreeContainsAwait | SubtreeContainsObjectRestOrSpread
|
||||
SubtreeExclusionsMethod = SubtreeExclusionsNode | SubtreeContainsLexicalThis | SubtreeContainsLexicalSuper | SubtreeContainsAwait | SubtreeContainsObjectRestOrSpread
|
||||
SubtreeExclusionsAccessor = SubtreeExclusionsNode | SubtreeContainsLexicalThis | SubtreeContainsLexicalSuper | SubtreeContainsAwait | SubtreeContainsObjectRestOrSpread
|
||||
SubtreeExclusionsProperty = SubtreeExclusionsNode | SubtreeContainsLexicalThis | SubtreeContainsLexicalSuper
|
||||
SubtreeExclusionsClass = SubtreeExclusionsNode
|
||||
SubtreeExclusionsModule = SubtreeExclusionsNode | SubtreeContainsLexicalThis | SubtreeContainsLexicalSuper
|
||||
SubtreeExclusionsObjectLiteral = SubtreeExclusionsNode | SubtreeContainsObjectRestOrSpread
|
||||
SubtreeExclusionsArrayLiteral = SubtreeExclusionsNode
|
||||
SubtreeExclusionsCall = SubtreeExclusionsNode
|
||||
SubtreeExclusionsNew = SubtreeExclusionsNode
|
||||
SubtreeExclusionsVariableDeclarationList = SubtreeExclusionsNode | SubtreeContainsObjectRestOrSpread
|
||||
SubtreeExclusionsParameter = SubtreeExclusionsNode
|
||||
SubtreeExclusionsCatchClause = SubtreeExclusionsNode | SubtreeContainsObjectRestOrSpread
|
||||
SubtreeExclusionsBindingPattern = SubtreeExclusionsNode | SubtreeContainsRestOrSpread
|
||||
|
||||
// Masks
|
||||
// - Additional bitmasks
|
||||
|
||||
SubtreeContainsLexicalThisOrSuper = SubtreeContainsLexicalThis | SubtreeContainsLexicalSuper
|
||||
)
|
||||
|
||||
func propagateEraseableSyntaxListSubtreeFacts(children *TypeArgumentList) SubtreeFacts {
|
||||
return core.IfElse(children != nil, SubtreeContainsTypeScript, SubtreeFactsNone)
|
||||
}
|
||||
|
||||
func propagateEraseableSyntaxSubtreeFacts(child *TypeNode) SubtreeFacts {
|
||||
return core.IfElse(child != nil, SubtreeContainsTypeScript, SubtreeFactsNone)
|
||||
}
|
||||
|
||||
func propagateObjectBindingElementSubtreeFacts(child *BindingElementNode) SubtreeFacts {
|
||||
facts := propagateSubtreeFacts(child)
|
||||
if facts&SubtreeContainsRestOrSpread != 0 {
|
||||
facts &= ^SubtreeContainsRestOrSpread
|
||||
facts |= SubtreeContainsObjectRestOrSpread | SubtreeContainsESObjectRestOrSpread
|
||||
}
|
||||
return facts
|
||||
}
|
||||
|
||||
func propagateBindingElementSubtreeFacts(child *BindingElementNode) SubtreeFacts {
|
||||
return propagateSubtreeFacts(child) & ^SubtreeContainsRestOrSpread
|
||||
}
|
||||
|
||||
func propagateSubtreeFacts(child *Node) SubtreeFacts {
|
||||
if child == nil {
|
||||
return SubtreeFactsNone
|
||||
}
|
||||
return child.propagateSubtreeFacts()
|
||||
}
|
||||
|
||||
func propagateNodeListSubtreeFacts(children *NodeList, propagate func(*Node) SubtreeFacts) SubtreeFacts {
|
||||
if children == nil {
|
||||
return SubtreeFactsNone
|
||||
}
|
||||
facts := SubtreeFactsNone
|
||||
for _, child := range children.Nodes {
|
||||
facts |= propagate(child)
|
||||
}
|
||||
return facts
|
||||
}
|
||||
|
||||
func propagateModifierListSubtreeFacts(children *ModifierList) SubtreeFacts {
|
||||
if children == nil {
|
||||
return SubtreeFactsNone
|
||||
}
|
||||
return propagateNodeListSubtreeFacts(&children.NodeList, propagateSubtreeFacts)
|
||||
}
|
||||
60
kitcom/internal/tsgo/ast/symbol.go
Normal file
60
kitcom/internal/tsgo/ast/symbol.go
Normal file
@ -0,0 +1,60 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/collections"
|
||||
)
|
||||
|
||||
// Symbol
|
||||
|
||||
type Symbol struct {
|
||||
Flags SymbolFlags
|
||||
CheckFlags CheckFlags // Non-zero only in transient symbols created by Checker
|
||||
Name string
|
||||
Declarations []*Node
|
||||
ValueDeclaration *Node
|
||||
Members SymbolTable
|
||||
Exports SymbolTable
|
||||
id atomic.Uint64
|
||||
Parent *Symbol
|
||||
ExportSymbol *Symbol
|
||||
AssignmentDeclarationMembers collections.Set[*Node] // Set of detected assignment declarations
|
||||
GlobalExports SymbolTable // Conditional global UMD exports
|
||||
}
|
||||
|
||||
// SymbolTable
|
||||
|
||||
type SymbolTable map[string]*Symbol
|
||||
|
||||
const InternalSymbolNamePrefix = "\xFE" // Invalid UTF8 sequence, will never occur as IdentifierName
|
||||
|
||||
const (
|
||||
InternalSymbolNameCall = InternalSymbolNamePrefix + "call" // Call signatures
|
||||
InternalSymbolNameConstructor = InternalSymbolNamePrefix + "constructor" // Constructor implementations
|
||||
InternalSymbolNameNew = InternalSymbolNamePrefix + "new" // Constructor signatures
|
||||
InternalSymbolNameIndex = InternalSymbolNamePrefix + "index" // Index signatures
|
||||
InternalSymbolNameExportStar = InternalSymbolNamePrefix + "export" // Module export * declarations
|
||||
InternalSymbolNameGlobal = InternalSymbolNamePrefix + "global" // Global self-reference
|
||||
InternalSymbolNameMissing = InternalSymbolNamePrefix + "missing" // Indicates missing symbol
|
||||
InternalSymbolNameType = InternalSymbolNamePrefix + "type" // Anonymous type literal symbol
|
||||
InternalSymbolNameObject = InternalSymbolNamePrefix + "object" // Anonymous object literal declaration
|
||||
InternalSymbolNameJSXAttributes = InternalSymbolNamePrefix + "jsxAttributes" // Anonymous JSX attributes object literal declaration
|
||||
InternalSymbolNameClass = InternalSymbolNamePrefix + "class" // Unnamed class expression
|
||||
InternalSymbolNameFunction = InternalSymbolNamePrefix + "function" // Unnamed function expression
|
||||
InternalSymbolNameComputed = InternalSymbolNamePrefix + "computed" // Computed property name declaration with dynamic name
|
||||
InternalSymbolNameResolving = InternalSymbolNamePrefix + "resolving" // Indicator symbol used to mark partially resolved type aliases
|
||||
InternalSymbolNameInstantiationExpression = InternalSymbolNamePrefix + "instantiationExpression" // Instantiation expressions
|
||||
InternalSymbolNameImportAttributes = InternalSymbolNamePrefix + "importAttributes"
|
||||
InternalSymbolNameExportEquals = "export=" // Export assignment symbol
|
||||
InternalSymbolNameDefault = "default" // Default export symbol (technically not wholly internal, but included here for usability)
|
||||
InternalSymbolNameThis = "this"
|
||||
InternalSymbolNameModuleExports = "module.exports"
|
||||
)
|
||||
|
||||
func SymbolName(symbol *Symbol) string {
|
||||
if symbol.ValueDeclaration != nil && IsPrivateIdentifierClassElementDeclaration(symbol.ValueDeclaration) {
|
||||
return symbol.ValueDeclaration.Name().Text()
|
||||
}
|
||||
return symbol.Name
|
||||
}
|
||||
86
kitcom/internal/tsgo/ast/symbolflags.go
Normal file
86
kitcom/internal/tsgo/ast/symbolflags.go
Normal file
@ -0,0 +1,86 @@
|
||||
package ast
|
||||
|
||||
// SymbolFlags
|
||||
|
||||
type SymbolFlags uint32
|
||||
|
||||
const (
|
||||
SymbolFlagsNone SymbolFlags = 0
|
||||
SymbolFlagsFunctionScopedVariable SymbolFlags = 1 << 0 // Variable (var) or parameter
|
||||
SymbolFlagsBlockScopedVariable SymbolFlags = 1 << 1 // A block-scoped variable (let or const)
|
||||
SymbolFlagsProperty SymbolFlags = 1 << 2 // Property or enum member
|
||||
SymbolFlagsEnumMember SymbolFlags = 1 << 3 // Enum member
|
||||
SymbolFlagsFunction SymbolFlags = 1 << 4 // Function
|
||||
SymbolFlagsClass SymbolFlags = 1 << 5 // Class
|
||||
SymbolFlagsInterface SymbolFlags = 1 << 6 // Interface
|
||||
SymbolFlagsConstEnum SymbolFlags = 1 << 7 // Const enum
|
||||
SymbolFlagsRegularEnum SymbolFlags = 1 << 8 // Enum
|
||||
SymbolFlagsValueModule SymbolFlags = 1 << 9 // Instantiated module
|
||||
SymbolFlagsNamespaceModule SymbolFlags = 1 << 10 // Uninstantiated module
|
||||
SymbolFlagsTypeLiteral SymbolFlags = 1 << 11 // Type Literal or mapped type
|
||||
SymbolFlagsObjectLiteral SymbolFlags = 1 << 12 // Object Literal
|
||||
SymbolFlagsMethod SymbolFlags = 1 << 13 // Method
|
||||
SymbolFlagsConstructor SymbolFlags = 1 << 14 // Constructor
|
||||
SymbolFlagsGetAccessor SymbolFlags = 1 << 15 // Get accessor
|
||||
SymbolFlagsSetAccessor SymbolFlags = 1 << 16 // Set accessor
|
||||
SymbolFlagsSignature SymbolFlags = 1 << 17 // Call, construct, or index signature
|
||||
SymbolFlagsTypeParameter SymbolFlags = 1 << 18 // Type parameter
|
||||
SymbolFlagsTypeAlias SymbolFlags = 1 << 19 // Type alias
|
||||
SymbolFlagsExportValue SymbolFlags = 1 << 20 // Exported value marker (see comment in declareModuleMember in binder)
|
||||
SymbolFlagsAlias SymbolFlags = 1 << 21 // An alias for another symbol (see comment in isAliasSymbolDeclaration in checker)
|
||||
SymbolFlagsPrototype SymbolFlags = 1 << 22 // Prototype property (no source representation)
|
||||
SymbolFlagsExportStar SymbolFlags = 1 << 23 // Export * declaration
|
||||
SymbolFlagsOptional SymbolFlags = 1 << 24 // Optional property
|
||||
SymbolFlagsTransient SymbolFlags = 1 << 25 // Transient symbol (created during type check)
|
||||
SymbolFlagsAssignment SymbolFlags = 1 << 26 // Assignment to property on function acting as declaration (eg `func.prop = 1`)
|
||||
SymbolFlagsModuleExports SymbolFlags = 1 << 27 // Symbol for CommonJS `module` of `module.exports`
|
||||
SymbolFlagsConstEnumOnlyModule SymbolFlags = 1 << 28 // Module contains only const enums or other modules with only const enums
|
||||
SymbolFlagsReplaceableByMethod SymbolFlags = 1 << 29
|
||||
SymbolFlagsGlobalLookup SymbolFlags = 1 << 30 // Flag to signal this is a global lookup
|
||||
SymbolFlagsAll SymbolFlags = 1<<30 - 1 // All flags except SymbolFlagsGlobalLookup
|
||||
|
||||
SymbolFlagsEnum = SymbolFlagsRegularEnum | SymbolFlagsConstEnum
|
||||
SymbolFlagsVariable = SymbolFlagsFunctionScopedVariable | SymbolFlagsBlockScopedVariable
|
||||
SymbolFlagsValue = SymbolFlagsVariable | SymbolFlagsProperty | SymbolFlagsEnumMember | SymbolFlagsObjectLiteral | SymbolFlagsFunction | SymbolFlagsClass | SymbolFlagsEnum | SymbolFlagsValueModule | SymbolFlagsMethod | SymbolFlagsGetAccessor | SymbolFlagsSetAccessor
|
||||
SymbolFlagsType = SymbolFlagsClass | SymbolFlagsInterface | SymbolFlagsEnum | SymbolFlagsEnumMember | SymbolFlagsTypeLiteral | SymbolFlagsTypeParameter | SymbolFlagsTypeAlias
|
||||
SymbolFlagsNamespace = SymbolFlagsValueModule | SymbolFlagsNamespaceModule | SymbolFlagsEnum
|
||||
SymbolFlagsModule = SymbolFlagsValueModule | SymbolFlagsNamespaceModule
|
||||
SymbolFlagsAccessor = SymbolFlagsGetAccessor | SymbolFlagsSetAccessor
|
||||
|
||||
// Variables can be redeclared, but can not redeclare a block-scoped declaration with the
|
||||
// same name, or any other value that is not a variable, e.g. ValueModule or Class
|
||||
SymbolFlagsFunctionScopedVariableExcludes = SymbolFlagsValue & ^SymbolFlagsFunctionScopedVariable
|
||||
|
||||
// Block-scoped declarations are not allowed to be re-declared
|
||||
// they can not merge with anything in the value space
|
||||
SymbolFlagsBlockScopedVariableExcludes = SymbolFlagsValue
|
||||
|
||||
SymbolFlagsParameterExcludes = SymbolFlagsValue
|
||||
SymbolFlagsPropertyExcludes = SymbolFlagsValue & ^SymbolFlagsProperty
|
||||
SymbolFlagsEnumMemberExcludes = SymbolFlagsValue | SymbolFlagsType
|
||||
SymbolFlagsFunctionExcludes = SymbolFlagsValue & ^(SymbolFlagsFunction | SymbolFlagsValueModule | SymbolFlagsClass)
|
||||
SymbolFlagsClassExcludes = (SymbolFlagsValue | SymbolFlagsType) & ^(SymbolFlagsValueModule | SymbolFlagsInterface | SymbolFlagsFunction) // class-interface mergability done in checker.ts
|
||||
SymbolFlagsInterfaceExcludes = SymbolFlagsType & ^(SymbolFlagsInterface | SymbolFlagsClass)
|
||||
SymbolFlagsRegularEnumExcludes = (SymbolFlagsValue | SymbolFlagsType) & ^(SymbolFlagsRegularEnum | SymbolFlagsValueModule) // regular enums merge only with regular enums and modules
|
||||
SymbolFlagsConstEnumExcludes = (SymbolFlagsValue | SymbolFlagsType) & ^SymbolFlagsConstEnum // const enums merge only with const enums
|
||||
SymbolFlagsValueModuleExcludes = SymbolFlagsValue & ^(SymbolFlagsFunction | SymbolFlagsClass | SymbolFlagsRegularEnum | SymbolFlagsValueModule)
|
||||
SymbolFlagsNamespaceModuleExcludes = SymbolFlagsNone
|
||||
SymbolFlagsMethodExcludes = SymbolFlagsValue & ^SymbolFlagsMethod
|
||||
SymbolFlagsGetAccessorExcludes = SymbolFlagsValue & ^SymbolFlagsSetAccessor
|
||||
SymbolFlagsSetAccessorExcludes = SymbolFlagsValue & ^SymbolFlagsGetAccessor
|
||||
SymbolFlagsAccessorExcludes = SymbolFlagsValue
|
||||
SymbolFlagsTypeParameterExcludes = SymbolFlagsType & ^SymbolFlagsTypeParameter
|
||||
SymbolFlagsTypeAliasExcludes = SymbolFlagsType
|
||||
SymbolFlagsAliasExcludes = SymbolFlagsAlias
|
||||
SymbolFlagsModuleMember = SymbolFlagsVariable | SymbolFlagsFunction | SymbolFlagsClass | SymbolFlagsInterface | SymbolFlagsEnum | SymbolFlagsModule | SymbolFlagsTypeAlias | SymbolFlagsAlias
|
||||
SymbolFlagsExportHasLocal = SymbolFlagsFunction | SymbolFlagsClass | SymbolFlagsEnum | SymbolFlagsValueModule
|
||||
SymbolFlagsBlockScoped = SymbolFlagsBlockScopedVariable | SymbolFlagsClass | SymbolFlagsEnum
|
||||
SymbolFlagsPropertyOrAccessor = SymbolFlagsProperty | SymbolFlagsAccessor
|
||||
SymbolFlagsClassMember = SymbolFlagsMethod | SymbolFlagsAccessor | SymbolFlagsProperty
|
||||
SymbolFlagsExportSupportsDefaultModifier = SymbolFlagsClass | SymbolFlagsFunction | SymbolFlagsInterface
|
||||
SymbolFlagsExportDoesNotSupportDefaultModifier = ^SymbolFlagsExportSupportsDefaultModifier
|
||||
// The set of things we consider semantically classifiable. Used to speed up the LS during
|
||||
// classification.
|
||||
SymbolFlagsClassifiable = SymbolFlagsClass | SymbolFlagsEnum | SymbolFlagsTypeAlias | SymbolFlagsInterface | SymbolFlagsTypeParameter | SymbolFlagsModule | SymbolFlagsAlias
|
||||
SymbolFlagsLateBindingContainer = SymbolFlagsClass | SymbolFlagsInterface | SymbolFlagsTypeLiteral | SymbolFlagsObjectLiteral | SymbolFlagsFunction
|
||||
)
|
||||
31
kitcom/internal/tsgo/ast/tokenflags.go
Normal file
31
kitcom/internal/tsgo/ast/tokenflags.go
Normal file
@ -0,0 +1,31 @@
|
||||
package ast
|
||||
|
||||
type TokenFlags int32
|
||||
|
||||
const (
|
||||
TokenFlagsNone TokenFlags = 0
|
||||
TokenFlagsPrecedingLineBreak TokenFlags = 1 << 0
|
||||
TokenFlagsPrecedingJSDocComment TokenFlags = 1 << 1
|
||||
TokenFlagsUnterminated TokenFlags = 1 << 2
|
||||
TokenFlagsExtendedUnicodeEscape TokenFlags = 1 << 3 // e.g. `\u{10ffff}`
|
||||
TokenFlagsScientific TokenFlags = 1 << 4 // e.g. `10e2`
|
||||
TokenFlagsOctal TokenFlags = 1 << 5 // e.g. `0777`
|
||||
TokenFlagsHexSpecifier TokenFlags = 1 << 6 // e.g. `0x00000000`
|
||||
TokenFlagsBinarySpecifier TokenFlags = 1 << 7 // e.g. `0b0110010000000000`
|
||||
TokenFlagsOctalSpecifier TokenFlags = 1 << 8 // e.g. `0o777`
|
||||
TokenFlagsContainsSeparator TokenFlags = 1 << 9 // e.g. `0b1100_0101`
|
||||
TokenFlagsUnicodeEscape TokenFlags = 1 << 10 // e.g. `\u00a0`
|
||||
TokenFlagsContainsInvalidEscape TokenFlags = 1 << 11 // e.g. `\uhello`
|
||||
TokenFlagsHexEscape TokenFlags = 1 << 12 // e.g. `\xa0`
|
||||
TokenFlagsContainsLeadingZero TokenFlags = 1 << 13 // e.g. `0888`
|
||||
TokenFlagsContainsInvalidSeparator TokenFlags = 1 << 14 // e.g. `0_1`
|
||||
TokenFlagsPrecedingJSDocLeadingAsterisks TokenFlags = 1 << 15
|
||||
TokenFlagsSingleQuote TokenFlags = 1 << 16 // e.g. `'abc'`
|
||||
TokenFlagsBinaryOrOctalSpecifier TokenFlags = TokenFlagsBinarySpecifier | TokenFlagsOctalSpecifier
|
||||
TokenFlagsWithSpecifier TokenFlags = TokenFlagsHexSpecifier | TokenFlagsBinaryOrOctalSpecifier
|
||||
TokenFlagsStringLiteralFlags TokenFlags = TokenFlagsUnterminated | TokenFlagsHexEscape | TokenFlagsUnicodeEscape | TokenFlagsExtendedUnicodeEscape | TokenFlagsContainsInvalidEscape | TokenFlagsSingleQuote
|
||||
TokenFlagsNumericLiteralFlags TokenFlags = TokenFlagsScientific | TokenFlagsOctal | TokenFlagsContainsLeadingZero | TokenFlagsWithSpecifier | TokenFlagsContainsSeparator | TokenFlagsContainsInvalidSeparator
|
||||
TokenFlagsTemplateLiteralLikeFlags TokenFlags = TokenFlagsUnterminated | TokenFlagsHexEscape | TokenFlagsUnicodeEscape | TokenFlagsExtendedUnicodeEscape | TokenFlagsContainsInvalidEscape
|
||||
TokenFlagsRegularExpressionLiteralFlags TokenFlags = TokenFlagsUnterminated
|
||||
TokenFlagsIsInvalid TokenFlags = TokenFlagsOctal | TokenFlagsContainsLeadingZero | TokenFlagsContainsInvalidSeparator | TokenFlagsContainsInvalidEscape
|
||||
)
|
||||
3892
kitcom/internal/tsgo/ast/utilities.go
Normal file
3892
kitcom/internal/tsgo/ast/utilities.go
Normal file
File diff suppressed because it is too large
Load Diff
278
kitcom/internal/tsgo/ast/visitor.go
Normal file
278
kitcom/internal/tsgo/ast/visitor.go
Normal file
@ -0,0 +1,278 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"slices"
|
||||
)
|
||||
|
||||
// NodeVisitor
|
||||
|
||||
type NodeVisitor struct {
|
||||
Visit func(node *Node) *Node // Required. The callback used to visit a node
|
||||
Factory *NodeFactory // Required. The NodeFactory used to produce new nodes when passed to VisitEachChild
|
||||
Hooks NodeVisitorHooks // Hooks to be invoked when visiting a node
|
||||
}
|
||||
|
||||
// These hooks are used to intercept the default behavior of the visitor
|
||||
type NodeVisitorHooks struct {
|
||||
VisitNode func(node *Node, v *NodeVisitor) *Node // Overrides visiting a Node. Only invoked by the VisitEachChild method on a given Node subtype.
|
||||
VisitToken func(node *TokenNode, v *NodeVisitor) *Node // Overrides visiting a TokenNode. Only invoked by the VisitEachChild method on a given Node subtype.
|
||||
VisitNodes func(nodes *NodeList, v *NodeVisitor) *NodeList // Overrides visiting a NodeList. Only invoked by the VisitEachChild method on a given Node subtype.
|
||||
VisitModifiers func(nodes *ModifierList, v *NodeVisitor) *ModifierList // Overrides visiting a ModifierList. Only invoked by the VisitEachChild method on a given Node subtype.
|
||||
VisitEmbeddedStatement func(node *Statement, v *NodeVisitor) *Statement // Overrides visiting a Node when it is the embedded statement body of an iteration statement, `if` statement, or `with` statement. Only invoked by the VisitEachChild method on a given Node subtype.
|
||||
VisitIterationBody func(node *Statement, v *NodeVisitor) *Statement // Overrides visiting a Node when it is the embedded statement body of an iteration statement. Only invoked by the VisitEachChild method on a given Node subtype.
|
||||
VisitParameters func(nodes *ParameterList, v *NodeVisitor) *ParameterList // Overrides visiting a ParameterList. Only invoked by the VisitEachChild method on a given Node subtype.
|
||||
VisitFunctionBody func(node *BlockOrExpression, v *NodeVisitor) *BlockOrExpression // Overrides visiting a function body. Only invoked by the VisitEachChild method on a given Node subtype.
|
||||
VisitTopLevelStatements func(nodes *StatementList, v *NodeVisitor) *StatementList // Overrides visiting a variable environment. Only invoked by the VisitEachChild method on a given Node subtype.
|
||||
}
|
||||
|
||||
func NewNodeVisitor(visit func(node *Node) *Node, factory *NodeFactory, hooks NodeVisitorHooks) *NodeVisitor {
|
||||
if factory == nil {
|
||||
factory = &NodeFactory{}
|
||||
}
|
||||
return &NodeVisitor{Visit: visit, Factory: factory, Hooks: hooks}
|
||||
}
|
||||
|
||||
func (v *NodeVisitor) VisitSourceFile(node *SourceFile) *SourceFile {
|
||||
return v.VisitNode(node.AsNode()).AsSourceFile()
|
||||
}
|
||||
|
||||
// Visits a Node, possibly returning a new Node in its place.
|
||||
//
|
||||
// - If the input node is nil, then the output is nil.
|
||||
// - If v.Visit is nil, then the output is the input.
|
||||
// - If v.Visit returns nil, then the output is nil.
|
||||
// - If v.Visit returns a SyntaxList Node, then the output is the only child of the SyntaxList Node.
|
||||
func (v *NodeVisitor) VisitNode(node *Node) *Node {
|
||||
if node == nil || v.Visit == nil {
|
||||
return node
|
||||
}
|
||||
|
||||
if v.Visit != nil {
|
||||
visited := v.Visit(node)
|
||||
if visited != nil && visited.Kind == KindSyntaxList {
|
||||
nodes := visited.AsSyntaxList().Children
|
||||
if len(nodes) != 1 {
|
||||
panic("Expected only a single node to be written to output")
|
||||
}
|
||||
visited = nodes[0]
|
||||
if visited != nil && visited.Kind == KindSyntaxList {
|
||||
panic("The result of visiting and lifting a Node may not be SyntaxList")
|
||||
}
|
||||
}
|
||||
return visited
|
||||
}
|
||||
|
||||
return node
|
||||
}
|
||||
|
||||
// Visits an embedded Statement (i.e., the single statement body of a loop, `if..else` branch, etc.), possibly returning a new Statement in its place.
|
||||
//
|
||||
// - If the input node is nil, then the output is nil.
|
||||
// - If v.Visit is nil, then the output is the input.
|
||||
// - If v.Visit returns nil, then the output is nil.
|
||||
// - If v.Visit returns a SyntaxList Node, then the output is either the only child of the SyntaxList Node, or a Block containing the nodes in the list.
|
||||
func (v *NodeVisitor) VisitEmbeddedStatement(node *Statement) *Statement {
|
||||
if node == nil || v.Visit == nil {
|
||||
return node
|
||||
}
|
||||
|
||||
if v.Visit != nil {
|
||||
return v.liftToBlock(v.Visit(node))
|
||||
}
|
||||
|
||||
return node
|
||||
}
|
||||
|
||||
// Visits a NodeList, possibly returning a new NodeList in its place.
|
||||
//
|
||||
// - If the input NodeList is nil, the output is nil.
|
||||
// - If v.Visit is nil, then the output is the input.
|
||||
// - If v.Visit returns nil, the visited Node will be absent in the output.
|
||||
// - If v.Visit returns a different Node than the input, a new NodeList will be generated and returned.
|
||||
// - If v.Visit returns a SyntaxList Node, then the children of that node will be merged into the output and a new NodeList will be returned.
|
||||
// - If this method returns a new NodeList for any reason, it will have the same Loc as the input NodeList.
|
||||
func (v *NodeVisitor) VisitNodes(nodes *NodeList) *NodeList {
|
||||
if nodes == nil || v.Visit == nil {
|
||||
return nodes
|
||||
}
|
||||
|
||||
if result, changed := v.VisitSlice(nodes.Nodes); changed {
|
||||
list := v.Factory.NewNodeList(result)
|
||||
list.Loc = nodes.Loc
|
||||
return list
|
||||
}
|
||||
|
||||
return nodes
|
||||
}
|
||||
|
||||
// Visits a ModifierList, possibly returning a new ModifierList in its place.
|
||||
//
|
||||
// - If the input ModifierList is nil, the output is nil.
|
||||
// - If v.Visit is nil, then the output is the input.
|
||||
// - If v.Visit returns nil, the visited Node will be absent in the output.
|
||||
// - If v.Visit returns a different Node than the input, a new ModifierList will be generated and returned.
|
||||
// - If v.Visit returns a SyntaxList Node, then the children of that node will be merged into the output and a new NodeList will be returned.
|
||||
// - If this method returns a new NodeList for any reason, it will have the same Loc as the input NodeList.
|
||||
func (v *NodeVisitor) VisitModifiers(nodes *ModifierList) *ModifierList {
|
||||
if nodes == nil || v.Visit == nil {
|
||||
return nodes
|
||||
}
|
||||
|
||||
if result, changed := v.VisitSlice(nodes.Nodes); changed {
|
||||
list := v.Factory.NewModifierList(result)
|
||||
list.Loc = nodes.Loc
|
||||
return list
|
||||
}
|
||||
|
||||
return nodes
|
||||
}
|
||||
|
||||
// Visits a slice of Nodes, returning the resulting slice and a value indicating whether the slice was changed.
|
||||
//
|
||||
// - If the input slice is nil, the output is nil.
|
||||
// - If v.Visit is nil, then the output is the input.
|
||||
// - If v.Visit returns nil, the visited Node will be absent in the output.
|
||||
// - If v.Visit returns a different Node than the input, a new slice will be generated and returned.
|
||||
// - If v.Visit returns a SyntaxList Node, then the children of that node will be merged into the output and a new slice will be returned.
|
||||
func (v *NodeVisitor) VisitSlice(nodes []*Node) (result []*Node, changed bool) {
|
||||
if nodes == nil || v.Visit == nil {
|
||||
return nodes, false
|
||||
}
|
||||
|
||||
for i := 0; i < len(nodes); i++ {
|
||||
node := nodes[i]
|
||||
if v.Visit == nil {
|
||||
break
|
||||
}
|
||||
|
||||
visited := v.Visit(node)
|
||||
if visited == nil || visited != node {
|
||||
updated := slices.Clone(nodes[:i])
|
||||
|
||||
for {
|
||||
// finish prior loop
|
||||
switch {
|
||||
case visited == nil: // do nothing
|
||||
case visited.Kind == KindSyntaxList:
|
||||
updated = append(updated, visited.AsSyntaxList().Children...)
|
||||
default:
|
||||
updated = append(updated, visited)
|
||||
}
|
||||
|
||||
i++
|
||||
|
||||
// loop over remaining elements
|
||||
if i >= len(nodes) {
|
||||
break
|
||||
}
|
||||
|
||||
if v.Visit != nil {
|
||||
node = nodes[i]
|
||||
visited = v.Visit(node)
|
||||
} else {
|
||||
updated = append(updated, nodes[i:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return updated, true
|
||||
}
|
||||
}
|
||||
|
||||
return nodes, false
|
||||
}
|
||||
|
||||
// Visits each child of a Node, possibly returning a new Node of the same kind in its place.
|
||||
func (v *NodeVisitor) VisitEachChild(node *Node) *Node {
|
||||
if node == nil || v.Visit == nil {
|
||||
return node
|
||||
}
|
||||
|
||||
return node.VisitEachChild(v)
|
||||
}
|
||||
|
||||
func (v *NodeVisitor) visitNode(node *Node) *Node {
|
||||
if v.Hooks.VisitNode != nil {
|
||||
return v.Hooks.VisitNode(node, v)
|
||||
}
|
||||
return v.VisitNode(node)
|
||||
}
|
||||
|
||||
func (v *NodeVisitor) visitEmbeddedStatement(node *Node) *Node {
|
||||
if v.Hooks.VisitEmbeddedStatement != nil {
|
||||
return v.Hooks.VisitEmbeddedStatement(node, v)
|
||||
}
|
||||
if v.Hooks.VisitNode != nil {
|
||||
return v.liftToBlock(v.Hooks.VisitNode(node, v))
|
||||
}
|
||||
return v.VisitEmbeddedStatement(node)
|
||||
}
|
||||
|
||||
func (v *NodeVisitor) visitIterationBody(node *Statement) *Statement {
|
||||
if v.Hooks.VisitIterationBody != nil {
|
||||
return v.Hooks.VisitIterationBody(node, v)
|
||||
}
|
||||
return v.visitEmbeddedStatement(node)
|
||||
}
|
||||
|
||||
func (v *NodeVisitor) visitFunctionBody(node *BlockOrExpression) *BlockOrExpression {
|
||||
if v.Hooks.VisitFunctionBody != nil {
|
||||
return v.Hooks.VisitFunctionBody(node, v)
|
||||
}
|
||||
return v.visitNode(node)
|
||||
}
|
||||
|
||||
func (v *NodeVisitor) visitToken(node *Node) *Node {
|
||||
if v.Hooks.VisitToken != nil {
|
||||
return v.Hooks.VisitToken(node, v)
|
||||
}
|
||||
return v.VisitNode(node)
|
||||
}
|
||||
|
||||
func (v *NodeVisitor) visitNodes(nodes *NodeList) *NodeList {
|
||||
if v.Hooks.VisitNodes != nil {
|
||||
return v.Hooks.VisitNodes(nodes, v)
|
||||
}
|
||||
return v.VisitNodes(nodes)
|
||||
}
|
||||
|
||||
func (v *NodeVisitor) visitModifiers(nodes *ModifierList) *ModifierList {
|
||||
if v.Hooks.VisitModifiers != nil {
|
||||
return v.Hooks.VisitModifiers(nodes, v)
|
||||
}
|
||||
return v.VisitModifiers(nodes)
|
||||
}
|
||||
|
||||
func (v *NodeVisitor) visitParameters(nodes *ParameterList) *ParameterList {
|
||||
if v.Hooks.VisitParameters != nil {
|
||||
return v.Hooks.VisitParameters(nodes, v)
|
||||
}
|
||||
return v.visitNodes(nodes)
|
||||
}
|
||||
|
||||
func (v *NodeVisitor) visitTopLevelStatements(nodes *StatementList) *StatementList {
|
||||
if v.Hooks.VisitTopLevelStatements != nil {
|
||||
return v.Hooks.VisitTopLevelStatements(nodes, v)
|
||||
}
|
||||
return v.visitNodes(nodes)
|
||||
}
|
||||
|
||||
func (v *NodeVisitor) liftToBlock(node *Statement) *Statement {
|
||||
var nodes []*Node
|
||||
if node != nil {
|
||||
if node.Kind == KindSyntaxList {
|
||||
nodes = node.AsSyntaxList().Children
|
||||
} else {
|
||||
nodes = []*Node{node}
|
||||
}
|
||||
}
|
||||
if len(nodes) == 1 {
|
||||
node = nodes[0]
|
||||
} else {
|
||||
node = v.Factory.NewBlock(v.Factory.NewNodeList(nodes), true /*multiLine*/)
|
||||
}
|
||||
if node.Kind == KindSyntaxList {
|
||||
panic("The result of visiting and lifting a Node may not be SyntaxList")
|
||||
}
|
||||
return node
|
||||
}
|
||||
653
kitcom/internal/tsgo/astnav/tokens.go
Normal file
653
kitcom/internal/tsgo/astnav/tokens.go
Normal file
@ -0,0 +1,653 @@
|
||||
package astnav
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/scanner"
|
||||
)
|
||||
|
||||
func GetTouchingPropertyName(sourceFile *ast.SourceFile, position int) *ast.Node {
|
||||
return getReparsedNodeForNode(getTokenAtPosition(sourceFile, position, false /*allowPositionInLeadingTrivia*/, func(node *ast.Node) bool {
|
||||
return ast.IsPropertyNameLiteral(node) || ast.IsKeywordKind(node.Kind) || ast.IsPrivateIdentifier(node)
|
||||
}))
|
||||
}
|
||||
|
||||
// If the given node is a declaration name node in a JSDoc comment that is subject to reparsing, return the declaration name node
|
||||
// for the corresponding reparsed construct. Otherwise, just return the node.
|
||||
func getReparsedNodeForNode(node *ast.Node) *ast.Node {
|
||||
if node.Flags&ast.NodeFlagsJSDoc != 0 && (ast.IsIdentifier(node) || ast.IsPrivateIdentifier(node)) {
|
||||
parent := node.Parent
|
||||
if (ast.IsJSDocTypedefTag(parent) || ast.IsJSDocCallbackTag(parent) || ast.IsJSDocPropertyTag(parent) || ast.IsJSDocParameterTag(parent) || ast.IsImportClause(parent) || ast.IsImportSpecifier(parent)) && parent.Name() == node {
|
||||
// Reparsing preserves the location of the name. Thus, a search at the position of the name with JSDoc excluded
|
||||
// finds the containing reparsed declaration node.
|
||||
if reparsed := ast.GetNodeAtPosition(ast.GetSourceFileOfNode(node), node.Pos(), false); reparsed != nil {
|
||||
if name := reparsed.Name(); name != nil && name.Pos() == node.Pos() {
|
||||
return name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
func GetTouchingToken(sourceFile *ast.SourceFile, position int) *ast.Node {
|
||||
return getTokenAtPosition(sourceFile, position, false /*allowPositionInLeadingTrivia*/, nil)
|
||||
}
|
||||
|
||||
func GetTokenAtPosition(sourceFile *ast.SourceFile, position int) *ast.Node {
|
||||
return getTokenAtPosition(sourceFile, position, true /*allowPositionInLeadingTrivia*/, nil)
|
||||
}
|
||||
|
||||
func getTokenAtPosition(
|
||||
sourceFile *ast.SourceFile,
|
||||
position int,
|
||||
allowPositionInLeadingTrivia bool,
|
||||
includePrecedingTokenAtEndPosition func(node *ast.Node) bool,
|
||||
) *ast.Node {
|
||||
// getTokenAtPosition returns a token at the given position in the source file.
|
||||
// The token can be a real node in the AST, or a synthesized token constructed
|
||||
// with information from the scanner. Synthesized tokens are only created when
|
||||
// needed, and they are stored in the source file's token cache such that multiple
|
||||
// calls to getTokenAtPosition with the same position will return the same object
|
||||
// in memory. If there is no token at the given position (possible when
|
||||
// `allowPositionInLeadingTrivia` is false), the lowest node that encloses the
|
||||
// position is returned.
|
||||
|
||||
// `next` tracks the node whose children will be visited on the next iteration.
|
||||
// `prevSubtree` is a node whose end position is equal to the target position,
|
||||
// only if `includePrecedingTokenAtEndPosition` is provided. Once set, the next
|
||||
// iteration of the loop will test the rightmost token of `prevSubtree` to see
|
||||
// if it should be returned.
|
||||
var next, prevSubtree *ast.Node
|
||||
current := sourceFile.AsNode()
|
||||
// `left` tracks the lower boundary of the node/token that could be returned,
|
||||
// and is eventually the scanner's start position, if the scanner is used.
|
||||
left := 0
|
||||
|
||||
testNode := func(node *ast.Node) int {
|
||||
if node.Kind != ast.KindEndOfFile && node.End() == position && includePrecedingTokenAtEndPosition != nil {
|
||||
prevSubtree = node
|
||||
}
|
||||
|
||||
if node.End() < position || node.Kind != ast.KindEndOfFile && node.End() == position {
|
||||
return -1
|
||||
}
|
||||
if getPosition(node, sourceFile, allowPositionInLeadingTrivia) > position {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// We zero in on the node that contains the target position by visiting each
|
||||
// child and JSDoc comment of the current node. Node children are walked in
|
||||
// order, while node lists are binary searched.
|
||||
visitNode := func(node *ast.Node, _ *ast.NodeVisitor) *ast.Node {
|
||||
// We can't abort visiting children, so once a match is found, we set `next`
|
||||
// and do nothing on subsequent visits.
|
||||
if node != nil && node.Flags&ast.NodeFlagsReparsed == 0 && next == nil {
|
||||
switch testNode(node) {
|
||||
case -1:
|
||||
if !ast.IsJSDocKind(node.Kind) {
|
||||
// We can't move the left boundary into or beyond JSDoc,
|
||||
// because we may end up returning the token after this JSDoc,
|
||||
// constructing it with the scanner, and we need to include
|
||||
// all its leading trivia in its position.
|
||||
left = node.End()
|
||||
}
|
||||
case 0:
|
||||
next = node
|
||||
}
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
visitNodeList := func(nodeList *ast.NodeList, _ *ast.NodeVisitor) *ast.NodeList {
|
||||
if nodeList != nil && len(nodeList.Nodes) > 0 && next == nil {
|
||||
if nodeList.End() == position && includePrecedingTokenAtEndPosition != nil {
|
||||
left = nodeList.End()
|
||||
prevSubtree = nodeList.Nodes[len(nodeList.Nodes)-1]
|
||||
} else if nodeList.End() <= position {
|
||||
left = nodeList.End()
|
||||
} else if nodeList.Pos() <= position {
|
||||
nodes := nodeList.Nodes
|
||||
index, match := core.BinarySearchUniqueFunc(nodes, func(middle int, node *ast.Node) int {
|
||||
if node.Flags&ast.NodeFlagsReparsed != 0 {
|
||||
return 0
|
||||
}
|
||||
cmp := testNode(node)
|
||||
if cmp < 0 {
|
||||
left = node.End()
|
||||
}
|
||||
return cmp
|
||||
})
|
||||
if match && nodes[index].Flags&ast.NodeFlagsReparsed != 0 {
|
||||
// filter and search again
|
||||
nodes = core.Filter(nodes, func(node *ast.Node) bool {
|
||||
return node.Flags&ast.NodeFlagsReparsed == 0
|
||||
})
|
||||
index, match = core.BinarySearchUniqueFunc(nodes, func(middle int, node *ast.Node) int {
|
||||
cmp := testNode(node)
|
||||
if cmp < 0 {
|
||||
left = node.End()
|
||||
}
|
||||
return cmp
|
||||
})
|
||||
}
|
||||
if match {
|
||||
next = nodes[index]
|
||||
}
|
||||
}
|
||||
}
|
||||
return nodeList
|
||||
}
|
||||
|
||||
for {
|
||||
VisitEachChildAndJSDoc(current, sourceFile, visitNode, visitNodeList)
|
||||
// If prevSubtree was set on the last iteration, it ends at the target position.
|
||||
// Check if the rightmost token of prevSubtree should be returned based on the
|
||||
// `includePrecedingTokenAtEndPosition` callback.
|
||||
if prevSubtree != nil {
|
||||
child := FindPrecedingTokenEx(sourceFile, position, prevSubtree, false /*excludeJSDoc*/)
|
||||
if child != nil && child.End() == position && includePrecedingTokenAtEndPosition(child) {
|
||||
// Optimization: includePrecedingTokenAtEndPosition only ever returns true
|
||||
// for real AST nodes, so we don't run the scanner here.
|
||||
return child
|
||||
}
|
||||
prevSubtree = nil
|
||||
}
|
||||
|
||||
// No node was found that contains the target position, so we've gone as deep as
|
||||
// we can in the AST. We've either found a token, or we need to run the scanner
|
||||
// to construct one that isn't stored in the AST.
|
||||
if next == nil {
|
||||
if ast.IsTokenKind(current.Kind) || shouldSkipChild(current) {
|
||||
return current
|
||||
}
|
||||
scanner := scanner.GetScannerForSourceFile(sourceFile, left)
|
||||
for left < current.End() {
|
||||
token := scanner.Token()
|
||||
tokenFullStart := scanner.TokenFullStart()
|
||||
tokenStart := core.IfElse(allowPositionInLeadingTrivia, tokenFullStart, scanner.TokenStart())
|
||||
tokenEnd := scanner.TokenEnd()
|
||||
if tokenStart <= position && (position < tokenEnd) {
|
||||
if token == ast.KindIdentifier || !ast.IsTokenKind(token) {
|
||||
if ast.IsJSDocKind(current.Kind) {
|
||||
return current
|
||||
}
|
||||
panic(fmt.Sprintf("did not expect %s to have %s in its trivia", current.Kind.String(), token.String()))
|
||||
}
|
||||
return sourceFile.GetOrCreateToken(token, tokenFullStart, tokenEnd, current)
|
||||
}
|
||||
if includePrecedingTokenAtEndPosition != nil && tokenEnd == position {
|
||||
prevToken := sourceFile.GetOrCreateToken(token, tokenFullStart, tokenEnd, current)
|
||||
if includePrecedingTokenAtEndPosition(prevToken) {
|
||||
return prevToken
|
||||
}
|
||||
}
|
||||
left = tokenEnd
|
||||
scanner.Scan()
|
||||
}
|
||||
return current
|
||||
}
|
||||
current = next
|
||||
left = current.Pos()
|
||||
next = nil
|
||||
}
|
||||
}
|
||||
|
||||
func getPosition(node *ast.Node, sourceFile *ast.SourceFile, allowPositionInLeadingTrivia bool) int {
|
||||
if allowPositionInLeadingTrivia {
|
||||
return node.Pos()
|
||||
}
|
||||
return scanner.GetTokenPosOfNode(node, sourceFile, true /*includeJSDoc*/)
|
||||
}
|
||||
|
||||
func findRightmostNode(node *ast.Node) *ast.Node {
|
||||
var next *ast.Node
|
||||
current := node
|
||||
visitNode := func(node *ast.Node, _ *ast.NodeVisitor) *ast.Node {
|
||||
if node != nil {
|
||||
next = node
|
||||
}
|
||||
return node
|
||||
}
|
||||
visitNodes := func(nodeList *ast.NodeList, visitor *ast.NodeVisitor) *ast.NodeList {
|
||||
if nodeList != nil {
|
||||
if rightmost := ast.FindLastVisibleNode(nodeList.Nodes); rightmost != nil {
|
||||
next = rightmost
|
||||
}
|
||||
}
|
||||
return nodeList
|
||||
}
|
||||
visitor := getNodeVisitor(visitNode, visitNodes)
|
||||
|
||||
for {
|
||||
current.VisitEachChild(visitor)
|
||||
if next == nil {
|
||||
return current
|
||||
}
|
||||
current = next
|
||||
next = nil
|
||||
}
|
||||
}
|
||||
|
||||
func VisitEachChildAndJSDoc(
|
||||
node *ast.Node,
|
||||
sourceFile *ast.SourceFile,
|
||||
visitNode func(*ast.Node, *ast.NodeVisitor) *ast.Node,
|
||||
visitNodes func(*ast.NodeList, *ast.NodeVisitor) *ast.NodeList,
|
||||
) {
|
||||
visitor := getNodeVisitor(visitNode, visitNodes)
|
||||
if node.Flags&ast.NodeFlagsHasJSDoc != 0 {
|
||||
for _, jsdoc := range node.JSDoc(sourceFile) {
|
||||
if visitor.Hooks.VisitNode != nil {
|
||||
visitor.Hooks.VisitNode(jsdoc, visitor)
|
||||
} else {
|
||||
visitor.VisitNode(jsdoc)
|
||||
}
|
||||
}
|
||||
}
|
||||
node.VisitEachChild(visitor)
|
||||
}
|
||||
|
||||
const (
|
||||
comparisonLessThan = -1
|
||||
comparisonEqualTo = 0
|
||||
comparisonGreaterThan = 1
|
||||
)
|
||||
|
||||
// Finds the leftmost token satisfying `position < token.End()`.
|
||||
// If the leftmost token satisfying `position < token.End()` is invalid, or if position
|
||||
// is in the trivia of that leftmost token,
|
||||
// we will find the rightmost valid token with `token.End() <= position`.
|
||||
func FindPrecedingToken(sourceFile *ast.SourceFile, position int) *ast.Node {
|
||||
return FindPrecedingTokenEx(sourceFile, position, nil, false)
|
||||
}
|
||||
|
||||
func FindPrecedingTokenEx(sourceFile *ast.SourceFile, position int, startNode *ast.Node, excludeJSDoc bool) *ast.Node {
|
||||
var find func(node *ast.Node) *ast.Node
|
||||
find = func(n *ast.Node) *ast.Node {
|
||||
if ast.IsNonWhitespaceToken(n) && n.Kind != ast.KindEndOfFile {
|
||||
return n
|
||||
}
|
||||
|
||||
// `foundChild` is the leftmost node that contains the target position.
|
||||
// `prevChild` is the last visited child of the current node.
|
||||
var foundChild, prevChild *ast.Node
|
||||
visitNode := func(node *ast.Node, _ *ast.NodeVisitor) *ast.Node {
|
||||
// skip synthesized nodes (that will exist now because of jsdoc handling)
|
||||
if node == nil || node.Flags&ast.NodeFlagsReparsed != 0 {
|
||||
return node
|
||||
}
|
||||
if foundChild != nil { // We cannot abort visiting children, so once the desired child is found, we do nothing.
|
||||
return node
|
||||
}
|
||||
if position < node.End() && (prevChild == nil || prevChild.End() <= position) {
|
||||
foundChild = node
|
||||
} else {
|
||||
prevChild = node
|
||||
}
|
||||
return node
|
||||
}
|
||||
visitNodes := func(nodeList *ast.NodeList, _ *ast.NodeVisitor) *ast.NodeList {
|
||||
if foundChild != nil {
|
||||
return nodeList
|
||||
}
|
||||
if nodeList != nil && len(nodeList.Nodes) > 0 {
|
||||
nodes := nodeList.Nodes
|
||||
index, match := core.BinarySearchUniqueFunc(nodes, func(middle int, _ *ast.Node) int {
|
||||
// synthetic jsdoc nodes should have jsdocNode.End() <= n.Pos()
|
||||
if nodes[middle].Flags&ast.NodeFlagsReparsed != 0 {
|
||||
return comparisonLessThan
|
||||
}
|
||||
if position < nodes[middle].End() {
|
||||
if middle == 0 || position >= nodes[middle-1].End() {
|
||||
return comparisonEqualTo
|
||||
}
|
||||
return comparisonGreaterThan
|
||||
}
|
||||
return comparisonLessThan
|
||||
})
|
||||
|
||||
if match {
|
||||
foundChild = nodes[index]
|
||||
}
|
||||
|
||||
validLookupIndex := core.IfElse(match, index-1, len(nodes)-1)
|
||||
for i := validLookupIndex; i >= 0; i-- {
|
||||
if nodes[i].Flags&ast.NodeFlagsReparsed != 0 {
|
||||
continue
|
||||
}
|
||||
if prevChild == nil {
|
||||
prevChild = nodes[i]
|
||||
}
|
||||
}
|
||||
}
|
||||
return nodeList
|
||||
}
|
||||
VisitEachChildAndJSDoc(n, sourceFile, visitNode, visitNodes)
|
||||
|
||||
if foundChild != nil {
|
||||
// Note that the span of a node's tokens is [getStartOfNode(node, ...), node.end).
|
||||
// Given that `position < child.end` and child has constituent tokens, we distinguish these cases:
|
||||
// 1) `position` precedes `child`'s tokens or `child` has no tokens (ie: in a comment or whitespace preceding `child`):
|
||||
// we need to find the last token in a previous child node or child tokens.
|
||||
// 2) `position` is within the same span: we recurse on `child`.
|
||||
start := GetStartOfNode(foundChild, sourceFile, !excludeJSDoc /*includeJSDoc*/)
|
||||
lookInPreviousChild := start >= position || // cursor in the leading trivia or preceding tokens
|
||||
!isValidPrecedingNode(foundChild, sourceFile)
|
||||
if lookInPreviousChild {
|
||||
if position >= foundChild.Pos() {
|
||||
// Find jsdoc preceding the foundChild.
|
||||
var jsDoc *ast.Node
|
||||
nodeJSDoc := n.JSDoc(sourceFile)
|
||||
for i := len(nodeJSDoc) - 1; i >= 0; i-- {
|
||||
if nodeJSDoc[i].Pos() >= foundChild.Pos() {
|
||||
jsDoc = nodeJSDoc[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
if jsDoc != nil {
|
||||
if !excludeJSDoc {
|
||||
return find(jsDoc)
|
||||
} else {
|
||||
return findRightmostValidToken(jsDoc.End(), sourceFile, n, position, excludeJSDoc)
|
||||
}
|
||||
}
|
||||
return findRightmostValidToken(foundChild.Pos(), sourceFile, n, -1 /*position*/, excludeJSDoc)
|
||||
} else { // Answer is in tokens between two visited children.
|
||||
return findRightmostValidToken(foundChild.Pos(), sourceFile, n, position, excludeJSDoc)
|
||||
}
|
||||
} else {
|
||||
// position is in [foundChild.getStart(), foundChild.End): recur.
|
||||
return find(foundChild)
|
||||
}
|
||||
}
|
||||
|
||||
// We have two cases here: either the position is at the end of the file,
|
||||
// or the desired token is in the unvisited trailing tokens of the current node.
|
||||
if position >= n.End() {
|
||||
return findRightmostValidToken(n.End(), sourceFile, n, -1 /*position*/, excludeJSDoc)
|
||||
} else {
|
||||
return findRightmostValidToken(n.End(), sourceFile, n, position, excludeJSDoc)
|
||||
}
|
||||
}
|
||||
|
||||
var node *ast.Node
|
||||
if startNode != nil {
|
||||
node = startNode
|
||||
} else {
|
||||
node = sourceFile.AsNode()
|
||||
}
|
||||
result := find(node)
|
||||
if result != nil && ast.IsWhitespaceOnlyJsxText(result) {
|
||||
panic("Expected result to be a non-whitespace token.")
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func isValidPrecedingNode(node *ast.Node, sourceFile *ast.SourceFile) bool {
|
||||
start := GetStartOfNode(node, sourceFile, false /*includeJSDoc*/)
|
||||
width := node.End() - start
|
||||
return !(ast.IsWhitespaceOnlyJsxText(node) || width == 0)
|
||||
}
|
||||
|
||||
func GetStartOfNode(node *ast.Node, file *ast.SourceFile, includeJSDoc bool) int {
|
||||
return scanner.GetTokenPosOfNode(node, file, includeJSDoc)
|
||||
}
|
||||
|
||||
// Looks for rightmost valid token in the range [startPos, endPos).
|
||||
// If position is >= 0, looks for rightmost valid token that precedes or touches that position.
|
||||
func findRightmostValidToken(endPos int, sourceFile *ast.SourceFile, containingNode *ast.Node, position int, excludeJSDoc bool) *ast.Node {
|
||||
if position == -1 {
|
||||
position = containingNode.End()
|
||||
}
|
||||
var find func(n *ast.Node, endPos int) *ast.Node
|
||||
find = func(n *ast.Node, endPos int) *ast.Node {
|
||||
if n == nil {
|
||||
return nil
|
||||
}
|
||||
if ast.IsNonWhitespaceToken(n) {
|
||||
return n
|
||||
}
|
||||
|
||||
var rightmostValidNode *ast.Node
|
||||
rightmostVisitedNodes := make([]*ast.Node, 0, 1) // Nodes after the last valid node.
|
||||
hasChildren := false
|
||||
shouldVisitNode := func(node *ast.Node) bool {
|
||||
// Node is synthetic or out of the desired range: don't visit it.
|
||||
return !(node.Flags&ast.NodeFlagsReparsed != 0 ||
|
||||
node.End() > endPos || GetStartOfNode(node, sourceFile, !excludeJSDoc /*includeJSDoc*/) >= position)
|
||||
}
|
||||
visitNode := func(node *ast.Node, _ *ast.NodeVisitor) *ast.Node {
|
||||
if node == nil {
|
||||
return node
|
||||
}
|
||||
hasChildren = true
|
||||
if !shouldVisitNode(node) {
|
||||
return node
|
||||
}
|
||||
rightmostVisitedNodes = append(rightmostVisitedNodes, node)
|
||||
if isValidPrecedingNode(node, sourceFile) {
|
||||
rightmostValidNode = node
|
||||
rightmostVisitedNodes = rightmostVisitedNodes[:0]
|
||||
}
|
||||
return node
|
||||
}
|
||||
visitNodes := func(nodeList *ast.NodeList, _ *ast.NodeVisitor) *ast.NodeList {
|
||||
if nodeList != nil && len(nodeList.Nodes) > 0 {
|
||||
hasChildren = true
|
||||
index, _ := core.BinarySearchUniqueFunc(nodeList.Nodes, func(middle int, node *ast.Node) int {
|
||||
if node.End() > endPos {
|
||||
return comparisonGreaterThan
|
||||
}
|
||||
return comparisonLessThan
|
||||
})
|
||||
validIndex := -1
|
||||
for i := index - 1; i >= 0; i-- {
|
||||
if !shouldVisitNode(nodeList.Nodes[i]) {
|
||||
continue
|
||||
}
|
||||
if isValidPrecedingNode(nodeList.Nodes[i], sourceFile) {
|
||||
validIndex = i
|
||||
rightmostValidNode = nodeList.Nodes[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
for i := validIndex + 1; i < index; i++ {
|
||||
if !shouldVisitNode(nodeList.Nodes[i]) {
|
||||
continue
|
||||
}
|
||||
rightmostVisitedNodes = append(rightmostVisitedNodes, nodeList.Nodes[i])
|
||||
}
|
||||
}
|
||||
return nodeList
|
||||
}
|
||||
VisitEachChildAndJSDoc(n, sourceFile, visitNode, visitNodes)
|
||||
|
||||
// Three cases:
|
||||
// 1. The answer is a token of `rightmostValidNode`.
|
||||
// 2. The answer is one of the unvisited tokens that occur after the rightmost valid node.
|
||||
// 3. The current node is a childless, token-less node. The answer is the current node.
|
||||
|
||||
// Case 2: Look at unvisited trailing tokens that occur in between the rightmost visited nodes.
|
||||
if !shouldSkipChild(n) { // JSDoc nodes don't include trivia tokens as children.
|
||||
var startPos int
|
||||
if rightmostValidNode != nil {
|
||||
startPos = rightmostValidNode.End()
|
||||
} else {
|
||||
startPos = n.Pos()
|
||||
}
|
||||
scanner := scanner.GetScannerForSourceFile(sourceFile, startPos)
|
||||
var tokens []*ast.Node
|
||||
for _, visitedNode := range rightmostVisitedNodes {
|
||||
// Trailing tokens that occur before this node.
|
||||
for startPos < min(visitedNode.Pos(), position) {
|
||||
tokenStart := scanner.TokenStart()
|
||||
if tokenStart >= position {
|
||||
break
|
||||
}
|
||||
token := scanner.Token()
|
||||
tokenFullStart := scanner.TokenFullStart()
|
||||
tokenEnd := scanner.TokenEnd()
|
||||
startPos = tokenEnd
|
||||
tokens = append(tokens, sourceFile.GetOrCreateToken(token, tokenFullStart, tokenEnd, n))
|
||||
scanner.Scan()
|
||||
}
|
||||
startPos = visitedNode.End()
|
||||
scanner.ResetPos(startPos)
|
||||
scanner.Scan()
|
||||
}
|
||||
// Trailing tokens after last visited node.
|
||||
for startPos < min(endPos, position) {
|
||||
tokenStart := scanner.TokenStart()
|
||||
if tokenStart >= position {
|
||||
break
|
||||
}
|
||||
token := scanner.Token()
|
||||
tokenFullStart := scanner.TokenFullStart()
|
||||
tokenEnd := scanner.TokenEnd()
|
||||
startPos = tokenEnd
|
||||
tokens = append(tokens, sourceFile.GetOrCreateToken(token, tokenFullStart, tokenEnd, n))
|
||||
scanner.Scan()
|
||||
}
|
||||
|
||||
lastToken := len(tokens) - 1
|
||||
// Find preceding valid token.
|
||||
for i := lastToken; i >= 0; i-- {
|
||||
if !ast.IsWhitespaceOnlyJsxText(tokens[i]) {
|
||||
return tokens[i]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Case 3: childless node.
|
||||
if !hasChildren {
|
||||
if n != containingNode {
|
||||
return n
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// Case 1: recur on rightmostValidNode.
|
||||
if rightmostValidNode != nil {
|
||||
endPos = rightmostValidNode.End()
|
||||
}
|
||||
return find(rightmostValidNode, endPos)
|
||||
}
|
||||
|
||||
return find(containingNode, endPos)
|
||||
}
|
||||
|
||||
func FindNextToken(previousToken *ast.Node, parent *ast.Node, file *ast.SourceFile) *ast.Node {
|
||||
var find func(n *ast.Node) *ast.Node
|
||||
find = func(n *ast.Node) *ast.Node {
|
||||
if ast.IsTokenKind(n.Kind) && n.Pos() == previousToken.End() {
|
||||
// this is token that starts at the end of previous token - return it
|
||||
return n
|
||||
}
|
||||
// Node that contains `previousToken` or occurs immediately after it.
|
||||
var foundNode *ast.Node
|
||||
visitNode := func(node *ast.Node, _ *ast.NodeVisitor) *ast.Node {
|
||||
if node != nil && node.Flags&ast.NodeFlagsReparsed == 0 &&
|
||||
node.Pos() <= previousToken.End() && node.End() > previousToken.End() {
|
||||
foundNode = node
|
||||
}
|
||||
return node
|
||||
}
|
||||
visitNodes := func(nodeList *ast.NodeList, _ *ast.NodeVisitor) *ast.NodeList {
|
||||
if nodeList != nil && len(nodeList.Nodes) > 0 && foundNode == nil {
|
||||
nodes := nodeList.Nodes
|
||||
index, match := core.BinarySearchUniqueFunc(nodes, func(_ int, node *ast.Node) int {
|
||||
if node.Flags&ast.NodeFlagsReparsed != 0 {
|
||||
return comparisonLessThan
|
||||
}
|
||||
if node.Pos() > previousToken.End() {
|
||||
return comparisonGreaterThan
|
||||
}
|
||||
if node.End() <= previousToken.Pos() {
|
||||
return comparisonLessThan
|
||||
}
|
||||
return comparisonEqualTo
|
||||
})
|
||||
if match {
|
||||
foundNode = nodes[index]
|
||||
}
|
||||
}
|
||||
return nodeList
|
||||
}
|
||||
VisitEachChildAndJSDoc(n, file, visitNode, visitNodes)
|
||||
// Cases:
|
||||
// 1. no answer exists
|
||||
// 2. answer is an unvisited token
|
||||
// 3. answer is in the visited found node
|
||||
|
||||
// Case 3: look for the next token inside the found node.
|
||||
if foundNode != nil {
|
||||
return find(foundNode)
|
||||
}
|
||||
startPos := previousToken.End()
|
||||
// Case 2: look for the next token directly.
|
||||
if startPos >= n.Pos() && startPos < n.End() {
|
||||
scanner := scanner.GetScannerForSourceFile(file, startPos)
|
||||
token := scanner.Token()
|
||||
tokenFullStart := scanner.TokenFullStart()
|
||||
tokenStart := scanner.TokenStart()
|
||||
tokenEnd := scanner.TokenEnd()
|
||||
if tokenStart == previousToken.End() {
|
||||
return file.GetOrCreateToken(token, tokenFullStart, tokenEnd, n)
|
||||
}
|
||||
panic(fmt.Sprintf("Expected to find next token at %d, got token %s at %d", previousToken.End(), token, tokenStart))
|
||||
}
|
||||
// Case 3: no answer.
|
||||
return nil
|
||||
}
|
||||
return find(parent)
|
||||
}
|
||||
|
||||
func getNodeVisitor(
|
||||
visitNode func(*ast.Node, *ast.NodeVisitor) *ast.Node,
|
||||
visitNodes func(*ast.NodeList, *ast.NodeVisitor) *ast.NodeList,
|
||||
) *ast.NodeVisitor {
|
||||
var wrappedVisitNode func(*ast.Node, *ast.NodeVisitor) *ast.Node
|
||||
var wrappedVisitNodes func(*ast.NodeList, *ast.NodeVisitor) *ast.NodeList
|
||||
if visitNode != nil {
|
||||
wrappedVisitNode = func(n *ast.Node, v *ast.NodeVisitor) *ast.Node {
|
||||
if ast.IsJSDocSingleCommentNodeComment(n) {
|
||||
return n
|
||||
}
|
||||
return visitNode(n, v)
|
||||
}
|
||||
}
|
||||
|
||||
if visitNodes != nil {
|
||||
wrappedVisitNodes = func(n *ast.NodeList, v *ast.NodeVisitor) *ast.NodeList {
|
||||
if ast.IsJSDocSingleCommentNodeList(n) {
|
||||
return n
|
||||
}
|
||||
return visitNodes(n, v)
|
||||
}
|
||||
}
|
||||
|
||||
return ast.NewNodeVisitor(core.Identity, nil, ast.NodeVisitorHooks{
|
||||
VisitNode: wrappedVisitNode,
|
||||
VisitToken: wrappedVisitNode,
|
||||
VisitNodes: wrappedVisitNodes,
|
||||
VisitModifiers: func(modifiers *ast.ModifierList, visitor *ast.NodeVisitor) *ast.ModifierList {
|
||||
if modifiers != nil {
|
||||
wrappedVisitNodes(&modifiers.NodeList, visitor)
|
||||
}
|
||||
return modifiers
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func shouldSkipChild(node *ast.Node) bool {
|
||||
return node.Kind == ast.KindJSDoc ||
|
||||
node.Kind == ast.KindJSDocText ||
|
||||
node.Kind == ast.KindJSDocTypeLiteral ||
|
||||
node.Kind == ast.KindJSDocSignature ||
|
||||
ast.IsJSDocLinkLike(node) ||
|
||||
ast.IsJSDocTag(node)
|
||||
}
|
||||
474
kitcom/internal/tsgo/astnav/tokens_test.go
Normal file
474
kitcom/internal/tsgo/astnav/tokens_test.go
Normal file
@ -0,0 +1,474 @@
|
||||
package astnav_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/astnav"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/parser"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/repo"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/testutil/baseline"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/testutil/jstest"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
var testFiles = []string{
|
||||
filepath.Join(repo.TypeScriptSubmodulePath, "src/services/mapCode.ts"),
|
||||
}
|
||||
|
||||
func TestGetTokenAtPosition(t *testing.T) {
|
||||
t.Parallel()
|
||||
repo.SkipIfNoTypeScriptSubmodule(t)
|
||||
jstest.SkipIfNoNodeJS(t)
|
||||
|
||||
t.Run("baseline", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
baselineTokens(
|
||||
t,
|
||||
"GetTokenAtPosition",
|
||||
false, /*includeEOF*/
|
||||
func(fileText string, positions []int) []*tokenInfo {
|
||||
return tsGetTokensAtPositions(t, fileText, positions)
|
||||
},
|
||||
func(file *ast.SourceFile, pos int) *tokenInfo {
|
||||
return toTokenInfo(astnav.GetTokenAtPosition(file, pos))
|
||||
},
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("pointer equality", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
fileText := `
|
||||
function foo() {
|
||||
return 0;
|
||||
}
|
||||
`
|
||||
file := parser.ParseSourceFile(ast.SourceFileParseOptions{
|
||||
FileName: "/file.ts",
|
||||
Path: "/file.ts",
|
||||
}, fileText, core.ScriptKindTS)
|
||||
assert.Equal(t, astnav.GetTokenAtPosition(file, 0), astnav.GetTokenAtPosition(file, 0))
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetTouchingPropertyName(t *testing.T) {
|
||||
t.Parallel()
|
||||
jstest.SkipIfNoNodeJS(t)
|
||||
repo.SkipIfNoTypeScriptSubmodule(t)
|
||||
|
||||
baselineTokens(
|
||||
t,
|
||||
"GetTouchingPropertyName",
|
||||
false, /*includeEOF*/
|
||||
func(fileText string, positions []int) []*tokenInfo {
|
||||
return tsGetTouchingPropertyName(t, fileText, positions)
|
||||
},
|
||||
func(file *ast.SourceFile, pos int) *tokenInfo {
|
||||
return toTokenInfo(astnav.GetTouchingPropertyName(file, pos))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func baselineTokens(t *testing.T, testName string, includeEOF bool, getTSTokens func(fileText string, positions []int) []*tokenInfo, getGoToken func(file *ast.SourceFile, pos int) *tokenInfo) {
|
||||
for _, fileName := range testFiles {
|
||||
t.Run(filepath.Base(fileName), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
fileText, err := os.ReadFile(fileName)
|
||||
assert.NilError(t, err)
|
||||
|
||||
positions := make([]int, len(fileText)+core.IfElse(includeEOF, 1, 0))
|
||||
for i := range positions {
|
||||
positions[i] = i
|
||||
}
|
||||
tsTokens := getTSTokens(string(fileText), positions)
|
||||
file := parser.ParseSourceFile(ast.SourceFileParseOptions{
|
||||
FileName: "/file.ts",
|
||||
Path: "/file.ts",
|
||||
}, string(fileText), core.ScriptKindTS)
|
||||
|
||||
var output strings.Builder
|
||||
currentRange := core.NewTextRange(0, 0)
|
||||
currentDiff := tokenDiff{}
|
||||
|
||||
for pos, tsToken := range tsTokens {
|
||||
goToken := getGoToken(file, pos)
|
||||
diff := tokenDiff{goToken: goToken, tsToken: tsToken}
|
||||
|
||||
if !diffEqual(currentDiff, diff) {
|
||||
if !tokensEqual(currentDiff.goToken, currentDiff.tsToken) {
|
||||
writeRangeDiff(&output, file, currentDiff, currentRange, pos)
|
||||
}
|
||||
currentDiff = diff
|
||||
currentRange = core.NewTextRange(pos, pos)
|
||||
}
|
||||
currentRange = currentRange.WithEnd(pos)
|
||||
}
|
||||
|
||||
if !tokensEqual(currentDiff.goToken, currentDiff.tsToken) {
|
||||
writeRangeDiff(&output, file, currentDiff, currentRange, len(tsTokens)-1)
|
||||
}
|
||||
|
||||
baseline.Run(
|
||||
t,
|
||||
fmt.Sprintf("%s.%s.baseline.txt", testName, filepath.Base(fileName)),
|
||||
core.IfElse(output.Len() > 0, output.String(), baseline.NoContent),
|
||||
baseline.Options{
|
||||
Subfolder: "astnav",
|
||||
},
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
type tokenDiff struct {
|
||||
goToken *tokenInfo
|
||||
tsToken *tokenInfo
|
||||
}
|
||||
|
||||
type tokenInfo struct {
|
||||
Kind string `json:"kind"`
|
||||
Pos int `json:"pos"`
|
||||
End int `json:"end"`
|
||||
}
|
||||
|
||||
func toTokenInfo(node *ast.Node) *tokenInfo {
|
||||
if node == nil {
|
||||
return nil
|
||||
}
|
||||
kind := strings.Replace(node.Kind.String(), "Kind", "", 1)
|
||||
switch kind {
|
||||
case "EndOfFile":
|
||||
kind = "EndOfFileToken"
|
||||
}
|
||||
return &tokenInfo{
|
||||
Kind: kind,
|
||||
Pos: node.Pos(),
|
||||
End: node.End(),
|
||||
}
|
||||
}
|
||||
|
||||
func diffEqual(a, b tokenDiff) bool {
|
||||
return tokensEqual(a.goToken, b.goToken) && tokensEqual(a.tsToken, b.tsToken)
|
||||
}
|
||||
|
||||
func tokensEqual(t1, t2 *tokenInfo) bool {
|
||||
if t1 == nil || t2 == nil {
|
||||
return t1 == t2
|
||||
}
|
||||
return *t1 == *t2
|
||||
}
|
||||
|
||||
func tsGetTokensAtPositions(t testing.TB, fileText string, positions []int) []*tokenInfo {
|
||||
dir := t.TempDir()
|
||||
err := os.WriteFile(filepath.Join(dir, "file.ts"), []byte(fileText), 0o644)
|
||||
assert.NilError(t, err)
|
||||
|
||||
err = os.WriteFile(filepath.Join(dir, "positions.json"), []byte(core.Must(core.StringifyJson(positions, "", ""))), 0o644)
|
||||
assert.NilError(t, err)
|
||||
|
||||
script := `
|
||||
import fs from "fs";
|
||||
export default (ts) => {
|
||||
const positions = JSON.parse(fs.readFileSync("positions.json", "utf8"));
|
||||
const fileText = fs.readFileSync("file.ts", "utf8");
|
||||
const file = ts.createSourceFile(
|
||||
"file.ts",
|
||||
fileText,
|
||||
{ languageVersion: ts.ScriptTarget.Latest, jsDocParsingMode: ts.JSDocParsingMode.ParseAll },
|
||||
/*setParentNodes*/ true
|
||||
);
|
||||
return positions.map(position => {
|
||||
let token = ts.getTokenAtPosition(file, position);
|
||||
if (token.kind === ts.SyntaxKind.SyntaxList) {
|
||||
token = token.parent;
|
||||
}
|
||||
return {
|
||||
kind: ts.Debug.formatSyntaxKind(token.kind),
|
||||
pos: token.pos,
|
||||
end: token.end,
|
||||
};
|
||||
});
|
||||
};`
|
||||
|
||||
info, err := jstest.EvalNodeScriptWithTS[[]*tokenInfo](t, script, dir, "")
|
||||
assert.NilError(t, err)
|
||||
return info
|
||||
}
|
||||
|
||||
func tsGetTouchingPropertyName(t testing.TB, fileText string, positions []int) []*tokenInfo {
|
||||
dir := t.TempDir()
|
||||
err := os.WriteFile(filepath.Join(dir, "file.ts"), []byte(fileText), 0o644)
|
||||
assert.NilError(t, err)
|
||||
|
||||
err = os.WriteFile(filepath.Join(dir, "positions.json"), []byte(core.Must(core.StringifyJson(positions, "", ""))), 0o644)
|
||||
assert.NilError(t, err)
|
||||
|
||||
script := `
|
||||
import fs from "fs";
|
||||
export default (ts) => {
|
||||
const positions = JSON.parse(fs.readFileSync("positions.json", "utf8"));
|
||||
const fileText = fs.readFileSync("file.ts", "utf8");
|
||||
const file = ts.createSourceFile(
|
||||
"file.ts",
|
||||
fileText,
|
||||
{ languageVersion: ts.ScriptTarget.Latest, jsDocParsingMode: ts.JSDocParsingMode.ParseAll },
|
||||
/*setParentNodes*/ true
|
||||
);
|
||||
return positions.map(position => {
|
||||
let token = ts.getTouchingPropertyName(file, position);
|
||||
if (token.kind === ts.SyntaxKind.SyntaxList) {
|
||||
token = token.parent;
|
||||
}
|
||||
return {
|
||||
kind: ts.Debug.formatSyntaxKind(token.kind),
|
||||
pos: token.pos,
|
||||
end: token.end,
|
||||
};
|
||||
});
|
||||
};`
|
||||
|
||||
info, err := jstest.EvalNodeScriptWithTS[[]*tokenInfo](t, script, dir, "")
|
||||
assert.NilError(t, err)
|
||||
return info
|
||||
}
|
||||
|
||||
func writeRangeDiff(output *strings.Builder, file *ast.SourceFile, diff tokenDiff, rng core.TextRange, position int) {
|
||||
lines := file.ECMALineMap()
|
||||
|
||||
tsTokenPos := position
|
||||
goTokenPos := position
|
||||
tsTokenEnd := position
|
||||
goTokenEnd := position
|
||||
if diff.tsToken != nil {
|
||||
tsTokenPos = diff.tsToken.Pos
|
||||
tsTokenEnd = diff.tsToken.End
|
||||
}
|
||||
if diff.goToken != nil {
|
||||
goTokenPos = diff.goToken.Pos
|
||||
goTokenEnd = diff.goToken.End
|
||||
}
|
||||
tsStartLine, _ := core.PositionToLineAndCharacter(tsTokenPos, lines)
|
||||
tsEndLine, _ := core.PositionToLineAndCharacter(tsTokenEnd, lines)
|
||||
goStartLine, _ := core.PositionToLineAndCharacter(goTokenPos, lines)
|
||||
goEndLine, _ := core.PositionToLineAndCharacter(goTokenEnd, lines)
|
||||
|
||||
contextLines := 2
|
||||
startLine := min(tsStartLine, goStartLine)
|
||||
endLine := max(tsEndLine, goEndLine)
|
||||
markerLines := []int{tsStartLine, tsEndLine, goStartLine, goEndLine}
|
||||
slices.Sort(markerLines)
|
||||
contextStart := max(0, startLine-contextLines)
|
||||
contextEnd := min(len(lines)-1, endLine+contextLines)
|
||||
digits := len(strconv.Itoa(contextEnd))
|
||||
|
||||
shouldTruncate := func(line int) (result bool, skipTo int) {
|
||||
index, _ := slices.BinarySearch(markerLines, line)
|
||||
if index == 0 || index == len(markerLines) {
|
||||
return false, 0
|
||||
}
|
||||
low := markerLines[index-1]
|
||||
high := markerLines[index]
|
||||
if line-low > 5 && high-line > 5 {
|
||||
return true, high - 5
|
||||
}
|
||||
return false, 0
|
||||
}
|
||||
|
||||
if output.Len() > 0 {
|
||||
output.WriteString("\n\n")
|
||||
}
|
||||
|
||||
output.WriteString(fmt.Sprintf("〚Positions: [%d, %d]〛\n", rng.Pos(), rng.End()))
|
||||
if diff.tsToken != nil {
|
||||
output.WriteString(fmt.Sprintf("【TS: %s [%d, %d)】\n", diff.tsToken.Kind, tsTokenPos, tsTokenEnd))
|
||||
} else {
|
||||
output.WriteString("【TS: nil】\n")
|
||||
}
|
||||
if diff.goToken != nil {
|
||||
output.WriteString(fmt.Sprintf("《Go: %s [%d, %d)》\n", diff.goToken.Kind, goTokenPos, goTokenEnd))
|
||||
} else {
|
||||
output.WriteString("《Go: nil》\n")
|
||||
}
|
||||
for line := contextStart; line <= contextEnd; line++ {
|
||||
if truncate, skipTo := shouldTruncate(line); truncate {
|
||||
output.WriteString(fmt.Sprintf("%s │........ %d lines omitted ........\n", strings.Repeat(" ", digits), skipTo-line+1))
|
||||
line = skipTo
|
||||
}
|
||||
output.WriteString(fmt.Sprintf("%*d │", digits, line+1))
|
||||
end := len(file.Text()) + 1
|
||||
if line < len(lines)-1 {
|
||||
end = int(lines[line+1])
|
||||
}
|
||||
for pos := int(lines[line]); pos < end; pos++ {
|
||||
if pos == rng.End()+1 {
|
||||
output.WriteString("〛")
|
||||
}
|
||||
if diff.tsToken != nil && pos == tsTokenEnd {
|
||||
output.WriteString("】")
|
||||
}
|
||||
if diff.goToken != nil && pos == goTokenEnd {
|
||||
output.WriteString("》")
|
||||
}
|
||||
|
||||
if diff.goToken != nil && pos == goTokenPos {
|
||||
output.WriteString("《")
|
||||
}
|
||||
if diff.tsToken != nil && pos == tsTokenPos {
|
||||
output.WriteString("【")
|
||||
}
|
||||
if pos == rng.Pos() {
|
||||
output.WriteString("〚")
|
||||
}
|
||||
|
||||
if pos < len(file.Text()) {
|
||||
output.WriteByte(file.Text()[pos])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindPrecedingToken(t *testing.T) {
|
||||
t.Parallel()
|
||||
repo.SkipIfNoTypeScriptSubmodule(t)
|
||||
jstest.SkipIfNoNodeJS(t)
|
||||
|
||||
t.Run("baseline", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
baselineTokens(
|
||||
t,
|
||||
"FindPrecedingToken",
|
||||
true, /*includeEOF*/
|
||||
func(fileText string, positions []int) []*tokenInfo {
|
||||
return tsFindPrecedingTokens(t, fileText, positions)
|
||||
},
|
||||
func(file *ast.SourceFile, pos int) *tokenInfo {
|
||||
return toTokenInfo(astnav.FindPrecedingToken(file, pos))
|
||||
},
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
func TestUnitFindPrecedingToken(t *testing.T) {
|
||||
t.Parallel()
|
||||
testCases := []struct {
|
||||
name string
|
||||
fileContent string
|
||||
position int
|
||||
expectedKind ast.Kind
|
||||
}{
|
||||
{
|
||||
name: "after dot in jsdoc",
|
||||
fileContent: `import {
|
||||
CharacterCodes,
|
||||
compareStringsCaseInsensitive,
|
||||
compareStringsCaseSensitive,
|
||||
compareValues,
|
||||
Comparison,
|
||||
Debug,
|
||||
endsWith,
|
||||
equateStringsCaseInsensitive,
|
||||
equateStringsCaseSensitive,
|
||||
GetCanonicalFileName,
|
||||
getDeclarationFileExtension,
|
||||
getStringComparer,
|
||||
identity,
|
||||
lastOrUndefined,
|
||||
Path,
|
||||
some,
|
||||
startsWith,
|
||||
} from "./_namespaces/ts.js";
|
||||
|
||||
/**
|
||||
* Internally, we represent paths as strings with '/' as the directory separator.
|
||||
* When we make system calls (eg: LanguageServiceHost.getDirectory()),
|
||||
* we expect the host to correctly handle paths in our specified format.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const directorySeparator = "/";
|
||||
/** @internal */
|
||||
export const altDirectorySeparator = "\\";
|
||||
const urlSchemeSeparator = "://";
|
||||
const backslashRegExp = /\\/g;
|
||||
|
||||
|
||||
backslashRegExp.
|
||||
|
||||
//Path Tests
|
||||
|
||||
/**
|
||||
* Determines whether a charCode corresponds to '/' or '\'.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function isAnyDirectorySeparator(charCode: number): boolean {
|
||||
return charCode === CharacterCodes.slash || charCode === CharacterCodes.backslash;
|
||||
}`,
|
||||
position: 839,
|
||||
expectedKind: ast.KindDotToken,
|
||||
},
|
||||
{
|
||||
name: "after comma in parameter list",
|
||||
fileContent: `takesCb((n, s, ))`,
|
||||
position: 15,
|
||||
expectedKind: ast.KindCommaToken,
|
||||
},
|
||||
}
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
file := parser.ParseSourceFile(ast.SourceFileParseOptions{
|
||||
FileName: "/file.ts",
|
||||
Path: "/file.ts",
|
||||
}, testCase.fileContent, core.ScriptKindTS)
|
||||
token := astnav.FindPrecedingToken(file, testCase.position)
|
||||
assert.Equal(t, token.Kind, testCase.expectedKind)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func tsFindPrecedingTokens(t *testing.T, fileText string, positions []int) []*tokenInfo {
|
||||
dir := t.TempDir()
|
||||
err := os.WriteFile(filepath.Join(dir, "file.ts"), []byte(fileText), 0o644)
|
||||
assert.NilError(t, err)
|
||||
|
||||
err = os.WriteFile(filepath.Join(dir, "positions.json"), []byte(core.Must(core.StringifyJson(positions, "", ""))), 0o644)
|
||||
assert.NilError(t, err)
|
||||
|
||||
script := `
|
||||
import fs from "fs";
|
||||
export default (ts) => {
|
||||
const positions = JSON.parse(fs.readFileSync("positions.json", "utf8"));
|
||||
const fileText = fs.readFileSync("file.ts", "utf8");
|
||||
const file = ts.createSourceFile(
|
||||
"file.ts",
|
||||
fileText,
|
||||
{ languageVersion: ts.ScriptTarget.Latest, jsDocParsingMode: ts.JSDocParsingMode.ParseAll },
|
||||
/*setParentNodes*/ true
|
||||
);
|
||||
return positions.map(position => {
|
||||
let token = ts.findPrecedingToken(position, file);
|
||||
if (token === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (token.kind === ts.SyntaxKind.SyntaxList) {
|
||||
token = token.parent;
|
||||
}
|
||||
return {
|
||||
kind: ts.Debug.formatSyntaxKind(token.kind),
|
||||
pos: token.pos,
|
||||
end: token.end,
|
||||
};
|
||||
});
|
||||
};`
|
||||
info, err := jstest.EvalNodeScriptWithTS[[]*tokenInfo](t, script, dir, "")
|
||||
assert.NilError(t, err)
|
||||
return info
|
||||
}
|
||||
2820
kitcom/internal/tsgo/binder/binder.go
Normal file
2820
kitcom/internal/tsgo/binder/binder.go
Normal file
File diff suppressed because it is too large
Load Diff
51
kitcom/internal/tsgo/binder/binder_test.go
Normal file
51
kitcom/internal/tsgo/binder/binder_test.go
Normal file
@ -0,0 +1,51 @@
|
||||
package binder
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/parser"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/testutil/fixtures"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/vfs/osvfs"
|
||||
)
|
||||
|
||||
func BenchmarkBind(b *testing.B) {
|
||||
for _, f := range fixtures.BenchFixtures {
|
||||
b.Run(f.Name(), func(b *testing.B) {
|
||||
f.SkipIfNotExist(b)
|
||||
|
||||
fileName := tspath.GetNormalizedAbsolutePath(f.Path(), "/")
|
||||
path := tspath.ToPath(fileName, "/", osvfs.FS().UseCaseSensitiveFileNames())
|
||||
sourceText := f.ReadFile(b)
|
||||
|
||||
compilerOptions := &core.CompilerOptions{Target: core.ScriptTargetESNext, Module: core.ModuleKindNodeNext}
|
||||
sourceAffecting := compilerOptions.SourceFileAffecting()
|
||||
|
||||
parseOptions := ast.SourceFileParseOptions{
|
||||
FileName: fileName,
|
||||
Path: path,
|
||||
CompilerOptions: sourceAffecting,
|
||||
JSDocParsingMode: ast.JSDocParsingModeParseAll,
|
||||
}
|
||||
scriptKind := core.GetScriptKindFromFileName(fileName)
|
||||
|
||||
sourceFiles := make([]*ast.SourceFile, b.N)
|
||||
for i := range b.N {
|
||||
sourceFiles[i] = parser.ParseSourceFile(parseOptions, sourceText, scriptKind)
|
||||
}
|
||||
|
||||
// The above parses do a lot of work; ensure GC is finished before we start collecting performance data.
|
||||
// GC must be called twice to allow things to settle.
|
||||
runtime.GC()
|
||||
runtime.GC()
|
||||
|
||||
b.ResetTimer()
|
||||
for i := range b.N {
|
||||
BindSourceFile(sourceFiles[i])
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
503
kitcom/internal/tsgo/binder/nameresolver.go
Normal file
503
kitcom/internal/tsgo/binder/nameresolver.go
Normal file
@ -0,0 +1,503 @@
|
||||
package binder
|
||||
|
||||
import (
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/diagnostics"
|
||||
)
|
||||
|
||||
type NameResolver struct {
|
||||
CompilerOptions *core.CompilerOptions
|
||||
GetSymbolOfDeclaration func(node *ast.Node) *ast.Symbol
|
||||
Error func(location *ast.Node, message *diagnostics.Message, args ...any) *ast.Diagnostic
|
||||
Globals ast.SymbolTable
|
||||
ArgumentsSymbol *ast.Symbol
|
||||
RequireSymbol *ast.Symbol
|
||||
GetModuleSymbol func(sourceFile *ast.Node) *ast.Symbol
|
||||
Lookup func(symbols ast.SymbolTable, name string, meaning ast.SymbolFlags) *ast.Symbol
|
||||
SymbolReferenced func(symbol *ast.Symbol, meaning ast.SymbolFlags)
|
||||
SetRequiresScopeChangeCache func(node *ast.Node, value core.Tristate)
|
||||
GetRequiresScopeChangeCache func(node *ast.Node) core.Tristate
|
||||
OnPropertyWithInvalidInitializer func(location *ast.Node, name string, declaration *ast.Node, result *ast.Symbol) bool
|
||||
OnFailedToResolveSymbol func(location *ast.Node, name string, meaning ast.SymbolFlags, nameNotFoundMessage *diagnostics.Message)
|
||||
OnSuccessfullyResolvedSymbol func(location *ast.Node, result *ast.Symbol, meaning ast.SymbolFlags, lastLocation *ast.Node, associatedDeclarationForContainingInitializerOrBindingName *ast.Node, withinDeferredContext bool)
|
||||
}
|
||||
|
||||
func (r *NameResolver) Resolve(location *ast.Node, name string, meaning ast.SymbolFlags, nameNotFoundMessage *diagnostics.Message, isUse bool, excludeGlobals bool) *ast.Symbol {
|
||||
var result *ast.Symbol
|
||||
var lastLocation *ast.Node
|
||||
var lastSelfReferenceLocation *ast.Node
|
||||
var propertyWithInvalidInitializer *ast.Node
|
||||
var associatedDeclarationForContainingInitializerOrBindingName *ast.Node
|
||||
var withinDeferredContext bool
|
||||
var grandparent *ast.Node
|
||||
originalLocation := location // needed for did-you-mean error reporting, which gathers candidates starting from the original location
|
||||
nameIsConst := name == "const"
|
||||
loop:
|
||||
for location != nil {
|
||||
if nameIsConst && ast.IsConstAssertion(location) {
|
||||
// `const` in an `as const` has no symbol, but issues no error because there is no *actual* lookup of the type
|
||||
// (it refers to the constant type of the expression instead)
|
||||
return nil
|
||||
}
|
||||
if ast.IsModuleOrEnumDeclaration(location) && lastLocation != nil && location.Name() == lastLocation {
|
||||
// If lastLocation is the name of a namespace or enum, skip the parent since it will have is own locals that could
|
||||
// conflict.
|
||||
lastLocation = location
|
||||
location = location.Parent
|
||||
}
|
||||
locals := location.Locals()
|
||||
// Locals of a source file are not in scope (because they get merged into the global symbol table)
|
||||
if locals != nil && !ast.IsGlobalSourceFile(location) {
|
||||
result = r.lookup(locals, name, meaning)
|
||||
if result != nil {
|
||||
useResult := true
|
||||
if ast.IsFunctionLike(location) && lastLocation != nil && lastLocation != location.Body() {
|
||||
// symbol lookup restrictions for function-like declarations
|
||||
// - Type parameters of a function are in scope in the entire function declaration, including the parameter
|
||||
// list and return type. However, local types are only in scope in the function body.
|
||||
// - parameters are only in the scope of function body
|
||||
if meaning&result.Flags&ast.SymbolFlagsType != 0 {
|
||||
useResult = result.Flags&ast.SymbolFlagsTypeParameter != 0 && (lastLocation == location.Type() || ast.IsParameterLike(lastLocation))
|
||||
}
|
||||
if meaning&result.Flags&ast.SymbolFlagsVariable != 0 {
|
||||
// expression inside parameter will lookup as normal variable scope when targeting es2015+
|
||||
if r.useOuterVariableScopeInParameter(result, location, lastLocation) {
|
||||
useResult = false
|
||||
} else if result.Flags&ast.SymbolFlagsFunctionScopedVariable != 0 {
|
||||
// parameters are visible only inside function body, parameter list and return type
|
||||
// technically for parameter list case here we might mix parameters and variables declared in function,
|
||||
// however it is detected separately when checking initializers of parameters
|
||||
// to make sure that they reference no variables declared after them.
|
||||
useResult = lastLocation.Kind == ast.KindParameter ||
|
||||
lastLocation.Flags&ast.NodeFlagsSynthesized != 0 ||
|
||||
lastLocation == location.Type() && ast.FindAncestor(result.ValueDeclaration, ast.IsParameter) != nil
|
||||
}
|
||||
}
|
||||
} else if location.Kind == ast.KindConditionalType {
|
||||
// A type parameter declared using 'infer T' in a conditional type is visible only in
|
||||
// the true branch of the conditional type.
|
||||
useResult = lastLocation == location.AsConditionalTypeNode().TrueType
|
||||
}
|
||||
if useResult {
|
||||
break loop
|
||||
}
|
||||
result = nil
|
||||
}
|
||||
}
|
||||
withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation)
|
||||
switch location.Kind {
|
||||
case ast.KindSourceFile:
|
||||
if !ast.IsExternalOrCommonJSModule(location.AsSourceFile()) {
|
||||
break
|
||||
}
|
||||
fallthrough
|
||||
case ast.KindModuleDeclaration:
|
||||
moduleExports := r.getSymbolOfDeclaration(location).Exports
|
||||
if ast.IsSourceFile(location) || (ast.IsModuleDeclaration(location) && location.Flags&ast.NodeFlagsAmbient != 0 && !ast.IsGlobalScopeAugmentation(location)) {
|
||||
// It's an external module. First see if the module has an export default and if the local
|
||||
// name of that export default matches.
|
||||
result = moduleExports[ast.InternalSymbolNameDefault]
|
||||
if result != nil {
|
||||
localSymbol := GetLocalSymbolForExportDefault(result)
|
||||
if localSymbol != nil && result.Flags&meaning != 0 && localSymbol.Name == name {
|
||||
break loop
|
||||
}
|
||||
result = nil
|
||||
}
|
||||
// Because of module/namespace merging, a module's exports are in scope,
|
||||
// yet we never want to treat an export specifier as putting a member in scope.
|
||||
// Therefore, if the name we find is purely an export specifier, it is not actually considered in scope.
|
||||
// Two things to note about this:
|
||||
// 1. We have to check this without calling getSymbol. The problem with calling getSymbol
|
||||
// on an export specifier is that it might find the export specifier itself, and try to
|
||||
// resolve it as an alias. This will cause the checker to consider the export specifier
|
||||
// a circular alias reference when it might not be.
|
||||
// 2. We check === SymbolFlags.Alias in order to check that the symbol is *purely*
|
||||
// an alias. If we used &, we'd be throwing out symbols that have non alias aspects,
|
||||
// which is not the desired behavior.
|
||||
moduleExport := moduleExports[name]
|
||||
if moduleExport != nil && moduleExport.Flags == ast.SymbolFlagsAlias && (ast.GetDeclarationOfKind(moduleExport, ast.KindExportSpecifier) != nil || ast.GetDeclarationOfKind(moduleExport, ast.KindNamespaceExport) != nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
if name != ast.InternalSymbolNameDefault {
|
||||
result = r.lookup(moduleExports, name, meaning&ast.SymbolFlagsModuleMember)
|
||||
if result != nil {
|
||||
break loop
|
||||
}
|
||||
}
|
||||
case ast.KindEnumDeclaration:
|
||||
result = r.lookup(r.getSymbolOfDeclaration(location).Exports, name, meaning&ast.SymbolFlagsEnumMember)
|
||||
if result != nil {
|
||||
if nameNotFoundMessage != nil && r.CompilerOptions.GetIsolatedModules() && location.Flags&ast.NodeFlagsAmbient == 0 && ast.GetSourceFileOfNode(location) != ast.GetSourceFileOfNode(result.ValueDeclaration) {
|
||||
isolatedModulesLikeFlagName := core.IfElse(r.CompilerOptions.VerbatimModuleSyntax == core.TSTrue, "verbatimModuleSyntax", "isolatedModules")
|
||||
r.error(originalLocation, diagnostics.Cannot_access_0_from_another_file_without_qualification_when_1_is_enabled_Use_2_instead,
|
||||
name, isolatedModulesLikeFlagName, r.getSymbolOfDeclaration(location).Name+"."+name)
|
||||
}
|
||||
break loop
|
||||
}
|
||||
case ast.KindPropertyDeclaration:
|
||||
if !ast.IsStatic(location) {
|
||||
ctor := ast.FindConstructorDeclaration(location.Parent)
|
||||
if ctor != nil && ctor.Locals() != nil {
|
||||
if r.lookup(ctor.Locals(), name, meaning&ast.SymbolFlagsValue) != nil {
|
||||
// Remember the property node, it will be used later to report appropriate error
|
||||
propertyWithInvalidInitializer = location
|
||||
}
|
||||
}
|
||||
}
|
||||
case ast.KindClassDeclaration, ast.KindClassExpression, ast.KindInterfaceDeclaration:
|
||||
result = r.lookup(r.getSymbolOfDeclaration(location).Members, name, meaning&ast.SymbolFlagsType)
|
||||
if result != nil {
|
||||
if !isTypeParameterSymbolDeclaredInContainer(result, location) {
|
||||
// ignore type parameters not declared in this container
|
||||
result = nil
|
||||
break
|
||||
}
|
||||
if lastLocation != nil && ast.IsStatic(lastLocation) {
|
||||
// TypeScript 1.0 spec (April 2014): 3.4.1
|
||||
// The scope of a type parameter extends over the entire declaration with which the type
|
||||
// parameter list is associated, with the exception of static member declarations in classes.
|
||||
if nameNotFoundMessage != nil {
|
||||
r.error(originalLocation, diagnostics.Static_members_cannot_reference_class_type_parameters)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
break loop
|
||||
}
|
||||
if ast.IsClassExpression(location) && meaning&ast.SymbolFlagsClass != 0 {
|
||||
className := location.Name()
|
||||
if className != nil && name == className.Text() {
|
||||
result = location.Symbol()
|
||||
break loop
|
||||
}
|
||||
}
|
||||
case ast.KindExpressionWithTypeArguments:
|
||||
if lastLocation == location.AsExpressionWithTypeArguments().Expression && ast.IsHeritageClause(location.Parent) && location.Parent.AsHeritageClause().Token == ast.KindExtendsKeyword {
|
||||
container := location.Parent.Parent
|
||||
if ast.IsClassLike(container) {
|
||||
result = r.lookup(r.getSymbolOfDeclaration(container).Members, name, meaning&ast.SymbolFlagsType)
|
||||
if result != nil {
|
||||
if nameNotFoundMessage != nil {
|
||||
r.error(originalLocation, diagnostics.Base_class_expressions_cannot_reference_class_type_parameters)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
// It is not legal to reference a class's own type parameters from a computed property name that
|
||||
// belongs to the class. For example:
|
||||
//
|
||||
// function foo<T>() { return '' }
|
||||
// class C<T> { // <-- Class's own type parameter T
|
||||
// [foo<T>()]() { } // <-- Reference to T from class's own computed property
|
||||
// }
|
||||
case ast.KindComputedPropertyName:
|
||||
grandparent = location.Parent.Parent
|
||||
if ast.IsClassLike(grandparent) || ast.IsInterfaceDeclaration(grandparent) {
|
||||
// A reference to this grandparent's type parameters would be an error
|
||||
result = r.lookup(r.getSymbolOfDeclaration(grandparent).Members, name, meaning&ast.SymbolFlagsType)
|
||||
if result != nil {
|
||||
if nameNotFoundMessage != nil {
|
||||
r.error(originalLocation, diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
case ast.KindArrowFunction:
|
||||
// when targeting ES6 or higher there is no 'arguments' in an arrow function
|
||||
// for lower compile targets the resolved symbol is used to emit an error
|
||||
if r.CompilerOptions.GetEmitScriptTarget() >= core.ScriptTargetES2015 {
|
||||
break
|
||||
}
|
||||
fallthrough
|
||||
case ast.KindMethodDeclaration, ast.KindConstructor, ast.KindGetAccessor, ast.KindSetAccessor, ast.KindFunctionDeclaration:
|
||||
if meaning&ast.SymbolFlagsVariable != 0 && name == "arguments" {
|
||||
result = r.argumentsSymbol()
|
||||
break loop
|
||||
}
|
||||
case ast.KindFunctionExpression:
|
||||
if meaning&ast.SymbolFlagsVariable != 0 && name == "arguments" {
|
||||
result = r.argumentsSymbol()
|
||||
break loop
|
||||
}
|
||||
if meaning&ast.SymbolFlagsFunction != 0 {
|
||||
functionName := location.AsFunctionExpression().Name()
|
||||
if functionName != nil && name == functionName.AsIdentifier().Text {
|
||||
result = location.AsFunctionExpression().Symbol
|
||||
break loop
|
||||
}
|
||||
}
|
||||
case ast.KindDecorator:
|
||||
// Decorators are resolved at the class declaration. Resolving at the parameter
|
||||
// or member would result in looking up locals in the method.
|
||||
//
|
||||
// function y() {}
|
||||
// class C {
|
||||
// method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter.
|
||||
// }
|
||||
//
|
||||
if location.Parent != nil && location.Parent.Kind == ast.KindParameter {
|
||||
location = location.Parent
|
||||
}
|
||||
// function y() {}
|
||||
// class C {
|
||||
// @y method(x, y) {} // <-- decorator y should be resolved at the class declaration, not the method.
|
||||
// }
|
||||
//
|
||||
// class Decorators are resolved outside of the class to avoid referencing type parameters of that class.
|
||||
//
|
||||
// type T = number;
|
||||
// declare function y(x: T): any;
|
||||
// @param(1 as T) // <-- T should resolve to the type alias outside of class C
|
||||
// class C<T> {}
|
||||
if location.Parent != nil && (ast.IsClassElement(location.Parent) || location.Parent.Kind == ast.KindClassDeclaration) {
|
||||
location = location.Parent
|
||||
}
|
||||
case ast.KindParameter:
|
||||
parameterDeclaration := location.AsParameterDeclaration()
|
||||
if lastLocation != nil && (lastLocation == parameterDeclaration.Initializer ||
|
||||
lastLocation == parameterDeclaration.Name() && ast.IsBindingPattern(lastLocation)) {
|
||||
if associatedDeclarationForContainingInitializerOrBindingName == nil {
|
||||
associatedDeclarationForContainingInitializerOrBindingName = location
|
||||
}
|
||||
}
|
||||
case ast.KindBindingElement:
|
||||
bindingElement := location.AsBindingElement()
|
||||
if lastLocation != nil && (lastLocation == bindingElement.Initializer ||
|
||||
lastLocation == bindingElement.Name() && ast.IsBindingPattern(lastLocation)) {
|
||||
if ast.IsPartOfParameterDeclaration(location) && associatedDeclarationForContainingInitializerOrBindingName == nil {
|
||||
associatedDeclarationForContainingInitializerOrBindingName = location
|
||||
}
|
||||
}
|
||||
case ast.KindInferType:
|
||||
if meaning&ast.SymbolFlagsTypeParameter != 0 {
|
||||
parameterName := location.AsInferTypeNode().TypeParameter.AsTypeParameter().Name()
|
||||
if parameterName != nil && name == parameterName.AsIdentifier().Text {
|
||||
result = location.AsInferTypeNode().TypeParameter.AsTypeParameter().Symbol
|
||||
break loop
|
||||
}
|
||||
}
|
||||
case ast.KindExportSpecifier:
|
||||
exportSpecifier := location.AsExportSpecifier()
|
||||
if lastLocation != nil && lastLocation == exportSpecifier.PropertyName && location.Parent.Parent.AsExportDeclaration().ModuleSpecifier != nil {
|
||||
location = location.Parent.Parent.Parent
|
||||
}
|
||||
}
|
||||
if isSelfReferenceLocation(location, lastLocation) {
|
||||
lastSelfReferenceLocation = location
|
||||
}
|
||||
lastLocation = location
|
||||
location = location.Parent
|
||||
}
|
||||
// We just climbed up parents looking for the name, meaning that we started in a descendant node of `lastLocation`.
|
||||
// If `result === lastSelfReferenceLocation.symbol`, that means that we are somewhere inside `lastSelfReferenceLocation` looking up a name, and resolving to `lastLocation` itself.
|
||||
// That means that this is a self-reference of `lastLocation`, and shouldn't count this when considering whether `lastLocation` is used.
|
||||
if isUse && result != nil && (lastSelfReferenceLocation == nil || result != lastSelfReferenceLocation.Symbol()) {
|
||||
if r.SymbolReferenced != nil {
|
||||
r.SymbolReferenced(result, meaning)
|
||||
}
|
||||
}
|
||||
if result == nil {
|
||||
if lastLocation != nil &&
|
||||
lastLocation.Kind == ast.KindSourceFile &&
|
||||
lastLocation.AsSourceFile().CommonJSModuleIndicator != nil &&
|
||||
name == "exports" &&
|
||||
meaning&lastLocation.Symbol().Flags != 0 {
|
||||
return lastLocation.Symbol()
|
||||
}
|
||||
if lastLocation != nil &&
|
||||
r.GetModuleSymbol != nil &&
|
||||
lastLocation.Kind == ast.KindSourceFile &&
|
||||
lastLocation.AsSourceFile().CommonJSModuleIndicator != nil &&
|
||||
name == "module" &&
|
||||
originalLocation.Parent != nil &&
|
||||
ast.IsModuleExportsAccessExpression(originalLocation.Parent) &&
|
||||
meaning&lastLocation.Symbol().Flags != 0 {
|
||||
return r.GetModuleSymbol(lastLocation)
|
||||
}
|
||||
if !excludeGlobals {
|
||||
result = r.lookup(r.Globals, name, meaning|ast.SymbolFlagsGlobalLookup)
|
||||
}
|
||||
}
|
||||
if result == nil {
|
||||
if originalLocation != nil && ast.IsInJSFile(originalLocation) && originalLocation.Parent != nil {
|
||||
if ast.IsRequireCall(originalLocation.Parent, false /*requireStringLiteralLikeArgument*/) {
|
||||
return r.RequireSymbol
|
||||
}
|
||||
}
|
||||
}
|
||||
if nameNotFoundMessage != nil {
|
||||
if propertyWithInvalidInitializer != nil && r.OnPropertyWithInvalidInitializer != nil && r.OnPropertyWithInvalidInitializer(originalLocation, name, propertyWithInvalidInitializer, result) {
|
||||
return nil
|
||||
}
|
||||
if result == nil {
|
||||
if r.OnFailedToResolveSymbol != nil {
|
||||
r.OnFailedToResolveSymbol(originalLocation, name, meaning, nameNotFoundMessage)
|
||||
}
|
||||
} else {
|
||||
if r.OnSuccessfullyResolvedSymbol != nil {
|
||||
r.OnSuccessfullyResolvedSymbol(originalLocation, result, meaning, lastLocation, associatedDeclarationForContainingInitializerOrBindingName, withinDeferredContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (r *NameResolver) useOuterVariableScopeInParameter(result *ast.Symbol, location *ast.Node, lastLocation *ast.Node) bool {
|
||||
if ast.IsParameter(lastLocation) {
|
||||
body := location.Body()
|
||||
if body != nil && result.ValueDeclaration != nil && result.ValueDeclaration.Pos() >= body.Pos() && result.ValueDeclaration.End() <= body.End() {
|
||||
// check for several cases where we introduce temporaries that require moving the name/initializer of the parameter to the body
|
||||
// - static field in a class expression
|
||||
// - optional chaining pre-es2020
|
||||
// - nullish coalesce pre-es2020
|
||||
// - spread assignment in binding pattern pre-es2017
|
||||
target := r.CompilerOptions.GetEmitScriptTarget()
|
||||
if target >= core.ScriptTargetES2015 {
|
||||
functionLocation := location
|
||||
declarationRequiresScopeChange := core.TSUnknown
|
||||
if r.GetRequiresScopeChangeCache != nil {
|
||||
declarationRequiresScopeChange = r.GetRequiresScopeChangeCache(functionLocation)
|
||||
}
|
||||
if declarationRequiresScopeChange == core.TSUnknown {
|
||||
declarationRequiresScopeChange = core.IfElse(core.Some(functionLocation.Parameters(), r.requiresScopeChange), core.TSTrue, core.TSFalse)
|
||||
if r.SetRequiresScopeChangeCache != nil {
|
||||
r.SetRequiresScopeChangeCache(functionLocation, declarationRequiresScopeChange)
|
||||
}
|
||||
}
|
||||
return declarationRequiresScopeChange != core.TSTrue
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (r *NameResolver) requiresScopeChange(node *ast.Node) bool {
|
||||
d := node.AsParameterDeclaration()
|
||||
return r.requiresScopeChangeWorker(d.Name()) || d.Initializer != nil && r.requiresScopeChangeWorker(d.Initializer)
|
||||
}
|
||||
|
||||
func (r *NameResolver) requiresScopeChangeWorker(node *ast.Node) bool {
|
||||
switch node.Kind {
|
||||
case ast.KindArrowFunction, ast.KindFunctionExpression, ast.KindFunctionDeclaration, ast.KindConstructor:
|
||||
return false
|
||||
case ast.KindMethodDeclaration, ast.KindGetAccessor, ast.KindSetAccessor, ast.KindPropertyAssignment:
|
||||
return r.requiresScopeChangeWorker(node.Name())
|
||||
case ast.KindPropertyDeclaration:
|
||||
if ast.HasStaticModifier(node) {
|
||||
return !r.CompilerOptions.GetEmitStandardClassFields()
|
||||
}
|
||||
return r.requiresScopeChangeWorker(node.AsPropertyDeclaration().Name())
|
||||
default:
|
||||
if ast.IsNullishCoalesce(node) || ast.IsOptionalChain(node) {
|
||||
return r.CompilerOptions.GetEmitScriptTarget() < core.ScriptTargetES2020
|
||||
}
|
||||
if ast.IsBindingElement(node) && node.AsBindingElement().DotDotDotToken != nil && ast.IsObjectBindingPattern(node.Parent) {
|
||||
return r.CompilerOptions.GetEmitScriptTarget() < core.ScriptTargetES2017
|
||||
}
|
||||
if ast.IsTypeNode(node) {
|
||||
return false
|
||||
}
|
||||
return node.ForEachChild(r.requiresScopeChangeWorker)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *NameResolver) error(location *ast.Node, message *diagnostics.Message, args ...any) {
|
||||
if r.Error != nil {
|
||||
r.Error(location, message, args...)
|
||||
}
|
||||
// Default implementation does not report errors
|
||||
}
|
||||
|
||||
func (r *NameResolver) getSymbolOfDeclaration(node *ast.Node) *ast.Symbol {
|
||||
if r.GetSymbolOfDeclaration != nil {
|
||||
return r.GetSymbolOfDeclaration(node)
|
||||
}
|
||||
|
||||
// Default implementation does not support merged symbols
|
||||
return node.Symbol()
|
||||
}
|
||||
|
||||
func (r *NameResolver) lookup(symbols ast.SymbolTable, name string, meaning ast.SymbolFlags) *ast.Symbol {
|
||||
if r.Lookup != nil {
|
||||
return r.Lookup(symbols, name, meaning)
|
||||
}
|
||||
// Default implementation does not support following aliases or merged symbols
|
||||
if meaning != 0 {
|
||||
symbol := symbols[name]
|
||||
if symbol != nil {
|
||||
if symbol.Flags&meaning != 0 {
|
||||
return symbol
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *NameResolver) argumentsSymbol() *ast.Symbol {
|
||||
if r.ArgumentsSymbol == nil {
|
||||
// Default implementation synthesizes a transient symbol for `arguments`
|
||||
r.ArgumentsSymbol = &ast.Symbol{Name: "arguments", Flags: ast.SymbolFlagsProperty | ast.SymbolFlagsTransient}
|
||||
}
|
||||
return r.ArgumentsSymbol
|
||||
}
|
||||
|
||||
func GetLocalSymbolForExportDefault(symbol *ast.Symbol) *ast.Symbol {
|
||||
if !isExportDefaultSymbol(symbol) || len(symbol.Declarations) == 0 {
|
||||
return nil
|
||||
}
|
||||
for _, decl := range symbol.Declarations {
|
||||
localSymbol := decl.LocalSymbol()
|
||||
if localSymbol != nil {
|
||||
return localSymbol
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func isExportDefaultSymbol(symbol *ast.Symbol) bool {
|
||||
return symbol != nil && len(symbol.Declarations) > 0 && ast.HasSyntacticModifier(symbol.Declarations[0], ast.ModifierFlagsDefault)
|
||||
}
|
||||
|
||||
func getIsDeferredContext(location *ast.Node, lastLocation *ast.Node) bool {
|
||||
if location.Kind != ast.KindArrowFunction && location.Kind != ast.KindFunctionExpression {
|
||||
// initializers in instance property declaration of class like entities are executed in constructor and thus deferred
|
||||
// A name is evaluated within the enclosing scope - so it shouldn't count as deferred
|
||||
return ast.IsTypeQueryNode(location) ||
|
||||
(ast.IsFunctionLikeDeclaration(location) || location.Kind == ast.KindPropertyDeclaration && !ast.IsStatic(location)) &&
|
||||
(lastLocation == nil || lastLocation != location.Name())
|
||||
}
|
||||
if lastLocation != nil && lastLocation == location.Name() {
|
||||
return false
|
||||
}
|
||||
// generator functions and async functions are not inlined in control flow when immediately invoked
|
||||
if location.BodyData().AsteriskToken != nil || ast.HasSyntacticModifier(location, ast.ModifierFlagsAsync) {
|
||||
return true
|
||||
}
|
||||
return ast.GetImmediatelyInvokedFunctionExpression(location) == nil
|
||||
}
|
||||
|
||||
func isTypeParameterSymbolDeclaredInContainer(symbol *ast.Symbol, container *ast.Node) bool {
|
||||
for _, decl := range symbol.Declarations {
|
||||
if decl.Kind == ast.KindTypeParameter {
|
||||
parent := decl.Parent
|
||||
if parent == container {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isSelfReferenceLocation(node *ast.Node, lastLocation *ast.Node) bool {
|
||||
switch node.Kind {
|
||||
case ast.KindParameter:
|
||||
return lastLocation != nil && lastLocation == node.Name()
|
||||
case ast.KindFunctionDeclaration, ast.KindClassDeclaration, ast.KindInterfaceDeclaration, ast.KindEnumDeclaration,
|
||||
ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration, ast.KindModuleDeclaration: // For `namespace N { N; }`
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
251
kitcom/internal/tsgo/binder/referenceresolver.go
Normal file
251
kitcom/internal/tsgo/binder/referenceresolver.go
Normal file
@ -0,0 +1,251 @@
|
||||
package binder
|
||||
|
||||
import (
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/diagnostics"
|
||||
)
|
||||
|
||||
type ReferenceResolver interface {
|
||||
GetReferencedExportContainer(node *ast.IdentifierNode, prefixLocals bool) *ast.Node
|
||||
GetReferencedImportDeclaration(node *ast.IdentifierNode) *ast.Declaration
|
||||
GetReferencedValueDeclaration(node *ast.IdentifierNode) *ast.Declaration
|
||||
GetReferencedValueDeclarations(node *ast.IdentifierNode) []*ast.Declaration
|
||||
GetElementAccessExpressionName(expression *ast.ElementAccessExpression) string
|
||||
}
|
||||
|
||||
type ReferenceResolverHooks struct {
|
||||
ResolveName func(location *ast.Node, name string, meaning ast.SymbolFlags, nameNotFoundMessage *diagnostics.Message, isUse bool, excludeGlobals bool) *ast.Symbol
|
||||
GetResolvedSymbol func(*ast.Node) *ast.Symbol
|
||||
GetMergedSymbol func(*ast.Symbol) *ast.Symbol
|
||||
GetParentOfSymbol func(*ast.Symbol) *ast.Symbol
|
||||
GetSymbolOfDeclaration func(*ast.Declaration) *ast.Symbol
|
||||
GetTypeOnlyAliasDeclaration func(symbol *ast.Symbol, include ast.SymbolFlags) *ast.Declaration
|
||||
GetExportSymbolOfValueSymbolIfExported func(*ast.Symbol) *ast.Symbol
|
||||
GetElementAccessExpressionName func(*ast.ElementAccessExpression) (string, bool)
|
||||
}
|
||||
|
||||
var _ ReferenceResolver = &referenceResolver{}
|
||||
|
||||
type referenceResolver struct {
|
||||
resolver *NameResolver
|
||||
options *core.CompilerOptions
|
||||
hooks ReferenceResolverHooks
|
||||
}
|
||||
|
||||
func NewReferenceResolver(options *core.CompilerOptions, hooks ReferenceResolverHooks) ReferenceResolver {
|
||||
return &referenceResolver{
|
||||
options: options,
|
||||
hooks: hooks,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *referenceResolver) getResolvedSymbol(node *ast.Node) *ast.Symbol {
|
||||
if node != nil {
|
||||
if r.hooks.GetResolvedSymbol != nil {
|
||||
return r.hooks.GetResolvedSymbol(node)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *referenceResolver) getMergedSymbol(symbol *ast.Symbol) *ast.Symbol {
|
||||
if symbol != nil {
|
||||
if r.hooks.GetMergedSymbol != nil {
|
||||
return r.hooks.GetMergedSymbol(symbol)
|
||||
}
|
||||
return symbol
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *referenceResolver) getParentOfSymbol(symbol *ast.Symbol) *ast.Symbol {
|
||||
if symbol != nil {
|
||||
if r.hooks.GetParentOfSymbol != nil {
|
||||
return r.hooks.GetParentOfSymbol(symbol)
|
||||
}
|
||||
return symbol.Parent
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *referenceResolver) getSymbolOfDeclaration(declaration *ast.Declaration) *ast.Symbol {
|
||||
if declaration != nil {
|
||||
if r.hooks.GetSymbolOfDeclaration != nil {
|
||||
return r.hooks.GetSymbolOfDeclaration(declaration)
|
||||
}
|
||||
return declaration.Symbol()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *referenceResolver) getReferencedValueSymbol(reference *ast.IdentifierNode, startInDeclarationContainer bool) *ast.Symbol {
|
||||
resolvedSymbol := r.getResolvedSymbol(reference)
|
||||
if resolvedSymbol != nil {
|
||||
return resolvedSymbol
|
||||
}
|
||||
|
||||
location := reference
|
||||
if startInDeclarationContainer && reference.Parent != nil && ast.IsDeclaration(reference.Parent) && reference.Parent.Name() == reference {
|
||||
location = ast.GetDeclarationContainer(reference.Parent)
|
||||
}
|
||||
|
||||
if r.hooks.ResolveName != nil {
|
||||
return r.hooks.ResolveName(location, reference.Text(), ast.SymbolFlagsExportValue|ast.SymbolFlagsValue|ast.SymbolFlagsAlias, nil /*nameNotFoundMessage*/, false /*isUse*/, false /*excludeGlobals*/)
|
||||
}
|
||||
|
||||
if r.resolver == nil {
|
||||
r.resolver = &NameResolver{
|
||||
CompilerOptions: r.options,
|
||||
}
|
||||
}
|
||||
|
||||
return r.resolver.Resolve(location, reference.Text(), ast.SymbolFlagsExportValue|ast.SymbolFlagsValue|ast.SymbolFlagsAlias, nil /*nameNotFoundMessage*/, false /*isUse*/, false /*excludeGlobals*/)
|
||||
}
|
||||
|
||||
func (r *referenceResolver) isTypeOnlyAliasDeclaration(symbol *ast.Symbol) bool {
|
||||
if symbol != nil {
|
||||
if r.hooks.GetTypeOnlyAliasDeclaration != nil {
|
||||
return r.hooks.GetTypeOnlyAliasDeclaration(symbol, ast.SymbolFlagsValue) != nil
|
||||
}
|
||||
|
||||
node := r.getDeclarationOfAliasSymbol(symbol)
|
||||
for node != nil {
|
||||
switch node.Kind {
|
||||
case ast.KindImportEqualsDeclaration, ast.KindExportDeclaration:
|
||||
return node.IsTypeOnly()
|
||||
case ast.KindImportClause, ast.KindImportSpecifier, ast.KindExportSpecifier:
|
||||
if node.IsTypeOnly() {
|
||||
return true
|
||||
}
|
||||
node = node.Parent
|
||||
continue
|
||||
case ast.KindNamedImports, ast.KindNamedExports:
|
||||
node = node.Parent
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (r *referenceResolver) getDeclarationOfAliasSymbol(symbol *ast.Symbol) *ast.Declaration {
|
||||
return core.FindLast(symbol.Declarations, ast.IsAliasSymbolDeclaration)
|
||||
}
|
||||
|
||||
func (r *referenceResolver) getExportSymbolOfValueSymbolIfExported(symbol *ast.Symbol) *ast.Symbol {
|
||||
if symbol != nil {
|
||||
if r.hooks.GetExportSymbolOfValueSymbolIfExported != nil {
|
||||
return r.hooks.GetExportSymbolOfValueSymbolIfExported(symbol)
|
||||
}
|
||||
if symbol.Flags&ast.SymbolFlagsExportValue != 0 && symbol.ExportSymbol != nil {
|
||||
symbol = symbol.ExportSymbol
|
||||
}
|
||||
return r.getMergedSymbol(symbol)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *referenceResolver) GetReferencedExportContainer(node *ast.IdentifierNode, prefixLocals bool) *ast.Node /*SourceFile|ModuleDeclaration|EnumDeclaration*/ {
|
||||
// When resolving the export for the name of a module or enum
|
||||
// declaration, we need to start resolution at the declaration's container.
|
||||
// Otherwise, we could incorrectly resolve the export as the
|
||||
// declaration if it contains an exported member with the same name.
|
||||
startInDeclarationContainer := node.Parent != nil && (node.Parent.Kind == ast.KindModuleDeclaration || node.Parent.Kind == ast.KindEnumDeclaration) && node == node.Parent.Name()
|
||||
if symbol := r.getReferencedValueSymbol(node, startInDeclarationContainer); symbol != nil {
|
||||
if symbol.Flags&ast.SymbolFlagsExportValue != 0 {
|
||||
// If we reference an exported entity within the same module declaration, then whether
|
||||
// we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the
|
||||
// kinds that we do NOT prefix.
|
||||
exportSymbol := r.getMergedSymbol(symbol.ExportSymbol)
|
||||
if !prefixLocals && exportSymbol.Flags&ast.SymbolFlagsExportHasLocal != 0 && exportSymbol.Flags&ast.SymbolFlagsVariable == 0 {
|
||||
return nil
|
||||
}
|
||||
symbol = exportSymbol
|
||||
}
|
||||
parentSymbol := r.getParentOfSymbol(symbol)
|
||||
if parentSymbol != nil {
|
||||
if parentSymbol.Flags&ast.SymbolFlagsValueModule != 0 && parentSymbol.ValueDeclaration != nil && parentSymbol.ValueDeclaration.Kind == ast.KindSourceFile {
|
||||
symbolFile := parentSymbol.ValueDeclaration.AsSourceFile()
|
||||
referenceFile := ast.GetSourceFileOfNode(node)
|
||||
// If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return nil.
|
||||
symbolIsUmdExport := symbolFile != referenceFile
|
||||
if symbolIsUmdExport {
|
||||
return nil
|
||||
}
|
||||
return symbolFile.AsNode()
|
||||
}
|
||||
isMatchingContainer := func(n *ast.Node) bool {
|
||||
return (n.Kind == ast.KindModuleDeclaration || n.Kind == ast.KindEnumDeclaration) && r.getSymbolOfDeclaration(n) == parentSymbol
|
||||
}
|
||||
if container := ast.FindAncestor(symbol.ValueDeclaration, isMatchingContainer); container != nil {
|
||||
return container
|
||||
}
|
||||
return ast.FindAncestor(node.Parent, isMatchingContainer)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *referenceResolver) GetReferencedImportDeclaration(node *ast.IdentifierNode) *ast.Declaration {
|
||||
if symbol := r.getReferencedValueSymbol(node, false /*startInDeclarationContainer*/); symbol != nil {
|
||||
// We should only get the declaration of an alias if there isn't a local value
|
||||
// declaration for the symbol
|
||||
if ast.IsNonLocalAlias(symbol, ast.SymbolFlagsValue /*excludes*/) && !r.isTypeOnlyAliasDeclaration(symbol) {
|
||||
return r.getDeclarationOfAliasSymbol(symbol)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *referenceResolver) GetReferencedValueDeclaration(node *ast.IdentifierNode) *ast.Declaration {
|
||||
if symbol := r.getReferencedValueSymbol(node, false /*startInDeclarationContainer*/); symbol != nil {
|
||||
return r.getExportSymbolOfValueSymbolIfExported(symbol).ValueDeclaration
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *referenceResolver) GetReferencedValueDeclarations(node *ast.IdentifierNode) []*ast.Declaration {
|
||||
var declarations []*ast.Declaration
|
||||
if symbol := r.getReferencedValueSymbol(node, false /*startInDeclarationContainer*/); symbol != nil {
|
||||
symbol = r.getExportSymbolOfValueSymbolIfExported(symbol)
|
||||
for _, declaration := range symbol.Declarations {
|
||||
switch declaration.Kind {
|
||||
case ast.KindVariableDeclaration,
|
||||
ast.KindParameter,
|
||||
ast.KindBindingElement,
|
||||
ast.KindPropertyDeclaration,
|
||||
ast.KindPropertyAssignment,
|
||||
ast.KindShorthandPropertyAssignment,
|
||||
ast.KindEnumMember,
|
||||
ast.KindObjectLiteralExpression,
|
||||
ast.KindFunctionDeclaration,
|
||||
ast.KindFunctionExpression,
|
||||
ast.KindArrowFunction,
|
||||
ast.KindClassDeclaration,
|
||||
ast.KindClassExpression,
|
||||
ast.KindEnumDeclaration,
|
||||
ast.KindMethodDeclaration,
|
||||
ast.KindGetAccessor,
|
||||
ast.KindSetAccessor,
|
||||
ast.KindModuleDeclaration:
|
||||
declarations = append(declarations, declaration)
|
||||
}
|
||||
}
|
||||
}
|
||||
return declarations
|
||||
}
|
||||
|
||||
func (r *referenceResolver) GetElementAccessExpressionName(expression *ast.ElementAccessExpression) string {
|
||||
if expression != nil {
|
||||
if r.hooks.GetElementAccessExpressionName != nil {
|
||||
if name, ok := r.hooks.GetElementAccessExpressionName(expression); ok {
|
||||
return name
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
53
kitcom/internal/tsgo/bundled/bundled.go
Normal file
53
kitcom/internal/tsgo/bundled/bundled.go
Normal file
@ -0,0 +1,53 @@
|
||||
// Package bundled provides access to files bundled with TypeScript.
|
||||
package bundled
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/vfs"
|
||||
)
|
||||
|
||||
//go:generate go run generate.go
|
||||
|
||||
// Define the below here to consolidate documentation.
|
||||
|
||||
// Embedded is true if the bundled files are implemented through an embedded FS.
|
||||
const Embedded = embedded
|
||||
|
||||
// WrapFS returns an FS which redirects embedded paths to the embedded file system.
|
||||
// If the embedded file system is not available, it returns the original FS.
|
||||
func WrapFS(fs vfs.FS) vfs.FS {
|
||||
return wrapFS(fs)
|
||||
}
|
||||
|
||||
// LibPath returns the path to the directory containing the bundled lib.d.ts files.
|
||||
// If embedding is not enabled, this is a path on disk, and must be accessed through
|
||||
// a real OS filesystem.
|
||||
func LibPath() string {
|
||||
return libPath()
|
||||
}
|
||||
|
||||
var bundledSourceDir = sync.OnceValue(func() string {
|
||||
_, filename, _, ok := runtime.Caller(0)
|
||||
if !ok {
|
||||
panic("bundled: could not get current filename")
|
||||
}
|
||||
return filepath.Dir(filepath.FromSlash(filename))
|
||||
})
|
||||
|
||||
var testingLibPath = sync.OnceValue(func() string {
|
||||
if !testing.Testing() {
|
||||
panic("bundled: TestingLibPath should only be called during tests")
|
||||
}
|
||||
return tspath.NormalizeSlashes(filepath.Join(bundledSourceDir(), "libs"))
|
||||
})
|
||||
|
||||
// TestingLibPath returns the path to the source bundled libs directory.
|
||||
// It's only valid to use in tests where the source code is available.
|
||||
func TestingLibPath() string {
|
||||
return testingLibPath()
|
||||
}
|
||||
48
kitcom/internal/tsgo/bundled/bundled_test.go
Normal file
48
kitcom/internal/tsgo/bundled/bundled_test.go
Normal file
@ -0,0 +1,48 @@
|
||||
package bundled_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/bundled"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/vfs"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/vfs/osvfs"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
func TestTestingLibPath(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
p := bundled.TestingLibPath()
|
||||
|
||||
_, err := os.Stat(p)
|
||||
assert.NilError(t, err)
|
||||
|
||||
libdts := filepath.Join(p, "lib.d.ts")
|
||||
|
||||
_, err = os.Stat(libdts)
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
|
||||
func TestEmbeddedLibs(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
fs := bundled.WrapFS(osvfs.FS())
|
||||
|
||||
var files []string
|
||||
|
||||
err := fs.WalkDir(bundled.LibPath(), func(path string, d vfs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !d.IsDir() {
|
||||
files = append(files, tspath.GetBaseFileName(path))
|
||||
}
|
||||
return nil
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
|
||||
assert.DeepEqual(t, files, bundled.LibNames)
|
||||
}
|
||||
212
kitcom/internal/tsgo/bundled/embed.go
Normal file
212
kitcom/internal/tsgo/bundled/embed.go
Normal file
@ -0,0 +1,212 @@
|
||||
//go:build !noembed
|
||||
|
||||
package bundled
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/vfs"
|
||||
)
|
||||
|
||||
const embedded = true
|
||||
|
||||
const scheme = "bundled:///"
|
||||
|
||||
func splitPath(path string) (rest string, ok bool) {
|
||||
return strings.CutPrefix(path, scheme)
|
||||
}
|
||||
|
||||
func libPath() string {
|
||||
return scheme + "libs"
|
||||
}
|
||||
|
||||
// wrappedFS is implemented directly rather than going through [io/fs.FS].
|
||||
// Our vfs.FS works with file contents in terms of strings, and that's
|
||||
// what go:embed does under the hood, but going through fs.FS will cause
|
||||
// copying to []byte and back.
|
||||
|
||||
type wrappedFS struct {
|
||||
fs vfs.FS
|
||||
}
|
||||
|
||||
var _ vfs.FS = (*wrappedFS)(nil)
|
||||
|
||||
func wrapFS(fs vfs.FS) vfs.FS {
|
||||
return &wrappedFS{fs: fs}
|
||||
}
|
||||
|
||||
func (vfs *wrappedFS) UseCaseSensitiveFileNames() bool {
|
||||
return vfs.fs.UseCaseSensitiveFileNames()
|
||||
}
|
||||
|
||||
func (vfs *wrappedFS) FileExists(path string) bool {
|
||||
if rest, ok := splitPath(path); ok {
|
||||
_, ok := embeddedContents[rest]
|
||||
return ok
|
||||
}
|
||||
return vfs.fs.FileExists(path)
|
||||
}
|
||||
|
||||
func (vfs *wrappedFS) ReadFile(path string) (contents string, ok bool) {
|
||||
if rest, ok := splitPath(path); ok {
|
||||
contents, ok = embeddedContents[rest]
|
||||
return contents, ok
|
||||
}
|
||||
return vfs.fs.ReadFile(path)
|
||||
}
|
||||
|
||||
func (vfs *wrappedFS) DirectoryExists(path string) bool {
|
||||
if rest, ok := splitPath(path); ok {
|
||||
return rest == "libs"
|
||||
}
|
||||
return vfs.fs.DirectoryExists(path)
|
||||
}
|
||||
|
||||
func (vfs *wrappedFS) GetAccessibleEntries(path string) (result vfs.Entries) {
|
||||
if rest, ok := splitPath(path); ok {
|
||||
if rest == "" {
|
||||
result.Directories = []string{"libs"}
|
||||
} else if rest == "libs" {
|
||||
result.Files = LibNames
|
||||
}
|
||||
return result
|
||||
}
|
||||
return vfs.fs.GetAccessibleEntries(path)
|
||||
}
|
||||
|
||||
var rootEntries = []fs.DirEntry{
|
||||
fs.FileInfoToDirEntry(&fileInfo{name: "libs", mode: fs.ModeDir}),
|
||||
}
|
||||
|
||||
func (vfs *wrappedFS) Stat(path string) vfs.FileInfo {
|
||||
if rest, ok := splitPath(path); ok {
|
||||
if rest == "" || rest == "libs" {
|
||||
return &fileInfo{name: rest, mode: fs.ModeDir}
|
||||
}
|
||||
if lib, ok := embeddedContents[rest]; ok {
|
||||
libName, _ := strings.CutPrefix(rest, "libs/")
|
||||
return &fileInfo{name: libName, size: int64(len(lib))}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return vfs.fs.Stat(path)
|
||||
}
|
||||
|
||||
func (vfs *wrappedFS) WalkDir(root string, walkFn vfs.WalkDirFunc) error {
|
||||
if rest, ok := splitPath(root); ok {
|
||||
if err := vfs.walkDir(rest, walkFn); err != nil {
|
||||
if err == fs.SkipAll { //nolint:errorlint
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return vfs.fs.WalkDir(root, walkFn)
|
||||
}
|
||||
|
||||
func (vfs *wrappedFS) walkDir(rest string, walkFn vfs.WalkDirFunc) error {
|
||||
var entries []fs.DirEntry
|
||||
switch rest {
|
||||
case "":
|
||||
entries = rootEntries
|
||||
case "libs":
|
||||
entries = libsEntries
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, entry := range entries {
|
||||
name := rest + "/" + entry.Name()
|
||||
|
||||
if err := walkFn(scheme+name, entry, nil); err != nil {
|
||||
if err == fs.SkipAll { //nolint:errorlint
|
||||
return fs.SkipAll
|
||||
}
|
||||
if err == fs.SkipDir { //nolint:errorlint
|
||||
continue
|
||||
}
|
||||
return err
|
||||
}
|
||||
if entry.IsDir() {
|
||||
if err := vfs.walkDir(name, walkFn); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (vfs *wrappedFS) Realpath(path string) string {
|
||||
if _, ok := splitPath(path); ok {
|
||||
return path
|
||||
}
|
||||
return vfs.fs.Realpath(path)
|
||||
}
|
||||
|
||||
func (vfs *wrappedFS) WriteFile(path string, data string, writeByteOrderMark bool) error {
|
||||
if _, ok := splitPath(path); ok {
|
||||
panic("cannot write to embedded file system")
|
||||
}
|
||||
return vfs.fs.WriteFile(path, data, writeByteOrderMark)
|
||||
}
|
||||
|
||||
func (vfs *wrappedFS) Remove(path string) error {
|
||||
if _, ok := splitPath(path); ok {
|
||||
panic("cannot remove from embedded file system")
|
||||
}
|
||||
return vfs.fs.Remove(path)
|
||||
}
|
||||
|
||||
func (vfs *wrappedFS) Chtimes(path string, aTime time.Time, mTime time.Time) error {
|
||||
if _, ok := splitPath(path); ok {
|
||||
panic("cannot change times on embedded file system")
|
||||
}
|
||||
return vfs.fs.Chtimes(path, aTime, mTime)
|
||||
}
|
||||
|
||||
type fileInfo struct {
|
||||
mode fs.FileMode
|
||||
name string
|
||||
size int64
|
||||
}
|
||||
|
||||
var (
|
||||
_ fs.FileInfo = (*fileInfo)(nil)
|
||||
_ fs.DirEntry = (*fileInfo)(nil)
|
||||
)
|
||||
|
||||
func (fi *fileInfo) IsDir() bool {
|
||||
return fi.mode.IsDir()
|
||||
}
|
||||
|
||||
func (fi *fileInfo) ModTime() time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (fi *fileInfo) Mode() fs.FileMode {
|
||||
return fi.mode
|
||||
}
|
||||
|
||||
func (fi *fileInfo) Name() string {
|
||||
return fi.name
|
||||
}
|
||||
|
||||
func (fi *fileInfo) Size() int64 {
|
||||
return fi.size
|
||||
}
|
||||
|
||||
func (fi *fileInfo) Sys() any {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fi *fileInfo) Info() (fs.FileInfo, error) {
|
||||
return fi, nil
|
||||
}
|
||||
|
||||
func (fi *fileInfo) Type() fs.FileMode {
|
||||
return fi.mode.Type()
|
||||
}
|
||||
420
kitcom/internal/tsgo/bundled/embed_generated.go
Normal file
420
kitcom/internal/tsgo/bundled/embed_generated.go
Normal file
@ -0,0 +1,420 @@
|
||||
//go:build !noembed
|
||||
|
||||
// Code generated by generate.go; DO NOT EDIT.
|
||||
|
||||
package bundled
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
var (
|
||||
//go:embed libs/lib.d.ts
|
||||
libs_lib_d_ts string
|
||||
//go:embed libs/lib.decorators.d.ts
|
||||
libs_lib_decorators_d_ts string
|
||||
//go:embed libs/lib.decorators.legacy.d.ts
|
||||
libs_lib_decorators_legacy_d_ts string
|
||||
//go:embed libs/lib.dom.asynciterable.d.ts
|
||||
libs_lib_dom_asynciterable_d_ts string
|
||||
//go:embed libs/lib.dom.d.ts
|
||||
libs_lib_dom_d_ts string
|
||||
//go:embed libs/lib.dom.iterable.d.ts
|
||||
libs_lib_dom_iterable_d_ts string
|
||||
//go:embed libs/lib.es2015.collection.d.ts
|
||||
libs_lib_es2015_collection_d_ts string
|
||||
//go:embed libs/lib.es2015.core.d.ts
|
||||
libs_lib_es2015_core_d_ts string
|
||||
//go:embed libs/lib.es2015.d.ts
|
||||
libs_lib_es2015_d_ts string
|
||||
//go:embed libs/lib.es2015.generator.d.ts
|
||||
libs_lib_es2015_generator_d_ts string
|
||||
//go:embed libs/lib.es2015.iterable.d.ts
|
||||
libs_lib_es2015_iterable_d_ts string
|
||||
//go:embed libs/lib.es2015.promise.d.ts
|
||||
libs_lib_es2015_promise_d_ts string
|
||||
//go:embed libs/lib.es2015.proxy.d.ts
|
||||
libs_lib_es2015_proxy_d_ts string
|
||||
//go:embed libs/lib.es2015.reflect.d.ts
|
||||
libs_lib_es2015_reflect_d_ts string
|
||||
//go:embed libs/lib.es2015.symbol.d.ts
|
||||
libs_lib_es2015_symbol_d_ts string
|
||||
//go:embed libs/lib.es2015.symbol.wellknown.d.ts
|
||||
libs_lib_es2015_symbol_wellknown_d_ts string
|
||||
//go:embed libs/lib.es2016.array.include.d.ts
|
||||
libs_lib_es2016_array_include_d_ts string
|
||||
//go:embed libs/lib.es2016.d.ts
|
||||
libs_lib_es2016_d_ts string
|
||||
//go:embed libs/lib.es2016.full.d.ts
|
||||
libs_lib_es2016_full_d_ts string
|
||||
//go:embed libs/lib.es2016.intl.d.ts
|
||||
libs_lib_es2016_intl_d_ts string
|
||||
//go:embed libs/lib.es2017.arraybuffer.d.ts
|
||||
libs_lib_es2017_arraybuffer_d_ts string
|
||||
//go:embed libs/lib.es2017.d.ts
|
||||
libs_lib_es2017_d_ts string
|
||||
//go:embed libs/lib.es2017.date.d.ts
|
||||
libs_lib_es2017_date_d_ts string
|
||||
//go:embed libs/lib.es2017.full.d.ts
|
||||
libs_lib_es2017_full_d_ts string
|
||||
//go:embed libs/lib.es2017.intl.d.ts
|
||||
libs_lib_es2017_intl_d_ts string
|
||||
//go:embed libs/lib.es2017.object.d.ts
|
||||
libs_lib_es2017_object_d_ts string
|
||||
//go:embed libs/lib.es2017.sharedmemory.d.ts
|
||||
libs_lib_es2017_sharedmemory_d_ts string
|
||||
//go:embed libs/lib.es2017.string.d.ts
|
||||
libs_lib_es2017_string_d_ts string
|
||||
//go:embed libs/lib.es2017.typedarrays.d.ts
|
||||
libs_lib_es2017_typedarrays_d_ts string
|
||||
//go:embed libs/lib.es2018.asyncgenerator.d.ts
|
||||
libs_lib_es2018_asyncgenerator_d_ts string
|
||||
//go:embed libs/lib.es2018.asynciterable.d.ts
|
||||
libs_lib_es2018_asynciterable_d_ts string
|
||||
//go:embed libs/lib.es2018.d.ts
|
||||
libs_lib_es2018_d_ts string
|
||||
//go:embed libs/lib.es2018.full.d.ts
|
||||
libs_lib_es2018_full_d_ts string
|
||||
//go:embed libs/lib.es2018.intl.d.ts
|
||||
libs_lib_es2018_intl_d_ts string
|
||||
//go:embed libs/lib.es2018.promise.d.ts
|
||||
libs_lib_es2018_promise_d_ts string
|
||||
//go:embed libs/lib.es2018.regexp.d.ts
|
||||
libs_lib_es2018_regexp_d_ts string
|
||||
//go:embed libs/lib.es2019.array.d.ts
|
||||
libs_lib_es2019_array_d_ts string
|
||||
//go:embed libs/lib.es2019.d.ts
|
||||
libs_lib_es2019_d_ts string
|
||||
//go:embed libs/lib.es2019.full.d.ts
|
||||
libs_lib_es2019_full_d_ts string
|
||||
//go:embed libs/lib.es2019.intl.d.ts
|
||||
libs_lib_es2019_intl_d_ts string
|
||||
//go:embed libs/lib.es2019.object.d.ts
|
||||
libs_lib_es2019_object_d_ts string
|
||||
//go:embed libs/lib.es2019.string.d.ts
|
||||
libs_lib_es2019_string_d_ts string
|
||||
//go:embed libs/lib.es2019.symbol.d.ts
|
||||
libs_lib_es2019_symbol_d_ts string
|
||||
//go:embed libs/lib.es2020.bigint.d.ts
|
||||
libs_lib_es2020_bigint_d_ts string
|
||||
//go:embed libs/lib.es2020.d.ts
|
||||
libs_lib_es2020_d_ts string
|
||||
//go:embed libs/lib.es2020.date.d.ts
|
||||
libs_lib_es2020_date_d_ts string
|
||||
//go:embed libs/lib.es2020.full.d.ts
|
||||
libs_lib_es2020_full_d_ts string
|
||||
//go:embed libs/lib.es2020.intl.d.ts
|
||||
libs_lib_es2020_intl_d_ts string
|
||||
//go:embed libs/lib.es2020.number.d.ts
|
||||
libs_lib_es2020_number_d_ts string
|
||||
//go:embed libs/lib.es2020.promise.d.ts
|
||||
libs_lib_es2020_promise_d_ts string
|
||||
//go:embed libs/lib.es2020.sharedmemory.d.ts
|
||||
libs_lib_es2020_sharedmemory_d_ts string
|
||||
//go:embed libs/lib.es2020.string.d.ts
|
||||
libs_lib_es2020_string_d_ts string
|
||||
//go:embed libs/lib.es2020.symbol.wellknown.d.ts
|
||||
libs_lib_es2020_symbol_wellknown_d_ts string
|
||||
//go:embed libs/lib.es2021.d.ts
|
||||
libs_lib_es2021_d_ts string
|
||||
//go:embed libs/lib.es2021.full.d.ts
|
||||
libs_lib_es2021_full_d_ts string
|
||||
//go:embed libs/lib.es2021.intl.d.ts
|
||||
libs_lib_es2021_intl_d_ts string
|
||||
//go:embed libs/lib.es2021.promise.d.ts
|
||||
libs_lib_es2021_promise_d_ts string
|
||||
//go:embed libs/lib.es2021.string.d.ts
|
||||
libs_lib_es2021_string_d_ts string
|
||||
//go:embed libs/lib.es2021.weakref.d.ts
|
||||
libs_lib_es2021_weakref_d_ts string
|
||||
//go:embed libs/lib.es2022.array.d.ts
|
||||
libs_lib_es2022_array_d_ts string
|
||||
//go:embed libs/lib.es2022.d.ts
|
||||
libs_lib_es2022_d_ts string
|
||||
//go:embed libs/lib.es2022.error.d.ts
|
||||
libs_lib_es2022_error_d_ts string
|
||||
//go:embed libs/lib.es2022.full.d.ts
|
||||
libs_lib_es2022_full_d_ts string
|
||||
//go:embed libs/lib.es2022.intl.d.ts
|
||||
libs_lib_es2022_intl_d_ts string
|
||||
//go:embed libs/lib.es2022.object.d.ts
|
||||
libs_lib_es2022_object_d_ts string
|
||||
//go:embed libs/lib.es2022.regexp.d.ts
|
||||
libs_lib_es2022_regexp_d_ts string
|
||||
//go:embed libs/lib.es2022.string.d.ts
|
||||
libs_lib_es2022_string_d_ts string
|
||||
//go:embed libs/lib.es2023.array.d.ts
|
||||
libs_lib_es2023_array_d_ts string
|
||||
//go:embed libs/lib.es2023.collection.d.ts
|
||||
libs_lib_es2023_collection_d_ts string
|
||||
//go:embed libs/lib.es2023.d.ts
|
||||
libs_lib_es2023_d_ts string
|
||||
//go:embed libs/lib.es2023.full.d.ts
|
||||
libs_lib_es2023_full_d_ts string
|
||||
//go:embed libs/lib.es2023.intl.d.ts
|
||||
libs_lib_es2023_intl_d_ts string
|
||||
//go:embed libs/lib.es2024.arraybuffer.d.ts
|
||||
libs_lib_es2024_arraybuffer_d_ts string
|
||||
//go:embed libs/lib.es2024.collection.d.ts
|
||||
libs_lib_es2024_collection_d_ts string
|
||||
//go:embed libs/lib.es2024.d.ts
|
||||
libs_lib_es2024_d_ts string
|
||||
//go:embed libs/lib.es2024.full.d.ts
|
||||
libs_lib_es2024_full_d_ts string
|
||||
//go:embed libs/lib.es2024.object.d.ts
|
||||
libs_lib_es2024_object_d_ts string
|
||||
//go:embed libs/lib.es2024.promise.d.ts
|
||||
libs_lib_es2024_promise_d_ts string
|
||||
//go:embed libs/lib.es2024.regexp.d.ts
|
||||
libs_lib_es2024_regexp_d_ts string
|
||||
//go:embed libs/lib.es2024.sharedmemory.d.ts
|
||||
libs_lib_es2024_sharedmemory_d_ts string
|
||||
//go:embed libs/lib.es2024.string.d.ts
|
||||
libs_lib_es2024_string_d_ts string
|
||||
//go:embed libs/lib.es5.d.ts
|
||||
libs_lib_es5_d_ts string
|
||||
//go:embed libs/lib.es6.d.ts
|
||||
libs_lib_es6_d_ts string
|
||||
//go:embed libs/lib.esnext.array.d.ts
|
||||
libs_lib_esnext_array_d_ts string
|
||||
//go:embed libs/lib.esnext.collection.d.ts
|
||||
libs_lib_esnext_collection_d_ts string
|
||||
//go:embed libs/lib.esnext.d.ts
|
||||
libs_lib_esnext_d_ts string
|
||||
//go:embed libs/lib.esnext.decorators.d.ts
|
||||
libs_lib_esnext_decorators_d_ts string
|
||||
//go:embed libs/lib.esnext.disposable.d.ts
|
||||
libs_lib_esnext_disposable_d_ts string
|
||||
//go:embed libs/lib.esnext.error.d.ts
|
||||
libs_lib_esnext_error_d_ts string
|
||||
//go:embed libs/lib.esnext.float16.d.ts
|
||||
libs_lib_esnext_float16_d_ts string
|
||||
//go:embed libs/lib.esnext.full.d.ts
|
||||
libs_lib_esnext_full_d_ts string
|
||||
//go:embed libs/lib.esnext.intl.d.ts
|
||||
libs_lib_esnext_intl_d_ts string
|
||||
//go:embed libs/lib.esnext.iterator.d.ts
|
||||
libs_lib_esnext_iterator_d_ts string
|
||||
//go:embed libs/lib.esnext.promise.d.ts
|
||||
libs_lib_esnext_promise_d_ts string
|
||||
//go:embed libs/lib.esnext.sharedmemory.d.ts
|
||||
libs_lib_esnext_sharedmemory_d_ts string
|
||||
//go:embed libs/lib.scripthost.d.ts
|
||||
libs_lib_scripthost_d_ts string
|
||||
//go:embed libs/lib.webworker.asynciterable.d.ts
|
||||
libs_lib_webworker_asynciterable_d_ts string
|
||||
//go:embed libs/lib.webworker.d.ts
|
||||
libs_lib_webworker_d_ts string
|
||||
//go:embed libs/lib.webworker.importscripts.d.ts
|
||||
libs_lib_webworker_importscripts_d_ts string
|
||||
//go:embed libs/lib.webworker.iterable.d.ts
|
||||
libs_lib_webworker_iterable_d_ts string
|
||||
)
|
||||
|
||||
var embeddedContents = map[string]string{
|
||||
"libs/lib.d.ts": libs_lib_d_ts,
|
||||
"libs/lib.decorators.d.ts": libs_lib_decorators_d_ts,
|
||||
"libs/lib.decorators.legacy.d.ts": libs_lib_decorators_legacy_d_ts,
|
||||
"libs/lib.dom.asynciterable.d.ts": libs_lib_dom_asynciterable_d_ts,
|
||||
"libs/lib.dom.d.ts": libs_lib_dom_d_ts,
|
||||
"libs/lib.dom.iterable.d.ts": libs_lib_dom_iterable_d_ts,
|
||||
"libs/lib.es2015.collection.d.ts": libs_lib_es2015_collection_d_ts,
|
||||
"libs/lib.es2015.core.d.ts": libs_lib_es2015_core_d_ts,
|
||||
"libs/lib.es2015.d.ts": libs_lib_es2015_d_ts,
|
||||
"libs/lib.es2015.generator.d.ts": libs_lib_es2015_generator_d_ts,
|
||||
"libs/lib.es2015.iterable.d.ts": libs_lib_es2015_iterable_d_ts,
|
||||
"libs/lib.es2015.promise.d.ts": libs_lib_es2015_promise_d_ts,
|
||||
"libs/lib.es2015.proxy.d.ts": libs_lib_es2015_proxy_d_ts,
|
||||
"libs/lib.es2015.reflect.d.ts": libs_lib_es2015_reflect_d_ts,
|
||||
"libs/lib.es2015.symbol.d.ts": libs_lib_es2015_symbol_d_ts,
|
||||
"libs/lib.es2015.symbol.wellknown.d.ts": libs_lib_es2015_symbol_wellknown_d_ts,
|
||||
"libs/lib.es2016.array.include.d.ts": libs_lib_es2016_array_include_d_ts,
|
||||
"libs/lib.es2016.d.ts": libs_lib_es2016_d_ts,
|
||||
"libs/lib.es2016.full.d.ts": libs_lib_es2016_full_d_ts,
|
||||
"libs/lib.es2016.intl.d.ts": libs_lib_es2016_intl_d_ts,
|
||||
"libs/lib.es2017.arraybuffer.d.ts": libs_lib_es2017_arraybuffer_d_ts,
|
||||
"libs/lib.es2017.d.ts": libs_lib_es2017_d_ts,
|
||||
"libs/lib.es2017.date.d.ts": libs_lib_es2017_date_d_ts,
|
||||
"libs/lib.es2017.full.d.ts": libs_lib_es2017_full_d_ts,
|
||||
"libs/lib.es2017.intl.d.ts": libs_lib_es2017_intl_d_ts,
|
||||
"libs/lib.es2017.object.d.ts": libs_lib_es2017_object_d_ts,
|
||||
"libs/lib.es2017.sharedmemory.d.ts": libs_lib_es2017_sharedmemory_d_ts,
|
||||
"libs/lib.es2017.string.d.ts": libs_lib_es2017_string_d_ts,
|
||||
"libs/lib.es2017.typedarrays.d.ts": libs_lib_es2017_typedarrays_d_ts,
|
||||
"libs/lib.es2018.asyncgenerator.d.ts": libs_lib_es2018_asyncgenerator_d_ts,
|
||||
"libs/lib.es2018.asynciterable.d.ts": libs_lib_es2018_asynciterable_d_ts,
|
||||
"libs/lib.es2018.d.ts": libs_lib_es2018_d_ts,
|
||||
"libs/lib.es2018.full.d.ts": libs_lib_es2018_full_d_ts,
|
||||
"libs/lib.es2018.intl.d.ts": libs_lib_es2018_intl_d_ts,
|
||||
"libs/lib.es2018.promise.d.ts": libs_lib_es2018_promise_d_ts,
|
||||
"libs/lib.es2018.regexp.d.ts": libs_lib_es2018_regexp_d_ts,
|
||||
"libs/lib.es2019.array.d.ts": libs_lib_es2019_array_d_ts,
|
||||
"libs/lib.es2019.d.ts": libs_lib_es2019_d_ts,
|
||||
"libs/lib.es2019.full.d.ts": libs_lib_es2019_full_d_ts,
|
||||
"libs/lib.es2019.intl.d.ts": libs_lib_es2019_intl_d_ts,
|
||||
"libs/lib.es2019.object.d.ts": libs_lib_es2019_object_d_ts,
|
||||
"libs/lib.es2019.string.d.ts": libs_lib_es2019_string_d_ts,
|
||||
"libs/lib.es2019.symbol.d.ts": libs_lib_es2019_symbol_d_ts,
|
||||
"libs/lib.es2020.bigint.d.ts": libs_lib_es2020_bigint_d_ts,
|
||||
"libs/lib.es2020.d.ts": libs_lib_es2020_d_ts,
|
||||
"libs/lib.es2020.date.d.ts": libs_lib_es2020_date_d_ts,
|
||||
"libs/lib.es2020.full.d.ts": libs_lib_es2020_full_d_ts,
|
||||
"libs/lib.es2020.intl.d.ts": libs_lib_es2020_intl_d_ts,
|
||||
"libs/lib.es2020.number.d.ts": libs_lib_es2020_number_d_ts,
|
||||
"libs/lib.es2020.promise.d.ts": libs_lib_es2020_promise_d_ts,
|
||||
"libs/lib.es2020.sharedmemory.d.ts": libs_lib_es2020_sharedmemory_d_ts,
|
||||
"libs/lib.es2020.string.d.ts": libs_lib_es2020_string_d_ts,
|
||||
"libs/lib.es2020.symbol.wellknown.d.ts": libs_lib_es2020_symbol_wellknown_d_ts,
|
||||
"libs/lib.es2021.d.ts": libs_lib_es2021_d_ts,
|
||||
"libs/lib.es2021.full.d.ts": libs_lib_es2021_full_d_ts,
|
||||
"libs/lib.es2021.intl.d.ts": libs_lib_es2021_intl_d_ts,
|
||||
"libs/lib.es2021.promise.d.ts": libs_lib_es2021_promise_d_ts,
|
||||
"libs/lib.es2021.string.d.ts": libs_lib_es2021_string_d_ts,
|
||||
"libs/lib.es2021.weakref.d.ts": libs_lib_es2021_weakref_d_ts,
|
||||
"libs/lib.es2022.array.d.ts": libs_lib_es2022_array_d_ts,
|
||||
"libs/lib.es2022.d.ts": libs_lib_es2022_d_ts,
|
||||
"libs/lib.es2022.error.d.ts": libs_lib_es2022_error_d_ts,
|
||||
"libs/lib.es2022.full.d.ts": libs_lib_es2022_full_d_ts,
|
||||
"libs/lib.es2022.intl.d.ts": libs_lib_es2022_intl_d_ts,
|
||||
"libs/lib.es2022.object.d.ts": libs_lib_es2022_object_d_ts,
|
||||
"libs/lib.es2022.regexp.d.ts": libs_lib_es2022_regexp_d_ts,
|
||||
"libs/lib.es2022.string.d.ts": libs_lib_es2022_string_d_ts,
|
||||
"libs/lib.es2023.array.d.ts": libs_lib_es2023_array_d_ts,
|
||||
"libs/lib.es2023.collection.d.ts": libs_lib_es2023_collection_d_ts,
|
||||
"libs/lib.es2023.d.ts": libs_lib_es2023_d_ts,
|
||||
"libs/lib.es2023.full.d.ts": libs_lib_es2023_full_d_ts,
|
||||
"libs/lib.es2023.intl.d.ts": libs_lib_es2023_intl_d_ts,
|
||||
"libs/lib.es2024.arraybuffer.d.ts": libs_lib_es2024_arraybuffer_d_ts,
|
||||
"libs/lib.es2024.collection.d.ts": libs_lib_es2024_collection_d_ts,
|
||||
"libs/lib.es2024.d.ts": libs_lib_es2024_d_ts,
|
||||
"libs/lib.es2024.full.d.ts": libs_lib_es2024_full_d_ts,
|
||||
"libs/lib.es2024.object.d.ts": libs_lib_es2024_object_d_ts,
|
||||
"libs/lib.es2024.promise.d.ts": libs_lib_es2024_promise_d_ts,
|
||||
"libs/lib.es2024.regexp.d.ts": libs_lib_es2024_regexp_d_ts,
|
||||
"libs/lib.es2024.sharedmemory.d.ts": libs_lib_es2024_sharedmemory_d_ts,
|
||||
"libs/lib.es2024.string.d.ts": libs_lib_es2024_string_d_ts,
|
||||
"libs/lib.es5.d.ts": libs_lib_es5_d_ts,
|
||||
"libs/lib.es6.d.ts": libs_lib_es6_d_ts,
|
||||
"libs/lib.esnext.array.d.ts": libs_lib_esnext_array_d_ts,
|
||||
"libs/lib.esnext.collection.d.ts": libs_lib_esnext_collection_d_ts,
|
||||
"libs/lib.esnext.d.ts": libs_lib_esnext_d_ts,
|
||||
"libs/lib.esnext.decorators.d.ts": libs_lib_esnext_decorators_d_ts,
|
||||
"libs/lib.esnext.disposable.d.ts": libs_lib_esnext_disposable_d_ts,
|
||||
"libs/lib.esnext.error.d.ts": libs_lib_esnext_error_d_ts,
|
||||
"libs/lib.esnext.float16.d.ts": libs_lib_esnext_float16_d_ts,
|
||||
"libs/lib.esnext.full.d.ts": libs_lib_esnext_full_d_ts,
|
||||
"libs/lib.esnext.intl.d.ts": libs_lib_esnext_intl_d_ts,
|
||||
"libs/lib.esnext.iterator.d.ts": libs_lib_esnext_iterator_d_ts,
|
||||
"libs/lib.esnext.promise.d.ts": libs_lib_esnext_promise_d_ts,
|
||||
"libs/lib.esnext.sharedmemory.d.ts": libs_lib_esnext_sharedmemory_d_ts,
|
||||
"libs/lib.scripthost.d.ts": libs_lib_scripthost_d_ts,
|
||||
"libs/lib.webworker.asynciterable.d.ts": libs_lib_webworker_asynciterable_d_ts,
|
||||
"libs/lib.webworker.d.ts": libs_lib_webworker_d_ts,
|
||||
"libs/lib.webworker.importscripts.d.ts": libs_lib_webworker_importscripts_d_ts,
|
||||
"libs/lib.webworker.iterable.d.ts": libs_lib_webworker_iterable_d_ts,
|
||||
}
|
||||
|
||||
var libsEntries = []fs.DirEntry{
|
||||
&fileInfo{name: "lib.d.ts", size: int64(len(libs_lib_d_ts))},
|
||||
&fileInfo{name: "lib.decorators.d.ts", size: int64(len(libs_lib_decorators_d_ts))},
|
||||
&fileInfo{name: "lib.decorators.legacy.d.ts", size: int64(len(libs_lib_decorators_legacy_d_ts))},
|
||||
&fileInfo{name: "lib.dom.asynciterable.d.ts", size: int64(len(libs_lib_dom_asynciterable_d_ts))},
|
||||
&fileInfo{name: "lib.dom.d.ts", size: int64(len(libs_lib_dom_d_ts))},
|
||||
&fileInfo{name: "lib.dom.iterable.d.ts", size: int64(len(libs_lib_dom_iterable_d_ts))},
|
||||
&fileInfo{name: "lib.es2015.collection.d.ts", size: int64(len(libs_lib_es2015_collection_d_ts))},
|
||||
&fileInfo{name: "lib.es2015.core.d.ts", size: int64(len(libs_lib_es2015_core_d_ts))},
|
||||
&fileInfo{name: "lib.es2015.d.ts", size: int64(len(libs_lib_es2015_d_ts))},
|
||||
&fileInfo{name: "lib.es2015.generator.d.ts", size: int64(len(libs_lib_es2015_generator_d_ts))},
|
||||
&fileInfo{name: "lib.es2015.iterable.d.ts", size: int64(len(libs_lib_es2015_iterable_d_ts))},
|
||||
&fileInfo{name: "lib.es2015.promise.d.ts", size: int64(len(libs_lib_es2015_promise_d_ts))},
|
||||
&fileInfo{name: "lib.es2015.proxy.d.ts", size: int64(len(libs_lib_es2015_proxy_d_ts))},
|
||||
&fileInfo{name: "lib.es2015.reflect.d.ts", size: int64(len(libs_lib_es2015_reflect_d_ts))},
|
||||
&fileInfo{name: "lib.es2015.symbol.d.ts", size: int64(len(libs_lib_es2015_symbol_d_ts))},
|
||||
&fileInfo{name: "lib.es2015.symbol.wellknown.d.ts", size: int64(len(libs_lib_es2015_symbol_wellknown_d_ts))},
|
||||
&fileInfo{name: "lib.es2016.array.include.d.ts", size: int64(len(libs_lib_es2016_array_include_d_ts))},
|
||||
&fileInfo{name: "lib.es2016.d.ts", size: int64(len(libs_lib_es2016_d_ts))},
|
||||
&fileInfo{name: "lib.es2016.full.d.ts", size: int64(len(libs_lib_es2016_full_d_ts))},
|
||||
&fileInfo{name: "lib.es2016.intl.d.ts", size: int64(len(libs_lib_es2016_intl_d_ts))},
|
||||
&fileInfo{name: "lib.es2017.arraybuffer.d.ts", size: int64(len(libs_lib_es2017_arraybuffer_d_ts))},
|
||||
&fileInfo{name: "lib.es2017.d.ts", size: int64(len(libs_lib_es2017_d_ts))},
|
||||
&fileInfo{name: "lib.es2017.date.d.ts", size: int64(len(libs_lib_es2017_date_d_ts))},
|
||||
&fileInfo{name: "lib.es2017.full.d.ts", size: int64(len(libs_lib_es2017_full_d_ts))},
|
||||
&fileInfo{name: "lib.es2017.intl.d.ts", size: int64(len(libs_lib_es2017_intl_d_ts))},
|
||||
&fileInfo{name: "lib.es2017.object.d.ts", size: int64(len(libs_lib_es2017_object_d_ts))},
|
||||
&fileInfo{name: "lib.es2017.sharedmemory.d.ts", size: int64(len(libs_lib_es2017_sharedmemory_d_ts))},
|
||||
&fileInfo{name: "lib.es2017.string.d.ts", size: int64(len(libs_lib_es2017_string_d_ts))},
|
||||
&fileInfo{name: "lib.es2017.typedarrays.d.ts", size: int64(len(libs_lib_es2017_typedarrays_d_ts))},
|
||||
&fileInfo{name: "lib.es2018.asyncgenerator.d.ts", size: int64(len(libs_lib_es2018_asyncgenerator_d_ts))},
|
||||
&fileInfo{name: "lib.es2018.asynciterable.d.ts", size: int64(len(libs_lib_es2018_asynciterable_d_ts))},
|
||||
&fileInfo{name: "lib.es2018.d.ts", size: int64(len(libs_lib_es2018_d_ts))},
|
||||
&fileInfo{name: "lib.es2018.full.d.ts", size: int64(len(libs_lib_es2018_full_d_ts))},
|
||||
&fileInfo{name: "lib.es2018.intl.d.ts", size: int64(len(libs_lib_es2018_intl_d_ts))},
|
||||
&fileInfo{name: "lib.es2018.promise.d.ts", size: int64(len(libs_lib_es2018_promise_d_ts))},
|
||||
&fileInfo{name: "lib.es2018.regexp.d.ts", size: int64(len(libs_lib_es2018_regexp_d_ts))},
|
||||
&fileInfo{name: "lib.es2019.array.d.ts", size: int64(len(libs_lib_es2019_array_d_ts))},
|
||||
&fileInfo{name: "lib.es2019.d.ts", size: int64(len(libs_lib_es2019_d_ts))},
|
||||
&fileInfo{name: "lib.es2019.full.d.ts", size: int64(len(libs_lib_es2019_full_d_ts))},
|
||||
&fileInfo{name: "lib.es2019.intl.d.ts", size: int64(len(libs_lib_es2019_intl_d_ts))},
|
||||
&fileInfo{name: "lib.es2019.object.d.ts", size: int64(len(libs_lib_es2019_object_d_ts))},
|
||||
&fileInfo{name: "lib.es2019.string.d.ts", size: int64(len(libs_lib_es2019_string_d_ts))},
|
||||
&fileInfo{name: "lib.es2019.symbol.d.ts", size: int64(len(libs_lib_es2019_symbol_d_ts))},
|
||||
&fileInfo{name: "lib.es2020.bigint.d.ts", size: int64(len(libs_lib_es2020_bigint_d_ts))},
|
||||
&fileInfo{name: "lib.es2020.d.ts", size: int64(len(libs_lib_es2020_d_ts))},
|
||||
&fileInfo{name: "lib.es2020.date.d.ts", size: int64(len(libs_lib_es2020_date_d_ts))},
|
||||
&fileInfo{name: "lib.es2020.full.d.ts", size: int64(len(libs_lib_es2020_full_d_ts))},
|
||||
&fileInfo{name: "lib.es2020.intl.d.ts", size: int64(len(libs_lib_es2020_intl_d_ts))},
|
||||
&fileInfo{name: "lib.es2020.number.d.ts", size: int64(len(libs_lib_es2020_number_d_ts))},
|
||||
&fileInfo{name: "lib.es2020.promise.d.ts", size: int64(len(libs_lib_es2020_promise_d_ts))},
|
||||
&fileInfo{name: "lib.es2020.sharedmemory.d.ts", size: int64(len(libs_lib_es2020_sharedmemory_d_ts))},
|
||||
&fileInfo{name: "lib.es2020.string.d.ts", size: int64(len(libs_lib_es2020_string_d_ts))},
|
||||
&fileInfo{name: "lib.es2020.symbol.wellknown.d.ts", size: int64(len(libs_lib_es2020_symbol_wellknown_d_ts))},
|
||||
&fileInfo{name: "lib.es2021.d.ts", size: int64(len(libs_lib_es2021_d_ts))},
|
||||
&fileInfo{name: "lib.es2021.full.d.ts", size: int64(len(libs_lib_es2021_full_d_ts))},
|
||||
&fileInfo{name: "lib.es2021.intl.d.ts", size: int64(len(libs_lib_es2021_intl_d_ts))},
|
||||
&fileInfo{name: "lib.es2021.promise.d.ts", size: int64(len(libs_lib_es2021_promise_d_ts))},
|
||||
&fileInfo{name: "lib.es2021.string.d.ts", size: int64(len(libs_lib_es2021_string_d_ts))},
|
||||
&fileInfo{name: "lib.es2021.weakref.d.ts", size: int64(len(libs_lib_es2021_weakref_d_ts))},
|
||||
&fileInfo{name: "lib.es2022.array.d.ts", size: int64(len(libs_lib_es2022_array_d_ts))},
|
||||
&fileInfo{name: "lib.es2022.d.ts", size: int64(len(libs_lib_es2022_d_ts))},
|
||||
&fileInfo{name: "lib.es2022.error.d.ts", size: int64(len(libs_lib_es2022_error_d_ts))},
|
||||
&fileInfo{name: "lib.es2022.full.d.ts", size: int64(len(libs_lib_es2022_full_d_ts))},
|
||||
&fileInfo{name: "lib.es2022.intl.d.ts", size: int64(len(libs_lib_es2022_intl_d_ts))},
|
||||
&fileInfo{name: "lib.es2022.object.d.ts", size: int64(len(libs_lib_es2022_object_d_ts))},
|
||||
&fileInfo{name: "lib.es2022.regexp.d.ts", size: int64(len(libs_lib_es2022_regexp_d_ts))},
|
||||
&fileInfo{name: "lib.es2022.string.d.ts", size: int64(len(libs_lib_es2022_string_d_ts))},
|
||||
&fileInfo{name: "lib.es2023.array.d.ts", size: int64(len(libs_lib_es2023_array_d_ts))},
|
||||
&fileInfo{name: "lib.es2023.collection.d.ts", size: int64(len(libs_lib_es2023_collection_d_ts))},
|
||||
&fileInfo{name: "lib.es2023.d.ts", size: int64(len(libs_lib_es2023_d_ts))},
|
||||
&fileInfo{name: "lib.es2023.full.d.ts", size: int64(len(libs_lib_es2023_full_d_ts))},
|
||||
&fileInfo{name: "lib.es2023.intl.d.ts", size: int64(len(libs_lib_es2023_intl_d_ts))},
|
||||
&fileInfo{name: "lib.es2024.arraybuffer.d.ts", size: int64(len(libs_lib_es2024_arraybuffer_d_ts))},
|
||||
&fileInfo{name: "lib.es2024.collection.d.ts", size: int64(len(libs_lib_es2024_collection_d_ts))},
|
||||
&fileInfo{name: "lib.es2024.d.ts", size: int64(len(libs_lib_es2024_d_ts))},
|
||||
&fileInfo{name: "lib.es2024.full.d.ts", size: int64(len(libs_lib_es2024_full_d_ts))},
|
||||
&fileInfo{name: "lib.es2024.object.d.ts", size: int64(len(libs_lib_es2024_object_d_ts))},
|
||||
&fileInfo{name: "lib.es2024.promise.d.ts", size: int64(len(libs_lib_es2024_promise_d_ts))},
|
||||
&fileInfo{name: "lib.es2024.regexp.d.ts", size: int64(len(libs_lib_es2024_regexp_d_ts))},
|
||||
&fileInfo{name: "lib.es2024.sharedmemory.d.ts", size: int64(len(libs_lib_es2024_sharedmemory_d_ts))},
|
||||
&fileInfo{name: "lib.es2024.string.d.ts", size: int64(len(libs_lib_es2024_string_d_ts))},
|
||||
&fileInfo{name: "lib.es5.d.ts", size: int64(len(libs_lib_es5_d_ts))},
|
||||
&fileInfo{name: "lib.es6.d.ts", size: int64(len(libs_lib_es6_d_ts))},
|
||||
&fileInfo{name: "lib.esnext.array.d.ts", size: int64(len(libs_lib_esnext_array_d_ts))},
|
||||
&fileInfo{name: "lib.esnext.collection.d.ts", size: int64(len(libs_lib_esnext_collection_d_ts))},
|
||||
&fileInfo{name: "lib.esnext.d.ts", size: int64(len(libs_lib_esnext_d_ts))},
|
||||
&fileInfo{name: "lib.esnext.decorators.d.ts", size: int64(len(libs_lib_esnext_decorators_d_ts))},
|
||||
&fileInfo{name: "lib.esnext.disposable.d.ts", size: int64(len(libs_lib_esnext_disposable_d_ts))},
|
||||
&fileInfo{name: "lib.esnext.error.d.ts", size: int64(len(libs_lib_esnext_error_d_ts))},
|
||||
&fileInfo{name: "lib.esnext.float16.d.ts", size: int64(len(libs_lib_esnext_float16_d_ts))},
|
||||
&fileInfo{name: "lib.esnext.full.d.ts", size: int64(len(libs_lib_esnext_full_d_ts))},
|
||||
&fileInfo{name: "lib.esnext.intl.d.ts", size: int64(len(libs_lib_esnext_intl_d_ts))},
|
||||
&fileInfo{name: "lib.esnext.iterator.d.ts", size: int64(len(libs_lib_esnext_iterator_d_ts))},
|
||||
&fileInfo{name: "lib.esnext.promise.d.ts", size: int64(len(libs_lib_esnext_promise_d_ts))},
|
||||
&fileInfo{name: "lib.esnext.sharedmemory.d.ts", size: int64(len(libs_lib_esnext_sharedmemory_d_ts))},
|
||||
&fileInfo{name: "lib.scripthost.d.ts", size: int64(len(libs_lib_scripthost_d_ts))},
|
||||
&fileInfo{name: "lib.webworker.asynciterable.d.ts", size: int64(len(libs_lib_webworker_asynciterable_d_ts))},
|
||||
&fileInfo{name: "lib.webworker.d.ts", size: int64(len(libs_lib_webworker_d_ts))},
|
||||
&fileInfo{name: "lib.webworker.importscripts.d.ts", size: int64(len(libs_lib_webworker_importscripts_d_ts))},
|
||||
&fileInfo{name: "lib.webworker.iterable.d.ts", size: int64(len(libs_lib_webworker_iterable_d_ts))},
|
||||
}
|
||||
228
kitcom/internal/tsgo/bundled/generate.go
Normal file
228
kitcom/internal/tsgo/bundled/generate.go
Normal file
@ -0,0 +1,228 @@
|
||||
//go:build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"go/format"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/parser"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/repo"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
)
|
||||
|
||||
var (
|
||||
libInputDir = filepath.Join(repo.TypeScriptSubmodulePath, "src", "lib")
|
||||
copyrightNotice = filepath.Join(repo.TypeScriptSubmodulePath, "scripts", "CopyrightNotice.txt")
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||
|
||||
libs := readLibs()
|
||||
generateLibs(libs)
|
||||
generateLibList(libs)
|
||||
generateEmbedded(libs)
|
||||
}
|
||||
|
||||
type lib struct {
|
||||
target string // target relative to libs dir
|
||||
sources []string // sources relative to src/lib dir
|
||||
}
|
||||
|
||||
func generateLibs(libs []lib) {
|
||||
const outputDir = "libs"
|
||||
|
||||
copyright := readCopyright()
|
||||
|
||||
if err := os.RemoveAll(outputDir); err != nil {
|
||||
log.Fatalf("failed to remove libs directory: %v", err)
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(outputDir, 0o755); err != nil {
|
||||
log.Fatalf("failed to create libs directory: %v", err)
|
||||
}
|
||||
|
||||
for _, lib := range libs {
|
||||
var output bytes.Buffer
|
||||
output.Write(copyright)
|
||||
|
||||
for _, source := range lib.sources {
|
||||
sourcePath := filepath.Join(libInputDir, source)
|
||||
b, err := os.ReadFile(sourcePath)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to read %s: %v", sourcePath, err)
|
||||
}
|
||||
|
||||
output.WriteByte('\n')
|
||||
output.Write(removeCRLF(b))
|
||||
}
|
||||
|
||||
outputPath := filepath.Join(outputDir, lib.target)
|
||||
if err := os.WriteFile(outputPath, output.Bytes(), 0o644); err != nil {
|
||||
log.Fatalf("failed to write %s: %v", outputPath, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func generateLibList(libs []lib) {
|
||||
var code bytes.Buffer
|
||||
code.WriteString("// Code generated by generate.go; DO NOT EDIT.\n\n")
|
||||
code.WriteString("package bundled\n\n")
|
||||
|
||||
code.WriteString("// LibNames is the list of all bundled lib files, sorted by name.\n")
|
||||
code.WriteString("// For the list of libs sorted by load order, use [tsoptions.Libs].\n")
|
||||
code.WriteString("var LibNames = []string{\n")
|
||||
for _, lib := range libs {
|
||||
code.WriteString("\t\"" + lib.target + "\",\n")
|
||||
}
|
||||
code.WriteString("}\n")
|
||||
|
||||
writeCode("libs_generated.go", code.Bytes())
|
||||
}
|
||||
|
||||
func generateEmbedded(libs []lib) {
|
||||
libVarNames := make([]string, len(libs))
|
||||
for i, lib := range libs {
|
||||
libVarNames[i] = "libs_" + strings.ReplaceAll(lib.target, ".", "_")
|
||||
}
|
||||
|
||||
var code bytes.Buffer
|
||||
code.WriteString("//go:build !noembed\n\n")
|
||||
code.WriteString("// Code generated by generate.go; DO NOT EDIT.\n\n")
|
||||
code.WriteString("package bundled\n\n")
|
||||
code.WriteString("import (\n")
|
||||
code.WriteString("\"io/fs\"\n\n")
|
||||
code.WriteString("_ \"embed\"\n")
|
||||
code.WriteString(")\n\n")
|
||||
|
||||
code.WriteString("var (\n")
|
||||
for i, lib := range libs {
|
||||
varName := libVarNames[i]
|
||||
code.WriteString("//go:embed libs/" + lib.target + "\n")
|
||||
code.WriteString("" + varName + " string\n")
|
||||
}
|
||||
code.WriteString(")\n\n")
|
||||
|
||||
code.WriteString("var embeddedContents = map[string]string{\n")
|
||||
for i, lib := range libs {
|
||||
varName := libVarNames[i]
|
||||
code.WriteString("\t\"libs/" + lib.target + "\": " + varName + ",\n")
|
||||
}
|
||||
code.WriteString("}\n\n")
|
||||
|
||||
code.WriteString("var libsEntries = []fs.DirEntry{\n")
|
||||
for i, lib := range libs {
|
||||
varName := libVarNames[i]
|
||||
fmt.Fprintf(&code, "\t&fileInfo{name: %q, size: int64(len(%s))},\n", lib.target, varName)
|
||||
}
|
||||
code.WriteString("}\n")
|
||||
|
||||
writeCode("embed_generated.go", code.Bytes())
|
||||
}
|
||||
|
||||
func readLibs() []lib {
|
||||
type libsMeta struct {
|
||||
libs []string
|
||||
paths map[string]string
|
||||
}
|
||||
|
||||
libsFile := tspath.NormalizeSlashes(filepath.Join(libInputDir, "libs.json"))
|
||||
|
||||
b, err := os.ReadFile(libsFile)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to open libs.json: %v", err)
|
||||
}
|
||||
|
||||
sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{
|
||||
FileName: libsFile,
|
||||
Path: tspath.Path(libsFile),
|
||||
}, string(b), core.ScriptKindJSON)
|
||||
diags := sourceFile.Diagnostics()
|
||||
|
||||
if len(diags) > 0 {
|
||||
for _, diag := range diags {
|
||||
log.Printf("%s", diag.Message())
|
||||
}
|
||||
log.Fatalf("failed to parse libs.json")
|
||||
}
|
||||
|
||||
paths := make(map[string]string)
|
||||
var libNames []string
|
||||
|
||||
props := sourceFile.Statements.Nodes[0].
|
||||
AsExpressionStatement().
|
||||
Expression.
|
||||
AsObjectLiteralExpression().
|
||||
Properties.
|
||||
Nodes
|
||||
|
||||
for _, prop := range props {
|
||||
assign := prop.AsPropertyAssignment()
|
||||
name := assign.Name().Text()
|
||||
switch name {
|
||||
case "libs":
|
||||
for _, lib := range assign.Initializer.AsArrayLiteralExpression().Elements.Nodes {
|
||||
libNames = append(libNames, lib.AsStringLiteral().Text)
|
||||
}
|
||||
case "paths":
|
||||
for _, path := range assign.Initializer.AsObjectLiteralExpression().Properties.Nodes {
|
||||
prop := path.AsPropertyAssignment()
|
||||
key := prop.Name().Text()
|
||||
value := prop.Initializer.AsStringLiteral().Text
|
||||
paths[key] = value
|
||||
}
|
||||
default:
|
||||
log.Fatalf("unexpected property: %s", name)
|
||||
}
|
||||
}
|
||||
|
||||
var libs []lib
|
||||
for _, libName := range libNames {
|
||||
sources := []string{"header.d.ts", libName + ".d.ts"}
|
||||
var target string
|
||||
if path, ok := paths[libName]; ok {
|
||||
target = path
|
||||
} else {
|
||||
target = "lib." + libName + ".d.ts"
|
||||
}
|
||||
libs = append(libs, lib{target: target, sources: sources})
|
||||
}
|
||||
|
||||
slices.SortFunc(libs, func(a lib, b lib) int {
|
||||
return strings.Compare(a.target, b.target)
|
||||
})
|
||||
|
||||
return libs
|
||||
}
|
||||
|
||||
func readCopyright() []byte {
|
||||
b, err := os.ReadFile(copyrightNotice)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to read copyright notice: %v", err)
|
||||
}
|
||||
return removeCRLF(b)
|
||||
}
|
||||
|
||||
func removeCRLF(b []byte) []byte {
|
||||
return bytes.ReplaceAll(b, []byte("\r\n"), []byte("\n"))
|
||||
}
|
||||
|
||||
func writeCode(filename string, code []byte) {
|
||||
formatted, err := format.Source(code)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to format source: %v", err)
|
||||
}
|
||||
|
||||
if err := os.WriteFile(filename, formatted, 0o644); err != nil {
|
||||
log.Fatalf("failed to write %s: %v", filename, err)
|
||||
}
|
||||
}
|
||||
22
kitcom/internal/tsgo/bundled/libs/lib.d.ts
vendored
Normal file
22
kitcom/internal/tsgo/bundled/libs/lib.d.ts
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es5" />
|
||||
/// <reference lib="dom" />
|
||||
/// <reference lib="webworker.importscripts" />
|
||||
/// <reference lib="scripthost" />
|
||||
384
kitcom/internal/tsgo/bundled/libs/lib.decorators.d.ts
vendored
Normal file
384
kitcom/internal/tsgo/bundled/libs/lib.decorators.d.ts
vendored
Normal file
@ -0,0 +1,384 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/**
|
||||
* The decorator context types provided to class element decorators.
|
||||
*/
|
||||
type ClassMemberDecoratorContext =
|
||||
| ClassMethodDecoratorContext
|
||||
| ClassGetterDecoratorContext
|
||||
| ClassSetterDecoratorContext
|
||||
| ClassFieldDecoratorContext
|
||||
| ClassAccessorDecoratorContext;
|
||||
|
||||
/**
|
||||
* The decorator context types provided to any decorator.
|
||||
*/
|
||||
type DecoratorContext =
|
||||
| ClassDecoratorContext
|
||||
| ClassMemberDecoratorContext;
|
||||
|
||||
type DecoratorMetadataObject = Record<PropertyKey, unknown> & object;
|
||||
|
||||
type DecoratorMetadata = typeof globalThis extends { Symbol: { readonly metadata: symbol; }; } ? DecoratorMetadataObject : DecoratorMetadataObject | undefined;
|
||||
|
||||
/**
|
||||
* Context provided to a class decorator.
|
||||
* @template Class The type of the decorated class associated with this context.
|
||||
*/
|
||||
interface ClassDecoratorContext<
|
||||
Class extends abstract new (...args: any) => any = abstract new (...args: any) => any,
|
||||
> {
|
||||
/** The kind of element that was decorated. */
|
||||
readonly kind: "class";
|
||||
|
||||
/** The name of the decorated class. */
|
||||
readonly name: string | undefined;
|
||||
|
||||
/**
|
||||
* Adds a callback to be invoked after the class definition has been finalized.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* function customElement(name: string): ClassDecoratorFunction {
|
||||
* return (target, context) => {
|
||||
* context.addInitializer(function () {
|
||||
* customElements.define(name, this);
|
||||
* });
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @customElement("my-element")
|
||||
* class MyElement {}
|
||||
* ```
|
||||
*/
|
||||
addInitializer(initializer: (this: Class) => void): void;
|
||||
|
||||
readonly metadata: DecoratorMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Context provided to a class method decorator.
|
||||
* @template This The type on which the class element will be defined. For a static class element, this will be
|
||||
* the type of the constructor. For a non-static class element, this will be the type of the instance.
|
||||
* @template Value The type of the decorated class method.
|
||||
*/
|
||||
interface ClassMethodDecoratorContext<
|
||||
This = unknown,
|
||||
Value extends (this: This, ...args: any) => any = (this: This, ...args: any) => any,
|
||||
> {
|
||||
/** The kind of class element that was decorated. */
|
||||
readonly kind: "method";
|
||||
|
||||
/** The name of the decorated class element. */
|
||||
readonly name: string | symbol;
|
||||
|
||||
/** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
|
||||
readonly static: boolean;
|
||||
|
||||
/** A value indicating whether the class element has a private name. */
|
||||
readonly private: boolean;
|
||||
|
||||
/** An object that can be used to access the current value of the class element at runtime. */
|
||||
readonly access: {
|
||||
/**
|
||||
* Determines whether an object has a property with the same name as the decorated element.
|
||||
*/
|
||||
has(object: This): boolean;
|
||||
/**
|
||||
* Gets the current value of the method from the provided object.
|
||||
*
|
||||
* @example
|
||||
* let fn = context.access.get(instance);
|
||||
*/
|
||||
get(object: This): Value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a callback to be invoked either after static methods are defined but before
|
||||
* static initializers are run (when decorating a `static` element), or before instance
|
||||
* initializers are run (when decorating a non-`static` element).
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const bound: ClassMethodDecoratorFunction = (value, context) {
|
||||
* if (context.private) throw new TypeError("Not supported on private methods.");
|
||||
* context.addInitializer(function () {
|
||||
* this[context.name] = this[context.name].bind(this);
|
||||
* });
|
||||
* }
|
||||
*
|
||||
* class C {
|
||||
* message = "Hello";
|
||||
*
|
||||
* @bound
|
||||
* m() {
|
||||
* console.log(this.message);
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
addInitializer(initializer: (this: This) => void): void;
|
||||
|
||||
readonly metadata: DecoratorMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Context provided to a class getter decorator.
|
||||
* @template This The type on which the class element will be defined. For a static class element, this will be
|
||||
* the type of the constructor. For a non-static class element, this will be the type of the instance.
|
||||
* @template Value The property type of the decorated class getter.
|
||||
*/
|
||||
interface ClassGetterDecoratorContext<
|
||||
This = unknown,
|
||||
Value = unknown,
|
||||
> {
|
||||
/** The kind of class element that was decorated. */
|
||||
readonly kind: "getter";
|
||||
|
||||
/** The name of the decorated class element. */
|
||||
readonly name: string | symbol;
|
||||
|
||||
/** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
|
||||
readonly static: boolean;
|
||||
|
||||
/** A value indicating whether the class element has a private name. */
|
||||
readonly private: boolean;
|
||||
|
||||
/** An object that can be used to access the current value of the class element at runtime. */
|
||||
readonly access: {
|
||||
/**
|
||||
* Determines whether an object has a property with the same name as the decorated element.
|
||||
*/
|
||||
has(object: This): boolean;
|
||||
/**
|
||||
* Invokes the getter on the provided object.
|
||||
*
|
||||
* @example
|
||||
* let value = context.access.get(instance);
|
||||
*/
|
||||
get(object: This): Value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a callback to be invoked either after static methods are defined but before
|
||||
* static initializers are run (when decorating a `static` element), or before instance
|
||||
* initializers are run (when decorating a non-`static` element).
|
||||
*/
|
||||
addInitializer(initializer: (this: This) => void): void;
|
||||
|
||||
readonly metadata: DecoratorMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Context provided to a class setter decorator.
|
||||
* @template This The type on which the class element will be defined. For a static class element, this will be
|
||||
* the type of the constructor. For a non-static class element, this will be the type of the instance.
|
||||
* @template Value The type of the decorated class setter.
|
||||
*/
|
||||
interface ClassSetterDecoratorContext<
|
||||
This = unknown,
|
||||
Value = unknown,
|
||||
> {
|
||||
/** The kind of class element that was decorated. */
|
||||
readonly kind: "setter";
|
||||
|
||||
/** The name of the decorated class element. */
|
||||
readonly name: string | symbol;
|
||||
|
||||
/** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
|
||||
readonly static: boolean;
|
||||
|
||||
/** A value indicating whether the class element has a private name. */
|
||||
readonly private: boolean;
|
||||
|
||||
/** An object that can be used to access the current value of the class element at runtime. */
|
||||
readonly access: {
|
||||
/**
|
||||
* Determines whether an object has a property with the same name as the decorated element.
|
||||
*/
|
||||
has(object: This): boolean;
|
||||
/**
|
||||
* Invokes the setter on the provided object.
|
||||
*
|
||||
* @example
|
||||
* context.access.set(instance, value);
|
||||
*/
|
||||
set(object: This, value: Value): void;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a callback to be invoked either after static methods are defined but before
|
||||
* static initializers are run (when decorating a `static` element), or before instance
|
||||
* initializers are run (when decorating a non-`static` element).
|
||||
*/
|
||||
addInitializer(initializer: (this: This) => void): void;
|
||||
|
||||
readonly metadata: DecoratorMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Context provided to a class `accessor` field decorator.
|
||||
* @template This The type on which the class element will be defined. For a static class element, this will be
|
||||
* the type of the constructor. For a non-static class element, this will be the type of the instance.
|
||||
* @template Value The type of decorated class field.
|
||||
*/
|
||||
interface ClassAccessorDecoratorContext<
|
||||
This = unknown,
|
||||
Value = unknown,
|
||||
> {
|
||||
/** The kind of class element that was decorated. */
|
||||
readonly kind: "accessor";
|
||||
|
||||
/** The name of the decorated class element. */
|
||||
readonly name: string | symbol;
|
||||
|
||||
/** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
|
||||
readonly static: boolean;
|
||||
|
||||
/** A value indicating whether the class element has a private name. */
|
||||
readonly private: boolean;
|
||||
|
||||
/** An object that can be used to access the current value of the class element at runtime. */
|
||||
readonly access: {
|
||||
/**
|
||||
* Determines whether an object has a property with the same name as the decorated element.
|
||||
*/
|
||||
has(object: This): boolean;
|
||||
|
||||
/**
|
||||
* Invokes the getter on the provided object.
|
||||
*
|
||||
* @example
|
||||
* let value = context.access.get(instance);
|
||||
*/
|
||||
get(object: This): Value;
|
||||
|
||||
/**
|
||||
* Invokes the setter on the provided object.
|
||||
*
|
||||
* @example
|
||||
* context.access.set(instance, value);
|
||||
*/
|
||||
set(object: This, value: Value): void;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a callback to be invoked immediately after the auto `accessor` being
|
||||
* decorated is initialized (regardless if the `accessor` is `static` or not).
|
||||
*/
|
||||
addInitializer(initializer: (this: This) => void): void;
|
||||
|
||||
readonly metadata: DecoratorMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the target provided to class `accessor` field decorators.
|
||||
* @template This The `this` type to which the target applies.
|
||||
* @template Value The property type for the class `accessor` field.
|
||||
*/
|
||||
interface ClassAccessorDecoratorTarget<This, Value> {
|
||||
/**
|
||||
* Invokes the getter that was defined prior to decorator application.
|
||||
*
|
||||
* @example
|
||||
* let value = target.get.call(instance);
|
||||
*/
|
||||
get(this: This): Value;
|
||||
|
||||
/**
|
||||
* Invokes the setter that was defined prior to decorator application.
|
||||
*
|
||||
* @example
|
||||
* target.set.call(instance, value);
|
||||
*/
|
||||
set(this: This, value: Value): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the allowed return value from a class `accessor` field decorator.
|
||||
* @template This The `this` type to which the target applies.
|
||||
* @template Value The property type for the class `accessor` field.
|
||||
*/
|
||||
interface ClassAccessorDecoratorResult<This, Value> {
|
||||
/**
|
||||
* An optional replacement getter function. If not provided, the existing getter function is used instead.
|
||||
*/
|
||||
get?(this: This): Value;
|
||||
|
||||
/**
|
||||
* An optional replacement setter function. If not provided, the existing setter function is used instead.
|
||||
*/
|
||||
set?(this: This, value: Value): void;
|
||||
|
||||
/**
|
||||
* An optional initializer mutator that is invoked when the underlying field initializer is evaluated.
|
||||
* @param value The incoming initializer value.
|
||||
* @returns The replacement initializer value.
|
||||
*/
|
||||
init?(this: This, value: Value): Value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Context provided to a class field decorator.
|
||||
* @template This The type on which the class element will be defined. For a static class element, this will be
|
||||
* the type of the constructor. For a non-static class element, this will be the type of the instance.
|
||||
* @template Value The type of the decorated class field.
|
||||
*/
|
||||
interface ClassFieldDecoratorContext<
|
||||
This = unknown,
|
||||
Value = unknown,
|
||||
> {
|
||||
/** The kind of class element that was decorated. */
|
||||
readonly kind: "field";
|
||||
|
||||
/** The name of the decorated class element. */
|
||||
readonly name: string | symbol;
|
||||
|
||||
/** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
|
||||
readonly static: boolean;
|
||||
|
||||
/** A value indicating whether the class element has a private name. */
|
||||
readonly private: boolean;
|
||||
|
||||
/** An object that can be used to access the current value of the class element at runtime. */
|
||||
readonly access: {
|
||||
/**
|
||||
* Determines whether an object has a property with the same name as the decorated element.
|
||||
*/
|
||||
has(object: This): boolean;
|
||||
|
||||
/**
|
||||
* Gets the value of the field on the provided object.
|
||||
*/
|
||||
get(object: This): Value;
|
||||
|
||||
/**
|
||||
* Sets the value of the field on the provided object.
|
||||
*/
|
||||
set(object: This, value: Value): void;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a callback to be invoked immediately after the field being decorated
|
||||
* is initialized (regardless if the field is `static` or not).
|
||||
*/
|
||||
addInitializer(initializer: (this: This) => void): void;
|
||||
|
||||
readonly metadata: DecoratorMetadata;
|
||||
}
|
||||
22
kitcom/internal/tsgo/bundled/libs/lib.decorators.legacy.d.ts
vendored
Normal file
22
kitcom/internal/tsgo/bundled/libs/lib.decorators.legacy.d.ts
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
|
||||
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
|
||||
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
|
||||
declare type ParameterDecorator = (target: Object, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
|
||||
41
kitcom/internal/tsgo/bundled/libs/lib.dom.asynciterable.d.ts
vendored
Normal file
41
kitcom/internal/tsgo/bundled/libs/lib.dom.asynciterable.d.ts
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/////////////////////////////
|
||||
/// Window Async Iterable APIs
|
||||
/////////////////////////////
|
||||
|
||||
interface FileSystemDirectoryHandleAsyncIterator<T> extends AsyncIteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.asyncIterator](): FileSystemDirectoryHandleAsyncIterator<T>;
|
||||
}
|
||||
|
||||
interface FileSystemDirectoryHandle {
|
||||
[Symbol.asyncIterator](): FileSystemDirectoryHandleAsyncIterator<[string, FileSystemHandle]>;
|
||||
entries(): FileSystemDirectoryHandleAsyncIterator<[string, FileSystemHandle]>;
|
||||
keys(): FileSystemDirectoryHandleAsyncIterator<string>;
|
||||
values(): FileSystemDirectoryHandleAsyncIterator<FileSystemHandle>;
|
||||
}
|
||||
|
||||
interface ReadableStreamAsyncIterator<T> extends AsyncIteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.asyncIterator](): ReadableStreamAsyncIterator<T>;
|
||||
}
|
||||
|
||||
interface ReadableStream<R = any> {
|
||||
[Symbol.asyncIterator](options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
|
||||
values(options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
|
||||
}
|
||||
39429
kitcom/internal/tsgo/bundled/libs/lib.dom.d.ts
vendored
Normal file
39429
kitcom/internal/tsgo/bundled/libs/lib.dom.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
571
kitcom/internal/tsgo/bundled/libs/lib.dom.iterable.d.ts
vendored
Normal file
571
kitcom/internal/tsgo/bundled/libs/lib.dom.iterable.d.ts
vendored
Normal file
@ -0,0 +1,571 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/////////////////////////////
|
||||
/// Window Iterable APIs
|
||||
/////////////////////////////
|
||||
|
||||
interface AudioParam {
|
||||
/**
|
||||
* The **`setValueCurveAtTime()`** method of the following a curve defined by a list of values.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioParam/setValueCurveAtTime)
|
||||
*/
|
||||
setValueCurveAtTime(values: Iterable<number>, startTime: number, duration: number): AudioParam;
|
||||
}
|
||||
|
||||
interface AudioParamMap extends ReadonlyMap<string, AudioParam> {
|
||||
}
|
||||
|
||||
interface BaseAudioContext {
|
||||
/**
|
||||
* The **`createIIRFilter()`** method of the BaseAudioContext interface creates an IIRFilterNode, which represents a general **infinite impulse response** (IIR) filter which can be configured to serve as various types of filter.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createIIRFilter)
|
||||
*/
|
||||
createIIRFilter(feedforward: Iterable<number>, feedback: Iterable<number>): IIRFilterNode;
|
||||
/**
|
||||
* The `createPeriodicWave()` method of the BaseAudioContext interface is used to create a PeriodicWave.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createPeriodicWave)
|
||||
*/
|
||||
createPeriodicWave(real: Iterable<number>, imag: Iterable<number>, constraints?: PeriodicWaveConstraints): PeriodicWave;
|
||||
}
|
||||
|
||||
interface CSSKeyframesRule {
|
||||
[Symbol.iterator](): ArrayIterator<CSSKeyframeRule>;
|
||||
}
|
||||
|
||||
interface CSSNumericArray {
|
||||
[Symbol.iterator](): ArrayIterator<CSSNumericValue>;
|
||||
entries(): ArrayIterator<[number, CSSNumericValue]>;
|
||||
keys(): ArrayIterator<number>;
|
||||
values(): ArrayIterator<CSSNumericValue>;
|
||||
}
|
||||
|
||||
interface CSSRuleList {
|
||||
[Symbol.iterator](): ArrayIterator<CSSRule>;
|
||||
}
|
||||
|
||||
interface CSSStyleDeclaration {
|
||||
[Symbol.iterator](): ArrayIterator<string>;
|
||||
}
|
||||
|
||||
interface CSSTransformValue {
|
||||
[Symbol.iterator](): ArrayIterator<CSSTransformComponent>;
|
||||
entries(): ArrayIterator<[number, CSSTransformComponent]>;
|
||||
keys(): ArrayIterator<number>;
|
||||
values(): ArrayIterator<CSSTransformComponent>;
|
||||
}
|
||||
|
||||
interface CSSUnparsedValue {
|
||||
[Symbol.iterator](): ArrayIterator<CSSUnparsedSegment>;
|
||||
entries(): ArrayIterator<[number, CSSUnparsedSegment]>;
|
||||
keys(): ArrayIterator<number>;
|
||||
values(): ArrayIterator<CSSUnparsedSegment>;
|
||||
}
|
||||
|
||||
interface Cache {
|
||||
/**
|
||||
* The **`addAll()`** method of the Cache interface takes an array of URLs, retrieves them, and adds the resulting response objects to the given cache.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Cache/addAll)
|
||||
*/
|
||||
addAll(requests: Iterable<RequestInfo>): Promise<void>;
|
||||
}
|
||||
|
||||
interface CanvasPath {
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/roundRect) */
|
||||
roundRect(x: number, y: number, w: number, h: number, radii?: number | DOMPointInit | Iterable<number | DOMPointInit>): void;
|
||||
}
|
||||
|
||||
interface CanvasPathDrawingStyles {
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/setLineDash) */
|
||||
setLineDash(segments: Iterable<number>): void;
|
||||
}
|
||||
|
||||
interface CookieStoreManager {
|
||||
/**
|
||||
* The **`subscribe()`** method of the CookieStoreManager interface subscribes a ServiceWorkerRegistration to cookie change events.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CookieStoreManager/subscribe)
|
||||
*/
|
||||
subscribe(subscriptions: Iterable<CookieStoreGetOptions>): Promise<void>;
|
||||
/**
|
||||
* The **`unsubscribe()`** method of the CookieStoreManager interface stops the ServiceWorkerRegistration from receiving previously subscribed events.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CookieStoreManager/unsubscribe)
|
||||
*/
|
||||
unsubscribe(subscriptions: Iterable<CookieStoreGetOptions>): Promise<void>;
|
||||
}
|
||||
|
||||
interface CustomStateSet extends Set<string> {
|
||||
}
|
||||
|
||||
interface DOMRectList {
|
||||
[Symbol.iterator](): ArrayIterator<DOMRect>;
|
||||
}
|
||||
|
||||
interface DOMStringList {
|
||||
[Symbol.iterator](): ArrayIterator<string>;
|
||||
}
|
||||
|
||||
interface DOMTokenList {
|
||||
[Symbol.iterator](): ArrayIterator<string>;
|
||||
entries(): ArrayIterator<[number, string]>;
|
||||
keys(): ArrayIterator<number>;
|
||||
values(): ArrayIterator<string>;
|
||||
}
|
||||
|
||||
interface DataTransferItemList {
|
||||
[Symbol.iterator](): ArrayIterator<DataTransferItem>;
|
||||
}
|
||||
|
||||
interface EventCounts extends ReadonlyMap<string, number> {
|
||||
}
|
||||
|
||||
interface FileList {
|
||||
[Symbol.iterator](): ArrayIterator<File>;
|
||||
}
|
||||
|
||||
interface FontFaceSet extends Set<FontFace> {
|
||||
}
|
||||
|
||||
interface FormDataIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): FormDataIterator<T>;
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
[Symbol.iterator](): FormDataIterator<[string, FormDataEntryValue]>;
|
||||
/** Returns an array of key, value pairs for every entry in the list. */
|
||||
entries(): FormDataIterator<[string, FormDataEntryValue]>;
|
||||
/** Returns a list of keys in the list. */
|
||||
keys(): FormDataIterator<string>;
|
||||
/** Returns a list of values in the list. */
|
||||
values(): FormDataIterator<FormDataEntryValue>;
|
||||
}
|
||||
|
||||
interface HTMLAllCollection {
|
||||
[Symbol.iterator](): ArrayIterator<Element>;
|
||||
}
|
||||
|
||||
interface HTMLCollectionBase {
|
||||
[Symbol.iterator](): ArrayIterator<Element>;
|
||||
}
|
||||
|
||||
interface HTMLCollectionOf<T extends Element> {
|
||||
[Symbol.iterator](): ArrayIterator<T>;
|
||||
}
|
||||
|
||||
interface HTMLFormElement {
|
||||
[Symbol.iterator](): ArrayIterator<Element>;
|
||||
}
|
||||
|
||||
interface HTMLSelectElement {
|
||||
[Symbol.iterator](): ArrayIterator<HTMLOptionElement>;
|
||||
}
|
||||
|
||||
interface HeadersIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): HeadersIterator<T>;
|
||||
}
|
||||
|
||||
interface Headers {
|
||||
[Symbol.iterator](): HeadersIterator<[string, string]>;
|
||||
/** Returns an iterator allowing to go through all key/value pairs contained in this object. */
|
||||
entries(): HeadersIterator<[string, string]>;
|
||||
/** Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
|
||||
keys(): HeadersIterator<string>;
|
||||
/** Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
|
||||
values(): HeadersIterator<string>;
|
||||
}
|
||||
|
||||
interface Highlight extends Set<AbstractRange> {
|
||||
}
|
||||
|
||||
interface HighlightRegistry extends Map<string, Highlight> {
|
||||
}
|
||||
|
||||
interface IDBDatabase {
|
||||
/**
|
||||
* The **`transaction`** method of the IDBDatabase interface immediately returns a transaction object (IDBTransaction) containing the IDBTransaction.objectStore method, which you can use to access your object store.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBDatabase/transaction)
|
||||
*/
|
||||
transaction(storeNames: string | Iterable<string>, mode?: IDBTransactionMode, options?: IDBTransactionOptions): IDBTransaction;
|
||||
}
|
||||
|
||||
interface IDBObjectStore {
|
||||
/**
|
||||
* The **`createIndex()`** method of the field/column defining a new data point for each database record to contain.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBObjectStore/createIndex)
|
||||
*/
|
||||
createIndex(name: string, keyPath: string | Iterable<string>, options?: IDBIndexParameters): IDBIndex;
|
||||
}
|
||||
|
||||
interface ImageTrackList {
|
||||
[Symbol.iterator](): ArrayIterator<ImageTrack>;
|
||||
}
|
||||
|
||||
interface MIDIInputMap extends ReadonlyMap<string, MIDIInput> {
|
||||
}
|
||||
|
||||
interface MIDIOutput {
|
||||
/**
|
||||
* The **`send()`** method of the MIDIOutput interface queues messages for the corresponding MIDI port.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MIDIOutput/send)
|
||||
*/
|
||||
send(data: Iterable<number>, timestamp?: DOMHighResTimeStamp): void;
|
||||
}
|
||||
|
||||
interface MIDIOutputMap extends ReadonlyMap<string, MIDIOutput> {
|
||||
}
|
||||
|
||||
interface MediaKeyStatusMapIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): MediaKeyStatusMapIterator<T>;
|
||||
}
|
||||
|
||||
interface MediaKeyStatusMap {
|
||||
[Symbol.iterator](): MediaKeyStatusMapIterator<[BufferSource, MediaKeyStatus]>;
|
||||
entries(): MediaKeyStatusMapIterator<[BufferSource, MediaKeyStatus]>;
|
||||
keys(): MediaKeyStatusMapIterator<BufferSource>;
|
||||
values(): MediaKeyStatusMapIterator<MediaKeyStatus>;
|
||||
}
|
||||
|
||||
interface MediaList {
|
||||
[Symbol.iterator](): ArrayIterator<string>;
|
||||
}
|
||||
|
||||
interface MessageEvent<T = any> {
|
||||
/** @deprecated */
|
||||
initMessageEvent(type: string, bubbles?: boolean, cancelable?: boolean, data?: any, origin?: string, lastEventId?: string, source?: MessageEventSource | null, ports?: Iterable<MessagePort>): void;
|
||||
}
|
||||
|
||||
interface MimeTypeArray {
|
||||
[Symbol.iterator](): ArrayIterator<MimeType>;
|
||||
}
|
||||
|
||||
interface NamedNodeMap {
|
||||
[Symbol.iterator](): ArrayIterator<Attr>;
|
||||
}
|
||||
|
||||
interface Navigator {
|
||||
/**
|
||||
* The **`requestMediaKeySystemAccess()`** method of the Navigator interface returns a Promise which delivers a MediaKeySystemAccess object that can be used to access a particular media key system, which can in turn be used to create keys for decrypting a media stream.
|
||||
* Available only in secure contexts.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Navigator/requestMediaKeySystemAccess)
|
||||
*/
|
||||
requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: Iterable<MediaKeySystemConfiguration>): Promise<MediaKeySystemAccess>;
|
||||
/**
|
||||
* The **`vibrate()`** method of the Navigator interface pulses the vibration hardware on the device, if such hardware exists.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Navigator/vibrate)
|
||||
*/
|
||||
vibrate(pattern: Iterable<number>): boolean;
|
||||
}
|
||||
|
||||
interface NodeList {
|
||||
[Symbol.iterator](): ArrayIterator<Node>;
|
||||
/** Returns an array of key, value pairs for every entry in the list. */
|
||||
entries(): ArrayIterator<[number, Node]>;
|
||||
/** Returns an list of keys in the list. */
|
||||
keys(): ArrayIterator<number>;
|
||||
/** Returns an list of values in the list. */
|
||||
values(): ArrayIterator<Node>;
|
||||
}
|
||||
|
||||
interface NodeListOf<TNode extends Node> {
|
||||
[Symbol.iterator](): ArrayIterator<TNode>;
|
||||
/** Returns an array of key, value pairs for every entry in the list. */
|
||||
entries(): ArrayIterator<[number, TNode]>;
|
||||
/** Returns an list of keys in the list. */
|
||||
keys(): ArrayIterator<number>;
|
||||
/** Returns an list of values in the list. */
|
||||
values(): ArrayIterator<TNode>;
|
||||
}
|
||||
|
||||
interface Plugin {
|
||||
[Symbol.iterator](): ArrayIterator<MimeType>;
|
||||
}
|
||||
|
||||
interface PluginArray {
|
||||
[Symbol.iterator](): ArrayIterator<Plugin>;
|
||||
}
|
||||
|
||||
interface RTCRtpTransceiver {
|
||||
/**
|
||||
* The **`setCodecPreferences()`** method of the RTCRtpTransceiver interface is used to set the codecs that the transceiver allows for decoding _received_ data, in order of decreasing preference.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/RTCRtpTransceiver/setCodecPreferences)
|
||||
*/
|
||||
setCodecPreferences(codecs: Iterable<RTCRtpCodec>): void;
|
||||
}
|
||||
|
||||
interface RTCStatsReport extends ReadonlyMap<string, any> {
|
||||
}
|
||||
|
||||
interface SVGLengthList {
|
||||
[Symbol.iterator](): ArrayIterator<SVGLength>;
|
||||
}
|
||||
|
||||
interface SVGNumberList {
|
||||
[Symbol.iterator](): ArrayIterator<SVGNumber>;
|
||||
}
|
||||
|
||||
interface SVGPointList {
|
||||
[Symbol.iterator](): ArrayIterator<DOMPoint>;
|
||||
}
|
||||
|
||||
interface SVGStringList {
|
||||
[Symbol.iterator](): ArrayIterator<string>;
|
||||
}
|
||||
|
||||
interface SVGTransformList {
|
||||
[Symbol.iterator](): ArrayIterator<SVGTransform>;
|
||||
}
|
||||
|
||||
interface SourceBufferList {
|
||||
[Symbol.iterator](): ArrayIterator<SourceBuffer>;
|
||||
}
|
||||
|
||||
interface SpeechRecognitionResult {
|
||||
[Symbol.iterator](): ArrayIterator<SpeechRecognitionAlternative>;
|
||||
}
|
||||
|
||||
interface SpeechRecognitionResultList {
|
||||
[Symbol.iterator](): ArrayIterator<SpeechRecognitionResult>;
|
||||
}
|
||||
|
||||
interface StylePropertyMapReadOnlyIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): StylePropertyMapReadOnlyIterator<T>;
|
||||
}
|
||||
|
||||
interface StylePropertyMapReadOnly {
|
||||
[Symbol.iterator](): StylePropertyMapReadOnlyIterator<[string, Iterable<CSSStyleValue>]>;
|
||||
entries(): StylePropertyMapReadOnlyIterator<[string, Iterable<CSSStyleValue>]>;
|
||||
keys(): StylePropertyMapReadOnlyIterator<string>;
|
||||
values(): StylePropertyMapReadOnlyIterator<Iterable<CSSStyleValue>>;
|
||||
}
|
||||
|
||||
interface StyleSheetList {
|
||||
[Symbol.iterator](): ArrayIterator<CSSStyleSheet>;
|
||||
}
|
||||
|
||||
interface SubtleCrypto {
|
||||
/**
|
||||
* The **`deriveKey()`** method of the SubtleCrypto interface can be used to derive a secret key from a master key.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey)
|
||||
*/
|
||||
deriveKey(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKey>;
|
||||
/**
|
||||
* The **`generateKey()`** method of the SubtleCrypto interface is used to generate a new key (for symmetric algorithms) or key pair (for public-key algorithms).
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey)
|
||||
*/
|
||||
generateKey(algorithm: "Ed25519" | { name: "Ed25519" }, extractable: boolean, keyUsages: ReadonlyArray<"sign" | "verify">): Promise<CryptoKeyPair>;
|
||||
generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>;
|
||||
generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>;
|
||||
generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKeyPair | CryptoKey>;
|
||||
/**
|
||||
* The **`importKey()`** method of the SubtleCrypto interface imports a key: that is, it takes as input a key in an external, portable format and gives you a CryptoKey object that you can use in the Web Crypto API.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey)
|
||||
*/
|
||||
importKey(format: "jwk", keyData: JsonWebKey, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>;
|
||||
importKey(format: Exclude<KeyFormat, "jwk">, keyData: BufferSource, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKey>;
|
||||
/**
|
||||
* The **`unwrapKey()`** method of the SubtleCrypto interface 'unwraps' a key.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey)
|
||||
*/
|
||||
unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, unwrappedKeyAlgorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKey>;
|
||||
}
|
||||
|
||||
interface TextTrackCueList {
|
||||
[Symbol.iterator](): ArrayIterator<TextTrackCue>;
|
||||
}
|
||||
|
||||
interface TextTrackList {
|
||||
[Symbol.iterator](): ArrayIterator<TextTrack>;
|
||||
}
|
||||
|
||||
interface TouchList {
|
||||
[Symbol.iterator](): ArrayIterator<Touch>;
|
||||
}
|
||||
|
||||
interface URLSearchParamsIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): URLSearchParamsIterator<T>;
|
||||
}
|
||||
|
||||
interface URLSearchParams {
|
||||
[Symbol.iterator](): URLSearchParamsIterator<[string, string]>;
|
||||
/** Returns an array of key, value pairs for every entry in the search params. */
|
||||
entries(): URLSearchParamsIterator<[string, string]>;
|
||||
/** Returns a list of keys in the search params. */
|
||||
keys(): URLSearchParamsIterator<string>;
|
||||
/** Returns a list of values in the search params. */
|
||||
values(): URLSearchParamsIterator<string>;
|
||||
}
|
||||
|
||||
interface ViewTransitionTypeSet extends Set<string> {
|
||||
}
|
||||
|
||||
interface WEBGL_draw_buffers {
|
||||
/**
|
||||
* The **`WEBGL_draw_buffers.drawBuffersWEBGL()`** method is part of the WebGL API and allows you to define the draw buffers to which all fragment colors are written.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WEBGL_draw_buffers/drawBuffersWEBGL)
|
||||
*/
|
||||
drawBuffersWEBGL(buffers: Iterable<GLenum>): void;
|
||||
}
|
||||
|
||||
interface WEBGL_multi_draw {
|
||||
/**
|
||||
* The **`WEBGL_multi_draw.multiDrawArraysInstancedWEBGL()`** method of the WebGL API renders multiple primitives from array data.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WEBGL_multi_draw/multiDrawArraysInstancedWEBGL)
|
||||
*/
|
||||
multiDrawArraysInstancedWEBGL(mode: GLenum, firstsList: Int32Array<ArrayBufferLike> | Iterable<GLint>, firstsOffset: number, countsList: Int32Array<ArrayBufferLike> | Iterable<GLsizei>, countsOffset: number, instanceCountsList: Int32Array<ArrayBufferLike> | Iterable<GLsizei>, instanceCountsOffset: number, drawcount: GLsizei): void;
|
||||
/**
|
||||
* The **`WEBGL_multi_draw.multiDrawArraysWEBGL()`** method of the WebGL API renders multiple primitives from array data.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WEBGL_multi_draw/multiDrawArraysWEBGL)
|
||||
*/
|
||||
multiDrawArraysWEBGL(mode: GLenum, firstsList: Int32Array<ArrayBufferLike> | Iterable<GLint>, firstsOffset: number, countsList: Int32Array<ArrayBufferLike> | Iterable<GLsizei>, countsOffset: number, drawcount: GLsizei): void;
|
||||
/**
|
||||
* The **`WEBGL_multi_draw.multiDrawElementsInstancedWEBGL()`** method of the WebGL API renders multiple primitives from array data.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WEBGL_multi_draw/multiDrawElementsInstancedWEBGL)
|
||||
*/
|
||||
multiDrawElementsInstancedWEBGL(mode: GLenum, countsList: Int32Array<ArrayBufferLike> | Iterable<GLsizei>, countsOffset: number, type: GLenum, offsetsList: Int32Array<ArrayBufferLike> | Iterable<GLsizei>, offsetsOffset: number, instanceCountsList: Int32Array<ArrayBufferLike> | Iterable<GLsizei>, instanceCountsOffset: number, drawcount: GLsizei): void;
|
||||
/**
|
||||
* The **`WEBGL_multi_draw.multiDrawElementsWEBGL()`** method of the WebGL API renders multiple primitives from array data.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WEBGL_multi_draw/multiDrawElementsWEBGL)
|
||||
*/
|
||||
multiDrawElementsWEBGL(mode: GLenum, countsList: Int32Array<ArrayBufferLike> | Iterable<GLsizei>, countsOffset: number, type: GLenum, offsetsList: Int32Array<ArrayBufferLike> | Iterable<GLsizei>, offsetsOffset: number, drawcount: GLsizei): void;
|
||||
}
|
||||
|
||||
interface WebGL2RenderingContextBase {
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/clearBuffer) */
|
||||
clearBufferfv(buffer: GLenum, drawbuffer: GLint, values: Iterable<GLfloat>, srcOffset?: number): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/clearBuffer) */
|
||||
clearBufferiv(buffer: GLenum, drawbuffer: GLint, values: Iterable<GLint>, srcOffset?: number): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/clearBuffer) */
|
||||
clearBufferuiv(buffer: GLenum, drawbuffer: GLint, values: Iterable<GLuint>, srcOffset?: number): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/drawBuffers) */
|
||||
drawBuffers(buffers: Iterable<GLenum>): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/getActiveUniforms) */
|
||||
getActiveUniforms(program: WebGLProgram, uniformIndices: Iterable<GLuint>, pname: GLenum): any;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/getUniformIndices) */
|
||||
getUniformIndices(program: WebGLProgram, uniformNames: Iterable<string>): GLuint[] | null;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/invalidateFramebuffer) */
|
||||
invalidateFramebuffer(target: GLenum, attachments: Iterable<GLenum>): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/invalidateSubFramebuffer) */
|
||||
invalidateSubFramebuffer(target: GLenum, attachments: Iterable<GLenum>, x: GLint, y: GLint, width: GLsizei, height: GLsizei): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings) */
|
||||
transformFeedbackVaryings(program: WebGLProgram, varyings: Iterable<string>, bufferMode: GLenum): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniform) */
|
||||
uniform1uiv(location: WebGLUniformLocation | null, data: Iterable<GLuint>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniform) */
|
||||
uniform2uiv(location: WebGLUniformLocation | null, data: Iterable<GLuint>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniform) */
|
||||
uniform3uiv(location: WebGLUniformLocation | null, data: Iterable<GLuint>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniform) */
|
||||
uniform4uiv(location: WebGLUniformLocation | null, data: Iterable<GLuint>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniformMatrix) */
|
||||
uniformMatrix2x3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniformMatrix) */
|
||||
uniformMatrix2x4fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniformMatrix) */
|
||||
uniformMatrix3x2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniformMatrix) */
|
||||
uniformMatrix3x4fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniformMatrix) */
|
||||
uniformMatrix4x2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniformMatrix) */
|
||||
uniformMatrix4x3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/vertexAttribI) */
|
||||
vertexAttribI4iv(index: GLuint, values: Iterable<GLint>): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/vertexAttribI) */
|
||||
vertexAttribI4uiv(index: GLuint, values: Iterable<GLuint>): void;
|
||||
}
|
||||
|
||||
interface WebGL2RenderingContextOverloads {
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
|
||||
uniform1fv(location: WebGLUniformLocation | null, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
|
||||
uniform1iv(location: WebGLUniformLocation | null, data: Iterable<GLint>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
|
||||
uniform2fv(location: WebGLUniformLocation | null, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
|
||||
uniform2iv(location: WebGLUniformLocation | null, data: Iterable<GLint>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
|
||||
uniform3fv(location: WebGLUniformLocation | null, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
|
||||
uniform3iv(location: WebGLUniformLocation | null, data: Iterable<GLint>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
|
||||
uniform4fv(location: WebGLUniformLocation | null, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
|
||||
uniform4iv(location: WebGLUniformLocation | null, data: Iterable<GLint>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniformMatrix) */
|
||||
uniformMatrix2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniformMatrix) */
|
||||
uniformMatrix3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniformMatrix) */
|
||||
uniformMatrix4fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
|
||||
}
|
||||
|
||||
interface WebGLRenderingContextBase {
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/vertexAttrib) */
|
||||
vertexAttrib1fv(index: GLuint, values: Iterable<GLfloat>): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/vertexAttrib) */
|
||||
vertexAttrib2fv(index: GLuint, values: Iterable<GLfloat>): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/vertexAttrib) */
|
||||
vertexAttrib3fv(index: GLuint, values: Iterable<GLfloat>): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/vertexAttrib) */
|
||||
vertexAttrib4fv(index: GLuint, values: Iterable<GLfloat>): void;
|
||||
}
|
||||
|
||||
interface WebGLRenderingContextOverloads {
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
|
||||
uniform1fv(location: WebGLUniformLocation | null, v: Iterable<GLfloat>): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
|
||||
uniform1iv(location: WebGLUniformLocation | null, v: Iterable<GLint>): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
|
||||
uniform2fv(location: WebGLUniformLocation | null, v: Iterable<GLfloat>): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
|
||||
uniform2iv(location: WebGLUniformLocation | null, v: Iterable<GLint>): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
|
||||
uniform3fv(location: WebGLUniformLocation | null, v: Iterable<GLfloat>): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
|
||||
uniform3iv(location: WebGLUniformLocation | null, v: Iterable<GLint>): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
|
||||
uniform4fv(location: WebGLUniformLocation | null, v: Iterable<GLfloat>): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
|
||||
uniform4iv(location: WebGLUniformLocation | null, v: Iterable<GLint>): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniformMatrix) */
|
||||
uniformMatrix2fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Iterable<GLfloat>): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniformMatrix) */
|
||||
uniformMatrix3fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Iterable<GLfloat>): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniformMatrix) */
|
||||
uniformMatrix4fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Iterable<GLfloat>): void;
|
||||
}
|
||||
147
kitcom/internal/tsgo/bundled/libs/lib.es2015.collection.d.ts
vendored
Normal file
147
kitcom/internal/tsgo/bundled/libs/lib.es2015.collection.d.ts
vendored
Normal file
@ -0,0 +1,147 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
interface Map<K, V> {
|
||||
clear(): void;
|
||||
/**
|
||||
* @returns true if an element in the Map existed and has been removed, or false if the element does not exist.
|
||||
*/
|
||||
delete(key: K): boolean;
|
||||
/**
|
||||
* Executes a provided function once per each key/value pair in the Map, in insertion order.
|
||||
*/
|
||||
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
|
||||
/**
|
||||
* Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
|
||||
* @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
|
||||
*/
|
||||
get(key: K): V | undefined;
|
||||
/**
|
||||
* @returns boolean indicating whether an element with the specified key exists or not.
|
||||
*/
|
||||
has(key: K): boolean;
|
||||
/**
|
||||
* Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.
|
||||
*/
|
||||
set(key: K, value: V): this;
|
||||
/**
|
||||
* @returns the number of elements in the Map.
|
||||
*/
|
||||
readonly size: number;
|
||||
}
|
||||
|
||||
interface MapConstructor {
|
||||
new (): Map<any, any>;
|
||||
new <K, V>(entries?: readonly (readonly [K, V])[] | null): Map<K, V>;
|
||||
readonly prototype: Map<any, any>;
|
||||
}
|
||||
declare var Map: MapConstructor;
|
||||
|
||||
interface ReadonlyMap<K, V> {
|
||||
forEach(callbackfn: (value: V, key: K, map: ReadonlyMap<K, V>) => void, thisArg?: any): void;
|
||||
get(key: K): V | undefined;
|
||||
has(key: K): boolean;
|
||||
readonly size: number;
|
||||
}
|
||||
|
||||
interface WeakMap<K extends WeakKey, V> {
|
||||
/**
|
||||
* Removes the specified element from the WeakMap.
|
||||
* @returns true if the element was successfully removed, or false if it was not present.
|
||||
*/
|
||||
delete(key: K): boolean;
|
||||
/**
|
||||
* @returns a specified element.
|
||||
*/
|
||||
get(key: K): V | undefined;
|
||||
/**
|
||||
* @returns a boolean indicating whether an element with the specified key exists or not.
|
||||
*/
|
||||
has(key: K): boolean;
|
||||
/**
|
||||
* Adds a new element with a specified key and value.
|
||||
* @param key Must be an object or symbol.
|
||||
*/
|
||||
set(key: K, value: V): this;
|
||||
}
|
||||
|
||||
interface WeakMapConstructor {
|
||||
new <K extends WeakKey = WeakKey, V = any>(entries?: readonly (readonly [K, V])[] | null): WeakMap<K, V>;
|
||||
readonly prototype: WeakMap<WeakKey, any>;
|
||||
}
|
||||
declare var WeakMap: WeakMapConstructor;
|
||||
|
||||
interface Set<T> {
|
||||
/**
|
||||
* Appends a new element with a specified value to the end of the Set.
|
||||
*/
|
||||
add(value: T): this;
|
||||
|
||||
clear(): void;
|
||||
/**
|
||||
* Removes a specified value from the Set.
|
||||
* @returns Returns true if an element in the Set existed and has been removed, or false if the element does not exist.
|
||||
*/
|
||||
delete(value: T): boolean;
|
||||
/**
|
||||
* Executes a provided function once per each value in the Set object, in insertion order.
|
||||
*/
|
||||
forEach(callbackfn: (value: T, value2: T, set: Set<T>) => void, thisArg?: any): void;
|
||||
/**
|
||||
* @returns a boolean indicating whether an element with the specified value exists in the Set or not.
|
||||
*/
|
||||
has(value: T): boolean;
|
||||
/**
|
||||
* @returns the number of (unique) elements in Set.
|
||||
*/
|
||||
readonly size: number;
|
||||
}
|
||||
|
||||
interface SetConstructor {
|
||||
new <T = any>(values?: readonly T[] | null): Set<T>;
|
||||
readonly prototype: Set<any>;
|
||||
}
|
||||
declare var Set: SetConstructor;
|
||||
|
||||
interface ReadonlySet<T> {
|
||||
forEach(callbackfn: (value: T, value2: T, set: ReadonlySet<T>) => void, thisArg?: any): void;
|
||||
has(value: T): boolean;
|
||||
readonly size: number;
|
||||
}
|
||||
|
||||
interface WeakSet<T extends WeakKey> {
|
||||
/**
|
||||
* Appends a new value to the end of the WeakSet.
|
||||
*/
|
||||
add(value: T): this;
|
||||
/**
|
||||
* Removes the specified element from the WeakSet.
|
||||
* @returns Returns true if the element existed and has been removed, or false if the element does not exist.
|
||||
*/
|
||||
delete(value: T): boolean;
|
||||
/**
|
||||
* @returns a boolean indicating whether a value exists in the WeakSet or not.
|
||||
*/
|
||||
has(value: T): boolean;
|
||||
}
|
||||
|
||||
interface WeakSetConstructor {
|
||||
new <T extends WeakKey = WeakKey>(values?: readonly T[] | null): WeakSet<T>;
|
||||
readonly prototype: WeakSet<WeakKey>;
|
||||
}
|
||||
declare var WeakSet: WeakSetConstructor;
|
||||
597
kitcom/internal/tsgo/bundled/libs/lib.es2015.core.d.ts
vendored
Normal file
597
kitcom/internal/tsgo/bundled/libs/lib.es2015.core.d.ts
vendored
Normal file
@ -0,0 +1,597 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
interface Array<T> {
|
||||
/**
|
||||
* Returns the value of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
find<S extends T>(predicate: (value: T, index: number, obj: T[]) => value is S, thisArg?: any): S | undefined;
|
||||
find(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): T | undefined;
|
||||
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Changes all array elements from `start` to `end` index to a static `value` and returns the modified array
|
||||
* @param value value to fill array section with
|
||||
* @param start index to start filling the array at. If start is negative, it is treated as
|
||||
* length+start where length is the length of the array.
|
||||
* @param end index to stop filling the array at. If end is negative, it is treated as
|
||||
* length+end.
|
||||
*/
|
||||
fill(value: T, start?: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Returns the this object after copying a section of the array identified by start and end
|
||||
* to the same array starting at position target
|
||||
* @param target If target is negative, it is treated as length+target where length is the
|
||||
* length of the array.
|
||||
* @param start If start is negative, it is treated as length+start. If end is negative, it
|
||||
* is treated as length+end.
|
||||
* @param end If not specified, length of the this object is used as its default value.
|
||||
*/
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
|
||||
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string;
|
||||
}
|
||||
|
||||
interface ArrayConstructor {
|
||||
/**
|
||||
* Creates an array from an array-like object.
|
||||
* @param arrayLike An array-like object to convert to an array.
|
||||
*/
|
||||
from<T>(arrayLike: ArrayLike<T>): T[];
|
||||
|
||||
/**
|
||||
* Creates an array from an iterable object.
|
||||
* @param arrayLike An array-like object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
||||
|
||||
/**
|
||||
* Returns a new array from a set of elements.
|
||||
* @param items A set of elements to include in the new array object.
|
||||
*/
|
||||
of<T>(...items: T[]): T[];
|
||||
}
|
||||
|
||||
interface DateConstructor {
|
||||
new (value: number | string | Date): Date;
|
||||
}
|
||||
|
||||
interface Function {
|
||||
/**
|
||||
* Returns the name of the function. Function names are read-only and can not be changed.
|
||||
*/
|
||||
readonly name: string;
|
||||
}
|
||||
|
||||
interface Math {
|
||||
/**
|
||||
* Returns the number of leading zero bits in the 32-bit binary representation of a number.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
clz32(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the result of 32-bit multiplication of two numbers.
|
||||
* @param x First number
|
||||
* @param y Second number
|
||||
*/
|
||||
imul(x: number, y: number): number;
|
||||
|
||||
/**
|
||||
* Returns the sign of the x, indicating whether x is positive, negative or zero.
|
||||
* @param x The numeric expression to test
|
||||
*/
|
||||
sign(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the base 10 logarithm of a number.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
log10(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the base 2 logarithm of a number.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
log2(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the natural logarithm of 1 + x.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
log1p(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the result of (e^x - 1), which is an implementation-dependent approximation to
|
||||
* subtracting 1 from the exponential function of x (e raised to the power of x, where e
|
||||
* is the base of the natural logarithms).
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
expm1(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the hyperbolic cosine of a number.
|
||||
* @param x A numeric expression that contains an angle measured in radians.
|
||||
*/
|
||||
cosh(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the hyperbolic sine of a number.
|
||||
* @param x A numeric expression that contains an angle measured in radians.
|
||||
*/
|
||||
sinh(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the hyperbolic tangent of a number.
|
||||
* @param x A numeric expression that contains an angle measured in radians.
|
||||
*/
|
||||
tanh(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the inverse hyperbolic cosine of a number.
|
||||
* @param x A numeric expression that contains an angle measured in radians.
|
||||
*/
|
||||
acosh(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the inverse hyperbolic sine of a number.
|
||||
* @param x A numeric expression that contains an angle measured in radians.
|
||||
*/
|
||||
asinh(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the inverse hyperbolic tangent of a number.
|
||||
* @param x A numeric expression that contains an angle measured in radians.
|
||||
*/
|
||||
atanh(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the square root of the sum of squares of its arguments.
|
||||
* @param values Values to compute the square root for.
|
||||
* If no arguments are passed, the result is +0.
|
||||
* If there is only one argument, the result is the absolute value.
|
||||
* If any argument is +Infinity or -Infinity, the result is +Infinity.
|
||||
* If any argument is NaN, the result is NaN.
|
||||
* If all arguments are either +0 or −0, the result is +0.
|
||||
*/
|
||||
hypot(...values: number[]): number;
|
||||
|
||||
/**
|
||||
* Returns the integral part of the a numeric expression, x, removing any fractional digits.
|
||||
* If x is already an integer, the result is x.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
trunc(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the nearest single precision float representation of a number.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
fround(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns an implementation-dependent approximation to the cube root of number.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
cbrt(x: number): number;
|
||||
}
|
||||
|
||||
interface NumberConstructor {
|
||||
/**
|
||||
* The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1
|
||||
* that is representable as a Number value, which is approximately:
|
||||
* 2.2204460492503130808472633361816 x 10−16.
|
||||
*/
|
||||
readonly EPSILON: number;
|
||||
|
||||
/**
|
||||
* Returns true if passed value is finite.
|
||||
* Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a
|
||||
* number. Only finite values of the type number, result in true.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
isFinite(number: unknown): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the value passed is an integer, false otherwise.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
isInteger(number: unknown): boolean;
|
||||
|
||||
/**
|
||||
* Returns a Boolean value that indicates whether a value is the reserved value NaN (not a
|
||||
* number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter
|
||||
* to a number. Only values of the type number, that are also NaN, result in true.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
isNaN(number: unknown): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the value passed is a safe integer.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
isSafeInteger(number: unknown): boolean;
|
||||
|
||||
/**
|
||||
* The value of the largest integer n such that n and n + 1 are both exactly representable as
|
||||
* a Number value.
|
||||
* The value of Number.MAX_SAFE_INTEGER is 9007199254740991 2^53 − 1.
|
||||
*/
|
||||
readonly MAX_SAFE_INTEGER: number;
|
||||
|
||||
/**
|
||||
* The value of the smallest integer n such that n and n − 1 are both exactly representable as
|
||||
* a Number value.
|
||||
* The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)).
|
||||
*/
|
||||
readonly MIN_SAFE_INTEGER: number;
|
||||
|
||||
/**
|
||||
* Converts a string to a floating-point number.
|
||||
* @param string A string that contains a floating-point number.
|
||||
*/
|
||||
parseFloat(string: string): number;
|
||||
|
||||
/**
|
||||
* Converts A string to an integer.
|
||||
* @param string A string to convert into a number.
|
||||
* @param radix A value between 2 and 36 that specifies the base of the number in `string`.
|
||||
* If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
|
||||
* All other strings are considered decimal.
|
||||
*/
|
||||
parseInt(string: string, radix?: number): number;
|
||||
}
|
||||
|
||||
interface ObjectConstructor {
|
||||
/**
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param source The source object from which to copy properties.
|
||||
*/
|
||||
assign<T extends {}, U>(target: T, source: U): T & U;
|
||||
|
||||
/**
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param source1 The first source object from which to copy properties.
|
||||
* @param source2 The second source object from which to copy properties.
|
||||
*/
|
||||
assign<T extends {}, U, V>(target: T, source1: U, source2: V): T & U & V;
|
||||
|
||||
/**
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param source1 The first source object from which to copy properties.
|
||||
* @param source2 The second source object from which to copy properties.
|
||||
* @param source3 The third source object from which to copy properties.
|
||||
*/
|
||||
assign<T extends {}, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
|
||||
|
||||
/**
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param sources One or more source objects from which to copy properties
|
||||
*/
|
||||
assign(target: object, ...sources: any[]): any;
|
||||
|
||||
/**
|
||||
* Returns an array of all symbol properties found directly on object o.
|
||||
* @param o Object to retrieve the symbols from.
|
||||
*/
|
||||
getOwnPropertySymbols(o: any): symbol[];
|
||||
|
||||
/**
|
||||
* Returns the names of the enumerable string properties and methods of an object.
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
keys(o: {}): string[];
|
||||
|
||||
/**
|
||||
* Returns true if the values are the same value, false otherwise.
|
||||
* @param value1 The first value.
|
||||
* @param value2 The second value.
|
||||
*/
|
||||
is(value1: any, value2: any): boolean;
|
||||
|
||||
/**
|
||||
* Sets the prototype of a specified object o to object proto or null. Returns the object o.
|
||||
* @param o The object to change its prototype.
|
||||
* @param proto The value of the new prototype or null.
|
||||
*/
|
||||
setPrototypeOf(o: any, proto: object | null): any;
|
||||
}
|
||||
|
||||
interface ReadonlyArray<T> {
|
||||
/**
|
||||
* Returns the value of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
find<S extends T>(predicate: (value: T, index: number, obj: readonly T[]) => value is S, thisArg?: any): S | undefined;
|
||||
find(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): T | undefined;
|
||||
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): number;
|
||||
|
||||
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string;
|
||||
}
|
||||
|
||||
interface RegExp {
|
||||
/**
|
||||
* Returns a string indicating the flags of the regular expression in question. This field is read-only.
|
||||
* The characters in this string are sequenced and concatenated in the following order:
|
||||
*
|
||||
* - "g" for global
|
||||
* - "i" for ignoreCase
|
||||
* - "m" for multiline
|
||||
* - "u" for unicode
|
||||
* - "y" for sticky
|
||||
*
|
||||
* If no flags are set, the value is the empty string.
|
||||
*/
|
||||
readonly flags: string;
|
||||
|
||||
/**
|
||||
* Returns a Boolean value indicating the state of the sticky flag (y) used with a regular
|
||||
* expression. Default is false. Read-only.
|
||||
*/
|
||||
readonly sticky: boolean;
|
||||
|
||||
/**
|
||||
* Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular
|
||||
* expression. Default is false. Read-only.
|
||||
*/
|
||||
readonly unicode: boolean;
|
||||
}
|
||||
|
||||
interface RegExpConstructor {
|
||||
new (pattern: RegExp | string, flags?: string): RegExp;
|
||||
(pattern: RegExp | string, flags?: string): RegExp;
|
||||
}
|
||||
|
||||
interface String {
|
||||
/**
|
||||
* Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
|
||||
* value of the UTF-16 encoded code point starting at the string element at position pos in
|
||||
* the String resulting from converting this object to a String.
|
||||
* If there is no element at that position, the result is undefined.
|
||||
* If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
|
||||
*/
|
||||
codePointAt(pos: number): number | undefined;
|
||||
|
||||
/**
|
||||
* Returns true if searchString appears as a substring of the result of converting this
|
||||
* object to a String, at one or more positions that are
|
||||
* greater than or equal to position; otherwise, returns false.
|
||||
* @param searchString search string
|
||||
* @param position If position is undefined, 0 is assumed, so as to search all of the String.
|
||||
*/
|
||||
includes(searchString: string, position?: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the sequence of elements of searchString converted to a String is the
|
||||
* same as the corresponding elements of this object (converted to a String) starting at
|
||||
* endPosition – length(this). Otherwise returns false.
|
||||
*/
|
||||
endsWith(searchString: string, endPosition?: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns the String value result of normalizing the string into the normalization form
|
||||
* named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
|
||||
* @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
|
||||
* is "NFC"
|
||||
*/
|
||||
normalize(form: "NFC" | "NFD" | "NFKC" | "NFKD"): string;
|
||||
|
||||
/**
|
||||
* Returns the String value result of normalizing the string into the normalization form
|
||||
* named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
|
||||
* @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
|
||||
* is "NFC"
|
||||
*/
|
||||
normalize(form?: string): string;
|
||||
|
||||
/**
|
||||
* Returns a String value that is made from count copies appended together. If count is 0,
|
||||
* the empty string is returned.
|
||||
* @param count number of copies to append
|
||||
*/
|
||||
repeat(count: number): string;
|
||||
|
||||
/**
|
||||
* Returns true if the sequence of elements of searchString converted to a String is the
|
||||
* same as the corresponding elements of this object (converted to a String) starting at
|
||||
* position. Otherwise returns false.
|
||||
*/
|
||||
startsWith(searchString: string, position?: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns an `<a>` HTML anchor element and sets the name attribute to the text value
|
||||
* @deprecated A legacy feature for browser compatibility
|
||||
* @param name
|
||||
*/
|
||||
anchor(name: string): string;
|
||||
|
||||
/**
|
||||
* Returns a `<big>` HTML element
|
||||
* @deprecated A legacy feature for browser compatibility
|
||||
*/
|
||||
big(): string;
|
||||
|
||||
/**
|
||||
* Returns a `<blink>` HTML element
|
||||
* @deprecated A legacy feature for browser compatibility
|
||||
*/
|
||||
blink(): string;
|
||||
|
||||
/**
|
||||
* Returns a `<b>` HTML element
|
||||
* @deprecated A legacy feature for browser compatibility
|
||||
*/
|
||||
bold(): string;
|
||||
|
||||
/**
|
||||
* Returns a `<tt>` HTML element
|
||||
* @deprecated A legacy feature for browser compatibility
|
||||
*/
|
||||
fixed(): string;
|
||||
|
||||
/**
|
||||
* Returns a `<font>` HTML element and sets the color attribute value
|
||||
* @deprecated A legacy feature for browser compatibility
|
||||
*/
|
||||
fontcolor(color: string): string;
|
||||
|
||||
/**
|
||||
* Returns a `<font>` HTML element and sets the size attribute value
|
||||
* @deprecated A legacy feature for browser compatibility
|
||||
*/
|
||||
fontsize(size: number): string;
|
||||
|
||||
/**
|
||||
* Returns a `<font>` HTML element and sets the size attribute value
|
||||
* @deprecated A legacy feature for browser compatibility
|
||||
*/
|
||||
fontsize(size: string): string;
|
||||
|
||||
/**
|
||||
* Returns an `<i>` HTML element
|
||||
* @deprecated A legacy feature for browser compatibility
|
||||
*/
|
||||
italics(): string;
|
||||
|
||||
/**
|
||||
* Returns an `<a>` HTML element and sets the href attribute value
|
||||
* @deprecated A legacy feature for browser compatibility
|
||||
*/
|
||||
link(url: string): string;
|
||||
|
||||
/**
|
||||
* Returns a `<small>` HTML element
|
||||
* @deprecated A legacy feature for browser compatibility
|
||||
*/
|
||||
small(): string;
|
||||
|
||||
/**
|
||||
* Returns a `<strike>` HTML element
|
||||
* @deprecated A legacy feature for browser compatibility
|
||||
*/
|
||||
strike(): string;
|
||||
|
||||
/**
|
||||
* Returns a `<sub>` HTML element
|
||||
* @deprecated A legacy feature for browser compatibility
|
||||
*/
|
||||
sub(): string;
|
||||
|
||||
/**
|
||||
* Returns a `<sup>` HTML element
|
||||
* @deprecated A legacy feature for browser compatibility
|
||||
*/
|
||||
sup(): string;
|
||||
}
|
||||
|
||||
interface StringConstructor {
|
||||
/**
|
||||
* Return the String value whose elements are, in order, the elements in the List elements.
|
||||
* If length is 0, the empty string is returned.
|
||||
*/
|
||||
fromCodePoint(...codePoints: number[]): string;
|
||||
|
||||
/**
|
||||
* String.raw is usually used as a tag function of a Tagged Template String. When called as
|
||||
* such, the first argument will be a well formed template call site object and the rest
|
||||
* parameter will contain the substitution values. It can also be called directly, for example,
|
||||
* to interleave strings and values from your own tag function, and in this case the only thing
|
||||
* it needs from the first argument is the raw property.
|
||||
* @param template A well-formed template string call site representation.
|
||||
* @param substitutions A set of substitution values.
|
||||
*/
|
||||
raw(template: { raw: readonly string[] | ArrayLike<string>; }, ...substitutions: any[]): string;
|
||||
}
|
||||
|
||||
interface Int8Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions): string;
|
||||
}
|
||||
|
||||
interface Uint8Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions): string;
|
||||
}
|
||||
|
||||
interface Uint8ClampedArray<TArrayBuffer extends ArrayBufferLike> {
|
||||
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions): string;
|
||||
}
|
||||
|
||||
interface Int16Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions): string;
|
||||
}
|
||||
|
||||
interface Uint16Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions): string;
|
||||
}
|
||||
|
||||
interface Int32Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions): string;
|
||||
}
|
||||
|
||||
interface Uint32Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions): string;
|
||||
}
|
||||
|
||||
interface Float32Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions): string;
|
||||
}
|
||||
|
||||
interface Float64Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions): string;
|
||||
}
|
||||
28
kitcom/internal/tsgo/bundled/libs/lib.es2015.d.ts
vendored
Normal file
28
kitcom/internal/tsgo/bundled/libs/lib.es2015.d.ts
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es5" />
|
||||
/// <reference lib="es2015.core" />
|
||||
/// <reference lib="es2015.collection" />
|
||||
/// <reference lib="es2015.iterable" />
|
||||
/// <reference lib="es2015.generator" />
|
||||
/// <reference lib="es2015.promise" />
|
||||
/// <reference lib="es2015.proxy" />
|
||||
/// <reference lib="es2015.reflect" />
|
||||
/// <reference lib="es2015.symbol" />
|
||||
/// <reference lib="es2015.symbol.wellknown" />
|
||||
77
kitcom/internal/tsgo/bundled/libs/lib.es2015.generator.d.ts
vendored
Normal file
77
kitcom/internal/tsgo/bundled/libs/lib.es2015.generator.d.ts
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2015.iterable" />
|
||||
|
||||
interface Generator<T = unknown, TReturn = any, TNext = any> extends IteratorObject<T, TReturn, TNext> {
|
||||
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
|
||||
next(...[value]: [] | [TNext]): IteratorResult<T, TReturn>;
|
||||
return(value: TReturn): IteratorResult<T, TReturn>;
|
||||
throw(e: any): IteratorResult<T, TReturn>;
|
||||
[Symbol.iterator](): Generator<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
interface GeneratorFunction {
|
||||
/**
|
||||
* Creates a new Generator object.
|
||||
* @param args A list of arguments the function accepts.
|
||||
*/
|
||||
new (...args: any[]): Generator;
|
||||
/**
|
||||
* Creates a new Generator object.
|
||||
* @param args A list of arguments the function accepts.
|
||||
*/
|
||||
(...args: any[]): Generator;
|
||||
/**
|
||||
* The length of the arguments.
|
||||
*/
|
||||
readonly length: number;
|
||||
/**
|
||||
* Returns the name of the function.
|
||||
*/
|
||||
readonly name: string;
|
||||
/**
|
||||
* A reference to the prototype.
|
||||
*/
|
||||
readonly prototype: Generator;
|
||||
}
|
||||
|
||||
interface GeneratorFunctionConstructor {
|
||||
/**
|
||||
* Creates a new Generator function.
|
||||
* @param args A list of arguments the function accepts.
|
||||
*/
|
||||
new (...args: string[]): GeneratorFunction;
|
||||
/**
|
||||
* Creates a new Generator function.
|
||||
* @param args A list of arguments the function accepts.
|
||||
*/
|
||||
(...args: string[]): GeneratorFunction;
|
||||
/**
|
||||
* The length of the arguments.
|
||||
*/
|
||||
readonly length: number;
|
||||
/**
|
||||
* Returns the name of the function.
|
||||
*/
|
||||
readonly name: string;
|
||||
/**
|
||||
* A reference to the prototype.
|
||||
*/
|
||||
readonly prototype: GeneratorFunction;
|
||||
}
|
||||
605
kitcom/internal/tsgo/bundled/libs/lib.es2015.iterable.d.ts
vendored
Normal file
605
kitcom/internal/tsgo/bundled/libs/lib.es2015.iterable.d.ts
vendored
Normal file
@ -0,0 +1,605 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2015.symbol" />
|
||||
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
* A method that returns the default iterator for an object. Called by the semantics of the
|
||||
* for-of statement.
|
||||
*/
|
||||
readonly iterator: unique symbol;
|
||||
}
|
||||
|
||||
interface IteratorYieldResult<TYield> {
|
||||
done?: false;
|
||||
value: TYield;
|
||||
}
|
||||
|
||||
interface IteratorReturnResult<TReturn> {
|
||||
done: true;
|
||||
value: TReturn;
|
||||
}
|
||||
|
||||
type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
|
||||
|
||||
interface Iterator<T, TReturn = any, TNext = any> {
|
||||
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
|
||||
next(...[value]: [] | [TNext]): IteratorResult<T, TReturn>;
|
||||
return?(value?: TReturn): IteratorResult<T, TReturn>;
|
||||
throw?(e?: any): IteratorResult<T, TReturn>;
|
||||
}
|
||||
|
||||
interface Iterable<T, TReturn = any, TNext = any> {
|
||||
[Symbol.iterator](): Iterator<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes a user-defined {@link Iterator} that is also iterable.
|
||||
*/
|
||||
interface IterableIterator<T, TReturn = any, TNext = any> extends Iterator<T, TReturn, TNext> {
|
||||
[Symbol.iterator](): IterableIterator<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes an {@link Iterator} produced by the runtime that inherits from the intrinsic `Iterator.prototype`.
|
||||
*/
|
||||
interface IteratorObject<T, TReturn = unknown, TNext = unknown> extends Iterator<T, TReturn, TNext> {
|
||||
[Symbol.iterator](): IteratorObject<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the `TReturn` type used for built-in iterators produced by `Array`, `Map`, `Set`, and others.
|
||||
* This is `undefined` when `strictBuiltInIteratorReturn` is `true`; otherwise, this is `any`.
|
||||
*/
|
||||
type BuiltinIteratorReturn = intrinsic;
|
||||
|
||||
interface ArrayIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): ArrayIterator<T>;
|
||||
}
|
||||
|
||||
interface Array<T> {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): ArrayIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): ArrayIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of keys in the array
|
||||
*/
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the array
|
||||
*/
|
||||
values(): ArrayIterator<T>;
|
||||
}
|
||||
|
||||
interface ArrayConstructor {
|
||||
/**
|
||||
* Creates an array from an iterable object.
|
||||
* @param iterable An iterable object to convert to an array.
|
||||
*/
|
||||
from<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
|
||||
|
||||
/**
|
||||
* Creates an array from an iterable object.
|
||||
* @param iterable An iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from<T, U>(iterable: Iterable<T> | ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
||||
}
|
||||
|
||||
interface ReadonlyArray<T> {
|
||||
/** Iterator of values in the array. */
|
||||
[Symbol.iterator](): ArrayIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): ArrayIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of keys in the array
|
||||
*/
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the array
|
||||
*/
|
||||
values(): ArrayIterator<T>;
|
||||
}
|
||||
|
||||
interface IArguments {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): ArrayIterator<any>;
|
||||
}
|
||||
|
||||
interface MapIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): MapIterator<T>;
|
||||
}
|
||||
|
||||
interface Map<K, V> {
|
||||
/** Returns an iterable of entries in the map. */
|
||||
[Symbol.iterator](): MapIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of key, value pairs for every entry in the map.
|
||||
*/
|
||||
entries(): MapIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of keys in the map
|
||||
*/
|
||||
keys(): MapIterator<K>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the map
|
||||
*/
|
||||
values(): MapIterator<V>;
|
||||
}
|
||||
|
||||
interface ReadonlyMap<K, V> {
|
||||
/** Returns an iterable of entries in the map. */
|
||||
[Symbol.iterator](): MapIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of key, value pairs for every entry in the map.
|
||||
*/
|
||||
entries(): MapIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of keys in the map
|
||||
*/
|
||||
keys(): MapIterator<K>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the map
|
||||
*/
|
||||
values(): MapIterator<V>;
|
||||
}
|
||||
|
||||
interface MapConstructor {
|
||||
new (): Map<any, any>;
|
||||
new <K, V>(iterable?: Iterable<readonly [K, V]> | null): Map<K, V>;
|
||||
}
|
||||
|
||||
interface WeakMap<K extends WeakKey, V> {}
|
||||
|
||||
interface WeakMapConstructor {
|
||||
new <K extends WeakKey, V>(iterable: Iterable<readonly [K, V]>): WeakMap<K, V>;
|
||||
}
|
||||
|
||||
interface SetIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): SetIterator<T>;
|
||||
}
|
||||
|
||||
interface Set<T> {
|
||||
/** Iterates over values in the set. */
|
||||
[Symbol.iterator](): SetIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of [v,v] pairs for every value `v` in the set.
|
||||
*/
|
||||
entries(): SetIterator<[T, T]>;
|
||||
|
||||
/**
|
||||
* Despite its name, returns an iterable of the values in the set.
|
||||
*/
|
||||
keys(): SetIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the set.
|
||||
*/
|
||||
values(): SetIterator<T>;
|
||||
}
|
||||
|
||||
interface ReadonlySet<T> {
|
||||
/** Iterates over values in the set. */
|
||||
[Symbol.iterator](): SetIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of [v,v] pairs for every value `v` in the set.
|
||||
*/
|
||||
entries(): SetIterator<[T, T]>;
|
||||
|
||||
/**
|
||||
* Despite its name, returns an iterable of the values in the set.
|
||||
*/
|
||||
keys(): SetIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the set.
|
||||
*/
|
||||
values(): SetIterator<T>;
|
||||
}
|
||||
|
||||
interface SetConstructor {
|
||||
new <T>(iterable?: Iterable<T> | null): Set<T>;
|
||||
}
|
||||
|
||||
interface WeakSet<T extends WeakKey> {}
|
||||
|
||||
interface WeakSetConstructor {
|
||||
new <T extends WeakKey = WeakKey>(iterable: Iterable<T>): WeakSet<T>;
|
||||
}
|
||||
|
||||
interface Promise<T> {}
|
||||
|
||||
interface PromiseConstructor {
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An iterable of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An iterable of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>>;
|
||||
}
|
||||
|
||||
interface StringIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): StringIterator<T>;
|
||||
}
|
||||
|
||||
interface String {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): StringIterator<string>;
|
||||
}
|
||||
|
||||
interface Int8Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Int8ArrayConstructor {
|
||||
new (elements: Iterable<number>): Int8Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
*/
|
||||
from(elements: Iterable<number>): Int8Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Int8Array<ArrayBuffer>;
|
||||
}
|
||||
|
||||
interface Uint8Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint8ArrayConstructor {
|
||||
new (elements: Iterable<number>): Uint8Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
*/
|
||||
from(elements: Iterable<number>): Uint8Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Uint8Array<ArrayBuffer>;
|
||||
}
|
||||
|
||||
interface Uint8ClampedArray<TArrayBuffer extends ArrayBufferLike> {
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint8ClampedArrayConstructor {
|
||||
new (elements: Iterable<number>): Uint8ClampedArray<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
*/
|
||||
from(elements: Iterable<number>): Uint8ClampedArray<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray<ArrayBuffer>;
|
||||
}
|
||||
|
||||
interface Int16Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Int16ArrayConstructor {
|
||||
new (elements: Iterable<number>): Int16Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
*/
|
||||
from(elements: Iterable<number>): Int16Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Int16Array<ArrayBuffer>;
|
||||
}
|
||||
|
||||
interface Uint16Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint16ArrayConstructor {
|
||||
new (elements: Iterable<number>): Uint16Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
*/
|
||||
from(elements: Iterable<number>): Uint16Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Uint16Array<ArrayBuffer>;
|
||||
}
|
||||
|
||||
interface Int32Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Int32ArrayConstructor {
|
||||
new (elements: Iterable<number>): Int32Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
*/
|
||||
from(elements: Iterable<number>): Int32Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Int32Array<ArrayBuffer>;
|
||||
}
|
||||
|
||||
interface Uint32Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint32ArrayConstructor {
|
||||
new (elements: Iterable<number>): Uint32Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
*/
|
||||
from(elements: Iterable<number>): Uint32Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Uint32Array<ArrayBuffer>;
|
||||
}
|
||||
|
||||
interface Float32Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Float32ArrayConstructor {
|
||||
new (elements: Iterable<number>): Float32Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
*/
|
||||
from(elements: Iterable<number>): Float32Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Float32Array<ArrayBuffer>;
|
||||
}
|
||||
|
||||
interface Float64Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Float64ArrayConstructor {
|
||||
new (elements: Iterable<number>): Float64Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
*/
|
||||
from(elements: Iterable<number>): Float64Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Float64Array<ArrayBuffer>;
|
||||
}
|
||||
81
kitcom/internal/tsgo/bundled/libs/lib.es2015.promise.d.ts
vendored
Normal file
81
kitcom/internal/tsgo/bundled/libs/lib.es2015.promise.d.ts
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
interface PromiseConstructor {
|
||||
/**
|
||||
* A reference to the prototype.
|
||||
*/
|
||||
readonly prototype: Promise<any>;
|
||||
|
||||
/**
|
||||
* Creates a new Promise.
|
||||
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
|
||||
* a resolve callback used to resolve the promise with a value or the result of another promise,
|
||||
* and a reject callback used to reject the promise with a provided reason or error.
|
||||
*/
|
||||
new <T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T extends readonly unknown[] | []>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>;
|
||||
|
||||
// see: lib.es2015.iterable.d.ts
|
||||
// all<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T extends readonly unknown[] | []>(values: T): Promise<Awaited<T[number]>>;
|
||||
|
||||
// see: lib.es2015.iterable.d.ts
|
||||
// race<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>>;
|
||||
|
||||
/**
|
||||
* Creates a new rejected promise for the provided reason.
|
||||
* @param reason The reason the promise was rejected.
|
||||
* @returns A new rejected Promise.
|
||||
*/
|
||||
reject<T = never>(reason?: any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a new resolved promise.
|
||||
* @returns A resolved promise.
|
||||
*/
|
||||
resolve(): Promise<void>;
|
||||
/**
|
||||
* Creates a new resolved promise for the provided value.
|
||||
* @param value A promise.
|
||||
* @returns A promise whose internal state matches the provided promise.
|
||||
*/
|
||||
resolve<T>(value: T): Promise<Awaited<T>>;
|
||||
/**
|
||||
* Creates a new resolved promise for the provided value.
|
||||
* @param value A promise.
|
||||
* @returns A promise whose internal state matches the provided promise.
|
||||
*/
|
||||
resolve<T>(value: T | PromiseLike<T>): Promise<Awaited<T>>;
|
||||
}
|
||||
|
||||
declare var Promise: PromiseConstructor;
|
||||
128
kitcom/internal/tsgo/bundled/libs/lib.es2015.proxy.d.ts
vendored
Normal file
128
kitcom/internal/tsgo/bundled/libs/lib.es2015.proxy.d.ts
vendored
Normal file
@ -0,0 +1,128 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
interface ProxyHandler<T extends object> {
|
||||
/**
|
||||
* A trap method for a function call.
|
||||
* @param target The original callable object which is being proxied.
|
||||
*/
|
||||
apply?(target: T, thisArg: any, argArray: any[]): any;
|
||||
|
||||
/**
|
||||
* A trap for the `new` operator.
|
||||
* @param target The original object which is being proxied.
|
||||
* @param newTarget The constructor that was originally called.
|
||||
*/
|
||||
construct?(target: T, argArray: any[], newTarget: Function): object;
|
||||
|
||||
/**
|
||||
* A trap for `Object.defineProperty()`.
|
||||
* @param target The original object which is being proxied.
|
||||
* @returns A `Boolean` indicating whether or not the property has been defined.
|
||||
*/
|
||||
defineProperty?(target: T, property: string | symbol, attributes: PropertyDescriptor): boolean;
|
||||
|
||||
/**
|
||||
* A trap for the `delete` operator.
|
||||
* @param target The original object which is being proxied.
|
||||
* @param p The name or `Symbol` of the property to delete.
|
||||
* @returns A `Boolean` indicating whether or not the property was deleted.
|
||||
*/
|
||||
deleteProperty?(target: T, p: string | symbol): boolean;
|
||||
|
||||
/**
|
||||
* A trap for getting a property value.
|
||||
* @param target The original object which is being proxied.
|
||||
* @param p The name or `Symbol` of the property to get.
|
||||
* @param receiver The proxy or an object that inherits from the proxy.
|
||||
*/
|
||||
get?(target: T, p: string | symbol, receiver: any): any;
|
||||
|
||||
/**
|
||||
* A trap for `Object.getOwnPropertyDescriptor()`.
|
||||
* @param target The original object which is being proxied.
|
||||
* @param p The name of the property whose description should be retrieved.
|
||||
*/
|
||||
getOwnPropertyDescriptor?(target: T, p: string | symbol): PropertyDescriptor | undefined;
|
||||
|
||||
/**
|
||||
* A trap for the `[[GetPrototypeOf]]` internal method.
|
||||
* @param target The original object which is being proxied.
|
||||
*/
|
||||
getPrototypeOf?(target: T): object | null;
|
||||
|
||||
/**
|
||||
* A trap for the `in` operator.
|
||||
* @param target The original object which is being proxied.
|
||||
* @param p The name or `Symbol` of the property to check for existence.
|
||||
*/
|
||||
has?(target: T, p: string | symbol): boolean;
|
||||
|
||||
/**
|
||||
* A trap for `Object.isExtensible()`.
|
||||
* @param target The original object which is being proxied.
|
||||
*/
|
||||
isExtensible?(target: T): boolean;
|
||||
|
||||
/**
|
||||
* A trap for `Reflect.ownKeys()`.
|
||||
* @param target The original object which is being proxied.
|
||||
*/
|
||||
ownKeys?(target: T): ArrayLike<string | symbol>;
|
||||
|
||||
/**
|
||||
* A trap for `Object.preventExtensions()`.
|
||||
* @param target The original object which is being proxied.
|
||||
*/
|
||||
preventExtensions?(target: T): boolean;
|
||||
|
||||
/**
|
||||
* A trap for setting a property value.
|
||||
* @param target The original object which is being proxied.
|
||||
* @param p The name or `Symbol` of the property to set.
|
||||
* @param receiver The object to which the assignment was originally directed.
|
||||
* @returns A `Boolean` indicating whether or not the property was set.
|
||||
*/
|
||||
set?(target: T, p: string | symbol, newValue: any, receiver: any): boolean;
|
||||
|
||||
/**
|
||||
* A trap for `Object.setPrototypeOf()`.
|
||||
* @param target The original object which is being proxied.
|
||||
* @param newPrototype The object's new prototype or `null`.
|
||||
*/
|
||||
setPrototypeOf?(target: T, v: object | null): boolean;
|
||||
}
|
||||
|
||||
interface ProxyConstructor {
|
||||
/**
|
||||
* Creates a revocable Proxy object.
|
||||
* @param target A target object to wrap with Proxy.
|
||||
* @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it.
|
||||
*/
|
||||
revocable<T extends object>(target: T, handler: ProxyHandler<T>): { proxy: T; revoke: () => void; };
|
||||
|
||||
/**
|
||||
* Creates a Proxy object. The Proxy object allows you to create an object that can be used in place of the
|
||||
* original object, but which may redefine fundamental Object operations like getting, setting, and defining
|
||||
* properties. Proxy objects are commonly used to log property accesses, validate, format, or sanitize inputs.
|
||||
* @param target A target object to wrap with Proxy.
|
||||
* @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it.
|
||||
*/
|
||||
new <T extends object>(target: T, handler: ProxyHandler<T>): T;
|
||||
}
|
||||
declare var Proxy: ProxyConstructor;
|
||||
144
kitcom/internal/tsgo/bundled/libs/lib.es2015.reflect.d.ts
vendored
Normal file
144
kitcom/internal/tsgo/bundled/libs/lib.es2015.reflect.d.ts
vendored
Normal file
@ -0,0 +1,144 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
declare namespace Reflect {
|
||||
/**
|
||||
* Calls the function with the specified object as the this value
|
||||
* and the elements of specified array as the arguments.
|
||||
* @param target The function to call.
|
||||
* @param thisArgument The object to be used as the this object.
|
||||
* @param argumentsList An array of argument values to be passed to the function.
|
||||
*/
|
||||
function apply<T, A extends readonly any[], R>(
|
||||
target: (this: T, ...args: A) => R,
|
||||
thisArgument: T,
|
||||
argumentsList: Readonly<A>,
|
||||
): R;
|
||||
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
|
||||
|
||||
/**
|
||||
* Constructs the target with the elements of specified array as the arguments
|
||||
* and the specified constructor as the `new.target` value.
|
||||
* @param target The constructor to invoke.
|
||||
* @param argumentsList An array of argument values to be passed to the constructor.
|
||||
* @param newTarget The constructor to be used as the `new.target` object.
|
||||
*/
|
||||
function construct<A extends readonly any[], R>(
|
||||
target: new (...args: A) => R,
|
||||
argumentsList: Readonly<A>,
|
||||
newTarget?: new (...args: any) => any,
|
||||
): R;
|
||||
function construct(target: Function, argumentsList: ArrayLike<any>, newTarget?: Function): any;
|
||||
|
||||
/**
|
||||
* Adds a property to an object, or modifies attributes of an existing property.
|
||||
* @param target Object on which to add or modify the property. This can be a native JavaScript object
|
||||
* (that is, a user-defined object or a built in object) or a DOM object.
|
||||
* @param propertyKey The property name.
|
||||
* @param attributes Descriptor for the property. It can be for a data property or an accessor property.
|
||||
*/
|
||||
function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor & ThisType<any>): boolean;
|
||||
|
||||
/**
|
||||
* Removes a property from an object, equivalent to `delete target[propertyKey]`,
|
||||
* except it won't throw if `target[propertyKey]` is non-configurable.
|
||||
* @param target Object from which to remove the own property.
|
||||
* @param propertyKey The property name.
|
||||
*/
|
||||
function deleteProperty(target: object, propertyKey: PropertyKey): boolean;
|
||||
|
||||
/**
|
||||
* Gets the property of target, equivalent to `target[propertyKey]` when `receiver === target`.
|
||||
* @param target Object that contains the property on itself or in its prototype chain.
|
||||
* @param propertyKey The property name.
|
||||
* @param receiver The reference to use as the `this` value in the getter function,
|
||||
* if `target[propertyKey]` is an accessor property.
|
||||
*/
|
||||
function get<T extends object, P extends PropertyKey>(
|
||||
target: T,
|
||||
propertyKey: P,
|
||||
receiver?: unknown,
|
||||
): P extends keyof T ? T[P] : any;
|
||||
|
||||
/**
|
||||
* Gets the own property descriptor of the specified object.
|
||||
* An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype.
|
||||
* @param target Object that contains the property.
|
||||
* @param propertyKey The property name.
|
||||
*/
|
||||
function getOwnPropertyDescriptor<T extends object, P extends PropertyKey>(
|
||||
target: T,
|
||||
propertyKey: P,
|
||||
): TypedPropertyDescriptor<P extends keyof T ? T[P] : any> | undefined;
|
||||
|
||||
/**
|
||||
* Returns the prototype of an object.
|
||||
* @param target The object that references the prototype.
|
||||
*/
|
||||
function getPrototypeOf(target: object): object | null;
|
||||
|
||||
/**
|
||||
* Equivalent to `propertyKey in target`.
|
||||
* @param target Object that contains the property on itself or in its prototype chain.
|
||||
* @param propertyKey Name of the property.
|
||||
*/
|
||||
function has(target: object, propertyKey: PropertyKey): boolean;
|
||||
|
||||
/**
|
||||
* Returns a value that indicates whether new properties can be added to an object.
|
||||
* @param target Object to test.
|
||||
*/
|
||||
function isExtensible(target: object): boolean;
|
||||
|
||||
/**
|
||||
* Returns the string and symbol keys of the own properties of an object. The own properties of an object
|
||||
* are those that are defined directly on that object, and are not inherited from the object's prototype.
|
||||
* @param target Object that contains the own properties.
|
||||
*/
|
||||
function ownKeys(target: object): (string | symbol)[];
|
||||
|
||||
/**
|
||||
* Prevents the addition of new properties to an object.
|
||||
* @param target Object to make non-extensible.
|
||||
* @return Whether the object has been made non-extensible.
|
||||
*/
|
||||
function preventExtensions(target: object): boolean;
|
||||
|
||||
/**
|
||||
* Sets the property of target, equivalent to `target[propertyKey] = value` when `receiver === target`.
|
||||
* @param target Object that contains the property on itself or in its prototype chain.
|
||||
* @param propertyKey Name of the property.
|
||||
* @param receiver The reference to use as the `this` value in the setter function,
|
||||
* if `target[propertyKey]` is an accessor property.
|
||||
*/
|
||||
function set<T extends object, P extends PropertyKey>(
|
||||
target: T,
|
||||
propertyKey: P,
|
||||
value: P extends keyof T ? T[P] : any,
|
||||
receiver?: any,
|
||||
): boolean;
|
||||
function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
|
||||
|
||||
/**
|
||||
* Sets the prototype of a specified object o to object proto or null.
|
||||
* @param target The object to change its prototype.
|
||||
* @param proto The value of the new prototype or null.
|
||||
* @return Whether setting the prototype was successful.
|
||||
*/
|
||||
function setPrototypeOf(target: object, proto: object | null): boolean;
|
||||
}
|
||||
46
kitcom/internal/tsgo/bundled/libs/lib.es2015.symbol.d.ts
vendored
Normal file
46
kitcom/internal/tsgo/bundled/libs/lib.es2015.symbol.d.ts
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
* A reference to the prototype.
|
||||
*/
|
||||
readonly prototype: Symbol;
|
||||
|
||||
/**
|
||||
* Returns a new unique Symbol value.
|
||||
* @param description Description of the new Symbol object.
|
||||
*/
|
||||
(description?: string | number): symbol;
|
||||
|
||||
/**
|
||||
* Returns a Symbol object from the global symbol registry matching the given key if found.
|
||||
* Otherwise, returns a new symbol with this key.
|
||||
* @param key key to search for.
|
||||
*/
|
||||
for(key: string): symbol;
|
||||
|
||||
/**
|
||||
* Returns a key from the global symbol registry matching the given Symbol if found.
|
||||
* Otherwise, returns a undefined.
|
||||
* @param sym Symbol to find the key for.
|
||||
*/
|
||||
keyFor(sym: symbol): string | undefined;
|
||||
}
|
||||
|
||||
declare var Symbol: SymbolConstructor;
|
||||
326
kitcom/internal/tsgo/bundled/libs/lib.es2015.symbol.wellknown.d.ts
vendored
Normal file
326
kitcom/internal/tsgo/bundled/libs/lib.es2015.symbol.wellknown.d.ts
vendored
Normal file
@ -0,0 +1,326 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2015.symbol" />
|
||||
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
* A method that determines if a constructor object recognizes an object as one of the
|
||||
* constructor’s instances. Called by the semantics of the instanceof operator.
|
||||
*/
|
||||
readonly hasInstance: unique symbol;
|
||||
|
||||
/**
|
||||
* A Boolean value that if true indicates that an object should flatten to its array elements
|
||||
* by Array.prototype.concat.
|
||||
*/
|
||||
readonly isConcatSpreadable: unique symbol;
|
||||
|
||||
/**
|
||||
* A regular expression method that matches the regular expression against a string. Called
|
||||
* by the String.prototype.match method.
|
||||
*/
|
||||
readonly match: unique symbol;
|
||||
|
||||
/**
|
||||
* A regular expression method that replaces matched substrings of a string. Called by the
|
||||
* String.prototype.replace method.
|
||||
*/
|
||||
readonly replace: unique symbol;
|
||||
|
||||
/**
|
||||
* A regular expression method that returns the index within a string that matches the
|
||||
* regular expression. Called by the String.prototype.search method.
|
||||
*/
|
||||
readonly search: unique symbol;
|
||||
|
||||
/**
|
||||
* A function valued property that is the constructor function that is used to create
|
||||
* derived objects.
|
||||
*/
|
||||
readonly species: unique symbol;
|
||||
|
||||
/**
|
||||
* A regular expression method that splits a string at the indices that match the regular
|
||||
* expression. Called by the String.prototype.split method.
|
||||
*/
|
||||
readonly split: unique symbol;
|
||||
|
||||
/**
|
||||
* A method that converts an object to a corresponding primitive value.
|
||||
* Called by the ToPrimitive abstract operation.
|
||||
*/
|
||||
readonly toPrimitive: unique symbol;
|
||||
|
||||
/**
|
||||
* A String value that is used in the creation of the default string description of an object.
|
||||
* Called by the built-in method Object.prototype.toString.
|
||||
*/
|
||||
readonly toStringTag: unique symbol;
|
||||
|
||||
/**
|
||||
* An Object whose truthy properties are properties that are excluded from the 'with'
|
||||
* environment bindings of the associated objects.
|
||||
*/
|
||||
readonly unscopables: unique symbol;
|
||||
}
|
||||
|
||||
interface Symbol {
|
||||
/**
|
||||
* Converts a Symbol object to a symbol.
|
||||
*/
|
||||
[Symbol.toPrimitive](hint: string): symbol;
|
||||
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface Array<T> {
|
||||
/**
|
||||
* Is an object whose properties have the value 'true'
|
||||
* when they will be absent when used in a 'with' statement.
|
||||
*/
|
||||
readonly [Symbol.unscopables]: {
|
||||
[K in keyof any[]]?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
interface ReadonlyArray<T> {
|
||||
/**
|
||||
* Is an object whose properties have the value 'true'
|
||||
* when they will be absent when used in a 'with' statement.
|
||||
*/
|
||||
readonly [Symbol.unscopables]: {
|
||||
[K in keyof readonly any[]]?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
interface Date {
|
||||
/**
|
||||
* Converts a Date object to a string.
|
||||
*/
|
||||
[Symbol.toPrimitive](hint: "default"): string;
|
||||
/**
|
||||
* Converts a Date object to a string.
|
||||
*/
|
||||
[Symbol.toPrimitive](hint: "string"): string;
|
||||
/**
|
||||
* Converts a Date object to a number.
|
||||
*/
|
||||
[Symbol.toPrimitive](hint: "number"): number;
|
||||
/**
|
||||
* Converts a Date object to a string or number.
|
||||
*
|
||||
* @param hint The strings "number", "string", or "default" to specify what primitive to return.
|
||||
*
|
||||
* @throws {TypeError} If 'hint' was given something other than "number", "string", or "default".
|
||||
* @returns A number if 'hint' was "number", a string if 'hint' was "string" or "default".
|
||||
*/
|
||||
[Symbol.toPrimitive](hint: string): string | number;
|
||||
}
|
||||
|
||||
interface Map<K, V> {
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface WeakMap<K extends WeakKey, V> {
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface Set<T> {
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface WeakSet<T extends WeakKey> {
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface JSON {
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface Function {
|
||||
/**
|
||||
* Determines whether the given value inherits from this function if this function was used
|
||||
* as a constructor function.
|
||||
*
|
||||
* A constructor function can control which objects are recognized as its instances by
|
||||
* 'instanceof' by overriding this method.
|
||||
*/
|
||||
[Symbol.hasInstance](value: any): boolean;
|
||||
}
|
||||
|
||||
interface GeneratorFunction {
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface Math {
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface Promise<T> {
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface PromiseConstructor {
|
||||
readonly [Symbol.species]: PromiseConstructor;
|
||||
}
|
||||
|
||||
interface RegExp {
|
||||
/**
|
||||
* Matches a string with this regular expression, and returns an array containing the results of
|
||||
* that search.
|
||||
* @param string A string to search within.
|
||||
*/
|
||||
[Symbol.match](string: string): RegExpMatchArray | null;
|
||||
|
||||
/**
|
||||
* Replaces text in a string, using this regular expression.
|
||||
* @param string A String object or string literal whose contents matching against
|
||||
* this regular expression will be replaced
|
||||
* @param replaceValue A String object or string literal containing the text to replace for every
|
||||
* successful match of this regular expression.
|
||||
*/
|
||||
[Symbol.replace](string: string, replaceValue: string): string;
|
||||
|
||||
/**
|
||||
* Replaces text in a string, using this regular expression.
|
||||
* @param string A String object or string literal whose contents matching against
|
||||
* this regular expression will be replaced
|
||||
* @param replacer A function that returns the replacement text.
|
||||
*/
|
||||
[Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string;
|
||||
|
||||
/**
|
||||
* Finds the position beginning first substring match in a regular expression search
|
||||
* using this regular expression.
|
||||
*
|
||||
* @param string The string to search within.
|
||||
*/
|
||||
[Symbol.search](string: string): number;
|
||||
|
||||
/**
|
||||
* Returns an array of substrings that were delimited by strings in the original input that
|
||||
* match against this regular expression.
|
||||
*
|
||||
* If the regular expression contains capturing parentheses, then each time this
|
||||
* regular expression matches, the results (including any undefined results) of the
|
||||
* capturing parentheses are spliced.
|
||||
*
|
||||
* @param string string value to split
|
||||
* @param limit if not undefined, the output array is truncated so that it contains no more
|
||||
* than 'limit' elements.
|
||||
*/
|
||||
[Symbol.split](string: string, limit?: number): string[];
|
||||
}
|
||||
|
||||
interface RegExpConstructor {
|
||||
readonly [Symbol.species]: RegExpConstructor;
|
||||
}
|
||||
|
||||
interface String {
|
||||
/**
|
||||
* Matches a string or an object that supports being matched against, and returns an array
|
||||
* containing the results of that search, or null if no matches are found.
|
||||
* @param matcher An object that supports being matched against.
|
||||
*/
|
||||
match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null;
|
||||
|
||||
/**
|
||||
* Passes a string and {@linkcode replaceValue} to the `[Symbol.replace]` method on {@linkcode searchValue}. This method is expected to implement its own replacement algorithm.
|
||||
* @param searchValue An object that supports searching for and replacing matches within a string.
|
||||
* @param replaceValue The replacement text.
|
||||
*/
|
||||
replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string;
|
||||
|
||||
/**
|
||||
* Replaces text in a string, using an object that supports replacement within a string.
|
||||
* @param searchValue A object can search for and replace matches within a string.
|
||||
* @param replacer A function that returns the replacement text.
|
||||
*/
|
||||
replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string;
|
||||
|
||||
/**
|
||||
* Finds the first substring match in a regular expression search.
|
||||
* @param searcher An object which supports searching within a string.
|
||||
*/
|
||||
search(searcher: { [Symbol.search](string: string): number; }): number;
|
||||
|
||||
/**
|
||||
* Split a string into substrings using the specified separator and return them as an array.
|
||||
* @param splitter An object that can split a string.
|
||||
* @param limit A value used to limit the number of elements returned in the array.
|
||||
*/
|
||||
split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[];
|
||||
}
|
||||
|
||||
interface ArrayBuffer {
|
||||
readonly [Symbol.toStringTag]: "ArrayBuffer";
|
||||
}
|
||||
|
||||
interface DataView<TArrayBuffer extends ArrayBufferLike> {
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface Int8Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
readonly [Symbol.toStringTag]: "Int8Array";
|
||||
}
|
||||
|
||||
interface Uint8Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
readonly [Symbol.toStringTag]: "Uint8Array";
|
||||
}
|
||||
|
||||
interface Uint8ClampedArray<TArrayBuffer extends ArrayBufferLike> {
|
||||
readonly [Symbol.toStringTag]: "Uint8ClampedArray";
|
||||
}
|
||||
|
||||
interface Int16Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
readonly [Symbol.toStringTag]: "Int16Array";
|
||||
}
|
||||
|
||||
interface Uint16Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
readonly [Symbol.toStringTag]: "Uint16Array";
|
||||
}
|
||||
|
||||
interface Int32Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
readonly [Symbol.toStringTag]: "Int32Array";
|
||||
}
|
||||
|
||||
interface Uint32Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
readonly [Symbol.toStringTag]: "Uint32Array";
|
||||
}
|
||||
|
||||
interface Float32Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
readonly [Symbol.toStringTag]: "Float32Array";
|
||||
}
|
||||
|
||||
interface Float64Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
readonly [Symbol.toStringTag]: "Float64Array";
|
||||
}
|
||||
|
||||
interface ArrayConstructor {
|
||||
readonly [Symbol.species]: ArrayConstructor;
|
||||
}
|
||||
interface MapConstructor {
|
||||
readonly [Symbol.species]: MapConstructor;
|
||||
}
|
||||
interface SetConstructor {
|
||||
readonly [Symbol.species]: SetConstructor;
|
||||
}
|
||||
interface ArrayBufferConstructor {
|
||||
readonly [Symbol.species]: ArrayBufferConstructor;
|
||||
}
|
||||
116
kitcom/internal/tsgo/bundled/libs/lib.es2016.array.include.d.ts
vendored
Normal file
116
kitcom/internal/tsgo/bundled/libs/lib.es2016.array.include.d.ts
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
interface Array<T> {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: T, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface ReadonlyArray<T> {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: T, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Int8Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Uint8Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Uint8ClampedArray<TArrayBuffer extends ArrayBufferLike> {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Int16Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Uint16Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Int32Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Uint32Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Float32Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Float64Array<TArrayBuffer extends ArrayBufferLike> {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
21
kitcom/internal/tsgo/bundled/libs/lib.es2016.d.ts
vendored
Normal file
21
kitcom/internal/tsgo/bundled/libs/lib.es2016.d.ts
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2015" />
|
||||
/// <reference lib="es2016.array.include" />
|
||||
/// <reference lib="es2016.intl" />
|
||||
23
kitcom/internal/tsgo/bundled/libs/lib.es2016.full.d.ts
vendored
Normal file
23
kitcom/internal/tsgo/bundled/libs/lib.es2016.full.d.ts
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2016" />
|
||||
/// <reference lib="dom" />
|
||||
/// <reference lib="webworker.importscripts" />
|
||||
/// <reference lib="scripthost" />
|
||||
/// <reference lib="dom.iterable" />
|
||||
31
kitcom/internal/tsgo/bundled/libs/lib.es2016.intl.d.ts
vendored
Normal file
31
kitcom/internal/tsgo/bundled/libs/lib.es2016.intl.d.ts
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
declare namespace Intl {
|
||||
/**
|
||||
* The `Intl.getCanonicalLocales()` method returns an array containing
|
||||
* the canonical locale names. Duplicates will be omitted and elements
|
||||
* will be validated as structurally valid language tags.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales)
|
||||
*
|
||||
* @param locale A list of String values for which to get the canonical locale names
|
||||
* @returns An array containing the canonical and validated locale names.
|
||||
*/
|
||||
function getCanonicalLocales(locale?: string | readonly string[]): string[];
|
||||
}
|
||||
21
kitcom/internal/tsgo/bundled/libs/lib.es2017.arraybuffer.d.ts
vendored
Normal file
21
kitcom/internal/tsgo/bundled/libs/lib.es2017.arraybuffer.d.ts
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
interface ArrayBufferConstructor {
|
||||
new (): ArrayBuffer;
|
||||
}
|
||||
26
kitcom/internal/tsgo/bundled/libs/lib.es2017.d.ts
vendored
Normal file
26
kitcom/internal/tsgo/bundled/libs/lib.es2017.d.ts
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2016" />
|
||||
/// <reference lib="es2017.arraybuffer" />
|
||||
/// <reference lib="es2017.date" />
|
||||
/// <reference lib="es2017.intl" />
|
||||
/// <reference lib="es2017.object" />
|
||||
/// <reference lib="es2017.sharedmemory" />
|
||||
/// <reference lib="es2017.string" />
|
||||
/// <reference lib="es2017.typedarrays" />
|
||||
31
kitcom/internal/tsgo/bundled/libs/lib.es2017.date.d.ts
vendored
Normal file
31
kitcom/internal/tsgo/bundled/libs/lib.es2017.date.d.ts
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
interface DateConstructor {
|
||||
/**
|
||||
* Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date.
|
||||
* @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year.
|
||||
* @param monthIndex The month as a number between 0 and 11 (January to December).
|
||||
* @param date The date as a number between 1 and 31.
|
||||
* @param hours Must be supplied if minutes is supplied. A number from 0 to 23 (midnight to 11pm) that specifies the hour.
|
||||
* @param minutes Must be supplied if seconds is supplied. A number from 0 to 59 that specifies the minutes.
|
||||
* @param seconds Must be supplied if milliseconds is supplied. A number from 0 to 59 that specifies the seconds.
|
||||
* @param ms A number from 0 to 999 that specifies the milliseconds.
|
||||
*/
|
||||
UTC(year: number, monthIndex?: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number;
|
||||
}
|
||||
23
kitcom/internal/tsgo/bundled/libs/lib.es2017.full.d.ts
vendored
Normal file
23
kitcom/internal/tsgo/bundled/libs/lib.es2017.full.d.ts
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2017" />
|
||||
/// <reference lib="dom" />
|
||||
/// <reference lib="webworker.importscripts" />
|
||||
/// <reference lib="scripthost" />
|
||||
/// <reference lib="dom.iterable" />
|
||||
44
kitcom/internal/tsgo/bundled/libs/lib.es2017.intl.d.ts
vendored
Normal file
44
kitcom/internal/tsgo/bundled/libs/lib.es2017.intl.d.ts
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
declare namespace Intl {
|
||||
interface DateTimeFormatPartTypesRegistry {
|
||||
day: any;
|
||||
dayPeriod: any;
|
||||
era: any;
|
||||
hour: any;
|
||||
literal: any;
|
||||
minute: any;
|
||||
month: any;
|
||||
second: any;
|
||||
timeZoneName: any;
|
||||
weekday: any;
|
||||
year: any;
|
||||
}
|
||||
|
||||
type DateTimeFormatPartTypes = keyof DateTimeFormatPartTypesRegistry;
|
||||
|
||||
interface DateTimeFormatPart {
|
||||
type: DateTimeFormatPartTypes;
|
||||
value: string;
|
||||
}
|
||||
|
||||
interface DateTimeFormat {
|
||||
formatToParts(date?: Date | number): DateTimeFormatPart[];
|
||||
}
|
||||
}
|
||||
49
kitcom/internal/tsgo/bundled/libs/lib.es2017.object.d.ts
vendored
Normal file
49
kitcom/internal/tsgo/bundled/libs/lib.es2017.object.d.ts
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
interface ObjectConstructor {
|
||||
/**
|
||||
* Returns an array of values of the enumerable own properties of an object
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
values<T>(o: { [s: string]: T; } | ArrayLike<T>): T[];
|
||||
|
||||
/**
|
||||
* Returns an array of values of the enumerable own properties of an object
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
values(o: {}): any[];
|
||||
|
||||
/**
|
||||
* Returns an array of key/values of the enumerable own properties of an object
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
entries<T>(o: { [s: string]: T; } | ArrayLike<T>): [string, T][];
|
||||
|
||||
/**
|
||||
* Returns an array of key/values of the enumerable own properties of an object
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
entries(o: {}): [string, any][];
|
||||
|
||||
/**
|
||||
* Returns an object containing all own property descriptors of an object
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
getOwnPropertyDescriptors<T>(o: T): { [P in keyof T]: TypedPropertyDescriptor<T[P]>; } & { [x: string]: PropertyDescriptor; };
|
||||
}
|
||||
135
kitcom/internal/tsgo/bundled/libs/lib.es2017.sharedmemory.d.ts
vendored
Normal file
135
kitcom/internal/tsgo/bundled/libs/lib.es2017.sharedmemory.d.ts
vendored
Normal file
@ -0,0 +1,135 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2015.symbol" />
|
||||
/// <reference lib="es2015.symbol.wellknown" />
|
||||
|
||||
interface SharedArrayBuffer {
|
||||
/**
|
||||
* Read-only. The length of the ArrayBuffer (in bytes).
|
||||
*/
|
||||
readonly byteLength: number;
|
||||
|
||||
/**
|
||||
* Returns a section of an SharedArrayBuffer.
|
||||
*/
|
||||
slice(begin?: number, end?: number): SharedArrayBuffer;
|
||||
readonly [Symbol.toStringTag]: "SharedArrayBuffer";
|
||||
}
|
||||
|
||||
interface SharedArrayBufferConstructor {
|
||||
readonly prototype: SharedArrayBuffer;
|
||||
new (byteLength?: number): SharedArrayBuffer;
|
||||
readonly [Symbol.species]: SharedArrayBufferConstructor;
|
||||
}
|
||||
declare var SharedArrayBuffer: SharedArrayBufferConstructor;
|
||||
|
||||
interface ArrayBufferTypes {
|
||||
SharedArrayBuffer: SharedArrayBuffer;
|
||||
}
|
||||
|
||||
interface Atomics {
|
||||
/**
|
||||
* Adds a value to the value at the given position in the array, returning the original value.
|
||||
* Until this atomic operation completes, any other read or write operation against the array
|
||||
* will block.
|
||||
*/
|
||||
add(typedArray: Int8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>, index: number, value: number): number;
|
||||
|
||||
/**
|
||||
* Stores the bitwise AND of a value with the value at the given position in the array,
|
||||
* returning the original value. Until this atomic operation completes, any other read or
|
||||
* write operation against the array will block.
|
||||
*/
|
||||
and(typedArray: Int8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>, index: number, value: number): number;
|
||||
|
||||
/**
|
||||
* Replaces the value at the given position in the array if the original value equals the given
|
||||
* expected value, returning the original value. Until this atomic operation completes, any
|
||||
* other read or write operation against the array will block.
|
||||
*/
|
||||
compareExchange(typedArray: Int8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>, index: number, expectedValue: number, replacementValue: number): number;
|
||||
|
||||
/**
|
||||
* Replaces the value at the given position in the array, returning the original value. Until
|
||||
* this atomic operation completes, any other read or write operation against the array will
|
||||
* block.
|
||||
*/
|
||||
exchange(typedArray: Int8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>, index: number, value: number): number;
|
||||
|
||||
/**
|
||||
* Returns a value indicating whether high-performance algorithms can use atomic operations
|
||||
* (`true`) or must use locks (`false`) for the given number of bytes-per-element of a typed
|
||||
* array.
|
||||
*/
|
||||
isLockFree(size: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns the value at the given position in the array. Until this atomic operation completes,
|
||||
* any other read or write operation against the array will block.
|
||||
*/
|
||||
load(typedArray: Int8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>, index: number): number;
|
||||
|
||||
/**
|
||||
* Stores the bitwise OR of a value with the value at the given position in the array,
|
||||
* returning the original value. Until this atomic operation completes, any other read or write
|
||||
* operation against the array will block.
|
||||
*/
|
||||
or(typedArray: Int8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>, index: number, value: number): number;
|
||||
|
||||
/**
|
||||
* Stores a value at the given position in the array, returning the new value. Until this
|
||||
* atomic operation completes, any other read or write operation against the array will block.
|
||||
*/
|
||||
store(typedArray: Int8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>, index: number, value: number): number;
|
||||
|
||||
/**
|
||||
* Subtracts a value from the value at the given position in the array, returning the original
|
||||
* value. Until this atomic operation completes, any other read or write operation against the
|
||||
* array will block.
|
||||
*/
|
||||
sub(typedArray: Int8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>, index: number, value: number): number;
|
||||
|
||||
/**
|
||||
* If the value at the given position in the array is equal to the provided value, the current
|
||||
* agent is put to sleep causing execution to suspend until the timeout expires (returning
|
||||
* `"timed-out"`) or until the agent is awoken (returning `"ok"`); otherwise, returns
|
||||
* `"not-equal"`.
|
||||
*/
|
||||
wait(typedArray: Int32Array<ArrayBufferLike>, index: number, value: number, timeout?: number): "ok" | "not-equal" | "timed-out";
|
||||
|
||||
/**
|
||||
* Wakes up sleeping agents that are waiting on the given index of the array, returning the
|
||||
* number of agents that were awoken.
|
||||
* @param typedArray A shared Int32Array<ArrayBufferLike>.
|
||||
* @param index The position in the typedArray to wake up on.
|
||||
* @param count The number of sleeping agents to notify. Defaults to +Infinity.
|
||||
*/
|
||||
notify(typedArray: Int32Array<ArrayBufferLike>, index: number, count?: number): number;
|
||||
|
||||
/**
|
||||
* Stores the bitwise XOR of a value with the value at the given position in the array,
|
||||
* returning the original value. Until this atomic operation completes, any other read or write
|
||||
* operation against the array will block.
|
||||
*/
|
||||
xor(typedArray: Int8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>, index: number, value: number): number;
|
||||
|
||||
readonly [Symbol.toStringTag]: "Atomics";
|
||||
}
|
||||
|
||||
declare var Atomics: Atomics;
|
||||
45
kitcom/internal/tsgo/bundled/libs/lib.es2017.string.d.ts
vendored
Normal file
45
kitcom/internal/tsgo/bundled/libs/lib.es2017.string.d.ts
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
interface String {
|
||||
/**
|
||||
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
|
||||
* The padding is applied from the start (left) of the current string.
|
||||
*
|
||||
* @param maxLength The length of the resulting string once the current string has been padded.
|
||||
* If this parameter is smaller than the current string's length, the current string will be returned as it is.
|
||||
*
|
||||
* @param fillString The string to pad the current string with.
|
||||
* If this string is too long, it will be truncated and the left-most part will be applied.
|
||||
* The default value for this parameter is " " (U+0020).
|
||||
*/
|
||||
padStart(maxLength: number, fillString?: string): string;
|
||||
|
||||
/**
|
||||
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
|
||||
* The padding is applied from the end (right) of the current string.
|
||||
*
|
||||
* @param maxLength The length of the resulting string once the current string has been padded.
|
||||
* If this parameter is smaller than the current string's length, the current string will be returned as it is.
|
||||
*
|
||||
* @param fillString The string to pad the current string with.
|
||||
* If this string is too long, it will be truncated and the left-most part will be applied.
|
||||
* The default value for this parameter is " " (U+0020).
|
||||
*/
|
||||
padEnd(maxLength: number, fillString?: string): string;
|
||||
}
|
||||
53
kitcom/internal/tsgo/bundled/libs/lib.es2017.typedarrays.d.ts
vendored
Normal file
53
kitcom/internal/tsgo/bundled/libs/lib.es2017.typedarrays.d.ts
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
interface Int8ArrayConstructor {
|
||||
new (): Int8Array<ArrayBuffer>;
|
||||
}
|
||||
|
||||
interface Uint8ArrayConstructor {
|
||||
new (): Uint8Array<ArrayBuffer>;
|
||||
}
|
||||
|
||||
interface Uint8ClampedArrayConstructor {
|
||||
new (): Uint8ClampedArray<ArrayBuffer>;
|
||||
}
|
||||
|
||||
interface Int16ArrayConstructor {
|
||||
new (): Int16Array<ArrayBuffer>;
|
||||
}
|
||||
|
||||
interface Uint16ArrayConstructor {
|
||||
new (): Uint16Array<ArrayBuffer>;
|
||||
}
|
||||
|
||||
interface Int32ArrayConstructor {
|
||||
new (): Int32Array<ArrayBuffer>;
|
||||
}
|
||||
|
||||
interface Uint32ArrayConstructor {
|
||||
new (): Uint32Array<ArrayBuffer>;
|
||||
}
|
||||
|
||||
interface Float32ArrayConstructor {
|
||||
new (): Float32Array<ArrayBuffer>;
|
||||
}
|
||||
|
||||
interface Float64ArrayConstructor {
|
||||
new (): Float64Array<ArrayBuffer>;
|
||||
}
|
||||
77
kitcom/internal/tsgo/bundled/libs/lib.es2018.asyncgenerator.d.ts
vendored
Normal file
77
kitcom/internal/tsgo/bundled/libs/lib.es2018.asyncgenerator.d.ts
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2018.asynciterable" />
|
||||
|
||||
interface AsyncGenerator<T = unknown, TReturn = any, TNext = any> extends AsyncIteratorObject<T, TReturn, TNext> {
|
||||
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
|
||||
next(...[value]: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
|
||||
return(value: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<T, TReturn>>;
|
||||
throw(e: any): Promise<IteratorResult<T, TReturn>>;
|
||||
[Symbol.asyncIterator](): AsyncGenerator<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
interface AsyncGeneratorFunction {
|
||||
/**
|
||||
* Creates a new AsyncGenerator object.
|
||||
* @param args A list of arguments the function accepts.
|
||||
*/
|
||||
new (...args: any[]): AsyncGenerator;
|
||||
/**
|
||||
* Creates a new AsyncGenerator object.
|
||||
* @param args A list of arguments the function accepts.
|
||||
*/
|
||||
(...args: any[]): AsyncGenerator;
|
||||
/**
|
||||
* The length of the arguments.
|
||||
*/
|
||||
readonly length: number;
|
||||
/**
|
||||
* Returns the name of the function.
|
||||
*/
|
||||
readonly name: string;
|
||||
/**
|
||||
* A reference to the prototype.
|
||||
*/
|
||||
readonly prototype: AsyncGenerator;
|
||||
}
|
||||
|
||||
interface AsyncGeneratorFunctionConstructor {
|
||||
/**
|
||||
* Creates a new AsyncGenerator function.
|
||||
* @param args A list of arguments the function accepts.
|
||||
*/
|
||||
new (...args: string[]): AsyncGeneratorFunction;
|
||||
/**
|
||||
* Creates a new AsyncGenerator function.
|
||||
* @param args A list of arguments the function accepts.
|
||||
*/
|
||||
(...args: string[]): AsyncGeneratorFunction;
|
||||
/**
|
||||
* The length of the arguments.
|
||||
*/
|
||||
readonly length: number;
|
||||
/**
|
||||
* Returns the name of the function.
|
||||
*/
|
||||
readonly name: string;
|
||||
/**
|
||||
* A reference to the prototype.
|
||||
*/
|
||||
readonly prototype: AsyncGeneratorFunction;
|
||||
}
|
||||
53
kitcom/internal/tsgo/bundled/libs/lib.es2018.asynciterable.d.ts
vendored
Normal file
53
kitcom/internal/tsgo/bundled/libs/lib.es2018.asynciterable.d.ts
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2015.symbol" />
|
||||
/// <reference lib="es2015.iterable" />
|
||||
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
* A method that returns the default async iterator for an object. Called by the semantics of
|
||||
* the for-await-of statement.
|
||||
*/
|
||||
readonly asyncIterator: unique symbol;
|
||||
}
|
||||
|
||||
interface AsyncIterator<T, TReturn = any, TNext = any> {
|
||||
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
|
||||
next(...[value]: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
|
||||
return?(value?: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<T, TReturn>>;
|
||||
throw?(e?: any): Promise<IteratorResult<T, TReturn>>;
|
||||
}
|
||||
|
||||
interface AsyncIterable<T, TReturn = any, TNext = any> {
|
||||
[Symbol.asyncIterator](): AsyncIterator<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes a user-defined {@link AsyncIterator} that is also async iterable.
|
||||
*/
|
||||
interface AsyncIterableIterator<T, TReturn = any, TNext = any> extends AsyncIterator<T, TReturn, TNext> {
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes an {@link AsyncIterator} produced by the runtime that inherits from the intrinsic `AsyncIterator.prototype`.
|
||||
*/
|
||||
interface AsyncIteratorObject<T, TReturn = unknown, TNext = unknown> extends AsyncIterator<T, TReturn, TNext> {
|
||||
[Symbol.asyncIterator](): AsyncIteratorObject<T, TReturn, TNext>;
|
||||
}
|
||||
24
kitcom/internal/tsgo/bundled/libs/lib.es2018.d.ts
vendored
Normal file
24
kitcom/internal/tsgo/bundled/libs/lib.es2018.d.ts
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2017" />
|
||||
/// <reference lib="es2018.asynciterable" />
|
||||
/// <reference lib="es2018.asyncgenerator" />
|
||||
/// <reference lib="es2018.promise" />
|
||||
/// <reference lib="es2018.regexp" />
|
||||
/// <reference lib="es2018.intl" />
|
||||
24
kitcom/internal/tsgo/bundled/libs/lib.es2018.full.d.ts
vendored
Normal file
24
kitcom/internal/tsgo/bundled/libs/lib.es2018.full.d.ts
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2018" />
|
||||
/// <reference lib="dom" />
|
||||
/// <reference lib="webworker.importscripts" />
|
||||
/// <reference lib="scripthost" />
|
||||
/// <reference lib="dom.iterable" />
|
||||
/// <reference lib="dom.asynciterable" />
|
||||
83
kitcom/internal/tsgo/bundled/libs/lib.es2018.intl.d.ts
vendored
Normal file
83
kitcom/internal/tsgo/bundled/libs/lib.es2018.intl.d.ts
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
declare namespace Intl {
|
||||
// http://cldr.unicode.org/index/cldr-spec/plural-rules#TOC-Determining-Plural-Categories
|
||||
type LDMLPluralRule = "zero" | "one" | "two" | "few" | "many" | "other";
|
||||
type PluralRuleType = "cardinal" | "ordinal";
|
||||
|
||||
interface PluralRulesOptions {
|
||||
localeMatcher?: "lookup" | "best fit" | undefined;
|
||||
type?: PluralRuleType | undefined;
|
||||
minimumIntegerDigits?: number | undefined;
|
||||
minimumFractionDigits?: number | undefined;
|
||||
maximumFractionDigits?: number | undefined;
|
||||
minimumSignificantDigits?: number | undefined;
|
||||
maximumSignificantDigits?: number | undefined;
|
||||
}
|
||||
|
||||
interface ResolvedPluralRulesOptions {
|
||||
locale: string;
|
||||
pluralCategories: LDMLPluralRule[];
|
||||
type: PluralRuleType;
|
||||
minimumIntegerDigits: number;
|
||||
minimumFractionDigits: number;
|
||||
maximumFractionDigits: number;
|
||||
minimumSignificantDigits?: number;
|
||||
maximumSignificantDigits?: number;
|
||||
}
|
||||
|
||||
interface PluralRules {
|
||||
resolvedOptions(): ResolvedPluralRulesOptions;
|
||||
select(n: number): LDMLPluralRule;
|
||||
}
|
||||
|
||||
interface PluralRulesConstructor {
|
||||
new (locales?: string | readonly string[], options?: PluralRulesOptions): PluralRules;
|
||||
(locales?: string | readonly string[], options?: PluralRulesOptions): PluralRules;
|
||||
supportedLocalesOf(locales: string | readonly string[], options?: { localeMatcher?: "lookup" | "best fit"; }): string[];
|
||||
}
|
||||
|
||||
const PluralRules: PluralRulesConstructor;
|
||||
|
||||
interface NumberFormatPartTypeRegistry {
|
||||
literal: never;
|
||||
nan: never;
|
||||
infinity: never;
|
||||
percent: never;
|
||||
integer: never;
|
||||
group: never;
|
||||
decimal: never;
|
||||
fraction: never;
|
||||
plusSign: never;
|
||||
minusSign: never;
|
||||
percentSign: never;
|
||||
currency: never;
|
||||
}
|
||||
|
||||
type NumberFormatPartTypes = keyof NumberFormatPartTypeRegistry;
|
||||
|
||||
interface NumberFormatPart {
|
||||
type: NumberFormatPartTypes;
|
||||
value: string;
|
||||
}
|
||||
|
||||
interface NumberFormat {
|
||||
formatToParts(number?: number | bigint): NumberFormatPart[];
|
||||
}
|
||||
}
|
||||
30
kitcom/internal/tsgo/bundled/libs/lib.es2018.promise.d.ts
vendored
Normal file
30
kitcom/internal/tsgo/bundled/libs/lib.es2018.promise.d.ts
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/**
|
||||
* Represents the completion of an asynchronous operation
|
||||
*/
|
||||
interface Promise<T> {
|
||||
/**
|
||||
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
|
||||
* resolved value cannot be modified from the callback.
|
||||
* @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
|
||||
* @returns A Promise for the completion of the callback.
|
||||
*/
|
||||
finally(onfinally?: (() => void) | undefined | null): Promise<T>;
|
||||
}
|
||||
37
kitcom/internal/tsgo/bundled/libs/lib.es2018.regexp.d.ts
vendored
Normal file
37
kitcom/internal/tsgo/bundled/libs/lib.es2018.regexp.d.ts
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
interface RegExpMatchArray {
|
||||
groups?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface RegExpExecArray {
|
||||
groups?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface RegExp {
|
||||
/**
|
||||
* Returns a Boolean value indicating the state of the dotAll flag (s) used with a regular expression.
|
||||
* Default is false. Read-only.
|
||||
*/
|
||||
readonly dotAll: boolean;
|
||||
}
|
||||
79
kitcom/internal/tsgo/bundled/libs/lib.es2019.array.d.ts
vendored
Normal file
79
kitcom/internal/tsgo/bundled/libs/lib.es2019.array.d.ts
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
type FlatArray<Arr, Depth extends number> = {
|
||||
done: Arr;
|
||||
recur: Arr extends ReadonlyArray<infer InnerArr> ? FlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][Depth]>
|
||||
: Arr;
|
||||
}[Depth extends -1 ? "done" : "recur"];
|
||||
|
||||
interface ReadonlyArray<T> {
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array. Then, flattens the result into
|
||||
* a new array.
|
||||
* This is identical to a map followed by flat with depth 1.
|
||||
*
|
||||
* @param callback A function that accepts up to three arguments. The flatMap method calls the
|
||||
* callback function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callback function. If
|
||||
* thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
flatMap<U, This = undefined>(
|
||||
callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray<U>,
|
||||
thisArg?: This,
|
||||
): U[];
|
||||
|
||||
/**
|
||||
* Returns a new array with all sub-array elements concatenated into it recursively up to the
|
||||
* specified depth.
|
||||
*
|
||||
* @param depth The maximum recursion depth
|
||||
*/
|
||||
flat<A, D extends number = 1>(
|
||||
this: A,
|
||||
depth?: D,
|
||||
): FlatArray<A, D>[];
|
||||
}
|
||||
|
||||
interface Array<T> {
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array. Then, flattens the result into
|
||||
* a new array.
|
||||
* This is identical to a map followed by flat with depth 1.
|
||||
*
|
||||
* @param callback A function that accepts up to three arguments. The flatMap method calls the
|
||||
* callback function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callback function. If
|
||||
* thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
flatMap<U, This = undefined>(
|
||||
callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray<U>,
|
||||
thisArg?: This,
|
||||
): U[];
|
||||
|
||||
/**
|
||||
* Returns a new array with all sub-array elements concatenated into it recursively up to the
|
||||
* specified depth.
|
||||
*
|
||||
* @param depth The maximum recursion depth
|
||||
*/
|
||||
flat<A, D extends number = 1>(
|
||||
this: A,
|
||||
depth?: D,
|
||||
): FlatArray<A, D>[];
|
||||
}
|
||||
24
kitcom/internal/tsgo/bundled/libs/lib.es2019.d.ts
vendored
Normal file
24
kitcom/internal/tsgo/bundled/libs/lib.es2019.d.ts
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2018" />
|
||||
/// <reference lib="es2019.array" />
|
||||
/// <reference lib="es2019.object" />
|
||||
/// <reference lib="es2019.string" />
|
||||
/// <reference lib="es2019.symbol" />
|
||||
/// <reference lib="es2019.intl" />
|
||||
24
kitcom/internal/tsgo/bundled/libs/lib.es2019.full.d.ts
vendored
Normal file
24
kitcom/internal/tsgo/bundled/libs/lib.es2019.full.d.ts
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2019" />
|
||||
/// <reference lib="dom" />
|
||||
/// <reference lib="webworker.importscripts" />
|
||||
/// <reference lib="scripthost" />
|
||||
/// <reference lib="dom.iterable" />
|
||||
/// <reference lib="dom.asynciterable" />
|
||||
23
kitcom/internal/tsgo/bundled/libs/lib.es2019.intl.d.ts
vendored
Normal file
23
kitcom/internal/tsgo/bundled/libs/lib.es2019.intl.d.ts
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
declare namespace Intl {
|
||||
interface DateTimeFormatPartTypesRegistry {
|
||||
unknown: never;
|
||||
}
|
||||
}
|
||||
33
kitcom/internal/tsgo/bundled/libs/lib.es2019.object.d.ts
vendored
Normal file
33
kitcom/internal/tsgo/bundled/libs/lib.es2019.object.d.ts
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2015.iterable" />
|
||||
|
||||
interface ObjectConstructor {
|
||||
/**
|
||||
* Returns an object created by key-value entries for properties and methods
|
||||
* @param entries An iterable object that contains key-value entries for properties and methods.
|
||||
*/
|
||||
fromEntries<T = any>(entries: Iterable<readonly [PropertyKey, T]>): { [k: string]: T; };
|
||||
|
||||
/**
|
||||
* Returns an object created by key-value entries for properties and methods
|
||||
* @param entries An iterable object that contains key-value entries for properties and methods.
|
||||
*/
|
||||
fromEntries(entries: Iterable<readonly any[]>): any;
|
||||
}
|
||||
37
kitcom/internal/tsgo/bundled/libs/lib.es2019.string.d.ts
vendored
Normal file
37
kitcom/internal/tsgo/bundled/libs/lib.es2019.string.d.ts
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
interface String {
|
||||
/** Removes the trailing white space and line terminator characters from a string. */
|
||||
trimEnd(): string;
|
||||
|
||||
/** Removes the leading white space and line terminator characters from a string. */
|
||||
trimStart(): string;
|
||||
|
||||
/**
|
||||
* Removes the leading white space and line terminator characters from a string.
|
||||
* @deprecated A legacy feature for browser compatibility. Use `trimStart` instead
|
||||
*/
|
||||
trimLeft(): string;
|
||||
|
||||
/**
|
||||
* Removes the trailing white space and line terminator characters from a string.
|
||||
* @deprecated A legacy feature for browser compatibility. Use `trimEnd` instead
|
||||
*/
|
||||
trimRight(): string;
|
||||
}
|
||||
24
kitcom/internal/tsgo/bundled/libs/lib.es2019.symbol.d.ts
vendored
Normal file
24
kitcom/internal/tsgo/bundled/libs/lib.es2019.symbol.d.ts
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
interface Symbol {
|
||||
/**
|
||||
* Expose the [[Description]] internal slot of a symbol directly.
|
||||
*/
|
||||
readonly description: string | undefined;
|
||||
}
|
||||
765
kitcom/internal/tsgo/bundled/libs/lib.es2020.bigint.d.ts
vendored
Normal file
765
kitcom/internal/tsgo/bundled/libs/lib.es2020.bigint.d.ts
vendored
Normal file
@ -0,0 +1,765 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2020.intl" />
|
||||
|
||||
interface BigIntToLocaleStringOptions {
|
||||
/**
|
||||
* The locale matching algorithm to use.The default is "best fit". For information about this option, see the {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation Intl page}.
|
||||
*/
|
||||
localeMatcher?: string;
|
||||
/**
|
||||
* The formatting style to use , the default is "decimal".
|
||||
*/
|
||||
style?: string;
|
||||
|
||||
numberingSystem?: string;
|
||||
/**
|
||||
* The unit to use in unit formatting, Possible values are core unit identifiers, defined in UTS #35, Part 2, Section 6. A subset of units from the full list was selected for use in ECMAScript. Pairs of simple units can be concatenated with "-per-" to make a compound unit. There is no default value; if the style is "unit", the unit property must be provided.
|
||||
*/
|
||||
unit?: string;
|
||||
|
||||
/**
|
||||
* The unit formatting style to use in unit formatting, the defaults is "short".
|
||||
*/
|
||||
unitDisplay?: string;
|
||||
|
||||
/**
|
||||
* The currency to use in currency formatting. Possible values are the ISO 4217 currency codes, such as "USD" for the US dollar, "EUR" for the euro, or "CNY" for the Chinese RMB — see the Current currency & funds code list. There is no default value; if the style is "currency", the currency property must be provided. It is only used when [[Style]] has the value "currency".
|
||||
*/
|
||||
currency?: string;
|
||||
|
||||
/**
|
||||
* How to display the currency in currency formatting. It is only used when [[Style]] has the value "currency". The default is "symbol".
|
||||
*
|
||||
* "symbol" to use a localized currency symbol such as €,
|
||||
*
|
||||
* "code" to use the ISO currency code,
|
||||
*
|
||||
* "name" to use a localized currency name such as "dollar"
|
||||
*/
|
||||
currencyDisplay?: string;
|
||||
|
||||
/**
|
||||
* Whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators. The default is true.
|
||||
*/
|
||||
useGrouping?: boolean;
|
||||
|
||||
/**
|
||||
* The minimum number of integer digits to use. Possible values are from 1 to 21; the default is 1.
|
||||
*/
|
||||
minimumIntegerDigits?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21;
|
||||
|
||||
/**
|
||||
* The minimum number of fraction digits to use. Possible values are from 0 to 20; the default for plain number and percent formatting is 0; the default for currency formatting is the number of minor unit digits provided by the {@link http://www.currency-iso.org/en/home/tables/table-a1.html ISO 4217 currency codes list} (2 if the list doesn't provide that information).
|
||||
*/
|
||||
minimumFractionDigits?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20;
|
||||
|
||||
/**
|
||||
* The maximum number of fraction digits to use. Possible values are from 0 to 20; the default for plain number formatting is the larger of minimumFractionDigits and 3; the default for currency formatting is the larger of minimumFractionDigits and the number of minor unit digits provided by the {@link http://www.currency-iso.org/en/home/tables/table-a1.html ISO 4217 currency codes list} (2 if the list doesn't provide that information); the default for percent formatting is the larger of minimumFractionDigits and 0.
|
||||
*/
|
||||
maximumFractionDigits?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20;
|
||||
|
||||
/**
|
||||
* The minimum number of significant digits to use. Possible values are from 1 to 21; the default is 1.
|
||||
*/
|
||||
minimumSignificantDigits?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21;
|
||||
|
||||
/**
|
||||
* The maximum number of significant digits to use. Possible values are from 1 to 21; the default is 21.
|
||||
*/
|
||||
maximumSignificantDigits?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21;
|
||||
|
||||
/**
|
||||
* The formatting that should be displayed for the number, the defaults is "standard"
|
||||
*
|
||||
* "standard" plain number formatting
|
||||
*
|
||||
* "scientific" return the order-of-magnitude for formatted number.
|
||||
*
|
||||
* "engineering" return the exponent of ten when divisible by three
|
||||
*
|
||||
* "compact" string representing exponent, defaults is using the "short" form
|
||||
*/
|
||||
notation?: string;
|
||||
|
||||
/**
|
||||
* used only when notation is "compact"
|
||||
*/
|
||||
compactDisplay?: string;
|
||||
}
|
||||
|
||||
interface BigInt {
|
||||
/**
|
||||
* Returns a string representation of an object.
|
||||
* @param radix Specifies a radix for converting numeric values to strings.
|
||||
*/
|
||||
toString(radix?: number): string;
|
||||
|
||||
/** Returns a string representation appropriate to the host environment's current locale. */
|
||||
toLocaleString(locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions): string;
|
||||
|
||||
/** Returns the primitive value of the specified object. */
|
||||
valueOf(): bigint;
|
||||
|
||||
readonly [Symbol.toStringTag]: "BigInt";
|
||||
}
|
||||
|
||||
interface BigIntConstructor {
|
||||
(value: bigint | boolean | number | string): bigint;
|
||||
readonly prototype: BigInt;
|
||||
|
||||
/**
|
||||
* Interprets the low bits of a BigInt as a 2's-complement signed integer.
|
||||
* All higher bits are discarded.
|
||||
* @param bits The number of low bits to use
|
||||
* @param int The BigInt whose bits to extract
|
||||
*/
|
||||
asIntN(bits: number, int: bigint): bigint;
|
||||
/**
|
||||
* Interprets the low bits of a BigInt as an unsigned integer.
|
||||
* All higher bits are discarded.
|
||||
* @param bits The number of low bits to use
|
||||
* @param int The BigInt whose bits to extract
|
||||
*/
|
||||
asUintN(bits: number, int: bigint): bigint;
|
||||
}
|
||||
|
||||
declare var BigInt: BigIntConstructor;
|
||||
|
||||
/**
|
||||
* A typed array of 64-bit signed integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated, an exception is raised.
|
||||
*/
|
||||
interface BigInt64Array<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> {
|
||||
/** The size in bytes of each element in the array. */
|
||||
readonly BYTES_PER_ELEMENT: number;
|
||||
|
||||
/** The ArrayBuffer instance referenced by the array. */
|
||||
readonly buffer: TArrayBuffer;
|
||||
|
||||
/** The length in bytes of the array. */
|
||||
readonly byteLength: number;
|
||||
|
||||
/** The offset in bytes of the array. */
|
||||
readonly byteOffset: number;
|
||||
|
||||
/**
|
||||
* Returns the this object after copying a section of the array identified by start and end
|
||||
* to the same array starting at position target
|
||||
* @param target If target is negative, it is treated as length+target where length is the
|
||||
* length of the array.
|
||||
* @param start If start is negative, it is treated as length+start. If end is negative, it
|
||||
* is treated as length+end.
|
||||
* @param end If not specified, length of the this object is used as its default value.
|
||||
*/
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
|
||||
/** Yields index, value pairs for every entry in the array. */
|
||||
entries(): ArrayIterator<[number, bigint]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
* @param predicate A function that accepts up to three arguments. The every method calls
|
||||
* the predicate function for each element in the array until the predicate returns false,
|
||||
* or until the end of the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the predicate function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
every(predicate: (value: bigint, index: number, array: BigInt64Array<TArrayBuffer>) => boolean, thisArg?: any): boolean;
|
||||
|
||||
/**
|
||||
* Changes all array elements from `start` to `end` index to a static `value` and returns the modified array
|
||||
* @param value value to fill array section with
|
||||
* @param start index to start filling the array at. If start is negative, it is treated as
|
||||
* length+start where length is the length of the array.
|
||||
* @param end index to stop filling the array at. If end is negative, it is treated as
|
||||
* length+end.
|
||||
*/
|
||||
fill(value: bigint, start?: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Returns the elements of an array that meet the condition specified in a callback function.
|
||||
* @param predicate A function that accepts up to three arguments. The filter method calls
|
||||
* the predicate function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the predicate function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
filter(predicate: (value: bigint, index: number, array: BigInt64Array<TArrayBuffer>) => any, thisArg?: any): BigInt64Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Returns the value of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
find(predicate: (value: bigint, index: number, array: BigInt64Array<TArrayBuffer>) => boolean, thisArg?: any): bigint | undefined;
|
||||
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: bigint, index: number, array: BigInt64Array<TArrayBuffer>) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
* @param callbackfn A function that accepts up to three arguments. forEach calls the
|
||||
* callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
forEach(callbackfn: (value: bigint, index: number, array: BigInt64Array<TArrayBuffer>) => void, thisArg?: any): void;
|
||||
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: bigint, fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns the index of the first occurrence of a value in an array.
|
||||
* @param searchElement The value to locate in the array.
|
||||
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
|
||||
* search starts at index 0.
|
||||
*/
|
||||
indexOf(searchElement: bigint, fromIndex?: number): number;
|
||||
|
||||
/**
|
||||
* Adds all the elements of an array separated by the specified separator string.
|
||||
* @param separator A string used to separate one element of an array from the next in the
|
||||
* resulting String. If omitted, the array elements are separated with a comma.
|
||||
*/
|
||||
join(separator?: string): string;
|
||||
|
||||
/** Yields each index in the array. */
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
* @param searchElement The value to locate in the array.
|
||||
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
|
||||
* search starts at index 0.
|
||||
*/
|
||||
lastIndexOf(searchElement: bigint, fromIndex?: number): number;
|
||||
|
||||
/** The length of the array. */
|
||||
readonly length: number;
|
||||
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that
|
||||
* contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the
|
||||
* callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map(callbackfn: (value: bigint, index: number, array: BigInt64Array<TArrayBuffer>) => bigint, thisArg?: any): BigInt64Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array. The return value of
|
||||
* the callback function is the accumulated result, and is provided as an argument in the next
|
||||
* call to the callback function.
|
||||
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the
|
||||
* callbackfn function one time for each element in the array.
|
||||
* @param initialValue If initialValue is specified, it is used as the initial value to start
|
||||
* the accumulation. The first call to the callbackfn function provides this value as an argument
|
||||
* instead of an array value.
|
||||
*/
|
||||
reduce(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array<TArrayBuffer>) => bigint): bigint;
|
||||
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array. The return value of
|
||||
* the callback function is the accumulated result, and is provided as an argument in the next
|
||||
* call to the callback function.
|
||||
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the
|
||||
* callbackfn function one time for each element in the array.
|
||||
* @param initialValue If initialValue is specified, it is used as the initial value to start
|
||||
* the accumulation. The first call to the callbackfn function provides this value as an argument
|
||||
* instead of an array value.
|
||||
*/
|
||||
reduce<U>(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array<TArrayBuffer>) => U, initialValue: U): U;
|
||||
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array, in descending order.
|
||||
* The return value of the callback function is the accumulated result, and is provided as an
|
||||
* argument in the next call to the callback function.
|
||||
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls
|
||||
* the callbackfn function one time for each element in the array.
|
||||
* @param initialValue If initialValue is specified, it is used as the initial value to start
|
||||
* the accumulation. The first call to the callbackfn function provides this value as an
|
||||
* argument instead of an array value.
|
||||
*/
|
||||
reduceRight(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array<TArrayBuffer>) => bigint): bigint;
|
||||
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array, in descending order.
|
||||
* The return value of the callback function is the accumulated result, and is provided as an
|
||||
* argument in the next call to the callback function.
|
||||
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls
|
||||
* the callbackfn function one time for each element in the array.
|
||||
* @param initialValue If initialValue is specified, it is used as the initial value to start
|
||||
* the accumulation. The first call to the callbackfn function provides this value as an argument
|
||||
* instead of an array value.
|
||||
*/
|
||||
reduceRight<U>(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array<TArrayBuffer>) => U, initialValue: U): U;
|
||||
|
||||
/** Reverses the elements in the array. */
|
||||
reverse(): this;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param array A typed or untyped array of values to set.
|
||||
* @param offset The index in the current array at which the values are to be written.
|
||||
*/
|
||||
set(array: ArrayLike<bigint>, offset?: number): void;
|
||||
|
||||
/**
|
||||
* Returns a section of an array.
|
||||
* @param start The beginning of the specified portion of the array.
|
||||
* @param end The end of the specified portion of the array.
|
||||
*/
|
||||
slice(start?: number, end?: number): BigInt64Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Determines whether the specified callback function returns true for any element of an array.
|
||||
* @param predicate A function that accepts up to three arguments. The some method calls the
|
||||
* predicate function for each element in the array until the predicate returns true, or until
|
||||
* the end of the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the predicate function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
some(predicate: (value: bigint, index: number, array: BigInt64Array<TArrayBuffer>) => boolean, thisArg?: any): boolean;
|
||||
|
||||
/**
|
||||
* Sorts the array.
|
||||
* @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order.
|
||||
*/
|
||||
sort(compareFn?: (a: bigint, b: bigint) => number | bigint): this;
|
||||
|
||||
/**
|
||||
* Gets a new BigInt64Array view of the ArrayBuffer store for this array, referencing the elements
|
||||
* at begin, inclusive, up to end, exclusive.
|
||||
* @param begin The index of the beginning of the array.
|
||||
* @param end The index of the end of the array.
|
||||
*/
|
||||
subarray(begin?: number, end?: number): BigInt64Array<TArrayBuffer>;
|
||||
|
||||
/** Converts the array to a string by using the current locale. */
|
||||
toLocaleString(locales?: string | string[], options?: Intl.NumberFormatOptions): string;
|
||||
|
||||
/** Returns a string representation of the array. */
|
||||
toString(): string;
|
||||
|
||||
/** Returns the primitive value of the specified object. */
|
||||
valueOf(): BigInt64Array<TArrayBuffer>;
|
||||
|
||||
/** Yields each value in the array. */
|
||||
values(): ArrayIterator<bigint>;
|
||||
|
||||
[Symbol.iterator](): ArrayIterator<bigint>;
|
||||
|
||||
readonly [Symbol.toStringTag]: "BigInt64Array";
|
||||
|
||||
[index: number]: bigint;
|
||||
}
|
||||
interface BigInt64ArrayConstructor {
|
||||
readonly prototype: BigInt64Array<ArrayBufferLike>;
|
||||
new (length?: number): BigInt64Array<ArrayBuffer>;
|
||||
new (array: ArrayLike<bigint> | Iterable<bigint>): BigInt64Array<ArrayBuffer>;
|
||||
new <TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(buffer: TArrayBuffer, byteOffset?: number, length?: number): BigInt64Array<TArrayBuffer>;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): BigInt64Array<ArrayBuffer>;
|
||||
new (array: ArrayLike<bigint> | ArrayBuffer): BigInt64Array<ArrayBuffer>;
|
||||
|
||||
/** The size in bytes of each element in the array. */
|
||||
readonly BYTES_PER_ELEMENT: number;
|
||||
|
||||
/**
|
||||
* Returns a new array from a set of elements.
|
||||
* @param items A set of elements to include in the new array object.
|
||||
*/
|
||||
of(...items: bigint[]): BigInt64Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like object to convert to an array.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<bigint>): BigInt64Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from<U>(arrayLike: ArrayLike<U>, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigInt64Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
*/
|
||||
from(elements: Iterable<bigint>): BigInt64Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => bigint, thisArg?: any): BigInt64Array<ArrayBuffer>;
|
||||
}
|
||||
declare var BigInt64Array: BigInt64ArrayConstructor;
|
||||
|
||||
/**
|
||||
* A typed array of 64-bit unsigned integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated, an exception is raised.
|
||||
*/
|
||||
interface BigUint64Array<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> {
|
||||
/** The size in bytes of each element in the array. */
|
||||
readonly BYTES_PER_ELEMENT: number;
|
||||
|
||||
/** The ArrayBuffer instance referenced by the array. */
|
||||
readonly buffer: TArrayBuffer;
|
||||
|
||||
/** The length in bytes of the array. */
|
||||
readonly byteLength: number;
|
||||
|
||||
/** The offset in bytes of the array. */
|
||||
readonly byteOffset: number;
|
||||
|
||||
/**
|
||||
* Returns the this object after copying a section of the array identified by start and end
|
||||
* to the same array starting at position target
|
||||
* @param target If target is negative, it is treated as length+target where length is the
|
||||
* length of the array.
|
||||
* @param start If start is negative, it is treated as length+start. If end is negative, it
|
||||
* is treated as length+end.
|
||||
* @param end If not specified, length of the this object is used as its default value.
|
||||
*/
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
|
||||
/** Yields index, value pairs for every entry in the array. */
|
||||
entries(): ArrayIterator<[number, bigint]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
* @param predicate A function that accepts up to three arguments. The every method calls
|
||||
* the predicate function for each element in the array until the predicate returns false,
|
||||
* or until the end of the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the predicate function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
every(predicate: (value: bigint, index: number, array: BigUint64Array<TArrayBuffer>) => boolean, thisArg?: any): boolean;
|
||||
|
||||
/**
|
||||
* Changes all array elements from `start` to `end` index to a static `value` and returns the modified array
|
||||
* @param value value to fill array section with
|
||||
* @param start index to start filling the array at. If start is negative, it is treated as
|
||||
* length+start where length is the length of the array.
|
||||
* @param end index to stop filling the array at. If end is negative, it is treated as
|
||||
* length+end.
|
||||
*/
|
||||
fill(value: bigint, start?: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Returns the elements of an array that meet the condition specified in a callback function.
|
||||
* @param predicate A function that accepts up to three arguments. The filter method calls
|
||||
* the predicate function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the predicate function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
filter(predicate: (value: bigint, index: number, array: BigUint64Array<TArrayBuffer>) => any, thisArg?: any): BigUint64Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Returns the value of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
find(predicate: (value: bigint, index: number, array: BigUint64Array<TArrayBuffer>) => boolean, thisArg?: any): bigint | undefined;
|
||||
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
findIndex(predicate: (value: bigint, index: number, array: BigUint64Array<TArrayBuffer>) => boolean, thisArg?: any): number;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
* @param callbackfn A function that accepts up to three arguments. forEach calls the
|
||||
* callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
forEach(callbackfn: (value: bigint, index: number, array: BigUint64Array<TArrayBuffer>) => void, thisArg?: any): void;
|
||||
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: bigint, fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns the index of the first occurrence of a value in an array.
|
||||
* @param searchElement The value to locate in the array.
|
||||
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
|
||||
* search starts at index 0.
|
||||
*/
|
||||
indexOf(searchElement: bigint, fromIndex?: number): number;
|
||||
|
||||
/**
|
||||
* Adds all the elements of an array separated by the specified separator string.
|
||||
* @param separator A string used to separate one element of an array from the next in the
|
||||
* resulting String. If omitted, the array elements are separated with a comma.
|
||||
*/
|
||||
join(separator?: string): string;
|
||||
|
||||
/** Yields each index in the array. */
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
* @param searchElement The value to locate in the array.
|
||||
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
|
||||
* search starts at index 0.
|
||||
*/
|
||||
lastIndexOf(searchElement: bigint, fromIndex?: number): number;
|
||||
|
||||
/** The length of the array. */
|
||||
readonly length: number;
|
||||
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that
|
||||
* contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the
|
||||
* callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map(callbackfn: (value: bigint, index: number, array: BigUint64Array<TArrayBuffer>) => bigint, thisArg?: any): BigUint64Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array. The return value of
|
||||
* the callback function is the accumulated result, and is provided as an argument in the next
|
||||
* call to the callback function.
|
||||
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the
|
||||
* callbackfn function one time for each element in the array.
|
||||
* @param initialValue If initialValue is specified, it is used as the initial value to start
|
||||
* the accumulation. The first call to the callbackfn function provides this value as an argument
|
||||
* instead of an array value.
|
||||
*/
|
||||
reduce(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array<TArrayBuffer>) => bigint): bigint;
|
||||
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array. The return value of
|
||||
* the callback function is the accumulated result, and is provided as an argument in the next
|
||||
* call to the callback function.
|
||||
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the
|
||||
* callbackfn function one time for each element in the array.
|
||||
* @param initialValue If initialValue is specified, it is used as the initial value to start
|
||||
* the accumulation. The first call to the callbackfn function provides this value as an argument
|
||||
* instead of an array value.
|
||||
*/
|
||||
reduce<U>(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array<TArrayBuffer>) => U, initialValue: U): U;
|
||||
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array, in descending order.
|
||||
* The return value of the callback function is the accumulated result, and is provided as an
|
||||
* argument in the next call to the callback function.
|
||||
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls
|
||||
* the callbackfn function one time for each element in the array.
|
||||
* @param initialValue If initialValue is specified, it is used as the initial value to start
|
||||
* the accumulation. The first call to the callbackfn function provides this value as an
|
||||
* argument instead of an array value.
|
||||
*/
|
||||
reduceRight(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array<TArrayBuffer>) => bigint): bigint;
|
||||
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array, in descending order.
|
||||
* The return value of the callback function is the accumulated result, and is provided as an
|
||||
* argument in the next call to the callback function.
|
||||
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls
|
||||
* the callbackfn function one time for each element in the array.
|
||||
* @param initialValue If initialValue is specified, it is used as the initial value to start
|
||||
* the accumulation. The first call to the callbackfn function provides this value as an argument
|
||||
* instead of an array value.
|
||||
*/
|
||||
reduceRight<U>(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array<TArrayBuffer>) => U, initialValue: U): U;
|
||||
|
||||
/** Reverses the elements in the array. */
|
||||
reverse(): this;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param array A typed or untyped array of values to set.
|
||||
* @param offset The index in the current array at which the values are to be written.
|
||||
*/
|
||||
set(array: ArrayLike<bigint>, offset?: number): void;
|
||||
|
||||
/**
|
||||
* Returns a section of an array.
|
||||
* @param start The beginning of the specified portion of the array.
|
||||
* @param end The end of the specified portion of the array.
|
||||
*/
|
||||
slice(start?: number, end?: number): BigUint64Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Determines whether the specified callback function returns true for any element of an array.
|
||||
* @param predicate A function that accepts up to three arguments. The some method calls the
|
||||
* predicate function for each element in the array until the predicate returns true, or until
|
||||
* the end of the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the predicate function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
some(predicate: (value: bigint, index: number, array: BigUint64Array<TArrayBuffer>) => boolean, thisArg?: any): boolean;
|
||||
|
||||
/**
|
||||
* Sorts the array.
|
||||
* @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order.
|
||||
*/
|
||||
sort(compareFn?: (a: bigint, b: bigint) => number | bigint): this;
|
||||
|
||||
/**
|
||||
* Gets a new BigUint64Array view of the ArrayBuffer store for this array, referencing the elements
|
||||
* at begin, inclusive, up to end, exclusive.
|
||||
* @param begin The index of the beginning of the array.
|
||||
* @param end The index of the end of the array.
|
||||
*/
|
||||
subarray(begin?: number, end?: number): BigUint64Array<TArrayBuffer>;
|
||||
|
||||
/** Converts the array to a string by using the current locale. */
|
||||
toLocaleString(locales?: string | string[], options?: Intl.NumberFormatOptions): string;
|
||||
|
||||
/** Returns a string representation of the array. */
|
||||
toString(): string;
|
||||
|
||||
/** Returns the primitive value of the specified object. */
|
||||
valueOf(): BigUint64Array<TArrayBuffer>;
|
||||
|
||||
/** Yields each value in the array. */
|
||||
values(): ArrayIterator<bigint>;
|
||||
|
||||
[Symbol.iterator](): ArrayIterator<bigint>;
|
||||
|
||||
readonly [Symbol.toStringTag]: "BigUint64Array";
|
||||
|
||||
[index: number]: bigint;
|
||||
}
|
||||
interface BigUint64ArrayConstructor {
|
||||
readonly prototype: BigUint64Array<ArrayBufferLike>;
|
||||
new (length?: number): BigUint64Array<ArrayBuffer>;
|
||||
new (array: ArrayLike<bigint> | Iterable<bigint>): BigUint64Array<ArrayBuffer>;
|
||||
new <TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(buffer: TArrayBuffer, byteOffset?: number, length?: number): BigUint64Array<TArrayBuffer>;
|
||||
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): BigUint64Array<ArrayBuffer>;
|
||||
new (array: ArrayLike<bigint> | ArrayBuffer): BigUint64Array<ArrayBuffer>;
|
||||
|
||||
/** The size in bytes of each element in the array. */
|
||||
readonly BYTES_PER_ELEMENT: number;
|
||||
|
||||
/**
|
||||
* Returns a new array from a set of elements.
|
||||
* @param items A set of elements to include in the new array object.
|
||||
*/
|
||||
of(...items: bigint[]): BigUint64Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like object to convert to an array.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<bigint>): BigUint64Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from<U>(arrayLike: ArrayLike<U>, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigUint64Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
*/
|
||||
from(elements: Iterable<bigint>): BigUint64Array<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param elements An iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => bigint, thisArg?: any): BigUint64Array<ArrayBuffer>;
|
||||
}
|
||||
declare var BigUint64Array: BigUint64ArrayConstructor;
|
||||
|
||||
interface DataView<TArrayBuffer extends ArrayBufferLike> {
|
||||
/**
|
||||
* Gets the BigInt64 value at the specified byte offset from the start of the view. There is
|
||||
* no alignment constraint; multi-byte values may be fetched from any offset.
|
||||
* @param byteOffset The place in the buffer at which the value should be retrieved.
|
||||
* @param littleEndian If false or undefined, a big-endian value should be read.
|
||||
*/
|
||||
getBigInt64(byteOffset: number, littleEndian?: boolean): bigint;
|
||||
|
||||
/**
|
||||
* Gets the BigUint64 value at the specified byte offset from the start of the view. There is
|
||||
* no alignment constraint; multi-byte values may be fetched from any offset.
|
||||
* @param byteOffset The place in the buffer at which the value should be retrieved.
|
||||
* @param littleEndian If false or undefined, a big-endian value should be read.
|
||||
*/
|
||||
getBigUint64(byteOffset: number, littleEndian?: boolean): bigint;
|
||||
|
||||
/**
|
||||
* Stores a BigInt64 value at the specified byte offset from the start of the view.
|
||||
* @param byteOffset The place in the buffer at which the value should be set.
|
||||
* @param value The value to set.
|
||||
* @param littleEndian If false or undefined, a big-endian value should be written.
|
||||
*/
|
||||
setBigInt64(byteOffset: number, value: bigint, littleEndian?: boolean): void;
|
||||
|
||||
/**
|
||||
* Stores a BigUint64 value at the specified byte offset from the start of the view.
|
||||
* @param byteOffset The place in the buffer at which the value should be set.
|
||||
* @param value The value to set.
|
||||
* @param littleEndian If false or undefined, a big-endian value should be written.
|
||||
*/
|
||||
setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void;
|
||||
}
|
||||
|
||||
declare namespace Intl {
|
||||
interface NumberFormat {
|
||||
format(value: number | bigint): string;
|
||||
}
|
||||
}
|
||||
27
kitcom/internal/tsgo/bundled/libs/lib.es2020.d.ts
vendored
Normal file
27
kitcom/internal/tsgo/bundled/libs/lib.es2020.d.ts
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2019" />
|
||||
/// <reference lib="es2020.bigint" />
|
||||
/// <reference lib="es2020.date" />
|
||||
/// <reference lib="es2020.number" />
|
||||
/// <reference lib="es2020.promise" />
|
||||
/// <reference lib="es2020.sharedmemory" />
|
||||
/// <reference lib="es2020.string" />
|
||||
/// <reference lib="es2020.symbol.wellknown" />
|
||||
/// <reference lib="es2020.intl" />
|
||||
42
kitcom/internal/tsgo/bundled/libs/lib.es2020.date.d.ts
vendored
Normal file
42
kitcom/internal/tsgo/bundled/libs/lib.es2020.date.d.ts
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2020.intl" />
|
||||
|
||||
interface Date {
|
||||
/**
|
||||
* Converts a date and time to a string by using the current or specified locale.
|
||||
* @param locales A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
|
||||
* @param options An object that contains one or more properties that specify comparison options.
|
||||
*/
|
||||
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
|
||||
|
||||
/**
|
||||
* Converts a date to a string by using the current or specified locale.
|
||||
* @param locales A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
|
||||
* @param options An object that contains one or more properties that specify comparison options.
|
||||
*/
|
||||
toLocaleDateString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
|
||||
|
||||
/**
|
||||
* Converts a time to a string by using the current or specified locale.
|
||||
* @param locales A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
|
||||
* @param options An object that contains one or more properties that specify comparison options.
|
||||
*/
|
||||
toLocaleTimeString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
|
||||
}
|
||||
24
kitcom/internal/tsgo/bundled/libs/lib.es2020.full.d.ts
vendored
Normal file
24
kitcom/internal/tsgo/bundled/libs/lib.es2020.full.d.ts
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2020" />
|
||||
/// <reference lib="dom" />
|
||||
/// <reference lib="webworker.importscripts" />
|
||||
/// <reference lib="scripthost" />
|
||||
/// <reference lib="dom.iterable" />
|
||||
/// <reference lib="dom.asynciterable" />
|
||||
474
kitcom/internal/tsgo/bundled/libs/lib.es2020.intl.d.ts
vendored
Normal file
474
kitcom/internal/tsgo/bundled/libs/lib.es2020.intl.d.ts
vendored
Normal file
@ -0,0 +1,474 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2018.intl" />
|
||||
declare namespace Intl {
|
||||
/**
|
||||
* A string that is a valid [Unicode BCP 47 Locale Identifier](https://unicode.org/reports/tr35/#Unicode_locale_identifier).
|
||||
*
|
||||
* For example: "fa", "es-MX", "zh-Hant-TW".
|
||||
*
|
||||
* See [MDN - Intl - locales argument](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument).
|
||||
*/
|
||||
type UnicodeBCP47LocaleIdentifier = string;
|
||||
|
||||
/**
|
||||
* Unit to use in the relative time internationalized message.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/format#Parameters).
|
||||
*/
|
||||
type RelativeTimeFormatUnit =
|
||||
| "year"
|
||||
| "years"
|
||||
| "quarter"
|
||||
| "quarters"
|
||||
| "month"
|
||||
| "months"
|
||||
| "week"
|
||||
| "weeks"
|
||||
| "day"
|
||||
| "days"
|
||||
| "hour"
|
||||
| "hours"
|
||||
| "minute"
|
||||
| "minutes"
|
||||
| "second"
|
||||
| "seconds";
|
||||
|
||||
/**
|
||||
* Value of the `unit` property in objects returned by
|
||||
* `Intl.RelativeTimeFormat.prototype.formatToParts()`. `formatToParts` and
|
||||
* `format` methods accept either singular or plural unit names as input,
|
||||
* but `formatToParts` only outputs singular (e.g. "day") not plural (e.g.
|
||||
* "days").
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts#Using_formatToParts).
|
||||
*/
|
||||
type RelativeTimeFormatUnitSingular =
|
||||
| "year"
|
||||
| "quarter"
|
||||
| "month"
|
||||
| "week"
|
||||
| "day"
|
||||
| "hour"
|
||||
| "minute"
|
||||
| "second";
|
||||
|
||||
/**
|
||||
* The locale matching algorithm to use.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation).
|
||||
*/
|
||||
type RelativeTimeFormatLocaleMatcher = "lookup" | "best fit";
|
||||
|
||||
/**
|
||||
* The format of output message.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters).
|
||||
*/
|
||||
type RelativeTimeFormatNumeric = "always" | "auto";
|
||||
|
||||
/**
|
||||
* The length of the internationalized message.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters).
|
||||
*/
|
||||
type RelativeTimeFormatStyle = "long" | "short" | "narrow";
|
||||
|
||||
/**
|
||||
* The locale or locales to use
|
||||
*
|
||||
* See [MDN - Intl - locales argument](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument).
|
||||
*/
|
||||
type LocalesArgument = UnicodeBCP47LocaleIdentifier | Locale | readonly (UnicodeBCP47LocaleIdentifier | Locale)[] | undefined;
|
||||
|
||||
/**
|
||||
* An object with some or all of properties of `options` parameter
|
||||
* of `Intl.RelativeTimeFormat` constructor.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters).
|
||||
*/
|
||||
interface RelativeTimeFormatOptions {
|
||||
/** The locale matching algorithm to use. For information about this option, see [Intl page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation). */
|
||||
localeMatcher?: RelativeTimeFormatLocaleMatcher;
|
||||
/** The format of output message. */
|
||||
numeric?: RelativeTimeFormatNumeric;
|
||||
/** The length of the internationalized message. */
|
||||
style?: RelativeTimeFormatStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* An object with properties reflecting the locale
|
||||
* and formatting options computed during initialization
|
||||
* of the `Intl.RelativeTimeFormat` object
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions#Description).
|
||||
*/
|
||||
interface ResolvedRelativeTimeFormatOptions {
|
||||
locale: UnicodeBCP47LocaleIdentifier;
|
||||
style: RelativeTimeFormatStyle;
|
||||
numeric: RelativeTimeFormatNumeric;
|
||||
numberingSystem: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* An object representing the relative time format in parts
|
||||
* that can be used for custom locale-aware formatting.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts#Using_formatToParts).
|
||||
*/
|
||||
type RelativeTimeFormatPart =
|
||||
| {
|
||||
type: "literal";
|
||||
value: string;
|
||||
}
|
||||
| {
|
||||
type: Exclude<NumberFormatPartTypes, "literal">;
|
||||
value: string;
|
||||
unit: RelativeTimeFormatUnitSingular;
|
||||
};
|
||||
|
||||
interface RelativeTimeFormat {
|
||||
/**
|
||||
* Formats a value and a unit according to the locale
|
||||
* and formatting options of the given
|
||||
* [`Intl.RelativeTimeFormat`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat)
|
||||
* object.
|
||||
*
|
||||
* While this method automatically provides the correct plural forms,
|
||||
* the grammatical form is otherwise as neutral as possible.
|
||||
*
|
||||
* It is the caller's responsibility to handle cut-off logic
|
||||
* such as deciding between displaying "in 7 days" or "in 1 week".
|
||||
* This API does not support relative dates involving compound units.
|
||||
* e.g "in 5 days and 4 hours".
|
||||
*
|
||||
* @param value - Numeric value to use in the internationalized relative time message
|
||||
*
|
||||
* @param unit - [Unit](https://tc39.es/ecma402/#sec-singularrelativetimeunit) to use in the relative time internationalized message.
|
||||
*
|
||||
* @throws `RangeError` if `unit` was given something other than `unit` possible values
|
||||
*
|
||||
* @returns {string} Internationalized relative time message as string
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/format).
|
||||
*/
|
||||
format(value: number, unit: RelativeTimeFormatUnit): string;
|
||||
|
||||
/**
|
||||
* Returns an array of objects representing the relative time format in parts that can be used for custom locale-aware formatting.
|
||||
*
|
||||
* @param value - Numeric value to use in the internationalized relative time message
|
||||
*
|
||||
* @param unit - [Unit](https://tc39.es/ecma402/#sec-singularrelativetimeunit) to use in the relative time internationalized message.
|
||||
*
|
||||
* @throws `RangeError` if `unit` was given something other than `unit` possible values
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts).
|
||||
*/
|
||||
formatToParts(value: number, unit: RelativeTimeFormatUnit): RelativeTimeFormatPart[];
|
||||
|
||||
/**
|
||||
* Provides access to the locale and options computed during initialization of this `Intl.RelativeTimeFormat` object.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions).
|
||||
*/
|
||||
resolvedOptions(): ResolvedRelativeTimeFormatOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* The [`Intl.RelativeTimeFormat`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat)
|
||||
* object is a constructor for objects that enable language-sensitive relative time formatting.
|
||||
*
|
||||
* [Compatibility](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat#Browser_compatibility).
|
||||
*/
|
||||
const RelativeTimeFormat: {
|
||||
/**
|
||||
* Creates [Intl.RelativeTimeFormat](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat) objects
|
||||
*
|
||||
* @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings.
|
||||
* For the general form and interpretation of the locales argument,
|
||||
* see the [`Intl` page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
|
||||
*
|
||||
* @param options - An [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters)
|
||||
* with some or all of options of `RelativeTimeFormatOptions`.
|
||||
*
|
||||
* @returns [Intl.RelativeTimeFormat](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat) object.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat).
|
||||
*/
|
||||
new (
|
||||
locales?: LocalesArgument,
|
||||
options?: RelativeTimeFormatOptions,
|
||||
): RelativeTimeFormat;
|
||||
|
||||
/**
|
||||
* Returns an array containing those of the provided locales
|
||||
* that are supported in date and time formatting
|
||||
* without having to fall back to the runtime's default locale.
|
||||
*
|
||||
* @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings.
|
||||
* For the general form and interpretation of the locales argument,
|
||||
* see the [`Intl` page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
|
||||
*
|
||||
* @param options - An [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters)
|
||||
* with some or all of options of the formatting.
|
||||
*
|
||||
* @returns An array containing those of the provided locales
|
||||
* that are supported in date and time formatting
|
||||
* without having to fall back to the runtime's default locale.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/supportedLocalesOf).
|
||||
*/
|
||||
supportedLocalesOf(
|
||||
locales?: LocalesArgument,
|
||||
options?: RelativeTimeFormatOptions,
|
||||
): UnicodeBCP47LocaleIdentifier[];
|
||||
};
|
||||
|
||||
interface NumberFormatOptionsStyleRegistry {
|
||||
unit: never;
|
||||
}
|
||||
|
||||
interface NumberFormatOptionsCurrencyDisplayRegistry {
|
||||
narrowSymbol: never;
|
||||
}
|
||||
|
||||
interface NumberFormatOptionsSignDisplayRegistry {
|
||||
auto: never;
|
||||
never: never;
|
||||
always: never;
|
||||
exceptZero: never;
|
||||
}
|
||||
|
||||
type NumberFormatOptionsSignDisplay = keyof NumberFormatOptionsSignDisplayRegistry;
|
||||
|
||||
interface NumberFormatOptions {
|
||||
numberingSystem?: string | undefined;
|
||||
compactDisplay?: "short" | "long" | undefined;
|
||||
notation?: "standard" | "scientific" | "engineering" | "compact" | undefined;
|
||||
signDisplay?: NumberFormatOptionsSignDisplay | undefined;
|
||||
unit?: string | undefined;
|
||||
unitDisplay?: "short" | "long" | "narrow" | undefined;
|
||||
currencySign?: "standard" | "accounting" | undefined;
|
||||
}
|
||||
|
||||
interface ResolvedNumberFormatOptions {
|
||||
compactDisplay?: "short" | "long";
|
||||
notation: "standard" | "scientific" | "engineering" | "compact";
|
||||
signDisplay: NumberFormatOptionsSignDisplay;
|
||||
unit?: string;
|
||||
unitDisplay?: "short" | "long" | "narrow";
|
||||
currencySign?: "standard" | "accounting";
|
||||
}
|
||||
|
||||
interface NumberFormatPartTypeRegistry {
|
||||
compact: never;
|
||||
exponentInteger: never;
|
||||
exponentMinusSign: never;
|
||||
exponentSeparator: never;
|
||||
unit: never;
|
||||
unknown: never;
|
||||
}
|
||||
|
||||
interface DateTimeFormatOptions {
|
||||
calendar?: string | undefined;
|
||||
dayPeriod?: "narrow" | "short" | "long" | undefined;
|
||||
numberingSystem?: string | undefined;
|
||||
|
||||
dateStyle?: "full" | "long" | "medium" | "short" | undefined;
|
||||
timeStyle?: "full" | "long" | "medium" | "short" | undefined;
|
||||
hourCycle?: "h11" | "h12" | "h23" | "h24" | undefined;
|
||||
}
|
||||
|
||||
type LocaleHourCycleKey = "h12" | "h23" | "h11" | "h24";
|
||||
type LocaleCollationCaseFirst = "upper" | "lower" | "false";
|
||||
|
||||
interface LocaleOptions {
|
||||
/** A string containing the language, and the script and region if available. */
|
||||
baseName?: string;
|
||||
/** The part of the Locale that indicates the locale's calendar era. */
|
||||
calendar?: string;
|
||||
/** Flag that defines whether case is taken into account for the locale's collation rules. */
|
||||
caseFirst?: LocaleCollationCaseFirst;
|
||||
/** The collation type used for sorting */
|
||||
collation?: string;
|
||||
/** The time keeping format convention used by the locale. */
|
||||
hourCycle?: LocaleHourCycleKey;
|
||||
/** The primary language subtag associated with the locale. */
|
||||
language?: string;
|
||||
/** The numeral system used by the locale. */
|
||||
numberingSystem?: string;
|
||||
/** Flag that defines whether the locale has special collation handling for numeric characters. */
|
||||
numeric?: boolean;
|
||||
/** The region of the world (usually a country) associated with the locale. Possible values are region codes as defined by ISO 3166-1. */
|
||||
region?: string;
|
||||
/** The script used for writing the particular language used in the locale. Possible values are script codes as defined by ISO 15924. */
|
||||
script?: string;
|
||||
}
|
||||
|
||||
interface Locale extends LocaleOptions {
|
||||
/** A string containing the language, and the script and region if available. */
|
||||
baseName: string;
|
||||
/** The primary language subtag associated with the locale. */
|
||||
language: string;
|
||||
/** Gets the most likely values for the language, script, and region of the locale based on existing values. */
|
||||
maximize(): Locale;
|
||||
/** Attempts to remove information about the locale that would be added by calling `Locale.maximize()`. */
|
||||
minimize(): Locale;
|
||||
/** Returns the locale's full locale identifier string. */
|
||||
toString(): UnicodeBCP47LocaleIdentifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor creates [Intl.Locale](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale)
|
||||
* objects
|
||||
*
|
||||
* @param tag - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646).
|
||||
* For the general form and interpretation of the locales argument,
|
||||
* see the [`Intl` page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
|
||||
*
|
||||
* @param options - An [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/Locale#Parameters) with some or all of options of the locale.
|
||||
*
|
||||
* @returns [Intl.Locale](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale) object.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale).
|
||||
*/
|
||||
const Locale: {
|
||||
new (tag: UnicodeBCP47LocaleIdentifier | Locale, options?: LocaleOptions): Locale;
|
||||
};
|
||||
|
||||
type DisplayNamesFallback =
|
||||
| "code"
|
||||
| "none";
|
||||
|
||||
type DisplayNamesType =
|
||||
| "language"
|
||||
| "region"
|
||||
| "script"
|
||||
| "calendar"
|
||||
| "dateTimeField"
|
||||
| "currency";
|
||||
|
||||
type DisplayNamesLanguageDisplay =
|
||||
| "dialect"
|
||||
| "standard";
|
||||
|
||||
interface DisplayNamesOptions {
|
||||
localeMatcher?: RelativeTimeFormatLocaleMatcher;
|
||||
style?: RelativeTimeFormatStyle;
|
||||
type: DisplayNamesType;
|
||||
languageDisplay?: DisplayNamesLanguageDisplay;
|
||||
fallback?: DisplayNamesFallback;
|
||||
}
|
||||
|
||||
interface ResolvedDisplayNamesOptions {
|
||||
locale: UnicodeBCP47LocaleIdentifier;
|
||||
style: RelativeTimeFormatStyle;
|
||||
type: DisplayNamesType;
|
||||
fallback: DisplayNamesFallback;
|
||||
languageDisplay?: DisplayNamesLanguageDisplay;
|
||||
}
|
||||
|
||||
interface DisplayNames {
|
||||
/**
|
||||
* Receives a code and returns a string based on the locale and options provided when instantiating
|
||||
* [`Intl.DisplayNames()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames)
|
||||
*
|
||||
* @param code The `code` to provide depends on the `type` passed to display name during creation:
|
||||
* - If the type is `"region"`, code should be either an [ISO-3166 two letters region code](https://www.iso.org/iso-3166-country-codes.html),
|
||||
* or a [three digits UN M49 Geographic Regions](https://unstats.un.org/unsd/methodology/m49/).
|
||||
* - If the type is `"script"`, code should be an [ISO-15924 four letters script code](https://unicode.org/iso15924/iso15924-codes.html).
|
||||
* - If the type is `"language"`, code should be a `languageCode` ["-" `scriptCode`] ["-" `regionCode` ] *("-" `variant` )
|
||||
* subsequence of the unicode_language_id grammar in [UTS 35's Unicode Language and Locale Identifiers grammar](https://unicode.org/reports/tr35/#Unicode_language_identifier).
|
||||
* `languageCode` is either a two letters ISO 639-1 language code or a three letters ISO 639-2 language code.
|
||||
* - If the type is `"currency"`, code should be a [3-letter ISO 4217 currency code](https://www.iso.org/iso-4217-currency-codes.html).
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/of).
|
||||
*/
|
||||
of(code: string): string | undefined;
|
||||
/**
|
||||
* Returns a new object with properties reflecting the locale and style formatting options computed during the construction of the current
|
||||
* [`Intl/DisplayNames`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames) object.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/resolvedOptions).
|
||||
*/
|
||||
resolvedOptions(): ResolvedDisplayNamesOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* The [`Intl.DisplayNames()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames)
|
||||
* object enables the consistent translation of language, region and script display names.
|
||||
*
|
||||
* [Compatibility](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames#browser_compatibility).
|
||||
*/
|
||||
const DisplayNames: {
|
||||
prototype: DisplayNames;
|
||||
|
||||
/**
|
||||
* @param locales A string with a BCP 47 language tag, or an array of such strings.
|
||||
* For the general form and interpretation of the `locales` argument, see the [Intl](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#locale_identification_and_negotiation)
|
||||
* page.
|
||||
*
|
||||
* @param options An object for setting up a display name.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames).
|
||||
*/
|
||||
new (locales: LocalesArgument, options: DisplayNamesOptions): DisplayNames;
|
||||
|
||||
/**
|
||||
* Returns an array containing those of the provided locales that are supported in display names without having to fall back to the runtime's default locale.
|
||||
*
|
||||
* @param locales A string with a BCP 47 language tag, or an array of such strings.
|
||||
* For the general form and interpretation of the `locales` argument, see the [Intl](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#locale_identification_and_negotiation)
|
||||
* page.
|
||||
*
|
||||
* @param options An object with a locale matcher.
|
||||
*
|
||||
* @returns An array of strings representing a subset of the given locale tags that are supported in display names without having to fall back to the runtime's default locale.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/supportedLocalesOf).
|
||||
*/
|
||||
supportedLocalesOf(locales?: LocalesArgument, options?: { localeMatcher?: RelativeTimeFormatLocaleMatcher; }): UnicodeBCP47LocaleIdentifier[];
|
||||
};
|
||||
|
||||
interface CollatorConstructor {
|
||||
new (locales?: LocalesArgument, options?: CollatorOptions): Collator;
|
||||
(locales?: LocalesArgument, options?: CollatorOptions): Collator;
|
||||
supportedLocalesOf(locales: LocalesArgument, options?: CollatorOptions): string[];
|
||||
}
|
||||
|
||||
interface DateTimeFormatConstructor {
|
||||
new (locales?: LocalesArgument, options?: DateTimeFormatOptions): DateTimeFormat;
|
||||
(locales?: LocalesArgument, options?: DateTimeFormatOptions): DateTimeFormat;
|
||||
supportedLocalesOf(locales: LocalesArgument, options?: DateTimeFormatOptions): string[];
|
||||
}
|
||||
|
||||
interface NumberFormatConstructor {
|
||||
new (locales?: LocalesArgument, options?: NumberFormatOptions): NumberFormat;
|
||||
(locales?: LocalesArgument, options?: NumberFormatOptions): NumberFormat;
|
||||
supportedLocalesOf(locales: LocalesArgument, options?: NumberFormatOptions): string[];
|
||||
}
|
||||
|
||||
interface PluralRulesConstructor {
|
||||
new (locales?: LocalesArgument, options?: PluralRulesOptions): PluralRules;
|
||||
(locales?: LocalesArgument, options?: PluralRulesOptions): PluralRules;
|
||||
|
||||
supportedLocalesOf(locales: LocalesArgument, options?: { localeMatcher?: "lookup" | "best fit"; }): string[];
|
||||
}
|
||||
}
|
||||
28
kitcom/internal/tsgo/bundled/libs/lib.es2020.number.d.ts
vendored
Normal file
28
kitcom/internal/tsgo/bundled/libs/lib.es2020.number.d.ts
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2020.intl" />
|
||||
|
||||
interface Number {
|
||||
/**
|
||||
* Converts a number to a string by using the current or specified locale.
|
||||
* @param locales A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
|
||||
* @param options An object that contains one or more properties that specify comparison options.
|
||||
*/
|
||||
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string;
|
||||
}
|
||||
47
kitcom/internal/tsgo/bundled/libs/lib.es2020.promise.d.ts
vendored
Normal file
47
kitcom/internal/tsgo/bundled/libs/lib.es2020.promise.d.ts
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
interface PromiseFulfilledResult<T> {
|
||||
status: "fulfilled";
|
||||
value: T;
|
||||
}
|
||||
|
||||
interface PromiseRejectedResult {
|
||||
status: "rejected";
|
||||
reason: any;
|
||||
}
|
||||
|
||||
type PromiseSettledResult<T> = PromiseFulfilledResult<T> | PromiseRejectedResult;
|
||||
|
||||
interface PromiseConstructor {
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all
|
||||
* of the provided Promises resolve or reject.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
allSettled<T extends readonly unknown[] | []>(values: T): Promise<{ -readonly [P in keyof T]: PromiseSettledResult<Awaited<T[P]>>; }>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all
|
||||
* of the provided Promises resolve or reject.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
allSettled<T>(values: Iterable<T | PromiseLike<T>>): Promise<PromiseSettledResult<Awaited<T>>[]>;
|
||||
}
|
||||
99
kitcom/internal/tsgo/bundled/libs/lib.es2020.sharedmemory.d.ts
vendored
Normal file
99
kitcom/internal/tsgo/bundled/libs/lib.es2020.sharedmemory.d.ts
vendored
Normal file
@ -0,0 +1,99 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2020.bigint" />
|
||||
|
||||
interface Atomics {
|
||||
/**
|
||||
* Adds a value to the value at the given position in the array, returning the original value.
|
||||
* Until this atomic operation completes, any other read or write operation against the array
|
||||
* will block.
|
||||
*/
|
||||
add(typedArray: BigInt64Array<ArrayBufferLike> | BigUint64Array<ArrayBufferLike>, index: number, value: bigint): bigint;
|
||||
|
||||
/**
|
||||
* Stores the bitwise AND of a value with the value at the given position in the array,
|
||||
* returning the original value. Until this atomic operation completes, any other read or
|
||||
* write operation against the array will block.
|
||||
*/
|
||||
and(typedArray: BigInt64Array<ArrayBufferLike> | BigUint64Array<ArrayBufferLike>, index: number, value: bigint): bigint;
|
||||
|
||||
/**
|
||||
* Replaces the value at the given position in the array if the original value equals the given
|
||||
* expected value, returning the original value. Until this atomic operation completes, any
|
||||
* other read or write operation against the array will block.
|
||||
*/
|
||||
compareExchange(typedArray: BigInt64Array<ArrayBufferLike> | BigUint64Array<ArrayBufferLike>, index: number, expectedValue: bigint, replacementValue: bigint): bigint;
|
||||
|
||||
/**
|
||||
* Replaces the value at the given position in the array, returning the original value. Until
|
||||
* this atomic operation completes, any other read or write operation against the array will
|
||||
* block.
|
||||
*/
|
||||
exchange(typedArray: BigInt64Array<ArrayBufferLike> | BigUint64Array<ArrayBufferLike>, index: number, value: bigint): bigint;
|
||||
|
||||
/**
|
||||
* Returns the value at the given position in the array. Until this atomic operation completes,
|
||||
* any other read or write operation against the array will block.
|
||||
*/
|
||||
load(typedArray: BigInt64Array<ArrayBufferLike> | BigUint64Array<ArrayBufferLike>, index: number): bigint;
|
||||
|
||||
/**
|
||||
* Stores the bitwise OR of a value with the value at the given position in the array,
|
||||
* returning the original value. Until this atomic operation completes, any other read or write
|
||||
* operation against the array will block.
|
||||
*/
|
||||
or(typedArray: BigInt64Array<ArrayBufferLike> | BigUint64Array<ArrayBufferLike>, index: number, value: bigint): bigint;
|
||||
|
||||
/**
|
||||
* Stores a value at the given position in the array, returning the new value. Until this
|
||||
* atomic operation completes, any other read or write operation against the array will block.
|
||||
*/
|
||||
store(typedArray: BigInt64Array<ArrayBufferLike> | BigUint64Array<ArrayBufferLike>, index: number, value: bigint): bigint;
|
||||
|
||||
/**
|
||||
* Subtracts a value from the value at the given position in the array, returning the original
|
||||
* value. Until this atomic operation completes, any other read or write operation against the
|
||||
* array will block.
|
||||
*/
|
||||
sub(typedArray: BigInt64Array<ArrayBufferLike> | BigUint64Array<ArrayBufferLike>, index: number, value: bigint): bigint;
|
||||
|
||||
/**
|
||||
* If the value at the given position in the array is equal to the provided value, the current
|
||||
* agent is put to sleep causing execution to suspend until the timeout expires (returning
|
||||
* `"timed-out"`) or until the agent is awoken (returning `"ok"`); otherwise, returns
|
||||
* `"not-equal"`.
|
||||
*/
|
||||
wait(typedArray: BigInt64Array<ArrayBufferLike>, index: number, value: bigint, timeout?: number): "ok" | "not-equal" | "timed-out";
|
||||
|
||||
/**
|
||||
* Wakes up sleeping agents that are waiting on the given index of the array, returning the
|
||||
* number of agents that were awoken.
|
||||
* @param typedArray A shared BigInt64Array.
|
||||
* @param index The position in the typedArray to wake up on.
|
||||
* @param count The number of sleeping agents to notify. Defaults to +Infinity.
|
||||
*/
|
||||
notify(typedArray: BigInt64Array<ArrayBufferLike>, index: number, count?: number): number;
|
||||
|
||||
/**
|
||||
* Stores the bitwise XOR of a value with the value at the given position in the array,
|
||||
* returning the original value. Until this atomic operation completes, any other read or write
|
||||
* operation against the array will block.
|
||||
*/
|
||||
xor(typedArray: BigInt64Array<ArrayBufferLike> | BigUint64Array<ArrayBufferLike>, index: number, value: bigint): bigint;
|
||||
}
|
||||
44
kitcom/internal/tsgo/bundled/libs/lib.es2020.string.d.ts
vendored
Normal file
44
kitcom/internal/tsgo/bundled/libs/lib.es2020.string.d.ts
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2015.iterable" />
|
||||
/// <reference lib="es2020.intl" />
|
||||
/// <reference lib="es2020.symbol.wellknown" />
|
||||
|
||||
interface String {
|
||||
/**
|
||||
* Matches a string with a regular expression, and returns an iterable of matches
|
||||
* containing the results of that search.
|
||||
* @param regexp A variable name or string literal containing the regular expression pattern and flags.
|
||||
*/
|
||||
matchAll(regexp: RegExp): RegExpStringIterator<RegExpExecArray>;
|
||||
|
||||
/** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */
|
||||
toLocaleLowerCase(locales?: Intl.LocalesArgument): string;
|
||||
|
||||
/** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */
|
||||
toLocaleUpperCase(locales?: Intl.LocalesArgument): string;
|
||||
|
||||
/**
|
||||
* Determines whether two strings are equivalent in the current or specified locale.
|
||||
* @param that String to compare to target string
|
||||
* @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details.
|
||||
* @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details.
|
||||
*/
|
||||
localeCompare(that: string, locales?: Intl.LocalesArgument, options?: Intl.CollatorOptions): number;
|
||||
}
|
||||
41
kitcom/internal/tsgo/bundled/libs/lib.es2020.symbol.wellknown.d.ts
vendored
Normal file
41
kitcom/internal/tsgo/bundled/libs/lib.es2020.symbol.wellknown.d.ts
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2015.iterable" />
|
||||
/// <reference lib="es2015.symbol" />
|
||||
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
* A regular expression method that matches the regular expression against a string. Called
|
||||
* by the String.prototype.matchAll method.
|
||||
*/
|
||||
readonly matchAll: unique symbol;
|
||||
}
|
||||
|
||||
interface RegExpStringIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): RegExpStringIterator<T>;
|
||||
}
|
||||
|
||||
interface RegExp {
|
||||
/**
|
||||
* Matches a string with this regular expression, and returns an iterable of matches
|
||||
* containing the results of that search.
|
||||
* @param string A string to search within.
|
||||
*/
|
||||
[Symbol.matchAll](str: string): RegExpStringIterator<RegExpMatchArray>;
|
||||
}
|
||||
23
kitcom/internal/tsgo/bundled/libs/lib.es2021.d.ts
vendored
Normal file
23
kitcom/internal/tsgo/bundled/libs/lib.es2021.d.ts
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2020" />
|
||||
/// <reference lib="es2021.promise" />
|
||||
/// <reference lib="es2021.string" />
|
||||
/// <reference lib="es2021.weakref" />
|
||||
/// <reference lib="es2021.intl" />
|
||||
24
kitcom/internal/tsgo/bundled/libs/lib.es2021.full.d.ts
vendored
Normal file
24
kitcom/internal/tsgo/bundled/libs/lib.es2021.full.d.ts
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2021" />
|
||||
/// <reference lib="dom" />
|
||||
/// <reference lib="webworker.importscripts" />
|
||||
/// <reference lib="scripthost" />
|
||||
/// <reference lib="dom.iterable" />
|
||||
/// <reference lib="dom.asynciterable" />
|
||||
166
kitcom/internal/tsgo/bundled/libs/lib.es2021.intl.d.ts
vendored
Normal file
166
kitcom/internal/tsgo/bundled/libs/lib.es2021.intl.d.ts
vendored
Normal file
@ -0,0 +1,166 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
declare namespace Intl {
|
||||
interface DateTimeFormatPartTypesRegistry {
|
||||
fractionalSecond: any;
|
||||
}
|
||||
|
||||
interface DateTimeFormatOptions {
|
||||
formatMatcher?: "basic" | "best fit" | "best fit" | undefined;
|
||||
dateStyle?: "full" | "long" | "medium" | "short" | undefined;
|
||||
timeStyle?: "full" | "long" | "medium" | "short" | undefined;
|
||||
dayPeriod?: "narrow" | "short" | "long" | undefined;
|
||||
fractionalSecondDigits?: 1 | 2 | 3 | undefined;
|
||||
}
|
||||
|
||||
interface DateTimeRangeFormatPart extends DateTimeFormatPart {
|
||||
source: "startRange" | "endRange" | "shared";
|
||||
}
|
||||
|
||||
interface DateTimeFormat {
|
||||
formatRange(startDate: Date | number | bigint, endDate: Date | number | bigint): string;
|
||||
formatRangeToParts(startDate: Date | number | bigint, endDate: Date | number | bigint): DateTimeRangeFormatPart[];
|
||||
}
|
||||
|
||||
interface ResolvedDateTimeFormatOptions {
|
||||
formatMatcher?: "basic" | "best fit" | "best fit";
|
||||
dateStyle?: "full" | "long" | "medium" | "short";
|
||||
timeStyle?: "full" | "long" | "medium" | "short";
|
||||
hourCycle?: "h11" | "h12" | "h23" | "h24";
|
||||
dayPeriod?: "narrow" | "short" | "long";
|
||||
fractionalSecondDigits?: 1 | 2 | 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* The locale matching algorithm to use.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#parameters).
|
||||
*/
|
||||
type ListFormatLocaleMatcher = "lookup" | "best fit";
|
||||
|
||||
/**
|
||||
* The format of output message.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#parameters).
|
||||
*/
|
||||
type ListFormatType = "conjunction" | "disjunction" | "unit";
|
||||
|
||||
/**
|
||||
* The length of the formatted message.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#parameters).
|
||||
*/
|
||||
type ListFormatStyle = "long" | "short" | "narrow";
|
||||
|
||||
/**
|
||||
* An object with some or all properties of the `Intl.ListFormat` constructor `options` parameter.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#parameters).
|
||||
*/
|
||||
interface ListFormatOptions {
|
||||
/** The locale matching algorithm to use. For information about this option, see [Intl page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation). */
|
||||
localeMatcher?: ListFormatLocaleMatcher | undefined;
|
||||
/** The format of output message. */
|
||||
type?: ListFormatType | undefined;
|
||||
/** The length of the internationalized message. */
|
||||
style?: ListFormatStyle | undefined;
|
||||
}
|
||||
|
||||
interface ResolvedListFormatOptions {
|
||||
locale: string;
|
||||
style: ListFormatStyle;
|
||||
type: ListFormatType;
|
||||
}
|
||||
|
||||
interface ListFormat {
|
||||
/**
|
||||
* Returns a string with a language-specific representation of the list.
|
||||
*
|
||||
* @param list - An iterable object, such as an [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array).
|
||||
*
|
||||
* @throws `TypeError` if `list` includes something other than the possible values.
|
||||
*
|
||||
* @returns {string} A language-specific formatted string representing the elements of the list.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/format).
|
||||
*/
|
||||
format(list: Iterable<string>): string;
|
||||
|
||||
/**
|
||||
* Returns an Array of objects representing the different components that can be used to format a list of values in a locale-aware fashion.
|
||||
*
|
||||
* @param list - An iterable object, such as an [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array), to be formatted according to a locale.
|
||||
*
|
||||
* @throws `TypeError` if `list` includes something other than the possible values.
|
||||
*
|
||||
* @returns {{ type: "element" | "literal", value: string; }[]} An Array of components which contains the formatted parts from the list.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/formatToParts).
|
||||
*/
|
||||
formatToParts(list: Iterable<string>): { type: "element" | "literal"; value: string; }[];
|
||||
|
||||
/**
|
||||
* Returns a new object with properties reflecting the locale and style
|
||||
* formatting options computed during the construction of the current
|
||||
* `Intl.ListFormat` object.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/resolvedOptions).
|
||||
*/
|
||||
resolvedOptions(): ResolvedListFormatOptions;
|
||||
}
|
||||
|
||||
const ListFormat: {
|
||||
prototype: ListFormat;
|
||||
|
||||
/**
|
||||
* Creates [Intl.ListFormat](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat) objects that
|
||||
* enable language-sensitive list formatting.
|
||||
*
|
||||
* @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings.
|
||||
* For the general form and interpretation of the `locales` argument,
|
||||
* see the [`Intl` page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
|
||||
*
|
||||
* @param options - An [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#parameters)
|
||||
* with some or all options of `ListFormatOptions`.
|
||||
*
|
||||
* @returns [Intl.ListFormatOptions](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat) object.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat).
|
||||
*/
|
||||
new (locales?: LocalesArgument, options?: ListFormatOptions): ListFormat;
|
||||
|
||||
/**
|
||||
* Returns an array containing those of the provided locales that are
|
||||
* supported in list formatting without having to fall back to the runtime's default locale.
|
||||
*
|
||||
* @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings.
|
||||
* For the general form and interpretation of the `locales` argument,
|
||||
* see the [`Intl` page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
|
||||
*
|
||||
* @param options - An [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/supportedLocalesOf#parameters).
|
||||
* with some or all possible options.
|
||||
*
|
||||
* @returns An array of strings representing a subset of the given locale tags that are supported in list
|
||||
* formatting without having to fall back to the runtime's default locale.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/supportedLocalesOf).
|
||||
*/
|
||||
supportedLocalesOf(locales: LocalesArgument, options?: Pick<ListFormatOptions, "localeMatcher">): UnicodeBCP47LocaleIdentifier[];
|
||||
};
|
||||
}
|
||||
48
kitcom/internal/tsgo/bundled/libs/lib.es2021.promise.d.ts
vendored
Normal file
48
kitcom/internal/tsgo/bundled/libs/lib.es2021.promise.d.ts
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
interface AggregateError extends Error {
|
||||
errors: any[];
|
||||
}
|
||||
|
||||
interface AggregateErrorConstructor {
|
||||
new (errors: Iterable<any>, message?: string): AggregateError;
|
||||
(errors: Iterable<any>, message?: string): AggregateError;
|
||||
readonly prototype: AggregateError;
|
||||
}
|
||||
|
||||
declare var AggregateError: AggregateErrorConstructor;
|
||||
|
||||
/**
|
||||
* Represents the completion of an asynchronous operation
|
||||
*/
|
||||
interface PromiseConstructor {
|
||||
/**
|
||||
* The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.
|
||||
* @param values An array or iterable of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
any<T extends readonly unknown[] | []>(values: T): Promise<Awaited<T[number]>>;
|
||||
|
||||
/**
|
||||
* The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.
|
||||
* @param values An array or iterable of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
any<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>>;
|
||||
}
|
||||
33
kitcom/internal/tsgo/bundled/libs/lib.es2021.string.d.ts
vendored
Normal file
33
kitcom/internal/tsgo/bundled/libs/lib.es2021.string.d.ts
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
interface String {
|
||||
/**
|
||||
* Replace all instances of a substring in a string, using a regular expression or search string.
|
||||
* @param searchValue A string to search for.
|
||||
* @param replaceValue A string containing the text to replace for every successful match of searchValue in this string.
|
||||
*/
|
||||
replaceAll(searchValue: string | RegExp, replaceValue: string): string;
|
||||
|
||||
/**
|
||||
* Replace all instances of a substring in a string, using a regular expression or search string.
|
||||
* @param searchValue A string to search for.
|
||||
* @param replacer A function that returns the replacement text.
|
||||
*/
|
||||
replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string;
|
||||
}
|
||||
78
kitcom/internal/tsgo/bundled/libs/lib.es2021.weakref.d.ts
vendored
Normal file
78
kitcom/internal/tsgo/bundled/libs/lib.es2021.weakref.d.ts
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2015.symbol.wellknown" />
|
||||
|
||||
interface WeakRef<T extends WeakKey> {
|
||||
readonly [Symbol.toStringTag]: "WeakRef";
|
||||
|
||||
/**
|
||||
* Returns the WeakRef instance's target value, or undefined if the target value has been
|
||||
* reclaimed.
|
||||
* In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.
|
||||
*/
|
||||
deref(): T | undefined;
|
||||
}
|
||||
|
||||
interface WeakRefConstructor {
|
||||
readonly prototype: WeakRef<any>;
|
||||
|
||||
/**
|
||||
* Creates a WeakRef instance for the given target value.
|
||||
* In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.
|
||||
* @param target The target value for the WeakRef instance.
|
||||
*/
|
||||
new <T extends WeakKey>(target: T): WeakRef<T>;
|
||||
}
|
||||
|
||||
declare var WeakRef: WeakRefConstructor;
|
||||
|
||||
interface FinalizationRegistry<T> {
|
||||
readonly [Symbol.toStringTag]: "FinalizationRegistry";
|
||||
|
||||
/**
|
||||
* Registers a value with the registry.
|
||||
* In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.
|
||||
* @param target The target value to register.
|
||||
* @param heldValue The value to pass to the finalizer for this value. This cannot be the
|
||||
* target value.
|
||||
* @param unregisterToken The token to pass to the unregister method to unregister the target
|
||||
* value. If not provided, the target cannot be unregistered.
|
||||
*/
|
||||
register(target: WeakKey, heldValue: T, unregisterToken?: WeakKey): void;
|
||||
|
||||
/**
|
||||
* Unregisters a value from the registry.
|
||||
* In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.
|
||||
* @param unregisterToken The token that was used as the unregisterToken argument when calling
|
||||
* register to register the target value.
|
||||
*/
|
||||
unregister(unregisterToken: WeakKey): boolean;
|
||||
}
|
||||
|
||||
interface FinalizationRegistryConstructor {
|
||||
readonly prototype: FinalizationRegistry<any>;
|
||||
|
||||
/**
|
||||
* Creates a finalization registry with an associated cleanup callback
|
||||
* @param cleanupCallback The callback to call after a value in the registry has been reclaimed.
|
||||
*/
|
||||
new <T>(cleanupCallback: (heldValue: T) => void): FinalizationRegistry<T>;
|
||||
}
|
||||
|
||||
declare var FinalizationRegistry: FinalizationRegistryConstructor;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user