Skip to content

Commit

Permalink
Reformat code to satisfy linter
Browse files Browse the repository at this point in the history
This patch was generated procedurally via the following command:

    $ ./node_modules/.bin/prettier --write lib/ test/
  • Loading branch information
jugglinmike committed Apr 1, 2024
1 parent fde47d5 commit 4e6bc1c
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 51 deletions.
1 change: 0 additions & 1 deletion lib/commands/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const MACOS_SYSTEM_DIR = '/usr/local/var/at_driver_generic';
const MACOS_SOCKET_UNIX_PATH = '/usr/local/var/at_driver_generic/driver.socket';
const DEFAULT_PORT = 4382;


/**
* Print logging information to the process's standard error stream, annotated
* with a timestamp describing the moment that the message was emitted.
Expand Down
8 changes: 4 additions & 4 deletions lib/install/macos.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

exports.install = async function() {
throw new Error('macos install not implemented');
exports.install = async function () {
throw new Error('macos install not implemented');
};

exports.uninstall = async function() {
throw new Error('macos uninstall not implemented');
exports.uninstall = async function () {
throw new Error('macos uninstall not implemented');
};
28 changes: 15 additions & 13 deletions lib/modules/macos/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@

const { v4: uuid } = require('uuid');

const newSession = /** @type {ATDriverModules.SessionNewSession} */ ((websocket, params) => {
// TODO: match requested capabilities
// const { capabilities } = params;
websocket.sessionId = uuid();
return {
sessionId: websocket.sessionId,
capabilities: {
atName: 'Voiceover',
atVersion: 'TODO',
platformName: 'macos',
},
};
});
const newSession = /** @type {ATDriverModules.SessionNewSession} */ (
(websocket, params) => {
// TODO: match requested capabilities
// const { capabilities } = params;
websocket.sessionId = uuid();
return {
sessionId: websocket.sessionId,
capabilities: {
atName: 'Voiceover',
atVersion: 'TODO',
platformName: 'macos',
},
};
}
);

module.exports = /** @type {ATDriverModules.Session} */ ({
'session.new': newSession,
Expand Down
34 changes: 18 additions & 16 deletions lib/modules/win32/interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,28 @@ const keyboardActionsMap = {

const keycodeMatch = /[\ue000-\ue05d]/;

const pressKeys = /** @type {ATDriverModules.InteractionPressKeys} */ ((websocket, { keys }) => {
const robotjsKeys = keys.map(key => {
if (keyboardActionsMap[key]) return keyboardActionsMap[key];
if (keycodeMatch.test(key))
throw new Error(`unknown key (\\u${key.charCodeAt(0).toString(16)})`);
const pressKeys = /** @type {ATDriverModules.InteractionPressKeys} */ (
(websocket, { keys }) => {
const robotjsKeys = keys.map(key => {
if (keyboardActionsMap[key]) return keyboardActionsMap[key];
if (keycodeMatch.test(key))
throw new Error(`unknown key (\\u${key.charCodeAt(0).toString(16)})`);

return key;
});
return key;
});

// keys = ['insert', 'tab'] means to press insert and tab together
// push all keys down in order then release them in reverse order
for (let x = 0; x < robotjsKeys.length; x++) {
robotjs.keyToggle(robotjsKeys[x], 'down');
}
// keys = ['insert', 'tab'] means to press insert and tab together
// push all keys down in order then release them in reverse order
for (let x = 0; x < robotjsKeys.length; x++) {
robotjs.keyToggle(robotjsKeys[x], 'down');
}

for (let x = robotjsKeys.length - 1; x >= 0; x--) {
robotjs.keyToggle(robotjsKeys[x], 'up');
for (let x = robotjsKeys.length - 1; x >= 0; x--) {
robotjs.keyToggle(robotjsKeys[x], 'up');
}
return {};
}
return {};
});
);

module.exports = /** @type {ATDriverModules.Interaction} */ ({
'interaction.pressKeys': pressKeys,
Expand Down
28 changes: 15 additions & 13 deletions lib/modules/win32/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
'use strict';
const { v4: uuid } = require('uuid');

const newSession = /** @type {ATDriverModules.SessionNewSession} */ ((websocket, params) => {
// TODO: match requested capabilities
// const { capabilities } = params;
websocket.sessionId = uuid();
return {
sessionId: websocket.sessionId,
capabilities: {
atName: 'TODO',
atVersion: 'TODO',
platformName: 'win32',
},
};
});
const newSession = /** @type {ATDriverModules.SessionNewSession} */ (
(websocket, params) => {
// TODO: match requested capabilities
// const { capabilities } = params;
websocket.sessionId = uuid();
return {
sessionId: websocket.sessionId,
capabilities: {
atName: 'TODO',
atVersion: 'TODO',
platformName: 'win32',
},
};
}
);

module.exports = /** @type {ATDriverModules.Session} */ ({
'session.new': newSession,
Expand Down
8 changes: 4 additions & 4 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ const net = require('net');

const WebSocket = require('ws');

const SOCKET_PATH = ({
win32: '\\\\?\\pipe\\my_pipe',
darwin: '/usr/local/var/at_driver_generic/driver.socket',
})[process.platform];
const SOCKET_PATH = {
win32: '\\\\?\\pipe\\my_pipe',
darwin: '/usr/local/var/at_driver_generic/driver.socket',
}[process.platform];

const executable = path.join(__dirname, '..', 'bin', 'at-driver');
const invert = promise =>
Expand Down

0 comments on commit 4e6bc1c

Please sign in to comment.