From e3b9a6e5d8b477e9f7dcd73c313697b0d3cb7a04 Mon Sep 17 00:00:00 2001 From: Paul Tagliamonte Date: Wed, 22 May 2024 14:22:07 -0400 Subject: [PATCH] Port forward to ts-rs 8.1 (currently: git only; waiting for 8.1.1+) (#2443) Port forward to ts-rs 8.1 We're just waiting on a release that includes a PR that we sent[1] for this to use the cargo version. For now we'll have to use the git release. [1]: https://github.com/Aleph-Alpha/ts-rs/commit/c5109a00e4a4feb7b614d35ddca2590300bdfb67 --- src/components/ProjectSidebarMenu.test.tsx | 3 +++ src/lib/coredump.ts | 8 +++--- src/lib/routeLoaders.ts | 5 +++- src/lib/tauriFS.ts | 2 +- src/wasm-lib/Cargo.lock | 11 +++----- src/wasm-lib/kcl/Cargo.toml | 3 ++- src/wasm-lib/kcl/src/docs.rs | 29 ++++++++++++++-------- src/wasm-lib/kcl/src/std/kcl_stdlib.rs | 26 +++++++++++++------ 8 files changed, 56 insertions(+), 31 deletions(-) diff --git a/src/components/ProjectSidebarMenu.test.tsx b/src/components/ProjectSidebarMenu.test.tsx index 501235e61..fb59dfc60 100644 --- a/src/components/ProjectSidebarMenu.test.tsx +++ b/src/components/ProjectSidebarMenu.test.tsx @@ -21,6 +21,9 @@ const projectWellFormed = { created: now.toISOString(), modified: now.toISOString(), size: 32, + accessed: null, + type: null, + permission: null, }, kcl_file_count: 1, directory_count: 0, diff --git a/src/lib/coredump.ts b/src/lib/coredump.ts index 30c530a21..fbf6e263d 100644 --- a/src/lib/coredump.ts +++ b/src/lib/coredump.ts @@ -75,6 +75,7 @@ export class CoreDumpManager { const osinfo: OsInfo = { platform, arch, + browser: 'tauri', version: kernelVersion, } return JSON.stringify(osinfo) @@ -89,6 +90,7 @@ export class CoreDumpManager { platform: userAgent, arch: userAgent, version: userAgent, + browser: userAgent, } return new Promise((resolve) => resolve(JSON.stringify(osinfo))) } @@ -96,9 +98,9 @@ export class CoreDumpManager { const parser = new UAParser(userAgent) const parserResults = parser.getResult() const osinfo: OsInfo = { - platform: parserResults.os.name, - arch: parserResults.cpu.architecture, - version: parserResults.os.version, + platform: parserResults.os.name || userAgent, + arch: parserResults.cpu.architecture || userAgent, + version: parserResults.os.version || userAgent, browser: userAgent, } return new Promise((resolve) => resolve(JSON.stringify(osinfo))) diff --git a/src/lib/routeLoaders.ts b/src/lib/routeLoaders.ts index 0f11e9758..dcafbfb46 100644 --- a/src/lib/routeLoaders.ts +++ b/src/lib/routeLoaders.ts @@ -39,7 +39,9 @@ export const settingsLoader: LoaderFunction = async ({ ) if (projectPathData) { const { project_path } = projectPathData - const { settings: s } = await loadAndValidateSettings(project_path) + const { settings: s } = await loadAndValidateSettings( + project_path || undefined + ) settings = s } } @@ -118,6 +120,7 @@ export const fileLoader: LoaderFunction = async ({ children: [], kcl_file_count: 0, directory_count: 0, + metadata: null, default_file: project_path, }, file: { diff --git a/src/lib/tauriFS.ts b/src/lib/tauriFS.ts index 5f1366013..cc79e2517 100644 --- a/src/lib/tauriFS.ts +++ b/src/lib/tauriFS.ts @@ -45,7 +45,7 @@ export function sortProject(project: FileEntry[]): FileEntry[] { if ('children' in fileOrDir && fileOrDir.children !== undefined) { return { ...fileOrDir, - children: sortProject(fileOrDir.children), + children: sortProject(fileOrDir.children || []), } } else { return fileOrDir diff --git a/src/wasm-lib/Cargo.lock b/src/wasm-lib/Cargo.lock index 2ee436d93..7b92e1134 100644 --- a/src/wasm-lib/Cargo.lock +++ b/src/wasm-lib/Cargo.lock @@ -4390,9 +4390,8 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "ts-rs" -version = "7.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc2cae1fc5d05d47aa24b64f9a4f7cba24cdc9187a2084dd97ac57bef5eccae6" +version = "8.1.0" +source = "git+https://github.com/Aleph-Alpha/ts-rs#badbac08e61e65b312880aa64e9ece2976f1bbef" dependencies = [ "chrono", "thiserror", @@ -4403,11 +4402,9 @@ dependencies = [ [[package]] name = "ts-rs-macros" -version = "7.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f7f9b821696963053a89a7bd8b292dc34420aea8294d7b225274d488f3ec92" +version = "8.1.0" +source = "git+https://github.com/Aleph-Alpha/ts-rs#badbac08e61e65b312880aa64e9ece2976f1bbef" dependencies = [ - "Inflector", "proc-macro2", "quote", "syn 2.0.65", diff --git a/src/wasm-lib/kcl/Cargo.toml b/src/wasm-lib/kcl/Cargo.toml index e1d8fd19e..fc60cdb8b 100644 --- a/src/wasm-lib/kcl/Cargo.toml +++ b/src/wasm-lib/kcl/Cargo.toml @@ -38,7 +38,8 @@ serde_json = "1.0.116" sha2 = "0.10.8" thiserror = "1.0.61" toml = "0.8.13" -ts-rs = { version = "7.1.1", features = ["uuid-impl", "url-impl", "chrono-impl", "no-serde-warnings"] } +# TODO: change this to a cargo release once 8.1.1 comes out +ts-rs = { git = "https://github.com/Aleph-Alpha/ts-rs", features = ["uuid-impl", "url-impl", "chrono-impl", "no-serde-warnings"] } url = { version = "2.5.0", features = ["serde"] } uuid = { version = "1.8.0", features = ["v4", "js", "serde"] } validator = { version = "0.18.1", features = ["derive"] } diff --git a/src/wasm-lib/kcl/src/docs.rs b/src/wasm-lib/kcl/src/docs.rs index fc2ca51cc..daa621440 100644 --- a/src/wasm-lib/kcl/src/docs.rs +++ b/src/wasm-lib/kcl/src/docs.rs @@ -1,15 +1,15 @@ //! Functions for generating docs for our stdlib functions. +use crate::std::Primitive; use anyhow::Result; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use std::path::Path; use tower_lsp::lsp_types::{ CompletionItem, CompletionItemKind, CompletionItemLabelDetails, Documentation, InsertTextFormat, MarkupContent, MarkupKind, ParameterInformation, ParameterLabel, SignatureHelp, SignatureInformation, }; -use crate::std::Primitive; - #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, JsonSchema, ts_rs::TS)] #[ts(export)] #[serde(rename_all = "camelCase")] @@ -262,21 +262,30 @@ impl<'de> Deserialize<'de> for Box { } impl ts_rs::TS for dyn StdLibFn { - const EXPORT_TO: Option<&'static str> = Some("bindings/StdLibFnData"); + type WithoutGenerics = Self; fn name() -> String { "StdLibFnData".to_string() } - fn dependencies() -> Vec - where - Self: 'static, - { - StdLibFnData::dependencies() + fn decl() -> String { + StdLibFnData::decl() } - fn transparent() -> bool { - StdLibFnData::transparent() + fn decl_concrete() -> String { + StdLibFnData::decl_concrete() + } + + fn inline() -> String { + StdLibFnData::inline() + } + + fn inline_flattened() -> String { + StdLibFnData::inline_flattened() + } + + fn output_path() -> Option<&'static Path> { + StdLibFnData::output_path() } } diff --git a/src/wasm-lib/kcl/src/std/kcl_stdlib.rs b/src/wasm-lib/kcl/src/std/kcl_stdlib.rs index 1bd0e6867..21ef2f477 100644 --- a/src/wasm-lib/kcl/src/std/kcl_stdlib.rs +++ b/src/wasm-lib/kcl/src/std/kcl_stdlib.rs @@ -1,5 +1,6 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use std::path::Path; use crate::{ ast::types::{BodyItem, FunctionExpression, Program, Value}, @@ -17,21 +18,30 @@ pub trait KclStdLibFn: StdLibFn { } impl ts_rs::TS for dyn KclStdLibFn { - const EXPORT_TO: Option<&'static str> = Some("bindings/StdLibFnData"); + type WithoutGenerics = Self; fn name() -> String { "StdLibFnData".to_string() } - fn dependencies() -> Vec - where - Self: 'static, - { - StdLibFnData::dependencies() + fn decl() -> String { + StdLibFnData::decl() } - fn transparent() -> bool { - StdLibFnData::transparent() + fn decl_concrete() -> String { + StdLibFnData::decl_concrete() + } + + fn inline() -> String { + StdLibFnData::inline() + } + + fn inline_flattened() -> String { + StdLibFnData::inline_flattened() + } + + fn output_path() -> Option<&'static Path> { + StdLibFnData::output_path() } }