Sort imports (#6101)

* add package.json

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

initial run;

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

updates

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

more fixes

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

clientsidescne

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

updates

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

paths

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

updates

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

updates

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

updates

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

updates

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

updates

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

updates

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

updates

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

updates

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

updates

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

updates

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

fix styles

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

updates

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

updates

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

updates

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

updates

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

updates

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

updates

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

updates

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

updates

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

updates

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

combine

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

eslint rule

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

updates

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

updates

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

fixes

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

updates

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

updates

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

updates

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

my ocd

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

updates

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

updates

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

constants file

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

updates

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

no more import sceneInfra

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

updates

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

try fix circular import

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

* updates

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

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2025-04-01 23:54:26 -07:00
committed by GitHub
parent 29f8b05f56
commit d168ef94e9
401 changed files with 5427 additions and 4716 deletions

View File

@ -1,7 +1,8 @@
import { type IndexLoaderData } from 'lib/types'
import { BROWSER_PATH, PATHS } from 'lib/paths'
import { useRouteLoaderData } from 'react-router-dom'
import { BROWSER_PATH, PATHS } from '@src/lib/paths'
import { type IndexLoaderData } from '@src/lib/types'
export function useAbsoluteFilePath() {
const routeData = useRouteLoaderData(PATHS.FILE) as IndexLoaderData

View File

@ -1,8 +1,9 @@
import { PATHS } from 'lib/paths'
import { useAuthState } from 'machines/appMachine'
import { useEffect } from 'react'
import { useLocation, useNavigate } from 'react-router-dom'
import { PATHS } from '@src/lib/paths'
import { useAuthState } from '@src/machines/appMachine'
/**
* A simple hook that listens to the auth state of the app and navigates
* accordingly.

View File

@ -1,11 +1,12 @@
import { base64ToString } from 'lib/base64'
import { CREATE_FILE_URL_PARAM, DEFAULT_FILE_NAME } from 'lib/constants'
import { useEffect } from 'react'
import { useSearchParams } from 'react-router-dom'
import { isDesktop } from 'lib/isDesktop'
import { FileLinkParams } from 'lib/links'
import { ProjectsCommandSchema } from 'lib/commandBarConfigs/projectsCommandConfig'
import { useSettings } from 'machines/appMachine'
import { base64ToString } from '@src/lib/base64'
import type { ProjectsCommandSchema } from '@src/lib/commandBarConfigs/projectsCommandConfig'
import { CREATE_FILE_URL_PARAM, DEFAULT_FILE_NAME } from '@src/lib/constants'
import { isDesktop } from '@src/lib/isDesktop'
import type { FileLinkParams } from '@src/lib/links'
import { useSettings } from '@src/machines/appMachine'
// For initializing the command arguments, we actually want `method` to be undefined
// so that we don't skip it in the command palette.
@ -45,8 +46,8 @@ export function useCreateFileLinkQuery(
? params.name.replace('.kcl', '')
: params.name
: isDesktop()
? settings.projects.defaultProjectName.current
: DEFAULT_FILE_NAME,
? settings.projects.defaultProjectName.current
: DEFAULT_FILE_NAME,
code: params.code || '',
method: isDesktop() ? undefined : 'existingProject',
}

View File

@ -1,5 +1,5 @@
// Based on https://learnersbucket.com/examples/interview/usehasfocus-hook-in-react/
import { useState, useEffect } from 'react'
import { useEffect, useState } from 'react'
export const useDocumentHasFocus = () => {
// get the initial state

View File

@ -1,28 +1,33 @@
import { useEffect, useRef } from 'react'
import { useModelingContext } from '@src/hooks/useModelingContext'
import { getNodeFromPath } from '@src/lang/queryAst'
import { getNodePathFromSourceRange } from '@src/lang/queryAstNodePathUtils'
import type { SegmentArtifact } from '@src/lang/std/artifactGraph'
import {
getArtifactOfTypes,
getCapCodeRef,
getCodeRefsByArtifactId,
getSweepFromSuspectedSweepSurface,
getWallCodeRef,
} from '@src/lang/std/artifactGraph'
import type { CallExpression, CallExpressionKw } from '@src/lang/wasm'
import { defaultSourceRange } from '@src/lang/wasm'
import type { DefaultPlaneStr } from '@src/lib/planes'
import { getEventForSelectWithPoint } from '@src/lib/selections'
import {
editorManager,
engineCommandManager,
kclManager,
rustContext,
sceneEntitiesManager,
sceneInfra,
} from 'lib/singletons'
import { useModelingContext } from './useModelingContext'
import { getEventForSelectWithPoint } from 'lib/selections'
import {
getCapCodeRef,
getSweepFromSuspectedSweepSurface,
getWallCodeRef,
getCodeRefsByArtifactId,
getArtifactOfTypes,
SegmentArtifact,
} from 'lang/std/artifactGraph'
import { err, reportRejection } from 'lib/trap'
import { getFaceDetails } from 'clientSideScene/sceneEntities'
import { DefaultPlaneStr } from 'lib/planes'
import { getNodeFromPath } from 'lang/queryAst'
import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils'
import { CallExpression, CallExpressionKw, defaultSourceRange } from 'lang/wasm'
import { EdgeCutInfo, ExtrudeFacePlane } from 'machines/modelingMachine'
import { rustContext } from 'lib/singletons'
} from '@src/lib/singletons'
import { err, reportRejection } from '@src/lib/trap'
import type {
EdgeCutInfo,
ExtrudeFacePlane,
} from '@src/machines/modelingMachine'
export function useEngineConnectionSubscriptions() {
const { send, context, state } = useModelingContext()
@ -143,7 +148,8 @@ export function useEngineConnectionSubscriptions() {
const artifact = kclManager.artifactGraph.get(planeOrFaceId)
if (artifact?.type === 'plane') {
const planeInfo = await getFaceDetails(planeOrFaceId)
const planeInfo =
await sceneEntitiesManager.getFaceDetails(planeOrFaceId)
sceneInfra.modelingSend({
type: 'Select default plane',
data: {
@ -165,7 +171,7 @@ export function useEngineConnectionSubscriptions() {
].map((num) => num / sceneInfra._baseUnitMultiplier) as [
number,
number,
number
number,
],
planeId: planeOrFaceId,
pathToNode: artifact.codeRef.pathToNode,
@ -194,10 +200,10 @@ export function useEngineConnectionSubscriptions() {
artifact.type === 'cap'
? getCapCodeRef(artifact, kclManager.artifactGraph)
: artifact.type === 'wall'
? getWallCodeRef(artifact, kclManager.artifactGraph)
: artifact.codeRef
? getWallCodeRef(artifact, kclManager.artifactGraph)
: artifact.codeRef
const faceInfo = await getFaceDetails(faceId)
const faceInfo = await sceneEntitiesManager.getFaceDetails(faceId)
if (!faceInfo?.origin || !faceInfo?.z_axis || !faceInfo?.y_axis)
return
const { z_axis, y_axis, origin } = faceInfo
@ -275,11 +281,11 @@ export function useEngineConnectionSubscriptions() {
const _faceInfo: ExtrudeFacePlane['faceInfo'] = edgeCutMeta
? edgeCutMeta
: artifact.type === 'cap'
? {
type: 'cap',
subType: artifact.subType,
}
: { type: 'wall' }
? {
type: 'cap',
subType: artifact.subType,
}
: { type: 'wall' }
const extrudePathToNode = !err(extrusion)
? getNodePathFromSourceRange(

View File

@ -1,6 +1,7 @@
import { FileContext } from 'components/FileMachineProvider'
import { useContext } from 'react'
import { FileContext } from '@src/components/FileMachineProvider'
export const useFileContext = () => {
return useContext(FileContext)
}

View File

@ -1,6 +1,7 @@
import { isDesktop } from 'lib/isDesktop'
import { reportRejection } from 'lib/trap'
import { useEffect, useState, useRef } from 'react'
import { useEffect, useRef, useState } from 'react'
import { isDesktop } from '@src/lib/isDesktop'
import { reportRejection } from '@src/lib/trap'
type Path = string

View File

@ -1,6 +1,7 @@
import { editorManager } from 'lib/singletons'
import { useEffect } from 'react'
import { editorManager } from '@src/lib/singletons'
// Kurt's note: codeMirror styling overrides were needed to make this work
// namely, the cursor needs to still be shown when the editor is not focused
// search for code-mirror-override in the repo to find the relevant styles

View File

@ -1,6 +1,8 @@
import { useEffect } from 'react'
import type { WebContentSendPayload } from '../menu/channels'
import { isDesktop } from 'lib/isDesktop'
import { isDesktop } from '@src/lib/isDesktop'
import type { WebContentSendPayload } from '@src/menu/channels'
export function useMenuListener(
callback: (data: WebContentSendPayload) => void
) {

View File

@ -1,6 +1,7 @@
import { ModelingMachineContext } from 'components/ModelingMachineProvider'
import { useContext } from 'react'
import { ModelingMachineContext } from '@src/components/ModelingMachineProvider'
export const useModelingContext = () => {
return useContext(ModelingMachineContext)
}

View File

@ -1,11 +1,13 @@
import { createContext, useContext } from 'react'
import type { NetworkStatus } from '@src/hooks/useNetworkStatus'
import { NetworkHealthState } from '@src/hooks/useNetworkStatus'
import type { EngineConnectionState } from '@src/lang/std/engineConnection'
import {
ConnectingTypeGroup,
EngineConnectionStateType,
EngineConnectionState,
initialConnectingTypeGroupState,
} from '../lang/std/engineConnection'
import { NetworkStatus, NetworkHealthState } from './useNetworkStatus'
} from '@src/lang/std/engineConnection'
export const NetworkContext = createContext<NetworkStatus>({
immediateState: {

View File

@ -1,16 +1,19 @@
import { useEffect, useState } from 'react'
import {
import type {
ConnectingType,
EngineConnectionState,
ErrorType,
} from '@src/lang/std/engineConnection'
import {
ConnectingTypeGroup,
DisconnectingType,
EngineCommandManagerEvents,
EngineConnectionEvents,
EngineConnectionStateType,
EngineConnectionState,
ErrorType,
initialConnectingTypeGroupState,
} from '../lang/std/engineConnection'
import { engineCommandManager } from '../lib/singletons'
} from '@src/lang/std/engineConnection'
import { engineCommandManager } from '@src/lib/singletons'
export enum NetworkHealthState {
Ok,
@ -69,10 +72,10 @@ export function useNetworkStatus() {
!internetConnected
? NetworkHealthState.Disconnected
: hasIssues || hasIssues === undefined
? NetworkHealthState.Issue
: pingPongHealth === 'TIMEOUT'
? NetworkHealthState.Weak
: NetworkHealthState.Ok
? NetworkHealthState.Issue
: pingPongHealth === 'TIMEOUT'
? NetworkHealthState.Weak
: NetworkHealthState.Ok
)
}, [hasIssues, internetConnected, pingPongHealth])

View File

@ -1,6 +1,8 @@
import { Platform, platform } from 'lib/utils'
import { useEffect, useState } from 'react'
import type { Platform } from '@src/lib/utils'
import { platform } from '@src/lib/utils'
export default function usePlatform() {
const [platformName, setPlatformName] = useState<Platform>('')

View File

@ -1,6 +1,7 @@
import { ProjectsMachineContext } from 'components/ProjectsContextProvider'
import { useContext } from 'react'
import { ProjectsMachineContext } from '@src/components/ProjectsContextProvider'
export const useProjectsContext = () => {
return useContext(ProjectsMachineContext)
}

View File

@ -1,9 +1,10 @@
import { trap } from 'lib/trap'
import { useState, useEffect } from 'react'
import { ensureProjectDirectoryExists, listProjects } from 'lib/desktop'
import { loadAndValidateSettings } from 'lib/settings/settingsUtils'
import { Project } from 'lib/project'
import { isDesktop } from 'lib/isDesktop'
import { useEffect, useState } from 'react'
import { ensureProjectDirectoryExists, listProjects } from '@src/lib/desktop'
import { isDesktop } from '@src/lib/isDesktop'
import type { Project } from '@src/lib/project'
import { loadAndValidateSettings } from '@src/lib/settings/settingsUtils'
import { trap } from '@src/lib/trap'
// Gotcha: This should be ported to the ProjectMachine and keep track of
// projectDirs and projectPaths in the context when it internally calls listProjects

View File

@ -1,5 +1,5 @@
import { Themes, getSystemTheme } from 'lib/theme'
import { useSettings } from 'machines/appMachine'
import { Themes, getSystemTheme } from '@src/lib/theme'
import { useSettings } from '@src/machines/appMachine'
/**
* Resolves the current theme based on the theme setting

View File

@ -1,15 +1,16 @@
import { useLayoutEffect, useEffect, useRef } from 'react'
import { engineCommandManager } from 'lib/singletons'
import { deferExecution } from 'lib/utils'
import { Themes } from 'lib/theme'
import { useModelingContext } from './useModelingContext'
import { useNetworkContext } from 'hooks/useNetworkContext'
import { useAppState, useAppStream } from 'AppState'
import { SettingsViaQueryString } from 'lib/settings/settingsTypes'
import { useAppState, useAppStream } from '@src/AppState'
import { useEffect, useLayoutEffect, useRef } from 'react'
import type { useModelingContext } from '@src/hooks/useModelingContext'
import { useNetworkContext } from '@src/hooks/useNetworkContext'
import {
EngineConnectionStateType,
DisconnectingType,
} from 'lang/std/engineConnection'
EngineConnectionStateType,
} from '@src/lang/std/engineConnection'
import type { SettingsViaQueryString } from '@src/lib/settings/settingsTypes'
import { engineCommandManager } from '@src/lib/singletons'
import { Themes } from '@src/lib/theme'
import { deferExecution } from '@src/lib/utils'
export function useSetupEngineManager(
streamRef: React.RefObject<HTMLDivElement>,

View File

@ -1,20 +1,21 @@
import { useAppState } from '@src/AppState'
import { useEffect } from 'react'
import { AnyStateMachine, Actor, StateFrom, EventFrom } from 'xstate'
import { createMachineCommand } from '../lib/createMachineCommand'
import { modelingMachine } from 'machines/modelingMachine'
import { authMachine } from 'machines/authMachine'
import { settingsMachine } from 'machines/settingsMachine'
import { projectsMachine } from 'machines/projectsMachine'
import {
import type { Actor, AnyStateMachine, EventFrom, StateFrom } from 'xstate'
import { useNetworkContext } from '@src/hooks/useNetworkContext'
import { NetworkHealthState } from '@src/hooks/useNetworkStatus'
import { useKclContext } from '@src/lang/KclProvider'
import type {
Command,
StateMachineCommandSetConfig,
StateMachineCommandSetSchema,
} from 'lib/commandTypes'
import { useKclContext } from 'lang/KclProvider'
import { useNetworkContext } from 'hooks/useNetworkContext'
import { NetworkHealthState } from 'hooks/useNetworkStatus'
import { useAppState } from 'AppState'
import { commandBarActor } from 'machines/commandBarMachine'
} from '@src/lib/commandTypes'
import { createMachineCommand } from '@src/lib/createMachineCommand'
import type { authMachine } from '@src/machines/authMachine'
import { commandBarActor } from '@src/machines/commandBarMachine'
import type { modelingMachine } from '@src/machines/modelingMachine'
import type { projectsMachine } from '@src/machines/projectsMachine'
import type { settingsMachine } from '@src/machines/settingsMachine'
// This might not be necessary, AnyStateMachine from xstate is working
export type AllMachines =
@ -25,7 +26,7 @@ export type AllMachines =
interface UseStateMachineCommandsArgs<
T extends AllMachines,
S extends StateMachineCommandSetSchema<T>
S extends StateMachineCommandSetSchema<T>,
> {
machineId: T['id']
state: StateFrom<T>
@ -38,7 +39,7 @@ interface UseStateMachineCommandsArgs<
export default function useStateMachineCommands<
T extends AnyStateMachine,
S extends StateMachineCommandSetSchema<T>
S extends StateMachineCommandSetSchema<T>,
>({
machineId,
state,

View File

@ -1,16 +1,18 @@
import { useEffect, useState } from 'react'
import {
SetVarNameModal,
createSetVarNameModal,
} from 'components/SetVarNameModal'
import { editorManager, kclManager, codeManager } from 'lib/singletons'
import { reportRejection, trap, err } from 'lib/trap'
import { moveValueIntoNewVariable } from 'lang/modifyAst'
import { isNodeSafeToReplace } from 'lang/queryAst'
import { useEffect, useState } from 'react'
import { useModelingContext } from './useModelingContext'
import { PathToNode, SourceRange, recast } from 'lang/wasm'
import { useKclContext } from 'lang/KclProvider'
import { toSync } from 'lib/utils'
} from '@src/components/SetVarNameModal'
import { useModelingContext } from '@src/hooks/useModelingContext'
import { useKclContext } from '@src/lang/KclProvider'
import { moveValueIntoNewVariable } from '@src/lang/modifyAst'
import { isNodeSafeToReplace } from '@src/lang/queryAst'
import type { PathToNode, SourceRange } from '@src/lang/wasm'
import { recast } from '@src/lang/wasm'
import { codeManager, editorManager, kclManager } from '@src/lib/singletons'
import { err, reportRejection, trap } from '@src/lib/trap'
import { toSync } from '@src/lib/utils'
export const getVarNameModal = createSetVarNameModal(SetVarNameModal)