@microsoft/live-share-media 1.0.0-preview.3 → 1.0.0-preview.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/bin/EphemeralMediaSession.d.ts +102 -0
- package/bin/EphemeralMediaSession.d.ts.map +1 -0
- package/bin/EphemeralMediaSession.js +226 -0
- package/bin/EphemeralMediaSession.js.map +1 -0
- package/bin/EphemeralMediaSessionCoordinator.d.ts +228 -0
- package/bin/EphemeralMediaSessionCoordinator.d.ts.map +1 -0
- package/bin/EphemeralMediaSessionCoordinator.js +396 -0
- package/bin/EphemeralMediaSessionCoordinator.js.map +1 -0
- package/bin/EphemeralMediaSessionCoordinatorSuspension.d.ts +20 -0
- package/bin/EphemeralMediaSessionCoordinatorSuspension.d.ts.map +1 -0
- package/bin/EphemeralMediaSessionCoordinatorSuspension.js +28 -0
- package/bin/EphemeralMediaSessionCoordinatorSuspension.js.map +1 -0
- package/bin/LiveMediaSession.d.ts.map +1 -1
- package/bin/LiveMediaSession.js +4 -0
- package/bin/LiveMediaSession.js.map +1 -1
- package/bin/MediaPlayerSynchronizer.d.ts.map +1 -1
- package/bin/MediaPlayerSynchronizer.js +9 -6
- package/bin/MediaPlayerSynchronizer.js.map +1 -1
- package/bin/VolumeLimiter.d.ts +70 -0
- package/bin/VolumeLimiter.d.ts.map +1 -0
- package/bin/VolumeLimiter.js +170 -0
- package/bin/VolumeLimiter.js.map +1 -0
- package/package.json +7 -7
- package/src/LiveMediaSession.ts +6 -1
- package/src/MediaPlayerSynchronizer.ts +15 -6
- package/.vscode/launch.json +0 -29
- package/.vscode/settings.json +0 -2
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
import { IMediaPlayer } from './IMediaPlayer';
|
|
6
|
+
export declare enum LevelType {
|
|
7
|
+
fixed = 0,
|
|
8
|
+
percentage = 1
|
|
9
|
+
}
|
|
10
|
+
export declare class VolumeLimiter {
|
|
11
|
+
private readonly _player;
|
|
12
|
+
private readonly _duration;
|
|
13
|
+
private readonly _rampDownDuration;
|
|
14
|
+
private readonly _rampUpDuration;
|
|
15
|
+
private _level;
|
|
16
|
+
private _levelType;
|
|
17
|
+
private _running;
|
|
18
|
+
private _endTime;
|
|
19
|
+
private _startTime;
|
|
20
|
+
private _startVolume;
|
|
21
|
+
private _inRamp;
|
|
22
|
+
constructor(player: IMediaPlayer);
|
|
23
|
+
/**
|
|
24
|
+
* Time, in seconds, that the volume should be lowered.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* Applications should periodically call `lowerVolume()` to keep the volume lowered.
|
|
28
|
+
*/
|
|
29
|
+
get duration(): number;
|
|
30
|
+
set duration(value: number);
|
|
31
|
+
/**
|
|
32
|
+
* Target level to lower volume to.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* Expressed as a value between 0.0 and 1.0. The value is applied based upon the configured
|
|
36
|
+
* `levelType`. The default value is 0.2.
|
|
37
|
+
*
|
|
38
|
+
* For a level type of `LevelType.fixed` the value is the exact level the volume will be
|
|
39
|
+
* lowered to. The default value of 0.2 would cause the volume to be lowered to 0.2.
|
|
40
|
+
*
|
|
41
|
+
* For a level type of `LevelType.percentage` the value is the percentage by which the volume
|
|
42
|
+
* level should be lowered to. The default value of 0.2 would cause the volume to be lowered
|
|
43
|
+
* to 20% of its starting value.
|
|
44
|
+
*/
|
|
45
|
+
get level(): number;
|
|
46
|
+
set level(value: number);
|
|
47
|
+
/**
|
|
48
|
+
* The type of level represented by the `level` property.
|
|
49
|
+
*/
|
|
50
|
+
get levelType(): LevelType;
|
|
51
|
+
set levelType(value: LevelType);
|
|
52
|
+
/**
|
|
53
|
+
* Amount of time, in seconds, it should take to ramp the volume down to the desired level.
|
|
54
|
+
*/
|
|
55
|
+
get rampDownDuration(): number;
|
|
56
|
+
set rampDownDuration(value: number);
|
|
57
|
+
/**
|
|
58
|
+
* Amount of time, in seconds, it should take to ramp the volume back up to the original level.
|
|
59
|
+
*/
|
|
60
|
+
get rampUpDuration(): number;
|
|
61
|
+
set rampUpDuration(value: number);
|
|
62
|
+
/**
|
|
63
|
+
* Temporarily lowers an audio sources volume.
|
|
64
|
+
*/
|
|
65
|
+
lowerVolume(): void;
|
|
66
|
+
private startLimiter;
|
|
67
|
+
private scheduleAnimationFrame;
|
|
68
|
+
private computeTargetVolume;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=VolumeLimiter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VolumeLimiter.d.ts","sourceRoot":"","sources":["../src/VolumeLimiter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE/C,oBAAY,SAAS;IAAG,KAAK,IAAA;IAAE,UAAU,IAAA;CAAE;AAE3C,qBAAa,aAAa;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IAGvC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0B;IACpD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAyB;IAC3D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAyB;IACzD,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,UAAU,CAA8B;IAGhD,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,YAAY;IAIhC;;;;;OAKG;IACH,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,IAAW,QAAQ,CAAC,KAAK,EAAE,MAAM,EAEhC;IAED;;;;;;;;;;;;;OAaG;IACH,IAAW,KAAK,IAAI,MAAM,CAEzB;IAED,IAAW,KAAK,CAAC,KAAK,EAAE,MAAM,EAM7B;IAED;;OAEG;IACH,IAAW,SAAS,IAAI,SAAS,CAEhC;IAED,IAAW,SAAS,CAAC,KAAK,EAAE,SAAS,EAEpC;IAED;;OAEG;IACH,IAAW,gBAAgB,IAAI,MAAM,CAEpC;IAED,IAAW,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAExC;IAED;;OAEG;IACF,IAAW,cAAc,IAAI,MAAM,CAEnC;IAED,IAAW,cAAc,CAAC,KAAK,EAAE,MAAM,EAEtC;IAED;;OAEG;IACI,WAAW,IAAI,IAAI;IAO1B,OAAO,CAAC,YAAY;IAkDpB,OAAO,CAAC,sBAAsB;IAQ9B,OAAO,CAAC,mBAAmB;CAS9B"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.VolumeLimiter = exports.LevelType = void 0;
|
|
8
|
+
const live_share_1 = require("@microsoft/live-share");
|
|
9
|
+
var LevelType;
|
|
10
|
+
(function (LevelType) {
|
|
11
|
+
LevelType[LevelType["fixed"] = 0] = "fixed";
|
|
12
|
+
LevelType[LevelType["percentage"] = 1] = "percentage";
|
|
13
|
+
})(LevelType = exports.LevelType || (exports.LevelType = {}));
|
|
14
|
+
class VolumeLimiter {
|
|
15
|
+
constructor(player) {
|
|
16
|
+
// Settings
|
|
17
|
+
this._duration = new live_share_1.TimeInterval(2000);
|
|
18
|
+
this._rampDownDuration = new live_share_1.TimeInterval(500);
|
|
19
|
+
this._rampUpDuration = new live_share_1.TimeInterval(500);
|
|
20
|
+
this._level = 0.1;
|
|
21
|
+
this._levelType = LevelType.fixed;
|
|
22
|
+
// Running state
|
|
23
|
+
this._running = false;
|
|
24
|
+
this._endTime = 0;
|
|
25
|
+
this._startTime = 0;
|
|
26
|
+
this._startVolume = 0;
|
|
27
|
+
this._inRamp = false;
|
|
28
|
+
this._player = player;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Time, in seconds, that the volume should be lowered.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* Applications should periodically call `lowerVolume()` to keep the volume lowered.
|
|
35
|
+
*/
|
|
36
|
+
get duration() {
|
|
37
|
+
return this._duration.seconds;
|
|
38
|
+
}
|
|
39
|
+
set duration(value) {
|
|
40
|
+
this._duration.seconds = Math.abs(value);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Target level to lower volume to.
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* Expressed as a value between 0.0 and 1.0. The value is applied based upon the configured
|
|
47
|
+
* `levelType`. The default value is 0.2.
|
|
48
|
+
*
|
|
49
|
+
* For a level type of `LevelType.fixed` the value is the exact level the volume will be
|
|
50
|
+
* lowered to. The default value of 0.2 would cause the volume to be lowered to 0.2.
|
|
51
|
+
*
|
|
52
|
+
* For a level type of `LevelType.percentage` the value is the percentage by which the volume
|
|
53
|
+
* level should be lowered to. The default value of 0.2 would cause the volume to be lowered
|
|
54
|
+
* to 20% of its starting value.
|
|
55
|
+
*/
|
|
56
|
+
get level() {
|
|
57
|
+
return this._level;
|
|
58
|
+
}
|
|
59
|
+
set level(value) {
|
|
60
|
+
if (value < 0 || value > 1.0) {
|
|
61
|
+
throw new Error(`VolumeLimiter: cannot set level to ${value}. Level must be between 0.0 and 1.0.`);
|
|
62
|
+
}
|
|
63
|
+
this._level = value;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The type of level represented by the `level` property.
|
|
67
|
+
*/
|
|
68
|
+
get levelType() {
|
|
69
|
+
return this._levelType;
|
|
70
|
+
}
|
|
71
|
+
set levelType(value) {
|
|
72
|
+
this._levelType = value;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Amount of time, in seconds, it should take to ramp the volume down to the desired level.
|
|
76
|
+
*/
|
|
77
|
+
get rampDownDuration() {
|
|
78
|
+
return this._rampDownDuration.seconds;
|
|
79
|
+
}
|
|
80
|
+
set rampDownDuration(value) {
|
|
81
|
+
this._rampDownDuration.seconds = Math.abs(value);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Amount of time, in seconds, it should take to ramp the volume back up to the original level.
|
|
85
|
+
*/
|
|
86
|
+
get rampUpDuration() {
|
|
87
|
+
return this._rampUpDuration.seconds;
|
|
88
|
+
}
|
|
89
|
+
set rampUpDuration(value) {
|
|
90
|
+
this._rampUpDuration.seconds = Math.abs(value);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Temporarily lowers an audio sources volume.
|
|
94
|
+
*/
|
|
95
|
+
lowerVolume() {
|
|
96
|
+
this._endTime = new Date().getTime() + this._duration.milliseconds;
|
|
97
|
+
if (!this._running) {
|
|
98
|
+
this.startLimiter();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
startLimiter() {
|
|
102
|
+
const adjustVolume = () => {
|
|
103
|
+
const now = new Date().getTime();
|
|
104
|
+
if (now < this._endTime) {
|
|
105
|
+
// Make no adjustment if muted
|
|
106
|
+
if (!this._player.muted) {
|
|
107
|
+
// Compute adjusted volume level
|
|
108
|
+
let volume;
|
|
109
|
+
const targetVolume = this.computeTargetVolume();
|
|
110
|
+
const rampRange = this._startVolume - targetVolume;
|
|
111
|
+
const rampUpStart = this._endTime - this._rampUpDuration.milliseconds;
|
|
112
|
+
const rampDownEnd = this._startTime + this._rampDownDuration.milliseconds;
|
|
113
|
+
if (now > rampUpStart) {
|
|
114
|
+
// We're about to end so ramping up
|
|
115
|
+
const progress = (now - rampUpStart) / this._rampUpDuration.milliseconds;
|
|
116
|
+
volume = targetVolume + (rampRange * progress);
|
|
117
|
+
this._player.volume = volume;
|
|
118
|
+
this._inRamp = true;
|
|
119
|
+
}
|
|
120
|
+
else if (now < rampDownEnd) {
|
|
121
|
+
// We just begun so ramping down
|
|
122
|
+
const remaining = (rampDownEnd - now) / this._rampUpDuration.milliseconds;
|
|
123
|
+
volume = targetVolume + (rampRange * remaining);
|
|
124
|
+
this._player.volume = volume;
|
|
125
|
+
this._inRamp = true;
|
|
126
|
+
}
|
|
127
|
+
else if (this._inRamp) {
|
|
128
|
+
// We're at the end of a ramp
|
|
129
|
+
volume = targetVolume;
|
|
130
|
+
this._player.volume = volume;
|
|
131
|
+
this._inRamp = false;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// Schedule next animation frame
|
|
135
|
+
this.scheduleAnimationFrame(adjustVolume);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
// Reset volume to original level
|
|
139
|
+
this._player.volume = this._startVolume;
|
|
140
|
+
this._running = false;
|
|
141
|
+
this._endTime = 0;
|
|
142
|
+
this._startTime = 0;
|
|
143
|
+
this._startVolume = 0;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
this._running = true;
|
|
147
|
+
this._startTime = new Date().getTime();
|
|
148
|
+
this._startVolume = this._player.volume;
|
|
149
|
+
this.scheduleAnimationFrame(adjustVolume);
|
|
150
|
+
}
|
|
151
|
+
scheduleAnimationFrame(callback) {
|
|
152
|
+
if (requestAnimationFrame) {
|
|
153
|
+
requestAnimationFrame(callback);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
setTimeout(callback, 20);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
computeTargetVolume() {
|
|
160
|
+
switch (this._levelType) {
|
|
161
|
+
case LevelType.percentage:
|
|
162
|
+
return this._startVolume * this._level;
|
|
163
|
+
case LevelType.fixed:
|
|
164
|
+
default:
|
|
165
|
+
return this._level;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
exports.VolumeLimiter = VolumeLimiter;
|
|
170
|
+
//# sourceMappingURL=Volum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AAI,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC;gBACxC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;gBACtB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;gBAClB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;gBACpB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;aACzB;QACL,CAAC,CAAC;QAEF,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QACvC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QACxC,IAAI,CAAC,sBAAsB,CAAC,YAAY,CAAC,CAAA;IAC7C,CAAC;IAEO,sBAAsB,CAAC,QAA8B;QACzD,IAAI,qBAAqB,EAAE;YACvB,qBAAqB,CAAC,QAAQ,CAAC,CAAC;SACnC;aAAM;YACH,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;SAC5B;IACL,CAAC;IAEO,mBAAmB;QACvB,QAAQ,IAAI,CAAC,UAAU,EAAE;YACrB,KAAK,SAAS,CAAC,UAAU;gBACrB,OAAO,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;YAC3C,KAAK,SAAS,CAAC,KAAK,CAAC;YACrB;gBACI,OAAO,IAAI,CAAC,MAAM,CAAC;SAC1B;IACL,CAAC;CACJ;AA3KD,sCA2KC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/live-share-media",
|
|
3
|
-
"version": "1.0.0-preview.
|
|
3
|
+
"version": "1.0.0-preview.5",
|
|
4
4
|
"description": "Live Share classes that synchronize media playback across clients.",
|
|
5
5
|
"author": "Microsoft",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
"test:coverage": "nyc --reporter=html --reporter=text --reporter=text-summary npm test"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"
|
|
18
|
-
"
|
|
17
|
+
"@microsoft/live-share": "1.0.0-preview.4",
|
|
18
|
+
"fluid-framework": "~1.2.3"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/assert": "^1.5.6",
|
|
22
|
-
"@types/mocha": "^
|
|
23
|
-
"@types/node": "^18.11.
|
|
24
|
-
"mocha": "^
|
|
22
|
+
"@types/mocha": "^10.0.1",
|
|
23
|
+
"@types/node": "^18.11.18",
|
|
24
|
+
"mocha": "^10.2.0",
|
|
25
25
|
"nyc": "^15.1.0",
|
|
26
|
-
"ts-mocha": "^
|
|
26
|
+
"ts-mocha": "^10.0.0",
|
|
27
27
|
"typescript": "^4.6.4"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
package/src/LiveMediaSession.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { DataObject, DataObjectFactory } from "@fluidframework/aqueduct";
|
|
7
|
-
import { LiveTelemetryLogger, UserMeetingRole } from "@microsoft/live-share";
|
|
7
|
+
import { DynamicObjectRegistry, LiveTelemetryLogger, UserMeetingRole } from "@microsoft/live-share";
|
|
8
8
|
import { MediaPlayerSynchronizer } from "./MediaPlayerSynchronizer";
|
|
9
9
|
import { ITriggerActionEvent, TelemetryEvents } from "./internals";
|
|
10
10
|
import {
|
|
@@ -298,3 +298,8 @@ export class LiveMediaSession extends DataObject {
|
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Register `LiveMediaSession` as an available `LoadableObjectClass` for use in packages that support dynamic object loading, such as `@microsoft/live-share-turbo`.
|
|
304
|
+
*/
|
|
305
|
+
DynamicObjectRegistry.registerObjectClass(LiveMediaSession, LiveMediaSession.TypeName);
|
|
@@ -167,22 +167,31 @@ export class MediaPlayerSynchronizer extends EventEmitter {
|
|
|
167
167
|
this.play();
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
// block play if player state is playing when expected synced state is paused.
|
|
170
|
+
// block play if player state is playing when expected synced state is paused and coordinator is not suspended.
|
|
171
171
|
// needed because cannot tell if its a user initiated event, so disallow play
|
|
172
|
-
if (
|
|
172
|
+
if (
|
|
173
|
+
this._expectedPlaybackState === "paused" &&
|
|
174
|
+
!this._mediaSession.coordinator.isSuspended
|
|
175
|
+
) {
|
|
173
176
|
this._player.pause();
|
|
174
177
|
}
|
|
175
178
|
|
|
176
|
-
// block play if player state is playing when expected synced state is none.
|
|
179
|
+
// block play if player state is playing when expected synced state is none and coordinator is not suspended.
|
|
177
180
|
// needed because user who is not in control should not be able to start, so disallow play
|
|
178
|
-
if (
|
|
181
|
+
if (
|
|
182
|
+
this._expectedPlaybackState === "none" &&
|
|
183
|
+
!this._mediaSession.coordinator.isSuspended
|
|
184
|
+
) {
|
|
179
185
|
this._player.pause();
|
|
180
186
|
}
|
|
181
187
|
break;
|
|
182
188
|
case "pause":
|
|
183
|
-
// block pause if player state is paused when expected synced state is playing
|
|
189
|
+
// block pause if player state is paused when expected synced state is playing and coordinator is not suspended.
|
|
184
190
|
// needed because cannot tell if its a user initiated event, so disallow pause
|
|
185
|
-
if (
|
|
191
|
+
if (
|
|
192
|
+
this._expectedPlaybackState === "playing" &&
|
|
193
|
+
!this._mediaSession.coordinator.isSuspended
|
|
194
|
+
) {
|
|
186
195
|
this._player.play();
|
|
187
196
|
}
|
|
188
197
|
break;
|
package/.vscode/launch.json
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// Use IntelliSense to learn about possible attributes.
|
|
3
|
-
// Hover to view descriptions of existing attributes.
|
|
4
|
-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
-
"version": "0.2.0",
|
|
6
|
-
"configurations": [
|
|
7
|
-
{
|
|
8
|
-
"name": "Attach by Process ID",
|
|
9
|
-
"processId": "${command:PickProcess}",
|
|
10
|
-
"request": "attach",
|
|
11
|
-
"skipFiles": [
|
|
12
|
-
"<node_internals>/**"
|
|
13
|
-
],
|
|
14
|
-
"type": "node"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"type": "pwa-node",
|
|
18
|
-
"request": "launch",
|
|
19
|
-
"name": "Launch Program",
|
|
20
|
-
"skipFiles": [
|
|
21
|
-
"<node_internals>/**"
|
|
22
|
-
],
|
|
23
|
-
"program": "${workspaceFolder}\\bin\\index.js",
|
|
24
|
-
"outFiles": [
|
|
25
|
-
"${workspaceFolder}/**/*.js"
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
]
|
|
29
|
-
}
|
package/.vscode/settings.json
DELETED