added websocket
This commit is contained in:
parent
4b20d20783
commit
8b1c30a746
@ -19,6 +19,7 @@
|
|||||||
"@tauri-apps/plugin-dialog": "~2",
|
"@tauri-apps/plugin-dialog": "~2",
|
||||||
"@tauri-apps/plugin-fs": "~2",
|
"@tauri-apps/plugin-fs": "~2",
|
||||||
"@tauri-apps/plugin-opener": "^2",
|
"@tauri-apps/plugin-opener": "^2",
|
||||||
|
"@tauri-apps/plugin-websocket": "~2",
|
||||||
"async-mutex": "^0.5.0",
|
"async-mutex": "^0.5.0",
|
||||||
"flowbite-svelte": "^0.47.4",
|
"flowbite-svelte": "^0.47.4",
|
||||||
"flowbite-svelte-icons": "^2.0.2",
|
"flowbite-svelte-icons": "^2.0.2",
|
||||||
|
|||||||
73
src-tauri/Cargo.lock
generated
73
src-tauri/Cargo.lock
generated
@ -1011,6 +1011,12 @@ version = "0.3.7"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "04d2cd9c18b9f454ed67da600630b021a8a80bf33f8c95896ab33aaf1c26b728"
|
checksum = "04d2cd9c18b9f454ed67da600630b021a8a80bf33f8c95896ab33aaf1c26b728"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "data-encoding"
|
||||||
|
version = "2.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "575f75dfd25738df5b91b8e43e14d44bda14637a58fae779fd2b064f8bf3e010"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "datasize"
|
name = "datasize"
|
||||||
version = "0.2.15"
|
version = "0.2.15"
|
||||||
@ -3696,6 +3702,7 @@ dependencies = [
|
|||||||
"tauri-plugin-dialog",
|
"tauri-plugin-dialog",
|
||||||
"tauri-plugin-fs",
|
"tauri-plugin-fs",
|
||||||
"tauri-plugin-opener",
|
"tauri-plugin-opener",
|
||||||
|
"tauri-plugin-websocket",
|
||||||
"uuid",
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -4813,6 +4820,17 @@ dependencies = [
|
|||||||
"stable_deref_trait",
|
"stable_deref_trait",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sha1"
|
||||||
|
version = "0.10.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"cpufeatures",
|
||||||
|
"digest",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sha2"
|
name = "sha2"
|
||||||
version = "0.10.8"
|
version = "0.10.8"
|
||||||
@ -5352,6 +5370,25 @@ dependencies = [
|
|||||||
"zbus",
|
"zbus",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tauri-plugin-websocket"
|
||||||
|
version = "2.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "af3ac71aec5fb0ae5441e830cd075b1cbed49ac3d39cb975a4894ea8fa2e62b9"
|
||||||
|
dependencies = [
|
||||||
|
"futures-util",
|
||||||
|
"http",
|
||||||
|
"log",
|
||||||
|
"rand 0.8.5",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"tauri",
|
||||||
|
"tauri-plugin",
|
||||||
|
"thiserror 2.0.11",
|
||||||
|
"tokio",
|
||||||
|
"tokio-tungstenite",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-runtime"
|
name = "tauri-runtime"
|
||||||
version = "2.3.0"
|
version = "2.3.0"
|
||||||
@ -5609,6 +5646,22 @@ dependencies = [
|
|||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tokio-tungstenite"
|
||||||
|
version = "0.26.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "be4bf6fecd69fcdede0ec680aaf474cdab988f9de6bc73d3758f0160e3b7025a"
|
||||||
|
dependencies = [
|
||||||
|
"futures-util",
|
||||||
|
"log",
|
||||||
|
"rustls",
|
||||||
|
"rustls-pki-types",
|
||||||
|
"tokio",
|
||||||
|
"tokio-rustls",
|
||||||
|
"tungstenite",
|
||||||
|
"webpki-roots",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-util"
|
name = "tokio-util"
|
||||||
version = "0.7.13"
|
version = "0.7.13"
|
||||||
@ -5777,6 +5830,26 @@ version = "0.2.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tungstenite"
|
||||||
|
version = "0.26.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "413083a99c579593656008130e29255e54dcaae495be556cc26888f211648c24"
|
||||||
|
dependencies = [
|
||||||
|
"byteorder",
|
||||||
|
"bytes",
|
||||||
|
"data-encoding",
|
||||||
|
"http",
|
||||||
|
"httparse",
|
||||||
|
"log",
|
||||||
|
"rand 0.8.5",
|
||||||
|
"rustls",
|
||||||
|
"rustls-pki-types",
|
||||||
|
"sha1",
|
||||||
|
"thiserror 2.0.11",
|
||||||
|
"utf-8",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tuple"
|
name = "tuple"
|
||||||
version = "0.5.2"
|
version = "0.5.2"
|
||||||
|
|||||||
@ -34,3 +34,4 @@ image = { version = "0.25.5", features = ["jpeg"] }
|
|||||||
pdf_render = { path = "../../pdf-render/render" }
|
pdf_render = { path = "../../pdf-render/render" }
|
||||||
pathfinder_rasterize = { git = "https://github.com/s3bk/pathfinder_rasterizer" }
|
pathfinder_rasterize = { git = "https://github.com/s3bk/pathfinder_rasterizer" }
|
||||||
pathfinder_geometry = { git = "https://github.com/servo/pathfinder" }
|
pathfinder_geometry = { git = "https://github.com/servo/pathfinder" }
|
||||||
|
tauri-plugin-websocket = "2"
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
"core:window:allow-close",
|
"core:window:allow-close",
|
||||||
"core:window:allow-minimize",
|
"core:window:allow-minimize",
|
||||||
"core:window:allow-toggle-maximize",
|
"core:window:allow-toggle-maximize",
|
||||||
"core:window:allow-internal-toggle-maximize"
|
"core:window:allow-internal-toggle-maximize",
|
||||||
|
"websocket:default"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -229,7 +229,11 @@ fn encode_b64(img: RgbImage) -> Result<String, String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
async fn get_stream_data_as_image(id: &str, path: &str, session: State<'_, Session>,) -> Result<String, String> {
|
async fn get_stream_data_as_image(
|
||||||
|
id: &str,
|
||||||
|
path: &str,
|
||||||
|
session: State<'_, Session>,
|
||||||
|
) -> Result<String, String> {
|
||||||
use base64::prelude::*;
|
use base64::prelude::*;
|
||||||
|
|
||||||
let file = session.get_file(id)?;
|
let file = session.get_file(id)?;
|
||||||
@ -238,7 +242,11 @@ async fn get_stream_data_as_image(id: &str, path: &str, session: State<'_, Sessi
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
async fn get_page_by_num(id: &str, num: u32, session: State<'_, Session>) -> Result<String, String> {
|
async fn get_page_by_num(
|
||||||
|
id: &str,
|
||||||
|
num: u32,
|
||||||
|
session: State<'_, Session>,
|
||||||
|
) -> Result<String, String> {
|
||||||
let file = session.get_file(id)?;
|
let file = session.get_file(id)?;
|
||||||
let mut renderer = Renderer::new(&file.cos_file, 150);
|
let mut renderer = Renderer::new(&file.cos_file, 150);
|
||||||
let img = renderer.render(num)?;
|
let img = renderer.render(num)?;
|
||||||
@ -762,6 +770,7 @@ impl Session {
|
|||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
|
.plugin(tauri_plugin_websocket::init())
|
||||||
.plugin(tauri_plugin_dialog::init())
|
.plugin(tauri_plugin_dialog::init())
|
||||||
.plugin(tauri_plugin_fs::init())
|
.plugin(tauri_plugin_fs::init())
|
||||||
.plugin(tauri_plugin_opener::init())
|
.plugin(tauri_plugin_opener::init())
|
||||||
|
|||||||
@ -6,8 +6,8 @@
|
|||||||
import StreamDataView from "./StreamDataView.svelte";
|
import StreamDataView from "./StreamDataView.svelte";
|
||||||
|
|
||||||
const cellH = 29;
|
const cellH = 29;
|
||||||
const headerOffset = 0;
|
const headerOffset = 24;
|
||||||
let {fState, height}: { fState: FileViewState; height: number } =
|
let { fState, height }: { fState: FileViewState; height: number } =
|
||||||
$props();
|
$props();
|
||||||
let fillerHeight: number = $state(0);
|
let fillerHeight: number = $state(0);
|
||||||
let firstEntry = $state(0);
|
let firstEntry = $state(0);
|
||||||
@ -19,8 +19,10 @@
|
|||||||
);
|
);
|
||||||
let tableHeight = $derived(prim ? prim.children.length * cellH : 0);
|
let tableHeight = $derived(prim ? prim.children.length * cellH : 0);
|
||||||
|
|
||||||
let bodyHeight = $derived(height - headerOffset);
|
let bodyHeight = $derived(height);
|
||||||
let editorHeight = $derived(Math.max(800, bodyHeight - tableHeight));
|
let editorHeight = $derived(
|
||||||
|
Math.max(800, bodyHeight - tableHeight - headerOffset),
|
||||||
|
);
|
||||||
|
|
||||||
let locallySelected: Primitive | undefined = $state(undefined);
|
let locallySelected: Primitive | undefined = $state(undefined);
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
@ -50,46 +52,48 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if prim && prim.children && prim.children.length > 0}
|
{#if prim && prim.children && prim.children.length > 0}
|
||||||
<div class="overflow-auto" onscroll={handleScroll}
|
<div
|
||||||
style="height: {bodyHeight}px">
|
class="overflow-auto"
|
||||||
|
onscroll={handleScroll}
|
||||||
|
style="height: {bodyHeight}px"
|
||||||
|
>
|
||||||
<div class="w-[851px]">
|
<div class="w-[851px]">
|
||||||
<table style="position: relative; top: {scrollY}px">
|
<table style="position: relative; top: {scrollY}px">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="page-cell t-header border-forge-prim">Key</td>
|
<td class="page-cell t-header border-forge-prim">Key</td
|
||||||
<td class="ref-cell t-header border-forge-prim">Type</td>
|
>
|
||||||
<td class="cell t-header border-forge-sec">Value</td>
|
<td class="ref-cell t-header border-forge-prim">Type</td
|
||||||
</tr>
|
>
|
||||||
|
<td class="cell t-header border-forge-sec">Value</td>
|
||||||
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
</table>
|
</table>
|
||||||
<div class="container" style="height: {tableHeight}px">
|
<div class="container" style="height: {tableHeight}px">
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr class="filler" style="height: {fillerHeight}px"
|
<tr class="filler" style="height: {fillerHeight}px"
|
||||||
></tr>
|
></tr>
|
||||||
{#each entriesToDisplay as entry}
|
{#each entriesToDisplay as entry}
|
||||||
<tr
|
<tr
|
||||||
class:selected={entry.key === locallySelected?.key}
|
class:selected={entry.key ===
|
||||||
|
locallySelected?.key}
|
||||||
class="row"
|
class="row"
|
||||||
onclick={() => handlePrimClick(entry)}
|
onclick={() => handlePrimClick(entry)}
|
||||||
ondblclick={() => handlePrimDbLClick(entry)}
|
ondblclick={() => handlePrimDbLClick(entry)}
|
||||||
>
|
|
||||||
<td class="page-cell t-data">
|
|
||||||
<div class="key-field">
|
|
||||||
<PrimitiveIcon
|
|
||||||
ptype={entry.ptype}
|
|
||||||
/>
|
|
||||||
<p class="text-left">
|
|
||||||
{entry.key}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td class="ref-cell t-data"
|
|
||||||
>{entry.ptype}</td
|
|
||||||
>
|
>
|
||||||
<td class="cell t-data">{entry.value}</td>
|
<td class="page-cell t-data">
|
||||||
</tr>
|
<div class="key-field">
|
||||||
{/each}
|
<PrimitiveIcon ptype={entry.ptype} />
|
||||||
|
<p class="text-left">
|
||||||
|
{entry.key}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="ref-cell t-data">{entry.ptype}</td>
|
||||||
|
<td class="cell t-data">{entry.value}</td>
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -122,7 +122,7 @@
|
|||||||
? formatFileName(fState.file.name)
|
? formatFileName(fState.file.name)
|
||||||
: "Select File"}</span
|
: "Select File"}</span
|
||||||
>
|
>
|
||||||
<CaretDownOutline class="ml-1" size="xs" />
|
<CaretDownOutline class="ml-1 text-forge-text_sec" size="sm" />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{#if dropdownVisible}
|
{#if dropdownVisible}
|
||||||
|
|||||||
@ -515,6 +515,13 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@tauri-apps/api" "^2.0.0"
|
"@tauri-apps/api" "^2.0.0"
|
||||||
|
|
||||||
|
"@tauri-apps/plugin-websocket@~2":
|
||||||
|
version "2.3.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@tauri-apps/plugin-websocket/-/plugin-websocket-2.3.0.tgz#7b7c69db52828aee8ad0efd3cbd684f593ef7e07"
|
||||||
|
integrity sha512-eAwRGe3tnqDeQYE0wq4g1PUKbam9tYvlC4uP/au12Y/z7MP4lrS4ylv+aoZ5Ly+hTlBdi7hDkhHomwF/UeBesA==
|
||||||
|
dependencies:
|
||||||
|
"@tauri-apps/api" "^2.0.0"
|
||||||
|
|
||||||
"@types/cookie@^0.6.0":
|
"@types/cookie@^0.6.0":
|
||||||
version "0.6.0"
|
version "0.6.0"
|
||||||
resolved "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz"
|
resolved "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user