2025-04-01 23:54:26 -07:00
|
|
|
import { AppStreamProvider } from '@src/AppState'
|
2025-04-01 15:31:19 -07:00
|
|
|
import ReactDOM from 'react-dom/client'
|
|
|
|
|
import toast, { Toaster } from 'react-hot-toast'
|
|
|
|
|
import { HotkeysProvider } from 'react-hotkeys-hook'
|
|
|
|
|
import ModalContainer from 'react-modal-promise'
|
2025-04-01 23:54:26 -07:00
|
|
|
|
|
|
|
|
import { Router } from '@src/Router'
|
|
|
|
|
import { ToastUpdate } from '@src/components/ToastUpdate'
|
|
|
|
|
import '@src/index.css'
|
2025-04-11 11:17:46 -07:00
|
|
|
import { initPromise } from '@src/lang/wasmUtils'
|
2025-04-01 23:54:26 -07:00
|
|
|
import { AUTO_UPDATER_TOAST_ID } from '@src/lib/constants'
|
|
|
|
|
import { initializeWindowExceptionHandler } from '@src/lib/exceptions'
|
|
|
|
|
import { isDesktop } from '@src/lib/isDesktop'
|
|
|
|
|
import { markOnce } from '@src/lib/performance'
|
|
|
|
|
import { reportRejection } from '@src/lib/trap'
|
[Feature]: Load external model becomes Add file to project, global application add file to project with home page update. (#6506)
* 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??
* feat: implemented load external for kcl samples
* feat: load external model from disk
* fix: trying to delete old stuff
* fix: all command trigger locations now have defaults for current project
* fix: gotcha comment for the future
* chore: hiding import file from url command, two separate commands for 3d and kcl file adding
* chore: commands are now add file to project, 3rd iteration
* fix: t2c in file menu fixed
* chore: updating file menu for new global actions
* fix: auto fixes
* fix: the command bar arg flow for web add kcl file seems backwards?
* chore: updated home layout, added create from kcl sample button
* chore: remapping some menu actions
* fix: fixing open dialog copy
* fix: an e2e test
* fix: fixed e2e tests
* fix: fixed e2e tests
* fix: auto fixes
* fix: pr clean up
* fix: removing console log
* fix: PR updates
* fix: the reviewed stage boolean required the expected state to change. Also I progressed the command bar too soon
* fix: no idea how this passed locally yesterday? I removed the {dir} unused but I need the function's logic but not the return value...
* fix: should be good to go?
---------
Co-authored-by: Frank Noirot <frankjohnson1993@gmail.com>
2025-04-29 13:04:45 -05:00
|
|
|
import { appActor, systemIOActor, commandBarActor } from '@src/lib/singletons'
|
2025-04-01 23:54:26 -07:00
|
|
|
import reportWebVitals from '@src/reportWebVitals'
|
[Feature]: Load external model becomes Add file to project, global application add file to project with home page update. (#6506)
* 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??
* feat: implemented load external for kcl samples
* feat: load external model from disk
* fix: trying to delete old stuff
* fix: all command trigger locations now have defaults for current project
* fix: gotcha comment for the future
* chore: hiding import file from url command, two separate commands for 3d and kcl file adding
* chore: commands are now add file to project, 3rd iteration
* fix: t2c in file menu fixed
* chore: updating file menu for new global actions
* fix: auto fixes
* fix: the command bar arg flow for web add kcl file seems backwards?
* chore: updated home layout, added create from kcl sample button
* chore: remapping some menu actions
* fix: fixing open dialog copy
* fix: an e2e test
* fix: fixed e2e tests
* fix: fixed e2e tests
* fix: auto fixes
* fix: pr clean up
* fix: removing console log
* fix: PR updates
* fix: the reviewed stage boolean required the expected state to change. Also I progressed the command bar too soon
* fix: no idea how this passed locally yesterday? I removed the {dir} unused but I need the function's logic but not the return value...
* fix: should be good to go?
---------
Co-authored-by: Frank Noirot <frankjohnson1993@gmail.com>
2025-04-29 13:04:45 -05:00
|
|
|
import { createApplicationCommands } from '@src/lib/commandBarConfigs/applicationCommandConfig'
|
2023-10-11 13:36:54 +11:00
|
|
|
|
2024-11-07 17:23:03 -05:00
|
|
|
markOnce('code/willAuth')
|
2025-01-08 10:58:41 -05:00
|
|
|
initializeWindowExceptionHandler()
|
|
|
|
|
|
2023-11-24 08:59:24 +11:00
|
|
|
// uncomment for xstate inspector
|
2024-02-11 12:59:00 +11:00
|
|
|
// import { DEV } from 'env'
|
|
|
|
|
// import { inspect } from '@xstate/inspect'
|
2023-11-24 08:59:24 +11:00
|
|
|
// if (DEV)
|
|
|
|
|
// inspect({
|
|
|
|
|
// iframe: false,
|
|
|
|
|
// })
|
2022-11-12 13:11:54 +11:00
|
|
|
|
2025-02-21 13:47:36 -05:00
|
|
|
// Don't start the app machine until all these singletons
|
|
|
|
|
// are initialized, and the wasm module is loaded.
|
|
|
|
|
initPromise
|
|
|
|
|
.then(() => {
|
|
|
|
|
appActor.start()
|
[Feature]: Load external model becomes Add file to project, global application add file to project with home page update. (#6506)
* 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??
* feat: implemented load external for kcl samples
* feat: load external model from disk
* fix: trying to delete old stuff
* fix: all command trigger locations now have defaults for current project
* fix: gotcha comment for the future
* chore: hiding import file from url command, two separate commands for 3d and kcl file adding
* chore: commands are now add file to project, 3rd iteration
* fix: t2c in file menu fixed
* chore: updating file menu for new global actions
* fix: auto fixes
* fix: the command bar arg flow for web add kcl file seems backwards?
* chore: updated home layout, added create from kcl sample button
* chore: remapping some menu actions
* fix: fixing open dialog copy
* fix: an e2e test
* fix: fixed e2e tests
* fix: fixed e2e tests
* fix: auto fixes
* fix: pr clean up
* fix: removing console log
* fix: PR updates
* fix: the reviewed stage boolean required the expected state to change. Also I progressed the command bar too soon
* fix: no idea how this passed locally yesterday? I removed the {dir} unused but I need the function's logic but not the return value...
* fix: should be good to go?
---------
Co-authored-by: Frank Noirot <frankjohnson1993@gmail.com>
2025-04-29 13:04:45 -05:00
|
|
|
// Application commands must be created after the initPromise because
|
|
|
|
|
// it calls WASM functions to file extensions, this dependency is not available during initialization, it is an async dependency
|
|
|
|
|
commandBarActor.send({
|
|
|
|
|
type: 'Add commands',
|
|
|
|
|
data: {
|
|
|
|
|
commands: [...createApplicationCommands({ systemIOActor })],
|
|
|
|
|
},
|
|
|
|
|
})
|
2025-02-21 13:47:36 -05:00
|
|
|
})
|
|
|
|
|
.catch(reportRejection)
|
|
|
|
|
|
2022-11-26 08:34:23 +11:00
|
|
|
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement)
|
2023-07-31 06:33:10 -04:00
|
|
|
|
2023-07-26 11:47:18 -05:00
|
|
|
root.render(
|
2023-08-06 21:29:26 -04:00
|
|
|
<HotkeysProvider>
|
2024-07-12 10:57:27 +10:00
|
|
|
<AppStreamProvider>
|
|
|
|
|
<Router />
|
|
|
|
|
<Toaster
|
|
|
|
|
position="bottom-center"
|
|
|
|
|
toastOptions={{
|
|
|
|
|
style: {
|
|
|
|
|
borderRadius: '3px',
|
2024-08-14 14:26:44 -04:00
|
|
|
maxInlineSize: 'min(480px, 100%)',
|
2023-12-06 14:44:13 -05:00
|
|
|
},
|
2024-07-12 10:57:27 +10:00
|
|
|
className:
|
|
|
|
|
'bg-chalkboard-10 dark:bg-chalkboard-90 text-chalkboard-110 dark:text-chalkboard-10 rounded-sm border-chalkboard-20/50 dark:border-chalkboard-80/50',
|
|
|
|
|
success: {
|
|
|
|
|
iconTheme: {
|
|
|
|
|
primary: 'oklch(89% 0.16 143.4deg)',
|
|
|
|
|
secondary: 'oklch(48.62% 0.1654 142.5deg)',
|
|
|
|
|
},
|
2024-08-17 14:15:11 -07:00
|
|
|
// We shouldn't have a different duration in tests than prod, it might
|
|
|
|
|
// lead to issues.
|
|
|
|
|
duration: 1500,
|
2024-07-12 10:57:27 +10:00
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<ModalContainer />
|
|
|
|
|
</AppStreamProvider>
|
2023-08-06 21:29:26 -04:00
|
|
|
</HotkeysProvider>
|
2023-07-26 11:47:18 -05:00
|
|
|
)
|
2022-11-12 13:11:54 +11:00
|
|
|
|
|
|
|
|
// If you want to start measuring performance in your app, pass a function
|
|
|
|
|
// to log results (for example: reportWebVitals(console.log))
|
|
|
|
|
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
2022-11-26 08:34:23 +11:00
|
|
|
reportWebVitals()
|
2024-04-17 10:30:23 -04:00
|
|
|
|
2024-10-10 12:16:45 -04:00
|
|
|
if (isDesktop()) {
|
2025-06-05 17:12:14 -04:00
|
|
|
window.electron.onUpdateChecking(() => {
|
|
|
|
|
const message = `Checking for updates...`
|
|
|
|
|
console.log(message)
|
|
|
|
|
toast.loading(message, { id: AUTO_UPDATER_TOAST_ID })
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
window.electron.onUpdateNotAvailable(() => {
|
|
|
|
|
const message = `You're already using the latest version of the app.`
|
|
|
|
|
console.log(message)
|
|
|
|
|
toast.success(message, { id: AUTO_UPDATER_TOAST_ID })
|
|
|
|
|
})
|
|
|
|
|
|
2024-10-10 12:16:45 -04:00
|
|
|
window.electron.onUpdateDownloadStart(() => {
|
|
|
|
|
const message = `Downloading app update...`
|
|
|
|
|
console.log(message)
|
|
|
|
|
toast.loading(message, { id: AUTO_UPDATER_TOAST_ID })
|
|
|
|
|
})
|
2025-06-05 17:12:14 -04:00
|
|
|
|
2024-10-10 12:16:45 -04:00
|
|
|
window.electron.onUpdateError(({ error }) => {
|
|
|
|
|
console.error(error)
|
|
|
|
|
toast.error('An error occurred while downloading the update.', {
|
|
|
|
|
id: AUTO_UPDATER_TOAST_ID,
|
|
|
|
|
})
|
|
|
|
|
})
|
2025-06-05 17:12:14 -04:00
|
|
|
|
2024-10-15 07:30:00 -04:00
|
|
|
window.electron.onUpdateDownloaded(({ version, releaseNotes }) => {
|
2024-09-24 13:55:42 -04:00
|
|
|
const message = `A new update (${version}) was downloaded and will be available next time you open the app.`
|
|
|
|
|
console.log(message)
|
|
|
|
|
toast.custom(
|
|
|
|
|
ToastUpdate({
|
|
|
|
|
version,
|
2024-10-15 07:30:00 -04:00
|
|
|
releaseNotes,
|
2024-09-24 13:55:42 -04:00
|
|
|
onRestart: () => {
|
|
|
|
|
window.electron.appRestart()
|
|
|
|
|
},
|
2024-10-15 07:30:00 -04:00
|
|
|
onDismiss: () => {},
|
2024-09-24 13:55:42 -04:00
|
|
|
}),
|
2024-10-10 12:16:45 -04:00
|
|
|
{ duration: 30000, id: AUTO_UPDATER_TOAST_ID }
|
2024-09-24 13:55:42 -04:00
|
|
|
)
|
|
|
|
|
})
|
2024-10-10 12:16:45 -04:00
|
|
|
}
|