-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
alert users when fontStyle.conditional is undefined
Signed-off-by: pogi7 <aaronlevitt7@gmail.com>
- Loading branch information
Showing
5 changed files
with
160 additions
and
9 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
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,8 +1,43 @@ | ||
import { CommandDefinitions } from "../../../commands/src/commands"; | ||
import { vsCode } from "./vsState"; | ||
|
||
// With this wrapper, we will see typing errors if we try to send a malformed command | ||
export function postMessage<K extends keyof CommandDefinitions>(message: { command: K } & CommandDefinitions[K] ) { | ||
/** | ||
* Sends a message to the VSCode extension. With this wrapper, we will see typing errors if we try to send a malformed command | ||
* | ||
* @remarks | ||
* This function sends a message to the VSCode extension using the {@link vsCode.postMessage} method. | ||
* | ||
* @template K - The type of command key in the CommandDefinitions. | ||
* | ||
* @param message - The message object to be sent, including the command key and its associated payload. | ||
* | ||
* @returns void | ||
*/ | ||
export function postMessage<K extends keyof CommandDefinitions>( | ||
message: { command: K } & CommandDefinitions[K] | ||
) { | ||
// Send the message to the extension | ||
vsCode.postMessage(message); | ||
} | ||
} | ||
|
||
/** | ||
* Sends a message to the parent window or page that instantiates the component. | ||
* | ||
* @remarks | ||
* This method uses the {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent | dispatchEvent} to send the message. | ||
* | ||
* The data structure for the message is the {@link https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent | MessageEvent}. | ||
* | ||
* @template K - The type of command key in the CommandDefinitions. | ||
* | ||
* @param message - The message object to be sent, including the command key and its associated payload. | ||
* | ||
* @returns void | ||
*/ | ||
export function postParentMessage<K extends keyof CommandDefinitions>( | ||
message: { command: K } & CommandDefinitions[K] | ||
) { | ||
// Send the message to the extension | ||
const event = new MessageEvent("message", { data: message }); | ||
window.dispatchEvent(event); | ||
} |