Compare commits
7 Commits
v0.25.0
...
kurt-model
Author | SHA1 | Date | |
---|---|---|---|
4107ab9b94 | |||
b473e23251 | |||
81498fcafe | |||
38d5fb8c41 | |||
a762d741a5 | |||
e62a5ccc47 | |||
4b8ca7f61f |
@ -224,6 +224,8 @@ jobs:
|
||||
--arg mac_x64_url "$RELEASE_DIR/${{ env.URL_CODED_NAME }}-${VERSION_NO_V}-x64-mac.dmg" \
|
||||
--arg windows_arm64_url "$RELEASE_DIR/${{ env.URL_CODED_NAME }}-${VERSION_NO_V}-arm64-win.msi" \
|
||||
--arg windows_x64_url "$RELEASE_DIR/${{ env.URL_CODED_NAME }}-${VERSION_NO_V}-x64-win.msi" \
|
||||
--arg linux_arm64_url "$RELEASE_DIR/${{ env.URL_CODED_NAME }}-${VERSION_NO_V}-arm64-linux.AppImage" \
|
||||
--arg linux_x64_url "$RELEASE_DIR/${{ env.URL_CODED_NAME }}-${VERSION_NO_V}-x86_64-linux.AppImage" \
|
||||
'{
|
||||
"version": $version,
|
||||
"pub_date": $pub_date,
|
||||
@ -240,6 +242,12 @@ jobs:
|
||||
},
|
||||
"msi-x64": {
|
||||
"url": $windows_x64_url
|
||||
},
|
||||
"appimage-arm64": {
|
||||
"url": $linux_arm64_url
|
||||
},
|
||||
"appimage-x64": {
|
||||
"url": $linux_x64_url
|
||||
}
|
||||
}
|
||||
}' > last_download.json
|
||||
|
@ -54,6 +54,11 @@ test(
|
||||
const modelStateIndicator = page.getByTestId(
|
||||
'model-state-indicator-execution-done'
|
||||
)
|
||||
const modelStateIndicatorLoading = page.getByTestId(
|
||||
'model-state-indicator-loading'
|
||||
)
|
||||
|
||||
await expect(modelStateIndicatorLoading).toBeVisible()
|
||||
await expect(modelStateIndicator).toBeVisible({ timeout: 60000 })
|
||||
|
||||
const gltfOption = page.getByText('glTF')
|
||||
|
1
interface.d.ts
vendored
1
interface.d.ts
vendored
@ -31,7 +31,6 @@ export interface IElectronAPI {
|
||||
sep: typeof path.sep
|
||||
rename: (prev: string, next: string) => typeof fs.rename
|
||||
setBaseUrl: (value: string) => void
|
||||
loadProjectAtStartup: () => Promise<ProjectState | null>
|
||||
packageJson: {
|
||||
name: string
|
||||
}
|
||||
|
@ -69,19 +69,6 @@ const router = createRouter([
|
||||
path: PATHS.INDEX,
|
||||
loader: async () => {
|
||||
const onDesktop = isDesktop()
|
||||
if (onDesktop) {
|
||||
const projectStartupFile =
|
||||
await window.electron.loadProjectAtStartup()
|
||||
if (projectStartupFile !== null) {
|
||||
// Redirect to the file if we have a file path.
|
||||
if (projectStartupFile.length > 0) {
|
||||
return redirect(
|
||||
PATHS.FILE + '/' + encodeURIComponent(projectStartupFile)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return onDesktop
|
||||
? redirect(PATHS.HOME)
|
||||
: redirect(PATHS.FILE + '/%2F' + BROWSER_PROJECT_NAME)
|
||||
|
@ -1,45 +1,27 @@
|
||||
import { useEngineCommands } from './EngineCommands'
|
||||
import { Spinner } from './Spinner'
|
||||
import { CustomIcon } from './CustomIcon'
|
||||
import { useKclContext } from 'lang/KclProvider'
|
||||
|
||||
export const ModelStateIndicator = () => {
|
||||
const [commands] = useEngineCommands()
|
||||
const { isExecuting } = useKclContext()
|
||||
|
||||
const lastCommandType = commands[commands.length - 1]?.type
|
||||
|
||||
let className = 'w-6 h-6 '
|
||||
let icon = <Spinner className={className} />
|
||||
let dataTestId = 'model-state-indicator'
|
||||
|
||||
if (lastCommandType === 'receive-reliable') {
|
||||
className +=
|
||||
'bg-chalkboard-20 dark:bg-chalkboard-80 !group-disabled:bg-chalkboard-30 !dark:group-disabled:bg-chalkboard-80 rounded-sm bg-succeed-10/30 dark:bg-succeed'
|
||||
icon = (
|
||||
<CustomIcon
|
||||
data-testid={dataTestId + '-receive-reliable'}
|
||||
name="checkmark"
|
||||
/>
|
||||
if (isExecuting)
|
||||
return (
|
||||
<div className="w-6 h-6" data-testid="model-state-indicator-loading">
|
||||
<Spinner className="w-6 h-6" />
|
||||
</div>
|
||||
)
|
||||
} else if (lastCommandType === 'execution-done') {
|
||||
className +=
|
||||
'border-6 border border-solid border-chalkboard-60 dark:border-chalkboard-80 bg-chalkboard-20 dark:bg-chalkboard-80 !group-disabled:bg-chalkboard-30 !dark:group-disabled:bg-chalkboard-80 rounded-sm bg-succeed-10/30 dark:bg-succeed'
|
||||
icon = (
|
||||
<CustomIcon
|
||||
data-testid={dataTestId + '-execution-done'}
|
||||
name="checkmark"
|
||||
/>
|
||||
)
|
||||
} else if (lastCommandType === 'export-done') {
|
||||
className +=
|
||||
'border-6 border border-solid border-chalkboard-60 dark:border-chalkboard-80 bg-chalkboard-20 dark:bg-chalkboard-80 !group-disabled:bg-chalkboard-30 !dark:group-disabled:bg-chalkboard-80 rounded-sm bg-succeed-10/30 dark:bg-succeed'
|
||||
icon = (
|
||||
<CustomIcon data-testid={dataTestId + '-export-done'} name="checkmark" />
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={className} data-testid="model-state-indicator">
|
||||
{icon}
|
||||
<div
|
||||
className="border-6 border border-solid border-chalkboard-60 dark:border-chalkboard-80 bg-chalkboard-20 dark:bg-chalkboard-80 !group-disabled:bg-chalkboard-30 !dark:group-disabled:bg-chalkboard-80 rounded-sm bg-succeed-10/30 dark:bg-succeed"
|
||||
data-testid="model-state-indicator"
|
||||
>
|
||||
<CustomIcon
|
||||
data-testid="model-state-indicator-execution-done"
|
||||
name="checkmark"
|
||||
className="w-6 h-6"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
107
src/main.ts
107
src/main.ts
@ -60,7 +60,7 @@ if (process.defaultApp) {
|
||||
// Must be done before ready event.
|
||||
registerStartupListeners()
|
||||
|
||||
const createWindow = (): BrowserWindow => {
|
||||
const createWindow = (filePath?: string): BrowserWindow => {
|
||||
const newWindow = new BrowserWindow({
|
||||
autoHideMenuBar: true,
|
||||
show: false,
|
||||
@ -81,9 +81,26 @@ const createWindow = (): BrowserWindow => {
|
||||
if (MAIN_WINDOW_VITE_DEV_SERVER_URL) {
|
||||
newWindow.loadURL(MAIN_WINDOW_VITE_DEV_SERVER_URL)
|
||||
} else {
|
||||
newWindow.loadFile(
|
||||
path.join(__dirname, `../renderer/${MAIN_WINDOW_VITE_NAME}/index.html`)
|
||||
)
|
||||
getProjectPathAtStartup(filePath).then((projectPath) => {
|
||||
const startIndex = path.join(
|
||||
__dirname,
|
||||
`../renderer/${MAIN_WINDOW_VITE_NAME}/index.html`
|
||||
)
|
||||
|
||||
if (projectPath === null) {
|
||||
newWindow.loadFile(startIndex)
|
||||
return
|
||||
}
|
||||
|
||||
console.log('Loading file', projectPath)
|
||||
|
||||
const fullUrl = `/file/${encodeURIComponent(projectPath)}`
|
||||
console.log('Full URL', fullUrl)
|
||||
|
||||
newWindow.loadFile(startIndex, {
|
||||
hash: fullUrl,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Open the DevTools.
|
||||
@ -233,7 +250,9 @@ app.on('ready', async () => {
|
||||
})
|
||||
})
|
||||
|
||||
ipcMain.handle('loadProjectAtStartup', async () => {
|
||||
const getProjectPathAtStartup = async (
|
||||
filePath?: string
|
||||
): Promise<string | null> => {
|
||||
// If we are in development mode, we don't want to load a project at
|
||||
// startup.
|
||||
// Since the args passed are always '.'
|
||||
@ -241,52 +260,54 @@ ipcMain.handle('loadProjectAtStartup', async () => {
|
||||
return null
|
||||
}
|
||||
|
||||
let projectPath: string | null = null
|
||||
// macOS: open-file events that were received before the app is ready
|
||||
const macOpenFiles: string[] = (global as any).macOpenFiles
|
||||
if (macOpenFiles && macOpenFiles && macOpenFiles.length > 0) {
|
||||
projectPath = macOpenFiles[0] // We only do one project at a time
|
||||
}
|
||||
// Reset this so we don't accidentally use it again.
|
||||
const macOpenFilesEmpty: string[] = []
|
||||
// @ts-ignore
|
||||
global['macOpenFiles'] = macOpenFilesEmpty
|
||||
let projectPath: string | null = filePath || null
|
||||
if (projectPath === null) {
|
||||
// macOS: open-file events that were received before the app is ready
|
||||
const macOpenFiles: string[] = (global as any).macOpenFiles
|
||||
if (macOpenFiles && macOpenFiles && macOpenFiles.length > 0) {
|
||||
projectPath = macOpenFiles[0] // We only do one project at a time
|
||||
}
|
||||
// Reset this so we don't accidentally use it again.
|
||||
const macOpenFilesEmpty: string[] = []
|
||||
// @ts-ignore
|
||||
global['macOpenFiles'] = macOpenFilesEmpty
|
||||
|
||||
// macOS: open-url events that were received before the app is ready
|
||||
const getOpenUrls: string[] = (global as any).getOpenUrls
|
||||
if (getOpenUrls && getOpenUrls.length > 0) {
|
||||
projectPath = getOpenUrls[0] // We only do one project at a
|
||||
}
|
||||
// Reset this so we don't accidentally use it again.
|
||||
// @ts-ignore
|
||||
global['getOpenUrls'] = []
|
||||
// macOS: open-url events that were received before the app is ready
|
||||
const getOpenUrls: string[] = (global as any).getOpenUrls
|
||||
if (getOpenUrls && getOpenUrls.length > 0) {
|
||||
projectPath = getOpenUrls[0] // We only do one project at a
|
||||
}
|
||||
// Reset this so we don't accidentally use it again.
|
||||
// @ts-ignore
|
||||
global['getOpenUrls'] = []
|
||||
|
||||
// Check if we have a project path in the command line arguments
|
||||
// If we do, we will load the project at that path
|
||||
if (args._.length > 1) {
|
||||
if (args._[1].length > 0) {
|
||||
projectPath = args._[1]
|
||||
// Reset all this value so we don't accidentally use it again.
|
||||
args._[1] = ''
|
||||
// Check if we have a project path in the command line arguments
|
||||
// If we do, we will load the project at that path
|
||||
if (args._.length > 1) {
|
||||
if (args._[1].length > 0) {
|
||||
projectPath = args._[1]
|
||||
// Reset all this value so we don't accidentally use it again.
|
||||
args._[1] = ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (projectPath) {
|
||||
// We have a project path, load the project information.
|
||||
console.log(`Loading project at startup: ${projectPath}`)
|
||||
try {
|
||||
const currentFile = await getCurrentProjectFile(projectPath)
|
||||
console.log(`Project loaded: ${currentFile}`)
|
||||
return currentFile
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
const currentFile = await getCurrentProjectFile(projectPath)
|
||||
|
||||
if (currentFile instanceof Error) {
|
||||
console.error(currentFile)
|
||||
return null
|
||||
}
|
||||
|
||||
return null
|
||||
console.log(`Project loaded: ${currentFile}`)
|
||||
return currentFile
|
||||
}
|
||||
|
||||
return null
|
||||
})
|
||||
}
|
||||
|
||||
function parseCLIArgs(): minimist.ParsedArgs {
|
||||
return minimist(process.argv, {})
|
||||
@ -303,10 +324,11 @@ function registerStartupListeners() {
|
||||
app.on('open-file', function (event, path) {
|
||||
event.preventDefault()
|
||||
|
||||
macOpenFiles.push(path)
|
||||
// If we have a mainWindow, lets open another window.
|
||||
if (mainWindow) {
|
||||
createWindow()
|
||||
createWindow(path)
|
||||
} else {
|
||||
macOpenFiles.push(path)
|
||||
}
|
||||
})
|
||||
|
||||
@ -322,10 +344,11 @@ function registerStartupListeners() {
|
||||
) {
|
||||
event.preventDefault()
|
||||
|
||||
openUrls.push(url)
|
||||
// If we have a mainWindow, lets open another window.
|
||||
if (mainWindow) {
|
||||
createWindow()
|
||||
createWindow(url)
|
||||
} else {
|
||||
openUrls.push(url)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,9 +60,6 @@ const listMachines = async (): Promise<MachinesListing> => {
|
||||
const getMachineApiIp = async (): Promise<String | null> =>
|
||||
ipcRenderer.invoke('find_machine_api')
|
||||
|
||||
const loadProjectAtStartup = async (): Promise<string | null> =>
|
||||
ipcRenderer.invoke('loadProjectAtStartup')
|
||||
|
||||
contextBridge.exposeInMainWorld('electron', {
|
||||
login,
|
||||
// Passing fs directly is not recommended since it gives a lot of power
|
||||
@ -96,7 +93,6 @@ contextBridge.exposeInMainWorld('electron', {
|
||||
isWindows,
|
||||
isLinux,
|
||||
},
|
||||
loadProjectAtStartup,
|
||||
// IMPORTANT NOTE: kittycad.ts reads process.env.BASE_URL. But there is
|
||||
// no way to set it across the bridge boundary. We need to make it a command.
|
||||
setBaseUrl: (value: string) => (process.env.BASE_URL = value),
|
||||
|
Reference in New Issue
Block a user