mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-25 11:46:06 +02:00
chore: adjust prettier config, .gitignore and use taplo to format toml files (#1728)
* chore: adjust prettier config, .gitignore and use taplo to format toml files This brings the plugins-workspace repository to the same code style of the main tauri repo * format toml * ignore examples gen dir * add .vscode/extensions.json * remove packageManager field * fmt * fix audit * taplo ignore permissions autogenerated files * remove create dummy dist * fix prettier workflow * install fmt in prettier workflow --------- Co-authored-by: Lucas Nogueira <lucas@tauri.app>
This commit is contained in:
@@ -2,57 +2,57 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import WebSocket from "tauri-plugin-websocket-api";
|
||||
import "./style.css";
|
||||
import WebSocket from 'tauri-plugin-websocket-api'
|
||||
import './style.css'
|
||||
|
||||
let ws: WebSocket;
|
||||
let ws: WebSocket
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
document.querySelector("#send")?.addEventListener("click", send);
|
||||
document.querySelector("#disconnect")?.addEventListener("click", disconnect);
|
||||
await connect();
|
||||
});
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
document.querySelector('#send')?.addEventListener('click', send)
|
||||
document.querySelector('#disconnect')?.addEventListener('click', disconnect)
|
||||
await connect()
|
||||
})
|
||||
|
||||
function _updateResponse(returnValue: unknown) {
|
||||
const msg = document.createElement("p");
|
||||
const msg = document.createElement('p')
|
||||
msg.textContent =
|
||||
typeof returnValue === "string" ? returnValue : JSON.stringify(returnValue);
|
||||
document.querySelector("#response-container")?.appendChild(msg);
|
||||
typeof returnValue === 'string' ? returnValue : JSON.stringify(returnValue)
|
||||
document.querySelector('#response-container')?.appendChild(msg)
|
||||
}
|
||||
|
||||
async function connect() {
|
||||
try {
|
||||
ws = await WebSocket.connect("ws://127.0.0.1:8080").then((r) => {
|
||||
_updateResponse("Connected");
|
||||
return r;
|
||||
});
|
||||
ws = await WebSocket.connect('ws://127.0.0.1:8080').then((r) => {
|
||||
_updateResponse('Connected')
|
||||
return r
|
||||
})
|
||||
} catch (e) {
|
||||
_updateResponse(e);
|
||||
_updateResponse(e)
|
||||
}
|
||||
ws.addListener(_updateResponse);
|
||||
ws.addListener(_updateResponse)
|
||||
}
|
||||
|
||||
function send() {
|
||||
ws.send(document.querySelector("#msg-input")?.textContent || "")
|
||||
ws.send(document.querySelector('#msg-input')?.textContent || '')
|
||||
.then(() => {
|
||||
_updateResponse("Message sent");
|
||||
_updateResponse('Message sent')
|
||||
})
|
||||
.catch(_updateResponse);
|
||||
.catch(_updateResponse)
|
||||
}
|
||||
|
||||
function disconnect() {
|
||||
ws.disconnect()
|
||||
.then(() => {
|
||||
_updateResponse("Disconnected");
|
||||
_updateResponse('Disconnected')
|
||||
})
|
||||
.catch(_updateResponse);
|
||||
.catch(_updateResponse)
|
||||
}
|
||||
|
||||
document.querySelector<HTMLDivElement>("#app")!.innerHTML = `
|
||||
document.querySelector<HTMLDivElement>('#app')!.innerHTML = `
|
||||
<div>
|
||||
<input type="text" />
|
||||
<button id="send">send</button>
|
||||
<button id="disconnect">disconnect</button>
|
||||
<div id="response-container"></div>
|
||||
</div>
|
||||
`;
|
||||
`
|
||||
|
||||
@@ -10,8 +10,8 @@ body {
|
||||
margin: 0;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
||||
Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
|
||||
Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
|
||||
Reference in New Issue
Block a user