fix: massive fix for circular depsga!
This commit is contained in:
@ -39,7 +39,7 @@ import {
|
|||||||
engineStreamActor,
|
engineStreamActor,
|
||||||
useSettings,
|
useSettings,
|
||||||
useToken,
|
useToken,
|
||||||
} from '@src/machines/appMachine'
|
} from '@src/lib/singletons'
|
||||||
import { commandBarActor } from '@src/machines/commandBarMachine'
|
import { commandBarActor } from '@src/machines/commandBarMachine'
|
||||||
import { EngineStreamTransition } from '@src/machines/engineStreamMachine'
|
import { EngineStreamTransition } from '@src/machines/engineStreamMachine'
|
||||||
import { onboardingPaths } from '@src/routes/Onboarding/paths'
|
import { onboardingPaths } from '@src/routes/Onboarding/paths'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import Loading from '@src/components/Loading'
|
import Loading from '@src/components/Loading'
|
||||||
import { useAuthState } from '@src/machines/appMachine'
|
import { useAuthState } from '@src/lib/singletons'
|
||||||
|
|
||||||
// Wrapper around protected routes, used in src/Router.tsx
|
// Wrapper around protected routes, used in src/Router.tsx
|
||||||
export const Auth = ({ children }: React.PropsWithChildren) => {
|
export const Auth = ({ children }: React.PropsWithChildren) => {
|
||||||
|
@ -35,7 +35,7 @@ import {
|
|||||||
rustContext,
|
rustContext,
|
||||||
} from '@src/lib/singletons'
|
} from '@src/lib/singletons'
|
||||||
import { reportRejection } from '@src/lib/trap'
|
import { reportRejection } from '@src/lib/trap'
|
||||||
import { useToken } from '@src/machines/appMachine'
|
import { useToken } from '@src/lib/singletons'
|
||||||
import RootLayout from '@src/Root'
|
import RootLayout from '@src/Root'
|
||||||
import Home from '@src/routes/Home'
|
import Home from '@src/routes/Home'
|
||||||
import Onboarding, { onboardingRoutes } from '@src/routes/Onboarding'
|
import Onboarding, { onboardingRoutes } from '@src/routes/Onboarding'
|
||||||
|
@ -40,7 +40,7 @@ import {
|
|||||||
} from '@src/lib/singletons'
|
} from '@src/lib/singletons'
|
||||||
import { err, reportRejection, trap } from '@src/lib/trap'
|
import { err, reportRejection, trap } from '@src/lib/trap'
|
||||||
import { throttle, toSync } from '@src/lib/utils'
|
import { throttle, toSync } from '@src/lib/utils'
|
||||||
import type { useSettings } from '@src/machines/appMachine'
|
import type { useSettings } from '@src/lib/singletons'
|
||||||
import { commandBarActor } from '@src/machines/commandBarMachine'
|
import { commandBarActor } from '@src/machines/commandBarMachine'
|
||||||
import type { SegmentOverlay } from '@src/machines/modelingMachine'
|
import type { SegmentOverlay } from '@src/machines/modelingMachine'
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import { RefreshButton } from '@src/components/RefreshButton'
|
|||||||
import UserSidebarMenu from '@src/components/UserSidebarMenu'
|
import UserSidebarMenu from '@src/components/UserSidebarMenu'
|
||||||
import { isDesktop } from '@src/lib/isDesktop'
|
import { isDesktop } from '@src/lib/isDesktop'
|
||||||
import { type IndexLoaderData } from '@src/lib/types'
|
import { type IndexLoaderData } from '@src/lib/types'
|
||||||
import { useUser } from '@src/machines/appMachine'
|
import { useUser } from '@src/lib/singletons'
|
||||||
|
|
||||||
import styles from './AppHeader.module.css'
|
import styles from './AppHeader.module.css'
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Switch } from '@headlessui/react'
|
import { Switch } from '@headlessui/react'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
import { settingsActor, useSettings } from '@src/machines/appMachine'
|
import { settingsActor, useSettings } from '@src/lib/singletons'
|
||||||
|
|
||||||
export function CameraProjectionToggle() {
|
export function CameraProjectionToggle() {
|
||||||
const settings = useSettings()
|
const settings = useSettings()
|
||||||
|
@ -29,7 +29,7 @@ import { err } from '@src/lib/trap'
|
|||||||
import { useCalculateKclExpression } from '@src/lib/useCalculateKclExpression'
|
import { useCalculateKclExpression } from '@src/lib/useCalculateKclExpression'
|
||||||
import { roundOff } from '@src/lib/utils'
|
import { roundOff } from '@src/lib/utils'
|
||||||
import { varMentions } from '@src/lib/varCompletionExtension'
|
import { varMentions } from '@src/lib/varCompletionExtension'
|
||||||
import { useSettings } from '@src/machines/appMachine'
|
import { useSettings } from '@src/lib/singletons'
|
||||||
import {
|
import {
|
||||||
commandBarActor,
|
commandBarActor,
|
||||||
useCommandBarState,
|
useCommandBarState,
|
||||||
|
@ -3,7 +3,7 @@ import { useState } from 'react'
|
|||||||
|
|
||||||
import { ActionButton } from '@src/components/ActionButton'
|
import { ActionButton } from '@src/components/ActionButton'
|
||||||
import { CREATE_FILE_URL_PARAM } from '@src/lib/constants'
|
import { CREATE_FILE_URL_PARAM } from '@src/lib/constants'
|
||||||
import { useSettings } from '@src/machines/appMachine'
|
import { useSettings } from '@src/lib/singletons'
|
||||||
import { useSearchParams } from 'react-router-dom'
|
import { useSearchParams } from 'react-router-dom'
|
||||||
|
|
||||||
const DownloadAppBanner = () => {
|
const DownloadAppBanner = () => {
|
||||||
|
@ -18,7 +18,7 @@ import { REASONABLE_TIME_TO_REFRESH_STREAM_SIZE } from '@src/lib/timings'
|
|||||||
import { err, reportRejection, trap } from '@src/lib/trap'
|
import { err, reportRejection, trap } from '@src/lib/trap'
|
||||||
import type { IndexLoaderData } from '@src/lib/types'
|
import type { IndexLoaderData } from '@src/lib/types'
|
||||||
import { uuidv4 } from '@src/lib/utils'
|
import { uuidv4 } from '@src/lib/utils'
|
||||||
import { engineStreamActor, useSettings } from '@src/machines/appMachine'
|
import { engineStreamActor, useSettings } from '@src/lib/singletons'
|
||||||
import { useCommandBarState } from '@src/machines/commandBarMachine'
|
import { useCommandBarState } from '@src/machines/commandBarMachine'
|
||||||
import {
|
import {
|
||||||
EngineStreamState,
|
EngineStreamState,
|
||||||
|
@ -33,7 +33,7 @@ import { markOnce } from '@src/lib/performance'
|
|||||||
import { codeManager, kclManager } from '@src/lib/singletons'
|
import { codeManager, kclManager } from '@src/lib/singletons'
|
||||||
import { err, reportRejection } from '@src/lib/trap'
|
import { err, reportRejection } from '@src/lib/trap'
|
||||||
import { type IndexLoaderData } from '@src/lib/types'
|
import { type IndexLoaderData } from '@src/lib/types'
|
||||||
import { useSettings, useToken } from '@src/machines/appMachine'
|
import { useSettings, useToken } from '@src/lib/singletons'
|
||||||
import { commandBarActor } from '@src/machines/commandBarMachine'
|
import { commandBarActor } from '@src/machines/commandBarMachine'
|
||||||
import { fileMachine } from '@src/machines/fileMachine'
|
import { fileMachine } from '@src/machines/fileMachine'
|
||||||
import { modelingMenuCallbackMostActions } from '@src/menu/register'
|
import { modelingMenuCallbackMostActions } from '@src/menu/register'
|
||||||
|
@ -27,7 +27,7 @@ import { useModelingContext } from '@src/hooks/useModelingContext'
|
|||||||
import { AxisNames } from '@src/lib/constants'
|
import { AxisNames } from '@src/lib/constants'
|
||||||
import { sceneInfra } from '@src/lib/singletons'
|
import { sceneInfra } from '@src/lib/singletons'
|
||||||
import { reportRejection } from '@src/lib/trap'
|
import { reportRejection } from '@src/lib/trap'
|
||||||
import { useSettings } from '@src/machines/appMachine'
|
import { useSettings } from '@src/lib/singletons'
|
||||||
|
|
||||||
const CANVAS_SIZE = 80
|
const CANVAS_SIZE = 80
|
||||||
const FRUSTUM_SIZE = 0.5
|
const FRUSTUM_SIZE = 0.5
|
||||||
|
@ -10,7 +10,7 @@ import { createAndOpenNewTutorialProject } from '@src/lib/desktopFS'
|
|||||||
import { openExternalBrowserIfDesktop } from '@src/lib/openWindow'
|
import { openExternalBrowserIfDesktop } from '@src/lib/openWindow'
|
||||||
import { PATHS } from '@src/lib/paths'
|
import { PATHS } from '@src/lib/paths'
|
||||||
import { reportRejection } from '@src/lib/trap'
|
import { reportRejection } from '@src/lib/trap'
|
||||||
import { settingsActor } from '@src/machines/appMachine'
|
import { settingsActor } from '@src/lib/singletons'
|
||||||
import type { WebContentSendPayload } from '@src/menu/channels'
|
import type { WebContentSendPayload } from '@src/menu/channels'
|
||||||
|
|
||||||
const HelpMenuDivider = () => (
|
const HelpMenuDivider = () => (
|
||||||
|
@ -27,7 +27,7 @@ import { PATHS } from '@src/lib/paths'
|
|||||||
import type { FileEntry } from '@src/lib/project'
|
import type { FileEntry } from '@src/lib/project'
|
||||||
import { codeManager } from '@src/lib/singletons'
|
import { codeManager } from '@src/lib/singletons'
|
||||||
import { err } from '@src/lib/trap'
|
import { err } from '@src/lib/trap'
|
||||||
import { useToken } from '@src/machines/appMachine'
|
import { useToken } from '@src/lib/singletons'
|
||||||
|
|
||||||
function getWorkspaceFolders(): LSP.WorkspaceFolder[] {
|
function getWorkspaceFolders(): LSP.WorkspaceFolder[] {
|
||||||
return []
|
return []
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { engineStreamActor } from '@src/machines/appMachine'
|
import { engineStreamActor } from '@src/lib/singletons'
|
||||||
import { EngineStreamState } from '@src/machines/engineStreamMachine'
|
import { EngineStreamState } from '@src/machines/engineStreamMachine'
|
||||||
import { useSelector } from '@xstate/react'
|
import { useSelector } from '@xstate/react'
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ import { submitAndAwaitTextToKcl } from '@src/lib/textToCad'
|
|||||||
import { err, reject, reportRejection, trap } from '@src/lib/trap'
|
import { err, reject, reportRejection, trap } from '@src/lib/trap'
|
||||||
import type { IndexLoaderData } from '@src/lib/types'
|
import type { IndexLoaderData } from '@src/lib/types'
|
||||||
import { platform, uuidv4 } from '@src/lib/utils'
|
import { platform, uuidv4 } from '@src/lib/utils'
|
||||||
import { useSettings, useToken } from '@src/machines/appMachine'
|
import { useSettings, useToken } from '@src/lib/singletons'
|
||||||
import { commandBarActor } from '@src/machines/commandBarMachine'
|
import { commandBarActor } from '@src/machines/commandBarMachine'
|
||||||
import { kclEditorActor } from '@src/machines/kclEditorMachine'
|
import { kclEditorActor } from '@src/machines/kclEditorMachine'
|
||||||
import {
|
import {
|
||||||
|
@ -5,7 +5,7 @@ import { ActionButton } from '@src/components/ActionButton'
|
|||||||
import { ActionIcon } from '@src/components/ActionIcon'
|
import { ActionIcon } from '@src/components/ActionIcon'
|
||||||
import type { CustomIconName } from '@src/components/CustomIcon'
|
import type { CustomIconName } from '@src/components/CustomIcon'
|
||||||
import Tooltip from '@src/components/Tooltip'
|
import Tooltip from '@src/components/Tooltip'
|
||||||
import { useSettings } from '@src/machines/appMachine'
|
import { useSettings } from '@src/lib/singletons'
|
||||||
import { onboardingPaths } from '@src/routes/Onboarding/paths'
|
import { onboardingPaths } from '@src/routes/Onboarding/paths'
|
||||||
|
|
||||||
import styles from './ModelingPane.module.css'
|
import styles from './ModelingPane.module.css'
|
||||||
|
@ -47,7 +47,7 @@ import { codeManagerHistoryCompartment } from '@src/lang/codeManager'
|
|||||||
import { codeManager, editorManager, kclManager } from '@src/lib/singletons'
|
import { codeManager, editorManager, kclManager } from '@src/lib/singletons'
|
||||||
import { Themes, getSystemTheme } from '@src/lib/theme'
|
import { Themes, getSystemTheme } from '@src/lib/theme'
|
||||||
import { onMouseDragMakeANewNumber, onMouseDragRegex } from '@src/lib/utils'
|
import { onMouseDragMakeANewNumber, onMouseDragRegex } from '@src/lib/utils'
|
||||||
import { useSettings } from '@src/machines/appMachine'
|
import { useSettings } from '@src/lib/singletons'
|
||||||
import {
|
import {
|
||||||
editorIsMountedSelector,
|
editorIsMountedSelector,
|
||||||
kclEditorActor,
|
kclEditorActor,
|
||||||
|
@ -22,7 +22,7 @@ import { useKclContext } from '@src/lang/KclProvider'
|
|||||||
import { EngineConnectionStateType } from '@src/lang/std/engineConnection'
|
import { EngineConnectionStateType } from '@src/lang/std/engineConnection'
|
||||||
import { SIDEBAR_BUTTON_SUFFIX } from '@src/lib/constants'
|
import { SIDEBAR_BUTTON_SUFFIX } from '@src/lib/constants'
|
||||||
import { isDesktop } from '@src/lib/isDesktop'
|
import { isDesktop } from '@src/lib/isDesktop'
|
||||||
import { useSettings } from '@src/machines/appMachine'
|
import { useSettings } from '@src/lib/singletons'
|
||||||
import { commandBarActor } from '@src/machines/commandBarMachine'
|
import { commandBarActor } from '@src/machines/commandBarMachine'
|
||||||
import { onboardingPaths } from '@src/routes/Onboarding/paths'
|
import { onboardingPaths } from '@src/routes/Onboarding/paths'
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import {
|
|||||||
kclManager,
|
kclManager,
|
||||||
} from '@src/lib/singletons'
|
} from '@src/lib/singletons'
|
||||||
import { type IndexLoaderData } from '@src/lib/types'
|
import { type IndexLoaderData } from '@src/lib/types'
|
||||||
import { useToken } from '@src/machines/appMachine'
|
import { useToken } from '@src/lib/singletons'
|
||||||
import { commandBarActor } from '@src/machines/commandBarMachine'
|
import { commandBarActor } from '@src/machines/commandBarMachine'
|
||||||
|
|
||||||
const ProjectSidebarMenu = ({
|
const ProjectSidebarMenu = ({
|
||||||
|
@ -33,7 +33,7 @@ import { PATHS } from '@src/lib/paths'
|
|||||||
import type { Project } from '@src/lib/project'
|
import type { Project } from '@src/lib/project'
|
||||||
import { codeManager, kclManager } from '@src/lib/singletons'
|
import { codeManager, kclManager } from '@src/lib/singletons'
|
||||||
import { err } from '@src/lib/trap'
|
import { err } from '@src/lib/trap'
|
||||||
import { useSettings } from '@src/machines/appMachine'
|
import { useSettings } from '@src/lib/singletons'
|
||||||
import { commandBarActor } from '@src/machines/commandBarMachine'
|
import { commandBarActor } from '@src/machines/commandBarMachine'
|
||||||
import { projectsMachine } from '@src/machines/projectsMachine'
|
import { projectsMachine } from '@src/machines/projectsMachine'
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { useFileSystemWatcher } from '@src/hooks/useFileSystemWatcher'
|
import { useFileSystemWatcher } from '@src/hooks/useFileSystemWatcher'
|
||||||
import { PATHS } from '@src/lib/paths'
|
import { PATHS } from '@src/lib/paths'
|
||||||
import { systemIOActor, useSettings } from '@src/machines/appMachine'
|
import { systemIOActor, useSettings } from '@src/lib/singletons'
|
||||||
import {
|
import {
|
||||||
useHasListedProjects,
|
useHasListedProjects,
|
||||||
useProjectDirectoryPath,
|
useProjectDirectoryPath,
|
||||||
|
@ -13,7 +13,7 @@ import {
|
|||||||
} from '@src/lib/singletons'
|
} from '@src/lib/singletons'
|
||||||
import { reportRejection } from '@src/lib/trap'
|
import { reportRejection } from '@src/lib/trap'
|
||||||
import { toSync } from '@src/lib/utils'
|
import { toSync } from '@src/lib/utils'
|
||||||
import { useToken } from '@src/machines/appMachine'
|
import { useToken } from '@src/lib/singletons'
|
||||||
import type { WebContentSendPayload } from '@src/menu/channels'
|
import type { WebContentSendPayload } from '@src/menu/channels'
|
||||||
|
|
||||||
export const RefreshButton = ({ children }: React.PropsWithChildren) => {
|
export const RefreshButton = ({ children }: React.PropsWithChildren) => {
|
||||||
|
@ -18,7 +18,7 @@ import { markOnce } from '@src/lib/performance'
|
|||||||
import { loadAndValidateSettings } from '@src/lib/settings/settingsUtils'
|
import { loadAndValidateSettings } from '@src/lib/settings/settingsUtils'
|
||||||
import { trap } from '@src/lib/trap'
|
import { trap } from '@src/lib/trap'
|
||||||
import type { IndexLoaderData } from '@src/lib/types'
|
import type { IndexLoaderData } from '@src/lib/types'
|
||||||
import { settingsActor, useSettings } from '@src/machines/appMachine'
|
import { settingsActor, useSettings } from '@src/lib/singletons'
|
||||||
|
|
||||||
export const RouteProviderContext = createContext({})
|
export const RouteProviderContext = createContext({})
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ import {
|
|||||||
} from '@src/lib/settings/settingsUtils'
|
} from '@src/lib/settings/settingsUtils'
|
||||||
import { reportRejection } from '@src/lib/trap'
|
import { reportRejection } from '@src/lib/trap'
|
||||||
import { toSync } from '@src/lib/utils'
|
import { toSync } from '@src/lib/utils'
|
||||||
import { settingsActor, useSettings } from '@src/machines/appMachine'
|
import { settingsActor, useSettings } from '@src/lib/singletons'
|
||||||
import { APP_VERSION, IS_NIGHTLY, getReleaseUrl } from '@src/routes/utils'
|
import { APP_VERSION, IS_NIGHTLY, getReleaseUrl } from '@src/routes/utils'
|
||||||
import { waitFor } from 'xstate'
|
import { waitFor } from 'xstate'
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import type {
|
|||||||
WildcardSetEvent,
|
WildcardSetEvent,
|
||||||
} from '@src/lib/settings/settingsTypes'
|
} from '@src/lib/settings/settingsTypes'
|
||||||
import { getSettingInputType } from '@src/lib/settings/settingsUtils'
|
import { getSettingInputType } from '@src/lib/settings/settingsUtils'
|
||||||
import { settingsActor, useSettings } from '@src/machines/appMachine'
|
import { settingsActor, useSettings } from '@src/lib/singletons'
|
||||||
|
|
||||||
interface SettingsFieldInputProps {
|
interface SettingsFieldInputProps {
|
||||||
// We don't need the fancy types here,
|
// We don't need the fancy types here,
|
||||||
|
@ -8,7 +8,7 @@ import { useNavigate } from 'react-router-dom'
|
|||||||
import { CustomIcon } from '@src/components/CustomIcon'
|
import { CustomIcon } from '@src/components/CustomIcon'
|
||||||
import { interactionMap } from '@src/lib/settings/initialKeybindings'
|
import { interactionMap } from '@src/lib/settings/initialKeybindings'
|
||||||
import type { SettingsLevel } from '@src/lib/settings/settingsTypes'
|
import type { SettingsLevel } from '@src/lib/settings/settingsTypes'
|
||||||
import { useSettings } from '@src/machines/appMachine'
|
import { useSettings } from '@src/lib/singletons'
|
||||||
|
|
||||||
type ExtendedSettingsLevel = SettingsLevel | 'keybindings'
|
type ExtendedSettingsLevel = SettingsLevel | 'keybindings'
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import decamelize from 'decamelize'
|
|||||||
import type { Setting } from '@src/lib/settings/initialSettings'
|
import type { Setting } from '@src/lib/settings/initialSettings'
|
||||||
import type { SettingsLevel } from '@src/lib/settings/settingsTypes'
|
import type { SettingsLevel } from '@src/lib/settings/settingsTypes'
|
||||||
import { shouldHideSetting } from '@src/lib/settings/settingsUtils'
|
import { shouldHideSetting } from '@src/lib/settings/settingsUtils'
|
||||||
import { useSettings } from '@src/machines/appMachine'
|
import { useSettings } from '@src/lib/singletons'
|
||||||
|
|
||||||
interface SettingsSectionsListProps {
|
interface SettingsSectionsListProps {
|
||||||
searchParamTab: SettingsLevel
|
searchParamTab: SettingsLevel
|
||||||
|
@ -11,7 +11,7 @@ import { useAbsoluteFilePath } from '@src/hooks/useAbsoluteFilePath'
|
|||||||
import usePlatform from '@src/hooks/usePlatform'
|
import usePlatform from '@src/hooks/usePlatform'
|
||||||
import { isDesktop } from '@src/lib/isDesktop'
|
import { isDesktop } from '@src/lib/isDesktop'
|
||||||
import { PATHS } from '@src/lib/paths'
|
import { PATHS } from '@src/lib/paths'
|
||||||
import { authActor } from '@src/machines/appMachine'
|
import { authActor } from '@src/lib/singletons'
|
||||||
|
|
||||||
type User = Models['User_type']
|
type User = Models['User_type']
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import type { AxisNames } from '@src/lib/constants'
|
|||||||
import { VIEW_NAMES_SEMANTIC } from '@src/lib/constants'
|
import { VIEW_NAMES_SEMANTIC } from '@src/lib/constants'
|
||||||
import { sceneInfra } from '@src/lib/singletons'
|
import { sceneInfra } from '@src/lib/singletons'
|
||||||
import { reportRejection } from '@src/lib/trap'
|
import { reportRejection } from '@src/lib/trap'
|
||||||
import { useSettings } from '@src/machines/appMachine'
|
import { useSettings } from '@src/lib/singletons'
|
||||||
|
|
||||||
export function useViewControlMenuItems() {
|
export function useViewControlMenuItems() {
|
||||||
const { state: modelingState, send: modelingSend } = useModelingContext()
|
const { state: modelingState, send: modelingSend } = useModelingContext()
|
||||||
|
@ -2,7 +2,7 @@ import { useEffect } from 'react'
|
|||||||
import { useLocation, useNavigate } from 'react-router-dom'
|
import { useLocation, useNavigate } from 'react-router-dom'
|
||||||
|
|
||||||
import { PATHS } from '@src/lib/paths'
|
import { PATHS } from '@src/lib/paths'
|
||||||
import { useAuthState } from '@src/machines/appMachine'
|
import { useAuthState } from '@src/lib/singletons'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple hook that listens to the auth state of the app and navigates
|
* A simple hook that listens to the auth state of the app and navigates
|
||||||
|
@ -9,7 +9,7 @@ import { CREATE_FILE_URL_PARAM, DEFAULT_FILE_NAME } from '@src/lib/constants'
|
|||||||
import { isDesktop } from '@src/lib/isDesktop'
|
import { isDesktop } from '@src/lib/isDesktop'
|
||||||
import type { FileLinkParams } from '@src/lib/links'
|
import type { FileLinkParams } from '@src/lib/links'
|
||||||
import { PATHS } from '@src/lib/paths'
|
import { PATHS } from '@src/lib/paths'
|
||||||
import { useSettings } from '@src/machines/appMachine'
|
import { useSettings } from '@src/lib/singletons'
|
||||||
|
|
||||||
// For initializing the command arguments, we actually want `method` to be undefined
|
// For initializing the command arguments, we actually want `method` to be undefined
|
||||||
// so that we don't skip it in the command palette.
|
// so that we don't skip it in the command palette.
|
||||||
|
@ -27,7 +27,7 @@ import {
|
|||||||
} from '@src/lib/singletons'
|
} from '@src/lib/singletons'
|
||||||
import { err, reportRejection } from '@src/lib/trap'
|
import { err, reportRejection } from '@src/lib/trap'
|
||||||
import { getModuleId } from '@src/lib/utils'
|
import { getModuleId } from '@src/lib/utils'
|
||||||
import { engineStreamActor } from '@src/machines/appMachine'
|
import { engineStreamActor } from '@src/lib/singletons'
|
||||||
import { EngineStreamState } from '@src/machines/engineStreamMachine'
|
import { EngineStreamState } from '@src/machines/engineStreamMachine'
|
||||||
import type {
|
import type {
|
||||||
EdgeCutInfo,
|
EdgeCutInfo,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Themes, getSystemTheme } from '@src/lib/theme'
|
import { Themes, getSystemTheme } from '@src/lib/theme'
|
||||||
import { useSettings } from '@src/machines/appMachine'
|
import { useSettings } from '@src/lib/singletons'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves the current theme based on the theme setting
|
* Resolves the current theme based on the theme setting
|
||||||
|
@ -13,7 +13,7 @@ import { initializeWindowExceptionHandler } from '@src/lib/exceptions'
|
|||||||
import { isDesktop } from '@src/lib/isDesktop'
|
import { isDesktop } from '@src/lib/isDesktop'
|
||||||
import { markOnce } from '@src/lib/performance'
|
import { markOnce } from '@src/lib/performance'
|
||||||
import { reportRejection } from '@src/lib/trap'
|
import { reportRejection } from '@src/lib/trap'
|
||||||
import { appActor } from '@src/machines/appMachine'
|
import { appActor } from '@src/lib/singletons'
|
||||||
import reportWebVitals from '@src/reportWebVitals'
|
import reportWebVitals from '@src/reportWebVitals'
|
||||||
|
|
||||||
markOnce('code/willAuth')
|
markOnce('code/willAuth')
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { Command } from '@src/lib/commandTypes'
|
import type { Command } from '@src/lib/commandTypes'
|
||||||
import { authActor } from '@src/machines/appMachine'
|
import { authActor } from '@src/lib/singletons'
|
||||||
import { ACTOR_IDS } from '@src/machines/machineConstants'
|
import { ACTOR_IDS } from '@src/machines/machineConstants'
|
||||||
|
|
||||||
export const authCommands: Command[] = [
|
export const authCommands: Command[] = [
|
||||||
|
@ -12,7 +12,7 @@ import type { Command, CommandArgumentOption } from '@src/lib/commandTypes'
|
|||||||
import { engineCommandManager } from '@src/lib/singletons'
|
import { engineCommandManager } from '@src/lib/singletons'
|
||||||
import { err, reportRejection } from '@src/lib/trap'
|
import { err, reportRejection } from '@src/lib/trap'
|
||||||
import { uuidv4 } from '@src/lib/utils'
|
import { uuidv4 } from '@src/lib/utils'
|
||||||
import { getSettings, settingsActor } from '@src/machines/appMachine'
|
import { getSettings, settingsActor } from '@src/lib/singletons'
|
||||||
|
|
||||||
function isWorldCoordinateSystemType(
|
function isWorldCoordinateSystemType(
|
||||||
x: string
|
x: string
|
||||||
|
@ -176,7 +176,7 @@ import {
|
|||||||
folderSnapshot,
|
folderSnapshot,
|
||||||
defaultProjectFolderNameSnapshot,
|
defaultProjectFolderNameSnapshot,
|
||||||
} from '@src/machines/systemIO/snapshotContext'
|
} from '@src/machines/systemIO/snapshotContext'
|
||||||
import { systemIOActor } from '@src/machines/appMachine'
|
import { systemIOActor } from '@src/lib/singletons'
|
||||||
import { SystemIOMachineEvents } from '@src/machines/systemIO/utils'
|
import { SystemIOMachineEvents } from '@src/machines/systemIO/utils'
|
||||||
|
|
||||||
export const openProjectCommand: Command = {
|
export const openProjectCommand: Command = {
|
||||||
|
@ -20,7 +20,7 @@ import type {
|
|||||||
HomeLoaderData,
|
HomeLoaderData,
|
||||||
IndexLoaderData,
|
IndexLoaderData,
|
||||||
} from '@src/lib/types'
|
} from '@src/lib/types'
|
||||||
import { settingsActor } from '@src/machines/appMachine'
|
import { settingsActor } from '@src/lib/singletons'
|
||||||
|
|
||||||
export const telemetryLoader: LoaderFunction = async ({
|
export const telemetryLoader: LoaderFunction = async ({
|
||||||
params,
|
params,
|
||||||
|
@ -43,7 +43,7 @@ import {
|
|||||||
isOverlap,
|
isOverlap,
|
||||||
uuidv4,
|
uuidv4,
|
||||||
} from '@src/lib/utils'
|
} from '@src/lib/utils'
|
||||||
import { engineStreamActor } from '@src/machines/appMachine'
|
import { engineStreamActor } from '@src/lib/singletons'
|
||||||
import type { ModelingMachineEvent } from '@src/machines/modelingMachine'
|
import type { ModelingMachineEvent } from '@src/machines/modelingMachine'
|
||||||
import { showUnsupportedSelectionToast } from '@src/components/ToastUnsupportedSelection'
|
import { showUnsupportedSelectionToast } from '@src/components/ToastUnsupportedSelection'
|
||||||
|
|
||||||
|
@ -456,7 +456,7 @@ export function getSettingInputType(setting: Setting) {
|
|||||||
export const jsAppSettings = async () => {
|
export const jsAppSettings = async () => {
|
||||||
let jsAppSettings = default_app_settings()
|
let jsAppSettings = default_app_settings()
|
||||||
if (!TEST) {
|
if (!TEST) {
|
||||||
const settings = await import('@src/machines/appMachine').then((module) =>
|
const settings = await import('@src/lib/singletons').then((module) =>
|
||||||
module.getSettings()
|
module.getSettings()
|
||||||
)
|
)
|
||||||
if (settings) {
|
if (settings) {
|
||||||
|
@ -74,7 +74,7 @@ if (typeof window !== 'undefined') {
|
|||||||
;(window as any).enableMousePositionLogs = () =>
|
;(window as any).enableMousePositionLogs = () =>
|
||||||
document.addEventListener('mousemove', (e) =>
|
document.addEventListener('mousemove', (e) =>
|
||||||
console.log(`await page.mouse.click(${e.clientX}, ${e.clientY})`)
|
console.log(`await page.mouse.click(${e.clientX}, ${e.clientY})`)
|
||||||
)
|
)
|
||||||
;(window as any).enableFillet = () => {
|
;(window as any).enableFillet = () => {
|
||||||
;(window as any)._enableFillet = true
|
;(window as any)._enableFillet = true
|
||||||
}
|
}
|
||||||
@ -90,3 +90,109 @@ if (typeof window !== 'undefined') {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
import { useSelector } from '@xstate/react'
|
||||||
|
import { createActor, setup, spawnChild } from 'xstate'
|
||||||
|
|
||||||
|
import { isDesktop } from '@src/lib/isDesktop'
|
||||||
|
import { createSettings } from '@src/lib/settings/initialSettings'
|
||||||
|
import { authMachine } from '@src/machines/authMachine'
|
||||||
|
import type { EngineStreamActor } from '@src/machines/engineStreamMachine'
|
||||||
|
import {
|
||||||
|
engineStreamContextCreate,
|
||||||
|
engineStreamMachine,
|
||||||
|
} from '@src/machines/engineStreamMachine'
|
||||||
|
import { ACTOR_IDS } from '@src/machines/machineConstants'
|
||||||
|
import { settingsMachine } from '@src/machines/settingsMachine'
|
||||||
|
import { systemIOMachineDesktop } from '@src/machines/systemIO/systemIOMachineDesktop'
|
||||||
|
import { systemIOMachineWeb } from '@src/machines/systemIO/systemIOMachineWeb'
|
||||||
|
const { AUTH, SETTINGS, SYSTEM_IO, ENGINE_STREAM } = ACTOR_IDS
|
||||||
|
const appMachineActors = {
|
||||||
|
[AUTH]: authMachine,
|
||||||
|
[SETTINGS]: settingsMachine,
|
||||||
|
[SYSTEM_IO]: isDesktop() ? systemIOMachineDesktop : systemIOMachineWeb,
|
||||||
|
[ENGINE_STREAM]: engineStreamMachine,
|
||||||
|
} as const
|
||||||
|
|
||||||
|
const appMachine = setup({
|
||||||
|
types: {} as {
|
||||||
|
children: {
|
||||||
|
auth: typeof AUTH
|
||||||
|
settings: typeof SETTINGS
|
||||||
|
systemIO: typeof SYSTEM_IO
|
||||||
|
}
|
||||||
|
},
|
||||||
|
actors: appMachineActors,
|
||||||
|
context: {} as {
|
||||||
|
codeManager: any,
|
||||||
|
kclManager: any,
|
||||||
|
engineCommandManager: any,
|
||||||
|
sceneInfra: any,
|
||||||
|
sceneEntitiesManager: any
|
||||||
|
}
|
||||||
|
}).createMachine({
|
||||||
|
id: 'modeling-app',
|
||||||
|
context:{
|
||||||
|
codeManager: codeManager,
|
||||||
|
kclManager: kclManager,
|
||||||
|
engineCommandManager: engineCommandManager,
|
||||||
|
sceneInfra: sceneInfra,
|
||||||
|
sceneEntitiesManager: sceneEntitiesManager
|
||||||
|
},
|
||||||
|
entry: [
|
||||||
|
spawnChild(AUTH, { id: AUTH, systemId: AUTH }),
|
||||||
|
spawnChild(SETTINGS, {
|
||||||
|
id: SETTINGS,
|
||||||
|
systemId: SETTINGS,
|
||||||
|
input: createSettings(),
|
||||||
|
}),
|
||||||
|
spawnChild(SYSTEM_IO, { id: SYSTEM_IO, systemId: SYSTEM_IO }),
|
||||||
|
spawnChild(ENGINE_STREAM, {
|
||||||
|
id: ENGINE_STREAM,
|
||||||
|
systemId: ENGINE_STREAM,
|
||||||
|
input: engineStreamContextCreate(),
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
export const appActor = createActor(appMachine, {
|
||||||
|
systemId: 'root',
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GOTCHA: the type coercion of this actor works because it is spawned for
|
||||||
|
* the lifetime of {appActor}, but would not work if it were invoked
|
||||||
|
* or if it were destroyed under any conditions during {appActor}'s life
|
||||||
|
*/
|
||||||
|
export const authActor = appActor.getSnapshot().children.auth!
|
||||||
|
export const useAuthState = () => useSelector(authActor, (state) => state)
|
||||||
|
export const useToken = () =>
|
||||||
|
useSelector(authActor, (state) => state.context.token)
|
||||||
|
export const useUser = () =>
|
||||||
|
useSelector(authActor, (state) => state.context.user)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GOTCHA: the type coercion of this actor works because it is spawned for
|
||||||
|
* the lifetime of {appActor}, but would not work if it were invoked
|
||||||
|
* or if it were destroyed under any conditions during {appActor}'s life
|
||||||
|
*/
|
||||||
|
export const settingsActor = appActor.getSnapshot().children.settings!
|
||||||
|
export const getSettings = () => {
|
||||||
|
const { currentProject: _, ...settings } = settingsActor.getSnapshot().context
|
||||||
|
return settings
|
||||||
|
}
|
||||||
|
export const useSettings = () =>
|
||||||
|
useSelector(settingsActor, (state) => {
|
||||||
|
// We have to peel everything that isn't settings off
|
||||||
|
const { currentProject, ...settings } = state.context
|
||||||
|
return settings
|
||||||
|
})
|
||||||
|
|
||||||
|
export const systemIOActor = appActor.getSnapshot().children.systemIO!
|
||||||
|
|
||||||
|
export const engineStreamActor = appActor.system.get(
|
||||||
|
ENGINE_STREAM
|
||||||
|
) as EngineStreamActor
|
||||||
|
|
||||||
|
window.actor = systemIOActor
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { engineCommandManager, sceneInfra } from '@src/lib/singletons'
|
|
||||||
import type { MutableRefObject } from 'react'
|
import type { MutableRefObject } from 'react'
|
||||||
import type { ActorRefFrom } from 'xstate'
|
import type { ActorRefFrom } from 'xstate'
|
||||||
import { assign, fromPromise, setup } from 'xstate'
|
import { assign, fromPromise, setup } from 'xstate'
|
||||||
@ -79,7 +78,7 @@ export const engineStreamMachine = setup({
|
|||||||
actors: {
|
actors: {
|
||||||
[EngineStreamTransition.Play]: fromPromise(
|
[EngineStreamTransition.Play]: fromPromise(
|
||||||
async ({
|
async ({
|
||||||
input: { context, params },
|
input: { context, params, rootContext},
|
||||||
}: {
|
}: {
|
||||||
input: { context: EngineStreamContext; params: { zoomToFit: boolean } }
|
input: { context: EngineStreamContext; params: { zoomToFit: boolean } }
|
||||||
}) => {
|
}) => {
|
||||||
@ -98,7 +97,7 @@ export const engineStreamMachine = setup({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
await sceneInfra.camControls.restoreRemoteCameraStateAndTriggerSync()
|
await rootContext.sceneInfra.camControls.restoreRemoteCameraStateAndTriggerSync()
|
||||||
|
|
||||||
video.style.display = 'block'
|
video.style.display = 'block'
|
||||||
canvas.style.display = 'none'
|
canvas.style.display = 'none'
|
||||||
@ -108,7 +107,7 @@ export const engineStreamMachine = setup({
|
|||||||
),
|
),
|
||||||
[EngineStreamTransition.Pause]: fromPromise(
|
[EngineStreamTransition.Pause]: fromPromise(
|
||||||
async ({
|
async ({
|
||||||
input: { context },
|
input: { context, rootContext },
|
||||||
}: {
|
}: {
|
||||||
input: { context: EngineStreamContext }
|
input: { context: EngineStreamContext }
|
||||||
}) => {
|
}) => {
|
||||||
@ -123,7 +122,7 @@ export const engineStreamMachine = setup({
|
|||||||
await holdOntoVideoFrameInCanvas(video, canvas)
|
await holdOntoVideoFrameInCanvas(video, canvas)
|
||||||
video.style.display = 'none'
|
video.style.display = 'none'
|
||||||
|
|
||||||
await sceneInfra.camControls.saveRemoteCameraState()
|
await rootContext.sceneInfra.camControls.saveRemoteCameraState()
|
||||||
|
|
||||||
// Make sure we're on the next frame for no flickering between canvas
|
// Make sure we're on the next frame for no flickering between canvas
|
||||||
// and the video elements.
|
// and the video elements.
|
||||||
@ -138,17 +137,18 @@ export const engineStreamMachine = setup({
|
|||||||
context.mediaStream = null
|
context.mediaStream = null
|
||||||
video.srcObject = null
|
video.srcObject = null
|
||||||
|
|
||||||
engineCommandManager.tearDown({ idleMode: true })
|
rootContext.engineCommandManager.tearDown({ idleMode: true })
|
||||||
})()
|
})()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
[EngineStreamTransition.StartOrReconfigureEngine]: fromPromise(
|
[EngineStreamTransition.StartOrReconfigureEngine]: fromPromise(
|
||||||
async ({
|
async ({
|
||||||
input: { context, event },
|
input: { context, event, rootContext },
|
||||||
}: {
|
}: {
|
||||||
input: { context: EngineStreamContext; event: any }
|
input: { context: EngineStreamContext; event: any }
|
||||||
}) => {
|
}) => {
|
||||||
|
console.log(context,event, rootContext)
|
||||||
if (!context.authToken) return
|
if (!context.authToken) return
|
||||||
|
|
||||||
const video = context.videoRef.current
|
const video = context.videoRef.current
|
||||||
@ -172,10 +172,10 @@ export const engineStreamMachine = setup({
|
|||||||
...event.settings,
|
...event.settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
engineCommandManager.settings = settingsNext
|
rootContext.engineCommandManager.settings = settingsNext
|
||||||
|
|
||||||
window.requestAnimationFrame(() => {
|
window.requestAnimationFrame(() => {
|
||||||
engineCommandManager.start({
|
rootContext.engineCommandManager.start({
|
||||||
setMediaStream: event.onMediaStream,
|
setMediaStream: event.onMediaStream,
|
||||||
setIsStreamReady: (isStreamReady: boolean) => {
|
setIsStreamReady: (isStreamReady: boolean) => {
|
||||||
event.setAppState({ isStreamReady })
|
event.setAppState({ isStreamReady })
|
||||||
@ -225,7 +225,12 @@ export const engineStreamMachine = setup({
|
|||||||
reenter: true,
|
reenter: true,
|
||||||
invoke: {
|
invoke: {
|
||||||
src: EngineStreamTransition.StartOrReconfigureEngine,
|
src: EngineStreamTransition.StartOrReconfigureEngine,
|
||||||
input: (args) => args,
|
input: (args) => ({
|
||||||
|
context: args.context,
|
||||||
|
rootContext: args.self.system.get('root').getSnapshot().context,
|
||||||
|
params: { zoomToFit: args.context.zoomToFit },
|
||||||
|
event: args.event
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
on: {
|
on: {
|
||||||
// Transition requested by engineConnection
|
// Transition requested by engineConnection
|
||||||
@ -246,6 +251,7 @@ export const engineStreamMachine = setup({
|
|||||||
src: EngineStreamTransition.Play,
|
src: EngineStreamTransition.Play,
|
||||||
input: (args) => ({
|
input: (args) => ({
|
||||||
context: args.context,
|
context: args.context,
|
||||||
|
rootContext: args.self.system.get('root').getSnapshot().context,
|
||||||
params: { zoomToFit: args.context.zoomToFit },
|
params: { zoomToFit: args.context.zoomToFit },
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -261,7 +267,11 @@ export const engineStreamMachine = setup({
|
|||||||
[EngineStreamState.Reconfiguring]: {
|
[EngineStreamState.Reconfiguring]: {
|
||||||
invoke: {
|
invoke: {
|
||||||
src: EngineStreamTransition.StartOrReconfigureEngine,
|
src: EngineStreamTransition.StartOrReconfigureEngine,
|
||||||
input: (args) => args,
|
input: (args) => ({
|
||||||
|
context: args.context,
|
||||||
|
rootContext: args.self.system.get('root').getSnapshot().context,
|
||||||
|
event: args.event
|
||||||
|
}),
|
||||||
onDone: {
|
onDone: {
|
||||||
target: EngineStreamState.Playing,
|
target: EngineStreamState.Playing,
|
||||||
},
|
},
|
||||||
@ -270,7 +280,10 @@ export const engineStreamMachine = setup({
|
|||||||
[EngineStreamState.Paused]: {
|
[EngineStreamState.Paused]: {
|
||||||
invoke: {
|
invoke: {
|
||||||
src: EngineStreamTransition.Pause,
|
src: EngineStreamTransition.Pause,
|
||||||
input: (args) => args,
|
input: (args) => ({
|
||||||
|
context: args.context,
|
||||||
|
rootContext: args.self.system.get('root').getSnapshot().context,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
on: {
|
on: {
|
||||||
[EngineStreamTransition.StartOrReconfigureEngine]: {
|
[EngineStreamTransition.StartOrReconfigureEngine]: {
|
||||||
@ -282,7 +295,11 @@ export const engineStreamMachine = setup({
|
|||||||
reenter: true,
|
reenter: true,
|
||||||
invoke: {
|
invoke: {
|
||||||
src: EngineStreamTransition.StartOrReconfigureEngine,
|
src: EngineStreamTransition.StartOrReconfigureEngine,
|
||||||
input: (args) => args,
|
input: (args) => ({
|
||||||
|
context: args.context,
|
||||||
|
rootContext: args.self.system.get('root').getSnapshot().context,
|
||||||
|
event: args.event
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
on: {
|
on: {
|
||||||
// The stream can be paused as it's resuming.
|
// The stream can be paused as it's resuming.
|
||||||
|
@ -35,13 +35,6 @@ import {
|
|||||||
saveSettings,
|
saveSettings,
|
||||||
setSettingsAtLevel,
|
setSettingsAtLevel,
|
||||||
} from '@src/lib/settings/settingsUtils'
|
} from '@src/lib/settings/settingsUtils'
|
||||||
import {
|
|
||||||
codeManager,
|
|
||||||
engineCommandManager,
|
|
||||||
kclManager,
|
|
||||||
sceneEntitiesManager,
|
|
||||||
sceneInfra,
|
|
||||||
} from '@src/lib/singletons'
|
|
||||||
import {
|
import {
|
||||||
Themes,
|
Themes,
|
||||||
darkModeMatcher,
|
darkModeMatcher,
|
||||||
@ -95,13 +88,14 @@ export const settingsMachine = setup({
|
|||||||
doNotPersist: boolean
|
doNotPersist: boolean
|
||||||
context: SettingsMachineContext
|
context: SettingsMachineContext
|
||||||
toastCallback?: () => void
|
toastCallback?: () => void
|
||||||
|
rootContext: any
|
||||||
}
|
}
|
||||||
>(async ({ input }) => {
|
>(async ({ input }) => {
|
||||||
// Without this, when a user changes the file, it'd
|
// Without this, when a user changes the file, it'd
|
||||||
// create a detection loop with the file-system watcher.
|
// create a detection loop with the file-system watcher.
|
||||||
if (input.doNotPersist) return
|
if (input.doNotPersist) return
|
||||||
|
|
||||||
codeManager.writeCausedByAppCheckedInFileTreeFileSystemWatcher = true
|
input.rootContext.codeManager.writeCausedByAppCheckedInFileTreeFileSystemWatcher = true
|
||||||
const { currentProject, ...settings } = input.context
|
const { currentProject, ...settings } = input.context
|
||||||
|
|
||||||
const val = await saveSettings(settings, currentProject?.path)
|
const val = await saveSettings(settings, currentProject?.path)
|
||||||
@ -190,20 +184,28 @@ export const settingsMachine = setup({
|
|||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
setEngineTheme: ({ context }) => {
|
setEngineTheme: ({ context, self }) => {
|
||||||
|
const rootContext = self.system.get('root').getSnapshot().context
|
||||||
|
const engineCommandManager = rootContext.engineCommandManager
|
||||||
if (engineCommandManager && context.app.theme.current) {
|
if (engineCommandManager && context.app.theme.current) {
|
||||||
engineCommandManager
|
engineCommandManager
|
||||||
.setTheme(context.app.theme.current)
|
.setTheme(context.app.theme.current)
|
||||||
.catch(reportRejection)
|
.catch(reportRejection)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setClientTheme: ({ context }) => {
|
setClientTheme: ({ context, self }) => {
|
||||||
|
const rootContext = self.system.get('root').getSnapshot().context
|
||||||
|
const sceneInfra = rootContext.sceneInfra
|
||||||
|
const sceneEntitiesManager = rootContext.sceneEntitiesManager
|
||||||
|
|
||||||
if (!sceneInfra || !sceneEntitiesManager) return
|
if (!sceneInfra || !sceneEntitiesManager) return
|
||||||
const opposingTheme = getOppositeTheme(context.app.theme.current)
|
const opposingTheme = getOppositeTheme(context.app.theme.current)
|
||||||
sceneInfra.theme = opposingTheme
|
sceneInfra.theme = opposingTheme
|
||||||
sceneEntitiesManager.updateSegmentBaseColor(opposingTheme)
|
sceneEntitiesManager.updateSegmentBaseColor(opposingTheme)
|
||||||
},
|
},
|
||||||
setAllowOrbitInSketchMode: ({ context }) => {
|
setAllowOrbitInSketchMode: ({ context, self }) => {
|
||||||
|
const rootContext = self.system.get('root').getSnapshot().context
|
||||||
|
const sceneInfra = rootContext.sceneInfra
|
||||||
if (!sceneInfra.camControls) return
|
if (!sceneInfra.camControls) return
|
||||||
sceneInfra.camControls._setting_allowOrbitInSketchMode =
|
sceneInfra.camControls._setting_allowOrbitInSketchMode =
|
||||||
context.app.allowOrbitInSketchMode.current
|
context.app.allowOrbitInSketchMode.current
|
||||||
@ -232,7 +234,9 @@ export const settingsMachine = setup({
|
|||||||
id: `${event.type}.success`,
|
id: `${event.type}.success`,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
'Execute AST': ({ context, event }) => {
|
'Execute AST': ({ context, event, self }) => {
|
||||||
|
const rootContext = self.system.get('root').getSnapshot().context
|
||||||
|
const kclManager = rootContext.kclManager
|
||||||
try {
|
try {
|
||||||
const relevantSetting = (s: typeof settings) => {
|
const relevantSetting = (s: typeof settings) => {
|
||||||
return (
|
return (
|
||||||
@ -345,8 +349,10 @@ export const settingsMachine = setup({
|
|||||||
currentTheme === Themes.System ? getSystemTheme() : currentTheme
|
currentTheme === Themes.System ? getSystemTheme() : currentTheme
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
setEngineCameraProjection: ({ context }) => {
|
setEngineCameraProjection: ({ context, self }) => {
|
||||||
const newCurrentProjection = context.modeling.cameraProjection.current
|
const newCurrentProjection = context.modeling.cameraProjection.current
|
||||||
|
const rootContext = self.system.get('root').getSnapshot().context
|
||||||
|
const sceneInfra = rootContext.sceneInfra
|
||||||
sceneInfra.camControls.setEngineCameraProjection(newCurrentProjection)
|
sceneInfra.camControls.setEngineCameraProjection(newCurrentProjection)
|
||||||
},
|
},
|
||||||
sendThemeToWatcher: sendTo('watchSystemTheme', ({ context }) => ({
|
sendThemeToWatcher: sendTo('watchSystemTheme', ({ context }) => ({
|
||||||
@ -532,7 +538,7 @@ export const settingsMachine = setup({
|
|||||||
console.error('Error persisting settings')
|
console.error('Error persisting settings')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
input: ({ context, event }) => {
|
input: ({ context, event, self }) => {
|
||||||
if (
|
if (
|
||||||
event.type === 'set.app.namedViews' &&
|
event.type === 'set.app.namedViews' &&
|
||||||
'toastCallback' in event.data
|
'toastCallback' in event.data
|
||||||
@ -547,6 +553,7 @@ export const settingsMachine = setup({
|
|||||||
return {
|
return {
|
||||||
doNotPersist: event.doNotPersist ?? false,
|
doNotPersist: event.doNotPersist ?? false,
|
||||||
context,
|
context,
|
||||||
|
rootContext: self.system.get('root').getSnapshot().context,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { systemIOActor } from '@src/machines/appMachine'
|
import { systemIOActor } from '@src/lib/singletons'
|
||||||
import { useSelector } from '@xstate/react'
|
import { useSelector } from '@xstate/react'
|
||||||
export const useRequestedProjectName = () =>
|
export const useRequestedProjectName = () =>
|
||||||
useSelector(systemIOActor, (state) => state.context.requestedProjectName)
|
useSelector(systemIOActor, (state) => state.context.requestedProjectName)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { systemIOActor } from '@src/machines/appMachine'
|
import { systemIOActor } from '@src/lib/singletons'
|
||||||
|
|
||||||
export const folderSnapshot = () => {
|
export const folderSnapshot = () => {
|
||||||
const { folders } = systemIOActor.getSnapshot().context
|
const { folders } = systemIOActor.getSnapshot().context
|
||||||
|
@ -190,6 +190,7 @@ export const systemIOMachine = setup({
|
|||||||
requestedProjectName: string
|
requestedProjectName: string
|
||||||
requestedFileName: string
|
requestedFileName: string
|
||||||
requestedCode: string
|
requestedCode: string
|
||||||
|
rootContext: any
|
||||||
}
|
}
|
||||||
}): Promise<{
|
}): Promise<{
|
||||||
message: string
|
message: string
|
||||||
@ -361,13 +362,14 @@ export const systemIOMachine = setup({
|
|||||||
invoke: {
|
invoke: {
|
||||||
id: SystemIOMachineActors.createKCLFile,
|
id: SystemIOMachineActors.createKCLFile,
|
||||||
src: SystemIOMachineActors.createKCLFile,
|
src: SystemIOMachineActors.createKCLFile,
|
||||||
input: ({ context, event }) => {
|
input: ({ context, event, self}) => {
|
||||||
assertEvent(event, SystemIOMachineEvents.createKCLFile)
|
assertEvent(event, SystemIOMachineEvents.createKCLFile)
|
||||||
return {
|
return {
|
||||||
context,
|
context,
|
||||||
requestedProjectName: event.data.requestedProjectName,
|
requestedProjectName: event.data.requestedProjectName,
|
||||||
requestedFileName: event.data.requestedFileName,
|
requestedFileName: event.data.requestedFileName,
|
||||||
requestedCode: event.data.requestedCode,
|
requestedCode: event.data.requestedCode,
|
||||||
|
rootContext: self.system.get('root').getSnapshot().context
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDone: {
|
onDone: {
|
||||||
|
@ -6,7 +6,6 @@ import { newKclFile } from '@src/lang/project'
|
|||||||
import { readLocalStorageProjectSettingsFile } from '@src/lib/settings/settingsUtils'
|
import { readLocalStorageProjectSettingsFile } from '@src/lib/settings/settingsUtils'
|
||||||
import { err } from '@src/lib/trap'
|
import { err } from '@src/lib/trap'
|
||||||
import { DEFAULT_DEFAULT_LENGTH_UNIT } from '@src/lib/constants'
|
import { DEFAULT_DEFAULT_LENGTH_UNIT } from '@src/lib/constants'
|
||||||
import { codeManager, kclManager } from '@src/lib/singletons'
|
|
||||||
|
|
||||||
export const systemIOMachineWeb = systemIOMachine.provide({
|
export const systemIOMachineWeb = systemIOMachine.provide({
|
||||||
actors: {
|
actors: {
|
||||||
@ -19,6 +18,7 @@ export const systemIOMachineWeb = systemIOMachine.provide({
|
|||||||
requestedProjectName: string
|
requestedProjectName: string
|
||||||
requestedFileName: string
|
requestedFileName: string
|
||||||
requestedCode: string
|
requestedCode: string
|
||||||
|
rootContext: any
|
||||||
}
|
}
|
||||||
}) => {
|
}) => {
|
||||||
// Browser version doesn't navigate, just overwrites the current file
|
// Browser version doesn't navigate, just overwrites the current file
|
||||||
@ -35,9 +35,9 @@ export const systemIOMachineWeb = systemIOMachine.provide({
|
|||||||
DEFAULT_DEFAULT_LENGTH_UNIT
|
DEFAULT_DEFAULT_LENGTH_UNIT
|
||||||
)
|
)
|
||||||
if (err(codeToWrite)) return Promise.reject(codeToWrite)
|
if (err(codeToWrite)) return Promise.reject(codeToWrite)
|
||||||
codeManager.updateCodeStateEditor(codeToWrite)
|
input.rootContext.codeManager.updateCodeStateEditor(codeToWrite)
|
||||||
await codeManager.writeToFile()
|
await input.rootContext.codeManager.writeToFile()
|
||||||
await kclManager.executeCode()
|
await input.rootContext.kclManager.executeCode()
|
||||||
return {
|
return {
|
||||||
message: 'File overwritten successfully',
|
message: 'File overwritten successfully',
|
||||||
fileName: input.requestedFileName,
|
fileName: input.requestedFileName,
|
||||||
|
@ -10,7 +10,7 @@ import {
|
|||||||
} from '@src/lib/singletons'
|
} from '@src/lib/singletons'
|
||||||
import { reportRejection } from '@src/lib/trap'
|
import { reportRejection } from '@src/lib/trap'
|
||||||
import { uuidv4 } from '@src/lib/utils'
|
import { uuidv4 } from '@src/lib/utils'
|
||||||
import { authActor, settingsActor } from '@src/machines/appMachine'
|
import { authActor, settingsActor } from '@src/lib/singletons'
|
||||||
import { commandBarActor } from '@src/machines/commandBarMachine'
|
import { commandBarActor } from '@src/machines/commandBarMachine'
|
||||||
import type { WebContentSendPayload } from '@src/menu/channels'
|
import type { WebContentSendPayload } from '@src/menu/channels'
|
||||||
import type { NavigateFunction } from 'react-router-dom'
|
import type { NavigateFunction } from 'react-router-dom'
|
||||||
|
@ -26,7 +26,7 @@ import {
|
|||||||
getSortIcon,
|
getSortIcon,
|
||||||
} from '@src/lib/sorting'
|
} from '@src/lib/sorting'
|
||||||
import { reportRejection } from '@src/lib/trap'
|
import { reportRejection } from '@src/lib/trap'
|
||||||
import { authActor, systemIOActor, useSettings } from '@src/machines/appMachine'
|
import { authActor, systemIOActor, useSettings } from '@src/lib/singletons'
|
||||||
import { commandBarActor } from '@src/machines/commandBarMachine'
|
import { commandBarActor } from '@src/machines/commandBarMachine'
|
||||||
import {
|
import {
|
||||||
useCanReadWriteProjectDirectory,
|
useCanReadWriteProjectDirectory,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { SettingsSection } from '@src/components/Settings/SettingsSection'
|
import { SettingsSection } from '@src/components/Settings/SettingsSection'
|
||||||
import type { CameraSystem } from '@src/lib/cameraControls'
|
import type { CameraSystem } from '@src/lib/cameraControls'
|
||||||
import { cameraMouseDragGuards, cameraSystems } from '@src/lib/cameraControls'
|
import { cameraMouseDragGuards, cameraSystems } from '@src/lib/cameraControls'
|
||||||
import { settingsActor, useSettings } from '@src/machines/appMachine'
|
import { settingsActor, useSettings } from '@src/lib/singletons'
|
||||||
import { onboardingPaths } from '@src/routes/Onboarding/paths'
|
import { onboardingPaths } from '@src/routes/Onboarding/paths'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -13,7 +13,7 @@ import { codeManager, kclManager } from '@src/lib/singletons'
|
|||||||
import { Themes, getSystemTheme } from '@src/lib/theme'
|
import { Themes, getSystemTheme } from '@src/lib/theme'
|
||||||
import { reportRejection } from '@src/lib/trap'
|
import { reportRejection } from '@src/lib/trap'
|
||||||
import type { IndexLoaderData } from '@src/lib/types'
|
import type { IndexLoaderData } from '@src/lib/types'
|
||||||
import { useSettings } from '@src/machines/appMachine'
|
import { useSettings } from '@src/lib/singletons'
|
||||||
import { onboardingPaths } from '@src/routes/Onboarding/paths'
|
import { onboardingPaths } from '@src/routes/Onboarding/paths'
|
||||||
|
|
||||||
import { OnboardingButtons, useDemoCode } from '@src/routes/Onboarding/utils'
|
import { OnboardingButtons, useDemoCode } from '@src/routes/Onboarding/utils'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { bracketThicknessCalculationLine } from '@src/lib/exampleKcl'
|
import { bracketThicknessCalculationLine } from '@src/lib/exampleKcl'
|
||||||
import { isDesktop } from '@src/lib/isDesktop'
|
import { isDesktop } from '@src/lib/isDesktop'
|
||||||
import { Themes, getSystemTheme } from '@src/lib/theme'
|
import { Themes, getSystemTheme } from '@src/lib/theme'
|
||||||
import { useSettings } from '@src/machines/appMachine'
|
import { useSettings } from '@src/lib/singletons'
|
||||||
import { onboardingPaths } from '@src/routes/Onboarding/paths'
|
import { onboardingPaths } from '@src/routes/Onboarding/paths'
|
||||||
|
|
||||||
import { OnboardingButtons, useDemoCode } from '@src/routes/Onboarding/utils'
|
import { OnboardingButtons, useDemoCode } from '@src/routes/Onboarding/utils'
|
||||||
|
@ -3,7 +3,7 @@ import { faArrowRight, faXmark } from '@fortawesome/free-solid-svg-icons'
|
|||||||
import { ActionButton } from '@src/components/ActionButton'
|
import { ActionButton } from '@src/components/ActionButton'
|
||||||
import { SettingsSection } from '@src/components/Settings/SettingsSection'
|
import { SettingsSection } from '@src/components/Settings/SettingsSection'
|
||||||
import { type BaseUnit, baseUnitsUnion } from '@src/lib/settings/settingsTypes'
|
import { type BaseUnit, baseUnitsUnion } from '@src/lib/settings/settingsTypes'
|
||||||
import { settingsActor, useSettings } from '@src/machines/appMachine'
|
import { settingsActor, useSettings } from '@src/lib/singletons'
|
||||||
import { onboardingPaths } from '@src/routes/Onboarding/paths'
|
import { onboardingPaths } from '@src/routes/Onboarding/paths'
|
||||||
|
|
||||||
import { useDismiss, useNextClick } from '@src/routes/Onboarding/utils'
|
import { useDismiss, useNextClick } from '@src/routes/Onboarding/utils'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
import { useUser } from '@src/machines/appMachine'
|
import { useUser } from '@src/lib/singletons'
|
||||||
import { onboardingPaths } from '@src/routes/Onboarding/paths'
|
import { onboardingPaths } from '@src/routes/Onboarding/paths'
|
||||||
|
|
||||||
import { OnboardingButtons } from '@src/routes/Onboarding/utils'
|
import { OnboardingButtons } from '@src/routes/Onboarding/utils'
|
||||||
|
@ -15,7 +15,7 @@ import { PATHS } from '@src/lib/paths'
|
|||||||
import { codeManager, editorManager, kclManager } from '@src/lib/singletons'
|
import { codeManager, editorManager, kclManager } from '@src/lib/singletons'
|
||||||
import { reportRejection } from '@src/lib/trap'
|
import { reportRejection } from '@src/lib/trap'
|
||||||
import { toSync } from '@src/lib/utils'
|
import { toSync } from '@src/lib/utils'
|
||||||
import { settingsActor } from '@src/machines/appMachine'
|
import { settingsActor } from '@src/lib/singletons'
|
||||||
import { onboardingRoutes } from '@src/routes/Onboarding'
|
import { onboardingRoutes } from '@src/routes/Onboarding'
|
||||||
import { onboardingPaths } from '@src/routes/Onboarding/paths'
|
import { onboardingPaths } from '@src/routes/Onboarding/paths'
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import { PATHS } from '@src/lib/paths'
|
|||||||
import { Themes, getSystemTheme } from '@src/lib/theme'
|
import { Themes, getSystemTheme } from '@src/lib/theme'
|
||||||
import { reportRejection } from '@src/lib/trap'
|
import { reportRejection } from '@src/lib/trap'
|
||||||
import { toSync } from '@src/lib/utils'
|
import { toSync } from '@src/lib/utils'
|
||||||
import { authActor, useSettings } from '@src/machines/appMachine'
|
import { authActor, useSettings } from '@src/lib/singletons'
|
||||||
import { APP_VERSION, IS_NIGHTLY } from '@src/routes/utils'
|
import { APP_VERSION, IS_NIGHTLY } from '@src/routes/utils'
|
||||||
|
|
||||||
const subtleBorder =
|
const subtleBorder =
|
||||||
|
Reference in New Issue
Block a user