-
Notifications
You must be signed in to change notification settings - Fork 281
/
configuration.ts
1146 lines (989 loc) · 32.6 KB
/
configuration.ts
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
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
import pkg from '../package.json';
import { SourceMapTimeouts } from './adapter/sources';
import { DebugType } from './common/contributionUtils';
import { assertNever, filterValues } from './common/objUtils';
import Dap from './dap/api';
import { AnyRestartOptions } from './targets/node/restartPolicy';
export interface IMandatedConfiguration extends Dap.LaunchParams {
/**
* The type of the debug session.
*/
type: string;
/**
* The name of the debug session.
*/
name: string;
/**
* The request type of the debug session.
*/
request: string;
/**
* Options that configure when the VS Code debug console opens.
*/
internalConsoleOptions?: 'neverOpen' | 'openOnSessionStart' | 'openOnFirstSessionStart';
// Lifecycle tasks:
preLaunchTask?: string;
postDebugTask?: string;
preRestartTask?: string;
postRestartTask?: string;
}
export const enum OutputSource {
Console = 'console',
Stdio = 'std',
}
export interface ILoggingConfiguration {
/**
* Whether to return trace data from the launched application or browser.
*/
stdio: boolean;
/**
* Configures where on disk logs are written. If this is null, no logs
* will be written, otherwise the extension log directory (in VS Code) or
* OS tmpdir (in VS) will be used.
*/
logFile: string | null;
}
/**
* Configuration for async stacks. See {@link IAsyncStackPolicy} for reasoning.
* - `true` aliases { onBoot: 32 }
* - `false` disables async stacks
* - `{ onBoot: N }` enables N async stacks when a target attaches
* - `{ onceBreakpointResolved: N }` enables N async stacks the first time a
* breakpoint is verified or hit.
*/
export type AsyncStackMode = boolean | { onAttach: number } | { onceBreakpointResolved: number };
export interface IBaseConfiguration extends IMandatedConfiguration {
/**
* A list of minimatch patterns for locations (folders and URLs) in which
* source maps can be used to resolve local files. This can be used to avoid
* incorrectly breaking in external source mapped code. Patterns can be
* prefixed with "!" to exclude them. May be set to an empty array or null
* to avoid restriction.
*/
resolveSourceMapLocations: ReadonlyArray<string> | null;
/**
* Locations that should be scanned while looking for sourcemaps. Patterns
* can be prefixed with "!" to exclude them.
*/
outFiles: ReadonlyArray<string>;
/**
* Whether to pause when sourcemapped scripts are loaded to load their
* sourcemap and ensure breakpoints are set.
*/
pauseForSourceMap: boolean;
/**
* Show the async calls that led to the current call stack.
*/
showAsyncStacks: AsyncStackMode;
/**
* An array of glob patterns for files to skip when debugging.
*/
skipFiles: ReadonlyArray<string>;
/**
* Automatically step through generated code that cannot be mapped back to the original source.
*/
smartStep: boolean;
/**
* Use JavaScript source maps (if they exist).
*/
sourceMaps: boolean;
/**
* Whether to use the "names" mapping in sourcemaps. This requires requesting
* source content, which can be slow with certain debuggers.
*/
sourceMapRenames: boolean;
/**
* A set of mappings for rewriting the locations of source files from what
* the sourcemap says, to their locations on disk.
*/
sourceMapPathOverrides: { [key: string]: string };
/**
* Retry for this number of milliseconds to connect to the debug adapter.
*/
timeout: number;
/**
* Timeouts for several operations.
*/
timeouts: Partial<Timeouts>;
/**
* Logging configuration
*/
trace: boolean | Partial<ILoggingConfiguration>;
/**
* Location where sources can be found.
*/
rootPath?: string;
/**
* From where to capture output messages: The debug API, or stdout/stderr streams.
*/
outputCapture: OutputSource;
/**
* Toggles whether we verify the contents of files on disk match the ones
* loaded in the runtime. This is useful in a variety of scenarios and
* required in some, but can cause issues if you have server-side
* transformation of scripts, for example.
*/
enableContentValidation: boolean;
/**
* A list of debug sessions which, when this debug session is terminated,
* will also be stopped.
*/
cascadeTerminateToConfigurations: string[];
/**
* The value of the ${workspaceFolder} variable
*/
__workspaceFolder: string;
/**
* Cache directory for workspace-related configuration.
*/
__workspaceCachePath?: string;
/**
* If a file starts with this prefix, we'll consider it a remote file, and perform it's operation thorugh DAP requests
*/
__remoteFilePrefix: string | undefined;
/**
* Whether to stop if a conditional breakpoint throws an error.
*/
__breakOnConditionalError: boolean;
/**
* Function used to generate the description of the objects shown in the debugger
* e.g.: "function (defaultDescription) { return this.toString(); }"
*/
customDescriptionGenerator?: string;
/**
* Function used to generate the custom properties to show for objects in the debugger
* e.g.: "function () { return {...this, extraProperty: 'otherProperty' } }"
*/
customPropertiesGenerator?: string;
}
export type Timeouts = SourceMapTimeouts & {
/**
* When evaluating the symbol that is hovered in the editor, we wait no longer than |hoverEvaluation| timeout before evaluation is canceled.
* Use 0 to never time out.
*/
hoverEvaluation: number;
};
export interface IExtensionHostBaseConfiguration extends INodeBaseConfiguration {
type: DebugType.ExtensionHost;
/**
* Command line arguments passed to the program.
*/
args: ReadonlyArray<string>;
/**
* If source maps are enabled, these glob patterns specify the generated
* JavaScript files. If a pattern starts with `!` the files are excluded.
* If not specified, the generated code is expected in the same directory
* as its source.
*/
outFiles: ReadonlyArray<string>;
/**
* Path to the VS Code binary.
*/
runtimeExecutable: string | null;
}
export interface IExtensionHostLaunchConfiguration extends IExtensionHostBaseConfiguration {
request: 'launch';
/**
* Whether we should try to attach to webviews in the launched
* VS Code instance.
*/
debugWebviews: boolean;
/**
* Whether we should try to attach to debug the web worker extension host.
*/
debugWebWorkerHost: boolean;
/**
* Chrome launch options used when attaching to the renderer process.
*/
rendererDebugOptions: Partial<IChromeAttachConfiguration>;
/**
* Port the extension host is listening on.
*/
port?: number;
/**
* Extension host session ID. A "magical" value set by VS Code.
*/
__sessionId: string;
}
export interface IExtensionHostAttachConfiguration extends IExtensionHostBaseConfiguration {
type: DebugType.ExtensionHost;
request: 'attach';
debugWebviews: boolean;
debugWebWorkerHost: boolean;
__sessionId: string;
port: number;
rendererDebugOptions: Partial<IChromeAttachConfiguration>;
}
/**
* Common configuration for the Node debugger.
*/
export interface INodeBaseConfiguration extends IBaseConfiguration, IConfigurationWithEnv {
/**
* Absolute path to the working directory of the program being debugged.
*/
cwd?: string;
/**
* If source maps are enabled, these glob patterns specify the generated
* JavaScript files. If a pattern starts with `!` the files are excluded.
* If not specified, the generated code is expected in the same directory
* as its source.
*/
outFiles: ReadonlyArray<string>;
/**
* Path to the local directory containing the program.
*/
localRoot: string | null;
/**
* Path to the remote directory containing the program.
*/
remoteRoot: string | null;
/**
* Attach debugger to new child processes automatically.
*/
autoAttachChildProcesses: boolean;
/**
* A list of patterns at which to manually insert entrypoint breakpoints.
* This can be useful to give the debugger an opportunity to set breakpoints
* when using sourcemaps that don't exist or can't be detected before launch.
* @see https://github.com/microsoft/vscode-js-debug/issues/492
*/
runtimeSourcemapPausePatterns: ReadonlyArray<string>;
/**
* Allows you to explicitly specify the Node version that's running, which
* can be used to disable or enable certain behaviors in cases where the
* automatic version detection does not working.
*/
nodeVersionHint?: number;
/**
* Whether to automatically resume processes if we see they were launched
* with `--inpect-brk`.
*/
continueOnAttach?: boolean;
}
export interface IConfigurationWithEnv {
/**
* Environment variables passed to the program. The value `null` removes the
* variable from the environment.
*/
env: Readonly<{ [key: string]: string | null }>;
/**
* Absolute path to a file containing environment variable definitions.
*/
envFile: string | null;
}
export const enum KillBehavior {
Forceful = 'forceful',
Polite = 'polite',
None = 'none',
}
/**
* Configuration for a launch request.
*/
export interface INodeLaunchConfiguration extends INodeBaseConfiguration, IConfigurationWithEnv {
type: DebugType.Node;
request: 'launch';
/**
* @override
*/
cwd: string;
/**
* Program to use to launch the debugger.
*/
program?: string;
/**
* Automatically stop program after launch. It can be set to a boolean, or
* the absolute filepath to stop in. Setting a path for stopOnEntry should
* only be needed in esoteric scenarios where it cannot be inferred
* from the run args.
*/
stopOnEntry: boolean | string;
/**
* Where to launch the debug target.
*/
console: 'internalConsole' | 'integratedTerminal' | 'externalTerminal';
/**
* Command line arguments passed to the program.
*/
args: string | ReadonlyArray<string>;
/**
* Restart session after Node.js has terminated.
*/
restart: AnyRestartOptions;
/**
* Runtime to use. Either an absolute path or the name of a runtime
* available on the PATH. If omitted `node` is assumed.
*/
runtimeExecutable: string | null;
/**
* Version of `node` runtime to use. Requires `nvm`.
*/
runtimeVersion: string;
/**
* Optional arguments passed to the runtime executable.
*/
runtimeArgs: ReadonlyArray<string>;
/**
* If true, will start profiling soon as the process launches.
*/
profileStartup: boolean;
/**
* Legacy debug port. Now, only used for --inspect-brk compatbility.
* @see https://github.com/microsoft/vscode-js-debug/issues/584
* @deprecated
*/
port?: number;
/**
* Simple port to attach to. If set, attach mode will be used and no
* bootloader will be injected. This is less desirable than letting the
* bootloader do its thing, but is needed is some esoteric cases (such as
* Deno and cases where the "launch" actually runs a Docker container.)
*/
attachSimplePort: null | number;
/**
* Configures how debug process are killed when stopping the sesssion. Can be:
* - forceful (default): forcefully tears down the process tree. Sends
* SIGKILL on posix, or `taskkill.exe /F` on Windows.
* - polite: gracefully tears down the process tree. It's possible that
* misbehaving processes continue to run after shutdown in this way. Sends
* SIGTERM on posix, or `taskkill.exe` with no `/F` (force) flag on Windows.
* - none: no termination will happen.
*/
killBehavior: KillBehavior;
}
/**
* A mapping of URLs/paths to local folders, to resolve scripts
* in Chrome to scripts on disk
*/
export type PathMapping = Readonly<{ [key: string]: string }>;
export interface IChromiumBaseConfiguration extends IBaseConfiguration {
/**
* Controls whether to skip the network cache for each request.
*/
disableNetworkCache: boolean;
/**
* A mapping of URLs/paths to local folders, to resolve scripts
* in Chrome to scripts on disk
*/
pathMapping: PathMapping;
/**
* This specifies the workspace absolute path to the webserver root. Used to
* resolve paths like `/app.js` to files on disk. Shorthand for a pathMapping for "/".
*/
webRoot: string;
/**
* Will navigate to this URL and attach to it. This can be omitted to
* avoid navigation.
*/
url: string | null;
/**
* Will search for a page with this url and attach to it, if found.
* Can have * wildcards.
*/
urlFilter: string;
/**
* Launch options to boot a server.
*/
server: INodeLaunchConfiguration | ITerminalLaunchConfiguration | null;
/**
* A list of file glob patterns to find `*.vue` components. By default,
* searches the entire workspace. This needs to be specified due to extra
* lookups that Vue's sourcemaps require.
*/
vueComponentPaths: ReadonlyArray<string>;
/**
* WebSocket (`ws://`) address of the inspector. It's a template string that
* interpolates keys in `{curlyBraces}`. Available keys are:
*
* - `url.*` is the parsed address of the running application. For instance,
* `{url.port}`, `{url.hostname}`
* - `port` is the debug port that Chrome is listening on.
* - `browserInspectUri` is the inspector URI on the launched browser
' - `browserInspectUriPath` is the path part of the inspector URI on the launched browser (e.g.: "/devtools/browser/e9ec0098-306e-472a-8133-5e42488929c2").\n' +
* - `wsProtocol` is the hinted websocket protocol. This is set to `wss` if
* the original URL is `https`, or `ws` otherwise.
*/
inspectUri?: string | null;
/**
* Whether scripts are loaded individually with unique sourcemaps containing
* the basename of the source file. This can be set to optimize sourcemap
* handling when dealing with lots of small scripts. If set to "auto", we'll
* detect known cases where this is appropriate.
*/
perScriptSourcemaps: 'yes' | 'no' | 'auto';
}
/**
* Opens a debugger-enabled terminal.
*/
export interface ITerminalLaunchConfiguration extends INodeBaseConfiguration {
type: DebugType.Terminal;
request: 'launch';
/**
* Command to run.
*/
command?: string;
}
/**
* Configuration for an attach request.
*/
export interface INodeAttachConfiguration extends INodeBaseConfiguration {
type: DebugType.Node;
request: 'attach';
/**
* Inspector webSocket address
*/
websocketAddress?: string;
/**
* TCP/IP address of process to be debugged. Default is 'localhost'.
*/
address: string;
/**
* Debug port to attach to. Default is 9229.
*/
port: number;
/**
* Restart session after Node.js has terminated.
*/
restart: AnyRestartOptions;
/**
* ID of process to attach to.
*/
processId?: string;
/**
* Whether to attempt to attach to already-spawned child processes.
*/
attachExistingChildren: boolean;
}
export interface IChromiumLaunchConfiguration extends IChromiumBaseConfiguration {
request: 'launch';
/**
* Port for the browser to listen on.
*/
port: number;
/**
* Optional working directory for the runtime executable.
*/
cwd: string | null;
/**
* Optional dictionary of environment key/value.
*/
env: { [key: string]: string | null };
/**
* A local html file to open in the browser.
*/
file: string | null;
/**
* Whether default browser launch arguments (to disable features that may
* make debugging harder) will be included in the launch.
*/
includeDefaultArgs: boolean;
/**
* Whether any default launch/debugging arguments are set on the browser.
* The debugger will assume the browser will use pipe debugging such as that
* which is provided with `--remote-debugging-pipe`. For advanced use cases.
*/
includeLaunchArgs: boolean;
/**
* Additional browser command line arguments.
*/
runtimeArgs: ReadonlyArray<string> | null;
/**
* Either 'canary', 'stable', 'custom' or path to the browser executable.
* Custom means a custom wrapper, custom build or CHROME_PATH
* environment variable.
*/
runtimeExecutable: string | null;
/**
* By default, Chrome is launched with a separate user profile in a temp
* folder. Use this option to override it. Set to false to launch
* with your default user profile.
*/
userDataDir: string | boolean;
/**
* The debug adapter is running elevated. Launch Chrome unelevated to avoid the security restrictions of running Chrome elevated
*/
launchUnelevated?: boolean;
/**
* Internal use only. Do not include in contrib.
*/
skipNavigateForTest?: boolean;
/**
* Forces the browser to be launched in one location. In a remote workspace
* (through ssh or WSL, for example) this can be used to open the browser
* on the remote machine rather than locally.
*/
browserLaunchLocation: 'workspace' | 'ui' | null;
/**
* If true, will start profiling soon as the page launches.
*/
profileStartup: boolean;
/**
* Close whole browser or just the tab when cleaning up
*/
cleanUp: 'wholeBrowser' | 'onlyTab';
}
/**
* Configuration to launch to a Chrome instance.
*/
export interface IChromeLaunchConfiguration extends IChromiumLaunchConfiguration {
type: DebugType.Chrome;
__pendingTargetId?: string;
}
export interface IChromiumAttachConfiguration extends IChromiumBaseConfiguration {
request: 'attach';
/**
* TCP/IP address of process to be debugged (for Node.js >= 5.0 only).
* Default is 'localhost'.
*/
address: string;
/**
* Debug port to attach to. Default is 9229.
*/
port: number;
/**
* Whether to restart whe attachment is lost.
*/
restart: boolean;
/**
* Whether to attach to all targets that match the URL filter ("automatic")
* or ask the user to pick one ("pick").
*/
targetSelection: 'pick' | 'automatic';
/**
* Forces the browser to attach in one location. In a remote workspace
* (through ssh or WSL, for example) this can be used to attach to a browser
* on the remote machine rather than locally.
*/
browserAttachLocation: 'workspace' | 'ui' | null;
}
/**
* Configuration to attach to a Chrome instance.
*/
export interface IChromeAttachConfiguration extends IChromiumAttachConfiguration {
type: DebugType.Chrome;
restart: boolean;
__pendingTargetId?: string;
}
/**
* Fake 'attach' config used in the binder.
*/
export interface IPseudoAttachConfiguration extends IMandatedConfiguration {
type: DebugType;
request: 'attach' | 'launch';
__pendingTargetId: string;
preLaunchTask?: string;
postDebugTask?: string;
preRestartTask?: string;
postRestartTask?: string;
}
/**
* Configuration to launch to a Edge instance.
*/
export interface IEdgeLaunchConfiguration extends IChromiumLaunchConfiguration {
type: DebugType.Edge;
/**
* Enable web view debugging.
*/
useWebView: boolean;
/**
* TCP/IP address of webview to be debugged. Default is 'localhost'.
*/
address?: string;
}
/**
* Configuration to attach to a Edge instance.
*/
export interface IEdgeAttachConfiguration extends IChromiumAttachConfiguration {
type: DebugType.Edge;
request: 'attach';
useWebView: boolean | { pipeName: string };
}
/**
* Attach request used internally to inject a pre-built target into the lifecycle.
*/
export interface ITerminalDelegateConfiguration extends INodeBaseConfiguration {
type: DebugType.Terminal;
request: 'attach';
delegateId: number;
}
export type AnyNodeConfiguration =
| INodeAttachConfiguration
| INodeLaunchConfiguration
| ITerminalLaunchConfiguration
| IExtensionHostLaunchConfiguration
| IExtensionHostAttachConfiguration
| ITerminalDelegateConfiguration;
export type AnyChromeConfiguration = IChromeAttachConfiguration | IChromeLaunchConfiguration;
export type AnyEdgeConfiguration = IEdgeAttachConfiguration | IEdgeLaunchConfiguration;
export type AnyChromiumLaunchConfiguration = IEdgeLaunchConfiguration | IChromeLaunchConfiguration;
export type AnyChromiumAttachConfiguration = IEdgeAttachConfiguration | IChromeAttachConfiguration;
export type AnyChromiumConfiguration = AnyEdgeConfiguration | AnyChromeConfiguration;
export type AnyLaunchConfiguration = AnyChromiumConfiguration | AnyNodeConfiguration;
export type AnyTerminalConfiguration =
| ITerminalDelegateConfiguration
| ITerminalLaunchConfiguration;
/**
* Where T subtypes AnyLaunchConfiguration, gets the resolving version of T.
*/
export type ResolvingConfiguration<T> = IMandatedConfiguration & Partial<T>;
export type ResolvingExtensionHostConfiguration =
ResolvingConfiguration<IExtensionHostLaunchConfiguration>;
export type ResolvingNodeAttachConfiguration = ResolvingConfiguration<INodeAttachConfiguration>;
export type ResolvingNodeLaunchConfiguration = ResolvingConfiguration<INodeLaunchConfiguration>;
export type ResolvingTerminalDelegateConfiguration =
ResolvingConfiguration<ITerminalDelegateConfiguration>;
export type ResolvingTerminalLaunchConfiguration =
ResolvingConfiguration<ITerminalLaunchConfiguration>;
export type ResolvingTerminalConfiguration =
| ResolvingTerminalDelegateConfiguration
| ResolvingTerminalLaunchConfiguration;
export type ResolvingNodeConfiguration =
| ResolvingNodeAttachConfiguration
| ResolvingNodeLaunchConfiguration;
export type ResolvingChromeConfiguration = ResolvingConfiguration<AnyChromeConfiguration>;
export type ResolvingEdgeConfiguration = ResolvingConfiguration<AnyEdgeConfiguration>;
export type AnyResolvingConfiguration =
| ResolvingExtensionHostConfiguration
| ResolvingChromeConfiguration
| ResolvingNodeAttachConfiguration
| ResolvingNodeLaunchConfiguration
| ResolvingTerminalConfiguration
| ResolvingEdgeConfiguration;
export const AnyLaunchConfiguration = Symbol('AnyLaunchConfiguration');
/**
* Where T subtypes AnyResolvingConfiguration, gets the resolved version of T.
*/
export type ResolvedConfiguration<T> = T extends ResolvingNodeAttachConfiguration
? INodeAttachConfiguration
: T extends ResolvingExtensionHostConfiguration
? IExtensionHostLaunchConfiguration
: T extends ResolvingNodeLaunchConfiguration
? INodeLaunchConfiguration
: T extends ResolvingChromeConfiguration
? AnyChromeConfiguration
: T extends ResolvingTerminalConfiguration
? ITerminalLaunchConfiguration
: never;
export const baseDefaults: IBaseConfiguration = {
type: '',
name: '',
request: '',
trace: false,
outputCapture: OutputSource.Console,
timeout: 10000,
timeouts: {},
showAsyncStacks: true,
skipFiles: [],
smartStep: true,
sourceMaps: true,
sourceMapRenames: true,
pauseForSourceMap: true,
resolveSourceMapLocations: null,
rootPath: '${workspaceFolder}',
outFiles: ['${workspaceFolder}/**/*.js', '!**/node_modules/**'],
sourceMapPathOverrides: defaultSourceMapPathOverrides('${workspaceFolder}'),
enableContentValidation: true,
cascadeTerminateToConfigurations: [],
// Should always be determined upstream;
__workspaceFolder: '',
__remoteFilePrefix: undefined,
__breakOnConditionalError: false,
customDescriptionGenerator: undefined,
customPropertiesGenerator: undefined,
};
const nodeBaseDefaults: INodeBaseConfiguration = {
...baseDefaults,
cwd: '${workspaceFolder}',
env: {},
envFile: null,
pauseForSourceMap: false,
sourceMaps: true,
localRoot: null,
remoteRoot: null,
resolveSourceMapLocations: ['**', '!**/node_modules/**'],
autoAttachChildProcesses: true,
runtimeSourcemapPausePatterns: [],
skipFiles: ['<node_internals>/**'],
};
export const terminalBaseDefaults: ITerminalLaunchConfiguration = {
...nodeBaseDefaults,
showAsyncStacks: { onceBreakpointResolved: 16 },
type: DebugType.Terminal,
request: 'launch',
name: 'JavaScript Debug Terminal',
};
export const delegateDefaults: ITerminalDelegateConfiguration = {
...nodeBaseDefaults,
type: DebugType.Terminal,
request: 'attach',
name: terminalBaseDefaults.name,
showAsyncStacks: { onceBreakpointResolved: 16 },
delegateId: -1,
};
export const extensionHostConfigDefaults: IExtensionHostLaunchConfiguration = {
...nodeBaseDefaults,
type: DebugType.ExtensionHost,
name: 'Debug Extension',
request: 'launch',
args: ['--extensionDevelopmentPath=${workspaceFolder}'],
outFiles: ['${workspaceFolder}/out/**/*.js'],
resolveSourceMapLocations: ['${workspaceFolder}/**', '!**/node_modules/**'],
rendererDebugOptions: {},
runtimeExecutable: '${execPath}',
autoAttachChildProcesses: false,
debugWebviews: false,
debugWebWorkerHost: false,
__sessionId: '',
};
export const nodeLaunchConfigDefaults: INodeLaunchConfiguration = {
...nodeBaseDefaults,
type: DebugType.Node,
request: 'launch',
program: '',
cwd: '${workspaceFolder}',
stopOnEntry: false,
console: 'internalConsole',
restart: false,
args: [],
runtimeExecutable: 'node',
runtimeVersion: 'default',
runtimeArgs: [],
profileStartup: false,
attachSimplePort: null,
killBehavior: KillBehavior.Forceful,
};
export const chromeAttachConfigDefaults: IChromeAttachConfiguration = {
...baseDefaults,
type: DebugType.Chrome,
request: 'attach',
address: 'localhost',
port: 0,
disableNetworkCache: true,
pathMapping: {},
url: null,
restart: false,
urlFilter: '',
sourceMapPathOverrides: defaultSourceMapPathOverrides('${webRoot}'),
webRoot: '${workspaceFolder}',
server: null,
browserAttachLocation: 'workspace',
targetSelection: 'automatic',
vueComponentPaths: ['${workspaceFolder}/**/*.vue', '!**/node_modules/**'],
perScriptSourcemaps: 'auto',
};
export const edgeAttachConfigDefaults: IEdgeAttachConfiguration = {
...chromeAttachConfigDefaults,
type: DebugType.Edge,
useWebView: false,
};
export const chromeLaunchConfigDefaults: IChromeLaunchConfiguration = {
...chromeAttachConfigDefaults,
type: DebugType.Chrome,
request: 'launch',
cwd: null,
file: null,
env: {},
urlFilter: '*',
includeDefaultArgs: true,
includeLaunchArgs: true,
runtimeArgs: null,
runtimeExecutable: '*',
userDataDir: true,
browserLaunchLocation: 'workspace',
profileStartup: false,
cleanUp: 'wholeBrowser',
};
export const edgeLaunchConfigDefaults: IEdgeLaunchConfiguration = {
...chromeLaunchConfigDefaults,
type: DebugType.Edge,
useWebView: false,
};
export const nodeAttachConfigDefaults: INodeAttachConfiguration = {
...nodeBaseDefaults,
type: DebugType.Node,
attachExistingChildren: true,
address: 'localhost',
port: 9229,
restart: false,
request: 'attach',
continueOnAttach: false,
};
export function defaultSourceMapPathOverrides(webRoot: string): { [key: string]: string } {
return {
'webpack:///./~/*': `${webRoot}/node_modules/*`,
'webpack:////*': '/*',
'webpack://@?:*/?:*/*': `${webRoot}/*`,
'webpack://?:*/*': `${webRoot}/*`,
'webpack:///([a-z]):/(.+)': '$1:/$2',
'meteor://💻app/*': `${webRoot}/*`,
};
}
export function applyNodeDefaults({ ...config }: ResolvingNodeConfiguration): AnyNodeConfiguration {
if (!config.sourceMapPathOverrides && config.cwd) {
config.sourceMapPathOverrides = defaultSourceMapPathOverrides(config.cwd);
}
// Resolve source map locations from the outFiles by default:
// https://github.com/microsoft/vscode-js-debug/issues/704
if (config.resolveSourceMapLocations === undefined && !config.remoteRoot) {
config.resolveSourceMapLocations = config.outFiles;
}
if (config.request === 'attach') {
return { ...nodeAttachConfigDefaults, ...config };
} else {
return { ...nodeLaunchConfigDefaults, ...config };
}
}
export function applyChromeDefaults(
config: ResolvingChromeConfiguration,
browserLocation: 'workspace' | 'ui',
): AnyChromeConfiguration {
return config.request === 'attach'
? { ...chromeAttachConfigDefaults, browserAttachLocation: browserLocation, ...config }
: { ...chromeLaunchConfigDefaults, browserLaunchLocation: browserLocation, ...config };
}
export function applyEdgeDefaults(
config: ResolvingEdgeConfiguration,
browserLocation: 'workspace' | 'ui',
): AnyEdgeConfiguration {
return config.request === 'attach'
? { ...edgeAttachConfigDefaults, browserAttachLocation: browserLocation, ...config }
: { ...edgeLaunchConfigDefaults, browserLaunchLocation: browserLocation, ...config };
}
export function applyExtensionHostDefaults(
config: ResolvingExtensionHostConfiguration,
): IExtensionHostLaunchConfiguration {
const resolved = { ...extensionHostConfigDefaults, ...config };
resolved.skipFiles = [...resolved.skipFiles, '**/node_modules.asar/**', '**/bootstrap-fork.js'];
return resolved;
}