-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
106 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,33 @@ | ||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
import './vscode-webview' | ||
let skslPath = ref('') | ||
// TODO: message type | ||
window.addEventListener('message', (event) => { | ||
const message = event.data | ||
skslPath.value = message | ||
}) | ||
function selectSkSL() { | ||
const vscode = acquireVsCodeApi() | ||
vscode.postMessage('Select SkSL') | ||
} | ||
</script> | ||
|
||
<template> | ||
<h1>SkSL Runner</h1> | ||
<div class="body"> | ||
<h1>SkSL Runner</h1> | ||
<button @click="selectSkSL()">Select SkSL</button> | ||
<span>{{ skslPath }}</span> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
.body { | ||
margin: 0 auto; | ||
max-width: 768px; | ||
} | ||
</style> |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// https://www.npmjs.com/package/@types/vscode-webview | ||
|
||
/** | ||
* API exposed to webviews. | ||
* | ||
* @template StateType Type of the persisted state stored for the webview. | ||
*/ | ||
export interface WebviewApi<StateType> { | ||
/** | ||
* Post a message to the owner of the webview. | ||
* | ||
* @param message Data to post. Must be JSON serializable. | ||
*/ | ||
postMessage(message: unknown): void | ||
|
||
/** | ||
* Get the persistent state stored for this webview. | ||
* | ||
* @return The current state or `undefined` if no state has been set. | ||
*/ | ||
getState(): StateType | undefined | ||
|
||
/** | ||
* Set the persistent state stored for this webview. | ||
* | ||
* @param newState New persisted state. This must be a JSON serializable object. Can be retrieved | ||
* using {@link getState}. | ||
* | ||
* @return The new state. | ||
*/ | ||
setState<T extends StateType | undefined>(newState: T): T | ||
} | ||
|
||
declare global { | ||
/** | ||
* Acquire an instance of the webview API. | ||
* | ||
* This may only be called once in a webview's context. Attempting to call `acquireVsCodeApi` after it has already | ||
* been called will throw an exception. | ||
* | ||
* @template StateType Type of the persisted state stored for the webview. | ||
*/ | ||
function acquireVsCodeApi<StateType = unknown>(): WebviewApi<StateType> | ||
} |
Empty file.