-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(updater): Use escaped installer path to start the nsis updater (#…
…727) Port of v1 change: tauri-apps/tauri#7956 Committed via a GitHub action: https://github.com/tauri-apps/plugins-workspace/actions/runs/6877612128 Co-authored-by: amrbashir <[email protected]>
- Loading branch information
Showing
10 changed files
with
72 additions
and
181 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
'use strict'; | ||
|
||
var primitives = require('@tauri-apps/api/primitives'); | ||
|
||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: MIT | ||
class WebSocket { | ||
constructor(id, listeners) { | ||
this.id = id; | ||
this.listeners = listeners; | ||
} | ||
static async connect(url, config) { | ||
const listeners = []; | ||
const onMessage = new primitives.Channel(); | ||
onMessage.onmessage = (message) => { | ||
listeners.forEach((l) => l(message)); | ||
}; | ||
if (config?.headers) { | ||
config.headers = Array.from(new Headers(config.headers).entries()); | ||
} | ||
return await primitives.invoke("plugin:websocket|connect", { | ||
url, | ||
onMessage, | ||
config, | ||
}).then((id) => new WebSocket(id, listeners)); | ||
} | ||
addListener(cb) { | ||
this.listeners.push(cb); | ||
} | ||
async send(message) { | ||
let m; | ||
if (typeof message === "string") { | ||
m = { type: "Text", data: message }; | ||
} | ||
else if (typeof message === "object" && "type" in message) { | ||
m = message; | ||
} | ||
else if (Array.isArray(message)) { | ||
m = { type: "Binary", data: message }; | ||
} | ||
else { | ||
throw new Error("invalid `message` type, expected a `{ type: string, data: any }` object, a string or a numeric array"); | ||
} | ||
return await primitives.invoke("plugin:websocket|send", { | ||
id: this.id, | ||
message: m, | ||
}); | ||
} | ||
async disconnect() { | ||
return await this.send({ | ||
type: "Close", | ||
data: { | ||
code: 1000, | ||
reason: "Disconnected by client", | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
module.exports = WebSocket; |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.