* initial

Signed-off-by: Jess Frazelle <github@jessfraz.com>

update

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* start of tauri

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* better

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* set the default type

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* add comments

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* dialog for save tauri

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* partial tsc fix

* bump kittycad lib

* Update src/lib/exportSave.ts

Co-authored-by: Kurt Hutten <k.hutten@protonmail.ch>

* updates;

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* default coords

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:
Jess Frazelle
2023-08-02 16:23:17 -07:00
committed by GitHub
parent c80dd44c59
commit cd4672c98d
13 changed files with 430 additions and 31 deletions

View File

@ -2,6 +2,7 @@ import { SourceRange } from '../executor'
import { Selections } from '../../useStore'
import { VITE_KC_API_WS_MODELING_URL } from '../../env'
import { Models } from '@kittycad/lib'
import { exportSave } from '../../lib/exportSave'
interface ResultCommand {
type: 'result'
@ -65,6 +66,10 @@ export class EngineCommandManager {
})
this.socket = new WebSocket(VITE_KC_API_WS_MODELING_URL, [])
// Change binary type from "blob" to "arraybuffer"
this.socket.binaryType = 'arraybuffer'
this.pc = new RTCPeerConnection()
this.pc.createDataChannel('unreliable_modeling_cmds')
this.socket.addEventListener('open', (event) => {
@ -87,15 +92,13 @@ export class EngineCommandManager {
this?.socket?.addEventListener('message', (event) => {
if (!this.socket || !this.pc) return
//console.log('Message from server ', event.data);
if (event.data instanceof Blob) {
const reader = new FileReader()
reader.onload = () => {
//console.log("Result: " + reader.result);
}
reader.readAsText(event.data)
// console.log('Message from server ', event.data);
if (event.data instanceof ArrayBuffer) {
// If the data is an ArrayBuffer, it's the result of an export command,
// because in all other cases we send JSON strings. But in the case of
// export we send a binary blob.
// Pass this to our export function.
exportSave(event.data)
} else if (
typeof event.data === 'string' &&
event.data.toLocaleLowerCase().startsWith('error')
@ -211,6 +214,7 @@ export class EngineCommandManager {
} else if (message.type === 'click') {
this.onClickCallback(message)
} else {
console.log('received message', message)
}
}
})
@ -272,6 +276,7 @@ export class EngineCommandManager {
this.lossyDataChannel.send(JSON.stringify(command))
return
}
console.log('sending command', command)
this.socket?.send(JSON.stringify(command))
}
sendModellingCommand({