ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / build / lib / compilation.ts 462 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
import es from 'event-stream' ;
import fs from 'fs' ;
import { gulp, bom, sourcemaps } from './gulp/facade.ts' ;
import path from 'path' ;
import * as monacodts from './monaco-api.ts' ;
import * as nls from './nls.ts' ;
import { createReporter } from './reporter.ts' ;
import * as util from './util.ts' ;
import fancyLog from 'fancy-log' ;
import ansiColors
os
File
task
Mangler
RawSourceMap
ts
watch
tsb
createTsgoStream spawnTsgo
extractExtensionPointNamesFromFile
reporter
src ts CompilerOptions
rootDir path meta dirname
options ts CompilerOptions
options verbose
options sourceMap
process env
options sourceMap
options rootDir rootDir
options baseUrl rootDir
options sourceRoot util rootDir
options newLine fs meta filename
options
build
emitError
transpileOnly esbuild
preserveEnglish
noEmit
src build emitError transpileOnly preserveEnglish noEmit ICompileTaskOptions
projectPath path meta dirname src
overrideOptions src inlineSources build
build
overrideOptions inlineSourceMap
noEmit
overrideOptions noEmit
compilation tsb projectPath overrideOptions
verbose
transpileOnly transpileOnly
transpileWithEsbuild transpileOnly transpileOnly esbuild
err err
token util ICancellationToken
tsFilter util data data path
f File f path
f File f path f path
noDeclarationsFilter util data data path
input es
output input
util $ isUtf8Test
util $ build isRuntimeJs util
tsFilter
util
token
noDeclarationsFilter
util $ build nls preserveEnglish
noDeclarationsFilter restore
util $ transpileOnly sourcemaps
addComment
includeContent build
sourceRoot overrideOptions sourceRoot
tsFilter restore
reporter emitError
es input output
pipeline
compilation base src
pipeline projectPath projectPath
pipeline
src out esbuild task StreamTask
transpile src build emitError transpileOnly esbuild esbuild preserveEnglish
srcPipe gulp base
srcPipe
gulp out
task taskName
task
src out build options disableMangle preserveEnglish task Task
os
compile src build emitError transpileOnly build esbuild preserveEnglish options preserveEnglish
srcPipe gulp base
generator
src
generator
mangleStream es
build options disableMangle
ts2tsMangler Mangler compile projectPath data ansiColors data mangleExports manglePrivateFields
newContentsByFileName ts2tsMangler
mangleStream es data File sourceMap RawSourceMap
ts path
tsNormalPath ts TypeScriptExt data path
newContents newContentsByFileName tsNormalPath
newContents
data contents Buffer newContents out
data sourceMap newContents sourceMap newContents sourceMap
data
newContentsByFileName
ts2tsMangler
emit util srcPipe
mangleStream
generator stream
gulp out
typecheck compile projectPath taskName noEmit
emit typecheck
task taskName
task
src task Task
task
projectPath path meta dirname src
generator
generator
watchInput base src readDelay
tsgoStream watchInput generator stream util
stream projectPath taskName noEmit
result es
stream
result
stream err
err
fancyLog ansiColors
result
result reporter
tsgoStream
path meta dirname
_isWatch
stream NodeJS ReadWriteStream
_watchedFiles filePath
_fsProvider monacodts FSProvider
_declarationResolver monacodts DeclarationResolver
isWatch
_isWatch isWatch
stream es
_watchedFiles
moduleId filePath
_isWatch
_watchedFiles filePath
_watchedFiles filePath
fs filePath
_declarationResolver moduleId
_fsProvider FSProvider
moduleId filePath Buffer
moduleId filePath
moduleId filePath
_declarationResolver _fsProvider
_isWatch
fs monacodts
_executeSoonTimer NodeJS Timeout
_executeSoonTimer
_executeSoonTimer
_executeSoonTimer
_executeSoonTimer
_executeSoonTimer
monacodts IMonacoDeclarationResult
r monacodts _declarationResolver
r _isWatch
r
message rest
ansiColors message rest
startTime Date
result
result
result isTheSame
fs result filePath result content
fs path result enums
_isWatch
stream
eol
src fs
match src
eol match match os
eol os
pattern
proposals
input es
output input
util f File pattern f path
es f File
name path f path
match pattern name
match
proposalName match
proposals proposalName
proposal
names proposals
contents
$ eol
eol
filePath
existing fs path filePath
existing contents
path filePath
contents Buffer contents
es input output
apiProposalNamesReporter
compileApiProposalNamesTask task
gulp
gulp
apiProposalNamesReporter
collectedNames
input es
output input
es file File
contents file contents
contents contents
sourceFile ts file path contents ts ScriptTarget Latest
collectedNames sourceFile
collectedNames
content collectedNames
filePath
existing fs path filePath
existing content
path filePath
contents Buffer content
es input output
extensionPointNamesReporter
compileExtensionPointNamesTask task
gulp
gulp
extensionPointNamesReporter
watchExtensionPointNamesTask task
gulp
extensionPointNamesReporter
readDelay
util task
gulp
watchApiProposalNamesTask task
gulp
apiProposalNamesReporter
readDelay
util task
gulp
root path path meta dirname
codiconSource path root
codiconDest path root
fs codiconSource
fs path codiconDest recursive
fs codiconSource codiconDest
ansiColors
e
ansiColors
copyCodiconsTask task
task copyCodiconsTask
watchCodiconsTask task
readDelay
task watchCodiconsTask
from
'ansi-colors'
;
import
from
'os'
;
import
from
'vinyl'
;
import
*
as
from
'./gulp/task.ts'
;
import
{
}
from
'./mangle/index.ts'
;
import
type
{
}
from
'source-map'
;
import
from
'typescript'
;
import
from
'./watch/index.ts'
;
import
*
as
from
'./tsb/index.ts'
;
import
{
,
}
from
'./tsgo.ts'
;
import
{
}
from
'./extractExtensionPoints.ts'
;
const
=
createReporter
(
)
;
function
getTypeScriptCompilerOptions
(
:
string
)
:
.
{
const
=
.
join
(
import
.
.
,
` ../../ ${ src} `
)
;
const
:
.
=
{
}
;
.
=
false
;
.
=
true
;
if
(
.
[
'VSCODE_NO_SOURCEMAP'
]
)
{
.
=
false
;
}
.
=
;
.
=
;
.
=
.
toFileUri
(
)
;
.
=
/ \r \n /
.
test
(
.
readFileSync
(
import
.
.
,
'utf8'
)
)
?
0
:
1
;
return
;
}
interface
ICompileTaskOptions
{
readonly
:
boolean
;
readonly
:
boolean
;
readonly
:
boolean
|
{
:
boolean
}
;
readonly
:
boolean
;
readonly
?
:
boolean
;
}
export
function
createCompile
(
:
string
,
{
,
,
,
,
}
:
)
{
const
=
.
join
(
import
.
.
,
'../../'
,
,
'tsconfig.json'
)
;
const
=
{
...
getTypeScriptCompilerOptions
(
)
,
:
Boolean
(
)
}
;
if
(
!
)
{
.
=
true
;
}
if
(
)
{
.
=
true
;
}
const
=
.
create
(
,
,
{
:
false
,
:
Boolean
(
)
,
:
typeof
!==
'boolean'
&&
.
}
,
=>
reporter
(
)
)
;
function
pipeline
(
?
:
.
)
{
const
=
.
filter
(
=>
/ \. ts$ /
.
test
(
.
)
)
;
const
isUtf8Test
=
(
:
)
=>
/ ( \/ | \\ ) test( \/ | \\ ) . * utf8/
.
test
(
.
)
;
const
isRuntimeJs
=
(
:
)
=>
.
.
endsWith
(
'.js'
)
&&
!
.
.
includes
(
'fixtures'
)
;
const
=
.
filter
(
=>
!
(
/ \. d\. ts$ /
.
test
(
.
)
)
)
;
const
=
.
through
(
)
;
const
=
.
pipe
(
.
if
(
,
bom
(
)
)
)
.
pipe
(
.
if
(
!
&&
,
.
appendOwnPathSourceURL
(
)
)
)
.
pipe
(
)
.
pipe
(
.
loadSourcemaps
(
)
)
.
pipe
(
compilation
(
)
)
.
pipe
(
)
.
pipe
(
.
if
(
,
.
nls
(
{
}
)
)
)
.
pipe
(
.
)
.
pipe
(
.
if
(
!
,
.
write
(
'.'
,
{
:
false
,
:
!
!
,
:
.
}
)
)
)
.
pipe
(
.
)
.
pipe
(
.
end
(
!
!
)
)
;
return
.
duplex
(
,
)
;
}
.
tsProjectSrc
=
(
)
=>
{
return
.
src
(
{
:
}
)
;
}
;
.
=
;
return
;
}
export
function
transpileTask
(
:
string
,
:
string
,
?
:
boolean
)
:
.
{
const
task
=
(
)
=>
{
const
=
createCompile
(
,
{
:
false
,
:
true
,
:
{
:
!
!
}
,
:
false
}
)
;
const
=
.
src
(
` ${ src} /** `
,
{
:
` ${ src} `
}
)
;
return
.
pipe
(
transpile
(
)
)
.
pipe
(
.
dest
(
)
)
;
}
;
.
=
` transpile- ${ path. basename ( src) } `
;
return
;
}
export
function
compileTask
(
:
string
,
:
string
,
:
boolean
,
:
{
?
:
boolean
;
?
:
boolean
}
=
{
}
)
:
.
{
const
task
=
async
(
)
=>
{
if
(
.
totalmem
(
)
<
4_000_000_000
)
{
throw
new
Error
(
'compilation requires 4GB of RAM'
)
;
}
const
=
createCompile
(
,
{
,
:
true
,
:
?
false
:
{
:
true
}
,
:
!
!
.
}
)
;
const
=
.
src
(
` ${ src} /** `
,
{
:
` ${ src} `
}
)
;
const
=
new
MonacoGenerator
(
false
)
;
if
(
===
'src'
)
{
.
execute
(
)
;
}
let
=
.
through
(
)
;
if
(
&&
!
.
)
{
let
:
|
undefined
=
new
Mangler
(
.
,
(
...
)
=>
fancyLog
(
.
blue
(
'[mangler]'
)
,
...
)
,
{
:
true
,
:
true
}
)
;
const
=
.
computeNewFileContents
(
new
Set
(
[
'saveState'
]
)
)
;
=
.
through
(
async
function
write
(
:
&
{
?
:
}
)
{
type
TypeScriptExt
=
typeof
&
{
normalizePath
(
:
string
)
:
string
}
;
const
=
(
as
)
.
normalizePath
(
.
)
;
const
=
(
await
)
.
get
(
)
;
if
(
!==
undefined
)
{
.
=
.
from
(
.
)
;
.
=
.
&&
JSON
.
parse
(
.
)
;
}
this
.
push
(
)
;
}
,
async
function
end
(
)
{
(
await
)
.
clear
(
)
;
this
.
push
(
null
)
;
=
undefined
;
}
)
;
}
const
=
.
streamToPromise
(
.
pipe
(
)
.
pipe
(
.
)
.
pipe
(
compile
(
)
)
.
pipe
(
.
dest
(
)
)
)
;
const
=
spawnTsgo
(
.
,
{
:
` compile- ${ path. basename ( src) } `
,
:
true
}
)
;
await
Promise
.
all
(
[
,
]
)
;
}
;
.
=
` compile- ${ path. basename ( src) } `
;
return
;
}
export
function
watchTypeCheckTask
(
:
string
)
:
.
{
return
.
define
(
` watch-typecheck- ${ path. basename ( src) } `
,
(
)
=>
{
const
=
.
join
(
import
.
.
,
'../../'
,
,
'tsconfig.json'
)
;
const
=
new
MonacoGenerator
(
true
)
;
.
execute
(
)
;
const
=
watch
(
` ${ src} /** `
,
{
:
,
:
200
}
)
;
const
=
.
pipe
(
.
)
.
pipe
(
.
debounce
(
(
)
=>
{
const
=
createTsgoStream
(
,
{
:
'watch-client-noEmit'
,
:
true
}
)
;
const
=
.
through
(
)
;
.
on
(
'end'
,
(
)
=>
{
.
emit
(
'end'
)
;
}
)
;
.
on
(
'error'
,
=>
{
reporter
(
)
;
.
error
(
.
red
(
'[tsgo] watch-client-noEmit failed'
)
)
;
.
emit
(
'end'
)
;
}
)
;
return
.
pipe
(
.
end
(
false
)
)
;
}
)
)
;
return
;
}
)
;
}
const
REPO_SRC_FOLDER
=
.
join
(
import
.
.
,
'../../src'
)
;
class
MonacoGenerator
{
private
readonly
:
boolean
;
public
readonly
:
.
;
private
readonly
:
{
[
:
string
]
:
boolean
}
;
private
readonly
:
.
;
private
readonly
:
.
;
constructor
(
:
boolean
)
{
this
.
=
;
this
.
=
.
through
(
)
;
this
.
=
{
}
;
const
onWillReadFile
=
(
:
string
,
:
string
)
=>
{
if
(
!
this
.
)
{
return
;
}
if
(
this
.
[
]
)
{
return
;
}
this
.
[
]
=
true
;
.
watchFile
(
,
(
)
=>
{
this
.
.
invalidateCache
(
)
;
this
.
_executeSoon
(
)
;
}
)
;
}
;
this
.
=
new
class
extends
monacodts
.
{
public
readFileSync
(
:
string
,
:
string
)
:
{
onWillReadFile
(
,
)
;
return
super
.
readFileSync
(
,
)
;
}
}
;
this
.
=
new
monacodts
.
DeclarationResolver
(
this
.
)
;
if
(
this
.
)
{
.
watchFile
(
.
RECIPE_PATH
,
(
)
=>
{
this
.
_executeSoon
(
)
;
}
)
;
}
}
private
:
.
|
null
=
null
;
private
_executeSoon
(
)
:
void
{
if
(
this
.
!==
null
)
{
clearTimeout
(
this
.
)
;
this
.
=
null
;
}
this
.
=
setTimeout
(
(
)
=>
{
this
.
=
null
;
this
.
execute
(
)
;
}
,
20
)
;
}
private
_run
(
)
:
.
|
null
{
const
=
.
run3
(
this
.
)
;
if
(
!
&&
!
this
.
)
{
throw
new
Error
(
` monaco.d.ts generation error - Cannot continue `
)
;
}
return
;
}
private
_log
(
:
string
,
...
:
unknown
[
]
)
:
void
{
fancyLog
(
.
cyan
(
'[monaco.d.ts]'
)
,
,
...
)
;
}
public
execute
(
)
:
void
{
const
=
.
now
(
)
;
const
=
this
.
_run
(
)
;
if
(
!
)
{
return
;
}
if
(
.
)
{
return
;
}
.
writeFileSync
(
.
,
.
)
;
.
writeFileSync
(
.
join
(
REPO_SRC_FOLDER
,
'vs/editor/common/standalone/standaloneEnums.ts'
)
,
.
)
;
this
.
_log
(
` monaco.d.ts is changed - total time took ${ Date. now ( ) - startTime} ms `
)
;
if
(
!
this
.
)
{
this
.
.
emit
(
'error'
,
'monaco.d.ts is no longer up to date. Please run gulp watch and commit the new file.'
)
;
}
}
}
function
generateApiProposalNames
(
)
{
let
:
string
;
try
{
const
=
.
readFileSync
(
'src/vs/platform/extensions/common/extensionsApiProposals.ts'
,
'utf-8'
)
;
const
=
/ \r ? \n / m
.
exec
(
)
;
=
?
[
0
]
:
.
EOL
;
}
catch
{
=
.
EOL
;
}
const
=
/ vscode\. proposed\. ( [ a- z A- Z \d ] + ) \. d\. ts$ /
;
const
=
new
Map< string , { proposal: string } >
(
)
;
const
=
.
through
(
)
;
const
=
.
pipe
(
.
filter
(
(
:
)
=>
.
test
(
.
)
)
)
.
pipe
(
.
through
(
(
:
)
=>
{
const
=
.
basename
(
.
)
;
const
=
.
exec
(
)
;
if
(
!
)
{
return
;
}
const
=
[
1
]
;
.
set
(
,
{
:
` https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed. ${ proposalName} .d.ts `
,
}
)
;
}
,
function
(
)
{
const
=
[
...
.
keys
(
)
]
.
sort
(
)
;
const
=
[
'/*---------------------------------------------------------------------------------------------'
,
' * Copyright (c) Microsoft Corporation. All rights reserved.'
,
' * Licensed under the MIT License. See License.txt in the project root for license information.'
,
' *--------------------------------------------------------------------------------------------*/'
,
''
,
'// THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY.'
,
''
,
'const _allApiProposals = {'
,
` ${ names. map ( proposalName => {
const proposal = proposals. get ( proposalName) ! ;
return ` \t ${ proposalName} : { ${ eol} \t\tproposal: ' ${ proposal. proposal} ', ${ eol} \t} ` ;
} ).join( `
,
{
}
` )} `
,
'};'
,
'export const allApiProposals = Object.freeze<{ [proposalName: string]: Readonly<{ proposal: string }> }>(_allApiProposals);'
,
'export type ApiProposalName = keyof typeof _allApiProposals;'
,
''
,
]
.
join
(
)
;
const
=
'vs/platform/extensions/common/extensionsApiProposals.ts'
;
try
{
const
=
.
readFileSync
(
.
join
(
'src'
,
)
,
'utf-8'
)
;
if
(
===
)
{
this
.
emit
(
'end'
)
;
return
;
}
}
catch
{
}
this
.
emit
(
'data'
,
new
File
(
{
:
,
:
.
from
(
)
}
)
)
;
this
.
emit
(
'end'
)
;
}
)
)
;
return
.
duplex
(
,
)
;
}
const
=
createReporter
(
'api-proposal-names'
)
;
export
const
=
.
define
(
'compile-api-proposal-names'
,
(
)
=>
{
return
.
src
(
'src/vscode-dts/**'
)
.
pipe
(
generateApiProposalNames
(
)
)
.
pipe
(
.
dest
(
'src'
)
)
.
pipe
(
.
end
(
true
)
)
;
}
)
;
function
generateExtensionPointNames
(
)
{
const
:
string
[
]
=
[
]
;
const
=
.
through
(
)
;
const
=
.
pipe
(
.
through
(
function
(
:
)
{
const
=
.
?.
toString
(
'utf-8'
)
;
if
(
&&
.
includes
(
'registerExtensionPoint'
)
)
{
const
=
.
createSourceFile
(
.
,
,
.
.
,
true
)
;
.
push
(
...
extractExtensionPointNamesFromFile
(
)
)
;
}
}
,
function
(
)
{
.
sort
(
)
;
const
=
JSON
.
stringify
(
,
undefined
,
'\t'
)
+
'\n'
;
const
=
'vs/workbench/services/extensions/common/extensionPoints.json'
;
try
{
const
=
.
readFileSync
(
.
join
(
'src'
,
)
,
'utf-8'
)
;
if
(
.
replace
(
/ \r \n / g
,
'\n'
)
===
)
{
this
.
emit
(
'end'
)
;
return
;
}
}
catch
{
}
this
.
emit
(
'data'
,
new
File
(
{
:
,
:
.
from
(
)
}
)
)
;
this
.
emit
(
'end'
)
;
}
)
)
;
return
.
duplex
(
,
)
;
}
const
=
createReporter
(
'extension-point-names'
)
;
export
const
=
.
define
(
'compile-extension-point-names'
,
(
)
=>
{
return
.
src
(
'src/vs/workbench/**/*.ts'
)
.
pipe
(
generateExtensionPointNames
(
)
)
.
pipe
(
.
dest
(
'src'
)
)
.
pipe
(
.
end
(
true
)
)
;
}
)
;
export
const
=
.
define
(
'watch-extension-point-names'
,
(
)
=>
{
const
task
=
(
)
=>
.
src
(
'src/vs/workbench/**/*.ts'
)
.
pipe
(
generateExtensionPointNames
(
)
)
.
pipe
(
.
end
(
true
)
)
;
return
watch
(
'src/vs/workbench/**/*.ts'
,
{
:
200
}
)
.
pipe
(
.
debounce
(
)
)
.
pipe
(
.
dest
(
'src'
)
)
;
}
)
;
export
const
=
.
define
(
'watch-api-proposal-names'
,
(
)
=>
{
const
task
=
(
)
=>
.
src
(
'src/vscode-dts/**'
)
.
pipe
(
generateApiProposalNames
(
)
)
.
pipe
(
.
end
(
true
)
)
;
return
watch
(
'src/vscode-dts/**'
,
{
:
200
}
)
.
pipe
(
.
debounce
(
)
)
.
pipe
(
.
dest
(
'src'
)
)
;
}
)
;
const
=
.
dirname
(
.
dirname
(
import
.
.
)
)
;
const
=
.
join
(
,
'node_modules'
,
'@vscode'
,
'codicons'
,
'dist'
,
'codicon.ttf'
)
;
const
=
.
join
(
,
'src'
,
'vs'
,
'base'
,
'browser'
,
'ui'
,
'codicons'
,
'codicon'
,
'codicon.ttf'
)
;
function
copyCodiconsImpl
(
)
{
try
{
if
(
.
existsSync
(
)
)
{
.
mkdirSync
(
.
dirname
(
)
,
{
:
true
}
)
;
.
copyFileSync
(
,
)
;
}
else
{
fancyLog
(
.
red
(
'[codicons]'
)
,
` codicon.ttf not found in node_modules. Please run 'npm install' to install dependencies. `
)
;
}
}
catch
(
)
{
fancyLog
(
.
red
(
'[codicons]'
)
,
` Error copying codicon.ttf: ${ e} `
)
;
}
}
export
const
=
.
define
(
'copy-codicons'
,
(
)
=>
{
copyCodiconsImpl
(
)
;
return
Promise
.
resolve
(
)
;
}
)
;
.
task
(
)
;
export
const
=
.
define
(
'watch-codicons'
,
(
)
=>
{
copyCodiconsImpl
(
)
;
return
watch
(
'node_modules/@vscode/codicons/dist/**'
,
{
:
200
}
)
.
on
(
'data'
,
(
)
=>
copyCodiconsImpl
(
)
)
;
}
)
;
.
task
(
)
;