Skip to content

Commit

Permalink
Update messages
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob committed Feb 9, 2024
1 parent f3fb509 commit fe540f6
Showing 1 changed file with 52 additions and 43 deletions.
95 changes: 52 additions & 43 deletions src/external_app/external_messaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,20 @@ interface EMOutgoingMessageConfigGet extends EMMessage {
type: "config/get";
}

interface EMOutgoingMessageScanBarCode extends EMMessage {
interface EMOutgoingMessageStartBarCodeScan extends EMMessage {
type: "bar_code/scan";
title: string;
description: string;
alternative_option_label?: string;
}

interface EMOutgoingMessageStopBarCodeScan extends EMMessage {
type: "bar_code/close";
title: string;
description: string;
alternative_option_label?: string;
}

interface EMOutgoingMessageMatterCommission extends EMMessage {
type: "matter/commission";
}
Expand All @@ -55,13 +62,6 @@ type EMOutgoingMessageWithAnswer = {
request: EMOutgoingMessageConfigGet;
response: ExternalConfig;
};
"bar_code/scan": {
request: EMOutgoingMessageScanBarCode;
response:
| EMIncomingMessageBarCodeResponseCanceled
| EMIncomingMessageBarCodeResponseAlternativeOptions
| EMIncomingMessageBarCodeResponseScanResult;
};
};

interface EMOutgoingMessageExoplayerPlayHLS extends EMMessage {
Expand Down Expand Up @@ -124,20 +124,22 @@ interface EMOutgoingMessageAssistShow extends EMMessage {
}

type EMOutgoingMessageWithoutAnswer =
| EMOutgoingMessageHaptic
| EMOutgoingMessageConnectionStatus
| EMMessageResultError
| EMMessageResultSuccess
| EMOutgoingMessageAppConfiguration
| EMOutgoingMessageTagWrite
| EMOutgoingMessageSidebarShow
| EMOutgoingMessageAssistShow
| EMOutgoingMessageConnectionStatus
| EMOutgoingMessageExoplayerPlayHLS
| EMOutgoingMessageExoplayerResize
| EMOutgoingMessageExoplayerStop
| EMOutgoingMessageThemeUpdate
| EMMessageResultSuccess
| EMMessageResultError
| EMOutgoingMessageHaptic
| EMOutgoingMessageImportThreadCredentials
| EMOutgoingMessageMatterCommission
| EMOutgoingMessageImportThreadCredentials;
| EMOutgoingMessageSidebarShow
| EMOutgoingMessageStartBarCodeScan
| EMOutgoingMessageStopBarCodeScan
| EMOutgoingMessageTagWrite
| EMOutgoingMessageThemeUpdate;

interface EMIncomingMessageRestart {
id: number;
Expand Down Expand Up @@ -172,42 +174,49 @@ interface EMIncomingMessageShowAutomationEditor {
};
}

export interface EMIncomingMessageBarCodeResponseCanceled {
action: "canceled";
}

export interface EMIncomingMessageBarCodeResponseAlternativeOptions {
action: "alternative_options";
export interface EMIncomingMessageBarCodeScanResult {
id: number;
type: "command";
command: "bar_code/scan_result";
payload: {
// A string decoded from the barcode data.
rawValue: string;
// https://developer.mozilla.org/en-US/docs/Web/API/Barcode_Detection_API#supported_barcode_formats
format:
| "aztec"
| "code_128"
| "code_39"
| "code_93"
| "codabar"
| "data_matrix"
| "ean_13"
| "ean_8"
| "itf"
| "pdf417"
| "qr_code"
| "upc_a"
| "upc_e"
| "unknown";
};
}

export interface EMIncomingMessageBarCodeResponseScanResult {
action: "scan_result";
// A string decoded from the barcode data.
rawValue: string;
// https://developer.mozilla.org/en-US/docs/Web/API/Barcode_Detection_API#supported_barcode_formats
format:
| "aztec"
| "code_128"
| "code_39"
| "code_93"
| "codabar"
| "data_matrix"
| "ean_13"
| "ean_8"
| "itf"
| "pdf417"
| "qr_code"
| "upc_a"
| "upc_e"
| "unknown";
export interface EMIncomingMessageBarCodeScanAborted {
id: number;
type: "command";
command: "bar_code/aborted";
payload: {
reason: "canceled" | "alternative_options";
};
}

export type EMIncomingMessageCommands =
| EMIncomingMessageRestart
| EMIncomingMessageShowNotifications
| EMIncomingMessageToggleSidebar
| EMIncomingMessageShowSidebar
| EMIncomingMessageShowAutomationEditor;
| EMIncomingMessageShowAutomationEditor
| EMIncomingMessageBarCodeScanResult
| EMIncomingMessageBarCodeScanAborted;

type EMIncomingMessage =
| EMMessageResultSuccess
Expand Down

0 comments on commit fe540f6

Please sign in to comment.