2025-04-24 13:32:49 -05:00
|
|
|
import type { Project } from '@src/lib/project'
|
2025-05-08 03:54:40 +10:00
|
|
|
import type { ActorRefFrom } from 'xstate'
|
|
|
|
import type { systemIOMachine } from '@src/machines/systemIO/systemIOMachine'
|
2025-04-24 13:32:49 -05:00
|
|
|
|
|
|
|
export enum SystemIOMachineActors {
|
|
|
|
readFoldersFromProjectDirectory = 'read folders from project directory',
|
|
|
|
setProjectDirectoryPath = 'set project directory path',
|
|
|
|
createProject = 'create project',
|
|
|
|
renameProject = 'rename project',
|
|
|
|
deleteProject = 'delete project',
|
|
|
|
createKCLFile = 'create kcl file',
|
|
|
|
checkReadWrite = 'check read write',
|
2025-05-02 15:54:49 -04:00
|
|
|
/** TODO: rename this event to be more generic, like `createKCLFileAndNavigate` */
|
2025-04-24 13:32:49 -05:00
|
|
|
importFileFromURL = 'import file from URL',
|
[Feature]: Enable Text-to-CAD at the application level (#6501)
* chore: saving off skeleton
* fix: saving skeleton
* chore: skeleton for loading projects from project directory path
* chore: cleaning up useless state transition to be an on event direct to action state
* fix: new structure for web vs desktop vs react machine provider code
* chore: saving off skeleton
* fix: skeleton logic for react? going to move it from a string to obj.string
* fix: trying to prevent error element unmount on global react components. This is bricking JS state
* fix: we are so back
* chore: implemented navigating to specfic KCL file
* chore: implementing renaming project
* chore: deleting project
* fix: auto fixes
* fix: old debug/testing file oops
* chore: generic create new file
* chore: skeleton for web create file provide
* chore: basic machine vitest... need to figure out how to get window.electron implemented in vitest?
* chore: save off progress before deleting other project implementation, a few missing features still
* chore: trying a different init skeleton? most likely will migrate
* chore: first attempt of purging projects context provider
* chore: enabling toast for some machine state
* chore: enabling more toast success and error
* chore: writing read write state to the system io based on the project path
* fix: tsc fixes
* fix: use file system watcher, navigate to project after creation via the requestProjectName
* chore: open project command, hooks vs snapshot context helpers
* chore: implemented open and create project for e2e testing. They are hard coded in poor spot for now.
* fix: codespell fixes
* chore: implementing more project commands
* chore: PR improvements for root.tsx
* chore: leaving comment about new Router.tsx layout
* fix: removing debugging code
* fix: rewriting component for readability
* fix: improving web initialization
* chore: implementing import file from url which is not actually that?
* fix: clearing search params on import file from url
* fix: fixed two e2e tests, forgot needsReview when making new command
* fix: fixing some import from url business logic to pass e2e tests
* chore: script for diffing circular deps +/-
* fix: formatting
* fix: massive fix for circular depsga!
* fix: trying to fix some errors and auto fmt
* fix: updating deps
* fix: removing debugging code
* fix: big clean up
* fix: more deletion
* fix: tsc cleanup
* fix: TSC TSC TSC TSC!
* fix: typo fix
* fix: clear query params on web only, desktop not required
* fix: removing unused code
* fmt
* Bring back `trap` removed in merge
* Use explicit types instead of `any`s on arg configs
* Add project commands directly to command palette
* fix: deleting debugging code, from PR review
* fix: this got added back(?)
* fix: using referred type
* fix: more PR clean up
* fix: big block comment for xstate architecture decision
* fix: more pr comment fixes
* fix: saving off logic, need a big cleanup because I hacked it together to get a POC
* fix: extra business?
* fix: merge conflict just added them back why dude
* fix: more PR comments
* fix: big ciruclar deps fix, commandBarActor in appActor
* chore: writing e2e test, still need to fix 3 bugs
* chore: adding more scenarios
* fix: formatting
* fix: fixing tsc errors
* chore: deleting the old text to cad and using the new application level one, almost there
* fix: prompt to edit works
* fix: large push to get 1 text to cad command... the usage is a little buggy with delete and navigate within /file
* fix: settings for highlight edges now works
* chore: adding another e2e test
* fix: cleaning up e2e tests and writing more of them
* fix: tsc type
* chore: more e2e improvements, unique project name in text to cad
* chore: e2e tests should be good to go
* fix: gotcha comment
* fix: enabled web t2c, codespell fixes
* fix: fixing merge conflcits??
* fix: t2c is back
* Remove spaces in command bar test
* fmt
---------
Co-authored-by: Frank Noirot <frankjohnson1993@gmail.com>
Co-authored-by: lee-at-zoo-corp <lee@zoo.dev>
2025-04-25 18:04:47 -05:00
|
|
|
deleteKCLFile = 'delete kcl delete',
|
2025-05-08 03:54:40 +10:00
|
|
|
bulkCreateKCLFiles = 'bulk create kcl files',
|
|
|
|
bulkCreateKCLFilesAndNavigateToProject = 'bulk create kcl files and navigate to project',
|
2025-04-24 13:32:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export enum SystemIOMachineStates {
|
|
|
|
idle = 'idle',
|
|
|
|
readingFolders = 'readingFolders',
|
|
|
|
settingProjectDirectoryPath = 'settingProjectDirectoryPath',
|
|
|
|
creatingProject = 'creatingProject',
|
|
|
|
renamingProject = 'renamingProject',
|
|
|
|
deletingProject = 'deletingProject',
|
|
|
|
creatingKCLFile = 'creatingKCLFile',
|
|
|
|
checkingReadWrite = 'checkingReadWrite',
|
2025-05-02 15:54:49 -04:00
|
|
|
/** TODO: rename this event to be more generic, like `createKCLFileAndNavigate` */
|
2025-04-24 13:32:49 -05:00
|
|
|
importFileFromURL = 'importFileFromURL',
|
[Feature]: Enable Text-to-CAD at the application level (#6501)
* chore: saving off skeleton
* fix: saving skeleton
* chore: skeleton for loading projects from project directory path
* chore: cleaning up useless state transition to be an on event direct to action state
* fix: new structure for web vs desktop vs react machine provider code
* chore: saving off skeleton
* fix: skeleton logic for react? going to move it from a string to obj.string
* fix: trying to prevent error element unmount on global react components. This is bricking JS state
* fix: we are so back
* chore: implemented navigating to specfic KCL file
* chore: implementing renaming project
* chore: deleting project
* fix: auto fixes
* fix: old debug/testing file oops
* chore: generic create new file
* chore: skeleton for web create file provide
* chore: basic machine vitest... need to figure out how to get window.electron implemented in vitest?
* chore: save off progress before deleting other project implementation, a few missing features still
* chore: trying a different init skeleton? most likely will migrate
* chore: first attempt of purging projects context provider
* chore: enabling toast for some machine state
* chore: enabling more toast success and error
* chore: writing read write state to the system io based on the project path
* fix: tsc fixes
* fix: use file system watcher, navigate to project after creation via the requestProjectName
* chore: open project command, hooks vs snapshot context helpers
* chore: implemented open and create project for e2e testing. They are hard coded in poor spot for now.
* fix: codespell fixes
* chore: implementing more project commands
* chore: PR improvements for root.tsx
* chore: leaving comment about new Router.tsx layout
* fix: removing debugging code
* fix: rewriting component for readability
* fix: improving web initialization
* chore: implementing import file from url which is not actually that?
* fix: clearing search params on import file from url
* fix: fixed two e2e tests, forgot needsReview when making new command
* fix: fixing some import from url business logic to pass e2e tests
* chore: script for diffing circular deps +/-
* fix: formatting
* fix: massive fix for circular depsga!
* fix: trying to fix some errors and auto fmt
* fix: updating deps
* fix: removing debugging code
* fix: big clean up
* fix: more deletion
* fix: tsc cleanup
* fix: TSC TSC TSC TSC!
* fix: typo fix
* fix: clear query params on web only, desktop not required
* fix: removing unused code
* fmt
* Bring back `trap` removed in merge
* Use explicit types instead of `any`s on arg configs
* Add project commands directly to command palette
* fix: deleting debugging code, from PR review
* fix: this got added back(?)
* fix: using referred type
* fix: more PR clean up
* fix: big block comment for xstate architecture decision
* fix: more pr comment fixes
* fix: saving off logic, need a big cleanup because I hacked it together to get a POC
* fix: extra business?
* fix: merge conflict just added them back why dude
* fix: more PR comments
* fix: big ciruclar deps fix, commandBarActor in appActor
* chore: writing e2e test, still need to fix 3 bugs
* chore: adding more scenarios
* fix: formatting
* fix: fixing tsc errors
* chore: deleting the old text to cad and using the new application level one, almost there
* fix: prompt to edit works
* fix: large push to get 1 text to cad command... the usage is a little buggy with delete and navigate within /file
* fix: settings for highlight edges now works
* chore: adding another e2e test
* fix: cleaning up e2e tests and writing more of them
* fix: tsc type
* chore: more e2e improvements, unique project name in text to cad
* chore: e2e tests should be good to go
* fix: gotcha comment
* fix: enabled web t2c, codespell fixes
* fix: fixing merge conflcits??
* fix: t2c is back
* Remove spaces in command bar test
* fmt
---------
Co-authored-by: Frank Noirot <frankjohnson1993@gmail.com>
Co-authored-by: lee-at-zoo-corp <lee@zoo.dev>
2025-04-25 18:04:47 -05:00
|
|
|
deletingKCLFile = 'deletingKCLFile',
|
2025-05-08 03:54:40 +10:00
|
|
|
bulkCreatingKCLFiles = 'bulkCreatingKCLFiles',
|
|
|
|
bulkCreatingKCLFilesAndNavigateToProject = 'bulkCreatingKCLFilesAndNavigateToProject',
|
2025-04-24 13:32:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
const donePrefix = 'xstate.done.actor.'
|
|
|
|
|
|
|
|
export enum SystemIOMachineEvents {
|
|
|
|
readFoldersFromProjectDirectory = 'read folders from project directory',
|
|
|
|
done_readFoldersFromProjectDirectory = donePrefix +
|
|
|
|
'read folders from project directory',
|
|
|
|
setProjectDirectoryPath = 'set project directory path',
|
|
|
|
navigateToProject = 'navigate to project',
|
|
|
|
navigateToFile = 'navigate to file',
|
|
|
|
createProject = 'create project',
|
|
|
|
renameProject = 'rename project',
|
|
|
|
deleteProject = 'delete project',
|
2025-04-28 18:15:20 -05:00
|
|
|
done_deleteProject = donePrefix + 'delete project',
|
2025-04-24 13:32:49 -05:00
|
|
|
createKCLFile = 'create kcl file',
|
|
|
|
setDefaultProjectFolderName = 'set default project folder name',
|
|
|
|
done_checkReadWrite = donePrefix + 'check read write',
|
2025-05-02 15:54:49 -04:00
|
|
|
/** TODO: rename this event to be more generic, like `createKCLFileAndNavigate` */
|
2025-04-24 13:32:49 -05:00
|
|
|
importFileFromURL = 'import file from URL',
|
|
|
|
done_importFileFromURL = donePrefix + 'import file from URL',
|
[Feature]: Enable Text-to-CAD at the application level (#6501)
* chore: saving off skeleton
* fix: saving skeleton
* chore: skeleton for loading projects from project directory path
* chore: cleaning up useless state transition to be an on event direct to action state
* fix: new structure for web vs desktop vs react machine provider code
* chore: saving off skeleton
* fix: skeleton logic for react? going to move it from a string to obj.string
* fix: trying to prevent error element unmount on global react components. This is bricking JS state
* fix: we are so back
* chore: implemented navigating to specfic KCL file
* chore: implementing renaming project
* chore: deleting project
* fix: auto fixes
* fix: old debug/testing file oops
* chore: generic create new file
* chore: skeleton for web create file provide
* chore: basic machine vitest... need to figure out how to get window.electron implemented in vitest?
* chore: save off progress before deleting other project implementation, a few missing features still
* chore: trying a different init skeleton? most likely will migrate
* chore: first attempt of purging projects context provider
* chore: enabling toast for some machine state
* chore: enabling more toast success and error
* chore: writing read write state to the system io based on the project path
* fix: tsc fixes
* fix: use file system watcher, navigate to project after creation via the requestProjectName
* chore: open project command, hooks vs snapshot context helpers
* chore: implemented open and create project for e2e testing. They are hard coded in poor spot for now.
* fix: codespell fixes
* chore: implementing more project commands
* chore: PR improvements for root.tsx
* chore: leaving comment about new Router.tsx layout
* fix: removing debugging code
* fix: rewriting component for readability
* fix: improving web initialization
* chore: implementing import file from url which is not actually that?
* fix: clearing search params on import file from url
* fix: fixed two e2e tests, forgot needsReview when making new command
* fix: fixing some import from url business logic to pass e2e tests
* chore: script for diffing circular deps +/-
* fix: formatting
* fix: massive fix for circular depsga!
* fix: trying to fix some errors and auto fmt
* fix: updating deps
* fix: removing debugging code
* fix: big clean up
* fix: more deletion
* fix: tsc cleanup
* fix: TSC TSC TSC TSC!
* fix: typo fix
* fix: clear query params on web only, desktop not required
* fix: removing unused code
* fmt
* Bring back `trap` removed in merge
* Use explicit types instead of `any`s on arg configs
* Add project commands directly to command palette
* fix: deleting debugging code, from PR review
* fix: this got added back(?)
* fix: using referred type
* fix: more PR clean up
* fix: big block comment for xstate architecture decision
* fix: more pr comment fixes
* fix: saving off logic, need a big cleanup because I hacked it together to get a POC
* fix: extra business?
* fix: merge conflict just added them back why dude
* fix: more PR comments
* fix: big ciruclar deps fix, commandBarActor in appActor
* chore: writing e2e test, still need to fix 3 bugs
* chore: adding more scenarios
* fix: formatting
* fix: fixing tsc errors
* chore: deleting the old text to cad and using the new application level one, almost there
* fix: prompt to edit works
* fix: large push to get 1 text to cad command... the usage is a little buggy with delete and navigate within /file
* fix: settings for highlight edges now works
* chore: adding another e2e test
* fix: cleaning up e2e tests and writing more of them
* fix: tsc type
* chore: more e2e improvements, unique project name in text to cad
* chore: e2e tests should be good to go
* fix: gotcha comment
* fix: enabled web t2c, codespell fixes
* fix: fixing merge conflcits??
* fix: t2c is back
* Remove spaces in command bar test
* fmt
---------
Co-authored-by: Frank Noirot <frankjohnson1993@gmail.com>
Co-authored-by: lee-at-zoo-corp <lee@zoo.dev>
2025-04-25 18:04:47 -05:00
|
|
|
generateTextToCAD = 'generate text to CAD',
|
|
|
|
deleteKCLFile = 'delete kcl file',
|
2025-05-08 03:54:40 +10:00
|
|
|
bulkCreateKCLFiles = 'bulk create kcl files',
|
|
|
|
bulkCreateKCLFilesAndNavigateToProject = 'bulk create kcl files and navigate to project',
|
2025-04-24 13:32:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export enum SystemIOMachineActions {
|
|
|
|
setFolders = 'set folders',
|
|
|
|
setProjectDirectoryPath = 'set project directory path',
|
|
|
|
setRequestedProjectName = 'set requested project name',
|
|
|
|
setRequestedFileName = 'set requested file name',
|
|
|
|
setDefaultProjectFolderName = 'set default project folder name',
|
|
|
|
toastSuccess = 'toastSuccess',
|
|
|
|
toastError = 'toastError',
|
|
|
|
setReadWriteProjectDirectory = 'set read write project directory',
|
[Feature]: Enable Text-to-CAD at the application level (#6501)
* chore: saving off skeleton
* fix: saving skeleton
* chore: skeleton for loading projects from project directory path
* chore: cleaning up useless state transition to be an on event direct to action state
* fix: new structure for web vs desktop vs react machine provider code
* chore: saving off skeleton
* fix: skeleton logic for react? going to move it from a string to obj.string
* fix: trying to prevent error element unmount on global react components. This is bricking JS state
* fix: we are so back
* chore: implemented navigating to specfic KCL file
* chore: implementing renaming project
* chore: deleting project
* fix: auto fixes
* fix: old debug/testing file oops
* chore: generic create new file
* chore: skeleton for web create file provide
* chore: basic machine vitest... need to figure out how to get window.electron implemented in vitest?
* chore: save off progress before deleting other project implementation, a few missing features still
* chore: trying a different init skeleton? most likely will migrate
* chore: first attempt of purging projects context provider
* chore: enabling toast for some machine state
* chore: enabling more toast success and error
* chore: writing read write state to the system io based on the project path
* fix: tsc fixes
* fix: use file system watcher, navigate to project after creation via the requestProjectName
* chore: open project command, hooks vs snapshot context helpers
* chore: implemented open and create project for e2e testing. They are hard coded in poor spot for now.
* fix: codespell fixes
* chore: implementing more project commands
* chore: PR improvements for root.tsx
* chore: leaving comment about new Router.tsx layout
* fix: removing debugging code
* fix: rewriting component for readability
* fix: improving web initialization
* chore: implementing import file from url which is not actually that?
* fix: clearing search params on import file from url
* fix: fixed two e2e tests, forgot needsReview when making new command
* fix: fixing some import from url business logic to pass e2e tests
* chore: script for diffing circular deps +/-
* fix: formatting
* fix: massive fix for circular depsga!
* fix: trying to fix some errors and auto fmt
* fix: updating deps
* fix: removing debugging code
* fix: big clean up
* fix: more deletion
* fix: tsc cleanup
* fix: TSC TSC TSC TSC!
* fix: typo fix
* fix: clear query params on web only, desktop not required
* fix: removing unused code
* fmt
* Bring back `trap` removed in merge
* Use explicit types instead of `any`s on arg configs
* Add project commands directly to command palette
* fix: deleting debugging code, from PR review
* fix: this got added back(?)
* fix: using referred type
* fix: more PR clean up
* fix: big block comment for xstate architecture decision
* fix: more pr comment fixes
* fix: saving off logic, need a big cleanup because I hacked it together to get a POC
* fix: extra business?
* fix: merge conflict just added them back why dude
* fix: more PR comments
* fix: big ciruclar deps fix, commandBarActor in appActor
* chore: writing e2e test, still need to fix 3 bugs
* chore: adding more scenarios
* fix: formatting
* fix: fixing tsc errors
* chore: deleting the old text to cad and using the new application level one, almost there
* fix: prompt to edit works
* fix: large push to get 1 text to cad command... the usage is a little buggy with delete and navigate within /file
* fix: settings for highlight edges now works
* chore: adding another e2e test
* fix: cleaning up e2e tests and writing more of them
* fix: tsc type
* chore: more e2e improvements, unique project name in text to cad
* chore: e2e tests should be good to go
* fix: gotcha comment
* fix: enabled web t2c, codespell fixes
* fix: fixing merge conflcits??
* fix: t2c is back
* Remove spaces in command bar test
* fmt
---------
Co-authored-by: Frank Noirot <frankjohnson1993@gmail.com>
Co-authored-by: lee-at-zoo-corp <lee@zoo.dev>
2025-04-25 18:04:47 -05:00
|
|
|
setRequestedTextToCadGeneration = 'set requested text to cad generation',
|
2025-04-29 01:23:50 -04:00
|
|
|
setLastProjectDeleteRequest = 'set last project delete request',
|
2025-04-24 13:32:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export const NO_PROJECT_DIRECTORY = ''
|
|
|
|
|
|
|
|
export type SystemIOContext = {
|
|
|
|
/** Only store folders under the projectDirectory, do not maintain folders outside this directory */
|
|
|
|
folders: Project[]
|
|
|
|
/** For this machines runtime, this is the default string when creating a project
|
|
|
|
* A project is defined by creating a folder at the one level below the working project directory */
|
|
|
|
defaultProjectFolderName: string
|
|
|
|
/** working project directory that stores all the project folders */
|
|
|
|
projectDirectoryPath: string
|
|
|
|
/** has the application gone through the initialization of systemIOMachine at least once.
|
|
|
|
* this is required to prevent chokidar from spamming invalid events during initialization. */
|
|
|
|
hasListedProjects: boolean
|
|
|
|
requestedProjectName: { name: string }
|
2025-05-02 15:54:49 -04:00
|
|
|
requestedFileName: { project: string; file: string; subRoute?: string }
|
2025-04-24 13:32:49 -05:00
|
|
|
canReadWriteProjectDirectory: { value: boolean; error: unknown }
|
|
|
|
clearURLParams: { value: boolean }
|
[Feature]: Enable Text-to-CAD at the application level (#6501)
* chore: saving off skeleton
* fix: saving skeleton
* chore: skeleton for loading projects from project directory path
* chore: cleaning up useless state transition to be an on event direct to action state
* fix: new structure for web vs desktop vs react machine provider code
* chore: saving off skeleton
* fix: skeleton logic for react? going to move it from a string to obj.string
* fix: trying to prevent error element unmount on global react components. This is bricking JS state
* fix: we are so back
* chore: implemented navigating to specfic KCL file
* chore: implementing renaming project
* chore: deleting project
* fix: auto fixes
* fix: old debug/testing file oops
* chore: generic create new file
* chore: skeleton for web create file provide
* chore: basic machine vitest... need to figure out how to get window.electron implemented in vitest?
* chore: save off progress before deleting other project implementation, a few missing features still
* chore: trying a different init skeleton? most likely will migrate
* chore: first attempt of purging projects context provider
* chore: enabling toast for some machine state
* chore: enabling more toast success and error
* chore: writing read write state to the system io based on the project path
* fix: tsc fixes
* fix: use file system watcher, navigate to project after creation via the requestProjectName
* chore: open project command, hooks vs snapshot context helpers
* chore: implemented open and create project for e2e testing. They are hard coded in poor spot for now.
* fix: codespell fixes
* chore: implementing more project commands
* chore: PR improvements for root.tsx
* chore: leaving comment about new Router.tsx layout
* fix: removing debugging code
* fix: rewriting component for readability
* fix: improving web initialization
* chore: implementing import file from url which is not actually that?
* fix: clearing search params on import file from url
* fix: fixed two e2e tests, forgot needsReview when making new command
* fix: fixing some import from url business logic to pass e2e tests
* chore: script for diffing circular deps +/-
* fix: formatting
* fix: massive fix for circular depsga!
* fix: trying to fix some errors and auto fmt
* fix: updating deps
* fix: removing debugging code
* fix: big clean up
* fix: more deletion
* fix: tsc cleanup
* fix: TSC TSC TSC TSC!
* fix: typo fix
* fix: clear query params on web only, desktop not required
* fix: removing unused code
* fmt
* Bring back `trap` removed in merge
* Use explicit types instead of `any`s on arg configs
* Add project commands directly to command palette
* fix: deleting debugging code, from PR review
* fix: this got added back(?)
* fix: using referred type
* fix: more PR clean up
* fix: big block comment for xstate architecture decision
* fix: more pr comment fixes
* fix: saving off logic, need a big cleanup because I hacked it together to get a POC
* fix: extra business?
* fix: merge conflict just added them back why dude
* fix: more PR comments
* fix: big ciruclar deps fix, commandBarActor in appActor
* chore: writing e2e test, still need to fix 3 bugs
* chore: adding more scenarios
* fix: formatting
* fix: fixing tsc errors
* chore: deleting the old text to cad and using the new application level one, almost there
* fix: prompt to edit works
* fix: large push to get 1 text to cad command... the usage is a little buggy with delete and navigate within /file
* fix: settings for highlight edges now works
* chore: adding another e2e test
* fix: cleaning up e2e tests and writing more of them
* fix: tsc type
* chore: more e2e improvements, unique project name in text to cad
* chore: e2e tests should be good to go
* fix: gotcha comment
* fix: enabled web t2c, codespell fixes
* fix: fixing merge conflcits??
* fix: t2c is back
* Remove spaces in command bar test
* fmt
---------
Co-authored-by: Frank Noirot <frankjohnson1993@gmail.com>
Co-authored-by: lee-at-zoo-corp <lee@zoo.dev>
2025-04-25 18:04:47 -05:00
|
|
|
requestedTextToCadGeneration: {
|
|
|
|
requestedPrompt: string
|
|
|
|
requestedProjectName: string
|
|
|
|
isProjectNew: boolean
|
|
|
|
}
|
2025-04-28 18:15:20 -05:00
|
|
|
lastProjectDeleteRequest: {
|
|
|
|
project: string
|
|
|
|
}
|
2025-04-24 13:32:49 -05:00
|
|
|
}
|
2025-05-08 03:54:40 +10:00
|
|
|
|
|
|
|
export type RequestedKCLFile = {
|
|
|
|
requestedProjectName: string
|
|
|
|
requestedFileName: string
|
|
|
|
requestedCode: string
|
|
|
|
}
|
|
|
|
|
|
|
|
export const waitForIdleState = async ({
|
|
|
|
systemIOActor,
|
|
|
|
}: { systemIOActor: ActorRefFrom<typeof systemIOMachine> }) => {
|
|
|
|
// Check if already idle before setting up subscription
|
|
|
|
if (systemIOActor.getSnapshot().matches(SystemIOMachineStates.idle)) {
|
|
|
|
return Promise.resolve()
|
|
|
|
}
|
|
|
|
|
|
|
|
const waitForIdlePromise = new Promise((resolve) => {
|
|
|
|
const subscription = systemIOActor.subscribe((state) => {
|
|
|
|
if (state.matches(SystemIOMachineStates.idle)) {
|
|
|
|
subscription.unsubscribe()
|
|
|
|
resolve(undefined)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return waitForIdlePromise
|
|
|
|
}
|