Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…htscript-language into diagnosticManager
  • Loading branch information
TwitchBronBron committed Oct 3, 2023
2 parents 0afae62 + c49a541 commit cc5db8a
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 654 deletions.
709 changes: 75 additions & 634 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 23 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"rimraf": "^3.0.0",
"sinon": "^7.2.3",
"source-map-support": "^0.5.21",
"statigen": "^0.5.0",
"statigen": "^0.5.1",
"terminal-overwrite": "^2.0.1",
"ts-node": "^10.9.1",
"tslib": "^2.3.1",
Expand Down Expand Up @@ -824,6 +824,28 @@
"type": "boolean",
"default": false,
"description": "Delete any currently installed dev channel before starting the debug session"
},
"remoteControlMode": {
"oneOf": [
{
"type": "object",
"description": "Options for activating and deactivating remote control mode",
"properties": {
"activateOnSessionStart": {
"type": "boolean",
"description": "Activate remote control mode on debug session start"
},
"deactivateOnSessionEnd": {
"type": "boolean",
"description": "Deactivate remote control mode on session end"
}
}
},
{
"type": "boolean",
"description": "Activate on session start, deactivate on session end."
}
]
}
}
}
Expand Down
15 changes: 14 additions & 1 deletion src/DebugConfigurationProvider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('BrightScriptConfigurationProvider', () => {
s`${folder.uri.fsPath}/out/`
);
} else {
expect(config[key], `Expected "${key}" to match the default`).to.equal(configDefaults[key]);
expect(config[key], `Expected "${key}" to match the default`).to.deep.equal(configDefaults[key]);
}
}
});
Expand All @@ -164,6 +164,19 @@ describe('BrightScriptConfigurationProvider', () => {
expect(config.packagePort).to.equal(1234);
expect(config.remotePort).to.equal(5678);
});

[
{ input: true, expected: { activateOnSessionStart: true, deactivateOnSessionEnd: true } },
{ input: false, expected: { activateOnSessionStart: false, deactivateOnSessionEnd: false } },
{ input: undefined, expected: { activateOnSessionStart: false, deactivateOnSessionEnd: false } }
].forEach(({ input, expected }) => {
it('allows using a bool value for remoteConfigMode', async () => {
let config = await configProvider.resolveDebugConfiguration(folder, <any>{
remoteControlMode: input
});
expect(config.remoteControlMode).to.deep.equal(expected);
});
});
});

describe('processLogfilePath', () => {
Expand Down
23 changes: 22 additions & 1 deletion src/DebugConfigurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio
enableDebugProtocol: false,
remotePort: 8060,
rendezvousTracking: true,
deleteDevChannelBeforeInstall: false
deleteDevChannelBeforeInstall: false,
remoteControlMode: {
activateOnSessionStart: false,
deactivateOnSessionEnd: false
}
};

let config: any = vscode.workspace.getConfiguration('brightscript') || {};
Expand Down Expand Up @@ -243,6 +247,17 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio
config.cwd = folderUri.fsPath;
config.rendezvousTracking = config.rendezvousTracking === false ? false : true;
config.deleteDevChannelBeforeInstall = config.deleteDevChannelBeforeInstall === true;
if (typeof config.remoteControlMode === 'boolean') {
config.remoteControlMode = {
activateOnSessionStart: config.remoteControlMode,
deactivateOnSessionEnd: config.remoteControlMode
};
} else {
config.remoteControlMode = {
activateOnSessionStart: config.remoteControlMode?.activateOnSessionStart ?? this.configDefaults.remoteControlMode.activateOnSessionStart,
deactivateOnSessionEnd: config.remoteControlMode?.deactivateOnSessionEnd ?? this.configDefaults.remoteControlMode.deactivateOnSessionEnd
};
}

if (config.request !== 'launch') {
await vscode.window.showErrorMessage(`roku-debug only supports the 'launch' request type`);
Expand Down Expand Up @@ -561,4 +576,10 @@ export interface BrightScriptLaunchConfiguration extends LaunchConfiguration {
* If injectRdbOnDeviceComponent is true and this is true the screen saver will be be disabled while the deployed application is running.
*/
disableScreenSaver?: boolean;

/**
* If set, the remote control will be enabled/disabled at the start/end of the debug session, respectively.
* @default { activateOnSessionStart: false, deactivateOnSessionEnd: false }
*/
remoteControlMode?: { activateOnSessionStart?: boolean; deactivateOnSessionEnd?: boolean };
}
7 changes: 7 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ export class Extension {
//if this is a brightscript debug session
if (e.type === 'brightscript') {
this.chanperfStatusBar.hide();
const config = e.configuration as BrightScriptLaunchConfiguration;
if (config.remoteControlMode?.deactivateOnSessionEnd) {
void this.remoteControlManager.setRemoteControlMode(false, 'launch');
}
}
this.diagnosticManager.clear();
});
Expand Down Expand Up @@ -216,6 +220,9 @@ export class Extension {
const config = e.body as BrightScriptLaunchConfiguration;
await docLinkProvider.setLaunchConfig(config);
logOutputManager.setLaunchConfig(config);
if (config.remoteControlMode?.activateOnSessionStart) {
void this.remoteControlManager.setRemoteControlMode(true, 'launch');
}
} else if (isChannelPublishedEvent(e)) {
this.webviewViewProviderManager.onChannelPublishedEvent(e);
//write debug server log statements to the DebugServer output channel
Expand Down
2 changes: 1 addition & 1 deletion src/managers/RemoteControlManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ export class RemoteControlManager {
}
}

export type RemoteControlModeInitiator = 'statusbar' | 'command';
export type RemoteControlModeInitiator = 'statusbar' | 'command' | 'launch';
34 changes: 18 additions & 16 deletions src/viewProviders/RokuAutomationViewViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,25 @@ export class RokuAutomationViewViewProvider extends BaseRdbViewProvider {
return Promise.resolve(true);
});

const config = this.rokuAutomationConfigs[index];
for (const [index, step] of config.steps.entries()) {
if (stopRunning) {
break;
}

this.updateCurrentRunningStep(index);
switch (step.type) {
case 'sleep':
await utils.sleep(+step.value * 1000);
break;
case 'sendText':
await ecp.sendText(step.value);
break;
case 'sendKeyPress':
await ecp.sendKeyPress(step.value as any);
const config = this.rokuAutomationConfigs?.[index];
if (config) {
for (const [index, step] of config.steps.entries()) {
if (stopRunning) {
break;
}

this.updateCurrentRunningStep(index);
switch (step.type) {
case 'sleep':
await utils.sleep(+step.value * 1000);
break;
case 'sendText':
await ecp.sendText(step.value);
break;
case 'sendKeyPress':
await ecp.sendKeyPress(step.value as any);
break;
}
}
}

Expand Down

0 comments on commit cc5db8a

Please sign in to comment.