fix export types (#271)
* fix export types Signed-off-by: Jess Frazelle <github@jessfraz.com> * update kittycad lib * fix wasm Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch>
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
"@fortawesome/free-solid-svg-icons": "^6.4.2",
|
"@fortawesome/free-solid-svg-icons": "^6.4.2",
|
||||||
"@fortawesome/react-fontawesome": "^0.2.0",
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
||||||
"@headlessui/react": "^1.7.13",
|
"@headlessui/react": "^1.7.13",
|
||||||
"@kittycad/lib": "^0.0.27",
|
"@kittycad/lib": "^0.0.28",
|
||||||
"@react-hook/resize-observer": "^1.2.6",
|
"@react-hook/resize-observer": "^1.2.6",
|
||||||
"@tauri-apps/api": "^1.3.0",
|
"@tauri-apps/api": "^1.3.0",
|
||||||
"@testing-library/jest-dom": "^5.14.1",
|
"@testing-library/jest-dom": "^5.14.1",
|
||||||
|
@ -409,7 +409,6 @@ export function App() {
|
|||||||
window: { x, y },
|
window: { x, y },
|
||||||
},
|
},
|
||||||
cmd_id: newCmdId,
|
cmd_id: newCmdId,
|
||||||
file_id: fileId,
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
debounceSocketSend({
|
debounceSocketSend({
|
||||||
@ -419,7 +418,6 @@ export function App() {
|
|||||||
selected_at_window: { x, y },
|
selected_at_window: { x, y },
|
||||||
},
|
},
|
||||||
cmd_id: newCmdId,
|
cmd_id: newCmdId,
|
||||||
file_id: fileId,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import { ActionButton } from '../components/ActionButton'
|
|||||||
import { faCheck } from '@fortawesome/free-solid-svg-icons'
|
import { faCheck } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
||||||
type SketchModeCmd = Extract<
|
type SketchModeCmd = Extract<
|
||||||
EngineCommand['cmd'],
|
Extract<EngineCommand, { type: 'modeling_cmd_req' }>['cmd'],
|
||||||
{ type: 'default_camera_enable_sketch_mode' }
|
{ type: 'default_camera_enable_sketch_mode' }
|
||||||
>
|
>
|
||||||
|
|
||||||
@ -22,6 +22,7 @@ export const DebugPanel = ({ className, ...props }: CollapsiblePanelProps) => {
|
|||||||
y_axis: { x: 0, y: 1, z: 0 },
|
y_axis: { x: 0, y: 1, z: 0 },
|
||||||
distance_to_plane: 100,
|
distance_to_plane: 100,
|
||||||
ortho: true,
|
ortho: true,
|
||||||
|
animated: true, // TODO #273 get prefers reduced motion from CSS
|
||||||
})
|
})
|
||||||
if (!sketchModeCmd) return null
|
if (!sketchModeCmd) return null
|
||||||
return (
|
return (
|
||||||
@ -79,7 +80,6 @@ export const DebugPanel = ({ className, ...props }: CollapsiblePanelProps) => {
|
|||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd: sketchModeCmd,
|
cmd: sketchModeCmd,
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
file_id: uuidv4(),
|
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
className="hover:border-succeed-50"
|
className="hover:border-succeed-50"
|
||||||
|
@ -76,7 +76,6 @@ export const ExportButton = ({ children, className }: ExportButtonProps) => {
|
|||||||
format: values,
|
format: values,
|
||||||
},
|
},
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
file_id: uuidv4(),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
closeModal()
|
closeModal()
|
||||||
|
@ -79,7 +79,6 @@ export const Stream = ({ className = '' }) => {
|
|||||||
window: { x, y },
|
window: { x, y },
|
||||||
},
|
},
|
||||||
cmd_id: newId,
|
cmd_id: newId,
|
||||||
file_id: fileId,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
setIsMouseDownInStream(true)
|
setIsMouseDownInStream(true)
|
||||||
@ -100,7 +99,6 @@ export const Stream = ({ className = '' }) => {
|
|||||||
window: { x: 0, y: zoom + e.deltaY },
|
window: { x: 0, y: zoom + e.deltaY },
|
||||||
},
|
},
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
file_id: uuidv4(),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
setZoom(zoom + e.deltaY)
|
setZoom(zoom + e.deltaY)
|
||||||
@ -130,7 +128,6 @@ export const Stream = ({ className = '' }) => {
|
|||||||
window: { x, y },
|
window: { x, y },
|
||||||
},
|
},
|
||||||
cmd_id: newCmdId,
|
cmd_id: newCmdId,
|
||||||
file_id: fileId,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
setIsMouseDownInStream(false)
|
setIsMouseDownInStream(false)
|
||||||
@ -143,7 +140,6 @@ export const Stream = ({ className = '' }) => {
|
|||||||
selected_at_window: { x, y },
|
selected_at_window: { x, y },
|
||||||
},
|
},
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
file_id: fileId,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
setDidDragInStream(false)
|
setDidDragInStream(false)
|
||||||
|
@ -32,15 +32,11 @@ interface CursorSelectionsArgs {
|
|||||||
idBasedSelections: { type: string; id: string }[]
|
idBasedSelections: { type: string; id: string }[]
|
||||||
}
|
}
|
||||||
|
|
||||||
type _EngineCommand = Models['ModelingCmdReq_type']
|
export type EngineCommand = Models['WebSocketMessages_type']
|
||||||
|
|
||||||
// TODO extending this type to add the type property is a work around
|
type OkResponse = Models['OkModelingCmdResponse_type']
|
||||||
// see https://github.com/KittyCAD/api-deux/issues/1096
|
|
||||||
export interface EngineCommand extends _EngineCommand {
|
|
||||||
type: 'modeling_cmd_req'
|
|
||||||
}
|
|
||||||
|
|
||||||
type WSResponse = Models['OkModelingCmdResponse_type']
|
type WebSocketResponse = Models['WebSocketResponses_type']
|
||||||
|
|
||||||
export class EngineCommandManager {
|
export class EngineCommandManager {
|
||||||
artifactMap: ArtifactMap = {}
|
artifactMap: ArtifactMap = {}
|
||||||
@ -113,13 +109,19 @@ export class EngineCommandManager {
|
|||||||
) {
|
) {
|
||||||
console.warn('something went wrong: ', event.data)
|
console.warn('something went wrong: ', event.data)
|
||||||
} else {
|
} else {
|
||||||
const message = JSON.parse(event.data)
|
const message: WebSocketResponse = JSON.parse(event.data)
|
||||||
if (message.type === 'sdp_answer') {
|
if (
|
||||||
|
message.type === 'sdp_answer' &&
|
||||||
|
message.answer.type !== 'unspecified'
|
||||||
|
) {
|
||||||
this.pc?.setRemoteDescription(
|
this.pc?.setRemoteDescription(
|
||||||
new RTCSessionDescription(message.answer)
|
new RTCSessionDescription({
|
||||||
|
type: message.answer.type,
|
||||||
|
sdp: message.answer.sdp,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
} else if (message.type === 'trickle_ice') {
|
} else if (message.type === 'trickle_ice') {
|
||||||
this.pc?.addIceCandidate(message.candidate)
|
this.pc?.addIceCandidate(message.candidate as RTCIceCandidateInit)
|
||||||
} else if (message.type === 'ice_server_info' && this.pc) {
|
} else if (message.type === 'ice_server_info' && this.pc) {
|
||||||
console.log('received ice_server_info')
|
console.log('received ice_server_info')
|
||||||
if (message.ice_servers.length > 0) {
|
if (message.ice_servers.length > 0) {
|
||||||
@ -193,7 +195,7 @@ export class EngineCommandManager {
|
|||||||
console.log('lossy data channel error')
|
console.log('lossy data channel error')
|
||||||
})
|
})
|
||||||
this.lossyDataChannel.addEventListener('message', (event) => {
|
this.lossyDataChannel.addEventListener('message', (event) => {
|
||||||
const result: WSResponse = JSON.parse(event.data)
|
const result: OkResponse = JSON.parse(event.data)
|
||||||
if (
|
if (
|
||||||
result.type === 'highlight_set_entity' &&
|
result.type === 'highlight_set_entity' &&
|
||||||
result.sequence &&
|
result.sequence &&
|
||||||
@ -204,11 +206,11 @@ export class EngineCommandManager {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else if (message.cmd_id) {
|
} else if (message.type === 'modeling') {
|
||||||
const id = message.cmd_id
|
const id = message.cmd_id
|
||||||
const command = this.artifactMap[id]
|
const command = this.artifactMap[id]
|
||||||
if (message?.result?.ok) {
|
if ('ok' in message.result) {
|
||||||
const result: WSResponse = message.result.ok
|
const result: OkResponse = message.result.ok
|
||||||
if (result.type === 'select_with_point') {
|
if (result.type === 'select_with_point') {
|
||||||
if (result.entity_id) {
|
if (result.entity_id) {
|
||||||
this.onClickCallback({
|
this.onClickCallback({
|
||||||
@ -280,7 +282,6 @@ export class EngineCommandManager {
|
|||||||
type: 'select_clear',
|
type: 'select_clear',
|
||||||
},
|
},
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
file_id: uuidv4(),
|
|
||||||
})
|
})
|
||||||
this.sendSceneCommand({
|
this.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
@ -289,7 +290,6 @@ export class EngineCommandManager {
|
|||||||
entities: selections.idBasedSelections.map((s) => s.id),
|
entities: selections.idBasedSelections.map((s) => s.id),
|
||||||
},
|
},
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
file_id: uuidv4(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
sendSceneCommand(command: EngineCommand) {
|
sendSceneCommand(command: EngineCommand) {
|
||||||
@ -297,6 +297,7 @@ export class EngineCommandManager {
|
|||||||
console.log('socket not ready')
|
console.log('socket not ready')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (command.type !== 'modeling_cmd_req') return
|
||||||
const cmd = command.cmd
|
const cmd = command.cmd
|
||||||
if (cmd.type === 'camera_drag_move' && this.lossyDataChannel) {
|
if (cmd.type === 'camera_drag_move' && this.lossyDataChannel) {
|
||||||
cmd.sequence = this.outSequence
|
cmd.sequence = this.outSequence
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { v4 as uuidv4 } from 'uuid'
|
|
||||||
import { InternalFn } from './stdTypes'
|
import { InternalFn } from './stdTypes'
|
||||||
import {
|
import {
|
||||||
ExtrudeGroup,
|
ExtrudeGroup,
|
||||||
@ -49,7 +48,6 @@ export const extrude: InternalFn = (
|
|||||||
cap: true,
|
cap: true,
|
||||||
},
|
},
|
||||||
cmd_id: id,
|
cmd_id: id,
|
||||||
file_id: uuidv4(),
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import {
|
|||||||
import { GuiModes, toolTips, TooTip } from '../../useStore'
|
import { GuiModes, toolTips, TooTip } from '../../useStore'
|
||||||
import { splitPathAtPipeExpression } from '../modifyAst'
|
import { splitPathAtPipeExpression } from '../modifyAst'
|
||||||
import { generateUuidFromHashSeed } from '../../lib/uuid'
|
import { generateUuidFromHashSeed } from '../../lib/uuid'
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
SketchLineHelper,
|
SketchLineHelper,
|
||||||
@ -282,7 +281,6 @@ export const line: SketchLineHelper = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
cmd_id: id,
|
cmd_id: id,
|
||||||
file_id: uuidv4(),
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const currentPath: Path = {
|
const currentPath: Path = {
|
||||||
@ -1575,7 +1573,6 @@ export const close: InternalFn = (
|
|||||||
path_id: sketchGroup.id,
|
path_id: sketchGroup.id,
|
||||||
},
|
},
|
||||||
cmd_id: id,
|
cmd_id: id,
|
||||||
file_id: uuidv4(),
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -1639,7 +1636,6 @@ export const startSketchAt: InternalFn = (
|
|||||||
type: 'start_path',
|
type: 'start_path',
|
||||||
},
|
},
|
||||||
cmd_id: pathId,
|
cmd_id: pathId,
|
||||||
file_id: uuidv4(),
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
engineCommandManager.sendSceneCommand({
|
engineCommandManager.sendSceneCommand({
|
||||||
@ -1654,7 +1650,6 @@ export const startSketchAt: InternalFn = (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
cmd_id: id,
|
cmd_id: id,
|
||||||
file_id: uuidv4(),
|
|
||||||
})
|
})
|
||||||
const currentPath: Path = {
|
const currentPath: Path = {
|
||||||
type: 'base',
|
type: 'base',
|
||||||
|
1201
src/wasm-lib/Cargo.lock
generated
1201
src/wasm-lib/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -12,6 +12,7 @@ anyhow = "1.0.75"
|
|||||||
backtrace = "0.3"
|
backtrace = "0.3"
|
||||||
bincode = "1.3.3"
|
bincode = "1.3.3"
|
||||||
gloo-utils = "0.2.0"
|
gloo-utils = "0.2.0"
|
||||||
|
kittycad = { version = "0.2.15", default-features = false, features = ["js"] }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
regex = "1.7.1"
|
regex = "1.7.1"
|
||||||
serde = {version = "1.0.152", features = ["derive"] }
|
serde = {version = "1.0.152", features = ["derive"] }
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
//! Functions for exported files from the server.
|
//! Functions for exported files from the server.
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
/// A file that has been exported from the server.
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
|
||||||
pub struct File {
|
|
||||||
pub name: String,
|
|
||||||
pub contents: Vec<u8>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn deserialize_files(data: Vec<u8>) -> Result<JsValue, JsError> {
|
pub fn deserialize_files(data: Vec<u8>) -> Result<JsValue, JsError> {
|
||||||
let files: Vec<File> = bincode::deserialize(&data)?;
|
let ws_resp: kittycad::types::WebSocketResponses = bincode::deserialize(&data)?;
|
||||||
|
|
||||||
Ok(serde_wasm_bindgen::to_value(&files)?)
|
if let kittycad::types::WebSocketResponses::Export { files } = ws_resp {
|
||||||
|
return Ok(serde_wasm_bindgen::to_value(&files)?);
|
||||||
|
}
|
||||||
|
|
||||||
|
Err(JsError::new(&format!(
|
||||||
|
"Invalid response type, got: {:?}",
|
||||||
|
ws_resp
|
||||||
|
)))
|
||||||
}
|
}
|
||||||
|
@ -1747,10 +1747,10 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@juggle/resize-observer/-/resize-observer-3.4.0.tgz#08d6c5e20cf7e4cc02fd181c4b0c225cd31dbb60"
|
resolved "https://registry.yarnpkg.com/@juggle/resize-observer/-/resize-observer-3.4.0.tgz#08d6c5e20cf7e4cc02fd181c4b0c225cd31dbb60"
|
||||||
integrity sha512-dfLbk+PwWvFzSxwk3n5ySL0hfBog779o8h68wK/7/APo/7cgyWp5jcXockbxdk5kFRkbeXWm4Fbi9FrdN381sA==
|
integrity sha512-dfLbk+PwWvFzSxwk3n5ySL0hfBog779o8h68wK/7/APo/7cgyWp5jcXockbxdk5kFRkbeXWm4Fbi9FrdN381sA==
|
||||||
|
|
||||||
"@kittycad/lib@^0.0.27":
|
"@kittycad/lib@^0.0.28":
|
||||||
version "0.0.27"
|
version "0.0.28"
|
||||||
resolved "https://registry.yarnpkg.com/@kittycad/lib/-/lib-0.0.27.tgz#6619494e365b6dfe1e400835d52b56a5d5128caa"
|
resolved "https://registry.yarnpkg.com/@kittycad/lib/-/lib-0.0.28.tgz#a40d67544bf2eb5571855114a75d8cb0eb9ec189"
|
||||||
integrity sha512-oRISiGJghEVm9hUs8y8ZYGRw4HFDkvK51E71ADKrNp+Mtmrzwjzt2sEj0C3yBQ8kKjeUiCeJU2EHSf2kYfD9bw==
|
integrity sha512-T5Lnu7qoB3bc4OMD3s4khPas+VkNKrMllpkvCzKrx7XXrelDCZOd21xALwEzbzOPMUdtp2SBd6nuJKMH/N2aOA==
|
||||||
dependencies:
|
dependencies:
|
||||||
node-fetch "3.3.2"
|
node-fetch "3.3.2"
|
||||||
openapi-types "^12.0.0"
|
openapi-types "^12.0.0"
|
||||||
|
Reference in New Issue
Block a user