-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from C-Loftus/restoreSettingInExtension
IPC Refactor to support reenabling only the desired settings
- Loading branch information
Showing
8 changed files
with
310 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,56 @@ | ||
from typing import Literal | ||
import enum | ||
from typing import List, Literal, Any, TypedDict, Optional | ||
|
||
# Exhaustive list of commands that can be sent to the NVDA addon server | ||
|
||
IPC_COMMAND = Literal[ | ||
"disableSpeechInterruptForCharacters", | ||
"enableSpeechInterruptForCharacters", | ||
"getSpeechInterruptForCharacters", | ||
"disableSpeakTypedWords", | ||
"enableSpeakTypedWords", | ||
"getSpeakTypedWords", | ||
"disableSpeakTypedCharacters", | ||
"enableSpeakTypedCharacters", | ||
"getSpeakTypedCharacters", | ||
"debug", | ||
] | ||
|
||
|
||
class ServerSpec(TypedDict): | ||
address: str | ||
port: str | ||
valid_commands: List[IPC_COMMAND] | ||
|
||
|
||
class ServerStatusResult(enum.Enum): | ||
SUCCESS = "success" | ||
INTERNAL_SERVER_ERROR = "serverError" | ||
INVALID_COMMAND_ERROR = "commandError" | ||
RUNTIME_ERROR = "runtimeError" | ||
JSON_ENCODE_ERROR = "jsonEncodeError" | ||
|
||
@staticmethod | ||
def generate_from(value: str): | ||
for member in ServerStatusResult: | ||
if member.value == value: | ||
return member | ||
raise KeyError(f"Invalid status result: {value}") | ||
|
||
|
||
class IPCServerResponse(TypedDict): | ||
processedCommands: List[str] | ||
returnedValues: List[Any] | ||
statusResults: List[ServerStatusResult] | ||
|
||
|
||
class IPCClientResponse(enum.Enum): | ||
NO_RESPONSE = "noResponse" | ||
TIMED_OUT = "timedOut" | ||
GENERAL_ERROR = "generalError" | ||
SUCCESS = "success" | ||
|
||
|
||
class ResponseBundle(TypedDict): | ||
client: IPCClientResponse | ||
server: Optional[None | IPCServerResponse] |
Oops, something went wrong.