Skip to content
This repository was archived by the owner on Feb 16, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,25 @@ function onReady () {
app.quit();
break;

case consts.eventNames.appExecuteJavaScript:
(async function () {
let evalAsync = (ev, json) => {
return new Promise((resolve, reject) => {
eval(ev);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eval code will have access to resolve and reject here ?

});
};
try {
client.write(json.targetID, consts.eventNames.appExecuteJavaScriptCallback, {
reply: await evalAsync(json.code, json)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename reply to success?

});
} catch (error) {
client.write(json.targetID, consts.eventNames.appExecuteJavaScriptCallback, {
error: error.toString()
});
}
}());
break;

// Dock
case consts.eventNames.dockCmdBounce:
let id = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module.exports = {
appCmdQuit: "app.cmd.quit",
appEventReady: "app.event.ready",
appEventSecondInstance: "app.event.second.instance",
appExecuteJavaScript: "app.execute.javascript",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename that to appCmdExecuteJavascript: "app.cmd.execute.javascript"?

appExecuteJavaScriptCallback: "app.execute.javascript.callback",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename that to appEventExecutedJavascript: "app.event.executed.javascript"?

displayEventAdded: "display.event.added",
displayEventMetricsChanged: "display.event.metrics.changed",
displayEventRemoved: "display.event.removed",
Expand Down