diff --git a/e2e/playwright/app-header-tests.spec.ts b/e2e/playwright/app-header-tests.spec.ts index 099ae7efe..c663c83a8 100644 --- a/e2e/playwright/app-header-tests.spec.ts +++ b/e2e/playwright/app-header-tests.spec.ts @@ -1,4 +1,4 @@ -import { expect, test } from './zoo-test' +import { test, expect } from './zoo-test' test.describe('Electron app header tests', () => { test( diff --git a/e2e/playwright/basic-sketch.spec.ts b/e2e/playwright/basic-sketch.spec.ts index d2fd1bd6d..3cb1e78fb 100644 --- a/e2e/playwright/basic-sketch.spec.ts +++ b/e2e/playwright/basic-sketch.spec.ts @@ -1,14 +1,13 @@ import { Page } from '@playwright/test' - -import { HomePageFixture } from './fixtures/homePageFixture' +import { test, expect } from './zoo-test' import { - PERSIST_MODELING_CONTEXT, + getUtils, TEST_COLORS, commonPoints, - getUtils, + PERSIST_MODELING_CONTEXT, orRunWhenFullSuiteEnabled, } from './test-utils' -import { expect, test } from './zoo-test' +import { HomePageFixture } from './fixtures/homePageFixture' test.setTimeout(120000) diff --git a/e2e/playwright/boolean.spec.ts b/e2e/playwright/boolean.spec.ts index 84e97e49a..67127ef68 100644 --- a/e2e/playwright/boolean.spec.ts +++ b/e2e/playwright/boolean.spec.ts @@ -1,8 +1,7 @@ +import { test, expect } from './zoo-test' import fs from 'node:fs/promises' import path from 'node:path' -import { expect, test } from './zoo-test' - test.describe('Point and click for boolean workflows', () => { // Boolean operations to test const booleanOperations = [ diff --git a/e2e/playwright/can-create-sketches-on-all-planes-and-their-back-sides.spec.ts b/e2e/playwright/can-create-sketches-on-all-planes-and-their-back-sides.spec.ts index 02ea903c3..b8e1b9ff0 100644 --- a/e2e/playwright/can-create-sketches-on-all-planes-and-their-back-sides.spec.ts +++ b/e2e/playwright/can-create-sketches-on-all-planes-and-their-back-sides.spec.ts @@ -1,11 +1,10 @@ import { Page } from '@playwright/test' +import { test, expect } from './zoo-test' +import { HomePageFixture } from './fixtures/homePageFixture' +import { getUtils } from './test-utils' import { EngineCommand } from 'lang/std/artifactGraph' import { uuidv4 } from 'lib/utils' - -import { HomePageFixture } from './fixtures/homePageFixture' import { SceneFixture } from './fixtures/sceneFixture' -import { getUtils } from './test-utils' -import { expect, test } from './zoo-test' test.describe( 'Can create sketches on all planes and their back sides', diff --git a/e2e/playwright/code-pane-and-errors.spec.ts b/e2e/playwright/code-pane-and-errors.spec.ts index 55c472f4c..1908ab38d 100644 --- a/e2e/playwright/code-pane-and-errors.spec.ts +++ b/e2e/playwright/code-pane-and-errors.spec.ts @@ -1,14 +1,13 @@ -import fsp from 'fs/promises' -import { bracket } from 'lib/exampleKcl' -import { join } from 'path' - -import { TEST_CODE_LONG_WITH_ERROR_OUT_OF_VIEW } from './storageStates' +import { test, expect } from './zoo-test' import { - executorInputPath, - getUtils, orRunWhenFullSuiteEnabled, + getUtils, + executorInputPath, } from './test-utils' -import { expect, test } from './zoo-test' +import { join } from 'path' +import { bracket } from 'lib/exampleKcl' +import { TEST_CODE_LONG_WITH_ERROR_OUT_OF_VIEW } from './storageStates' +import fsp from 'fs/promises' test.describe('Code pane and errors', { tag: ['@skipWin'] }, () => { test('Typing KCL errors induces a badge on the code pane button', async ({ diff --git a/e2e/playwright/command-bar-tests.spec.ts b/e2e/playwright/command-bar-tests.spec.ts index 3092ed0d2..a162a70b7 100644 --- a/e2e/playwright/command-bar-tests.spec.ts +++ b/e2e/playwright/command-bar-tests.spec.ts @@ -1,13 +1,12 @@ +import { test, expect } from './zoo-test' import * as fsp from 'fs/promises' -import { KCL_DEFAULT_LENGTH } from 'lib/constants' -import path, { join } from 'path' - import { executorInputPath, getUtils, orRunWhenFullSuiteEnabled, } from './test-utils' -import { expect, test } from './zoo-test' +import { KCL_DEFAULT_LENGTH } from 'lib/constants' +import path, { join } from 'path' test.describe('Command bar tests', { tag: ['@skipWin'] }, () => { test('Extrude from command bar selects extrude line after', async ({ diff --git a/e2e/playwright/copilot-ghost-test.spec.ts b/e2e/playwright/copilot-ghost-test.spec.ts index 0f6a9df73..c7f552258 100644 --- a/e2e/playwright/copilot-ghost-test.spec.ts +++ b/e2e/playwright/copilot-ghost-test.spec.ts @@ -1,5 +1,5 @@ +import { test, expect } from './zoo-test' import { getUtils } from './test-utils' -import { expect, test } from './zoo-test' test.describe('Copilot ghost text', () => { // eslint-disable-next-line jest/valid-title diff --git a/e2e/playwright/debug-pane.spec.ts b/e2e/playwright/debug-pane.spec.ts index 502d9fc9e..59ff83605 100644 --- a/e2e/playwright/debug-pane.spec.ts +++ b/e2e/playwright/debug-pane.spec.ts @@ -1,5 +1,6 @@ +import { test, expect } from './zoo-test' + import { getUtils } from './test-utils' -import { expect, test } from './zoo-test' function countNewlines(input: string): number { let count = 0 diff --git a/e2e/playwright/desktop-export.spec.ts b/e2e/playwright/desktop-export.spec.ts index e5415ae0d..c4d32ccd1 100644 --- a/e2e/playwright/desktop-export.spec.ts +++ b/e2e/playwright/desktop-export.spec.ts @@ -1,12 +1,11 @@ -import fsp from 'fs/promises' +import { test, expect } from './zoo-test' import path from 'path' - import { + getUtils, executorInputPath, getPlaywrightDownloadDir, - getUtils, } from './test-utils' -import { expect, test } from './zoo-test' +import fsp from 'fs/promises' test( 'export works on the first try', diff --git a/e2e/playwright/editor-tests.spec.ts b/e2e/playwright/editor-tests.spec.ts index 76daaa2e6..739236857 100644 --- a/e2e/playwright/editor-tests.spec.ts +++ b/e2e/playwright/editor-tests.spec.ts @@ -1,14 +1,14 @@ +import { test, expect } from './zoo-test' import fsp from 'fs/promises' import { uuidv4 } from 'lib/utils' -import { join } from 'path' - import { - TEST_COLORS, executorInputPath, getUtils, orRunWhenFullSuiteEnabled, + TEST_COLORS, } from './test-utils' -import { expect, test } from './zoo-test' + +import { join } from 'path' test.describe('Editor tests', { tag: ['@skipWin'] }, () => { test('can comment out code with ctrl+/', async ({ page, homePage }) => { diff --git a/e2e/playwright/feature-tree-pane.spec.ts b/e2e/playwright/feature-tree-pane.spec.ts index e8157da2b..54e4ed0b6 100644 --- a/e2e/playwright/feature-tree-pane.spec.ts +++ b/e2e/playwright/feature-tree-pane.spec.ts @@ -1,8 +1,7 @@ +import { test, expect } from './zoo-test' import * as fsp from 'fs/promises' import { join } from 'path' -import { expect, test } from './zoo-test' - const FEATURE_TREE_EXAMPLE_CODE = `export fn timesFive(x) { return 5 * x } diff --git a/e2e/playwright/file-tree.spec.ts b/e2e/playwright/file-tree.spec.ts index 87f40a28c..88ed2d403 100644 --- a/e2e/playwright/file-tree.spec.ts +++ b/e2e/playwright/file-tree.spec.ts @@ -1,8 +1,6 @@ -import * as fs from 'fs' +import { test, expect } from './zoo-test' import * as fsp from 'fs/promises' -import { FILE_EXT } from 'lib/constants' -import { join } from 'path' - +import * as fs from 'fs' import { createProject, executorInputPath, @@ -10,7 +8,8 @@ import { orRunWhenFullSuiteEnabled, runningOnWindows, } from './test-utils' -import { expect, test } from './zoo-test' +import { join } from 'path' +import { FILE_EXT } from 'lib/constants' test.describe('integrations tests', () => { test( diff --git a/e2e/playwright/fixtures/cmdBarFixture.ts b/e2e/playwright/fixtures/cmdBarFixture.ts index d9e7ae97b..18800ef9e 100644 --- a/e2e/playwright/fixtures/cmdBarFixture.ts +++ b/e2e/playwright/fixtures/cmdBarFixture.ts @@ -1,5 +1,5 @@ -import type { Locator, Page, Request, Route } from '@playwright/test' -import { TestInfo, expect } from '@playwright/test' +import type { Page, Locator, Route, Request } from '@playwright/test' +import { expect, TestInfo } from '@playwright/test' import * as fs from 'fs' import * as path from 'path' diff --git a/e2e/playwright/fixtures/editorFixture.ts b/e2e/playwright/fixtures/editorFixture.ts index ddf3b344a..3304a8a66 100644 --- a/e2e/playwright/fixtures/editorFixture.ts +++ b/e2e/playwright/fixtures/editorFixture.ts @@ -1,9 +1,8 @@ -import type { Locator, Page } from '@playwright/test' +import type { Page, Locator } from '@playwright/test' import { expect } from '@playwright/test' - import { - checkIfPaneIsOpen, closePane, + checkIfPaneIsOpen, openPane, sansWhitespace, } from '../test-utils' diff --git a/e2e/playwright/fixtures/fixtureSetup.ts b/e2e/playwright/fixtures/fixtureSetup.ts index c48cb2947..e051917ab 100644 --- a/e2e/playwright/fixtures/fixtureSetup.ts +++ b/e2e/playwright/fixtures/fixtureSetup.ts @@ -1,27 +1,28 @@ /* eslint-disable react-hooks/rules-of-hooks */ -import * as TOML from '@iarna/toml' + import type { BrowserContext, ElectronApplication, - Page, TestInfo, + Page, } from '@playwright/test' + import { _electron as electron } from '@playwright/test' -import fsp from 'fs/promises' + +import * as TOML from '@iarna/toml' +import { TEST_SETTINGS } from '../storageStates' import { SETTINGS_FILE_NAME } from 'lib/constants' -import { DeepPartial } from 'lib/types' +import { getUtils, setup } from '../test-utils' +import fsp from 'fs/promises' import fs from 'node:fs' import path from 'path' - -import { Settings } from '@rust/kcl-lib/bindings/Settings' - -import { TEST_SETTINGS } from '../storageStates' -import { getUtils, setup } from '../test-utils' import { CmdBarFixture } from './cmdBarFixture' import { EditorFixture } from './editorFixture' -import { HomePageFixture } from './homePageFixture' -import { SceneFixture } from './sceneFixture' import { ToolbarFixture } from './toolbarFixture' +import { SceneFixture } from './sceneFixture' +import { HomePageFixture } from './homePageFixture' +import { DeepPartial } from 'lib/types' +import { Settings } from '@rust/kcl-lib/bindings/Settings' export class AuthenticatedApp { public readonly page: Page diff --git a/e2e/playwright/fixtures/homePageFixture.ts b/e2e/playwright/fixtures/homePageFixture.ts index 891c66a84..e6caf43a8 100644 --- a/e2e/playwright/fixtures/homePageFixture.ts +++ b/e2e/playwright/fixtures/homePageFixture.ts @@ -1,4 +1,4 @@ -import type { Locator, Page } from '@playwright/test' +import type { Page, Locator } from '@playwright/test' import { expect } from '@playwright/test' interface ProjectCardState { diff --git a/e2e/playwright/fixtures/sceneFixture.ts b/e2e/playwright/fixtures/sceneFixture.ts index 531054f7e..b47538345 100644 --- a/e2e/playwright/fixtures/sceneFixture.ts +++ b/e2e/playwright/fixtures/sceneFixture.ts @@ -1,16 +1,15 @@ -import type { Locator, Page } from '@playwright/test' +import type { Page, Locator } from '@playwright/test' +import { expect } from '../zoo-test' import { isArray, uuidv4 } from 'lib/utils' - +import { CmdBarFixture } from './cmdBarFixture' import { closeDebugPanel, doAndWaitForImageDiff, getPixelRGBs, - getUtils, openAndClearDebugPanel, sendCustomCmd, + getUtils, } from '../test-utils' -import { expect } from '../zoo-test' -import { CmdBarFixture } from './cmdBarFixture' type MouseParams = { pixelDiff?: number diff --git a/e2e/playwright/fixtures/toolbarFixture.ts b/e2e/playwright/fixtures/toolbarFixture.ts index ae20cd22e..09dd54d96 100644 --- a/e2e/playwright/fixtures/toolbarFixture.ts +++ b/e2e/playwright/fixtures/toolbarFixture.ts @@ -1,15 +1,14 @@ -import { type Locator, type Page, test } from '@playwright/test' -import { SidebarType } from 'components/ModelingSidebar/ModelingPanes' -import { SIDEBAR_BUTTON_SUFFIX } from 'lib/constants' -import { ToolbarModeName } from 'lib/toolbar' - +import { type Page, type Locator, test } from '@playwright/test' +import { expect } from '../zoo-test' import { checkIfPaneIsOpen, closePane, doAndWaitForImageDiff, openPane, } from '../test-utils' -import { expect } from '../zoo-test' +import { SidebarType } from 'components/ModelingSidebar/ModelingPanes' +import { SIDEBAR_BUTTON_SUFFIX } from 'lib/constants' +import { ToolbarModeName } from 'lib/toolbar' export class ToolbarFixture { public page: Page diff --git a/e2e/playwright/machines.spec.ts b/e2e/playwright/machines.spec.ts index b84ec51a2..113f59ffc 100644 --- a/e2e/playwright/machines.spec.ts +++ b/e2e/playwright/machines.spec.ts @@ -1,8 +1,7 @@ -import fsp from 'fs/promises' -import { join } from 'path' - +import { test, expect } from './zoo-test' import { executorInputPath } from './test-utils' -import { expect, test } from './zoo-test' +import { join } from 'path' +import fsp from 'fs/promises' test( 'When machine-api server not found butt is disabled and shows the reason', diff --git a/e2e/playwright/named-views.spec.ts b/e2e/playwright/named-views.spec.ts index 31893b5b8..c24ea6de9 100644 --- a/e2e/playwright/named-views.spec.ts +++ b/e2e/playwright/named-views.spec.ts @@ -1,15 +1,13 @@ -import * as fsp from 'fs/promises' +import { test, expect } from './zoo-test' import { PROJECT_SETTINGS_FILE_NAME } from 'lib/constants' +import * as fsp from 'fs/promises' import { join } from 'path' - -import { NamedView } from '@rust/kcl-lib/bindings/NamedView' - import { createProject, - perProjectsettingsToToml, tomlToPerProjectSettings, + perProjectsettingsToToml, } from './test-utils' -import { expect, test } from './zoo-test' +import { NamedView } from '@rust/kcl-lib/bindings/NamedView' // Helper function to determine if the file path on disk exists // Specifically this is used to check if project.toml exists on disk diff --git a/e2e/playwright/native-file-menu.spec.ts b/e2e/playwright/native-file-menu.spec.ts index d1afd767a..798013e24 100644 --- a/e2e/playwright/native-file-menu.spec.ts +++ b/e2e/playwright/native-file-menu.spec.ts @@ -1,4 +1,4 @@ -import { expect, test } from './zoo-test' +import { test, expect } from './zoo-test' /** * Not all menu actions are tested. Some are default electron menu actions. diff --git a/e2e/playwright/null.spec.ts b/e2e/playwright/null.spec.ts index c79870cd3..dcb213a9f 100644 --- a/e2e/playwright/null.spec.ts +++ b/e2e/playwright/null.spec.ts @@ -2,7 +2,8 @@ // application, check it can make it to the project pane, and nothing more. // It also tests our test wrappers are working. // Additionally this serves as a nice minimal example. -import { expect, test } from './zoo-test' + +import { test, expect } from './zoo-test' test.describe('Open the application', () => { test('see the project view', async ({ page, context }) => { diff --git a/e2e/playwright/onboarding-tests.spec.ts b/e2e/playwright/onboarding-tests.spec.ts index cbb143967..4ecac34e3 100644 --- a/e2e/playwright/onboarding-tests.spec.ts +++ b/e2e/playwright/onboarding-tests.spec.ts @@ -1,23 +1,22 @@ -import fsp from 'fs/promises' -import { bracket } from 'lib/exampleKcl' +import { test, expect } from './zoo-test' import { join } from 'path' +import fsp from 'fs/promises' +import { + getUtils, + executorInputPath, + createProject, + settingsToToml, + orRunWhenFullSuiteEnabled, +} from './test-utils' +import { bracket } from 'lib/exampleKcl' import { onboardingPaths } from 'routes/Onboarding/paths' - -import { expectPixelColor } from './fixtures/sceneFixture' import { TEST_SETTINGS_KEY, - TEST_SETTINGS_ONBOARDING_EXPORT, TEST_SETTINGS_ONBOARDING_START, + TEST_SETTINGS_ONBOARDING_EXPORT, TEST_SETTINGS_ONBOARDING_USER_MENU, } from './storageStates' -import { - createProject, - executorInputPath, - getUtils, - orRunWhenFullSuiteEnabled, - settingsToToml, -} from './test-utils' -import { expect, test } from './zoo-test' +import { expectPixelColor } from './fixtures/sceneFixture' // Because our default test settings have the onboardingStatus set to 'dismissed', // we must set it to empty for the tests where we want to see the onboarding immediately. diff --git a/e2e/playwright/playwright-deprecated.ts b/e2e/playwright/playwright-deprecated.ts index 2c25b4f57..b92a52dfc 100644 --- a/e2e/playwright/playwright-deprecated.ts +++ b/e2e/playwright/playwright-deprecated.ts @@ -1,4 +1,4 @@ -import { expect, test } from '@playwright/test' +import { test, expect } from '@playwright/test' /** @deprecated, import from ./fixtureSetup.ts instead */ export const _test = test diff --git a/e2e/playwright/point-click.spec.ts b/e2e/playwright/point-click.spec.ts index 6f7ec807d..7c18108a5 100644 --- a/e2e/playwright/point-click.spec.ts +++ b/e2e/playwright/point-click.spec.ts @@ -1,13 +1,12 @@ import { Page } from '@playwright/test' -import { Locator } from '@playwright/test' -import fs from 'node:fs/promises' -import path from 'node:path' - +import { test, expect } from './zoo-test' import { EditorFixture } from './fixtures/editorFixture' import { SceneFixture } from './fixtures/sceneFixture' import { ToolbarFixture } from './fixtures/toolbarFixture' +import fs from 'node:fs/promises' +import path from 'node:path' import { getUtils, orRunWhenFullSuiteEnabled } from './test-utils' -import { expect, test } from './zoo-test' +import { Locator } from '@playwright/test' // test file is for testing point an click code gen functionality that's not sketch mode related diff --git a/e2e/playwright/projects.spec.ts b/e2e/playwright/projects.spec.ts index 51cb052f1..425fd9d2b 100644 --- a/e2e/playwright/projects.spec.ts +++ b/e2e/playwright/projects.spec.ts @@ -1,20 +1,19 @@ -import fs from 'fs' -import fsp from 'fs/promises' -import { DEFAULT_PROJECT_KCL_FILE } from 'lib/constants' -import path from 'path' - +import { test, expect } from './zoo-test' import { - Paths, - createProject, doExport, executorInputPath, - getPlaywrightDownloadDir, getUtils, isOutOfViewInScrollContainer, + Paths, + createProject, + getPlaywrightDownloadDir, orRunWhenFullSuiteEnabled, runningOnWindows, } from './test-utils' -import { expect, test } from './zoo-test' +import fsp from 'fs/promises' +import fs from 'fs' +import path from 'path' +import { DEFAULT_PROJECT_KCL_FILE } from 'lib/constants' test( 'projects reload if a new one is created, deleted, or renamed externally', diff --git a/e2e/playwright/prompt-to-edit-snapshot-tests.spec.ts b/e2e/playwright/prompt-to-edit-snapshot-tests.spec.ts index faedeb756..083ea8406 100644 --- a/e2e/playwright/prompt-to-edit-snapshot-tests.spec.ts +++ b/e2e/playwright/prompt-to-edit-snapshot-tests.spec.ts @@ -1,5 +1,4 @@ -import { expect, test } from './zoo-test' - +import { test, expect } from './zoo-test' /* eslint-disable jest/no-conditional-expect */ /** diff --git a/e2e/playwright/prompt-to-edit.spec.ts b/e2e/playwright/prompt-to-edit.spec.ts index 8a6e634dd..0121a1d32 100644 --- a/e2e/playwright/prompt-to-edit.spec.ts +++ b/e2e/playwright/prompt-to-edit.spec.ts @@ -1,5 +1,5 @@ +import { test, expect } from './zoo-test' import { orRunWhenFullSuiteEnabled } from './test-utils' -import { expect, test } from './zoo-test' /* eslint-disable jest/no-conditional-expect */ diff --git a/e2e/playwright/regression-tests.spec.ts b/e2e/playwright/regression-tests.spec.ts index 3c9ae1caa..c261120c6 100644 --- a/e2e/playwright/regression-tests.spec.ts +++ b/e2e/playwright/regression-tests.spec.ts @@ -1,18 +1,17 @@ import { Page } from '@playwright/test' -import * as fsp from 'fs/promises' -import { bracket } from 'lib/exampleKcl' -import { reportRejection } from 'lib/trap' +import { test, expect } from './zoo-test' import path from 'path' - -import { TEST_CODE_TRIGGER_ENGINE_EXPORT_ERROR } from './storageStates' +import * as fsp from 'fs/promises' import { + getUtils, TEST_COLORS, TestColor, executorInputPath, - getUtils, orRunWhenFullSuiteEnabled, } from './test-utils' -import { expect, test } from './zoo-test' +import { TEST_CODE_TRIGGER_ENGINE_EXPORT_ERROR } from './storageStates' +import { bracket } from 'lib/exampleKcl' +import { reportRejection } from 'lib/trap' test.describe('Regression tests', { tag: ['@skipWin'] }, () => { // bugs we found that don't fit neatly into other categories diff --git a/e2e/playwright/sketch-tests.spec.ts b/e2e/playwright/sketch-tests.spec.ts index afe883585..628f55bca 100644 --- a/e2e/playwright/sketch-tests.spec.ts +++ b/e2e/playwright/sketch-tests.spec.ts @@ -1,20 +1,20 @@ import { Page } from '@playwright/test' -import { roundOff, uuidv4 } from 'lib/utils' +import { test, expect } from './zoo-test' import fs from 'node:fs/promises' import path from 'node:path' - -import { CmdBarFixture } from './fixtures/cmdBarFixture' import { HomePageFixture } from './fixtures/homePageFixture' -import { SceneFixture } from './fixtures/sceneFixture' -import { ToolbarFixture } from './fixtures/toolbarFixture' + import { - PERSIST_MODELING_CONTEXT, - TEST_COLORS, getMovementUtils, getUtils, + PERSIST_MODELING_CONTEXT, + TEST_COLORS, orRunWhenFullSuiteEnabled, } from './test-utils' -import { expect, test } from './zoo-test' +import { uuidv4, roundOff } from 'lib/utils' +import { SceneFixture } from './fixtures/sceneFixture' +import { ToolbarFixture } from './fixtures/toolbarFixture' +import { CmdBarFixture } from './fixtures/cmdBarFixture' test.describe('Sketch tests', { tag: ['@skipWin'] }, () => { test('multi-sketch file shows multiple Edit Sketch buttons', async ({ diff --git a/e2e/playwright/snapshot-tests.spec.ts b/e2e/playwright/snapshot-tests.spec.ts index 0a574ab63..67d40bb6a 100644 --- a/e2e/playwright/snapshot-tests.spec.ts +++ b/e2e/playwright/snapshot-tests.spec.ts @@ -1,22 +1,21 @@ -import { Models } from '@kittycad/lib' -import { spawn } from 'child_process' -import fsp from 'fs/promises' -import JSZip from 'jszip' -import { KCL_DEFAULT_LENGTH } from 'lib/constants' -import path from 'path' - -import { CmdBarFixture } from './fixtures/cmdBarFixture' -import { SceneFixture } from './fixtures/sceneFixture' +import { test, expect } from './zoo-test' import { secrets } from './secrets' -import { TEST_SETTINGS, TEST_SETTINGS_KEY } from './storageStates' import { Paths, doExport, getUtils, - orRunWhenFullSuiteEnabled, settingsToToml, + orRunWhenFullSuiteEnabled, } from './test-utils' -import { expect, test } from './zoo-test' +import { Models } from '@kittycad/lib' +import fsp from 'fs/promises' +import { spawn } from 'child_process' +import { KCL_DEFAULT_LENGTH } from 'lib/constants' +import JSZip from 'jszip' +import path from 'path' +import { TEST_SETTINGS, TEST_SETTINGS_KEY } from './storageStates' +import { SceneFixture } from './fixtures/sceneFixture' +import { CmdBarFixture } from './fixtures/cmdBarFixture' test.beforeEach(async ({ page, context }) => { // Make the user avatar image always 404 diff --git a/e2e/playwright/storageStates.ts b/e2e/playwright/storageStates.ts index 4033b6547..4b2cc30c6 100644 --- a/e2e/playwright/storageStates.ts +++ b/e2e/playwright/storageStates.ts @@ -1,10 +1,9 @@ +import { Settings } from '@rust/kcl-lib/bindings/Settings' import { SaveSettingsPayload } from 'lib/settings/settingsTypes' import { Themes } from 'lib/theme' import { DeepPartial } from 'lib/types' import { onboardingPaths } from 'routes/Onboarding/paths' -import { Settings } from '@rust/kcl-lib/bindings/Settings' - export const IS_PLAYWRIGHT_KEY = 'playwright' export const TEST_SETTINGS_KEY = '/settings.toml' diff --git a/e2e/playwright/test-network-and-connection-issues.spec.ts b/e2e/playwright/test-network-and-connection-issues.spec.ts index 75b7fc21a..50bf53b64 100644 --- a/e2e/playwright/test-network-and-connection-issues.spec.ts +++ b/e2e/playwright/test-network-and-connection-issues.spec.ts @@ -1,9 +1,8 @@ +import { test, expect } from './zoo-test' +import { commonPoints, getUtils, orRunWhenFullSuiteEnabled } from './test-utils' import { EngineCommand } from 'lang/std/artifactGraph' import { uuidv4 } from 'lib/utils' -import { commonPoints, getUtils, orRunWhenFullSuiteEnabled } from './test-utils' -import { expect, test } from './zoo-test' - test.describe('Test network and connection issues', () => { test( 'simulate network down and network little widget', diff --git a/e2e/playwright/test-utils.test.ts b/e2e/playwright/test-utils.test.ts index c668b61f4..e8dc1491b 100644 --- a/e2e/playwright/test-utils.test.ts +++ b/e2e/playwright/test-utils.test.ts @@ -1,8 +1,8 @@ import { - orRunWhenFullSuiteEnabled, runningOnLinux, runningOnMac, runningOnWindows, + orRunWhenFullSuiteEnabled, } from './test-utils' describe('platform detection utilities', () => { diff --git a/e2e/playwright/test-utils.ts b/e2e/playwright/test-utils.ts index 5fdb790a2..aae8a922c 100644 --- a/e2e/playwright/test-utils.ts +++ b/e2e/playwright/test-utils.ts @@ -1,34 +1,32 @@ -import * as TOML from '@iarna/toml' -import type { Models } from '@kittycad/lib' import { + expect, BrowserContext, + TestInfo, Locator, Page, - TestInfo, - expect, } from '@playwright/test' -import fsp from 'fs/promises' +import { test } from './zoo-test' import { EngineCommand } from 'lang/std/artifactGraph' -import { Configuration } from 'lang/wasm' -import { COOKIE_NAME } from 'lib/constants' -import { reportRejection } from 'lib/trap' -import { DeepPartial } from 'lib/types' -import { isArray } from 'lib/utils' +import fsp from 'fs/promises' import path from 'path' import pixelMatch from 'pixelmatch' -import { Protocol } from 'playwright-core/types/protocol' import { PNG } from 'pngjs' - -import { ProjectConfiguration } from '@rust/kcl-lib/bindings/ProjectConfiguration' - -import { isErrorWhitelisted } from './lib/console-error-whitelist' +import { Protocol } from 'playwright-core/types/protocol' +import type { Models } from '@kittycad/lib' +import { COOKIE_NAME } from 'lib/constants' import { secrets } from './secrets' import { - IS_PLAYWRIGHT_KEY, - TEST_SETTINGS, TEST_SETTINGS_KEY, + TEST_SETTINGS, + IS_PLAYWRIGHT_KEY, } from './storageStates' -import { test } from './zoo-test' +import * as TOML from '@iarna/toml' +import { isErrorWhitelisted } from './lib/console-error-whitelist' +import { isArray } from 'lib/utils' +import { reportRejection } from 'lib/trap' +import { DeepPartial } from 'lib/types' +import { Configuration } from 'lang/wasm' +import { ProjectConfiguration } from '@rust/kcl-lib/bindings/ProjectConfiguration' const toNormalizedCode = (text: string) => { return text.replace(/\s+/g, '') @@ -685,8 +683,8 @@ const _makeTemplate = ( isArray(currentOptions) ? currentOptions[i] : typeof currentOptions === 'number' - ? currentOptions - : '' + ? currentOptions + : '' ) ) }) diff --git a/e2e/playwright/testing-camera-movement.spec.ts b/e2e/playwright/testing-camera-movement.spec.ts index 3c17f1424..c900f3fc6 100644 --- a/e2e/playwright/testing-camera-movement.spec.ts +++ b/e2e/playwright/testing-camera-movement.spec.ts @@ -1,8 +1,7 @@ +import { test, expect } from './zoo-test' import { EngineCommand } from 'lang/std/artifactGraph' import { uuidv4 } from 'lib/utils' - import { getUtils, orRunWhenFullSuiteEnabled } from './test-utils' -import { expect, test } from './zoo-test' test.describe('Testing Camera Movement', { tag: ['@skipWin'] }, () => { test('Can move camera reliably', async ({ page, context, homePage }) => { diff --git a/e2e/playwright/testing-constraints.spec.ts b/e2e/playwright/testing-constraints.spec.ts index f5be46e08..da190a058 100644 --- a/e2e/playwright/testing-constraints.spec.ts +++ b/e2e/playwright/testing-constraints.spec.ts @@ -1,15 +1,14 @@ +import { test, expect } from './zoo-test' import * as fsp from 'fs/promises' +import { + getUtils, + TEST_COLORS, + pollEditorLinesSelectedLength, + orRunWhenFullSuiteEnabled, +} from './test-utils' import { XOR } from 'lib/utils' import path from 'node:path' -import { - TEST_COLORS, - getUtils, - orRunWhenFullSuiteEnabled, - pollEditorLinesSelectedLength, -} from './test-utils' -import { expect, test } from './zoo-test' - test.describe('Testing constraints', { tag: ['@skipWin'] }, () => { test('Can constrain line length', async ({ page, homePage }) => { await page.addInitScript(async () => { diff --git a/e2e/playwright/testing-gizmo.spec.ts b/e2e/playwright/testing-gizmo.spec.ts index ef6b94b0e..75b222b32 100644 --- a/e2e/playwright/testing-gizmo.spec.ts +++ b/e2e/playwright/testing-gizmo.spec.ts @@ -1,8 +1,7 @@ -import { uuidv4 } from 'lib/utils' - -import { TEST_CODE_GIZMO } from './storageStates' +import { test, expect } from './zoo-test' import { getUtils } from './test-utils' -import { expect, test } from './zoo-test' +import { uuidv4 } from 'lib/utils' +import { TEST_CODE_GIZMO } from './storageStates' test.describe('Testing Gizmo', { tag: ['@skipWin'] }, () => { const cases = [ diff --git a/e2e/playwright/testing-perspective-toggle.spec.ts b/e2e/playwright/testing-perspective-toggle.spec.ts index d64d07ae4..78c83e7b0 100644 --- a/e2e/playwright/testing-perspective-toggle.spec.ts +++ b/e2e/playwright/testing-perspective-toggle.spec.ts @@ -1,5 +1,5 @@ +import { test, expect } from './zoo-test' import { getUtils, orRunWhenFullSuiteEnabled } from './test-utils' -import { expect, test } from './zoo-test' test.describe('Test toggling perspective', () => { test('via command palette and toggle', async ({ page, homePage }) => { diff --git a/e2e/playwright/testing-samples-loading.spec.ts b/e2e/playwright/testing-samples-loading.spec.ts index 0c936c694..182925fe9 100644 --- a/e2e/playwright/testing-samples-loading.spec.ts +++ b/e2e/playwright/testing-samples-loading.spec.ts @@ -1,10 +1,9 @@ -import * as fsp from 'fs/promises' -import { FILE_EXT } from 'lib/constants' -import { bracket } from 'lib/exampleKcl' -import { join } from 'path' - +import { test, expect } from './zoo-test' import { getUtils } from './test-utils' -import { expect, test } from './zoo-test' +import { bracket } from 'lib/exampleKcl' +import * as fsp from 'fs/promises' +import { join } from 'path' +import { FILE_EXT } from 'lib/constants' test.describe('Testing in-app sample loading', () => { /** diff --git a/e2e/playwright/testing-segment-overlays.spec.ts b/e2e/playwright/testing-segment-overlays.spec.ts index ac8aadb1e..809ad55bb 100644 --- a/e2e/playwright/testing-segment-overlays.spec.ts +++ b/e2e/playwright/testing-segment-overlays.spec.ts @@ -1,15 +1,15 @@ import { Page } from '@playwright/test' -import { LineInputsType } from 'lang/std/sketchcombos' -import { uuidv4 } from 'lib/utils' +import { test, expect } from './zoo-test' -import { EditorFixture } from './fixtures/editorFixture' import { deg, getUtils, - orRunWhenFullSuiteEnabled, wiggleMove, + orRunWhenFullSuiteEnabled, } from './test-utils' -import { expect, test } from './zoo-test' +import { LineInputsType } from 'lang/std/sketchcombos' +import { uuidv4 } from 'lib/utils' +import { EditorFixture } from './fixtures/editorFixture' test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => { test('Hover over a segment should show its overlay, hovering over the input overlays should show its popover, clicking the input overlay should constrain/unconstrain it:\nfor the following segments', () => { diff --git a/e2e/playwright/testing-selections.spec.ts b/e2e/playwright/testing-selections.spec.ts index 63896cc5a..0b1ded979 100644 --- a/e2e/playwright/testing-selections.spec.ts +++ b/e2e/playwright/testing-selections.spec.ts @@ -1,10 +1,10 @@ +import { test, expect } from './zoo-test' + +import { commonPoints, getUtils, orRunWhenFullSuiteEnabled } from './test-utils' import { Coords2d } from 'lang/std/sketch' import { KCL_DEFAULT_LENGTH } from 'lib/constants' import { uuidv4 } from 'lib/utils' -import { commonPoints, getUtils, orRunWhenFullSuiteEnabled } from './test-utils' -import { expect, test } from './zoo-test' - test.describe('Testing selections', { tag: ['@skipWin'] }, () => { test.setTimeout(90_000) test('Selections work on fresh and edited sketch', async ({ diff --git a/e2e/playwright/testing-settings.spec.ts b/e2e/playwright/testing-settings.spec.ts index 58ad8f6ca..c57eccf23 100644 --- a/e2e/playwright/testing-settings.spec.ts +++ b/e2e/playwright/testing-settings.spec.ts @@ -1,26 +1,24 @@ +import { test, expect } from './zoo-test' import * as fsp from 'fs/promises' -import { PROJECT_SETTINGS_FILE_NAME, SETTINGS_FILE_NAME } from 'lib/constants' -import { SettingsLevel } from 'lib/settings/settingsTypes' -import { DeepPartial } from 'lib/types' import { join } from 'path' - -import { Settings } from '@rust/kcl-lib/bindings/Settings' - import { - TEST_SETTINGS, - TEST_SETTINGS_CORRUPTED, - TEST_SETTINGS_DEFAULT_THEME, - TEST_SETTINGS_KEY, -} from './storageStates' -import { - TEST_COLORS, - createProject, - executorInputPath, getUtils, - orRunWhenFullSuiteEnabled, + executorInputPath, + createProject, tomlToSettings, + TEST_COLORS, + orRunWhenFullSuiteEnabled, } from './test-utils' -import { expect, test } from './zoo-test' +import { SettingsLevel } from 'lib/settings/settingsTypes' +import { SETTINGS_FILE_NAME, PROJECT_SETTINGS_FILE_NAME } from 'lib/constants' +import { + TEST_SETTINGS_KEY, + TEST_SETTINGS_CORRUPTED, + TEST_SETTINGS, + TEST_SETTINGS_DEFAULT_THEME, +} from './storageStates' +import { DeepPartial } from 'lib/types' +import { Settings } from '@rust/kcl-lib/bindings/Settings' test.describe('Testing settings', () => { test('Stored settings are validated and fall back to defaults', async ({ diff --git a/e2e/playwright/text-to-cad-tests.spec.ts b/e2e/playwright/text-to-cad-tests.spec.ts index 8d2448a34..8dddbcb33 100644 --- a/e2e/playwright/text-to-cad-tests.spec.ts +++ b/e2e/playwright/text-to-cad-tests.spec.ts @@ -1,13 +1,12 @@ import { Page } from '@playwright/test' -import fs from 'fs' -import { join } from 'path' - +import { test, expect } from './zoo-test' import { - createProject, getUtils, + createProject, orRunWhenFullSuiteEnabled, } from './test-utils' -import { expect, test } from './zoo-test' +import { join } from 'path' +import fs from 'fs' test.describe('Text-to-CAD tests', { tag: ['@skipWin'] }, () => { test('basic lego happy case', async ({ page, homePage }) => { diff --git a/e2e/playwright/various.spec.ts b/e2e/playwright/various.spec.ts index 4f9b5c342..d49ff9514 100644 --- a/e2e/playwright/various.spec.ts +++ b/e2e/playwright/various.spec.ts @@ -1,10 +1,11 @@ +import { test, expect } from './zoo-test' + import { doExport, getUtils, makeTemplate, orRunWhenFullSuiteEnabled, } from './test-utils' -import { expect, test } from './zoo-test' test('Units menu', async ({ page, homePage }) => { test.fixme(orRunWhenFullSuiteEnabled()) diff --git a/e2e/playwright/zoo-test.ts b/e2e/playwright/zoo-test.ts index 7f612d58e..5096686a4 100644 --- a/e2e/playwright/zoo-test.ts +++ b/e2e/playwright/zoo-test.ts @@ -1,10 +1,11 @@ /* eslint-disable react-hooks/rules-of-hooks */ + import { test as playwrightTestFn } from '@playwright/test' import { - ElectronZoo, - Fixtures, fixturesBasedOnProcessEnvPlatform, + Fixtures, + ElectronZoo, } from './fixtures/fixtureSetup' export { expect } from '@playwright/test' diff --git a/forge.config.ts b/forge.config.ts index ace957e8b..5a079660e 100644 --- a/forge.config.ts +++ b/forge.config.ts @@ -1,6 +1,6 @@ -import { FusesPlugin } from '@electron-forge/plugin-fuses' -import { VitePlugin } from '@electron-forge/plugin-vite' import type { ForgeConfig } from '@electron-forge/shared-types' +import { VitePlugin } from '@electron-forge/plugin-vite' +import { FusesPlugin } from '@electron-forge/plugin-fuses' import { FuseV1Options, FuseVersion } from '@electron/fuses' import path from 'path' diff --git a/forge.env.d.ts b/forge.env.d.ts index 4408b1e64..eb0a5a87e 100644 --- a/forge.env.d.ts +++ b/forge.env.d.ts @@ -26,7 +26,7 @@ declare global { declare module 'vite' { interface ConfigEnv< - K extends keyof VitePluginConfig = keyof VitePluginConfig, + K extends keyof VitePluginConfig = keyof VitePluginConfig > { root: string forgeConfig: VitePluginConfig diff --git a/interface.d.ts b/interface.d.ts index f33fa20c8..27c97f3ac 100644 --- a/interface.d.ts +++ b/interface.d.ts @@ -1,13 +1,13 @@ -import { MachinesListing } from 'components/MachineManagerProvider' +import fs from 'node:fs/promises' +import fsSync from 'node:fs' +import path from 'path' import { dialog, shell } from 'electron' +import { MachinesListing } from 'components/MachineManagerProvider' +import type { Channel } from 'src/menu/channels' import { Menu, WebContents } from 'electron' -import type { WebContentSendPayload } from 'menu/channels' import { ZooLabel, ZooMenuEvents } from 'menu/roles' import type { MenuActionIPC } from 'menu/rules' -import fsSync from 'node:fs' -import fs from 'node:fs/promises' -import path from 'path' -import type { Channel } from 'src/menu/channels' +import type { WebContentSendPayload } from 'menu/channels' // Extend the interface with additional custom properties declare module 'electron' { diff --git a/package.json b/package.json index 9aa3879e5..fe5c1a0ad 100644 --- a/package.json +++ b/package.json @@ -135,6 +135,12 @@ "test:unit:local": "yarn simpleserver:bg && yarn test:unit; kill-port 3000", "test:unit:kcl-samples:local": "yarn simpleserver:bg && yarn test:unit:kcl-samples; kill-port 3000" }, + "prettier": { + "trailingComma": "es5", + "tabWidth": 2, + "semi": false, + "singleQuote": true + }, "browserslist": { "production": [ ">0.2%", @@ -161,7 +167,6 @@ "@playwright/test": "^1.51.1", "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^15.0.2", - "@trivago/prettier-plugin-sort-imports": "^5.2.2", "@types/diff": "^7.0.2", "@types/electron": "^1.6.10", "@types/isomorphic-fetch": "^0.0.39", @@ -203,7 +208,7 @@ "pngjs": "^7.0.0", "postcss": "^8.4.43", "postinstall-postinstall": "^2.1.0", - "prettier": "^3.5.3", + "prettier": "^2.8.8", "setimmediate": "^1.0.5", "tailwindcss": "^3.4.17", "ts-node": "^10.0.0", diff --git a/packages/codemirror-lang-kcl/rollup.config.js b/packages/codemirror-lang-kcl/rollup.config.js index deadb2519..d558688be 100644 --- a/packages/codemirror-lang-kcl/rollup.config.js +++ b/packages/codemirror-lang-kcl/rollup.config.js @@ -1,6 +1,6 @@ +import dts from 'rollup-plugin-dts' import { lezer } from '@lezer/generator/rollup' import typescript from '@rollup/plugin-typescript' -import dts from 'rollup-plugin-dts' export default [ { diff --git a/packages/codemirror-lang-kcl/src/index.ts b/packages/codemirror-lang-kcl/src/index.ts index 238340459..7d77f1375 100644 --- a/packages/codemirror-lang-kcl/src/index.ts +++ b/packages/codemirror-lang-kcl/src/index.ts @@ -1,14 +1,14 @@ // Base CodeMirror language support for kcl. + import { LRLanguage, LanguageSupport, + indentNodeProp, continuedIndent, delimitedIndent, - foldInside, foldNodeProp, - indentNodeProp, + foldInside, } from '@codemirror/language' - // @ts-ignore: No types available import { parser } from './kcl.grammar' diff --git a/packages/codemirror-lang-kcl/test/all.test.ts b/packages/codemirror-lang-kcl/test/all.test.ts index 5d03f09f3..dba913ceb 100644 --- a/packages/codemirror-lang-kcl/test/all.test.ts +++ b/packages/codemirror-lang-kcl/test/all.test.ts @@ -1,9 +1,9 @@ +import { KclLanguage } from '../src/index' import { fileTests } from '@lezer/generator/dist/test' + import * as fs from 'fs' import * as path from 'path' -import { KclLanguage } from '../src/index' - let caseDir = path.dirname(__filename) for (let file of fs.readdirSync(caseDir)) { diff --git a/packages/codemirror-lang-kcl/vitest.main.config.ts b/packages/codemirror-lang-kcl/vitest.main.config.ts index cd5eabe60..814142a18 100644 --- a/packages/codemirror-lang-kcl/vitest.main.config.ts +++ b/packages/codemirror-lang-kcl/vitest.main.config.ts @@ -1,8 +1,9 @@ // Overrides the test options from the modeling-app config. + +import viteTsconfigPaths from 'vite-tsconfig-paths' +import { defineConfig, configDefaults } from 'vitest/config' // @ts-ignore: No types available import { lezer } from '@lezer/generator/rollup' -import viteTsconfigPaths from 'vite-tsconfig-paths' -import { configDefaults, defineConfig } from 'vitest/config' const config = defineConfig({ test: { diff --git a/packages/codemirror-lsp-client/src/client/codec/bytes.ts b/packages/codemirror-lsp-client/src/client/codec/bytes.ts index 59bc2a356..73d778752 100644 --- a/packages/codemirror-lsp-client/src/client/codec/bytes.ts +++ b/packages/codemirror-lsp-client/src/client/codec/bytes.ts @@ -1,4 +1,4 @@ -import { decoder, encoder } from '../codec' +import { encoder, decoder } from '../codec' export default class Bytes { static encode(input: string): Uint8Array { @@ -10,7 +10,7 @@ export default class Bytes { } static append< - T extends { length: number; set(arr: T, offset: number): void }, + T extends { length: number; set(arr: T, offset: number): void } >(constructor: { new (length: number): T }, ...arrays: T[]) { let totalLength = 0 for (const arr of arrays) { diff --git a/packages/codemirror-lsp-client/src/client/codec/demuxer.ts b/packages/codemirror-lsp-client/src/client/codec/demuxer.ts index 5710aaf39..dff846d6a 100644 --- a/packages/codemirror-lsp-client/src/client/codec/demuxer.ts +++ b/packages/codemirror-lsp-client/src/client/codec/demuxer.ts @@ -2,9 +2,9 @@ import * as vsrpc from 'vscode-jsonrpc' import { Codec } from '.' import Bytes from './bytes' -import PromiseMap from './map' import Queue from './queue' import Tracer from './tracer' +import PromiseMap from './map' export default class StreamDemuxer extends Queue { readonly responses: PromiseMap = diff --git a/packages/codemirror-lsp-client/src/client/index.ts b/packages/codemirror-lsp-client/src/client/index.ts index 575f18afc..822957482 100644 --- a/packages/codemirror-lsp-client/src/client/index.ts +++ b/packages/codemirror-lsp-client/src/client/index.ts @@ -1,8 +1,8 @@ import type * as LSP from 'vscode-languageserver-protocol' -import { LanguageServerPlugin } from '../plugin/lsp' import { FromServer, IntoServer } from './codec' import Client from './jsonrpc' +import { LanguageServerPlugin } from '../plugin/lsp' // https://microsoft.github.io/language-server-protocol/specifications/specification-current/ @@ -12,15 +12,15 @@ interface LSPRequestMap { 'textDocument/hover': [LSP.HoverParams, LSP.Hover] 'textDocument/completion': [ LSP.CompletionParams, - LSP.CompletionItem[] | LSP.CompletionList | null, + LSP.CompletionItem[] | LSP.CompletionList | null ] 'textDocument/semanticTokens/full': [ LSP.SemanticTokensParams, - LSP.SemanticTokens, + LSP.SemanticTokens ] 'textDocument/formatting': [ LSP.DocumentFormattingParams, - LSP.TextEdit[] | null, + LSP.TextEdit[] | null ] 'textDocument/foldingRange': [LSP.FoldingRangeParams, LSP.FoldingRange[]] } diff --git a/packages/codemirror-lsp-client/src/client/jsonrpc.ts b/packages/codemirror-lsp-client/src/client/jsonrpc.ts index 079ea5f84..0a18bf9d0 100644 --- a/packages/codemirror-lsp-client/src/client/jsonrpc.ts +++ b/packages/codemirror-lsp-client/src/client/jsonrpc.ts @@ -1,11 +1,11 @@ import * as jsrpc from 'json-rpc-2.0' import * as LSP from 'vscode-languageserver-protocol' -import { Codec, FromServer, IntoServer } from './codec' import { registerServerCapability, unregisterServerCapability, } from './server-capability-registration' +import { Codec, FromServer, IntoServer } from './codec' const client_capabilities: LSP.ClientCapabilities = { textDocument: { diff --git a/packages/codemirror-lsp-client/src/index.ts b/packages/codemirror-lsp-client/src/index.ts index a76c4587c..708aca942 100644 --- a/packages/codemirror-lsp-client/src/index.ts +++ b/packages/codemirror-lsp-client/src/index.ts @@ -1,14 +1,14 @@ import { foldService } from '@codemirror/language' -import { EditorState, Extension } from '@codemirror/state' +import { Extension, EditorState } from '@codemirror/state' import { ViewPlugin } from '@codemirror/view' import { - LanguageServerOptions, + docPathFacet, LanguageServerPlugin, LanguageServerPluginSpec, - docPathFacet, languageId, workspaceFolders, + LanguageServerOptions, } from './plugin/lsp' export type { LanguageServerClientOptions } from './client' diff --git a/packages/codemirror-lsp-client/src/plugin/autocomplete.ts b/packages/codemirror-lsp-client/src/plugin/autocomplete.ts index dad5ffc5b..a1352c71c 100644 --- a/packages/codemirror-lsp-client/src/plugin/autocomplete.ts +++ b/packages/codemirror-lsp-client/src/plugin/autocomplete.ts @@ -9,9 +9,9 @@ import { prevSnippetField, startCompletion, } from '@codemirror/autocomplete' -import { syntaxTree } from '@codemirror/language' -import { Extension, Prec } from '@codemirror/state' -import { EditorView, KeyBinding, ViewPlugin, keymap } from '@codemirror/view' +import { Prec, Extension } from '@codemirror/state' +import { EditorView, keymap, KeyBinding, ViewPlugin } from '@codemirror/view' + import { CompletionItemKind, CompletionTriggerKind, @@ -19,6 +19,7 @@ import { import { LanguageServerPlugin } from './lsp' import { offsetToPos } from './util' +import { syntaxTree } from '@codemirror/language' export const CompletionItemKindMap = Object.fromEntries( Object.entries(CompletionItemKind).map(([key, value]) => [value, key]) diff --git a/packages/codemirror-lsp-client/src/plugin/format.ts b/packages/codemirror-lsp-client/src/plugin/format.ts index c922979dd..d7cedc1a4 100644 --- a/packages/codemirror-lsp-client/src/plugin/format.ts +++ b/packages/codemirror-lsp-client/src/plugin/format.ts @@ -1,5 +1,5 @@ import { Extension, Prec } from '@codemirror/state' -import { EditorView, KeyBinding, ViewPlugin, keymap } from '@codemirror/view' +import { EditorView, keymap, KeyBinding, ViewPlugin } from '@codemirror/view' import { LanguageServerPlugin } from './lsp' diff --git a/packages/codemirror-lsp-client/src/plugin/hover.ts b/packages/codemirror-lsp-client/src/plugin/hover.ts index 01c13c177..ec2a843d7 100644 --- a/packages/codemirror-lsp-client/src/plugin/hover.ts +++ b/packages/codemirror-lsp-client/src/plugin/hover.ts @@ -1,9 +1,9 @@ import { Extension } from '@codemirror/state' import { - EditorView, - ViewPlugin, hoverTooltip, tooltips, + ViewPlugin, + EditorView, } from '@codemirror/view' import { LanguageServerPlugin } from './lsp' diff --git a/packages/codemirror-lsp-client/src/plugin/lsp.ts b/packages/codemirror-lsp-client/src/plugin/lsp.ts index bb6419335..c8c7e0fb6 100644 --- a/packages/codemirror-lsp-client/src/plugin/lsp.ts +++ b/packages/codemirror-lsp-client/src/plugin/lsp.ts @@ -4,38 +4,39 @@ import type { CompletionResult, } from '@codemirror/autocomplete' import { completeFromList, snippetCompletion } from '@codemirror/autocomplete' -import { linter } from '@codemirror/lint' import { - Annotation, - Extension, Facet, StateEffect, + Extension, Transaction, + Annotation, } from '@codemirror/state' import type { - PluginSpec, - PluginValue, - ViewPlugin, ViewUpdate, + PluginValue, + PluginSpec, + ViewPlugin, } from '@codemirror/view' import { EditorView, Tooltip } from '@codemirror/view' +import { linter } from '@codemirror/lint' + import type { PublishDiagnosticsParams } from 'vscode-languageserver-protocol' import type * as LSP from 'vscode-languageserver-protocol' import { - CompletionTriggerKind, DiagnosticSeverity, + CompletionTriggerKind, } from 'vscode-languageserver-protocol' import { URI } from 'vscode-uri' import { LanguageServerClient } from '../client' import { CompletionItemKindMap } from './autocomplete' +import { addToken, SemanticToken } from './semantic-tokens' +import { posToOffset, formatMarkdownContents } from './util' import lspAutocompleteExt from './autocomplete' -import lspFormatExt from './format' import lspHoverExt from './hover' +import lspFormatExt from './format' import lspIndentExt from './indent' -import { SemanticToken, addToken } from './semantic-tokens' import lspSemanticTokensExt from './semantic-tokens' -import { formatMarkdownContents, posToOffset } from './util' const useLast = (values: readonly any[]) => values.reduce((_, v) => v, '') export const docPathFacet = Facet.define({ @@ -97,10 +98,7 @@ export class LanguageServerPlugin implements PluginValue { // document. private sendScheduled: number | null = null - constructor( - options: LanguageServerOptions, - private view: EditorView - ) { + constructor(options: LanguageServerOptions, private view: EditorView) { this.client = options.client this.documentVersion = 0 diff --git a/packages/codemirror-lsp-client/src/plugin/semantic-tokens.ts b/packages/codemirror-lsp-client/src/plugin/semantic-tokens.ts index a4c63f754..02af94d33 100644 --- a/packages/codemirror-lsp-client/src/plugin/semantic-tokens.ts +++ b/packages/codemirror-lsp-client/src/plugin/semantic-tokens.ts @@ -1,6 +1,7 @@ import { highlightingFor } from '@codemirror/language' -import { Extension, StateEffect, StateField } from '@codemirror/state' -import { Decoration, DecorationSet, EditorView } from '@codemirror/view' +import { StateEffect, StateField, Extension } from '@codemirror/state' +import { EditorView, Decoration, DecorationSet } from '@codemirror/view' + import { Tag, tags } from '@lezer/highlight' import { lspSemanticTokensEvent } from './lsp' diff --git a/packages/codemirror-lsp-client/src/plugin/util.ts b/packages/codemirror-lsp-client/src/plugin/util.ts index 84e5075af..f70e429f3 100644 --- a/packages/codemirror-lsp-client/src/plugin/util.ts +++ b/packages/codemirror-lsp-client/src/plugin/util.ts @@ -1,7 +1,7 @@ import { Text } from '@codemirror/state' import { Marked, MarkedOptions } from '@ts-stack/markdown' -import type * as LSP from 'vscode-languageserver-protocol' +import type * as LSP from 'vscode-languageserver-protocol' import { isArray } from '../lib/utils' // takes a function and executes it after the wait time, if the function is called again before the wait time is up, the timer is reset diff --git a/prettier.config.js b/prettier.config.js deleted file mode 100644 index 45d9a01a2..000000000 --- a/prettier.config.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - trailingComma: 'es5', - tabWidth: 2, - semi: false, - singleQuote: true, - importOrder: ['', '^@rust/(.*)$', '^[./]'], - importOrderSeparation: true, - importOrderSortSpecifiers: true, - plugins: ['@trivago/prettier-plugin-sort-imports'], -} diff --git a/rust/kcl-language-server/client/src/bootstrap.ts b/rust/kcl-language-server/client/src/bootstrap.ts index fdda77e8f..77d5e0f04 100644 --- a/rust/kcl-language-server/client/src/bootstrap.ts +++ b/rust/kcl-language-server/client/src/bootstrap.ts @@ -1,11 +1,10 @@ /* eslint suggest-no-throw/suggest-no-throw: 0 */ -import { exec } from 'child_process' -import * as os from 'os' import * as vscode from 'vscode' - +import * as os from 'os' import type { Config } from './config' +import { log, isValidExecutable } from './util' import type { PersistentState } from './persistent_state' -import { isValidExecutable, log } from './util' +import { exec } from 'child_process' export async function bootstrap( context: vscode.ExtensionContext, diff --git a/rust/kcl-language-server/client/src/client.ts b/rust/kcl-language-server/client/src/client.ts index 772103c34..968fe7d65 100644 --- a/rust/kcl-language-server/client/src/client.ts +++ b/rust/kcl-language-server/client/src/client.ts @@ -1,6 +1,6 @@ /* eslint suggest-no-throw/suggest-no-throw: 0 */ -import type * as vscode from 'vscode' import * as lc from 'vscode-languageclient/node' +import type * as vscode from 'vscode' export async function createClient( traceOutputChannel: vscode.OutputChannel, diff --git a/rust/kcl-language-server/client/src/commands.ts b/rust/kcl-language-server/client/src/commands.ts index 31b629399..b51c8ec53 100644 --- a/rust/kcl-language-server/client/src/commands.ts +++ b/rust/kcl-language-server/client/src/commands.ts @@ -1,8 +1,8 @@ /* eslint suggest-no-throw/suggest-no-throw: 0 */ -import { spawnSync } from 'child_process' import * as vscode from 'vscode' import type { Cmd, CtxInit } from './ctx' +import { spawnSync } from 'child_process' export function serverVersion(ctx: CtxInit): Cmd { return async () => { diff --git a/rust/kcl-language-server/client/src/config.ts b/rust/kcl-language-server/client/src/config.ts index 7a96d42e7..49ad5addd 100644 --- a/rust/kcl-language-server/client/src/config.ts +++ b/rust/kcl-language-server/client/src/config.ts @@ -1,11 +1,10 @@ /* eslint suggest-no-throw/suggest-no-throw: 0 */ +import * as Is from 'vscode-languageclient/lib/common/utils/is' import * as os from 'os' import * as path from 'path' import * as vscode from 'vscode' -import * as Is from 'vscode-languageclient/lib/common/utils/is' - +import { log, type Env } from './util' import { expectNotUndefined, unwrapUndefinable } from './undefinable' -import { type Env, log } from './util' export type RunnableEnvCfgItem = { mask?: string diff --git a/rust/kcl-language-server/client/src/ctx.ts b/rust/kcl-language-server/client/src/ctx.ts index ffe4100a5..7ebe3f7af 100644 --- a/rust/kcl-language-server/client/src/ctx.ts +++ b/rust/kcl-language-server/client/src/ctx.ts @@ -1,20 +1,20 @@ /* eslint suggest-no-throw/suggest-no-throw: 0 */ import * as vscode from 'vscode' import type * as lc from 'vscode-languageclient/node' -import { TransportKind } from 'vscode-languageclient/node' -import { bootstrap } from './bootstrap' -import { createClient } from './client' import { Config, prepareVSCodeConfig } from './config' -import type { ServerStatusParams } from './lsp_ext' -import { PersistentState } from './persistent_state' +import { createClient } from './client' import { - type KclEditor, - LazyOutputChannel, isKclDocument, isKclEditor, + LazyOutputChannel, log, + type KclEditor, } from './util' +import type { ServerStatusParams } from './lsp_ext' +import { PersistentState } from './persistent_state' +import { bootstrap } from './bootstrap' +import { TransportKind } from 'vscode-languageclient/node' // We only support local folders, not eg. Live Share (`vlsl:` scheme), so don't activate if // only those are in use. We use "Empty" to represent these scenarios diff --git a/rust/kcl-language-server/client/src/persistent_state.ts b/rust/kcl-language-server/client/src/persistent_state.ts index 14c02e1d1..ae9e60204 100644 --- a/rust/kcl-language-server/client/src/persistent_state.ts +++ b/rust/kcl-language-server/client/src/persistent_state.ts @@ -1,6 +1,5 @@ /* eslint suggest-no-throw/suggest-no-throw: 0 */ import type * as vscode from 'vscode' - import { log } from './util' export class PersistentState { diff --git a/rust/kcl-language-server/client/src/test/runTest.ts b/rust/kcl-language-server/client/src/test/runTest.ts index 7467c59a4..542d5903e 100644 --- a/rust/kcl-language-server/client/src/test/runTest.ts +++ b/rust/kcl-language-server/client/src/test/runTest.ts @@ -1,6 +1,7 @@ -import { runTests } from '@vscode/test-electron' import * as path from 'path' +import { runTests } from '@vscode/test-electron' + async function main() { try { // The folder containing the Extension Manifest package.json diff --git a/rust/kcl-language-server/client/src/test/suite/extension.test.ts b/rust/kcl-language-server/client/src/test/suite/extension.test.ts index 42b002018..d28ece25b 100644 --- a/rust/kcl-language-server/client/src/test/suite/extension.test.ts +++ b/rust/kcl-language-server/client/src/test/suite/extension.test.ts @@ -1,8 +1,8 @@ import * as assert from 'assert' + // You can import and use all API from the 'vscode' module // as well as import your extension to test it import * as vscode from 'vscode' - // import * as myExtension from '../../extension'; suite('Extension Test Suite', () => { diff --git a/rust/kcl-language-server/client/src/test/suite/index.ts b/rust/kcl-language-server/client/src/test/suite/index.ts index c1c17b03b..d6681067c 100644 --- a/rust/kcl-language-server/client/src/test/suite/index.ts +++ b/rust/kcl-language-server/client/src/test/suite/index.ts @@ -1,5 +1,4 @@ import * as path from 'path' - const Mocha = require('mocha') const { glob } = require('glob') diff --git a/rust/kcl-language-server/client/src/util.ts b/rust/kcl-language-server/client/src/util.ts index b8e5fa89b..04ad5a1fd 100644 --- a/rust/kcl-language-server/client/src/util.ts +++ b/rust/kcl-language-server/client/src/util.ts @@ -1,8 +1,8 @@ /* eslint suggest-no-throw/suggest-no-throw: 0 */ -import { strict as nativeAssert } from 'assert' -import { type ExecOptions, exec, spawnSync } from 'child_process' -import { inspect } from 'util' import * as vscode from 'vscode' +import { strict as nativeAssert } from 'assert' +import { exec, type ExecOptions, spawnSync } from 'child_process' +import { inspect } from 'util' export interface Env { [name: string]: string diff --git a/src/App.tsx b/src/App.tsx index 5846f8e8c..d6a63dd45 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,38 +1,36 @@ -import { CameraProjectionToggle } from 'components/CameraProjectionToggle' -import { useEngineCommands } from 'components/EngineCommands' -import Gizmo from 'components/Gizmo' -import { LowerRightControls } from 'components/LowerRightControls' +import { useEffect, useMemo, useRef } from 'react' +import { useHotKeyListener } from './hooks/useHotKeyListener' +import { Stream } from './components/Stream' +import { AppHeader } from './components/AppHeader' +import { useHotkeys } from 'react-hotkeys-hook' +import { useLoaderData, useNavigate } from 'react-router-dom' +import { type IndexLoaderData } from 'lib/types' +import { PATHS } from 'lib/paths' +import { onboardingPaths } from 'routes/Onboarding/paths' +import { useEngineConnectionSubscriptions } from 'hooks/useEngineConnectionSubscriptions' +import { codeManager, engineCommandManager } from 'lib/singletons' +import { useAbsoluteFilePath } from 'hooks/useAbsoluteFilePath' +import { isDesktop } from 'lib/isDesktop' import { useLspContext } from 'components/LspProvider' import { ModelingSidebar } from 'components/ModelingSidebar/ModelingSidebar' -import { UnitsMenu } from 'components/UnitsMenu' -import { useAbsoluteFilePath } from 'hooks/useAbsoluteFilePath' -import { useCreateFileLinkQuery } from 'hooks/useCreateFileLinkQueryWatcher' -import { useEngineConnectionSubscriptions } from 'hooks/useEngineConnectionSubscriptions' -import { CoreDumpManager } from 'lib/coredump' -import { writeProjectThumbnailFile } from 'lib/desktop' +import { LowerRightControls } from 'components/LowerRightControls' +import ModalContainer from 'react-modal-promise' import useHotkeyWrapper from 'lib/hotkeyWrapper' -import { isDesktop } from 'lib/isDesktop' -import { PATHS } from 'lib/paths' -import { takeScreenshotOfVideoStreamCanvas } from 'lib/screenshot' -import { codeManager, engineCommandManager } from 'lib/singletons' -import { rustContext } from 'lib/singletons' +import Gizmo from 'components/Gizmo' +import { CoreDumpManager } from 'lib/coredump' +import { UnitsMenu } from 'components/UnitsMenu' +import { CameraProjectionToggle } from 'components/CameraProjectionToggle' +import { useCreateFileLinkQuery } from 'hooks/useCreateFileLinkQueryWatcher' import { maybeWriteToDisk } from 'lib/telemetry' -import { type IndexLoaderData } from 'lib/types' +import { takeScreenshotOfVideoStreamCanvas } from 'lib/screenshot' +import { writeProjectThumbnailFile } from 'lib/desktop' +import { useRouteLoaderData } from 'react-router-dom' +import { useEngineCommands } from 'components/EngineCommands' +import { commandBarActor } from 'machines/commandBarMachine' import { useToken } from 'machines/appMachine' import { useSettings } from 'machines/appMachine' -import { commandBarActor } from 'machines/commandBarMachine' -import { useEffect, useMemo, useRef } from 'react' +import { rustContext } from 'lib/singletons' import toast from 'react-hot-toast' -import { useHotkeys } from 'react-hotkeys-hook' -import ModalContainer from 'react-modal-promise' -import { useLoaderData, useNavigate } from 'react-router-dom' -import { useRouteLoaderData } from 'react-router-dom' -import { onboardingPaths } from 'routes/Onboarding/paths' - -import { AppHeader } from './components/AppHeader' -import { Stream } from './components/Stream' -import { useHotKeyListener } from './hooks/useHotKeyListener' - maybeWriteToDisk() .then(() => {}) .catch(() => {}) diff --git a/src/AppState.tsx b/src/AppState.tsx index 3c83b2a6a..7ecb30fdc 100644 --- a/src/AppState.tsx +++ b/src/AppState.tsx @@ -1,4 +1,4 @@ -import { ReactNode, createContext, useContext, useState } from 'react' +import { createContext, useContext, useState, ReactNode } from 'react' /* diff --git a/src/Auth.tsx b/src/Auth.tsx index 95618e5e7..7281471c2 100644 --- a/src/Auth.tsx +++ b/src/Auth.tsx @@ -1,5 +1,4 @@ import { useAuthState } from 'machines/appMachine' - import Loading from './components/Loading' // Wrapper around protected routes, used in src/Router.tsx diff --git a/src/Router.tsx b/src/Router.tsx index 1c93aea6e..b13e97301 100644 --- a/src/Router.tsx +++ b/src/Router.tsx @@ -1,47 +1,46 @@ -import { AppStateProvider } from 'AppState' -import { CommandBar } from 'components/CommandBar/CommandBar' -import DownloadAppBanner from 'components/DownloadAppBanner' -import FileMachineProvider from 'components/FileMachineProvider' -import LspProvider from 'components/LspProvider' -import { MachineManagerProvider } from 'components/MachineManagerProvider' -import ModelingMachineProvider from 'components/ModelingMachineProvider' -import { OpenInDesktopAppHandler } from 'components/OpenInDesktopAppHandler' -import { ProjectsContextProvider } from 'components/ProjectsContextProvider' -import { RouteProvider } from 'components/RouteProvider' -import { WasmErrBanner } from 'components/WasmErrBanner' -import { KclContextProvider } from 'lang/KclProvider' -import { coreDump } from 'lang/wasm' -import { ASK_TO_OPEN_QUERY_PARAM, BROWSER_PROJECT_NAME } from 'lib/constants' -import { CoreDumpManager } from 'lib/coredump' -import useHotkeyWrapper from 'lib/hotkeyWrapper' -import { PATHS } from 'lib/paths' -import { fileLoader, homeLoader, telemetryLoader } from 'lib/routeLoaders' -import { codeManager, engineCommandManager } from 'lib/singletons' -import { rustContext } from 'lib/singletons' -import { reportRejection } from 'lib/trap' -import { useToken } from 'machines/appMachine' -import { useMemo } from 'react' -import toast from 'react-hot-toast' +import { App } from './App' import { - Outlet, - RouterProvider, createBrowserRouter, createHashRouter, + Outlet, redirect, + RouterProvider, } from 'react-router-dom' - -import { App } from './App' -import { Auth } from './Auth' import { ErrorPage } from './components/ErrorPage' +import { Settings } from './routes/Settings' +import { Telemetry } from './routes/Telemetry' +import Onboarding, { onboardingRoutes } from './routes/Onboarding' +import SignIn from './routes/SignIn' +import { Auth } from './Auth' +import { isDesktop } from './lib/isDesktop' +import Home from './routes/Home' import { NetworkContext } from './hooks/useNetworkContext' import { useNetworkStatus } from './hooks/useNetworkStatus' -import { isDesktop } from './lib/isDesktop' import makeUrlPathRelative from './lib/makeUrlPathRelative' -import Home from './routes/Home' -import Onboarding, { onboardingRoutes } from './routes/Onboarding' -import { Settings } from './routes/Settings' -import SignIn from './routes/SignIn' -import { Telemetry } from './routes/Telemetry' +import DownloadAppBanner from 'components/DownloadAppBanner' +import { WasmErrBanner } from 'components/WasmErrBanner' +import { CommandBar } from 'components/CommandBar/CommandBar' +import ModelingMachineProvider from 'components/ModelingMachineProvider' +import FileMachineProvider from 'components/FileMachineProvider' +import { MachineManagerProvider } from 'components/MachineManagerProvider' +import { PATHS } from 'lib/paths' +import { fileLoader, homeLoader, telemetryLoader } from 'lib/routeLoaders' +import LspProvider from 'components/LspProvider' +import { KclContextProvider } from 'lang/KclProvider' +import { ASK_TO_OPEN_QUERY_PARAM, BROWSER_PROJECT_NAME } from 'lib/constants' +import { CoreDumpManager } from 'lib/coredump' +import { codeManager, engineCommandManager } from 'lib/singletons' +import useHotkeyWrapper from 'lib/hotkeyWrapper' +import toast from 'react-hot-toast' +import { coreDump } from 'lang/wasm' +import { useMemo } from 'react' +import { AppStateProvider } from 'AppState' +import { reportRejection } from 'lib/trap' +import { RouteProvider } from 'components/RouteProvider' +import { ProjectsContextProvider } from 'components/ProjectsContextProvider' +import { useToken } from 'machines/appMachine' +import { OpenInDesktopAppHandler } from 'components/OpenInDesktopAppHandler' +import { rustContext } from 'lib/singletons' const createRouter = isDesktop() ? createHashRouter : createBrowserRouter diff --git a/src/Toolbar.tsx b/src/Toolbar.tsx index c278802d8..7a0aa1348 100644 --- a/src/Toolbar.tsx +++ b/src/Toolbar.tsx @@ -1,28 +1,28 @@ -import { useAppState } from 'AppState' -import { ActionButton } from 'components/ActionButton' -import { ActionButtonDropdown } from 'components/ActionButtonDropdown' -import { CustomIcon } from 'components/CustomIcon' -import Tooltip from 'components/Tooltip' +import { useRef, useMemo, memo, useCallback, useState } from 'react' +import { isCursorInSketchCommandRange } from 'lang/util' +import { editorManager, kclManager } from 'lib/singletons' import { useModelingContext } from 'hooks/useModelingContext' import { useNetworkContext } from 'hooks/useNetworkContext' import { NetworkHealthState } from 'hooks/useNetworkStatus' +import { ActionButton } from 'components/ActionButton' import { useKclContext } from 'lang/KclProvider' -import { isCursorInFunctionDefinition } from 'lang/queryAst' -import { isCursorInSketchCommandRange } from 'lang/util' -import { isDesktop } from 'lib/isDesktop' -import { openExternalBrowserIfDesktop } from 'lib/openWindow' -import { editorManager, kclManager } from 'lib/singletons' +import { ActionButtonDropdown } from 'components/ActionButtonDropdown' +import { useHotkeys } from 'react-hotkeys-hook' +import Tooltip from 'components/Tooltip' +import { useAppState } from 'AppState' +import { CustomIcon } from 'components/CustomIcon' import { + toolbarConfig, ToolbarItem, ToolbarItemCallbackProps, ToolbarItemResolved, ToolbarModeName, - toolbarConfig, } from 'lib/toolbar' -import { isArray } from 'lib/utils' +import { isDesktop } from 'lib/isDesktop' +import { openExternalBrowserIfDesktop } from 'lib/openWindow' +import { isCursorInFunctionDefinition } from 'lang/queryAst' import { commandBarActor } from 'machines/commandBarMachine' -import { memo, useCallback, useMemo, useRef, useState } from 'react' -import { useHotkeys } from 'react-hotkeys-hook' +import { isArray } from 'lib/utils' export function Toolbar({ className = '', diff --git a/src/clientSideScene/CameraControls.ts b/src/clientSideScene/CameraControls.ts index cf9b698a2..92ae7196d 100644 --- a/src/clientSideScene/CameraControls.ts +++ b/src/clientSideScene/CameraControls.ts @@ -1,16 +1,4 @@ -import { CameraDragInteractionType_type } from '@kittycad/lib/dist/types/src/models' -import * as TWEEN from '@tweenjs/tween.js' -import { EngineCommand } from 'lang/std/artifactGraph' -import { - EngineCommandManager, - Subscription, - UnreliableSubscription, -} from 'lang/std/engineConnection' -import { MouseGuard, cameraMouseDragGuards } from 'lib/cameraControls' -import { reportRejection } from 'lib/trap' -import { getNormalisedCoordinates, toSync, uuidv4 } from 'lib/utils' -import { isReducedMotion, roundOff, throttle } from 'lib/utils' -import { deg2Rad } from 'lib/utils2d' +import { cameraMouseDragGuards, MouseGuard } from 'lib/cameraControls' import { Euler, MathUtils, @@ -22,16 +10,26 @@ import { Vector2, Vector3, } from 'three' - -import { CameraProjectionType } from '@rust/kcl-lib/bindings/CameraProjectionType' - -import { isQuaternionVertical } from './helpers' import { DEBUG_SHOW_INTERSECTION_PLANE, INTERSECTION_PLANE_LAYER, SKETCH_LAYER, ZOOM_MAGIC_NUMBER, } from './sceneInfra' +import { + Subscription, + EngineCommandManager, + UnreliableSubscription, +} from 'lang/std/engineConnection' +import { EngineCommand } from 'lang/std/artifactGraph' +import { toSync, uuidv4, getNormalisedCoordinates } from 'lib/utils' +import { deg2Rad } from 'lib/utils2d' +import { isReducedMotion, roundOff, throttle } from 'lib/utils' +import * as TWEEN from '@tweenjs/tween.js' +import { isQuaternionVertical } from './helpers' +import { reportRejection } from 'lib/trap' +import { CameraProjectionType } from '@rust/kcl-lib/bindings/CameraProjectionType' +import { CameraDragInteractionType_type } from '@kittycad/lib/dist/types/src/models' const ORTHOGRAPHIC_CAMERA_SIZE = 20 const FRAMES_TO_ANIMATE_IN = 30 diff --git a/src/clientSideScene/ClientSideSceneComp.tsx b/src/clientSideScene/ClientSideSceneComp.tsx index 7b5f0edc8..06c9a70e5 100644 --- a/src/clientSideScene/ClientSideSceneComp.tsx +++ b/src/clientSideScene/ClientSideSceneComp.tsx @@ -1,55 +1,54 @@ -import { Dialog, Popover, Transition } from '@headlessui/react' -import { ActionButton } from 'components/ActionButton' -import { CustomIcon, CustomIconName } from 'components/CustomIcon' +import { useRef, useEffect, useState, useMemo, Fragment } from 'react' import { useModelingContext } from 'hooks/useModelingContext' -import { executeAstMock } from 'lang/langHelpers' -import { - deleteSegmentFromPipeExpression, - removeSingleConstraintInfo, -} from 'lang/modifyAst' -import { findUsesOfTagInPipe, getNodeFromPath } from 'lang/queryAst' -import { getConstraintInfo, getConstraintInfoKw } from 'lang/std/sketch' -import { ConstrainInfo } from 'lang/std/stdTypes' -import { - CallExpression, - CallExpressionKw, - Expr, - PathToNode, - Program, - defaultSourceRange, - parse, - recast, - resultIsOk, - topLevelRange, -} from 'lang/wasm' + import { cameraMouseDragGuards } from 'lib/cameraControls' +import { ARROWHEAD, DEBUG_SHOW_BOTH_SCENES } from './sceneInfra' +import { ReactCameraProperties } from './CameraControls' +import { throttle, toSync } from 'lib/utils' import { + sceneInfra, + kclManager, codeManager, editorManager, - engineCommandManager, - kclManager, - rustContext, sceneEntitiesManager, - sceneInfra, + engineCommandManager, + rustContext, } from 'lib/singletons' -import { err, reportRejection, trap } from 'lib/trap' -import { throttle, toSync } from 'lib/utils' -import { useSettings } from 'machines/appMachine' -import { commandBarActor } from 'machines/commandBarMachine' -import { SegmentOverlay, SketchDetails } from 'machines/modelingMachine' -import { Fragment, useEffect, useMemo, useRef, useState } from 'react' -import toast from 'react-hot-toast' -import { InstanceProps, create } from 'react-modal-promise' - -import { Node } from '@rust/kcl-lib/bindings/Node' - -import { ReactCameraProperties } from './CameraControls' import { EXTRA_SEGMENT_HANDLE, PROFILE_START, getParentGroup, } from './sceneEntities' -import { ARROWHEAD, DEBUG_SHOW_BOTH_SCENES } from './sceneInfra' +import { SegmentOverlay, SketchDetails } from 'machines/modelingMachine' +import { findUsesOfTagInPipe, getNodeFromPath } from 'lang/queryAst' +import { + CallExpression, + CallExpressionKw, + PathToNode, + Program, + Expr, + parse, + recast, + defaultSourceRange, + resultIsOk, + topLevelRange, +} from 'lang/wasm' +import { CustomIcon, CustomIconName } from 'components/CustomIcon' +import { ConstrainInfo } from 'lang/std/stdTypes' +import { getConstraintInfo, getConstraintInfoKw } from 'lang/std/sketch' +import { Dialog, Popover, Transition } from '@headlessui/react' +import toast from 'react-hot-toast' +import { InstanceProps, create } from 'react-modal-promise' +import { executeAstMock } from 'lang/langHelpers' +import { + deleteSegmentFromPipeExpression, + removeSingleConstraintInfo, +} from 'lang/modifyAst' +import { ActionButton } from 'components/ActionButton' +import { err, reportRejection, trap } from 'lib/trap' +import { Node } from '@rust/kcl-lib/bindings/Node' +import { commandBarActor } from 'machines/commandBarMachine' +import { useSettings } from 'machines/appMachine' function useShouldHideScene(): { hideClient: boolean; hideServer: boolean } { const [isCamMoving, setIsCamMoving] = useState(false) @@ -636,8 +635,8 @@ const ConstraintSymbol = ({ implicitDesc ? 'bg-chalkboard-10 dark:bg-chalkboard-100 border-transparent border-0 rounded' : isConstrained - ? 'bg-chalkboard-10 dark:bg-chalkboard-90 dark:hover:bg-chalkboard-80 border-chalkboard-40 dark:border-chalkboard-70 rounded-sm' - : 'bg-primary/30 dark:bg-primary text-primary dark:text-chalkboard-10 dark:border-transparent group-hover:bg-primary/40 group-hover:border-primary/50 group-hover:brightness-125' + ? 'bg-chalkboard-10 dark:bg-chalkboard-90 dark:hover:bg-chalkboard-80 border-chalkboard-40 dark:border-chalkboard-70 rounded-sm' + : 'bg-primary/30 dark:bg-primary text-primary dark:text-chalkboard-10 dark:border-transparent group-hover:bg-primary/40 group-hover:border-primary/50 group-hover:brightness-125' } h-[26px] w-[26px] rounded-sm relative m-0 p-0`} onMouseEnter={() => { editorManager.setHighlightRange([range]) diff --git a/src/clientSideScene/helpers.test.ts b/src/clientSideScene/helpers.test.ts index 43a8aee1f..1b6a68309 100644 --- a/src/clientSideScene/helpers.test.ts +++ b/src/clientSideScene/helpers.test.ts @@ -1,5 +1,4 @@ import { Quaternion } from 'three' - import { isQuaternionVertical } from './helpers' describe('isQuaternionVertical', () => { diff --git a/src/clientSideScene/helpers.ts b/src/clientSideScene/helpers.ts index 55e136503..e938fa2c5 100644 --- a/src/clientSideScene/helpers.ts +++ b/src/clientSideScene/helpers.ts @@ -1,11 +1,11 @@ import { compareVec2Epsilon2 } from 'lang/std/sketch' import { GridHelper, - Group, LineBasicMaterial, - Mesh, OrthographicCamera, PerspectiveCamera, + Group, + Mesh, Quaternion, Vector3, } from 'three' diff --git a/src/clientSideScene/sceneEntities.ts b/src/clientSideScene/sceneEntities.ts index faf91f4b2..e2181ed94 100644 --- a/src/clientSideScene/sceneEntities.ts +++ b/src/clientSideScene/sceneEntities.ts @@ -1,89 +1,8 @@ -import { Models } from '@kittycad/lib' -import { ToolTip, executeAstMock } from 'lang/langHelpers' -import { updateModelingState } from 'lang/modelingWorkflows' -import { - createArrayExpression, - createCallExpressionStdLib, - createCallExpressionStdLibKw, - createLabeledArg, - createLiteral, - createLocalName, - createNodeFromExprSnippet, - createPipeExpression, - createPipeSubstitution, - createVariableDeclaration, - findUniqueName, - getInsertIndex, - insertNewStartProfileAt, - updateSketchNodePathsWithInsertIndex, -} from 'lang/modifyAst' -import { getNodeFromPath } from 'lang/queryAst' -import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' -import { codeRefFromRange, getArtifactFromRange } from 'lang/std/artifactGraph' -import { EngineCommandManager } from 'lang/std/engineConnection' -import { - ARG_END_ABSOLUTE, - Coords2d, - addCallExpressionsToPipe, - addCloseToPipe, - addNewSketchLn, - changeSketchArguments, - updateStartProfileAtArgs, -} from 'lang/std/sketch' -import { SegmentInputs } from 'lang/std/stdTypes' -import { - CallExpression, - CallExpressionKw, - Path, - PathToNode, - PipeExpression, - Program, - Sketch, - SourceRange, - VariableDeclaration, - VariableDeclarator, - VariableMap, - defaultSourceRange, - parse, - recast, - resultIsOk, - sketchFromKclValue, - sourceRangeFromRust, - topLevelRange, -} from 'lang/wasm' -import { EXECUTION_TYPE_MOCK } from 'lib/constants' -import { - getRectangleCallExpressions, - updateCenterRectangleSketch, - updateRectangleSketch, -} from 'lib/rectangleTool' -import { Selections, getEventForSegmentSelection } from 'lib/selections' -import { - codeManager, - editorManager, - engineCommandManager, - kclManager, - rustContext, - sceneInfra, -} from 'lib/singletons' -import { Themes, getThemeColorForThreeJs } from 'lib/theme' -import { err, reportRejection, trap } from 'lib/trap' -import { isArray, isOverlap, roundOff } from 'lib/utils' -import { uuidv4 } from 'lib/utils' -import { - SegmentOverlayPayload, - SketchDetails, - SketchDetailsUpdate, - SketchTool, -} from 'machines/modelingMachine' -import toast from 'react-hot-toast' import { BoxGeometry, DoubleSide, - ExtrudeGeometry, Group, Intersection, - LineCurve3, Mesh, MeshBasicMaterial, Object3D, @@ -93,24 +12,19 @@ import { PlaneGeometry, Points, Quaternion, - Shape, Vector2, Vector3, + Shape, + LineCurve3, + ExtrudeGeometry, } from 'three' -import { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer' -import { radToDeg } from 'three/src/math/MathUtils' - -import { Node } from '@rust/kcl-lib/bindings/Node' -import { Point3d } from '@rust/kcl-lib/bindings/Point3d' - -import { isQuaternionVertical, quaternionFromUpNForward } from './helpers' -import { createGridHelper, orthoScale, perspScale } from './helpers' import { ANGLE_SNAP_THRESHOLD_DEGREES, ARROWHEAD, AXIS_GROUP, DRAFT_POINT, DRAFT_POINT_GROUP, + getSceneScale, INTERSECTION_PLANE_LAYER, OnClickCallbackArgs, OnMouseEnterLeaveArgs, @@ -119,14 +33,98 @@ import { SKETCH_LAYER, X_AXIS, Y_AXIS, - getSceneScale, } from './sceneInfra' +import { isQuaternionVertical, quaternionFromUpNForward } from './helpers' +import { + CallExpression, + parse, + Path, + PathToNode, + PipeExpression, + Program, + recast, + Sketch, + VariableDeclaration, + VariableDeclarator, + sketchFromKclValue, + defaultSourceRange, + sourceRangeFromRust, + resultIsOk, + SourceRange, + topLevelRange, + CallExpressionKw, + VariableMap, +} from 'lang/wasm' +import { + engineCommandManager, + kclManager, + sceneInfra, + codeManager, + editorManager, + rustContext, +} from 'lib/singletons' +import { getNodeFromPath } from 'lang/queryAst' +import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' +import { executeAstMock, ToolTip } from 'lang/langHelpers' import { - SegmentUtils, createProfileStartHandle, dashedStraight, + SegmentUtils, segmentUtils, } from './segments' +import { + addCallExpressionsToPipe, + addCloseToPipe, + addNewSketchLn, + ARG_END_ABSOLUTE, + changeSketchArguments, + Coords2d, + updateStartProfileAtArgs, +} from 'lang/std/sketch' +import { isArray, isOverlap, roundOff } from 'lib/utils' +import { + createArrayExpression, + createCallExpressionStdLib, + createLocalName, + createCallExpressionStdLibKw, + createLabeledArg, + createLiteral, + createNodeFromExprSnippet, + createPipeExpression, + createPipeSubstitution, + createVariableDeclaration, + findUniqueName, + getInsertIndex, + insertNewStartProfileAt, + updateSketchNodePathsWithInsertIndex, +} from 'lang/modifyAst' +import { Selections, getEventForSegmentSelection } from 'lib/selections' +import { createGridHelper, orthoScale, perspScale } from './helpers' +import { Models } from '@kittycad/lib' +import { uuidv4 } from 'lib/utils' +import { + SegmentOverlayPayload, + SketchDetails, + SketchDetailsUpdate, + SketchTool, +} from 'machines/modelingMachine' +import { EngineCommandManager } from 'lang/std/engineConnection' +import { + getRectangleCallExpressions, + updateRectangleSketch, + updateCenterRectangleSketch, +} from 'lib/rectangleTool' +import { getThemeColorForThreeJs, Themes } from 'lib/theme' +import { err, reportRejection, trap } from 'lib/trap' +import { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer' +import { Point3d } from '@rust/kcl-lib/bindings/Point3d' +import { SegmentInputs } from 'lang/std/stdTypes' +import { Node } from '@rust/kcl-lib/bindings/Node' +import { radToDeg } from 'three/src/math/MathUtils' +import toast from 'react-hot-toast' +import { getArtifactFromRange, codeRefFromRange } from 'lang/std/artifactGraph' +import { updateModelingState } from 'lang/modelingWorkflows' +import { EXECUTION_TYPE_MOCK } from 'lib/constants' type DraftSegment = 'line' | 'tangentialArcTo' @@ -760,14 +758,14 @@ export class SceneEntities { segment.type === 'TangentialArcTo' ? segmentUtils.tangentialArcTo.init : segment.type === 'Circle' - ? segmentUtils.circle.init - : segment.type === 'Arc' - ? segmentUtils.arc.init - : segment.type === 'CircleThreePoint' - ? segmentUtils.circleThreePoint.init - : segment.type === 'ArcThreePoint' - ? segmentUtils.threePointArc.init - : segmentUtils.straight.init + ? segmentUtils.circle.init + : segment.type === 'Arc' + ? segmentUtils.arc.init + : segment.type === 'CircleThreePoint' + ? segmentUtils.circleThreePoint.init + : segment.type === 'ArcThreePoint' + ? segmentUtils.threePointArc.init + : segmentUtils.straight.init const input: SegmentInputs = segment.type === 'Circle' ? { @@ -779,27 +777,27 @@ export class SceneEntities { radius: segment.radius, } : segment.type === 'CircleThreePoint' || - segment.type === 'ArcThreePoint' - ? { - type: 'circle-three-point-segment', - p1: segment.p1, - p2: segment.p2, - p3: segment.p3, - } - : segment.type === 'Arc' - ? { - type: 'arc-segment', - from: segment.from, - center: segment.center, - to: segment.to, - ccw: segment.ccw, - radius: segment.radius, - } - : { - type: 'straight-segment', - from: segment.from, - to: segment.to, - } + segment.type === 'ArcThreePoint' + ? { + type: 'circle-three-point-segment', + p1: segment.p1, + p2: segment.p2, + p3: segment.p3, + } + : segment.type === 'Arc' + ? { + type: 'arc-segment', + from: segment.from, + center: segment.center, + to: segment.to, + ccw: segment.ccw, + radius: segment.radius, + } + : { + type: 'straight-segment', + from: segment.from, + to: segment.to, + } const startRange = _node1.node.start const endRange = _node1.node.end const sourceRange: SourceRange = [startRange, endRange, 0] diff --git a/src/clientSideScene/sceneInfra.ts b/src/clientSideScene/sceneInfra.ts index 2e88ea8d7..40d9dbbbc 100644 --- a/src/clientSideScene/sceneInfra.ts +++ b/src/clientSideScene/sceneInfra.ts @@ -1,36 +1,35 @@ -import * as TWEEN from '@tweenjs/tween.js' -import { useModelingContext } from 'hooks/useModelingContext' -import { EngineCommandManager } from 'lang/std/engineConnection' -import { Coords2d, compareVec2Epsilon2 } from 'lang/std/sketch' -import { Axis, NonCodeSelection } from 'lib/selections' -import { type BaseUnit } from 'lib/settings/settingsTypes' -import { Themes } from 'lib/theme' -import { getAngle, throttle } from 'lib/utils' -import { MouseState, SegmentOverlayPayload } from 'machines/modelingMachine' import { AmbientLight, Color, GridHelper, - Group, - Intersection, LineBasicMaterial, - Mesh, - MeshBasicMaterial, - Object3D, - Object3DEventMap, OrthographicCamera, PerspectiveCamera, - Raycaster, Scene, - Texture, - TextureLoader, - Vector2, Vector3, WebGLRenderer, + Raycaster, + Vector2, + Group, + MeshBasicMaterial, + Mesh, + Intersection, + Object3D, + Object3DEventMap, + TextureLoader, + Texture, } from 'three' -import { CSS2DRenderer } from 'three/examples/jsm/renderers/CSS2DRenderer' - +import { Coords2d, compareVec2Epsilon2 } from 'lang/std/sketch' +import { useModelingContext } from 'hooks/useModelingContext' +import * as TWEEN from '@tweenjs/tween.js' +import { Axis, NonCodeSelection } from 'lib/selections' +import { type BaseUnit } from 'lib/settings/settingsTypes' import { CameraControls } from './CameraControls' +import { EngineCommandManager } from 'lang/std/engineConnection' +import { MouseState, SegmentOverlayPayload } from 'machines/modelingMachine' +import { getAngle, throttle } from 'lib/utils' +import { Themes } from 'lib/theme' +import { CSS2DRenderer } from 'three/examples/jsm/renderers/CSS2DRenderer' import { orthoScale, perspScale } from './helpers' type SendType = ReturnType['send'] diff --git a/src/clientSideScene/segments.ts b/src/clientSideScene/segments.ts index 66d95db7f..bcb70ba0d 100644 --- a/src/clientSideScene/segments.ts +++ b/src/clientSideScene/segments.ts @@ -1,18 +1,4 @@ import { Coords2d } from 'lang/std/sketch' -import { SegmentInputs } from 'lang/std/stdTypes' -import { PathToNode, Sketch, getTangentialArcToInfo } from 'lang/wasm' -import { Selections } from 'lib/selections' -import { sceneInfra } from 'lib/singletons' -import { Themes, getThemeColorForThreeJs } from 'lib/theme' -import { err } from 'lib/trap' -import { isClockwise, normaliseAngle, roundOff } from 'lib/utils' -import { getTangentPointFromPreviousArc } from 'lib/utils2d' -import { commandBarActor } from 'machines/commandBarMachine' -import { - SegmentOverlay, - SegmentOverlayPayload, - SegmentOverlays, -} from 'machines/modelingMachine' import { BoxGeometry, BufferGeometry, @@ -22,10 +8,10 @@ import { EllipseCurve, ExtrudeGeometry, Group, - Line, - LineBasicMaterial, LineCurve3, + LineBasicMaterial, LineDashedMaterial, + Line, Mesh, MeshBasicMaterial, NormalBufferAttributes, @@ -37,19 +23,10 @@ import { Vector2, Vector3, } from 'three' -import { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer' import { mergeGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils.js' - -import { calculate_circle_from_3_points } from '@rust/kcl-wasm-lib/pkg/kcl_wasm_lib' - +import { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer' +import { PathToNode, Sketch, getTangentialArcToInfo } from 'lang/wasm' import { - ARC_ANGLE_END, - ARC_ANGLE_REFERENCE_LINE, - ARC_CENTER_TO_FROM, - ARC_CENTER_TO_TO, - ARC_SEGMENT, - ARC_SEGMENT_BODY, - ARC_SEGMENT_DASH, CIRCLE_CENTER_HANDLE, CIRCLE_SEGMENT, CIRCLE_SEGMENT_BODY, @@ -72,21 +49,42 @@ import { TANGENTIAL_ARC_TO_SEGMENT, TANGENTIAL_ARC_TO_SEGMENT_BODY, TANGENTIAL_ARC_TO__SEGMENT_DASH, - THREE_POINT_ARC_HANDLE2, - THREE_POINT_ARC_HANDLE3, + ARC_SEGMENT, + ARC_SEGMENT_BODY, + ARC_SEGMENT_DASH, + ARC_ANGLE_END, + getParentGroup, + ARC_CENTER_TO_FROM, + ARC_CENTER_TO_TO, + ARC_ANGLE_REFERENCE_LINE, THREE_POINT_ARC_SEGMENT, THREE_POINT_ARC_SEGMENT_BODY, THREE_POINT_ARC_SEGMENT_DASH, - getParentGroup, + THREE_POINT_ARC_HANDLE2, + THREE_POINT_ARC_HANDLE3, } from './sceneEntities' +import { getTangentPointFromPreviousArc } from 'lib/utils2d' import { ARROWHEAD, DRAFT_POINT, + SceneInfra, SEGMENT_LENGTH_LABEL, SEGMENT_LENGTH_LABEL_OFFSET_PX, SEGMENT_LENGTH_LABEL_TEXT, - SceneInfra, } from './sceneInfra' +import { Themes, getThemeColorForThreeJs } from 'lib/theme' +import { isClockwise, normaliseAngle, roundOff } from 'lib/utils' +import { + SegmentOverlay, + SegmentOverlayPayload, + SegmentOverlays, +} from 'machines/modelingMachine' +import { SegmentInputs } from 'lang/std/stdTypes' +import { err } from 'lib/trap' +import { sceneInfra } from 'lib/singletons' +import { Selections } from 'lib/selections' +import { calculate_circle_from_3_points } from '@rust/kcl-wasm-lib/pkg/kcl_wasm_lib' +import { commandBarActor } from 'machines/commandBarMachine' const ANGLE_INDICATOR_RADIUS = 30 // in px interface CreateSegmentArgs { diff --git a/src/components/ActionButton.test.tsx b/src/components/ActionButton.test.tsx index f00747fa2..fd649fa67 100644 --- a/src/components/ActionButton.test.tsx +++ b/src/components/ActionButton.test.tsx @@ -1,6 +1,5 @@ import { render, screen } from '@testing-library/react' import { describe, expect, it } from 'vitest' - import { ActionButton } from './ActionButton' describe('ActionButton tests', () => { diff --git a/src/components/ActionButton.tsx b/src/components/ActionButton.tsx index 858917378..2905f8ae0 100644 --- a/src/components/ActionButton.tsx +++ b/src/components/ActionButton.tsx @@ -1,11 +1,10 @@ +import { ActionIcon, ActionIconProps } from './ActionIcon' import { openExternalBrowserIfDesktop } from 'lib/openWindow' -import { PATHS } from 'lib/paths' import React, { ForwardedRef, forwardRef } from 'react' +import { PATHS } from 'lib/paths' import { Link } from 'react-router-dom' import type { LinkProps } from 'react-router-dom' -import { ActionIcon, ActionIconProps } from './ActionIcon' - interface BaseActionButtonProps { iconStart?: ActionIconProps iconEnd?: ActionIconProps @@ -48,8 +47,8 @@ export const ActionButton = forwardRef((props: ActionButtonProps, ref) => { ? 'px-0' // No padding if both icons are present : 'pr-2' // Padding on the right if only the start icon is present : props.iconEnd - ? 'pl-2' // Padding on the left if only the end icon is present - : 'px-2' // Padding on both sides if no icons are present + ? 'pl-2' // Padding on the left if only the end icon is present + : 'px-2' // Padding on both sides if no icons are present } ${props.className ? props.className : ''}` switch (props.Element) { diff --git a/src/components/ActionButtonDropdown.tsx b/src/components/ActionButtonDropdown.tsx index cfc3de352..32c55db98 100644 --- a/src/components/ActionButtonDropdown.tsx +++ b/src/components/ActionButtonDropdown.tsx @@ -1,5 +1,4 @@ import { Popover } from '@headlessui/react' - import { ActionButtonProps } from './ActionButton' import { CustomIcon } from './CustomIcon' import Tooltip from './Tooltip' diff --git a/src/components/ActionIcon.tsx b/src/components/ActionIcon.tsx index 001ce53da..1609360bc 100644 --- a/src/components/ActionIcon.tsx +++ b/src/components/ActionIcon.tsx @@ -3,7 +3,6 @@ import { faCircleExclamation, } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' - import { CustomIcon, CustomIconName } from './CustomIcon' const iconSizes = { diff --git a/src/components/AppHeader.tsx b/src/components/AppHeader.tsx index 9ad90b9cf..58dd37b20 100644 --- a/src/components/AppHeader.tsx +++ b/src/components/AppHeader.tsx @@ -1,13 +1,12 @@ -import { RefreshButton } from 'components/RefreshButton' -import UserSidebarMenu from 'components/UserSidebarMenu' -import { isDesktop } from 'lib/isDesktop' -import { type IndexLoaderData } from 'lib/types' -import { useUser } from 'machines/appMachine' - import { Toolbar } from '../Toolbar' -import styles from './AppHeader.module.css' -import { CommandBarOpenButton } from './CommandBarOpenButton' +import UserSidebarMenu from 'components/UserSidebarMenu' +import { type IndexLoaderData } from 'lib/types' import ProjectSidebarMenu from './ProjectSidebarMenu' +import styles from './AppHeader.module.css' +import { RefreshButton } from 'components/RefreshButton' +import { CommandBarOpenButton } from './CommandBarOpenButton' +import { isDesktop } from 'lib/isDesktop' +import { useUser } from 'machines/appMachine' interface AppHeaderProps extends React.PropsWithChildren { showToolbar?: boolean diff --git a/src/components/AstExplorer.tsx b/src/components/AstExplorer.tsx index ae74fb6a9..5d85ab7b4 100644 --- a/src/components/AstExplorer.tsx +++ b/src/components/AstExplorer.tsx @@ -1,13 +1,13 @@ import { useModelingContext } from 'hooks/useModelingContext' +import { editorManager, kclManager } from 'lib/singletons' import { getNodeFromPath } from 'lang/queryAst' import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' +import { useEffect, useRef, useState } from 'react' +import { trap } from 'lib/trap' +import { codeToIdSelections } from 'lib/selections' import { codeRefFromRange } from 'lang/std/artifactGraph' import { defaultSourceRange, topLevelRange } from 'lang/wasm' -import { codeToIdSelections } from 'lib/selections' -import { editorManager, kclManager } from 'lib/singletons' -import { trap } from 'lib/trap' import { isArray } from 'lib/utils' -import { useEffect, useRef, useState } from 'react' export function AstExplorer() { const { context } = useModelingContext() diff --git a/src/components/AvailableVarsHelpers.tsx b/src/components/AvailableVarsHelpers.tsx index 12f7335ae..40f624d35 100644 --- a/src/components/AvailableVarsHelpers.tsx +++ b/src/components/AvailableVarsHelpers.tsx @@ -1,10 +1,10 @@ +import { BinaryPart } from '../lang/wasm' import { - createLiteral, createLocalName, + createLiteral, createUnaryExpression, } from '../lang/modifyAst' import { PrevVariable } from '../lang/queryAst' -import { BinaryPart } from '../lang/wasm' export const AvailableVars = ({ onVarClick, diff --git a/src/components/CamToggle.tsx b/src/components/CamToggle.tsx index 46516f0ad..4e1b3d48a 100644 --- a/src/components/CamToggle.tsx +++ b/src/components/CamToggle.tsx @@ -1,8 +1,8 @@ +import { useState, useEffect } from 'react' import { EngineCommandManagerEvents } from 'lang/std/engineConnection' import { engineCommandManager, sceneInfra } from 'lib/singletons' +import { throttle, isReducedMotion } from 'lib/utils' import { reportRejection } from 'lib/trap' -import { isReducedMotion, throttle } from 'lib/utils' -import { useEffect, useState } from 'react' const updateDollyZoom = throttle( (newFov: number) => sceneInfra.camControls.dollyZoom(newFov), diff --git a/src/components/CommandBar/CommandBar.tsx b/src/components/CommandBar/CommandBar.tsx index 0e4c8f495..07ca73b44 100644 --- a/src/components/CommandBar/CommandBar.tsx +++ b/src/components/CommandBar/CommandBar.tsx @@ -1,14 +1,13 @@ import { Dialog, Popover, Transition } from '@headlessui/react' +import { Fragment, useEffect } from 'react' +import CommandBarArgument from './CommandBarArgument' +import CommandComboBox from '../CommandComboBox' +import CommandBarReview from './CommandBarReview' +import { useLocation } from 'react-router-dom' +import useHotkeyWrapper from 'lib/hotkeyWrapper' import { CustomIcon } from 'components/CustomIcon' import Tooltip from 'components/Tooltip' -import useHotkeyWrapper from 'lib/hotkeyWrapper' import { commandBarActor, useCommandBarState } from 'machines/commandBarMachine' -import { Fragment, useEffect } from 'react' -import { useLocation } from 'react-router-dom' - -import CommandComboBox from '../CommandComboBox' -import CommandBarArgument from './CommandBarArgument' -import CommandBarReview from './CommandBarReview' export const COMMAND_PALETTE_HOTKEY = 'mod+k' diff --git a/src/components/CommandBar/CommandBarArgument.tsx b/src/components/CommandBar/CommandBarArgument.tsx index c84d844d0..93d4fa345 100644 --- a/src/components/CommandBar/CommandBarArgument.tsx +++ b/src/components/CommandBar/CommandBarArgument.tsx @@ -1,13 +1,12 @@ -import { CommandArgument } from 'lib/commandTypes' -import { commandBarActor, useCommandBarState } from 'machines/commandBarMachine' - import CommandArgOptionInput from './CommandArgOptionInput' import CommandBarBasicInput from './CommandBarBasicInput' -import CommandBarHeader from './CommandBarHeader' -import CommandBarKclInput from './CommandBarKclInput' import CommandBarSelectionInput from './CommandBarSelectionInput' import CommandBarSelectionMixedInput from './CommandBarSelectionMixedInput' +import { CommandArgument } from 'lib/commandTypes' +import CommandBarHeader from './CommandBarHeader' +import CommandBarKclInput from './CommandBarKclInput' import CommandBarTextareaInput from './CommandBarTextareaInput' +import { commandBarActor, useCommandBarState } from 'machines/commandBarMachine' function CommandBarArgument({ stepBack }: { stepBack: () => void }) { const commandBarState = useCommandBarState() diff --git a/src/components/CommandBar/CommandBarHeader.tsx b/src/components/CommandBar/CommandBarHeader.tsx index 35b5c0dbc..64bda41a4 100644 --- a/src/components/CommandBar/CommandBarHeader.tsx +++ b/src/components/CommandBar/CommandBarHeader.tsx @@ -1,13 +1,12 @@ -import Tooltip from 'components/Tooltip' -import { KclCommandValue, KclExpressionWithVariable } from 'lib/commandTypes' +import { CustomIcon } from '../CustomIcon' +import React, { useMemo, useState } from 'react' +import { ActionButton } from '../ActionButton' import { Selections, getSelectionTypeDisplayText } from 'lib/selections' +import { useHotkeys } from 'react-hotkeys-hook' +import { KclCommandValue, KclExpressionWithVariable } from 'lib/commandTypes' +import Tooltip from 'components/Tooltip' import { roundOff } from 'lib/utils' import { commandBarActor, useCommandBarState } from 'machines/commandBarMachine' -import React, { useMemo, useState } from 'react' -import { useHotkeys } from 'react-hotkeys-hook' - -import { ActionButton } from '../ActionButton' -import { CustomIcon } from '../CustomIcon' function CommandBarHeader({ children }: React.PropsWithChildren) { const commandBarState = useCommandBarState() diff --git a/src/components/CommandBar/CommandBarKclInput.tsx b/src/components/CommandBar/CommandBarKclInput.tsx index 998b9d581..1014e38f1 100644 --- a/src/components/CommandBar/CommandBarKclInput.tsx +++ b/src/components/CommandBar/CommandBarKclInput.tsx @@ -1,35 +1,33 @@ import { - Completion, closeBrackets, closeBracketsKeymap, + Completion, completionKeymap, completionStatus, } from '@codemirror/autocomplete' -import { EditorView, ViewUpdate, keymap } from '@codemirror/view' -import { useSelector } from '@xstate/react' +import { EditorView, keymap, ViewUpdate } from '@codemirror/view' import { CustomIcon } from 'components/CustomIcon' -import { useCodeMirror } from 'components/ModelingSidebar/ModelingPanes/CodeEditor' -import { Spinner } from 'components/Spinner' -import { createLocalName, createVariableDeclaration } from 'lang/modifyAst' -import { getNodeFromPath } from 'lang/queryAst' -import { SourceRange, VariableDeclarator, isPathToNode } from 'lang/wasm' import { CommandArgument, KclCommandValue } from 'lib/commandTypes' -import { kclManager } from 'lib/singletons' import { getSystemTheme } from 'lib/theme' -import { err } from 'lib/trap' import { useCalculateKclExpression } from 'lib/useCalculateKclExpression' import { roundOff } from 'lib/utils' import { varMentions } from 'lib/varCompletionExtension' -import { useSettings } from 'machines/appMachine' -import { commandBarActor, useCommandBarState } from 'machines/commandBarMachine' import { useEffect, useMemo, useRef, useState } from 'react' -import toast from 'react-hot-toast' import { useHotkeys } from 'react-hotkeys-hook' -import { AnyStateMachine, SnapshotFrom } from 'xstate' - -import { Node } from '@rust/kcl-lib/bindings/Node' - import styles from './CommandBarKclInput.module.css' +import { createLocalName, createVariableDeclaration } from 'lang/modifyAst' +import { useCodeMirror } from 'components/ModelingSidebar/ModelingPanes/CodeEditor' +import { useSelector } from '@xstate/react' +import { commandBarActor, useCommandBarState } from 'machines/commandBarMachine' +import { useSettings } from 'machines/appMachine' +import toast from 'react-hot-toast' +import { AnyStateMachine, SnapshotFrom } from 'xstate' +import { kclManager } from 'lib/singletons' +import { getNodeFromPath } from 'lang/queryAst' +import { isPathToNode, SourceRange, VariableDeclarator } from 'lang/wasm' +import { Node } from '@rust/kcl-lib/bindings/Node' +import { err } from 'lib/trap' +import { Spinner } from 'components/Spinner' // TODO: remove the need for this selector once we decouple all actors from React const machineContextSelector = (snapshot?: SnapshotFrom) => diff --git a/src/components/CommandBar/CommandBarReview.tsx b/src/components/CommandBar/CommandBarReview.tsx index 7897f55bc..a944560ba 100644 --- a/src/components/CommandBar/CommandBarReview.tsx +++ b/src/components/CommandBar/CommandBarReview.tsx @@ -1,7 +1,6 @@ import { commandBarActor, useCommandBarState } from 'machines/commandBarMachine' -import { useHotkeys } from 'react-hotkeys-hook' - import CommandBarHeader from './CommandBarHeader' +import { useHotkeys } from 'react-hotkeys-hook' function CommandBarReview({ stepBack }: { stepBack: () => void }) { const commandBarState = useCommandBarState() diff --git a/src/components/CommandBar/CommandBarSelectionMixedInput.tsx b/src/components/CommandBar/CommandBarSelectionMixedInput.tsx index 5b252c60a..fbee6d5ae 100644 --- a/src/components/CommandBar/CommandBarSelectionMixedInput.tsx +++ b/src/components/CommandBar/CommandBarSelectionMixedInput.tsx @@ -1,13 +1,13 @@ -import { useSelector } from '@xstate/react' +import { useEffect, useMemo, useRef, useState } from 'react' import { CommandArgument } from 'lib/commandTypes' import { Selections, canSubmitSelectionArg, getSelectionCountByType, } from 'lib/selections' -import { kclManager } from 'lib/singletons' +import { useSelector } from '@xstate/react' import { commandBarActor, useCommandBarState } from 'machines/commandBarMachine' -import { useEffect, useMemo, useRef, useState } from 'react' +import { kclManager } from 'lib/singletons' const selectionSelector = (snapshot: any) => snapshot?.context.selectionRanges diff --git a/src/components/CommandBarOpenButton.tsx b/src/components/CommandBarOpenButton.tsx index 80cc23196..a0b3d466e 100644 --- a/src/components/CommandBarOpenButton.tsx +++ b/src/components/CommandBarOpenButton.tsx @@ -1,8 +1,7 @@ import usePlatform from 'hooks/usePlatform' import { hotkeyDisplay } from 'lib/hotkeyWrapper' -import { commandBarActor } from 'machines/commandBarMachine' - import { COMMAND_PALETTE_HOTKEY } from './CommandBar/CommandBar' +import { commandBarActor } from 'machines/commandBarMachine' export function CommandBarOpenButton() { const platform = usePlatform() diff --git a/src/components/CommandComboBox.tsx b/src/components/CommandComboBox.tsx index 35e833fee..c589d8a2b 100644 --- a/src/components/CommandComboBox.tsx +++ b/src/components/CommandComboBox.tsx @@ -1,12 +1,11 @@ import { Combobox } from '@headlessui/react' import Fuse from 'fuse.js' import { Command } from 'lib/commandTypes' -import { sortCommands } from 'lib/commandUtils' -import { getActorNextEvents } from 'lib/utils' -import { commandBarActor } from 'machines/commandBarMachine' import { useEffect, useState } from 'react' - import { CustomIcon } from './CustomIcon' +import { getActorNextEvents } from 'lib/utils' +import { sortCommands } from 'lib/commandUtils' +import { commandBarActor } from 'machines/commandBarMachine' function CommandComboBox({ options, diff --git a/src/components/ContextMenu.tsx b/src/components/ContextMenu.tsx index 5af0cb758..b263e29c2 100644 --- a/src/components/ContextMenu.tsx +++ b/src/components/ContextMenu.tsx @@ -1,4 +1,5 @@ -import { Dialog } from '@headlessui/react' +import toast from 'react-hot-toast' +import { ActionIcon, ActionIconProps } from './ActionIcon' import { RefObject, useCallback, @@ -7,10 +8,8 @@ import { useRef, useState, } from 'react' -import toast from 'react-hot-toast' import { useHotkeys } from 'react-hotkeys-hook' - -import { ActionIcon, ActionIconProps } from './ActionIcon' +import { Dialog } from '@headlessui/react' export interface ContextMenuProps extends Omit, 'children'> { diff --git a/src/components/DebugArtifactGraph.tsx b/src/components/DebugArtifactGraph.tsx index 90f46b67f..5436ab237 100644 --- a/src/components/DebugArtifactGraph.tsx +++ b/src/components/DebugArtifactGraph.tsx @@ -1,8 +1,7 @@ -import { PlaneArtifactRich, expandPlane } from 'lang/std/artifactGraph' -import { ArtifactGraph } from 'lang/wasm' -import { kclManager } from 'lib/singletons' import { useMemo } from 'react' - +import { kclManager } from 'lib/singletons' +import { expandPlane, PlaneArtifactRich } from 'lang/std/artifactGraph' +import { ArtifactGraph } from 'lang/wasm' import { DebugDisplayArray, GenericObj } from './DebugDisplayObj' export function DebugArtifactGraph() { diff --git a/src/components/DownloadAppBanner.tsx b/src/components/DownloadAppBanner.tsx index 1935b0bb6..cbc278d75 100644 --- a/src/components/DownloadAppBanner.tsx +++ b/src/components/DownloadAppBanner.tsx @@ -1,8 +1,7 @@ import { Dialog } from '@headlessui/react' -import { useSettings } from 'machines/appMachine' -import { useState } from 'react' - import { ActionButton } from './ActionButton' +import { useState } from 'react' +import { useSettings } from 'machines/appMachine' const DownloadAppBanner = () => { const settings = useSettings() diff --git a/src/components/EngineCommands.tsx b/src/components/EngineCommands.tsx index 1804b711e..ace639518 100644 --- a/src/components/EngineCommands.tsx +++ b/src/components/EngineCommands.tsx @@ -1,7 +1,7 @@ import { CommandLog } from 'lang/std/engineConnection' import { engineCommandManager } from 'lib/singletons' import { reportRejection } from 'lib/trap' -import { useEffect, useState } from 'react' +import { useState, useEffect } from 'react' export function useEngineCommands(): [CommandLog[], () => void] { const [engineCommands, setEngineCommands] = useState( diff --git a/src/components/ErrorPage.tsx b/src/components/ErrorPage.tsx index c7b0fed36..0705074be 100644 --- a/src/components/ErrorPage.tsx +++ b/src/components/ErrorPage.tsx @@ -1,13 +1,12 @@ +import { isDesktop } from 'lib/isDesktop' +import { useRouteError, isRouteErrorResponse } from 'react-router-dom' +import { ActionButton } from './ActionButton' import { faBug, faHome, faRefresh, faTrash, } from '@fortawesome/free-solid-svg-icons' -import { isDesktop } from 'lib/isDesktop' -import { isRouteErrorResponse, useRouteError } from 'react-router-dom' - -import { ActionButton } from './ActionButton' /** Type narrowing function of unknown error to a string */ function errorMessage(error: unknown): string { diff --git a/src/components/FileMachineProvider.tsx b/src/components/FileMachineProvider.tsx index 9358f2b94..dcfd2fb6a 100644 --- a/src/components/FileMachineProvider.tsx +++ b/src/components/FileMachineProvider.tsx @@ -1,33 +1,9 @@ import { useMachine } from '@xstate/react' -import { newKclFile } from 'lang/project' -import { createNamedViewsCommand } from 'lib/commandBarConfigs/namedViewsConfig' -import { createRouteCommands } from 'lib/commandBarConfigs/routeCommandConfig' -import { - DEFAULT_DEFAULT_LENGTH_UNIT, - DEFAULT_FILE_NAME, - DEFAULT_PROJECT_KCL_FILE, - FILE_EXT, -} from 'lib/constants' -import { getProjectInfo } from 'lib/desktop' -import { getNextDirName, getNextFileName } from 'lib/desktopFS' -import { - KclSamplesManifestItem, - getKclSamplesManifest, -} from 'lib/getKclSamplesManifest' -import { isDesktop } from 'lib/isDesktop' -import { kclCommands } from 'lib/kclCommands' -import { BROWSER_PATH, PATHS } from 'lib/paths' -import { markOnce } from 'lib/performance' -import { codeManager, kclManager } from 'lib/singletons' -import { err, reportRejection } from 'lib/trap' +import { useLocation, useNavigate, useRouteLoaderData } from 'react-router-dom' import { type IndexLoaderData } from 'lib/types' -import { useSettings } from 'machines/appMachine' -import { useToken } from 'machines/appMachine' -import { commandBarActor } from 'machines/commandBarMachine' -import { fileMachine } from 'machines/fileMachine' +import { BROWSER_PATH, PATHS } from 'lib/paths' import React, { createContext, useEffect, useMemo } from 'react' import { toast } from 'react-hot-toast' -import { useLocation, useNavigate, useRouteLoaderData } from 'react-router-dom' import { Actor, AnyStateMachine, @@ -36,6 +12,30 @@ import { StateFrom, fromPromise, } from 'xstate' +import { fileMachine } from 'machines/fileMachine' +import { isDesktop } from 'lib/isDesktop' +import { + DEFAULT_DEFAULT_LENGTH_UNIT, + DEFAULT_FILE_NAME, + DEFAULT_PROJECT_KCL_FILE, + FILE_EXT, +} from 'lib/constants' +import { getProjectInfo } from 'lib/desktop' +import { getNextDirName, getNextFileName } from 'lib/desktopFS' +import { kclCommands } from 'lib/kclCommands' +import { codeManager, kclManager } from 'lib/singletons' +import { + getKclSamplesManifest, + KclSamplesManifestItem, +} from 'lib/getKclSamplesManifest' +import { markOnce } from 'lib/performance' +import { commandBarActor } from 'machines/commandBarMachine' +import { useSettings } from 'machines/appMachine' +import { createRouteCommands } from 'lib/commandBarConfigs/routeCommandConfig' +import { useToken } from 'machines/appMachine' +import { createNamedViewsCommand } from 'lib/commandBarConfigs/namedViewsConfig' +import { err, reportRejection } from 'lib/trap' +import { newKclFile } from 'lang/project' type MachineContext = { state: StateFrom diff --git a/src/components/FileTree.tsx b/src/components/FileTree.tsx index 2c2eb0880..27d5f5f21 100644 --- a/src/components/FileTree.tsx +++ b/src/components/FileTree.tsx @@ -1,31 +1,30 @@ -import { faChevronRight, faPencil } from '@fortawesome/free-solid-svg-icons' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { Disclosure } from '@headlessui/react' -import { useFileContext } from 'hooks/useFileContext' -import { useFileSystemWatcher } from 'hooks/useFileSystemWatcher' -import { useModelingContext } from 'hooks/useModelingContext' -import usePlatform from 'hooks/usePlatform' -import { useKclContext } from 'lang/KclProvider' -import { KCLError, kclErrorsByFilename } from 'lang/errors' -import { normalizeLineEndings } from 'lib/codeEditor' -import { FILE_EXT } from 'lib/constants' -import { sortFilesAndDirectories } from 'lib/desktopFS' -import useHotkeyWrapper from 'lib/hotkeyWrapper' -import { PATHS } from 'lib/paths' -import { FileEntry } from 'lib/project' -import { codeManager, kclManager } from 'lib/singletons' -import { reportRejection } from 'lib/trap' import type { IndexLoaderData } from 'lib/types' +import { PATHS } from 'lib/paths' +import { ActionButton } from './ActionButton' +import Tooltip from './Tooltip' import { Dispatch, useCallback, useRef, useState } from 'react' import { useNavigate, useRouteLoaderData } from 'react-router-dom' - -import { ActionButton } from './ActionButton' -import { ContextMenu, ContextMenuItem } from './ContextMenu' -import { CustomIcon } from './CustomIcon' +import { Disclosure } from '@headlessui/react' +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import { faChevronRight, faPencil } from '@fortawesome/free-solid-svg-icons' +import { useFileContext } from 'hooks/useFileContext' import styles from './FileTree.module.css' +import { sortFilesAndDirectories } from 'lib/desktopFS' +import { FILE_EXT } from 'lib/constants' +import { CustomIcon } from './CustomIcon' +import { codeManager, kclManager } from 'lib/singletons' import { useLspContext } from './LspProvider' +import useHotkeyWrapper from 'lib/hotkeyWrapper' +import { useModelingContext } from 'hooks/useModelingContext' import { DeleteConfirmationDialog } from './ProjectCard/DeleteProjectDialog' -import Tooltip from './Tooltip' +import { ContextMenu, ContextMenuItem } from './ContextMenu' +import usePlatform from 'hooks/usePlatform' +import { FileEntry } from 'lib/project' +import { useFileSystemWatcher } from 'hooks/useFileSystemWatcher' +import { normalizeLineEndings } from 'lib/codeEditor' +import { reportRejection } from 'lib/trap' +import { useKclContext } from 'lang/KclProvider' +import { kclErrorsByFilename, KCLError } from 'lang/errors' function getIndentationCSS(level: number) { return `calc(1rem * ${level + 1})` diff --git a/src/components/Gizmo.tsx b/src/components/Gizmo.tsx index 6b907dbd7..06c681bb6 100644 --- a/src/components/Gizmo.tsx +++ b/src/components/Gizmo.tsx @@ -1,35 +1,34 @@ -import { Popover } from '@headlessui/react' import { SceneInfra } from 'clientSideScene/sceneInfra' -import { useModelingContext } from 'hooks/useModelingContext' -import { AxisNames } from 'lib/constants' import { sceneInfra } from 'lib/singletons' -import { reportRejection } from 'lib/trap' -import { useSettings } from 'machines/appMachine' import { MutableRefObject, useEffect, useRef } from 'react' import { - BoxGeometry, - Camera, - Clock, - Color, - ColorRepresentation, - Intersection, - Mesh, - MeshBasicMaterial, - Object3D, - OrthographicCamera, - Quaternion, - Raycaster, - Scene, - SphereGeometry, - Vector2, WebGLRenderer, + Scene, + OrthographicCamera, + BoxGeometry, + SphereGeometry, + MeshBasicMaterial, + Color, + Mesh, + Clock, + Quaternion, + ColorRepresentation, + Vector2, + Raycaster, + Camera, + Intersection, + Object3D, } from 'three' - +import { Popover } from '@headlessui/react' import { CustomIcon } from './CustomIcon' +import { reportRejection } from 'lib/trap' import { - ViewControlContextMenu, useViewControlMenuItems, + ViewControlContextMenu, } from './ViewControlMenu' +import { AxisNames } from 'lib/constants' +import { useModelingContext } from 'hooks/useModelingContext' +import { useSettings } from 'machines/appMachine' const CANVAS_SIZE = 80 const FRUSTUM_SIZE = 0.5 diff --git a/src/components/HelpMenu.tsx b/src/components/HelpMenu.tsx index d3503b01c..56a186f22 100644 --- a/src/components/HelpMenu.tsx +++ b/src/components/HelpMenu.tsx @@ -1,17 +1,16 @@ import { Popover } from '@headlessui/react' -import { useAbsoluteFilePath } from 'hooks/useAbsoluteFilePath' -import { useMenuListener } from 'hooks/useMenu' -import { createAndOpenNewTutorialProject } from 'lib/desktopFS' -import { openExternalBrowserIfDesktop } from 'lib/openWindow' +import Tooltip from './Tooltip' +import { CustomIcon } from './CustomIcon' +import { useLocation, useNavigate } from 'react-router-dom' import { PATHS } from 'lib/paths' +import { createAndOpenNewTutorialProject } from 'lib/desktopFS' +import { useAbsoluteFilePath } from 'hooks/useAbsoluteFilePath' +import { useLspContext } from './LspProvider' +import { openExternalBrowserIfDesktop } from 'lib/openWindow' import { reportRejection } from 'lib/trap' import { settingsActor } from 'machines/appMachine' -import { useLocation, useNavigate } from 'react-router-dom' - import type { WebContentSendPayload } from '../menu/channels' -import { CustomIcon } from './CustomIcon' -import { useLspContext } from './LspProvider' -import Tooltip from './Tooltip' +import { useMenuListener } from 'hooks/useMenu' const HelpMenuDivider = () => (
diff --git a/src/components/Loading.tsx b/src/components/Loading.tsx index c72462d21..7d2972340 100644 --- a/src/components/Loading.tsx +++ b/src/components/Loading.tsx @@ -1,14 +1,16 @@ import { useEffect, useState } from 'react' import { - CONNECTION_ERROR_TEXT, - ConnectionError, + EngineConnectionStateType, DisconnectingType, EngineCommandManagerEvents, EngineConnectionEvents, - EngineConnectionStateType, + ConnectionError, + CONNECTION_ERROR_TEXT, } from '../lang/std/engineConnection' + import { engineCommandManager } from '../lib/singletons' + import { Spinner } from './Spinner' interface LoadingProps extends React.PropsWithChildren { diff --git a/src/components/LowerRightControls.tsx b/src/components/LowerRightControls.tsx index fed641186..ac942204c 100644 --- a/src/components/LowerRightControls.tsx +++ b/src/components/LowerRightControls.tsx @@ -1,19 +1,18 @@ +import { APP_VERSION, getReleaseUrl } from 'routes/Settings' import { CustomIcon } from 'components/CustomIcon' -import { NetworkHealthIndicator } from 'components/NetworkHealthIndicator' import Tooltip from 'components/Tooltip' +import { PATHS } from 'lib/paths' +import { NetworkHealthIndicator } from 'components/NetworkHealthIndicator' +import { HelpMenu } from './HelpMenu' +import { Link, useLocation } from 'react-router-dom' import { useAbsoluteFilePath } from 'hooks/useAbsoluteFilePath' import { coreDump } from 'lang/wasm' +import toast from 'react-hot-toast' import { CoreDumpManager } from 'lib/coredump' import openWindow, { openExternalBrowserIfDesktop } from 'lib/openWindow' -import { PATHS } from 'lib/paths' -import { reportRejection } from 'lib/trap' -import toast from 'react-hot-toast' -import { Link, useLocation } from 'react-router-dom' -import { APP_VERSION, getReleaseUrl } from 'routes/Settings' - -import { HelpMenu } from './HelpMenu' -import { ModelStateIndicator } from './ModelStateIndicator' import { NetworkMachineIndicator } from './NetworkMachineIndicator' +import { ModelStateIndicator } from './ModelStateIndicator' +import { reportRejection } from 'lib/trap' export function LowerRightControls({ children, diff --git a/src/components/LspProvider.tsx b/src/components/LspProvider.tsx index 51c26f1d0..71f158eef 100644 --- a/src/components/LspProvider.tsx +++ b/src/components/LspProvider.tsx @@ -1,32 +1,32 @@ -import { LanguageSupport } from '@codemirror/language' -import { Extension } from '@codemirror/state' +import type * as LSP from 'vscode-languageserver-protocol' +import React, { createContext, useMemo, useContext, useState } from 'react' import { + LanguageServerClient, FromServer, IntoServer, - LanguageServerClient, - LanguageServerPlugin, LspWorkerEventType, + LanguageServerPlugin, } from '@kittycad/codemirror-lsp-client' -import { copilotPlugin } from 'editor/plugins/lsp/copilot' -import { kcl } from 'editor/plugins/lsp/kcl/language' -import { - CopilotWorkerOptions, - KclWorkerOptions, - LspWorker, -} from 'editor/plugins/lsp/types' -import Worker from 'editor/plugins/lsp/worker.ts?worker' import { TEST, VITE_KC_API_BASE_URL } from 'env' -import { wasmUrl } from 'lang/wasm' -import { PROJECT_ENTRYPOINT } from 'lib/constants' -import { isDesktop } from 'lib/isDesktop' +import { kcl } from 'editor/plugins/lsp/kcl/language' +import { copilotPlugin } from 'editor/plugins/lsp/copilot' +import { Extension } from '@codemirror/state' +import { LanguageSupport } from '@codemirror/language' +import { useNavigate } from 'react-router-dom' import { PATHS } from 'lib/paths' import { FileEntry } from 'lib/project' -import { codeManager } from 'lib/singletons' +import Worker from 'editor/plugins/lsp/worker.ts?worker' +import { + KclWorkerOptions, + CopilotWorkerOptions, + LspWorker, +} from 'editor/plugins/lsp/types' +import { wasmUrl } from 'lang/wasm' +import { PROJECT_ENTRYPOINT } from 'lib/constants' import { err } from 'lib/trap' +import { isDesktop } from 'lib/isDesktop' +import { codeManager } from 'lib/singletons' import { useToken } from 'machines/appMachine' -import React, { createContext, useContext, useMemo, useState } from 'react' -import { useNavigate } from 'react-router-dom' -import type * as LSP from 'vscode-languageserver-protocol' function getWorkspaceFolders(): LSP.WorkspaceFolder[] { return [] diff --git a/src/components/MachineManagerProvider.tsx b/src/components/MachineManagerProvider.tsx index 6ad239d85..8e0605bae 100644 --- a/src/components/MachineManagerProvider.tsx +++ b/src/components/MachineManagerProvider.tsx @@ -1,10 +1,11 @@ +import { createContext, useEffect, useState } from 'react' + +import { engineCommandManager } from 'lib/singletons' import { isDesktop } from 'lib/isDesktop' import { components } from 'lib/machine-api' -import { engineCommandManager } from 'lib/singletons' import { reportRejection } from 'lib/trap' import { toSync } from 'lib/utils' import { commandBarActor } from 'machines/commandBarMachine' -import { createContext, useEffect, useState } from 'react' export type MachinesListing = Array< components['schemas']['MachineInfoResponse'] diff --git a/src/components/ModelStateIndicator.tsx b/src/components/ModelStateIndicator.tsx index e9e5a27dd..660d7e99c 100644 --- a/src/components/ModelStateIndicator.tsx +++ b/src/components/ModelStateIndicator.tsx @@ -1,7 +1,6 @@ -import { CustomIcon } from './CustomIcon' import { useEngineCommands } from './EngineCommands' import { Spinner } from './Spinner' - +import { CustomIcon } from './CustomIcon' export const ModelStateIndicator = () => { const [commands] = useEngineCommands() const lastCommandType = commands[commands.length - 1]?.type diff --git a/src/components/ModelingMachineProvider.tsx b/src/components/ModelingMachineProvider.tsx index 47be7da94..e26f67d23 100644 --- a/src/components/ModelingMachineProvider.tsx +++ b/src/components/ModelingMachineProvider.tsx @@ -1,18 +1,70 @@ import { useMachine, useSelector } from '@xstate/react' -import { letEngineAnimateAndSyncCamAfter } from 'clientSideScene/CameraControls' +import React, { + createContext, + useEffect, + useMemo, + useRef, + useContext, +} from 'react' +import { + Actor, + ContextFrom, + Prop, + SnapshotFrom, + StateFrom, + assign, + fromPromise, +} from 'xstate' +import { + getPersistedContext, + modelingMachine, + modelingMachineDefaultContext, +} from 'machines/modelingMachine' +import { useSetupEngineManager } from 'hooks/useSetupEngineManager' +import { + isCursorInSketchCommandRange, + updateSketchDetailsNodePaths, +} from 'lang/util' +import { + kclManager, + sceneInfra, + engineCommandManager, + codeManager, + editorManager, + sceneEntitiesManager, + rustContext, +} from 'lib/singletons' +import { + MachineManager, + MachineManagerContext, +} from 'components/MachineManagerProvider' +import { useHotkeys } from 'react-hotkeys-hook' +import { applyConstraintHorzVertDistance } from './Toolbar/SetHorzVertDistance' +import { + angleBetweenInfo, + applyConstraintAngleBetween, +} from './Toolbar/SetAngleBetween' +import { + applyConstraintAngleLength, + applyConstraintLength, +} from './Toolbar/setAngleLength' +import { + handleSelectionBatch, + Selections, + updateSelections, +} from 'lib/selections' +import { applyConstraintIntersect } from './Toolbar/Intersect' +import { applyConstraintAbsDistance } from './Toolbar/SetAbsDistance' +import useStateMachineCommands from 'hooks/useStateMachineCommands' +import { + ModelingCommandSchema, + modelingMachineCommandConfig, +} from 'lib/commandBarConfigs/modelingCommandConfig' import { SEGMENT_BODIES, getParentGroup, getSketchOrientationDetails, } from 'clientSideScene/sceneEntities' -import { - MachineManager, - MachineManagerContext, -} from 'components/MachineManagerProvider' -import { useFileContext } from 'hooks/useFileContext' -import { useSetupEngineManager } from 'hooks/useSetupEngineManager' -import useStateMachineCommands from 'hooks/useStateMachineCommands' -import { updateModelingState } from 'lang/modelingWorkflows' import { insertNamedConstant, replaceValueAtNodePath, @@ -21,27 +73,6 @@ import { splitPipedProfile, startSketchOnDefault, } from 'lang/modifyAst' -import { - artifactIsPlaneWithPaths, - doesSketchPipeNeedSplitting, - getNodeFromPath, - isCursorInFunctionDefinition, - traverse, -} from 'lang/queryAst' -import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' -import { - getFaceCodeRef, - getPathsFromArtifact, - getPlaneFromArtifact, -} from 'lang/std/artifactGraph' -import { - EngineConnectionEvents, - EngineConnectionStateType, -} from 'lang/std/engineConnection' -import { - isCursorInSketchCommandRange, - updateSketchDetailsNodePaths, -} from 'lang/util' import { KclValue, PathToNode, @@ -53,76 +84,43 @@ import { resultIsOk, } from 'lang/wasm' import { - ModelingCommandSchema, - modelingMachineCommandConfig, -} from 'lib/commandBarConfigs/modelingCommandConfig' + artifactIsPlaneWithPaths, + doesSketchPipeNeedSplitting, + getNodeFromPath, + isCursorInFunctionDefinition, + traverse, +} from 'lang/queryAst' +import toast from 'react-hot-toast' +import { useLoaderData, useNavigate, useSearchParams } from 'react-router-dom' +import { letEngineAnimateAndSyncCamAfter } from 'clientSideScene/CameraControls' +import { err, reportRejection, trap, reject } from 'lib/trap' +import { + EngineConnectionStateType, + EngineConnectionEvents, +} from 'lang/std/engineConnection' +import { submitAndAwaitTextToKcl } from 'lib/textToCad' +import { useFileContext } from 'hooks/useFileContext' +import { platform, uuidv4 } from 'lib/utils' +import { Node } from '@rust/kcl-lib/bindings/Node' +import { + getFaceCodeRef, + getPathsFromArtifact, + getPlaneFromArtifact, +} from 'lang/std/artifactGraph' +import { promptToEditFlow } from 'lib/promptToEdit' +import { kclEditorActor } from 'machines/kclEditorMachine' +import { commandBarActor } from 'machines/commandBarMachine' +import { useToken } from 'machines/appMachine' +import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' +import { useSettings } from 'machines/appMachine' +import { IndexLoaderData } from 'lib/types' +import { OutputFormat3d, Point3d } from '@rust/kcl-lib/bindings/ModelingCmd' import { EXPORT_TOAST_MESSAGES, MAKE_TOAST_MESSAGES } from 'lib/constants' -import { EXECUTION_TYPE_MOCK } from 'lib/constants' import { exportMake } from 'lib/exportMake' import { exportSave } from 'lib/exportSave' -import { promptToEditFlow } from 'lib/promptToEdit' -import { - Selections, - handleSelectionBatch, - updateSelections, -} from 'lib/selections' -import { - codeManager, - editorManager, - engineCommandManager, - kclManager, - rustContext, - sceneEntitiesManager, - sceneInfra, -} from 'lib/singletons' -import { submitAndAwaitTextToKcl } from 'lib/textToCad' -import { err, reject, reportRejection, trap } from 'lib/trap' -import { IndexLoaderData } from 'lib/types' -import { platform, uuidv4 } from 'lib/utils' -import { useToken } from 'machines/appMachine' -import { useSettings } from 'machines/appMachine' -import { commandBarActor } from 'machines/commandBarMachine' -import { kclEditorActor } from 'machines/kclEditorMachine' -import { - getPersistedContext, - modelingMachine, - modelingMachineDefaultContext, -} from 'machines/modelingMachine' -import React, { - createContext, - useContext, - useEffect, - useMemo, - useRef, -} from 'react' -import toast from 'react-hot-toast' -import { useHotkeys } from 'react-hotkeys-hook' -import { useLoaderData, useNavigate, useSearchParams } from 'react-router-dom' -import { - Actor, - ContextFrom, - Prop, - SnapshotFrom, - StateFrom, - assign, - fromPromise, -} from 'xstate' - -import { OutputFormat3d, Point3d } from '@rust/kcl-lib/bindings/ModelingCmd' -import { Node } from '@rust/kcl-lib/bindings/Node' import { Plane } from '@rust/kcl-lib/bindings/Plane' - -import { applyConstraintIntersect } from './Toolbar/Intersect' -import { applyConstraintAbsDistance } from './Toolbar/SetAbsDistance' -import { - angleBetweenInfo, - applyConstraintAngleBetween, -} from './Toolbar/SetAngleBetween' -import { applyConstraintHorzVertDistance } from './Toolbar/SetHorzVertDistance' -import { - applyConstraintAngleLength, - applyConstraintLength, -} from './Toolbar/setAngleLength' +import { updateModelingState } from 'lang/modelingWorkflows' +import { EXECUTION_TYPE_MOCK } from 'lib/constants' export const ModelingMachineContext = createContext( {} as { diff --git a/src/components/ModelingSidebar/ModelingPane.tsx b/src/components/ModelingSidebar/ModelingPane.tsx index a3fdeecbb..b39c0e05d 100644 --- a/src/components/ModelingSidebar/ModelingPane.tsx +++ b/src/components/ModelingSidebar/ModelingPane.tsx @@ -1,13 +1,12 @@ -import { IconDefinition } from '@fortawesome/free-solid-svg-icons' -import { ActionButton } from 'components/ActionButton' -import { ActionIcon } from 'components/ActionIcon' -import { CustomIconName } from 'components/CustomIcon' -import Tooltip from 'components/Tooltip' -import { useSettings } from 'machines/appMachine' import { ReactNode } from 'react' -import { onboardingPaths } from 'routes/Onboarding/paths' - import styles from './ModelingPane.module.css' +import { ActionButton } from 'components/ActionButton' +import Tooltip from 'components/Tooltip' +import { CustomIconName } from 'components/CustomIcon' +import { IconDefinition } from '@fortawesome/free-solid-svg-icons' +import { ActionIcon } from 'components/ActionIcon' +import { onboardingPaths } from 'routes/Onboarding/paths' +import { useSettings } from 'machines/appMachine' export interface ModelingPaneProps { id: string diff --git a/src/components/ModelingSidebar/ModelingPanes/CodeEditor.tsx b/src/components/ModelingSidebar/ModelingPanes/CodeEditor.tsx index 4b0159e1b..050d9c098 100644 --- a/src/components/ModelingSidebar/ModelingPanes/CodeEditor.tsx +++ b/src/components/ModelingSidebar/ModelingPanes/CodeEditor.tsx @@ -1,20 +1,20 @@ +import React, { + useEffect, + useMemo, + useRef, + useState, + forwardRef, + useImperativeHandle, +} from 'react' import { EditorState, EditorStateConfig, Extension, StateEffect, } from '@codemirror/state' -import { oneDark } from '@codemirror/theme-one-dark' import { EditorView } from '@codemirror/view' +import { oneDark } from '@codemirror/theme-one-dark' import { isArray } from 'lib/utils' -import React, { - forwardRef, - useEffect, - useImperativeHandle, - useMemo, - useRef, - useState, -} from 'react' //reference: https://github.com/sachinraja/rodemirror/blob/main/src/use-first-render.ts const useFirstRender = () => { diff --git a/src/components/ModelingSidebar/ModelingPanes/DebugPane.tsx b/src/components/ModelingSidebar/ModelingPanes/DebugPane.tsx index 620874708..99c4a0166 100644 --- a/src/components/ModelingSidebar/ModelingPanes/DebugPane.tsx +++ b/src/components/ModelingSidebar/ModelingPanes/DebugPane.tsx @@ -1,8 +1,7 @@ -import { CamDebugSettings } from 'clientSideScene/ClientSideSceneComp' import { DebugArtifactGraph } from 'components/DebugArtifactGraph' - import { AstExplorer } from '../../AstExplorer' import { EngineCommands } from '../../EngineCommands' +import { CamDebugSettings } from 'clientSideScene/ClientSideSceneComp' export const DebugPane = () => { return ( diff --git a/src/components/ModelingSidebar/ModelingPanes/FeatureTreeMenu.tsx b/src/components/ModelingSidebar/ModelingPanes/FeatureTreeMenu.tsx index 470de2a14..d0cfb1f9e 100644 --- a/src/components/ModelingSidebar/ModelingPanes/FeatureTreeMenu.tsx +++ b/src/components/ModelingSidebar/ModelingPanes/FeatureTreeMenu.tsx @@ -1,9 +1,8 @@ import { Menu } from '@headlessui/react' -import { ActionIcon } from 'components/ActionIcon' -import { commandBarActor } from 'machines/commandBarMachine' import { PropsWithChildren } from 'react' - +import { ActionIcon } from 'components/ActionIcon' import styles from './KclEditorMenu.module.css' +import { commandBarActor } from 'machines/commandBarMachine' export const FeatureTreeMenu = ({ children }: PropsWithChildren) => { return ( diff --git a/src/components/ModelingSidebar/ModelingPanes/FeatureTreePane.tsx b/src/components/ModelingSidebar/ModelingPanes/FeatureTreePane.tsx index 5581a7fb4..ed0b90747 100644 --- a/src/components/ModelingSidebar/ModelingPanes/FeatureTreePane.tsx +++ b/src/components/ModelingSidebar/ModelingPanes/FeatureTreePane.tsx @@ -14,16 +14,15 @@ import { stdLibMap, } from 'lib/operations' import { editorManager, kclManager } from 'lib/singletons' +import { ComponentProps, useEffect, useMemo, useRef, useState } from 'react' +import { Operation } from '@rust/kcl-lib/bindings/Operation' +import { Actor, Prop } from 'xstate' import { featureTreeMachine } from 'machines/featureTreeMachine' import { editorIsMountedSelector, kclEditorActor, selectionEventSelector, } from 'machines/kclEditorMachine' -import { ComponentProps, useEffect, useMemo, useRef, useState } from 'react' -import { Actor, Prop } from 'xstate' - -import { Operation } from '@rust/kcl-lib/bindings/Operation' export const FeatureTreePane = () => { const isEditorMounted = useSelector(kclEditorActor, editorIsMountedSelector) diff --git a/src/components/ModelingSidebar/ModelingPanes/KclEditorMenu.tsx b/src/components/ModelingSidebar/ModelingPanes/KclEditorMenu.tsx index 82c93239d..ba462d5d4 100644 --- a/src/components/ModelingSidebar/ModelingPanes/KclEditorMenu.tsx +++ b/src/components/ModelingSidebar/ModelingPanes/KclEditorMenu.tsx @@ -1,16 +1,15 @@ -import { faArrowUpRightFromSquare } from '@fortawesome/free-solid-svg-icons' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { Menu } from '@headlessui/react' +import { PropsWithChildren } from 'react' +import { faArrowUpRightFromSquare } from '@fortawesome/free-solid-svg-icons' import { ActionIcon } from 'components/ActionIcon' +import styles from './KclEditorMenu.module.css' import { useConvertToVariable } from 'hooks/useToolbarGuards' -import { openExternalBrowserIfDesktop } from 'lib/openWindow' +import { editorShortcutMeta } from './KclEditorPane' +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { kclManager } from 'lib/singletons' +import { openExternalBrowserIfDesktop } from 'lib/openWindow' import { reportRejection } from 'lib/trap' import { commandBarActor } from 'machines/commandBarMachine' -import { PropsWithChildren } from 'react' - -import styles from './KclEditorMenu.module.css' -import { editorShortcutMeta } from './KclEditorPane' export const KclEditorMenu = ({ children }: PropsWithChildren) => { const { enable: convertToVarEnabled, handleClick: handleConvertToVarClick } = diff --git a/src/components/ModelingSidebar/ModelingPanes/KclEditorPane.tsx b/src/components/ModelingSidebar/ModelingPanes/KclEditorPane.tsx index 4040c053f..5094d0fc5 100644 --- a/src/components/ModelingSidebar/ModelingPanes/KclEditorPane.tsx +++ b/src/components/ModelingSidebar/ModelingPanes/KclEditorPane.tsx @@ -1,57 +1,56 @@ +import { TEST } from 'env' +import { Themes, getSystemTheme } from 'lib/theme' +import { useEffect, useMemo, useRef } from 'react' +import { highlightSelectionMatches, searchKeymap } from '@codemirror/search' +import { lineHighlightField } from 'editor/highlightextension' +import { onMouseDragMakeANewNumber, onMouseDragRegex } from 'lib/utils' +import { + lineNumbers, + rectangularSelection, + highlightActiveLineGutter, + highlightSpecialChars, + highlightActiveLine, + keymap, + EditorView, + dropCursor, + drawSelection, +} from '@codemirror/view' +import { + indentWithTab, + defaultKeymap, + historyKeymap, + history, +} from '@codemirror/commands' +import { diagnosticCount, lintGutter, lintKeymap } from '@codemirror/lint' +import { + foldGutter, + foldKeymap, + bracketMatching, + indentOnInput, + codeFolding, + syntaxHighlighting, + defaultHighlightStyle, +} from '@codemirror/language' +import interact from '@replit/codemirror-interact' +import { kclManager, editorManager, codeManager } from 'lib/singletons' +import { useHotkeys } from 'react-hotkeys-hook' +import { useLspContext } from 'components/LspProvider' +import { Prec, EditorState, Extension, Transaction } from '@codemirror/state' import { closeBrackets, closeBracketsKeymap, completionKeymap, } from '@codemirror/autocomplete' -import { - defaultKeymap, - history, - historyKeymap, - indentWithTab, -} from '@codemirror/commands' -import { - bracketMatching, - codeFolding, - defaultHighlightStyle, - foldGutter, - foldKeymap, - indentOnInput, - syntaxHighlighting, -} from '@codemirror/language' -import { diagnosticCount, lintGutter, lintKeymap } from '@codemirror/lint' -import { highlightSelectionMatches, searchKeymap } from '@codemirror/search' -import { EditorState, Extension, Prec, Transaction } from '@codemirror/state' -import { - EditorView, - drawSelection, - dropCursor, - highlightActiveLine, - highlightActiveLineGutter, - highlightSpecialChars, - keymap, - lineNumbers, - rectangularSelection, -} from '@codemirror/view' -import interact from '@replit/codemirror-interact' -import { useSelector } from '@xstate/react' -import { useLspContext } from 'components/LspProvider' -import { lineHighlightField } from 'editor/highlightextension' -import { modelingMachineEvent } from 'editor/manager' -import { TEST } from 'env' +import CodeEditor from './CodeEditor' import { codeManagerHistoryCompartment } from 'lang/codeManager' -import { codeManager, editorManager, kclManager } from 'lib/singletons' -import { Themes, getSystemTheme } from 'lib/theme' -import { onMouseDragMakeANewNumber, onMouseDragRegex } from 'lib/utils' -import { useSettings } from 'machines/appMachine' import { editorIsMountedSelector, kclEditorActor, selectionEventSelector, } from 'machines/kclEditorMachine' -import { useEffect, useMemo, useRef } from 'react' -import { useHotkeys } from 'react-hotkeys-hook' - -import CodeEditor from './CodeEditor' +import { useSelector } from '@xstate/react' +import { modelingMachineEvent } from 'editor/manager' +import { useSettings } from 'machines/appMachine' export const editorShortcutMeta = { formatCode: { diff --git a/src/components/ModelingSidebar/ModelingPanes/LoggingPanes.tsx b/src/components/ModelingSidebar/ModelingPanes/LoggingPanes.tsx index 1eb503a34..91b7d628b 100644 --- a/src/components/ModelingSidebar/ModelingPanes/LoggingPanes.tsx +++ b/src/components/ModelingSidebar/ModelingPanes/LoggingPanes.tsx @@ -1,6 +1,6 @@ -import { useResolvedTheme } from 'hooks/useResolvedTheme' -import { useKclContext } from 'lang/KclProvider' import ReactJson from 'react-json-view' +import { useKclContext } from 'lang/KclProvider' +import { useResolvedTheme } from 'hooks/useResolvedTheme' const ReactJsonTypeHack = ReactJson as any diff --git a/src/components/ModelingSidebar/ModelingPanes/MemoryPane.test.tsx b/src/components/ModelingSidebar/ModelingPanes/MemoryPane.test.tsx index 590abceb0..1e598ad60 100644 --- a/src/components/ModelingSidebar/ModelingPanes/MemoryPane.test.tsx +++ b/src/components/ModelingSidebar/ModelingPanes/MemoryPane.test.tsx @@ -1,6 +1,6 @@ -import { assertParse, initPromise } from '../../../lang/wasm' -import { enginelessExecutor } from '../../../lib/testHelpers' import { processMemory } from './MemoryPane' +import { enginelessExecutor } from '../../../lib/testHelpers' +import { assertParse, initPromise } from '../../../lang/wasm' beforeAll(async () => { await initPromise diff --git a/src/components/ModelingSidebar/ModelingPanes/MemoryPane.tsx b/src/components/ModelingSidebar/ModelingPanes/MemoryPane.tsx index 939d2ac9f..7b11fd6b1 100644 --- a/src/components/ModelingSidebar/ModelingPanes/MemoryPane.tsx +++ b/src/components/ModelingSidebar/ModelingPanes/MemoryPane.tsx @@ -1,18 +1,18 @@ -import { ActionButton } from 'components/ActionButton' -import Tooltip from 'components/Tooltip' -import { useModelingContext } from 'hooks/useModelingContext' -import { useResolvedTheme } from 'hooks/useResolvedTheme' -import { useKclContext } from 'lang/KclProvider' -import { - ExtrudeSurface, - Path, - VariableMap, - sketchFromKclValueOptional, -} from 'lang/wasm' -import { Reason, trap } from 'lib/trap' -import { useMemo } from 'react' import toast from 'react-hot-toast' import ReactJson from 'react-json-view' +import { useMemo } from 'react' +import { + Path, + ExtrudeSurface, + sketchFromKclValueOptional, + VariableMap, +} from 'lang/wasm' +import { useKclContext } from 'lang/KclProvider' +import { useResolvedTheme } from 'hooks/useResolvedTheme' +import { ActionButton } from 'components/ActionButton' +import { Reason, trap } from 'lib/trap' +import Tooltip from 'components/Tooltip' +import { useModelingContext } from 'hooks/useModelingContext' export const MemoryPaneMenu = () => { const { variables } = useKclContext() diff --git a/src/components/ModelingSidebar/ModelingPanes/index.tsx b/src/components/ModelingSidebar/ModelingPanes/index.tsx index 5faea9cf9..6ec850748 100644 --- a/src/components/ModelingSidebar/ModelingPanes/index.tsx +++ b/src/components/ModelingSidebar/ModelingPanes/index.tsx @@ -1,26 +1,25 @@ import { IconDefinition, faBugSlash } from '@fortawesome/free-solid-svg-icons' +import { KclEditorMenu } from 'components/ModelingSidebar/ModelingPanes/KclEditorMenu' import { CustomIconName } from 'components/CustomIcon' +import { KclEditorPane } from 'components/ModelingSidebar/ModelingPanes/KclEditorPane' +import { ModelingPaneHeader } from 'components/ModelingSidebar/ModelingPane' +import { MouseEventHandler, ReactNode } from 'react' +import { MemoryPane, MemoryPaneMenu } from './MemoryPane' +import { LogsPane } from './LoggingPanes' +import { DebugPane } from './DebugPane' import { FileTreeInner, FileTreeMenu, FileTreeRoot, useFileTreeOperations, } from 'components/FileTree' -import { ModelingPaneHeader } from 'components/ModelingSidebar/ModelingPane' -import { KclEditorMenu } from 'components/ModelingSidebar/ModelingPanes/KclEditorMenu' -import { KclEditorPane } from 'components/ModelingSidebar/ModelingPanes/KclEditorPane' import { useKclContext } from 'lang/KclProvider' -import { kclErrorsByFilename } from 'lang/errors' import { editorManager } from 'lib/singletons' -import { settingsMachine } from 'machines/settingsMachine' -import { MouseEventHandler, ReactNode } from 'react' import { ContextFrom } from 'xstate' - -import { DebugPane } from './DebugPane' -import { FeatureTreeMenu } from './FeatureTreeMenu' +import { settingsMachine } from 'machines/settingsMachine' import { FeatureTreePane } from './FeatureTreePane' -import { LogsPane } from './LoggingPanes' -import { MemoryPane, MemoryPaneMenu } from './MemoryPane' +import { kclErrorsByFilename } from 'lang/errors' +import { FeatureTreeMenu } from './FeatureTreeMenu' export type SidebarType = | 'code' diff --git a/src/components/ModelingSidebar/ModelingSidebar.tsx b/src/components/ModelingSidebar/ModelingSidebar.tsx index 8ab21b9ec..38146b8a8 100644 --- a/src/components/ModelingSidebar/ModelingSidebar.tsx +++ b/src/components/ModelingSidebar/ModelingSidebar.tsx @@ -1,27 +1,26 @@ -import { IconDefinition } from '@fortawesome/free-solid-svg-icons' -import { ActionIcon } from 'components/ActionIcon' -import { CustomIconName } from 'components/CustomIcon' -import { MachineManagerContext } from 'components/MachineManagerProvider' -import Tooltip from 'components/Tooltip' -import { useModelingContext } from 'hooks/useModelingContext' -import { useKclContext } from 'lang/KclProvider' -import { SIDEBAR_BUTTON_SUFFIX } from 'lib/constants' -import { isDesktop } from 'lib/isDesktop' -import { useSettings } from 'machines/appMachine' -import { commandBarActor } from 'machines/commandBarMachine' import { Resizable } from 're-resizable' import { MouseEventHandler, useCallback, - useContext, useEffect, useMemo, + useContext, } from 'react' import { useHotkeys } from 'react-hotkeys-hook' -import { onboardingPaths } from 'routes/Onboarding/paths' - -import { ModelingPane } from './ModelingPane' import { SidebarAction, SidebarType, sidebarPanes } from './ModelingPanes' +import Tooltip from 'components/Tooltip' +import { ActionIcon } from 'components/ActionIcon' +import { ModelingPane } from './ModelingPane' +import { isDesktop } from 'lib/isDesktop' +import { useModelingContext } from 'hooks/useModelingContext' +import { CustomIconName } from 'components/CustomIcon' +import { IconDefinition } from '@fortawesome/free-solid-svg-icons' +import { useKclContext } from 'lang/KclProvider' +import { MachineManagerContext } from 'components/MachineManagerProvider' +import { onboardingPaths } from 'routes/Onboarding/paths' +import { SIDEBAR_BUTTON_SUFFIX } from 'lib/constants' +import { commandBarActor } from 'machines/commandBarMachine' +import { useSettings } from 'machines/appMachine' interface ModelingSidebarProps { paneOpacity: '' | 'opacity-20' | 'opacity-40' @@ -114,20 +113,17 @@ export function ModelingSidebar({ paneOpacity }: ModelingSidebarProps) { ) const paneBadgeMap: Record = useMemo(() => { - return filteredPanes.reduce( - (acc, pane) => { - if (pane.showBadge) { - acc[pane.id] = { - value: pane.showBadge.value(paneCallbackProps), - onClick: pane.showBadge.onClick, - className: pane.showBadge.className, - title: pane.showBadge.title, - } + return filteredPanes.reduce((acc, pane) => { + if (pane.showBadge) { + acc[pane.id] = { + value: pane.showBadge.value(paneCallbackProps), + onClick: pane.showBadge.onClick, + className: pane.showBadge.className, + title: pane.showBadge.title, } - return acc - }, - {} as Record - ) + } + return acc + }, {} as Record) }, [paneCallbackProps]) // Clear any hidden panes from the `openPanes` array diff --git a/src/components/NetworkHealthIndicator.test.tsx b/src/components/NetworkHealthIndicator.test.tsx index 62f004334..84e2ef978 100644 --- a/src/components/NetworkHealthIndicator.test.tsx +++ b/src/components/NetworkHealthIndicator.test.tsx @@ -1,11 +1,10 @@ import { fireEvent, render, screen } from '@testing-library/react' -import { NetworkHealthState } from 'hooks/useNetworkStatus' import { BrowserRouter } from 'react-router-dom' - import { NETWORK_HEALTH_TEXT, NetworkHealthIndicator, } from './NetworkHealthIndicator' +import { NetworkHealthState } from 'hooks/useNetworkStatus' function TestWrap({ children }: { children: React.ReactNode }) { // wrap in router and xState context diff --git a/src/components/NetworkHealthIndicator.tsx b/src/components/NetworkHealthIndicator.tsx index 3ef1fb0e2..45381dc5f 100644 --- a/src/components/NetworkHealthIndicator.tsx +++ b/src/components/NetworkHealthIndicator.tsx @@ -1,12 +1,11 @@ import { Popover } from '@headlessui/react' -import { reportRejection } from 'lib/trap' -import { toSync } from 'lib/utils' - -import { useNetworkContext } from '../hooks/useNetworkContext' -import { NetworkHealthState } from '../hooks/useNetworkStatus' -import { ConnectingTypeGroup } from '../lang/std/engineConnection' import { ActionIcon, ActionIconProps } from './ActionIcon' import Tooltip from './Tooltip' +import { ConnectingTypeGroup } from '../lang/std/engineConnection' +import { useNetworkContext } from '../hooks/useNetworkContext' +import { NetworkHealthState } from '../hooks/useNetworkStatus' +import { toSync } from 'lib/utils' +import { reportRejection } from 'lib/trap' export const NETWORK_HEALTH_TEXT: Record = { [NetworkHealthState.Ok]: 'Connected', diff --git a/src/components/NetworkMachineIndicator.tsx b/src/components/NetworkMachineIndicator.tsx index a7a0f1c31..6d07fd946 100644 --- a/src/components/NetworkMachineIndicator.tsx +++ b/src/components/NetworkMachineIndicator.tsx @@ -1,11 +1,10 @@ import { Popover } from '@headlessui/react' -import { MachineManagerContext } from 'components/MachineManagerProvider' +import { useContext } from 'react' +import Tooltip from './Tooltip' import { isDesktop } from 'lib/isDesktop' import { components } from 'lib/machine-api' -import { useContext } from 'react' - +import { MachineManagerContext } from 'components/MachineManagerProvider' import { CustomIcon } from './CustomIcon' -import Tooltip from './Tooltip' export const NetworkMachineIndicator = ({ className, diff --git a/src/components/OpenInDesktopAppHandler.test.tsx b/src/components/OpenInDesktopAppHandler.test.tsx index 71de40429..9cac84fee 100644 --- a/src/components/OpenInDesktopAppHandler.test.tsx +++ b/src/components/OpenInDesktopAppHandler.test.tsx @@ -1,6 +1,5 @@ import { fireEvent, render, screen } from '@testing-library/react' import { BrowserRouter, Route, Routes } from 'react-router-dom' - import { OpenInDesktopAppHandler } from './OpenInDesktopAppHandler' /** diff --git a/src/components/OpenInDesktopAppHandler.tsx b/src/components/OpenInDesktopAppHandler.tsx index ac72af626..3c34dad1e 100644 --- a/src/components/OpenInDesktopAppHandler.tsx +++ b/src/components/OpenInDesktopAppHandler.tsx @@ -1,12 +1,11 @@ -import { Transition } from '@headlessui/react' -import { VITE_KC_SITE_BASE_URL } from 'env' +import { getSystemTheme, Themes } from 'lib/theme' import { ZOO_STUDIO_PROTOCOL } from 'lib/constants' -import { ASK_TO_OPEN_QUERY_PARAM } from 'lib/constants' import { isDesktop } from 'lib/isDesktop' -import { Themes, getSystemTheme } from 'lib/theme' import { useSearchParams } from 'react-router-dom' - +import { ASK_TO_OPEN_QUERY_PARAM } from 'lib/constants' +import { VITE_KC_SITE_BASE_URL } from 'env' import { ActionButton } from './ActionButton' +import { Transition } from '@headlessui/react' /** * This component is a handler that checks if a certain query parameter diff --git a/src/components/ProjectCard/ProjectCard.tsx b/src/components/ProjectCard/ProjectCard.tsx index 9aee57bea..da6a20313 100644 --- a/src/components/ProjectCard/ProjectCard.tsx +++ b/src/components/ProjectCard/ProjectCard.tsx @@ -1,16 +1,15 @@ -import { FILE_EXT, PROJECT_IMAGE_NAME } from 'lib/constants' -import { PATHS } from 'lib/paths' -import { Project } from 'lib/project' -import { reportRejection } from 'lib/trap' -import { toSync } from 'lib/utils' import { FormEvent, useEffect, useRef, useState } from 'react' -import { useHotkeys } from 'react-hotkeys-hook' +import { PATHS } from 'lib/paths' import { Link } from 'react-router-dom' - import { ActionButton } from '../ActionButton' +import { FILE_EXT, PROJECT_IMAGE_NAME } from 'lib/constants' +import { useHotkeys } from 'react-hotkeys-hook' import Tooltip from '../Tooltip' import { DeleteConfirmationDialog } from './DeleteProjectDialog' import { ProjectCardRenameForm } from './ProjectCardRenameForm' +import { Project } from 'lib/project' +import { toSync } from 'lib/utils' +import { reportRejection } from 'lib/trap' function ProjectCard({ project, diff --git a/src/components/ProjectCard/ProjectCardRenameForm.tsx b/src/components/ProjectCard/ProjectCardRenameForm.tsx index 5813babac..91addd69c 100644 --- a/src/components/ProjectCard/ProjectCardRenameForm.tsx +++ b/src/components/ProjectCard/ProjectCardRenameForm.tsx @@ -1,7 +1,7 @@ import { ActionButton } from 'components/ActionButton' import Tooltip from 'components/Tooltip' -import { Project } from 'lib/project' import { HTMLProps, forwardRef } from 'react' +import { Project } from 'lib/project' interface ProjectCardRenameFormProps extends HTMLProps { project: Project diff --git a/src/components/ProjectSearchBar.tsx b/src/components/ProjectSearchBar.tsx index 7327af75f..2eabd3035 100644 --- a/src/components/ProjectSearchBar.tsx +++ b/src/components/ProjectSearchBar.tsx @@ -1,9 +1,8 @@ -import Fuse from 'fuse.js' import { Project } from 'lib/project' +import { CustomIcon } from './CustomIcon' import { useEffect, useRef, useState } from 'react' import { useHotkeys } from 'react-hotkeys-hook' - -import { CustomIcon } from './CustomIcon' +import Fuse from 'fuse.js' export function useProjectSearch(projects: Project[]) { const [query, setQuery] = useState('') diff --git a/src/components/ProjectSidebarMenu.test.tsx b/src/components/ProjectSidebarMenu.test.tsx index e950d63a6..60c43184c 100644 --- a/src/components/ProjectSidebarMenu.test.tsx +++ b/src/components/ProjectSidebarMenu.test.tsx @@ -1,8 +1,7 @@ import { render, screen } from '@testing-library/react' -import { Project } from 'lib/project' import { BrowserRouter } from 'react-router-dom' - import ProjectSidebarMenu from './ProjectSidebarMenu' +import { Project } from 'lib/project' const now = new Date() const projectWellFormed = { diff --git a/src/components/ProjectSidebarMenu.tsx b/src/components/ProjectSidebarMenu.tsx index 20271e43d..5e125a829 100644 --- a/src/components/ProjectSidebarMenu.tsx +++ b/src/components/ProjectSidebarMenu.tsx @@ -1,25 +1,24 @@ import { Popover, Transition } from '@headlessui/react' -import { useSelector } from '@xstate/react' -import { MachineManagerContext } from 'components/MachineManagerProvider' -import { useAbsoluteFilePath } from 'hooks/useAbsoluteFilePath' -import usePlatform from 'hooks/usePlatform' -import { APP_NAME } from 'lib/constants' -import { copyFileShareLink } from 'lib/links' -import { PATHS } from 'lib/paths' -import { codeManager, engineCommandManager, kclManager } from 'lib/singletons' -import { type IndexLoaderData } from 'lib/types' -import { useToken } from 'machines/appMachine' -import { commandBarActor } from 'machines/commandBarMachine' -import { Fragment, useContext, useMemo } from 'react' -import { Link, useLocation, useNavigate } from 'react-router-dom' -import { SnapshotFrom } from 'xstate' - -import { isDesktop } from '../lib/isDesktop' import { ActionButton, ActionButtonProps } from './ActionButton' -import { CustomIcon } from './CustomIcon' +import { type IndexLoaderData } from 'lib/types' +import { PATHS } from 'lib/paths' +import { isDesktop } from '../lib/isDesktop' +import { Link, useLocation, useNavigate } from 'react-router-dom' +import { Fragment, useMemo, useContext } from 'react' import { Logo } from './Logo' +import { APP_NAME } from 'lib/constants' +import { CustomIcon } from './CustomIcon' import { useLspContext } from './LspProvider' +import { codeManager, engineCommandManager, kclManager } from 'lib/singletons' +import { MachineManagerContext } from 'components/MachineManagerProvider' +import usePlatform from 'hooks/usePlatform' +import { useAbsoluteFilePath } from 'hooks/useAbsoluteFilePath' import Tooltip from './Tooltip' +import { SnapshotFrom } from 'xstate' +import { commandBarActor } from 'machines/commandBarMachine' +import { useSelector } from '@xstate/react' +import { copyFileShareLink } from 'lib/links' +import { useToken } from 'machines/appMachine' const ProjectSidebarMenu = ({ project, diff --git a/src/components/ProjectsContextProvider.tsx b/src/components/ProjectsContextProvider.tsx index e5bd26f8d..0c6559f98 100644 --- a/src/components/ProjectsContextProvider.tsx +++ b/src/components/ProjectsContextProvider.tsx @@ -1,40 +1,39 @@ import { useMachine } from '@xstate/react' import { useFileSystemWatcher } from 'hooks/useFileSystemWatcher' import { useProjectsLoader } from 'hooks/useProjectsLoader' -import useStateMachineCommands from 'hooks/useStateMachineCommands' -import { newKclFile } from 'lang/project' -import { projectsCommandBarConfig } from 'lib/commandBarConfigs/projectsCommandConfig' -import { - CREATE_FILE_URL_PARAM, - FILE_EXT, - PROJECT_ENTRYPOINT, -} from 'lib/constants' +import { projectsMachine } from 'machines/projectsMachine' +import { createContext, useCallback, useEffect, useState } from 'react' +import { Actor, AnyStateMachine, fromPromise, Prop, StateFrom } from 'xstate' +import { useLspContext } from './LspProvider' +import toast from 'react-hot-toast' +import { useLocation, useNavigate, useSearchParams } from 'react-router-dom' +import { PATHS } from 'lib/paths' import { createNewProjectDirectory, listProjects, renameProjectDirectory, } from 'lib/desktop' import { - doesProjectNameNeedInterpolated, - getNextFileName, getNextProjectIndex, - getUniqueProjectName, interpolateProjectNameWithIndex, + doesProjectNameNeedInterpolated, + getUniqueProjectName, + getNextFileName, } from 'lib/desktopFS' +import useStateMachineCommands from 'hooks/useStateMachineCommands' +import { projectsCommandBarConfig } from 'lib/commandBarConfigs/projectsCommandConfig' import { isDesktop } from 'lib/isDesktop' -import { PATHS } from 'lib/paths' -import { Project } from 'lib/project' -import { codeManager, kclManager } from 'lib/singletons' -import { err } from 'lib/trap' -import { useSettings } from 'machines/appMachine' import { commandBarActor } from 'machines/commandBarMachine' -import { projectsMachine } from 'machines/projectsMachine' -import { createContext, useCallback, useEffect, useState } from 'react' -import toast from 'react-hot-toast' -import { useLocation, useNavigate, useSearchParams } from 'react-router-dom' -import { Actor, AnyStateMachine, Prop, StateFrom, fromPromise } from 'xstate' - -import { useLspContext } from './LspProvider' +import { useSettings } from 'machines/appMachine' +import { + CREATE_FILE_URL_PARAM, + FILE_EXT, + PROJECT_ENTRYPOINT, +} from 'lib/constants' +import { codeManager, kclManager } from 'lib/singletons' +import { Project } from 'lib/project' +import { newKclFile } from 'lang/project' +import { err } from 'lib/trap' type MachineContext = { state?: StateFrom @@ -383,8 +382,8 @@ const ProjectsContextDesktop = ({ input.method === 'newProject' ? PROJECT_ENTRYPOINT : input.name.endsWith(FILE_EXT) - ? input.name - : input.name + FILE_EXT + ? input.name + : input.name + FILE_EXT let message = 'File created successfully' const needsInterpolated = doesProjectNameNeedInterpolated(projectName) diff --git a/src/components/RefreshButton.tsx b/src/components/RefreshButton.tsx index dd8447781..65aefb741 100644 --- a/src/components/RefreshButton.tsx +++ b/src/components/RefreshButton.tsx @@ -1,17 +1,16 @@ -import { useMenuListener } from 'hooks/useMenu' import { coreDump } from 'lang/wasm' import { CoreDumpManager } from 'lib/coredump' +import { CustomIcon } from './CustomIcon' import { codeManager, engineCommandManager } from 'lib/singletons' -import { rustContext } from 'lib/singletons' +import React, { useMemo } from 'react' +import toast from 'react-hot-toast' +import Tooltip from './Tooltip' import { reportRejection } from 'lib/trap' import { toSync } from 'lib/utils' import { useToken } from 'machines/appMachine' -import React, { useMemo } from 'react' -import toast from 'react-hot-toast' - +import { rustContext } from 'lib/singletons' import type { WebContentSendPayload } from '../menu/channels' -import { CustomIcon } from './CustomIcon' -import Tooltip from './Tooltip' +import { useMenuListener } from 'hooks/useMenu' export const RefreshButton = ({ children }: React.PropsWithChildren) => { const token = useToken() diff --git a/src/components/RouteProvider.tsx b/src/components/RouteProvider.tsx index d88d7679f..6662f8702 100644 --- a/src/components/RouteProvider.tsx +++ b/src/components/RouteProvider.tsx @@ -1,22 +1,21 @@ -import { useAuthNavigation } from 'hooks/useAuthNavigation' -import { useFileSystemWatcher } from 'hooks/useFileSystemWatcher' -import { getAppSettingsFilePath } from 'lib/desktop' -import { isDesktop } from 'lib/isDesktop' -import { PATHS } from 'lib/paths' -import { markOnce } from 'lib/performance' -import { loadAndValidateSettings } from 'lib/settings/settingsUtils' -import { trap } from 'lib/trap' -import { IndexLoaderData } from 'lib/types' -import { useSettings } from 'machines/appMachine' -import { settingsActor } from 'machines/appMachine' -import { ReactNode, createContext, useEffect, useState } from 'react' +import { useEffect, useState, createContext, ReactNode } from 'react' import { + useNavigation, useLocation, useNavigate, - useNavigation, useRouteLoaderData, } from 'react-router-dom' - +import { PATHS } from 'lib/paths' +import { markOnce } from 'lib/performance' +import { useAuthNavigation } from 'hooks/useAuthNavigation' +import { useSettings } from 'machines/appMachine' +import { IndexLoaderData } from 'lib/types' +import { getAppSettingsFilePath } from 'lib/desktop' +import { isDesktop } from 'lib/isDesktop' +import { trap } from 'lib/trap' +import { useFileSystemWatcher } from 'hooks/useFileSystemWatcher' +import { loadAndValidateSettings } from 'lib/settings/settingsUtils' +import { settingsActor } from 'machines/appMachine' import { OnboardingStatus } from '@rust/kcl-lib/bindings/OnboardingStatus' export const RouteProviderContext = createContext({}) diff --git a/src/components/SetAngleLengthModal.tsx b/src/components/SetAngleLengthModal.tsx index c7333e9c3..982f98bfb 100644 --- a/src/components/SetAngleLengthModal.tsx +++ b/src/components/SetAngleLengthModal.tsx @@ -1,15 +1,14 @@ import { Dialog, Transition } from '@headlessui/react' -import { useCalculateKclExpression } from 'lib/useCalculateKclExpression' import { Fragment, useState } from 'react' import { type InstanceProps, create } from 'react-modal-promise' - import { Expr } from '../lang/wasm' import { AvailableVars, + addToInputHelper, CalcResult, CreateNewVariable, - addToInputHelper, } from './AvailableVarsHelpers' +import { useCalculateKclExpression } from 'lib/useCalculateKclExpression' type ModalResolve = { value: string diff --git a/src/components/SetHorVertDistanceModal.tsx b/src/components/SetHorVertDistanceModal.tsx index 6b7a814ad..46c1f2ff6 100644 --- a/src/components/SetHorVertDistanceModal.tsx +++ b/src/components/SetHorVertDistanceModal.tsx @@ -1,15 +1,14 @@ import { Dialog, Transition } from '@headlessui/react' -import { useCalculateKclExpression } from 'lib/useCalculateKclExpression' import { Fragment, useState } from 'react' import { type InstanceProps, create } from 'react-modal-promise' - import { Expr } from '../lang/wasm' import { AvailableVars, + addToInputHelper, CalcResult, CreateNewVariable, - addToInputHelper, } from './AvailableVarsHelpers' +import { useCalculateKclExpression } from 'lib/useCalculateKclExpression' type ModalResolve = { value: string diff --git a/src/components/SetVarNameModal.tsx b/src/components/SetVarNameModal.tsx index f9b69c088..e69f1f2de 100644 --- a/src/components/SetVarNameModal.tsx +++ b/src/components/SetVarNameModal.tsx @@ -1,11 +1,10 @@ import { Dialog, Transition } from '@headlessui/react' -import { useCalculateKclExpression } from 'lib/useCalculateKclExpression' import { Fragment } from 'react' +import { CreateNewVariable } from './AvailableVarsHelpers' +import { ActionButton } from './ActionButton' import { toast } from 'react-hot-toast' import { type InstanceProps, create } from 'react-modal-promise' - -import { ActionButton } from './ActionButton' -import { CreateNewVariable } from './AvailableVarsHelpers' +import { useCalculateKclExpression } from 'lib/useCalculateKclExpression' type ModalResolve = { variableName: string } type ModalReject = boolean diff --git a/src/components/Settings/AllSettingsFields.tsx b/src/components/Settings/AllSettingsFields.tsx index 621ac20bd..6b9ae8da6 100644 --- a/src/components/Settings/AllSettingsFields.tsx +++ b/src/components/Settings/AllSettingsFields.tsx @@ -1,32 +1,31 @@ -import { useSelector } from '@xstate/react' -import { ActionButton } from 'components/ActionButton' -import { useLspContext } from 'components/LspProvider' import decamelize from 'decamelize' -import { useDotDotSlash } from 'hooks/useDotDotSlash' -import { - createAndOpenNewTutorialProject, - getSettingsFolderPaths, -} from 'lib/desktopFS' -import { isDesktop } from 'lib/isDesktop' -import { openExternalBrowserIfDesktop } from 'lib/openWindow' -import { PATHS } from 'lib/paths' import { Setting } from 'lib/settings/initialSettings' import { SetEventTypes, SettingsLevel } from 'lib/settings/settingsTypes' import { shouldHideSetting, shouldShowSettingInput, } from 'lib/settings/settingsUtils' -import { reportRejection } from 'lib/trap' -import { toSync } from 'lib/utils' -import { settingsActor, useSettings } from 'machines/appMachine' -import { ForwardedRef, forwardRef, useEffect, useMemo } from 'react' -import toast from 'react-hot-toast' -import { useLocation, useNavigate } from 'react-router-dom' import { Fragment } from 'react/jsx-runtime' -import { APP_VERSION, IS_NIGHTLY, getReleaseUrl } from 'routes/Settings' - -import { SettingsFieldInput } from './SettingsFieldInput' import { SettingsSection } from './SettingsSection' +import { useLocation, useNavigate } from 'react-router-dom' +import { isDesktop } from 'lib/isDesktop' +import { ActionButton } from 'components/ActionButton' +import { SettingsFieldInput } from './SettingsFieldInput' +import toast from 'react-hot-toast' +import { APP_VERSION, IS_NIGHTLY, getReleaseUrl } from 'routes/Settings' +import { PATHS } from 'lib/paths' +import { + createAndOpenNewTutorialProject, + getSettingsFolderPaths, +} from 'lib/desktopFS' +import { useDotDotSlash } from 'hooks/useDotDotSlash' +import { ForwardedRef, forwardRef, useEffect, useMemo } from 'react' +import { useLspContext } from 'components/LspProvider' +import { toSync } from 'lib/utils' +import { reportRejection } from 'lib/trap' +import { openExternalBrowserIfDesktop } from 'lib/openWindow' +import { settingsActor, useSettings } from 'machines/appMachine' +import { useSelector } from '@xstate/react' interface AllSettingsFieldsProps { searchParamTab: SettingsLevel diff --git a/src/components/Settings/SettingsTabs.tsx b/src/components/Settings/SettingsTabs.tsx index 22e57e75e..2b93cb40b 100644 --- a/src/components/Settings/SettingsTabs.tsx +++ b/src/components/Settings/SettingsTabs.tsx @@ -1,5 +1,4 @@ import { RadioGroup } from '@headlessui/react' - import { SettingsTabButton } from './SettingsTabButton' interface SettingsTabButtonProps { diff --git a/src/components/Stream.tsx b/src/components/Stream.tsx index d2ff190c3..f64b45431 100644 --- a/src/components/Stream.tsx +++ b/src/components/Stream.tsx @@ -1,27 +1,26 @@ -import { useAppStream } from 'AppState' -import { ClientSideScene } from 'clientSideScene/ClientSideSceneComp' +import { MouseEventHandler, useEffect, useRef, useState } from 'react' +import Loading from './Loading' import { useModelingContext } from 'hooks/useModelingContext' import { useNetworkContext } from 'hooks/useNetworkContext' import { NetworkHealthState } from 'hooks/useNetworkStatus' -import { getArtifactOfTypes } from 'lang/std/artifactGraph' +import { ClientSideScene } from 'clientSideScene/ClientSideSceneComp' +import { btnName } from 'lib/cameraControls' +import { sendSelectEventToEngine } from 'lib/selections' +import { kclManager, engineCommandManager, sceneInfra } from 'lib/singletons' +import { useAppStream } from 'AppState' import { - DisconnectingType, EngineCommandManagerEvents, EngineConnectionStateType, + DisconnectingType, } from 'lang/std/engineConnection' -import { btnName } from 'lib/cameraControls' -import { PATHS } from 'lib/paths' -import { sendSelectEventToEngine } from 'lib/selections' -import { engineCommandManager, kclManager, sceneInfra } from 'lib/singletons' -import { err, reportRejection } from 'lib/trap' -import { IndexLoaderData } from 'lib/types' -import { useSettings } from 'machines/appMachine' -import { useCommandBarState } from 'machines/commandBarMachine' -import { MouseEventHandler, useEffect, useRef, useState } from 'react' import { useRouteLoaderData } from 'react-router-dom' - -import Loading from './Loading' +import { PATHS } from 'lib/paths' +import { IndexLoaderData } from 'lib/types' +import { err, reportRejection } from 'lib/trap' +import { getArtifactOfTypes } from 'lang/std/artifactGraph' import { ViewControlContextMenu } from './ViewControlMenu' +import { useCommandBarState } from 'machines/commandBarMachine' +import { useSettings } from 'machines/appMachine' enum StreamState { Playing = 'playing', diff --git a/src/components/TelemetryExplorer.tsx b/src/components/TelemetryExplorer.tsx index acb1dbeda..24c0d85a2 100644 --- a/src/components/TelemetryExplorer.tsx +++ b/src/components/TelemetryExplorer.tsx @@ -1,4 +1,5 @@ import { getMarks } from 'lib/performance' + import { printDeltaTotal, printInvocationCount, diff --git a/src/components/ToastTextToCad.tsx b/src/components/ToastTextToCad.tsx index 3a0a935c0..899e60261 100644 --- a/src/components/ToastTextToCad.tsx +++ b/src/components/ToastTextToCad.tsx @@ -1,20 +1,14 @@ -import { - TextToCadIteration_type, - TextToCad_type, -} from '@kittycad/lib/dist/types/src/models' +import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader' +import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls' import { useFileContext } from 'hooks/useFileContext' -import { base64Decode } from 'lang/wasm' import { isDesktop } from 'lib/isDesktop' -import { openExternalBrowserIfDesktop } from 'lib/openWindow' import { PATHS } from 'lib/paths' -import { codeManager, kclManager } from 'lib/singletons' -import { sendTelemetry } from 'lib/textToCad' -import { Themes } from 'lib/theme' -import { reportRejection } from 'lib/trap' -import { commandBarActor } from 'machines/commandBarMachine' -import { fileMachine } from 'machines/fileMachine' -import { useCallback, useEffect, useRef, useState } from 'react' import toast from 'react-hot-toast' +import { + TextToCad_type, + TextToCadIteration_type, +} from '@kittycad/lib/dist/types/src/models' +import { useCallback, useEffect, useRef, useState } from 'react' import { Box3, Color, @@ -29,12 +23,17 @@ import { Vector3, WebGLRenderer, } from 'three' -import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls' import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader' -import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader' -import { EventFrom } from 'xstate' - +import { base64Decode } from 'lang/wasm' +import { sendTelemetry } from 'lib/textToCad' +import { Themes } from 'lib/theme' import { ActionButton } from './ActionButton' +import { commandBarActor } from 'machines/commandBarMachine' +import { EventFrom } from 'xstate' +import { fileMachine } from 'machines/fileMachine' +import { reportRejection } from 'lib/trap' +import { codeManager, kclManager } from 'lib/singletons' +import { openExternalBrowserIfDesktop } from 'lib/openWindow' const CANVAS_SIZE = 128 const PROMPT_TRUNCATE_LENGTH = 128 diff --git a/src/components/ToastUpdate.test.tsx b/src/components/ToastUpdate.test.tsx index a746cc8cd..8b141e701 100644 --- a/src/components/ToastUpdate.test.tsx +++ b/src/components/ToastUpdate.test.tsx @@ -1,6 +1,5 @@ import { fireEvent, render, screen } from '@testing-library/react' import { vi } from 'vitest' - import { ToastUpdate } from './ToastUpdate' describe('ToastUpdate tests', () => { diff --git a/src/components/ToastUpdate.tsx b/src/components/ToastUpdate.tsx index a879b1c89..fbedc03fd 100644 --- a/src/components/ToastUpdate.tsx +++ b/src/components/ToastUpdate.tsx @@ -1,10 +1,9 @@ -import { Marked, MarkedOptions, escape, unescape } from '@ts-stack/markdown' -import { SafeRenderer } from 'lib/markdown' -import { openExternalBrowserIfDesktop } from 'lib/openWindow' import toast from 'react-hot-toast' -import { getReleaseUrl } from 'routes/Settings' - import { ActionButton } from './ActionButton' +import { openExternalBrowserIfDesktop } from 'lib/openWindow' +import { escape, Marked, MarkedOptions, unescape } from '@ts-stack/markdown' +import { getReleaseUrl } from 'routes/Settings' +import { SafeRenderer } from 'lib/markdown' export function ToastUpdate({ version, diff --git a/src/components/Toolbar/EqualAngle.tsx b/src/components/Toolbar/EqualAngle.tsx index a86be5009..c2ba55c46 100644 --- a/src/components/Toolbar/EqualAngle.tsx +++ b/src/components/Toolbar/EqualAngle.tsx @@ -1,18 +1,17 @@ import { toolTips } from 'lang/langHelpers' -import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' -import { TransformInfo } from 'lang/std/stdTypes' import { Selections } from 'lib/selections' -import { kclManager } from 'lib/singletons' -import { err } from 'lib/trap' - +import { Program, Expr, VariableDeclarator } from '../../lang/wasm' import { getNodeFromPath } from '../../lang/queryAst' +import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' import { isSketchVariablesLinked } from '../../lang/std/sketchConstraints' import { - PathToNodeMap, - getTransformInfos, transformSecondarySketchLinesTagFirst, + getTransformInfos, + PathToNodeMap, } from '../../lang/std/sketchcombos' -import { Expr, Program, VariableDeclarator } from '../../lang/wasm' +import { kclManager } from 'lib/singletons' +import { err } from 'lib/trap' +import { TransformInfo } from 'lang/std/stdTypes' export function equalAngleInfo({ selectionRanges, diff --git a/src/components/Toolbar/EqualLength.tsx b/src/components/Toolbar/EqualLength.tsx index 3acd0adb5..9d41df1f0 100644 --- a/src/components/Toolbar/EqualLength.tsx +++ b/src/components/Toolbar/EqualLength.tsx @@ -1,19 +1,17 @@ import { toolTips } from 'lang/langHelpers' -import { TransformInfo } from 'lang/std/stdTypes' import { Selections } from 'lib/selections' -import { kclManager } from 'lib/singletons' -import { err } from 'lib/trap' - -import { Node } from '@rust/kcl-lib/bindings/Node' - +import { Program, Expr, VariableDeclarator } from '../../lang/wasm' import { getNodeFromPath } from '../../lang/queryAst' import { isSketchVariablesLinked } from '../../lang/std/sketchConstraints' import { - PathToNodeMap, - getTransformInfos, transformSecondarySketchLinesTagFirst, + getTransformInfos, + PathToNodeMap, } from '../../lang/std/sketchcombos' -import { Expr, Program, VariableDeclarator } from '../../lang/wasm' +import { TransformInfo } from 'lang/std/stdTypes' +import { kclManager } from 'lib/singletons' +import { err } from 'lib/trap' +import { Node } from '@rust/kcl-lib/bindings/Node' export function setEqualLengthInfo({ selectionRanges, diff --git a/src/components/Toolbar/HorzVert.tsx b/src/components/Toolbar/HorzVert.tsx index 675c744b1..46593d009 100644 --- a/src/components/Toolbar/HorzVert.tsx +++ b/src/components/Toolbar/HorzVert.tsx @@ -1,18 +1,16 @@ import { toolTips } from 'lang/langHelpers' -import { TransformInfo } from 'lang/std/stdTypes' import { Selections } from 'lib/selections' -import { kclManager } from 'lib/singletons' -import { err } from 'lib/trap' - -import { Node } from '@rust/kcl-lib/bindings/Node' - +import { Program, Expr, VariableMap } from '../../lang/wasm' import { getNodeFromPath } from '../../lang/queryAst' import { PathToNodeMap, getTransformInfos, transformAstSketchLines, } from '../../lang/std/sketchcombos' -import { Expr, Program, VariableMap } from '../../lang/wasm' +import { TransformInfo } from 'lang/std/stdTypes' +import { kclManager } from 'lib/singletons' +import { err } from 'lib/trap' +import { Node } from '@rust/kcl-lib/bindings/Node' export function horzVertInfo( selectionRanges: Selections, diff --git a/src/components/Toolbar/Intersect.tsx b/src/components/Toolbar/Intersect.tsx index e6e35e859..762fd38cd 100644 --- a/src/components/Toolbar/Intersect.tsx +++ b/src/components/Toolbar/Intersect.tsx @@ -1,26 +1,24 @@ import { toolTips } from 'lang/langHelpers' -import { TransformInfo } from 'lang/std/stdTypes' +import { Program, Expr, VariableDeclarator } from '../../lang/wasm' import { Selections } from 'lib/selections' -import { kclManager } from 'lib/singletons' -import { err } from 'lib/trap' - -import { Node } from '@rust/kcl-lib/bindings/Node' - -import { createVariableDeclaration } from '../../lang/modifyAst' import { getNodeFromPath, isLinesParallelAndConstrained, } from '../../lang/queryAst' import { isSketchVariablesLinked } from '../../lang/std/sketchConstraints' import { - PathToNodeMap, - getTransformInfos, - isExprBinaryPart, transformSecondarySketchLinesTagFirst, + getTransformInfos, + PathToNodeMap, + isExprBinaryPart, } from '../../lang/std/sketchcombos' -import { Expr, Program, VariableDeclarator } from '../../lang/wasm' -import { removeDoubleNegatives } from '../AvailableVarsHelpers' +import { TransformInfo } from 'lang/std/stdTypes' import { GetInfoModal, createInfoModal } from '../SetHorVertDistanceModal' +import { createVariableDeclaration } from '../../lang/modifyAst' +import { removeDoubleNegatives } from '../AvailableVarsHelpers' +import { kclManager } from 'lib/singletons' +import { err } from 'lib/trap' +import { Node } from '@rust/kcl-lib/bindings/Node' const getModalInfo = createInfoModal(GetInfoModal) diff --git a/src/components/Toolbar/RemoveConstrainingValues.tsx b/src/components/Toolbar/RemoveConstrainingValues.tsx index 8ab522644..94fd626c2 100644 --- a/src/components/Toolbar/RemoveConstrainingValues.tsx +++ b/src/components/Toolbar/RemoveConstrainingValues.tsx @@ -1,19 +1,17 @@ import { toolTips } from 'lang/langHelpers' -import { codeRefFromRange } from 'lang/std/artifactGraph' -import { TransformInfo } from 'lang/std/stdTypes' import { Selection, Selections } from 'lib/selections' -import { kclManager } from 'lib/singletons' -import { err } from 'lib/trap' - -import { Node } from '@rust/kcl-lib/bindings/Node' - +import { PathToNode, Program, Expr, topLevelRange } from '../../lang/wasm' import { getNodeFromPath } from '../../lang/queryAst' import { PathToNodeMap, getRemoveConstraintsTransforms, transformAstSketchLines, } from '../../lang/std/sketchcombos' -import { Expr, PathToNode, Program, topLevelRange } from '../../lang/wasm' +import { TransformInfo } from 'lang/std/stdTypes' +import { kclManager } from 'lib/singletons' +import { err } from 'lib/trap' +import { Node } from '@rust/kcl-lib/bindings/Node' +import { codeRefFromRange } from 'lang/std/artifactGraph' export function removeConstrainingValuesInfo({ selectionRanges, diff --git a/src/components/Toolbar/SetAbsDistance.tsx b/src/components/Toolbar/SetAbsDistance.tsx index 68d481591..4efeb7fff 100644 --- a/src/components/Toolbar/SetAbsDistance.tsx +++ b/src/components/Toolbar/SetAbsDistance.tsx @@ -1,25 +1,23 @@ import { toolTips } from 'lang/langHelpers' -import { TransformInfo } from 'lang/std/stdTypes' +import { Program, Expr } from '../../lang/wasm' import { Selections } from 'lib/selections' -import { kclManager } from 'lib/singletons' -import { err } from 'lib/trap' - -import { Node } from '@rust/kcl-lib/bindings/Node' - -import { createName, createVariableDeclaration } from '../../lang/modifyAst' import { getNodeFromPath } from '../../lang/queryAst' import { - PathToNodeMap, getTransformInfos, - isExprBinaryPart, transformAstSketchLines, + PathToNodeMap, + isExprBinaryPart, } from '../../lang/std/sketchcombos' -import { Expr, Program } from '../../lang/wasm' -import { removeDoubleNegatives } from '../AvailableVarsHelpers' +import { TransformInfo } from 'lang/std/stdTypes' import { SetAngleLengthModal, createSetAngleLengthModal, } from '../SetAngleLengthModal' +import { createName, createVariableDeclaration } from '../../lang/modifyAst' +import { removeDoubleNegatives } from '../AvailableVarsHelpers' +import { kclManager } from 'lib/singletons' +import { err } from 'lib/trap' +import { Node } from '@rust/kcl-lib/bindings/Node' const getModalInfo = createSetAngleLengthModal(SetAngleLengthModal) @@ -41,8 +39,8 @@ export function absDistanceInfo({ constraint === 'xAbs' || constraint === 'yAbs' ? constraint : constraint === 'snapToYAxis' - ? 'xAbs' - : 'yAbs' + ? 'xAbs' + : 'yAbs' const _nodes = selectionRanges.graphSelections.map(({ codeRef }) => { const tmp = getNodeFromPath(kclManager.ast, codeRef.pathToNode, [ 'CallExpression', diff --git a/src/components/Toolbar/SetAngleBetween.tsx b/src/components/Toolbar/SetAngleBetween.tsx index 3e006771e..7bd192889 100644 --- a/src/components/Toolbar/SetAngleBetween.tsx +++ b/src/components/Toolbar/SetAngleBetween.tsx @@ -1,21 +1,20 @@ import { toolTips } from 'lang/langHelpers' -import { TransformInfo } from 'lang/std/stdTypes' +import { Program, Expr, VariableDeclarator } from '../../lang/wasm' import { Selections } from 'lib/selections' -import { kclManager } from 'lib/singletons' -import { err } from 'lib/trap' - -import { createVariableDeclaration } from '../../lang/modifyAst' import { getNodeFromPath } from '../../lang/queryAst' import { isSketchVariablesLinked } from '../../lang/std/sketchConstraints' import { - PathToNodeMap, - getTransformInfos, - isExprBinaryPart, transformSecondarySketchLinesTagFirst, + getTransformInfos, + PathToNodeMap, + isExprBinaryPart, } from '../../lang/std/sketchcombos' -import { Expr, Program, VariableDeclarator } from '../../lang/wasm' -import { removeDoubleNegatives } from '../AvailableVarsHelpers' +import { TransformInfo } from 'lang/std/stdTypes' import { GetInfoModal, createInfoModal } from '../SetHorVertDistanceModal' +import { createVariableDeclaration } from '../../lang/modifyAst' +import { removeDoubleNegatives } from '../AvailableVarsHelpers' +import { kclManager } from 'lib/singletons' +import { err } from 'lib/trap' const getModalInfo = createInfoModal(GetInfoModal) diff --git a/src/components/Toolbar/SetHorzVertDistance.tsx b/src/components/Toolbar/SetHorzVertDistance.tsx index 453862df4..7a85abb49 100644 --- a/src/components/Toolbar/SetHorzVertDistance.tsx +++ b/src/components/Toolbar/SetHorzVertDistance.tsx @@ -1,23 +1,21 @@ import { toolTips } from 'lang/langHelpers' -import { TransformInfo } from 'lang/std/stdTypes' -import { Selections } from 'lib/selections' -import { kclManager } from 'lib/singletons' -import { cleanErrs, err } from 'lib/trap' - -import { Node } from '@rust/kcl-lib/bindings/Node' - -import { createLiteral, createVariableDeclaration } from '../../lang/modifyAst' +import { Program, Expr, VariableDeclarator } from '../../lang/wasm' import { getNodeFromPath } from '../../lang/queryAst' import { isSketchVariablesLinked } from '../../lang/std/sketchConstraints' import { - PathToNodeMap, - getTransformInfos, - isExprBinaryPart, transformSecondarySketchLinesTagFirst, + getTransformInfos, + PathToNodeMap, + isExprBinaryPart, } from '../../lang/std/sketchcombos' -import { Expr, Program, VariableDeclarator } from '../../lang/wasm' -import { removeDoubleNegatives } from '../AvailableVarsHelpers' +import { TransformInfo } from 'lang/std/stdTypes' import { GetInfoModal, createInfoModal } from '../SetHorVertDistanceModal' +import { createLiteral, createVariableDeclaration } from '../../lang/modifyAst' +import { removeDoubleNegatives } from '../AvailableVarsHelpers' +import { kclManager } from 'lib/singletons' +import { Selections } from 'lib/selections' +import { cleanErrs, err } from 'lib/trap' +import { Node } from '@rust/kcl-lib/bindings/Node' const getModalInfo = createInfoModal(GetInfoModal) diff --git a/src/components/Toolbar/setAngleLength.tsx b/src/components/Toolbar/setAngleLength.tsx index 433b453bf..ac04f093c 100644 --- a/src/components/Toolbar/setAngleLength.tsx +++ b/src/components/Toolbar/setAngleLength.tsx @@ -1,16 +1,6 @@ import { toolTips } from 'lang/langHelpers' -import { TransformInfo } from 'lang/std/stdTypes' -import { KclCommandValue } from 'lib/commandTypes' +import { Program, Expr } from '../../lang/wasm' import { Selections } from 'lib/selections' -import { kclManager } from 'lib/singletons' -import { err } from 'lib/trap' - -import { - createBinaryExpressionWithUnary, - createLocalName, - createName, - createVariableDeclaration, -} from '../../lang/modifyAst' import { getNodeFromPath } from '../../lang/queryAst' import { PathToNodeMap, @@ -18,13 +8,22 @@ import { isExprBinaryPart, transformAstSketchLines, } from '../../lang/std/sketchcombos' -import { Expr, Program } from '../../lang/wasm' -import { normaliseAngle } from '../../lib/utils' -import { removeDoubleNegatives } from '../AvailableVarsHelpers' +import { TransformInfo } from 'lang/std/stdTypes' import { SetAngleLengthModal, createSetAngleLengthModal, } from '../SetAngleLengthModal' +import { + createBinaryExpressionWithUnary, + createLocalName, + createName, + createVariableDeclaration, +} from '../../lang/modifyAst' +import { removeDoubleNegatives } from '../AvailableVarsHelpers' +import { normaliseAngle } from '../../lib/utils' +import { kclManager } from 'lib/singletons' +import { err } from 'lib/trap' +import { KclCommandValue } from 'lib/commandTypes' const getModalInfo = createSetAngleLengthModal(SetAngleLengthModal) diff --git a/src/components/Tooltip.module.css b/src/components/Tooltip.module.css index 896f9adc7..033f2c7a5 100644 --- a/src/components/Tooltip.module.css +++ b/src/components/Tooltip.module.css @@ -20,9 +20,7 @@ /* The parts that will be transitioned */ opacity: 0; transform: translate(var(--_x, 0), var(--_y, 0)); - transition: - transform 0.15s ease-out, - opacity 0.11s ease-out; + transition: transform 0.15s ease-out, opacity 0.11s ease-out; } .tooltip { diff --git a/src/components/UpdaterRestartModal.test.tsx b/src/components/UpdaterRestartModal.test.tsx index b90b568fd..c177bbab8 100644 --- a/src/components/UpdaterRestartModal.test.tsx +++ b/src/components/UpdaterRestartModal.test.tsx @@ -1,6 +1,5 @@ import { fireEvent, render, screen } from '@testing-library/react' import { vi } from 'vitest' - import { UpdaterRestartModal } from './UpdaterRestartModal' describe('UpdaterRestartModal tests', () => { diff --git a/src/components/UpdaterRestartModal.tsx b/src/components/UpdaterRestartModal.tsx index bd770ae86..0be9f82f8 100644 --- a/src/components/UpdaterRestartModal.tsx +++ b/src/components/UpdaterRestartModal.tsx @@ -1,5 +1,4 @@ -import { InstanceProps, create } from 'react-modal-promise' - +import { create, InstanceProps } from 'react-modal-promise' import { ActionButton } from './ActionButton' type ModalResolve = { diff --git a/src/components/UserSidebarMenu.test.tsx b/src/components/UserSidebarMenu.test.tsx index 52cfade8e..afa3ebd94 100644 --- a/src/components/UserSidebarMenu.test.tsx +++ b/src/components/UserSidebarMenu.test.tsx @@ -1,13 +1,12 @@ -import { Models } from '@kittycad/lib' import { fireEvent, render, screen, waitFor } from '@testing-library/react' +import UserSidebarMenu from './UserSidebarMenu' import { Route, RouterProvider, createMemoryRouter, createRoutesFromElements, } from 'react-router-dom' - -import UserSidebarMenu from './UserSidebarMenu' +import { Models } from '@kittycad/lib' type User = Models['User_type'] diff --git a/src/components/UserSidebarMenu.tsx b/src/components/UserSidebarMenu.tsx index b150fe0eb..8f76a9f4f 100644 --- a/src/components/UserSidebarMenu.tsx +++ b/src/components/UserSidebarMenu.tsx @@ -1,16 +1,15 @@ import { Popover, Transition } from '@headlessui/react' +import { ActionButton, ActionButtonProps } from './ActionButton' +import { useLocation, useNavigate } from 'react-router-dom' +import { Fragment, useMemo, useState } from 'react' +import { PATHS } from 'lib/paths' import { Models } from '@kittycad/lib' import { useAbsoluteFilePath } from 'hooks/useAbsoluteFilePath' +import Tooltip from './Tooltip' import usePlatform from 'hooks/usePlatform' import { isDesktop } from 'lib/isDesktop' -import { PATHS } from 'lib/paths' -import { authActor } from 'machines/appMachine' -import { Fragment, useMemo, useState } from 'react' -import { useLocation, useNavigate } from 'react-router-dom' - -import { ActionButton, ActionButtonProps } from './ActionButton' import { CustomIcon } from './CustomIcon' -import Tooltip from './Tooltip' +import { authActor } from 'machines/appMachine' type User = Models['User_type'] diff --git a/src/components/ViewControlMenu.tsx b/src/components/ViewControlMenu.tsx index f3e6dacc3..4e9c8c5bd 100644 --- a/src/components/ViewControlMenu.tsx +++ b/src/components/ViewControlMenu.tsx @@ -1,10 +1,4 @@ -import { useModelingContext } from 'hooks/useModelingContext' -import { AxisNames, VIEW_NAMES_SEMANTIC } from 'lib/constants' -import { sceneInfra } from 'lib/singletons' import { reportRejection } from 'lib/trap' -import { useSettings } from 'machines/appMachine' -import { useMemo } from 'react' - import { ContextMenu, ContextMenuDivider, @@ -12,6 +6,11 @@ import { ContextMenuItemRefresh, ContextMenuProps, } from './ContextMenu' +import { AxisNames, VIEW_NAMES_SEMANTIC } from 'lib/constants' +import { useModelingContext } from 'hooks/useModelingContext' +import { useMemo } from 'react' +import { sceneInfra } from 'lib/singletons' +import { useSettings } from 'machines/appMachine' export function useViewControlMenuItems() { const { state: modelingState, send: modelingSend } = useModelingContext() diff --git a/src/components/WasmErrBanner.tsx b/src/components/WasmErrBanner.tsx index c7c300d8f..67bc3fdd3 100644 --- a/src/components/WasmErrBanner.tsx +++ b/src/components/WasmErrBanner.tsx @@ -1,8 +1,7 @@ import { Dialog } from '@headlessui/react' -import { useKclContext } from 'lang/KclProvider' import { useState } from 'react' - import { ActionButton } from './ActionButton' +import { useKclContext } from 'lang/KclProvider' export function WasmErrBanner() { const [isBannerDismissed, setBannerDismissed] = useState(false) diff --git a/src/editor/highlightextension.ts b/src/editor/highlightextension.ts index c6b6220e9..90df5deb5 100644 --- a/src/editor/highlightextension.ts +++ b/src/editor/highlightextension.ts @@ -1,5 +1,5 @@ -import { Annotation, StateEffect, StateField } from '@codemirror/state' -import { Decoration, EditorView } from '@codemirror/view' +import { StateField, StateEffect, Annotation } from '@codemirror/state' +import { EditorView, Decoration } from '@codemirror/view' export { EditorView } diff --git a/src/editor/manager.test.ts b/src/editor/manager.test.ts index c47370db9..d214ba5ec 100644 --- a/src/editor/manager.test.ts +++ b/src/editor/manager.test.ts @@ -1,5 +1,5 @@ -import { Diagnostic } from '@codemirror/lint' import { editorManager } from 'lib/singletons' +import { Diagnostic } from '@codemirror/lint' describe('EditorManager Class', () => { describe('makeUniqueDiagnostics', () => { diff --git a/src/editor/manager.ts b/src/editor/manager.ts index 7b6cf465f..8b97d97cf 100644 --- a/src/editor/manager.ts +++ b/src/editor/manager.ts @@ -1,20 +1,19 @@ -import { redo, undo } from '@codemirror/commands' +import { EditorView, ViewUpdate } from '@codemirror/view' import { syntaxTree } from '@codemirror/language' +import { EditorSelection, Annotation, Transaction } from '@codemirror/state' +import { engineCommandManager, kclManager } from 'lib/singletons' +import { modelingMachine, ModelingMachineEvent } from 'machines/modelingMachine' +import { Selections, Selection, processCodeMirrorRanges } from 'lib/selections' +import { undo, redo } from '@codemirror/commands' +import { addLineHighlight, addLineHighlightEvent } from './highlightextension' import { Diagnostic, forEachDiagnostic, setDiagnosticsEffect, } from '@codemirror/lint' -import { Annotation, EditorSelection, Transaction } from '@codemirror/state' -import { EditorView, ViewUpdate } from '@codemirror/view' -import { markOnce } from 'lib/performance' -import { Selection, Selections, processCodeMirrorRanges } from 'lib/selections' -import { engineCommandManager, kclManager } from 'lib/singletons' -import { kclEditorActor } from 'machines/kclEditorMachine' -import { ModelingMachineEvent, modelingMachine } from 'machines/modelingMachine' import { StateFrom } from 'xstate' - -import { addLineHighlight, addLineHighlightEvent } from './highlightextension' +import { markOnce } from 'lib/performance' +import { kclEditorActor } from 'machines/kclEditorMachine' declare global { interface Window { diff --git a/src/editor/plugins/lsp/copilot/index.ts b/src/editor/plugins/lsp/copilot/index.ts index 396520475..85982daaa 100644 --- a/src/editor/plugins/lsp/copilot/index.ts +++ b/src/editor/plugins/lsp/copilot/index.ts @@ -1,17 +1,7 @@ /// Thanks to the Cursor folks for their heavy lifting here. /// This has been heavily modified from their original implementation but we are /// still grateful. -import { completionStatus } from '@codemirror/autocomplete' import { indentUnit } from '@codemirror/language' -import { - Annotation, - EditorState, - Extension, - Prec, - StateEffect, - StateField, - Transaction, -} from '@codemirror/state' import { Decoration, DecorationSet, @@ -23,21 +13,30 @@ import { keymap, } from '@codemirror/view' import { - LanguageServerClient, - LanguageServerOptions, - docPathFacet, - languageId, + Annotation, + EditorState, + Extension, + Prec, + StateEffect, + StateField, + Transaction, +} from '@codemirror/state' +import { completionStatus } from '@codemirror/autocomplete' +import { offsetToPos, posToOffset, + LanguageServerOptions, + LanguageServerClient, + docPathFacet, + languageId, } from '@kittycad/codemirror-lsp-client' +import { deferExecution } from 'lib/utils' +import { CopilotLspCompletionParams } from '@rust/kcl-lib/bindings/CopilotLspCompletionParams' +import { CopilotCompletionResponse } from '@rust/kcl-lib/bindings/CopilotCompletionResponse' +import { CopilotAcceptCompletionParams } from '@rust/kcl-lib/bindings/CopilotAcceptCompletionParams' +import { CopilotRejectCompletionParams } from '@rust/kcl-lib/bindings/CopilotRejectCompletionParams' import { editorManager } from 'lib/singletons' import { reportRejection } from 'lib/trap' -import { deferExecution } from 'lib/utils' - -import { CopilotAcceptCompletionParams } from '@rust/kcl-lib/bindings/CopilotAcceptCompletionParams' -import { CopilotCompletionResponse } from '@rust/kcl-lib/bindings/CopilotCompletionResponse' -import { CopilotLspCompletionParams } from '@rust/kcl-lib/bindings/CopilotLspCompletionParams' -import { CopilotRejectCompletionParams } from '@rust/kcl-lib/bindings/CopilotRejectCompletionParams' const copilotPluginAnnotation = Annotation.define() export const copilotPluginEvent = copilotPluginAnnotation.of(true) @@ -206,10 +205,7 @@ export class CompletionRequester implements PluginValue { // document. private sendScheduledInput: number | null = null - constructor( - readonly view: EditorView, - client: LanguageServerClient - ) { + constructor(readonly view: EditorView, client: LanguageServerClient) { this.client = client } diff --git a/src/editor/plugins/lsp/kcl/colors.ts b/src/editor/plugins/lsp/kcl/colors.ts index 727e3aba5..9fc11b129 100644 --- a/src/editor/plugins/lsp/kcl/colors.ts +++ b/src/editor/plugins/lsp/kcl/colors.ts @@ -1,14 +1,14 @@ -import { language, syntaxTree } from '@codemirror/language' -import { Extension, Range, Text } from '@codemirror/state' import { - Decoration, - DecorationSet, EditorView, - ViewPlugin, - ViewUpdate, WidgetType, + ViewUpdate, + ViewPlugin, + DecorationSet, + Decoration, } from '@codemirror/view' +import { Range, Extension, Text } from '@codemirror/state' import { NodeProp, Tree } from '@lezer/common' +import { language, syntaxTree } from '@codemirror/language' import { isArray } from 'lib/utils' interface PickerState { diff --git a/src/editor/plugins/lsp/kcl/index.ts b/src/editor/plugins/lsp/kcl/index.ts index 2ee6e3654..2c1543a2b 100644 --- a/src/editor/plugins/lsp/kcl/index.ts +++ b/src/editor/plugins/lsp/kcl/index.ts @@ -1,22 +1,20 @@ import { Extension } from '@codemirror/state' -import { PluginValue, ViewPlugin, ViewUpdate } from '@codemirror/view' +import { ViewPlugin, PluginValue, ViewUpdate } from '@codemirror/view' import { - LanguageServerClient, LanguageServerOptions, - lspFormatCodeEvent, + LanguageServerClient, lspPlugin, + lspFormatCodeEvent, } from '@kittycad/codemirror-lsp-client' -import { updateOutsideEditorEvent } from 'editor/manager' -import { codeManagerUpdateEvent } from 'lang/codeManager' -import { codeManager, editorManager, kclManager } from 'lib/singletons' import { deferExecution } from 'lib/utils' - -import { UpdateCanExecuteParams } from '@rust/kcl-lib/bindings/UpdateCanExecuteParams' -import { UpdateCanExecuteResponse } from '@rust/kcl-lib/bindings/UpdateCanExecuteResponse' +import { codeManager, editorManager, kclManager } from 'lib/singletons' import { UpdateUnitsParams } from '@rust/kcl-lib/bindings/UpdateUnitsParams' +import { UpdateCanExecuteParams } from '@rust/kcl-lib/bindings/UpdateCanExecuteParams' import { UpdateUnitsResponse } from '@rust/kcl-lib/bindings/UpdateUnitsResponse' - +import { UpdateCanExecuteResponse } from '@rust/kcl-lib/bindings/UpdateCanExecuteResponse' +import { codeManagerUpdateEvent } from 'lang/codeManager' import { copilotPluginEvent } from '../copilot' +import { updateOutsideEditorEvent } from 'editor/manager' const changesDelay = 600 diff --git a/src/editor/plugins/lsp/kcl/language.ts b/src/editor/plugins/lsp/kcl/language.ts index e633643df..d1884b498 100644 --- a/src/editor/plugins/lsp/kcl/language.ts +++ b/src/editor/plugins/lsp/kcl/language.ts @@ -1,14 +1,14 @@ // Code mirror language implementation for kcl. + import { LanguageSupport } from '@codemirror/language' -import { KclLanguage } from '@kittycad/codemirror-lang-kcl' import { LanguageServerClient, LanguageServerPlugin, } from '@kittycad/codemirror-lsp-client' -import type * as LSP from 'vscode-languageserver-protocol' - import { kclPlugin } from '.' +import type * as LSP from 'vscode-languageserver-protocol' import { colorPicker } from './colors' +import { KclLanguage } from '@kittycad/codemirror-lang-kcl' export interface LanguageOptions { workspaceFolders: LSP.WorkspaceFolder[] diff --git a/src/editor/plugins/lsp/worker.ts b/src/editor/plugins/lsp/worker.ts index 5b5aac537..05cdfd2cc 100644 --- a/src/editor/plugins/lsp/worker.ts +++ b/src/editor/plugins/lsp/worker.ts @@ -4,21 +4,20 @@ import { IntoServer, LspWorkerEventType, } from '@kittycad/codemirror-lsp-client' -import { - CopilotWorkerOptions, - KclWorkerOptions, - LspWorker, - LspWorkerEvent, -} from 'editor/plugins/lsp/types' -import * as jsrpc from 'json-rpc-2.0' import { fileSystemManager } from 'lang/std/fileSystemManager' -import { err, reportRejection } from 'lib/trap' - import init, { LspServerConfig, lsp_run_copilot, lsp_run_kcl, } from '@rust/kcl-wasm-lib/pkg/kcl_wasm_lib' +import * as jsrpc from 'json-rpc-2.0' +import { + LspWorkerEvent, + LspWorker, + KclWorkerOptions, + CopilotWorkerOptions, +} from 'editor/plugins/lsp/types' +import { err, reportRejection } from 'lib/trap' const intoServer: IntoServer = new IntoServer() const fromServer: FromServer | Error = FromServer.create() diff --git a/src/hooks/useAbsoluteFilePath.ts b/src/hooks/useAbsoluteFilePath.ts index fd4a56eee..4e9c9dc37 100644 --- a/src/hooks/useAbsoluteFilePath.ts +++ b/src/hooks/useAbsoluteFilePath.ts @@ -1,5 +1,5 @@ -import { BROWSER_PATH, PATHS } from 'lib/paths' import { type IndexLoaderData } from 'lib/types' +import { BROWSER_PATH, PATHS } from 'lib/paths' import { useRouteLoaderData } from 'react-router-dom' export function useAbsoluteFilePath() { diff --git a/src/hooks/useCreateFileLinkQueryWatcher.ts b/src/hooks/useCreateFileLinkQueryWatcher.ts index 056c96224..04237aadf 100644 --- a/src/hooks/useCreateFileLinkQueryWatcher.ts +++ b/src/hooks/useCreateFileLinkQueryWatcher.ts @@ -1,11 +1,11 @@ import { base64ToString } from 'lib/base64' -import { ProjectsCommandSchema } from 'lib/commandBarConfigs/projectsCommandConfig' import { CREATE_FILE_URL_PARAM, DEFAULT_FILE_NAME } from 'lib/constants' -import { isDesktop } from 'lib/isDesktop' -import { FileLinkParams } from 'lib/links' -import { useSettings } from 'machines/appMachine' 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' // 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 +45,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', } diff --git a/src/hooks/useDocumentHasFocus.ts b/src/hooks/useDocumentHasFocus.ts index f97045bad..fab729ab6 100644 --- a/src/hooks/useDocumentHasFocus.ts +++ b/src/hooks/useDocumentHasFocus.ts @@ -1,5 +1,5 @@ // Based on https://learnersbucket.com/examples/interview/usehasfocus-hook-in-react/ -import { useEffect, useState } from 'react' +import { useState, useEffect } from 'react' export const useDocumentHasFocus = () => { // get the initial state diff --git a/src/hooks/useEngineConnectionSubscriptions.ts b/src/hooks/useEngineConnectionSubscriptions.ts index 84ff2844a..ff7c94108 100644 --- a/src/hooks/useEngineConnectionSubscriptions.ts +++ b/src/hooks/useEngineConnectionSubscriptions.ts @@ -1,29 +1,28 @@ -import { getFaceDetails } from 'clientSideScene/sceneEntities' -import { getNodeFromPath } from 'lang/queryAst' -import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' -import { - SegmentArtifact, - getArtifactOfTypes, - getCapCodeRef, - getCodeRefsByArtifactId, - getSweepFromSuspectedSweepSurface, - getWallCodeRef, -} from 'lang/std/artifactGraph' -import { CallExpression, CallExpressionKw, defaultSourceRange } from 'lang/wasm' -import { DefaultPlaneStr } from 'lib/planes' -import { getEventForSelectWithPoint } from 'lib/selections' +import { useEffect, useRef } from 'react' import { editorManager, engineCommandManager, kclManager, sceneInfra, } from 'lib/singletons' -import { rustContext } from 'lib/singletons' -import { err, reportRejection } from 'lib/trap' -import { EdgeCutInfo, ExtrudeFacePlane } from 'machines/modelingMachine' -import { useEffect, useRef } from 'react' - 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' export function useEngineConnectionSubscriptions() { const { send, context, state } = useModelingContext() @@ -166,7 +165,7 @@ export function useEngineConnectionSubscriptions() { ].map((num) => num / sceneInfra._baseUnitMultiplier) as [ number, number, - number, + number ], planeId: planeOrFaceId, pathToNode: artifact.codeRef.pathToNode, @@ -195,8 +194,8 @@ 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) if (!faceInfo?.origin || !faceInfo?.z_axis || !faceInfo?.y_axis) @@ -276,11 +275,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( diff --git a/src/hooks/useFileSystemWatcher.tsx b/src/hooks/useFileSystemWatcher.tsx index c5e0099e9..210b31e11 100644 --- a/src/hooks/useFileSystemWatcher.tsx +++ b/src/hooks/useFileSystemWatcher.tsx @@ -1,6 +1,6 @@ import { isDesktop } from 'lib/isDesktop' import { reportRejection } from 'lib/trap' -import { useEffect, useRef, useState } from 'react' +import { useEffect, useState, useRef } from 'react' type Path = string diff --git a/src/hooks/useMenu.ts b/src/hooks/useMenu.ts index 9776d61ce..f99e2d8b9 100644 --- a/src/hooks/useMenu.ts +++ b/src/hooks/useMenu.ts @@ -1,8 +1,6 @@ -import { isDesktop } from 'lib/isDesktop' import { useEffect } from 'react' - import type { WebContentSendPayload } from '../menu/channels' - +import { isDesktop } from 'lib/isDesktop' export function useMenuListener( callback: (data: WebContentSendPayload) => void ) { diff --git a/src/hooks/useNetworkContext.tsx b/src/hooks/useNetworkContext.tsx index d6dcb109c..16da16a11 100644 --- a/src/hooks/useNetworkContext.tsx +++ b/src/hooks/useNetworkContext.tsx @@ -1,12 +1,11 @@ import { createContext, useContext } from 'react' - import { ConnectingTypeGroup, - EngineConnectionState, EngineConnectionStateType, + EngineConnectionState, initialConnectingTypeGroupState, } from '../lang/std/engineConnection' -import { NetworkHealthState, NetworkStatus } from './useNetworkStatus' +import { NetworkStatus, NetworkHealthState } from './useNetworkStatus' export const NetworkContext = createContext({ immediateState: { diff --git a/src/hooks/useNetworkStatus.tsx b/src/hooks/useNetworkStatus.tsx index 2606d29d9..30c4ccf2c 100644 --- a/src/hooks/useNetworkStatus.tsx +++ b/src/hooks/useNetworkStatus.tsx @@ -1,13 +1,12 @@ import { useEffect, useState } from 'react' - import { ConnectingType, ConnectingTypeGroup, DisconnectingType, EngineCommandManagerEvents, EngineConnectionEvents, - EngineConnectionState, EngineConnectionStateType, + EngineConnectionState, ErrorType, initialConnectingTypeGroupState, } from '../lang/std/engineConnection' @@ -70,10 +69,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]) diff --git a/src/hooks/useProjectsLoader.tsx b/src/hooks/useProjectsLoader.tsx index b3844b61e..8df3bab8a 100644 --- a/src/hooks/useProjectsLoader.tsx +++ b/src/hooks/useProjectsLoader.tsx @@ -1,9 +1,9 @@ -import { ensureProjectDirectoryExists, listProjects } from 'lib/desktop' -import { isDesktop } from 'lib/isDesktop' -import { Project } from 'lib/project' -import { loadAndValidateSettings } from 'lib/settings/settingsUtils' import { trap } from 'lib/trap' -import { useEffect, useState } from 'react' +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' // Gotcha: This should be ported to the ProjectMachine and keep track of // projectDirs and projectPaths in the context when it internally calls listProjects diff --git a/src/hooks/useSetupEngineManager.ts b/src/hooks/useSetupEngineManager.ts index 4ddebca06..5092bc8bf 100644 --- a/src/hooks/useSetupEngineManager.ts +++ b/src/hooks/useSetupEngineManager.ts @@ -1,16 +1,15 @@ -import { useAppState, useAppStream } from 'AppState' -import { useNetworkContext } from 'hooks/useNetworkContext' -import { - DisconnectingType, - EngineConnectionStateType, -} from 'lang/std/engineConnection' -import { SettingsViaQueryString } from 'lib/settings/settingsTypes' +import { useLayoutEffect, useEffect, useRef } from 'react' import { engineCommandManager } from 'lib/singletons' -import { Themes } from 'lib/theme' import { deferExecution } from 'lib/utils' -import { useEffect, useLayoutEffect, useRef } from 'react' - +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 { + EngineConnectionStateType, + DisconnectingType, +} from 'lang/std/engineConnection' export function useSetupEngineManager( streamRef: React.RefObject, diff --git a/src/hooks/useStateMachineCommands.ts b/src/hooks/useStateMachineCommands.ts index b1926661e..923d8ae79 100644 --- a/src/hooks/useStateMachineCommands.ts +++ b/src/hooks/useStateMachineCommands.ts @@ -1,21 +1,20 @@ -import { useAppState } from 'AppState' -import { useNetworkContext } from 'hooks/useNetworkContext' -import { NetworkHealthState } from 'hooks/useNetworkStatus' -import { useKclContext } from 'lang/KclProvider' +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 { Command, StateMachineCommandSetConfig, StateMachineCommandSetSchema, } from 'lib/commandTypes' -import { authMachine } from 'machines/authMachine' +import { useKclContext } from 'lang/KclProvider' +import { useNetworkContext } from 'hooks/useNetworkContext' +import { NetworkHealthState } from 'hooks/useNetworkStatus' +import { useAppState } from 'AppState' import { commandBarActor } from 'machines/commandBarMachine' -import { modelingMachine } from 'machines/modelingMachine' -import { projectsMachine } from 'machines/projectsMachine' -import { settingsMachine } from 'machines/settingsMachine' -import { useEffect } from 'react' -import { Actor, AnyStateMachine, EventFrom, StateFrom } from 'xstate' - -import { createMachineCommand } from '../lib/createMachineCommand' // This might not be necessary, AnyStateMachine from xstate is working export type AllMachines = @@ -26,7 +25,7 @@ export type AllMachines = interface UseStateMachineCommandsArgs< T extends AllMachines, - S extends StateMachineCommandSetSchema, + S extends StateMachineCommandSetSchema > { machineId: T['id'] state: StateFrom @@ -39,7 +38,7 @@ interface UseStateMachineCommandsArgs< export default function useStateMachineCommands< T extends AnyStateMachine, - S extends StateMachineCommandSetSchema, + S extends StateMachineCommandSetSchema >({ machineId, state, diff --git a/src/hooks/useToolbarGuards.ts b/src/hooks/useToolbarGuards.ts index c129e6b8e..0319a0ef1 100644 --- a/src/hooks/useToolbarGuards.ts +++ b/src/hooks/useToolbarGuards.ts @@ -2,16 +2,15 @@ import { SetVarNameModal, createSetVarNameModal, } from 'components/SetVarNameModal' -import { useKclContext } from 'lang/KclProvider' +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 { PathToNode, SourceRange, recast } from 'lang/wasm' -import { codeManager, editorManager, kclManager } from 'lib/singletons' -import { err, reportRejection, trap } from 'lib/trap' -import { toSync } from 'lib/utils' 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' export const getVarNameModal = createSetVarNameModal(SetVarNameModal) diff --git a/src/index.css b/src/index.css index fb216014c..90e9e9a84 100644 --- a/src/index.css +++ b/src/index.css @@ -131,13 +131,13 @@ input { } .mono { - font-family: - source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; + font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', + monospace; } code { - font-family: - source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; + font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', + monospace; } /* diff --git a/src/index.tsx b/src/index.tsx index dfdff8740..b7abe9b9f 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,20 +1,19 @@ -import { AppStreamProvider } from 'AppState' -import { ToastUpdate } from 'components/ToastUpdate' -import { initPromise } from 'lang/wasm' -import { AUTO_UPDATER_TOAST_ID } from 'lib/constants' -import { initializeWindowExceptionHandler } from 'lib/exceptions' -import { isDesktop } from 'lib/isDesktop' -import { markOnce } from 'lib/performance' -import { reportRejection } from 'lib/trap' -import { appActor } from 'machines/appMachine' 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' - -import { Router } from './Router' import './index.css' import reportWebVitals from './reportWebVitals' +import toast, { Toaster } from 'react-hot-toast' +import { Router } from './Router' +import { HotkeysProvider } from 'react-hotkeys-hook' +import ModalContainer from 'react-modal-promise' +import { isDesktop } from 'lib/isDesktop' +import { AppStreamProvider } from 'AppState' +import { ToastUpdate } from 'components/ToastUpdate' +import { markOnce } from 'lib/performance' +import { AUTO_UPDATER_TOAST_ID } from 'lib/constants' +import { initializeWindowExceptionHandler } from 'lib/exceptions' +import { initPromise } from 'lang/wasm' +import { appActor } from 'machines/appMachine' +import { reportRejection } from 'lib/trap' markOnce('code/willAuth') initializeWindowExceptionHandler() diff --git a/src/lang/KclProvider.tsx b/src/lang/KclProvider.tsx index 5673a6236..61dc05f39 100644 --- a/src/lang/KclProvider.tsx +++ b/src/lang/KclProvider.tsx @@ -1,11 +1,10 @@ -import { Diagnostic } from '@codemirror/lint' -import { PATHS } from 'lib/paths' -import { codeManager, kclManager } from 'lib/singletons' -import { type IndexLoaderData } from 'lib/types' import { createContext, useContext, useEffect, useState } from 'react' +import { type IndexLoaderData } from 'lib/types' import { useRouteLoaderData } from 'react-router-dom' - +import { codeManager, kclManager } from 'lib/singletons' +import { Diagnostic } from '@codemirror/lint' import { KCLError } from './errors' +import { PATHS } from 'lib/paths' const KclContext = createContext({ code: codeManager?.code || '', diff --git a/src/lang/KclSingleton.ts b/src/lang/KclSingleton.ts index 2247bc5d8..10d518866 100644 --- a/src/lang/KclSingleton.ts +++ b/src/lang/KclSingleton.ts @@ -1,50 +1,49 @@ -import { Diagnostic } from '@codemirror/lint' -import { - EntityType_type, - ModelingCmdReq_type, -} from '@kittycad/lib/dist/types/src/models' import { executeAst, executeAstMock, lintAst } from 'lang/langHelpers' -import { - ArtifactGraph, - ExecState, - KclValue, - PathToNode, - Program, - SourceRange, - VariableMap, - emptyExecState, - getKclVersion, - initPromise, - jsAppSettings, - parse, - recast, - topLevelRange, -} from 'lang/wasm' -import { buildArtifactIndex } from 'lib/artifactIndex' -import { ArtifactIndex } from 'lib/artifactIndex' -import { EXECUTE_AST_INTERRUPT_ERROR_MESSAGE } from 'lib/constants' -import { markOnce } from 'lib/performance' -import { Selections, handleSelectionBatch } from 'lib/selections' -import { KclSettingsAnnotation } from 'lib/settings/settingsTypes' -import { - codeManager, - editorManager, - rustContext, - sceneInfra, -} from 'lib/singletons' -import { err, reportRejection } from 'lib/trap' -import { deferExecution, isOverlap, uuidv4 } from 'lib/utils' - -import { Node } from '@rust/kcl-lib/bindings/Node' -import { Operation } from '@rust/kcl-lib/bindings/Operation' - +import { handleSelectionBatch, Selections } from 'lib/selections' import { KCLError, compilationErrorsToDiagnostics, kclErrorsToDiagnostics, } from './errors' -import { getNodeFromPath, getSettingsAnnotation } from './queryAst' +import { uuidv4, isOverlap, deferExecution } from 'lib/utils' import { EngineCommandManager } from './std/engineConnection' +import { err, reportRejection } from 'lib/trap' +import { EXECUTE_AST_INTERRUPT_ERROR_MESSAGE } from 'lib/constants' +import { buildArtifactIndex } from 'lib/artifactIndex' +import { ArtifactIndex } from 'lib/artifactIndex' + +import { + emptyExecState, + ExecState, + getKclVersion, + initPromise, + jsAppSettings, + KclValue, + parse, + PathToNode, + Program, + recast, + SourceRange, + topLevelRange, + VariableMap, + ArtifactGraph, +} from 'lang/wasm' +import { getNodeFromPath, getSettingsAnnotation } from './queryAst' +import { + codeManager, + editorManager, + sceneInfra, + rustContext, +} from 'lib/singletons' +import { Diagnostic } from '@codemirror/lint' +import { markOnce } from 'lib/performance' +import { Node } from '@rust/kcl-lib/bindings/Node' +import { + EntityType_type, + ModelingCmdReq_type, +} from '@kittycad/lib/dist/types/src/models' +import { Operation } from '@rust/kcl-lib/bindings/Operation' +import { KclSettingsAnnotation } from 'lib/settings/settingsTypes' interface ExecuteArgs { ast?: Node diff --git a/src/lang/artifact.test.ts b/src/lang/artifact.test.ts index 98e2fbde9..3ac0a67af 100644 --- a/src/lang/artifact.test.ts +++ b/src/lang/artifact.test.ts @@ -1,5 +1,5 @@ -import { enginelessExecutor } from '../lib/testHelpers' import { assertParse, initPromise } from './wasm' +import { enginelessExecutor } from '../lib/testHelpers' beforeAll(async () => { await initPromise diff --git a/src/lang/codeManager.ts b/src/lang/codeManager.ts index 2ab254a8f..96ea4fa2c 100644 --- a/src/lang/codeManager.ts +++ b/src/lang/codeManager.ts @@ -1,16 +1,16 @@ // A little class for updating the code state when we need to and explicitly // NOT updating the code state when we don't need to. // This prevents re-renders of the codemirror editor, when typing. -import { history } from '@codemirror/commands' -import { Annotation, Transaction } from '@codemirror/state' -import { Compartment } from '@codemirror/state' -import { EditorView, KeyBinding } from '@codemirror/view' -import { Program, parse, recast } from 'lang/wasm' import { bracket } from 'lib/exampleKcl' import { isDesktop } from 'lib/isDesktop' -import { editorManager } from 'lib/singletons' -import { err, reportRejection } from 'lib/trap' import toast from 'react-hot-toast' +import { editorManager } from 'lib/singletons' +import { Annotation, Transaction } from '@codemirror/state' +import { EditorView, KeyBinding } from '@codemirror/view' +import { recast, Program, parse } from 'lang/wasm' +import { err, reportRejection } from 'lib/trap' +import { Compartment } from '@codemirror/state' +import { history } from '@codemirror/commands' const PERSIST_CODE_KEY = 'persistCode' diff --git a/src/lang/errors.test.ts b/src/lang/errors.test.ts index c0386a3f6..f115eb0da 100644 --- a/src/lang/errors.test.ts +++ b/src/lang/errors.test.ts @@ -1,7 +1,6 @@ +import { kclErrorsToDiagnostics, KCLError } from './errors' import { defaultArtifactGraph, topLevelRange } from 'lang/wasm' -import { KCLError, kclErrorsToDiagnostics } from './errors' - describe('test kclErrToDiagnostic', () => { it('converts KCL errors to CodeMirror diagnostics', () => { const errors: KCLError[] = [ diff --git a/src/lang/errors.ts b/src/lang/errors.ts index 2ebdd9f09..efb35ca67 100644 --- a/src/lang/errors.ts +++ b/src/lang/errors.ts @@ -1,21 +1,20 @@ +import { KclError as RustKclError } from '@rust/kcl-lib/bindings/KclError' +import { CompilationError } from '@rust/kcl-lib/bindings/CompilationError' import { Diagnostic as CodeMirrorDiagnostic } from '@codemirror/lint' -import { Text } from '@codemirror/state' import { posToOffset } from '@kittycad/codemirror-lsp-client' +import { Diagnostic as LspDiagnostic } from 'vscode-languageserver-protocol' +import { Text } from '@codemirror/state' import { EditorView } from 'codemirror' import { ArtifactCommand, ArtifactGraph, - SourceRange, defaultArtifactGraph, isTopLevelModule, + SourceRange, } from 'lang/wasm' -import { Diagnostic as LspDiagnostic } from 'vscode-languageserver-protocol' - -import { CompilationError } from '@rust/kcl-lib/bindings/CompilationError' -import { DefaultPlanes } from '@rust/kcl-lib/bindings/DefaultPlanes' -import { KclError as RustKclError } from '@rust/kcl-lib/bindings/KclError' -import { ModulePath } from '@rust/kcl-lib/bindings/ModulePath' import { Operation } from '@rust/kcl-lib/bindings/Operation' +import { ModulePath } from '@rust/kcl-lib/bindings/ModulePath' +import { DefaultPlanes } from '@rust/kcl-lib/bindings/DefaultPlanes' type ExtractKind = T extends { kind: infer K } ? K : never export class KCLError extends Error { diff --git a/src/lang/executor.test.ts b/src/lang/executor.test.ts index e6a9b7988..1ca8e7c8c 100644 --- a/src/lang/executor.test.ts +++ b/src/lang/executor.test.ts @@ -1,15 +1,15 @@ import fs from 'node:fs' -import { enginelessExecutor } from '../lib/testHelpers' -import { KCLError } from './errors' import { - Sketch, assertParse, - defaultArtifactGraph, + Sketch, initPromise, sketchFromKclValue, + defaultArtifactGraph, topLevelRange, } from './wasm' +import { enginelessExecutor } from '../lib/testHelpers' +import { KCLError } from './errors' beforeAll(async () => { await initPromise diff --git a/src/lang/getNodePathFromSourceRange.test.ts b/src/lang/getNodePathFromSourceRange.test.ts index d52a1dd73..acec223af 100644 --- a/src/lang/getNodePathFromSourceRange.test.ts +++ b/src/lang/getNodePathFromSourceRange.test.ts @@ -1,11 +1,9 @@ +import { getNodeFromPath, LABELED_ARG_FIELD, ARG_INDEX_FIELD } from './queryAst' import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' +import { assertParse, initPromise, Parameter, topLevelRange } from './wasm' import { err } from 'lib/trap' - import { Name } from '@rust/kcl-lib/bindings/Name' -import { ARG_INDEX_FIELD, LABELED_ARG_FIELD, getNodeFromPath } from './queryAst' -import { Parameter, assertParse, initPromise, topLevelRange } from './wasm' - beforeAll(async () => { await initPromise }) diff --git a/src/lang/kclSamples.test.ts b/src/lang/kclSamples.test.ts index 653f4d978..6bb9720b4 100644 --- a/src/lang/kclSamples.test.ts +++ b/src/lang/kclSamples.test.ts @@ -1,8 +1,8 @@ -import fs from 'node:fs/promises' -import path from 'node:path' - -import { enginelessExecutor } from '../lib/testHelpers' import { assertParse, initPromise } from './wasm' +import { enginelessExecutor } from '../lib/testHelpers' + +import path from 'node:path' +import fs from 'node:fs/promises' // The purpose of these tests is to act as a first line of defense // if something gets real screwy with our KCL ecosystem. diff --git a/src/lang/langHelpers.ts b/src/lang/langHelpers.ts index 049e86b8c..a8fd7bd1e 100644 --- a/src/lang/langHelpers.ts +++ b/src/lang/langHelpers.ts @@ -1,16 +1,15 @@ -import { Diagnostic } from '@codemirror/lint' -import { KCLError } from 'lang/errors' import { - ExecState, Program, - emptyExecState, - jsAppSettings, kclLint, + emptyExecState, + ExecState, + jsAppSettings, } from 'lang/wasm' -import { EXECUTE_AST_INTERRUPT_ERROR_STRING } from 'lib/constants' -import RustContext from 'lib/rustContext' - +import { KCLError } from 'lang/errors' +import { Diagnostic } from '@codemirror/lint' import { Node } from '@rust/kcl-lib/bindings/Node' +import RustContext from 'lib/rustContext' +import { EXECUTE_AST_INTERRUPT_ERROR_STRING } from 'lib/constants' export type ToolTip = | 'lineTo' diff --git a/src/lang/modelingWorkflows.ts b/src/lang/modelingWorkflows.ts index 171096d12..d77bcf4b3 100644 --- a/src/lang/modelingWorkflows.ts +++ b/src/lang/modelingWorkflows.ts @@ -5,18 +5,18 @@ * coordinate between different subsystems in the modeling app: * AST, code editor, file system and 3D engine. */ -import EditorManager from 'editor/manager' + +import { Node } from '@rust/kcl-lib/bindings/Node' import { KclManager } from 'lang/KclSingleton' -import CodeManager from 'lang/codeManager' -import { PathToNode, Program, SourceRange } from 'lang/wasm' import { ExecutionType } from 'lib/constants' import { EXECUTION_TYPE_MOCK, EXECUTION_TYPE_NONE, EXECUTION_TYPE_REAL, } from 'lib/constants' - -import { Node } from '@rust/kcl-lib/bindings/Node' +import { PathToNode, Program, SourceRange } from 'lang/wasm' +import EditorManager from 'editor/manager' +import CodeManager from 'lang/codeManager' /** * Updates the complete modeling state: diff --git a/src/lang/modifyAst.test.ts b/src/lang/modifyAst.test.ts index 5a3a65e23..f647640fb 100644 --- a/src/lang/modifyAst.test.ts +++ b/src/lang/modifyAst.test.ts @@ -1,40 +1,38 @@ -import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' -import { err } from 'lib/trap' - -import { Node } from '@rust/kcl-lib/bindings/Node' - -import { enginelessExecutor } from '../lib/testHelpers' import { - addSketchTo, - createArrayExpression, - createCallExpression, - createIdentifier, + assertParse, + recast, + initPromise, + Identifier, + topLevelRange, + LiteralValue, + Literal, +} from './wasm' +import { createLiteral, + createIdentifier, + createCallExpression, createObjectExpression, - createPipeExpression, + createArrayExpression, createPipeSubstitution, createVariableDeclaration, - deleteFromSelection, - deleteSegmentFromPipeExpression, + createPipeExpression, findUniqueName, + addSketchTo, giveSketchFnCallTag, moveValueIntoNewVariable, - removeSingleConstraintInfo, sketchOnExtrudedFace, + deleteSegmentFromPipeExpression, + removeSingleConstraintInfo, + deleteFromSelection, splitPipedProfile, } from './modifyAst' +import { enginelessExecutor } from '../lib/testHelpers' import { findUsesOfTagInPipe } from './queryAst' -import { Artifact, codeRefFromRange } from './std/artifactGraph' +import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' +import { err } from 'lib/trap' import { SimplifiedArgDetails } from './std/stdTypes' -import { - Identifier, - Literal, - LiteralValue, - assertParse, - initPromise, - recast, - topLevelRange, -} from './wasm' +import { Node } from '@rust/kcl-lib/bindings/Node' +import { Artifact, codeRefFromRange } from './std/artifactGraph' beforeAll(async () => { await initPromise diff --git a/src/lang/modifyAst.ts b/src/lang/modifyAst.ts index 74fdd5433..f7423c95a 100644 --- a/src/lang/modifyAst.ts +++ b/src/lang/modifyAst.ts @@ -1,35 +1,66 @@ -import { Models } from '@kittycad/lib' -import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' -import { KclExpressionWithVariable } from 'lib/commandTypes' -import { KCL_DEFAULT_CONSTANT_PREFIXES } from 'lib/constants' -import { DefaultPlaneStr } from 'lib/planes' -import { Selection } from 'lib/selections' import { err, reportRejection, trap } from 'lib/trap' -import { isArray, isOverlap, roundOff } from 'lib/utils' -import { ExtrudeFacePlane } from 'machines/modelingMachine' - -import { BodyItem } from '@rust/kcl-lib/bindings/BodyItem' -import { Name } from '@rust/kcl-lib/bindings/Name' -import { Node } from '@rust/kcl-lib/bindings/Node' -import { TagDeclarator } from '@rust/kcl-lib/bindings/TagDeclarator' - +import { Selection } from 'lib/selections' import { - deleteEdgeTreatment, - locateExtrudeDeclarator, -} from './modifyAst/addEdgeTreatment' + Program, + CallExpression, + LabeledArg, + CallExpressionKw, + PipeExpression, + VariableDeclaration, + VariableDeclarator, + Expr, + Literal, + LiteralValue, + PipeSubstitution, + Identifier, + ArrayExpression, + ObjectExpression, + UnaryExpression, + BinaryExpression, + PathToNode, + SourceRange, + isPathToNodeNumber, + parse, + formatNumber, + ArtifactGraph, + VariableMap, + KclValue, +} from './wasm' import { + isNodeSafeToReplacePath, + findAllPreviousVariables, + findAllPreviousVariablesPath, + getNodeFromPath, + isNodeSafeToReplace, + traverse, + getBodyIndex, + isCallExprWithName, ARG_INDEX_FIELD, LABELED_ARG_FIELD, UNLABELED_ARG, - findAllPreviousVariables, - findAllPreviousVariablesPath, - getBodyIndex, - getNodeFromPath, - isCallExprWithName, - isNodeSafeToReplace, - isNodeSafeToReplacePath, - traverse, } from './queryAst' +import { + addTagForSketchOnFace, + ARG_TAG, + getConstraintInfo, + getConstraintInfoKw, +} from './std/sketch' +import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' +import { + PathToNodeMap, + isLiteralArrayOrStatic, + removeSingleConstraint, + transformAstSketchLines, +} from './std/sketchcombos' +import { DefaultPlaneStr } from 'lib/planes' +import { isArray, isOverlap, roundOff } from 'lib/utils' +import { KCL_DEFAULT_CONSTANT_PREFIXES } from 'lib/constants' +import { SimplifiedArgDetails } from './std/stdTypes' +import { TagDeclarator } from '@rust/kcl-lib/bindings/TagDeclarator' +import { Models } from '@kittycad/lib' +import { ExtrudeFacePlane } from 'machines/modelingMachine' +import { Node } from '@rust/kcl-lib/bindings/Node' +import { KclExpressionWithVariable } from 'lib/commandTypes' import { Artifact, expandCap, @@ -40,46 +71,13 @@ import { getFaceCodeRef, getPathsFromArtifact, } from './std/artifactGraph' -import { - ARG_TAG, - addTagForSketchOnFace, - getConstraintInfo, - getConstraintInfoKw, -} from './std/sketch' -import { - PathToNodeMap, - isLiteralArrayOrStatic, - removeSingleConstraint, - transformAstSketchLines, -} from './std/sketchcombos' -import { SimplifiedArgDetails } from './std/stdTypes' +import { BodyItem } from '@rust/kcl-lib/bindings/BodyItem' import { findKwArg } from './util' import { - ArrayExpression, - ArtifactGraph, - BinaryExpression, - CallExpression, - CallExpressionKw, - Expr, - Identifier, - KclValue, - LabeledArg, - Literal, - LiteralValue, - ObjectExpression, - PathToNode, - PipeExpression, - PipeSubstitution, - Program, - SourceRange, - UnaryExpression, - VariableDeclaration, - VariableDeclarator, - VariableMap, - formatNumber, - isPathToNodeNumber, - parse, -} from './wasm' + deleteEdgeTreatment, + locateExtrudeDeclarator, +} from './modifyAst/addEdgeTreatment' +import { Name } from '@rust/kcl-lib/bindings/Name' export function startSketchOnDefault( node: Node, @@ -495,8 +493,8 @@ export function addShell({ insertIndex !== undefined ? insertIndex : modifiedAst.body.length - ? modifiedAst.body.length - : 0 + ? modifiedAst.body.length + : 0 if (modifiedAst.body.length) { modifiedAst.body.splice(insertAt, 0, variable) @@ -555,8 +553,8 @@ export function addSweep({ insertIndex !== undefined ? insertIndex : modifiedAst.body.length - ? modifiedAst.body.length - : 0 + ? modifiedAst.body.length + : 0 modifiedAst.body.length ? modifiedAst.body.splice(insertAt, 0, variable) @@ -789,8 +787,8 @@ export function addOffsetPlane({ insertIndex !== undefined ? insertIndex : modifiedAst.body.length - ? modifiedAst.body.length - : 0 + ? modifiedAst.body.length + : 0 modifiedAst.body.length ? modifiedAst.body.splice(insertAt, 0, newPlane) @@ -868,8 +866,8 @@ export function addHelix({ insertIndex !== undefined ? insertIndex : modifiedAst.body.length - ? modifiedAst.body.length - : 0 + ? modifiedAst.body.length + : 0 modifiedAst.body.length ? modifiedAst.body.splice(insertAt, 0, variable) @@ -1286,7 +1284,7 @@ export function createUnaryExpression( export function createBinaryExpression([left, operator, right]: [ BinaryExpression['left'], BinaryExpression['operator'], - BinaryExpression['right'], + BinaryExpression['right'] ]): Node { return { type: 'BinaryExpression', @@ -1305,7 +1303,7 @@ export function createBinaryExpression([left, operator, right]: [ export function createBinaryExpressionWithUnary([left, right]: [ BinaryExpression['left'], - BinaryExpression['right'], + BinaryExpression['right'] ]): Node { if (right.type === 'UnaryExpression' && right.operator === '-') return createBinaryExpression([left, '-', right.argument]) @@ -1559,7 +1557,7 @@ export async function deleteFromSelection( variables: VariableMap, artifactGraph: ArtifactGraph, getFaceDetails: (id: string) => Promise = () => - ({}) as any + ({} as any) ): Promise | Error> { const astClone = structuredClone(ast) let deletionArtifact = selection.artifact @@ -1593,8 +1591,8 @@ export async function deleteFromSelection( deletionArtifact.type === 'plane' ? expandPlane(deletionArtifact, artifactGraph) : deletionArtifact.type === 'wall' - ? expandWall(deletionArtifact, artifactGraph) - : expandCap(deletionArtifact, artifactGraph) + ? expandWall(deletionArtifact, artifactGraph) + : expandCap(deletionArtifact, artifactGraph) for (const path of plane.paths.sort( (a, b) => b.codeRef.range?.[0] - a.codeRef.range?.[0] )) { @@ -1734,12 +1732,12 @@ export async function deleteFromSelection( selection.artifact?.type === 'wall' ? selection.artifact : selection.artifact?.type === 'segment' && - selection.artifact.surfaceId - ? getArtifactOfTypes( - { key: selection.artifact.surfaceId, types: ['wall'] }, - artifactGraph - ) - : null + selection.artifact.surfaceId + ? getArtifactOfTypes( + { key: selection.artifact.surfaceId, types: ['wall'] }, + artifactGraph + ) + : null if (err(wallArtifact)) return if (wallArtifact) { const sweep = getArtifactOfTypes( @@ -1804,15 +1802,15 @@ export async function deleteFromSelection( variable.type === 'Sketch' ? variable.value.artifactId : variable.type === 'Face' - ? variable.value.artifactId - : '' + ? variable.value.artifactId + : '' if (!artifactId) return new Error('Sketch not on anything') const onId = variable.type === 'Sketch' ? variable.value.on.id : variable.type === 'Face' - ? variable.value.id - : '' + ? variable.value.id + : '' if (!onId) return new Error('Sketch not on anything') // Can't kick off multiple requests at once as getFaceDetails // is three engine calls in one and they conflict @@ -1965,8 +1963,8 @@ export function getInsertIndex( const insertIndex = !sketchNodePaths.length ? Number(planeNodePath[1][0]) + 1 : insertType === 'start' - ? minIndex - : maxIndex + 1 + ? minIndex + : maxIndex + 1 return insertIndex } diff --git a/src/lang/modifyAst/addEdgeTreatment.test.ts b/src/lang/modifyAst/addEdgeTreatment.test.ts index d7da587d1..aa91f9389 100644 --- a/src/lang/modifyAst/addEdgeTreatment.test.ts +++ b/src/lang/modifyAst/addEdgeTreatment.test.ts @@ -1,7 +1,31 @@ -import { VITE_KC_DEV_TOKEN } from 'env' -import { createLiteral } from 'lang/modifyAst' +import { + assertParse, + recast, + initPromise, + PathToNode, + Program, + CallExpression, + PipeExpression, + VariableDeclarator, + SourceRange, + topLevelRange, + CallExpressionKw, +} from '../wasm' +import { + EdgeTreatmentType, + getPathToExtrudeForSegmentSelection, + hasValidEdgeTreatmentSelection, + isTagUsedInEdgeTreatment, + modifyAstWithEdgeTreatmentAndTag, + FilletParameters, + ChamferParameters, + EdgeTreatmentParameters, + deleteEdgeTreatment, +} from './addEdgeTreatment' +import { getNodeFromPath } from '../queryAst' import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' -import { codeRefFromRange } from 'lang/std/artifactGraph' +import { createLiteral } from 'lang/modifyAst' +import { err } from 'lib/trap' import { Selection, Selections } from 'lib/selections' import { codeManager, @@ -9,34 +33,9 @@ import { engineCommandManager, kclManager, } from 'lib/singletons' -import { err } from 'lib/trap' +import { VITE_KC_DEV_TOKEN } from 'env' import { isOverlap } from 'lib/utils' - -import { getNodeFromPath } from '../queryAst' -import { - CallExpression, - CallExpressionKw, - PathToNode, - PipeExpression, - Program, - SourceRange, - VariableDeclarator, - assertParse, - initPromise, - recast, - topLevelRange, -} from '../wasm' -import { - ChamferParameters, - EdgeTreatmentParameters, - EdgeTreatmentType, - FilletParameters, - deleteEdgeTreatment, - getPathToExtrudeForSegmentSelection, - hasValidEdgeTreatmentSelection, - isTagUsedInEdgeTreatment, - modifyAstWithEdgeTreatmentAndTag, -} from './addEdgeTreatment' +import { codeRefFromRange } from 'lang/std/artifactGraph' beforeAll(async () => { await initPromise diff --git a/src/lang/modifyAst/addEdgeTreatment.ts b/src/lang/modifyAst/addEdgeTreatment.ts index 5babff419..db6a285ad 100644 --- a/src/lang/modifyAst/addEdgeTreatment.ts +++ b/src/lang/modifyAst/addEdgeTreatment.ts @@ -1,40 +1,3 @@ -import EditorManager from 'editor/manager' -import { KclManager } from 'lang/KclSingleton' -import CodeManager from 'lang/codeManager' -import { updateModelingState } from 'lang/modelingWorkflows' -import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' -import { Artifact, getSweepArtifactFromSelection } from 'lang/std/artifactGraph' -import { EngineCommandManager } from 'lang/std/engineConnection' -import { findKwArg } from 'lang/util' -import { KclCommandValue } from 'lib/commandTypes' -import { EXECUTION_TYPE_REAL } from 'lib/constants' -import { Selection, Selections } from 'lib/selections' -import { err } from 'lib/trap' -import { isArray } from 'lib/utils' - -import { Name } from '@rust/kcl-lib/bindings/Name' -import { Node } from '@rust/kcl-lib/bindings/Node' - -import { - createArrayExpression, - createCallExpressionStdLib, - createCallExpressionStdLibKw, - createLabeledArg, - createLocalName, - createPipeExpression, -} from '../modifyAst' -import { - getNodeFromPath, - hasSketchPipeBeenExtruded, - traverse, -} from '../queryAst' -import { - ARG_TAG, - addTagForSketchOnFace, - getTagFromCallExpression, - sketchLineHelperMap, - sketchLineHelperMapKw, -} from '../std/sketch' import { ArtifactGraph, CallExpression, @@ -47,6 +10,41 @@ import { VariableDeclaration, VariableDeclarator, } from '../wasm' +import { + createCallExpressionStdLib, + createArrayExpression, + createLocalName, + createPipeExpression, + createCallExpressionStdLibKw, + createLabeledArg, +} from '../modifyAst' +import { + getNodeFromPath, + hasSketchPipeBeenExtruded, + traverse, +} from '../queryAst' +import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' +import { + addTagForSketchOnFace, + ARG_TAG, + getTagFromCallExpression, + sketchLineHelperMap, + sketchLineHelperMapKw, +} from '../std/sketch' +import { err } from 'lib/trap' +import { Selection, Selections } from 'lib/selections' +import { KclCommandValue } from 'lib/commandTypes' +import { isArray } from 'lib/utils' +import { Artifact, getSweepArtifactFromSelection } from 'lang/std/artifactGraph' +import { Node } from '@rust/kcl-lib/bindings/Node' +import { findKwArg } from 'lang/util' +import { KclManager } from 'lang/KclSingleton' +import { EXECUTION_TYPE_REAL } from 'lib/constants' +import { EngineCommandManager } from 'lang/std/engineConnection' +import EditorManager from 'editor/manager' +import CodeManager from 'lang/codeManager' +import { updateModelingState } from 'lang/modelingWorkflows' +import { Name } from '@rust/kcl-lib/bindings/Name' // Edge Treatment Types export enum EdgeTreatmentType { diff --git a/src/lang/modifyAst/addRevolve.ts b/src/lang/modifyAst/addRevolve.ts index b079196f2..3841a7f7b 100644 --- a/src/lang/modifyAst/addRevolve.ts +++ b/src/lang/modifyAst/addRevolve.ts @@ -1,28 +1,27 @@ +import { err } from 'lib/trap' +import { KCL_DEFAULT_CONSTANT_PREFIXES } from 'lib/constants' +import { Program, PathToNode, Expr, VariableDeclarator } from 'lang/wasm' +import { Selections } from 'lib/selections' +import { Node } from '@rust/kcl-lib/bindings/Node' import { - createCallExpressionStdLibKw, - createLabeledArg, createLiteral, createLocalName, - createVariableDeclaration, findUniqueName, + createVariableDeclaration, + createCallExpressionStdLibKw, + createLabeledArg, } from 'lang/modifyAst' -import { - getEdgeTagCall, - mutateAstWithTagForSketchSegment, -} from 'lang/modifyAst/addEdgeTreatment' import { ARG_INDEX_FIELD, - LABELED_ARG_FIELD, getNodeFromPath, + LABELED_ARG_FIELD, } from 'lang/queryAst' -import { getSafeInsertIndex } from 'lang/queryAst/getSafeInsertIndex' import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' -import { Expr, PathToNode, Program, VariableDeclarator } from 'lang/wasm' -import { KCL_DEFAULT_CONSTANT_PREFIXES } from 'lib/constants' -import { Selections } from 'lib/selections' -import { err } from 'lib/trap' - -import { Node } from '@rust/kcl-lib/bindings/Node' +import { + mutateAstWithTagForSketchSegment, + getEdgeTagCall, +} from 'lang/modifyAst/addEdgeTreatment' +import { getSafeInsertIndex } from 'lang/queryAst/getSafeInsertIndex' export function getAxisExpressionAndIndex( axisOrEdge: 'Axis' | 'Edge', diff --git a/src/lang/modifyAst/boolean.ts b/src/lang/modifyAst/boolean.ts index dce889669..322907cc2 100644 --- a/src/lang/modifyAst/boolean.ts +++ b/src/lang/modifyAst/boolean.ts @@ -1,6 +1,7 @@ +import { Node } from '@rust/kcl-lib/bindings/Node' import EditorManager from 'editor/manager' -import { KclManager } from 'lang/KclSingleton' import CodeManager from 'lang/codeManager' +import { KclManager } from 'lang/KclSingleton' import { updateModelingState } from 'lang/modelingWorkflows' import { createArrayExpression, @@ -25,8 +26,6 @@ import { Selection, Selections } from 'lib/selections' import { err } from 'lib/trap' import { isArray } from 'lib/utils' -import { Node } from '@rust/kcl-lib/bindings/Node' - export async function applySubtractFromTargetOperatorSelections( target: Selection, tool: Selection, diff --git a/src/lang/modifyAst/deleteSelection.ts b/src/lang/modifyAst/deleteSelection.ts index 7289b07ff..95b46921b 100644 --- a/src/lang/modifyAst/deleteSelection.ts +++ b/src/lang/modifyAst/deleteSelection.ts @@ -1,9 +1,6 @@ -import { getFaceDetails } from 'clientSideScene/sceneEntities' -import { executeAstMock } from 'lang/langHelpers' -import { updateModelingState } from 'lang/modelingWorkflows' -import { deleteFromSelection } from 'lang/modifyAst' -import { EXECUTION_TYPE_REAL } from 'lib/constants' import { Selection } from 'lib/selections' +import { getFaceDetails } from 'clientSideScene/sceneEntities' +import { deleteFromSelection } from 'lang/modifyAst' import { codeManager, editorManager, @@ -11,6 +8,9 @@ import { rustContext, } from 'lib/singletons' import { err } from 'lib/trap' +import { executeAstMock } from 'lang/langHelpers' +import { updateModelingState } from 'lang/modelingWorkflows' +import { EXECUTION_TYPE_REAL } from 'lib/constants' export const deletionErrorMessage = 'Unable to delete selection. Please edit manually in code pane.' diff --git a/src/lang/modifyAst/setAppearance.ts b/src/lang/modifyAst/setAppearance.ts index a15fe6816..1775569eb 100644 --- a/src/lang/modifyAst/setAppearance.ts +++ b/src/lang/modifyAst/setAppearance.ts @@ -1,3 +1,7 @@ +import { PathToNode, Program } from 'lang/wasm' +import { Node } from '@rust/kcl-lib/bindings/Node' +import { locateExtrudeDeclarator } from './addEdgeTreatment' +import { err } from 'lib/trap' import { createCallExpressionStdLibKw, createLabeledArg, @@ -5,13 +9,7 @@ import { createPipeExpression, } from 'lang/modifyAst' import { createPipeSubstitution } from 'lang/modifyAst' -import { PathToNode, Program } from 'lang/wasm' import { COMMAND_APPEARANCE_COLOR_DEFAULT } from 'lib/commandBarConfigs/modelingCommandConfig' -import { err } from 'lib/trap' - -import { Node } from '@rust/kcl-lib/bindings/Node' - -import { locateExtrudeDeclarator } from './addEdgeTreatment' export function setAppearance({ ast, diff --git a/src/lang/project.ts b/src/lang/project.ts index a000d571d..17141a034 100644 --- a/src/lang/project.ts +++ b/src/lang/project.ts @@ -1,13 +1,11 @@ -import { DEFAULT_DEFAULT_ANGLE_UNIT } from 'lib/constants' -import { DEFAULT_DEFAULT_LENGTH_UNIT } from 'lib/constants' - import { UnitLength } from '@rust/kcl-lib/bindings/ModelingCmd' - import { changeKclSettings, unitAngleToUnitAng, unitLengthToUnitLen, } from './wasm' +import { DEFAULT_DEFAULT_ANGLE_UNIT } from 'lib/constants' +import { DEFAULT_DEFAULT_LENGTH_UNIT } from 'lib/constants' /** * Create a new KCL file with the given initial content and default length unit. diff --git a/src/lang/queryAst.test.ts b/src/lang/queryAst.test.ts index 597324211..7a1261c37 100644 --- a/src/lang/queryAst.test.ts +++ b/src/lang/queryAst.test.ts @@ -1,38 +1,36 @@ +import { + assertParse, + recast, + initPromise, + PathToNode, + Identifier, + topLevelRange, +} from './wasm' +import { + findAllPreviousVariables, + isNodeSafeToReplace, + isTypeInValue, + hasExtrudeSketch, + findUsesOfTagInPipe, + hasSketchPipeBeenExtruded, + doesSceneHaveSweepableSketch, + traverse, + getNodeFromPath, + doesSceneHaveExtrudedSketch, +} from './queryAst' import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' -import { addCallExpressionsToPipe, addCloseToPipe } from 'lang/std/sketch' -import { err } from 'lib/trap' - -import { Name } from '@rust/kcl-lib/bindings/Name' - import { enginelessExecutor } from '../lib/testHelpers' import { createArrayExpression, createCallExpression, - createCallExpressionStdLib, createLiteral, createPipeSubstitution, + createCallExpressionStdLib, } from './modifyAst' -import { - doesSceneHaveExtrudedSketch, - doesSceneHaveSweepableSketch, - findAllPreviousVariables, - findUsesOfTagInPipe, - getNodeFromPath, - hasExtrudeSketch, - hasSketchPipeBeenExtruded, - isNodeSafeToReplace, - isTypeInValue, - traverse, -} from './queryAst' +import { err } from 'lib/trap' import { codeRefFromRange } from './std/artifactGraph' -import { - Identifier, - PathToNode, - assertParse, - initPromise, - recast, - topLevelRange, -} from './wasm' +import { addCallExpressionsToPipe, addCloseToPipe } from 'lang/std/sketch' +import { Name } from '@rust/kcl-lib/bindings/Name' beforeAll(async () => { await initPromise diff --git a/src/lang/queryAst.ts b/src/lang/queryAst.ts index 912579247..d2d16251d 100644 --- a/src/lang/queryAst.ts +++ b/src/lang/queryAst.ts @@ -1,52 +1,50 @@ import { ToolTip } from 'lang/langHelpers' -import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' import { Selection, Selections } from 'lib/selections' -import { KclSettingsAnnotation } from 'lib/settings/settingsTypes' -import { Reason, err } from 'lib/trap' - -import { FunctionExpression } from '@rust/kcl-lib/bindings/FunctionExpression' -import { ImportStatement } from '@rust/kcl-lib/bindings/ImportStatement' -import { Node } from '@rust/kcl-lib/bindings/Node' -import { TypeDeclaration } from '@rust/kcl-lib/bindings/TypeDeclaration' - -import { getAngle, isArray } from '../lib/utils' -import { createLocalName, splitPathAtLastIndex } from './modifyAst' -import { codeRefFromRange } from './std/artifactGraph' -import { ARG_TAG, getArgForEnd, getFirstArg } from './std/sketch' -import { getSketchSegmentFromSourceRange } from './std/sketchConstraints' -import { - getConstraintLevelFromSourceRange, - getConstraintType, -} from './std/sketchcombos' -import { findKwArg } from './util' import { ArrayExpression, - ArtifactGraph, BinaryExpression, CallExpression, CallExpressionKw, Expr, ExpressionStatement, - Identifier, ObjectExpression, ObjectProperty, PathToNode, PipeExpression, Program, ReturnStatement, - SourceRange, - SyntaxType, - VariableDeclaration, - VariableDeclarator, - VariableMap, - kclSettings, - recast, sketchFromKclValue, sketchFromKclValueOptional, + SourceRange, + SyntaxType, topLevelRange, - unitAngToUnitAngle, + VariableDeclaration, + VariableDeclarator, + recast, + ArtifactGraph, + kclSettings, unitLenToUnitLength, + unitAngToUnitAngle, + VariableMap, + Identifier, } from './wasm' +import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' +import { createLocalName, splitPathAtLastIndex } from './modifyAst' +import { getSketchSegmentFromSourceRange } from './std/sketchConstraints' +import { getAngle, isArray } from '../lib/utils' +import { ARG_TAG, getArgForEnd, getFirstArg } from './std/sketch' +import { + getConstraintLevelFromSourceRange, + getConstraintType, +} from './std/sketchcombos' +import { err, Reason } from 'lib/trap' +import { Node } from '@rust/kcl-lib/bindings/Node' +import { findKwArg } from './util' +import { codeRefFromRange } from './std/artifactGraph' +import { FunctionExpression } from '@rust/kcl-lib/bindings/FunctionExpression' +import { ImportStatement } from '@rust/kcl-lib/bindings/ImportStatement' +import { KclSettingsAnnotation } from 'lib/settings/settingsTypes' +import { TypeDeclaration } from '@rust/kcl-lib/bindings/TypeDeclaration' export const LABELED_ARG_FIELD = 'LabeledArg -> Arg' export const UNLABELED_ARG = 'unlabeled first arg' diff --git a/src/lang/queryAst/getIdentifiersInProgram.test.ts b/src/lang/queryAst/getIdentifiersInProgram.test.ts index 66d3d3d51..c2a2cf557 100644 --- a/src/lang/queryAst/getIdentifiersInProgram.test.ts +++ b/src/lang/queryAst/getIdentifiersInProgram.test.ts @@ -1,5 +1,4 @@ import { assertParse, initPromise } from 'lang/wasm' - import { getIdentifiersInProgram } from './getIndentifiersInProgram' function identifier(name: string, start: number, end: number) { diff --git a/src/lang/queryAst/getIndentifiersInProgram.ts b/src/lang/queryAst/getIndentifiersInProgram.ts index 637be0574..4a06d8b4d 100644 --- a/src/lang/queryAst/getIndentifiersInProgram.ts +++ b/src/lang/queryAst/getIndentifiersInProgram.ts @@ -1,6 +1,5 @@ import { traverse } from 'lang/queryAst' import { Expr, Name, Program } from 'lang/wasm' - import { Node } from '@rust/kcl-lib/bindings/Node' /** diff --git a/src/lang/queryAst/getSafeInsertIndex.test.ts b/src/lang/queryAst/getSafeInsertIndex.test.ts index 01d3edede..af62d6bd1 100644 --- a/src/lang/queryAst/getSafeInsertIndex.test.ts +++ b/src/lang/queryAst/getSafeInsertIndex.test.ts @@ -1,5 +1,4 @@ import { assertParse, initPromise } from 'lang/wasm' - import { getSafeInsertIndex } from './getSafeInsertIndex' beforeAll(async () => { diff --git a/src/lang/queryAst/getSafeInsertIndex.ts b/src/lang/queryAst/getSafeInsertIndex.ts index 5486ff40a..37c6587b1 100644 --- a/src/lang/queryAst/getSafeInsertIndex.ts +++ b/src/lang/queryAst/getSafeInsertIndex.ts @@ -1,8 +1,6 @@ -import { Expr, Program } from 'lang/wasm' - -import { Node } from '@rust/kcl-lib/bindings/Node' - import { getIdentifiersInProgram } from './getIndentifiersInProgram' +import { Program, Expr } from 'lang/wasm' +import { Node } from '@rust/kcl-lib/bindings/Node' import { getTagDeclaratorsInProgram } from './getTagDeclaratorsInProgram' /** diff --git a/src/lang/queryAst/getTagDeclaratorsInProgram.test.ts b/src/lang/queryAst/getTagDeclaratorsInProgram.test.ts index b9ac6822f..d8a78ebb2 100644 --- a/src/lang/queryAst/getTagDeclaratorsInProgram.test.ts +++ b/src/lang/queryAst/getTagDeclaratorsInProgram.test.ts @@ -1,5 +1,4 @@ import { assertParse, initPromise } from 'lang/wasm' - import { getTagDeclaratorsInProgram } from './getTagDeclaratorsInProgram' function tagDeclaratorWithIndex( diff --git a/src/lang/queryAst/getTagDeclaratorsInProgram.ts b/src/lang/queryAst/getTagDeclaratorsInProgram.ts index de2ba15c1..31e96132e 100644 --- a/src/lang/queryAst/getTagDeclaratorsInProgram.ts +++ b/src/lang/queryAst/getTagDeclaratorsInProgram.ts @@ -1,9 +1,8 @@ import { getBodyIndex, traverse } from 'lang/queryAst' import { Expr, Program } from 'lang/wasm' -import { err } from 'lib/trap' - import { Node } from '@rust/kcl-lib/bindings/Node' import { TagDeclarator } from '@rust/kcl-lib/bindings/TagDeclarator' +import { err } from 'lib/trap' type TagWithBodyIndex = { tag: TagDeclarator; bodyIndex: number } diff --git a/src/lang/queryAst/getVariableDeclaration.ts b/src/lang/queryAst/getVariableDeclaration.ts index 4583258de..277952293 100644 --- a/src/lang/queryAst/getVariableDeclaration.ts +++ b/src/lang/queryAst/getVariableDeclaration.ts @@ -1,6 +1,5 @@ -import { Program } from 'lang/wasm' - import { Node } from '@rust/kcl-lib/bindings/Node' +import { Program } from 'lang/wasm' /** * Given a program and a variable name, return the variable declaration diff --git a/src/lang/queryAst/getVariableDeclarationIndex.ts b/src/lang/queryAst/getVariableDeclarationIndex.ts index a42125f7b..d3960771b 100644 --- a/src/lang/queryAst/getVariableDeclarationIndex.ts +++ b/src/lang/queryAst/getVariableDeclarationIndex.ts @@ -1,6 +1,5 @@ -import { Program } from 'lang/wasm' - import { Node } from '@rust/kcl-lib/bindings/Node' +import { Program } from 'lang/wasm' /** * Given a program and a variable name, return the index of the variable declaration diff --git a/src/lang/queryAstNodePathUtils.ts b/src/lang/queryAstNodePathUtils.ts index d51f5859a..2f00457fb 100644 --- a/src/lang/queryAstNodePathUtils.ts +++ b/src/lang/queryAstNodePathUtils.ts @@ -1,18 +1,17 @@ -import { ImportStatement } from '@rust/kcl-lib/bindings/ImportStatement' -import { Node } from '@rust/kcl-lib/bindings/Node' -import { TypeDeclaration } from '@rust/kcl-lib/bindings/TypeDeclaration' - -import { ARG_INDEX_FIELD, LABELED_ARG_FIELD } from './queryAst' import { Expr, ExpressionStatement, - Identifier, - PathToNode, - Program, + VariableDeclaration, ReturnStatement, SourceRange, - VariableDeclaration, + PathToNode, + Program, + Identifier, } from './wasm' +import { ImportStatement } from '@rust/kcl-lib/bindings/ImportStatement' +import { Node } from '@rust/kcl-lib/bindings/Node' +import { ARG_INDEX_FIELD, LABELED_ARG_FIELD } from './queryAst' +import { TypeDeclaration } from '@rust/kcl-lib/bindings/TypeDeclaration' function moreNodePathFromSourceRange( node: Node< diff --git a/src/lang/recast.test.ts b/src/lang/recast.test.ts index ce21fed0d..38110f71b 100644 --- a/src/lang/recast.test.ts +++ b/src/lang/recast.test.ts @@ -1,7 +1,6 @@ -import { err } from 'lib/trap' +import { assertParse, Program, recast, initPromise } from './wasm' import fs from 'node:fs' - -import { Program, assertParse, initPromise, recast } from './wasm' +import { err } from 'lib/trap' beforeAll(async () => { await initPromise diff --git a/src/lang/std/artifactGraph.ts b/src/lang/std/artifactGraph.ts index 07acdedc1..b13b2c81c 100644 --- a/src/lang/std/artifactGraph.ts +++ b/src/lang/std/artifactGraph.ts @@ -1,26 +1,25 @@ -import { Models } from '@kittycad/lib' -import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' import { + Expr, Artifact, ArtifactGraph, ArtifactId, - CapArtifact, - EdgeCut, - Expr, - PathArtifact, PathToNode, - PlaneArtifact, Program, + SourceRange, + PathArtifact, + PlaneArtifact, + WallArtifact, SegmentArtifact, Solid2dArtifact as Solid2D, - SourceRange, SweepArtifact, SweepEdge, - WallArtifact, + CapArtifact, + EdgeCut, } from 'lang/wasm' +import { Models } from '@kittycad/lib' +import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' import { Selection } from 'lib/selections' import { err } from 'lib/trap' - import { Cap, Plane, diff --git a/src/lang/std/engineConnection.ts b/src/lang/std/engineConnection.ts index 0e5694b9f..855510a34 100644 --- a/src/lang/std/engineConnection.ts +++ b/src/lang/std/engineConnection.ts @@ -1,22 +1,22 @@ -import { Models } from '@kittycad/lib' -import { BSON } from 'bson' -import { MachineManager } from 'components/MachineManagerProvider' +import { defaultSourceRange, SourceRange } from 'lang/wasm' import { VITE_KC_API_WS_MODELING_URL, VITE_KC_DEV_TOKEN } from 'env' -import { useModelingContext } from 'hooks/useModelingContext' -import { KclManager } from 'lang/KclSingleton' -import { EngineCommand, ResponseMap } from 'lang/std/artifactGraph' -import { SourceRange, defaultSourceRange } from 'lang/wasm' -import { EXECUTE_AST_INTERRUPT_ERROR_MESSAGE } from 'lib/constants' -import { markOnce } from 'lib/performance' -import { SettingsViaQueryString } from 'lib/settings/settingsTypes' +import { Models } from '@kittycad/lib' +import { uuidv4, binaryToUuid } from 'lib/utils' +import { BSON } from 'bson' import { Themes, - darkModeMatcher, - getOppositeTheme, getThemeColorForEngine, + getOppositeTheme, + darkModeMatcher, } from 'lib/theme' +import { EngineCommand, ResponseMap } from 'lang/std/artifactGraph' +import { useModelingContext } from 'hooks/useModelingContext' +import { SettingsViaQueryString } from 'lib/settings/settingsTypes' +import { EXECUTE_AST_INTERRUPT_ERROR_MESSAGE } from 'lib/constants' +import { KclManager } from 'lang/KclSingleton' import { reportRejection } from 'lib/trap' -import { binaryToUuid, uuidv4 } from 'lib/utils' +import { markOnce } from 'lib/performance' +import { MachineManager } from 'components/MachineManagerProvider' // TODO(paultag): This ought to be tweakable. const pingIntervalMs = 5_000 @@ -48,8 +48,8 @@ interface WebRTCClientMetrics extends ClientMetrics { type Value = U extends undefined ? { type: T; value: U } : U extends void - ? { type: T } - : { type: T; value: U } + ? { type: T } + : { type: T; value: U } type State = Value @@ -309,10 +309,8 @@ class EngineConnection extends EventTarget { private engineCommandManager: EngineCommandManager private pingPongSpan: { ping?: Date; pong?: Date } - private pingIntervalId: ReturnType = setInterval( - () => {}, - 60_000 - ) + private pingIntervalId: ReturnType = setInterval(() => {}, + 60_000) isUsingConnectionLite: boolean = false constructor({ diff --git a/src/lang/std/sketch.test.ts b/src/lang/std/sketch.test.ts index 98b1c9ec2..0a47f2f86 100644 --- a/src/lang/std/sketch.test.ts +++ b/src/lang/std/sketch.test.ts @@ -1,28 +1,26 @@ -import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' -import { err } from 'lib/trap' - -import { Node } from '@rust/kcl-lib/bindings/Node' - -import { enginelessExecutor } from '../../lib/testHelpers' -import { getNodeFromPath } from '../queryAst' import { - CallExpression, - CallExpressionKw, - assertParse, - initPromise, - recast, - topLevelRange, -} from '../wasm' -import { - addCloseToPipe, - addNewSketchLn, - addTagForSketchOnFace, changeSketchArguments, + addTagForSketchOnFace, + addNewSketchLn, + getYComponent, + getXComponent, + addCloseToPipe, getConstraintInfo, getConstraintInfoKw, - getXComponent, - getYComponent, } from './sketch' +import { + assertParse, + recast, + initPromise, + CallExpression, + topLevelRange, + CallExpressionKw, +} from '../wasm' +import { getNodeFromPath } from '../queryAst' +import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' +import { enginelessExecutor } from '../../lib/testHelpers' +import { err } from 'lib/trap' +import { Node } from '@rust/kcl-lib/bindings/Node' const eachQuad: [number, [number, number]][] = [ [-315, [1, 1]], diff --git a/src/lang/std/sketch.ts b/src/lang/std/sketch.ts index 09f5535f3..1076ef19d 100644 --- a/src/lang/std/sketch.ts +++ b/src/lang/std/sketch.ts @@ -1,73 +1,31 @@ -import { ToolTip, toolTips } from 'lang/langHelpers' import { - createArrayExpression, - createCallExpression, - createCallExpressionStdLibKw, - createLabeledArg, - createLiteral, - createObjectExpression, - createPipeSubstitution, - createTagDeclarator, - findUniqueName, - mutateArrExp, - mutateObjExpProp, -} from 'lang/modifyAst' + Path, + Sketch, + SourceRange, + PathToNode, + Program, + PipeExpression, + CallExpression, + CallExpressionKw, + VariableDeclarator, + Expr, + VariableDeclaration, + sketchFromKclValue, + topLevelRange, + VariableMap, +} from 'lang/wasm' import { ARG_INDEX_FIELD, - LABELED_ARG_FIELD, getNodeFromPath, getNodeFromPathCurry, + LABELED_ARG_FIELD, } from 'lang/queryAst' import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' import { isLiteralArrayOrStatic, isNotLiteralArrayOrStatic, } from 'lang/std/sketchcombos' -import { - AddTagInfo, - ArrayItemInput, - ConstrainInfo, - CreatedSketchExprResult, - InputArgKeys, - ObjectPropertyInput, - RawArgs, - SegmentInputs, - SimplifiedArgDetails, - SingleValueInput, - SketchLineHelper, - SketchLineHelperKw, -} from 'lang/std/stdTypes' -import { - findKwArg, - findKwArgAny, - findKwArgAnyIndex, - findKwArgWithIndex, -} from 'lang/util' -import { - CallExpression, - CallExpressionKw, - Expr, - Path, - PathToNode, - PipeExpression, - Program, - Sketch, - SourceRange, - VariableDeclaration, - VariableDeclarator, - VariableMap, - sketchFromKclValue, - topLevelRange, -} from 'lang/wasm' -import { err } from 'lib/trap' -import { getAngle, getLength, isArray, roundOff } from 'lib/utils' -import { EdgeCutInfo } from 'machines/modelingMachine' -import { perpendicularDistance } from 'sketch-helpers' - -import { Name } from '@rust/kcl-lib/bindings/Name' -import { Node } from '@rust/kcl-lib/bindings/Node' -import { TagDeclarator } from '@rust/kcl-lib/bindings/TagDeclarator' - +import { toolTips, ToolTip } from 'lang/langHelpers' import { createPipeExpression, mutateKwArg, @@ -76,6 +34,48 @@ import { splitPathAtPipeExpression, } from '../modifyAst' +import { + SketchLineHelper, + ConstrainInfo, + ArrayItemInput, + ObjectPropertyInput, + SingleValueInput, + AddTagInfo, + SegmentInputs, + SimplifiedArgDetails, + RawArgs, + CreatedSketchExprResult, + SketchLineHelperKw, + InputArgKeys, +} from 'lang/std/stdTypes' + +import { + createLiteral, + createTagDeclarator, + createCallExpression, + createCallExpressionStdLibKw, + createArrayExpression, + createLabeledArg, + createPipeSubstitution, + createObjectExpression, + mutateArrExp, + mutateObjExpProp, + findUniqueName, +} from 'lang/modifyAst' +import { roundOff, getLength, getAngle, isArray } from 'lib/utils' +import { err } from 'lib/trap' +import { perpendicularDistance } from 'sketch-helpers' +import { TagDeclarator } from '@rust/kcl-lib/bindings/TagDeclarator' +import { EdgeCutInfo } from 'machines/modelingMachine' +import { Node } from '@rust/kcl-lib/bindings/Node' +import { + findKwArg, + findKwArgWithIndex, + findKwArgAny, + findKwArgAnyIndex, +} from 'lang/util' +import { Name } from '@rust/kcl-lib/bindings/Name' + export const ARG_TAG = 'tag' export const ARG_END = 'end' export const ARG_LENGTH = 'length' @@ -158,10 +158,10 @@ const constrainInfo = ( g === 'singleValue' ? { type: 'singleValue' } : typeof g === 'number' - ? { type: 'arrayItem', index: g } - : typeof g === 'string' - ? { type: 'objectProperty', key: g } - : undefined, + ? { type: 'arrayItem', index: g } + : typeof g === 'string' + ? { type: 'objectProperty', key: g } + : undefined, pathToNode: e, stdLibFnName: f, }) @@ -178,7 +178,7 @@ const commonConstraintInfoHelper = ( { arrayInput?: 0 | 1 objInput?: ObjectPropertyInput['key'] - }, + } ], code: string, pathToNode: PathToNode, @@ -3459,11 +3459,10 @@ function isAngleLiteral(lineArugement: Expr): boolean { return lineArugement?.type === 'ArrayExpression' ? isLiteralArrayOrStatic(lineArugement.elements[0]) : lineArugement?.type === 'ObjectExpression' - ? isLiteralArrayOrStatic( - lineArugement.properties.find(({ key }) => key.name === 'angle') - ?.value - ) - : false + ? isLiteralArrayOrStatic( + lineArugement.properties.find(({ key }) => key.name === 'angle')?.value + ) + : false } type addTagFn = ( diff --git a/src/lang/std/sketchConstraints.test.ts b/src/lang/std/sketchConstraints.test.ts index f2f0d385e..67f091556 100644 --- a/src/lang/std/sketchConstraints.test.ts +++ b/src/lang/std/sketchConstraints.test.ts @@ -1,22 +1,21 @@ -import { err } from 'lib/trap' - -import { enginelessExecutor } from '../../lib/testHelpers' import { - Sketch, - SourceRange, assertParse, - initPromise, + Sketch, recast, + initPromise, sketchFromKclValue, + SourceRange, topLevelRange, } from '../wasm' -import { codeRefFromRange } from './artifactGraph' -import { getSketchSegmentFromSourceRange } from './sketchConstraints' import { ConstraintType, getTransformInfos, transformAstSketchLines, } from './sketchcombos' +import { getSketchSegmentFromSourceRange } from './sketchConstraints' +import { enginelessExecutor } from '../../lib/testHelpers' +import { err } from 'lib/trap' +import { codeRefFromRange } from './artifactGraph' beforeAll(async () => { await initPromise diff --git a/src/lang/std/sketchConstraints.ts b/src/lang/std/sketchConstraints.ts index 05516b074..f9c57e490 100644 --- a/src/lang/std/sketchConstraints.ts +++ b/src/lang/std/sketchConstraints.ts @@ -1,23 +1,21 @@ -import { ToolTip, toolTips } from 'lang/langHelpers' import { getNodeFromPath } from 'lang/queryAst' -import { findKwArgAny } from 'lang/util' -import { err } from 'lib/trap' - +import { ToolTip, toolTips } from 'lang/langHelpers' import { Node } from '@rust/kcl-lib/bindings/Node' - import { - CallExpression, - CallExpressionKw, - Expr, - LabeledArg, - Path, - PathToNode, Program, + VariableDeclarator, + CallExpression, Sketch, SourceRange, - VariableDeclarator, + Path, + PathToNode, + Expr, topLevelRange, + LabeledArg, + CallExpressionKw, } from '../wasm' +import { err } from 'lib/trap' +import { findKwArgAny } from 'lang/util' import { DETERMINING_ARGS } from './sketch' export function getSketchSegmentFromPathToNode( diff --git a/src/lang/std/sketchcombos.test.ts b/src/lang/std/sketchcombos.test.ts index 69db621e1..13c1dc6ec 100644 --- a/src/lang/std/sketchcombos.test.ts +++ b/src/lang/std/sketchcombos.test.ts @@ -1,33 +1,32 @@ -import { ToolTip } from 'lang/langHelpers' -import { findKwArg } from 'lang/util' -import { Selection, Selections } from 'lib/selections' -import { err } from 'lib/trap' - -import { enginelessExecutor } from '../../lib/testHelpers' import { - Expr, - Program, assertParse, - initPromise, + Expr, recast, + initPromise, + Program, topLevelRange, } from '../wasm' +import { + getConstraintType, + getTransformInfos, + transformAstSketchLines, + transformSecondarySketchLinesTagFirst, + ConstraintType, + ConstraintLevel, + getConstraintLevelFromSourceRange, +} from './sketchcombos' +import { ToolTip } from 'lang/langHelpers' +import { Selections, Selection } from 'lib/selections' +import { err } from 'lib/trap' +import { enginelessExecutor } from '../../lib/testHelpers' import { codeRefFromRange } from './artifactGraph' +import { findKwArg } from 'lang/util' import { ARG_END, ARG_END_ABSOLUTE, getArgForEnd, isAbsoluteLine, } from './sketch' -import { - ConstraintLevel, - ConstraintType, - getConstraintLevelFromSourceRange, - getConstraintType, - getTransformInfos, - transformAstSketchLines, - transformSecondarySketchLinesTagFirst, -} from './sketchcombos' beforeAll(async () => { await initPromise diff --git a/src/lang/std/sketchcombos.ts b/src/lang/std/sketchcombos.ts index 0089882d4..a5ba6029a 100644 --- a/src/lang/std/sketchcombos.ts +++ b/src/lang/std/sketchcombos.ts @@ -1,12 +1,31 @@ +import { + CreatedSketchExprResult, + CreateStdLibSketchCallExpr, + InputArg, + InputArgs, + SimplifiedArgDetails, + TransformInfo, +} from './stdTypes' import { ToolTip, toolTips } from 'lang/langHelpers' -import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' -import { findKwArg, findKwArgAny } from 'lang/util' import { Selections } from 'lib/selections' import { cleanErrs, err } from 'lib/trap' - -import { Node } from '@rust/kcl-lib/bindings/Node' - -import { getAngle, isArray, normaliseAngle, roundOff } from '../../lib/utils' +import { + CallExpression, + CallExpressionKw, + Program, + Expr, + BinaryPart, + VariableDeclarator, + PathToNode, + sketchFromKclValue, + Literal, + SourceRange, + LiteralValue, + LabeledArg, + VariableMap, +} from '../wasm' +import { getNodeFromPath, getNodeFromPathCurry } from '../queryAst' +import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' import { createArrayExpression, createBinaryExpression, @@ -22,51 +41,30 @@ import { createUnaryExpression, giveSketchFnCallTag, } from '../modifyAst' -import { getNodeFromPath, getNodeFromPathCurry } from '../queryAst' -import { - BinaryPart, - CallExpression, - CallExpressionKw, - Expr, - LabeledArg, - Literal, - LiteralValue, - PathToNode, - Program, - SourceRange, - VariableDeclarator, - VariableMap, - sketchFromKclValue, -} from '../wasm' import { + createFirstArg, + getConstraintInfo, + getFirstArg, + getArgForEnd, + replaceSketchLine, + ARG_TAG, ARG_END, ARG_END_ABSOLUTE, - ARG_LENGTH, - ARG_TAG, - DETERMINING_ARGS, - createFirstArg, - fnNameToTooltip, - getArgForEnd, - getCircle, - getConstraintInfo, getConstraintInfoKw, - getFirstArg, isAbsoluteLine, - replaceSketchLine, + getCircle, + ARG_LENGTH, tooltipToFnName, + fnNameToTooltip, + DETERMINING_ARGS, } from './sketch' import { getSketchSegmentFromPathToNode, getSketchSegmentFromSourceRange, } from './sketchConstraints' -import { - CreateStdLibSketchCallExpr, - CreatedSketchExprResult, - InputArg, - InputArgs, - SimplifiedArgDetails, - TransformInfo, -} from './stdTypes' +import { getAngle, roundOff, normaliseAngle, isArray } from '../../lib/utils' +import { Node } from '@rust/kcl-lib/bindings/Node' +import { findKwArg, findKwArgAny } from 'lang/util' export type LineInputsType = | 'xAbsolute' @@ -324,8 +322,8 @@ const xyLineSetLength = const lineVal = forceValueUsedInTransform ? forceValueUsedInTransform : referenceSeg - ? segRef - : args[0].expr + ? segRef + : args[0].expr const literalArg = asNum(args[0].expr.value) if (err(literalArg)) return literalArg return createCallWrapper(xOrY, lineVal, tag, literalArg) @@ -353,18 +351,18 @@ const basicAngledLineCreateNode = varValToUse === 'ang' ? inputs[0].expr : referenceSeg === 'ang' - ? getClosesAngleDirection( - argValue, - refAng, - createSegAngle(referenceSegName) - ) - : args[0].expr + ? getClosesAngleDirection( + argValue, + refAng, + createSegAngle(referenceSegName) + ) + : args[0].expr const nonForcedLen = varValToUse === 'len' ? inputs[1].expr : referenceSeg === 'len' - ? createSegLen(referenceSegName) - : args[1].expr + ? createSegLen(referenceSegName) + : args[1].expr const shouldForceAng = valToForce === 'ang' && forceValueUsedInTransform const shouldForceLen = valToForce === 'len' && forceValueUsedInTransform const literalArg = asNum( @@ -680,13 +678,13 @@ const setAngleBetweenCreateNode = tranformToType === 'none' ? 'angledLine' : tranformToType === 'xAbs' - ? 'angledLineToX' - : 'angledLineToY', + ? 'angledLineToX' + : 'angledLineToY', tranformToType === 'none' ? [binExp, args[1].expr] : tranformToType === 'xAbs' - ? [binExp, inputs[0].expr] - : [binExp, inputs[1].expr], + ? [binExp, inputs[0].expr] + : [binExp, inputs[1].expr], tag, valueUsedInTransform ) @@ -2106,17 +2104,17 @@ export function transformAstSketchLines({ ccw: true, // Default to counter-clockwise for circles } : seg.type === 'CircleThreePoint' || seg.type === 'ArcThreePoint' - ? { - type: 'circle-three-point-segment', - p1: seg.p1, - p2: seg.p2, - p3: seg.p3, - } - : { - type: 'straight-segment', - to, - from, - }, + ? { + type: 'circle-three-point-segment', + p1: seg.p1, + p2: seg.p2, + p3: seg.p3, + } + : { + type: 'straight-segment', + to, + from, + }, replaceExistingCallback: (rawArgs) => callBack({ diff --git a/src/lang/std/std.test.ts b/src/lang/std/std.test.ts index 3fcae9f6f..f18183ab2 100644 --- a/src/lang/std/std.test.ts +++ b/src/lang/std/std.test.ts @@ -1,5 +1,5 @@ -import { enginelessExecutor } from '../../lib/testHelpers' import { assertParse, initPromise } from '../wasm' +import { enginelessExecutor } from '../../lib/testHelpers' beforeAll(async () => { await initPromise diff --git a/src/lang/std/stdTypes.ts b/src/lang/std/stdTypes.ts index be9f68bd7..c29c5e677 100644 --- a/src/lang/std/stdTypes.ts +++ b/src/lang/std/stdTypes.ts @@ -1,20 +1,18 @@ import { ToolTip } from 'lang/langHelpers' - -import { Node } from '@rust/kcl-lib/bindings/Node' - import { - BinaryPart, - CallExpression, - CallExpressionKw, - Expr, - Literal, Path, - PathToNode, - Program, SourceRange, + Program, + Expr, + PathToNode, + CallExpression, + Literal, + BinaryPart, + CallExpressionKw, VariableMap, } from '../wasm' import { LineInputsType } from './sketchcombos' +import { Node } from '@rust/kcl-lib/bindings/Node' export interface ModifyAstBase { node: Node diff --git a/src/lang/util.ts b/src/lang/util.ts index 96c823f64..aa91956c6 100644 --- a/src/lang/util.ts +++ b/src/lang/util.ts @@ -1,19 +1,18 @@ -import { filterArtifacts, getFaceCodeRef } from 'lang/std/artifactGraph' import { Selections } from 'lib/selections' -import { isArray, isOverlap } from 'lib/utils' - import { - ArrayExpression, - ArtifactGraph, - BinaryExpression, + PathToNode, CallExpression, + Literal, + ArrayExpression, + BinaryExpression, + ArtifactGraph, CallExpressionKw, Expr, - Literal, LiteralValue, NumericSuffix, - PathToNode, } from './wasm' +import { filterArtifacts, getFaceCodeRef } from 'lang/std/artifactGraph' +import { isArray, isOverlap } from 'lib/utils' /** * Updates pathToNode body indices to account for the insertion of an expression @@ -82,12 +81,12 @@ export function isCursorInSketchCommandRange( firstEntry?.type === 'segment' ? firstEntry.pathId : ((firstEntry?.type === 'plane' || - firstEntry?.type === 'cap' || - firstEntry?.type === 'wall') && - firstEntry.pathIds?.length) || - false - ? firstEntry.pathIds[0] - : false + firstEntry?.type === 'cap' || + firstEntry?.type === 'wall') && + firstEntry.pathIds?.length) || + false + ? firstEntry.pathIds[0] + : false return parentId ? parentId diff --git a/src/lang/wasm.test.ts b/src/lang/wasm.test.ts index aeeb181b3..e792085c5 100644 --- a/src/lang/wasm.test.ts +++ b/src/lang/wasm.test.ts @@ -1,11 +1,9 @@ -import { enginelessExecutor } from 'lib/testHelpers' import { err } from 'lib/trap' - +import { formatNumber, initPromise, parse, ParseResult } from './wasm' +import { enginelessExecutor } from 'lib/testHelpers' import { Node } from '@rust/kcl-lib/bindings/Node' import { Program } from '@rust/kcl-lib/bindings/Program' -import { ParseResult, formatNumber, initPromise, parse } from './wasm' - beforeEach(async () => { await initPromise }) diff --git a/src/lang/wasm.ts b/src/lang/wasm.ts index 2039260b9..861264234 100644 --- a/src/lang/wasm.ts +++ b/src/lang/wasm.ts @@ -1,66 +1,65 @@ +import { + init, + parse_wasm, + recast_wasm, + format_number, + kcl_lint, + is_points_ccw, + get_tangential_arc_to_info, + get_kcl_version, + coredump, + default_app_settings, + parse_app_settings, + parse_project_settings, + default_project_settings, + base64_decode, + kcl_settings, + change_kcl_settings, + serialize_project_configuration, + serialize_configuration, + reloadModule, + is_kcl_empty_or_only_settings, +} from 'lib/wasm_lib_wrapper' + +import { KCLError } from './errors' +import { KclError as RustKclError } from '@rust/kcl-lib/bindings/KclError' +import { Discovered } from '@rust/kcl-lib/bindings/Discovered' +import { KclValue } from '@rust/kcl-lib/bindings/KclValue' +import type { Program } from '@rust/kcl-lib/bindings/Program' +import { Coords2d } from './std/sketch' +import { CoreDumpInfo } from '@rust/kcl-lib/bindings/CoreDumpInfo' +import { CoreDumpManager } from 'lib/coredump' +import openWindow from 'lib/openWindow' import { TEST } from 'env' +import { err, Reason } from 'lib/trap' +import { Configuration } from '@rust/kcl-lib/bindings/Configuration' +import { DeepPartial } from 'lib/types' +import { ProjectConfiguration } from '@rust/kcl-lib/bindings/ProjectConfiguration' +import { Sketch } from '@rust/kcl-lib/bindings/Sketch' +import { ExecOutcome as RustExecOutcome } from '@rust/kcl-lib/bindings/ExecOutcome' +import { Node } from '@rust/kcl-lib/bindings/Node' +import { CompilationError } from '@rust/kcl-lib/bindings/CompilationError' +import { SourceRange } from '@rust/kcl-lib/bindings/SourceRange' +import { getAllCurrentSettings } from 'lib/settings/settingsUtils' +import { Operation } from '@rust/kcl-lib/bindings/Operation' +import { KclErrorWithOutputs } from '@rust/kcl-lib/bindings/KclErrorWithOutputs' +import { ArtifactId } from '@rust/kcl-lib/bindings/Artifact' +import { ArtifactCommand } from '@rust/kcl-lib/bindings/Artifact' +import { ArtifactGraph as RustArtifactGraph } from '@rust/kcl-lib/bindings/Artifact' +import { Artifact } from './std/artifactGraph' import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' +import { NumericSuffix } from '@rust/kcl-lib/bindings/NumericSuffix' +import { MetaSettings } from '@rust/kcl-lib/bindings/MetaSettings' +import { UnitAngle, UnitLength } from '@rust/kcl-lib/bindings/ModelingCmd' +import { UnitLen } from '@rust/kcl-lib/bindings/UnitLen' +import { UnitAngle as UnitAng } from '@rust/kcl-lib/bindings/UnitAngle' +import { ModulePath } from '@rust/kcl-lib/bindings/ModulePath' +import { DefaultPlanes } from '@rust/kcl-lib/bindings/DefaultPlanes' +import { isArray } from 'lib/utils' import { DEFAULT_DEFAULT_ANGLE_UNIT, DEFAULT_DEFAULT_LENGTH_UNIT, } from 'lib/constants' -import { CoreDumpManager } from 'lib/coredump' -import openWindow from 'lib/openWindow' -import { getAllCurrentSettings } from 'lib/settings/settingsUtils' -import { Reason, err } from 'lib/trap' -import { DeepPartial } from 'lib/types' -import { isArray } from 'lib/utils' -import { - base64_decode, - change_kcl_settings, - coredump, - default_app_settings, - default_project_settings, - format_number, - get_kcl_version, - get_tangential_arc_to_info, - init, - is_kcl_empty_or_only_settings, - is_points_ccw, - kcl_lint, - kcl_settings, - parse_app_settings, - parse_project_settings, - parse_wasm, - recast_wasm, - reloadModule, - serialize_configuration, - serialize_project_configuration, -} from 'lib/wasm_lib_wrapper' - -import { ArtifactId } from '@rust/kcl-lib/bindings/Artifact' -import { ArtifactCommand } from '@rust/kcl-lib/bindings/Artifact' -import { ArtifactGraph as RustArtifactGraph } from '@rust/kcl-lib/bindings/Artifact' -import { CompilationError } from '@rust/kcl-lib/bindings/CompilationError' -import { Configuration } from '@rust/kcl-lib/bindings/Configuration' -import { CoreDumpInfo } from '@rust/kcl-lib/bindings/CoreDumpInfo' -import { DefaultPlanes } from '@rust/kcl-lib/bindings/DefaultPlanes' -import { Discovered } from '@rust/kcl-lib/bindings/Discovered' -import { ExecOutcome as RustExecOutcome } from '@rust/kcl-lib/bindings/ExecOutcome' -import { KclError as RustKclError } from '@rust/kcl-lib/bindings/KclError' -import { KclErrorWithOutputs } from '@rust/kcl-lib/bindings/KclErrorWithOutputs' -import { KclValue } from '@rust/kcl-lib/bindings/KclValue' -import { MetaSettings } from '@rust/kcl-lib/bindings/MetaSettings' -import { UnitAngle, UnitLength } from '@rust/kcl-lib/bindings/ModelingCmd' -import { ModulePath } from '@rust/kcl-lib/bindings/ModulePath' -import { Node } from '@rust/kcl-lib/bindings/Node' -import { NumericSuffix } from '@rust/kcl-lib/bindings/NumericSuffix' -import { Operation } from '@rust/kcl-lib/bindings/Operation' -import type { Program } from '@rust/kcl-lib/bindings/Program' -import { ProjectConfiguration } from '@rust/kcl-lib/bindings/ProjectConfiguration' -import { Sketch } from '@rust/kcl-lib/bindings/Sketch' -import { SourceRange } from '@rust/kcl-lib/bindings/SourceRange' -import { UnitAngle as UnitAng } from '@rust/kcl-lib/bindings/UnitAngle' -import { UnitLen } from '@rust/kcl-lib/bindings/UnitLen' - -import { KCLError } from './errors' -import { Artifact } from './std/artifactGraph' -import { Coords2d } from './std/sketch' export type { Artifact } from '@rust/kcl-lib/bindings/Artifact' export type { ArtifactCommand } from '@rust/kcl-lib/bindings/Artifact' diff --git a/src/lib/artifactIndex.ts b/src/lib/artifactIndex.ts index cdb91ffae..19cb92b8a 100644 --- a/src/lib/artifactIndex.ts +++ b/src/lib/artifactIndex.ts @@ -1,5 +1,5 @@ +import { ArtifactGraph, ArtifactId, SourceRange, Artifact } from 'lang/wasm' import { getFaceCodeRef } from 'lang/std/artifactGraph' -import { Artifact, ArtifactGraph, ArtifactId, SourceRange } from 'lang/wasm' // Index artifacts in an ordered list for binary search export type ArtifactEntry = { artifact: Artifact; id: ArtifactId } diff --git a/src/lib/base64.test.ts b/src/lib/base64.test.ts index 503c68f1d..edb7db9d2 100644 --- a/src/lib/base64.test.ts +++ b/src/lib/base64.test.ts @@ -1,5 +1,4 @@ import { expect } from 'vitest' - import { base64ToString, stringToBase64 } from './base64' describe('base64 encoding', () => { diff --git a/src/lib/browserSaveFile.ts b/src/lib/browserSaveFile.ts index 8b98bb6c3..73004d695 100644 --- a/src/lib/browserSaveFile.ts +++ b/src/lib/browserSaveFile.ts @@ -1,8 +1,8 @@ /// The method below uses the File System Access API when it's supported and // else falls back to the classic approach. In both cases the function saves // the file, but in case of where the File System Access API is supported, the -import toast from 'react-hot-toast' +import toast from 'react-hot-toast' import { EXPORT_TOAST_MESSAGES } from './constants' // user will get a file save dialog where they can choose where the file should be saved. diff --git a/src/lib/cameraControls.ts b/src/lib/cameraControls.ts index 5c6162077..00fe4ccd5 100644 --- a/src/lib/cameraControls.ts +++ b/src/lib/cameraControls.ts @@ -1,5 +1,4 @@ import { MouseControlType } from '@rust/kcl-lib/bindings/MouseControlType' - import { platform } from './utils' const PLATFORM = platform() diff --git a/src/lib/commandBarConfigs/modelingCommandConfig.ts b/src/lib/commandBarConfigs/modelingCommandConfig.ts index 0a73924b7..4e8cebf8d 100644 --- a/src/lib/commandBarConfigs/modelingCommandConfig.ts +++ b/src/lib/commandBarConfigs/modelingCommandConfig.ts @@ -1,31 +1,30 @@ import { Models } from '@kittycad/lib' import { angleLengthInfo } from 'components/Toolbar/setAngleLength' -import { DEV } from 'env' -import { getNodeFromPath } from 'lang/queryAst' -import { getVariableDeclaration } from 'lang/queryAst/getVariableDeclaration' -import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' import { transformAstSketchLines } from 'lang/std/sketchcombos' import { + isPathToNode, PathToNode, SourceRange, VariableDeclarator, - isPathToNode, } from 'lang/wasm' -import { KclCommandValue, StateMachineCommandSetConfig } from 'lib/commandTypes' -import { KCL_DEFAULT_DEGREE, KCL_DEFAULT_LENGTH } from 'lib/constants' +import { StateMachineCommandSetConfig, KclCommandValue } from 'lib/commandTypes' +import { KCL_DEFAULT_LENGTH, KCL_DEFAULT_DEGREE } from 'lib/constants' import { components } from 'lib/machine-api' import { Selections } from 'lib/selections' import { codeManager, kclManager } from 'lib/singletons' import { err } from 'lib/trap' -import { SketchTool, modelingMachine } from 'machines/modelingMachine' -import { IS_NIGHTLY_OR_DEBUG } from 'routes/Settings' - +import { modelingMachine, SketchTool } from 'machines/modelingMachine' import { loftValidator, revolveAxisValidator, shellValidator, sweepValidator, } from './validators' +import { getVariableDeclaration } from 'lang/queryAst/getVariableDeclaration' +import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' +import { getNodeFromPath } from 'lang/queryAst' +import { IS_NIGHTLY_OR_DEBUG } from 'routes/Settings' +import { DEV } from 'env' type OutputFormat = Models['OutputFormat3d_type'] type OutputTypeKey = OutputFormat['type'] diff --git a/src/lib/commandBarConfigs/namedViewsConfig.ts b/src/lib/commandBarConfigs/namedViewsConfig.ts index e081ce5d4..a22313366 100644 --- a/src/lib/commandBarConfigs/namedViewsConfig.ts +++ b/src/lib/commandBarConfigs/namedViewsConfig.ts @@ -1,16 +1,14 @@ +import { NamedView } from '@rust/kcl-lib/bindings/NamedView' +import { Command, CommandArgumentOption } from '../commandTypes' +import toast from 'react-hot-toast' +import { engineCommandManager } from 'lib/singletons' +import { uuidv4 } from 'lib/utils' +import { settingsActor, getSettings } from 'machines/appMachine' +import { err, reportRejection } from 'lib/trap' import { CameraViewState_type, WorldCoordinateSystem_type, } from '@kittycad/lib/dist/types/src/models' -import { engineCommandManager } from 'lib/singletons' -import { err, reportRejection } from 'lib/trap' -import { uuidv4 } from 'lib/utils' -import { getSettings, settingsActor } from 'machines/appMachine' -import toast from 'react-hot-toast' - -import { NamedView } from '@rust/kcl-lib/bindings/NamedView' - -import { Command, CommandArgumentOption } from '../commandTypes' function isWorldCoordinateSystemType( x: string diff --git a/src/lib/commandBarConfigs/routeCommandConfig.ts b/src/lib/commandBarConfigs/routeCommandConfig.ts index 5ddc4dd9f..4c058137d 100644 --- a/src/lib/commandBarConfigs/routeCommandConfig.ts +++ b/src/lib/commandBarConfigs/routeCommandConfig.ts @@ -1,8 +1,6 @@ -import { PATHS } from 'lib/paths' -import { Location, NavigateFunction } from 'react-router-dom' - import { Command } from '../commandTypes' - +import { PATHS } from 'lib/paths' +import { NavigateFunction, Location } from 'react-router-dom' export function createRouteCommands( navigate: NavigateFunction, location: Location, diff --git a/src/lib/commandBarConfigs/settingsCommandConfig.ts b/src/lib/commandBarConfigs/settingsCommandConfig.ts index 5b1f243aa..a79b4a29f 100644 --- a/src/lib/commandBarConfigs/settingsCommandConfig.ts +++ b/src/lib/commandBarConfigs/settingsCommandConfig.ts @@ -1,27 +1,26 @@ -import decamelize from 'decamelize' -import { buildCommandArgument } from 'lib/createMachineCommand' -import { isDesktop } from 'lib/isDesktop' -import { getPropertyByPath } from 'lib/objectPropertyByPath' -import { - Setting, - SettingsType, - createSettings, -} from 'lib/settings/initialSettings' -import { - SetEventTypes, - SettingProps, - SettingsLevel, - SettingsPaths, -} from 'lib/settings/settingsTypes' -import { PathValue } from 'lib/types' -import { settingsMachine } from 'machines/settingsMachine' -import { ActorRefFrom, AnyStateMachine } from 'xstate' - import { Command, CommandArgument, CommandArgumentConfig, } from '../commandTypes' +import { + SettingsPaths, + SettingsLevel, + SettingProps, + SetEventTypes, +} from 'lib/settings/settingsTypes' +import { settingsMachine } from 'machines/settingsMachine' +import { PathValue } from 'lib/types' +import { ActorRefFrom, AnyStateMachine } from 'xstate' +import { getPropertyByPath } from 'lib/objectPropertyByPath' +import { buildCommandArgument } from 'lib/createMachineCommand' +import decamelize from 'decamelize' +import { isDesktop } from 'lib/isDesktop' +import { + createSettings, + Setting, + SettingsType, +} from 'lib/settings/initialSettings' // An array of the paths to all of the settings that have commandConfigs export const settingsWithCommandConfigs = (s: SettingsType) => diff --git a/src/lib/commandBarConfigs/validators.ts b/src/lib/commandBarConfigs/validators.ts index c35996b28..b199ced47 100644 --- a/src/lib/commandBarConfigs/validators.ts +++ b/src/lib/commandBarConfigs/validators.ts @@ -1,9 +1,9 @@ import { Models } from '@kittycad/lib' -import { ApiError_type } from '@kittycad/lib/dist/types/src/models' -import { Selections } from 'lib/selections' import { engineCommandManager, kclManager } from 'lib/singletons' import { uuidv4 } from 'lib/utils' import { CommandBarContext } from 'machines/commandBarMachine' +import { Selections } from 'lib/selections' +import { ApiError_type } from '@kittycad/lib/dist/types/src/models' export const disableDryRunWithRetry = async (numberOfRetries = 3) => { for (let tries = 0; tries < numberOfRetries; tries++) { diff --git a/src/lib/commandTypes.ts b/src/lib/commandTypes.ts index 8c7a092f2..026b00865 100644 --- a/src/lib/commandTypes.ts +++ b/src/lib/commandTypes.ts @@ -1,15 +1,14 @@ -import { EntityType_type } from '@kittycad/lib/dist/types/src/models' import { CustomIconName } from 'components/CustomIcon' -import { MachineManager } from 'components/MachineManagerProvider' import { AllMachines } from 'hooks/useStateMachineCommands' -import { Artifact } from 'lang/std/artifactGraph' +import { Actor, AnyStateMachine, ContextFrom, EventFrom } from 'xstate' import { Expr, Name, VariableDeclaration } from 'lang/wasm' import { commandBarMachine } from 'machines/commandBarMachine' -import { CommandBarContext } from 'machines/commandBarMachine' import { ReactNode } from 'react' -import { Actor, AnyStateMachine, ContextFrom, EventFrom } from 'xstate' - +import { MachineManager } from 'components/MachineManagerProvider' import { Node } from '@rust/kcl-lib/bindings/Node' +import { Artifact } from 'lang/std/artifactGraph' +import { CommandBarContext } from 'machines/commandBarMachine' +import { EntityType_type } from '@kittycad/lib/dist/types/src/models' type Icon = CustomIconName const _PLATFORMS = ['both', 'web', 'desktop'] as const @@ -44,7 +43,7 @@ export type StateMachineCommandSetSchema = Partial<{ export type StateMachineCommandSet< T extends AllMachines, - Schema extends StateMachineCommandSetSchema, + Schema extends StateMachineCommandSetSchema > = Partial<{ [EventType in EventFrom['type']]: Command< T, @@ -61,7 +60,7 @@ export type StateMachineCommandSet< */ export type StateMachineCommandSetConfig< T extends AllMachines, - Schema extends StateMachineCommandSetSchema, + Schema extends StateMachineCommandSetSchema > = Partial<{ [EventType in EventFrom['type']]: | CommandConfig['type'], Schema[EventType]> @@ -71,8 +70,7 @@ export type StateMachineCommandSetConfig< export type Command< T extends AnyStateMachine = AnyStateMachine, CommandName extends EventFrom['type'] = EventFrom['type'], - CommandSchema extends - StateMachineCommandSetSchema[CommandName] = StateMachineCommandSetSchema[CommandName], + CommandSchema extends StateMachineCommandSetSchema[CommandName] = StateMachineCommandSetSchema[CommandName] > = { name: CommandName groupId: T['id'] @@ -98,8 +96,7 @@ export type Command< export type CommandConfig< T extends AnyStateMachine = AnyStateMachine, CommandName extends EventFrom['type'] = EventFrom['type'], - CommandSchema extends - StateMachineCommandSetSchema[CommandName] = StateMachineCommandSetSchema[CommandName], + CommandSchema extends StateMachineCommandSetSchema[CommandName] = StateMachineCommandSetSchema[CommandName] > = Omit< Command, 'name' | 'groupId' | 'onSubmit' | 'onCancel' | 'args' | 'needsReview' @@ -116,7 +113,7 @@ export type CommandConfig< export type CommandArgumentConfig< OutputType, - C = ContextFrom, + C = ContextFrom > = { displayName?: string description?: string @@ -242,7 +239,7 @@ export type CommandArgumentConfig< export type CommandArgument< OutputType, - T extends AnyStateMachine = AnyStateMachine, + T extends AnyStateMachine = AnyStateMachine > = { displayName?: string description?: string @@ -363,7 +360,7 @@ export type CommandArgument< export type CommandArgumentWithName< OutputType, - T extends AnyStateMachine = AnyStateMachine, + T extends AnyStateMachine = AnyStateMachine > = CommandArgument & { name: string } diff --git a/src/lib/commandUtils.ts b/src/lib/commandUtils.ts index 2fe74032d..ec7bdb59d 100644 --- a/src/lib/commandUtils.ts +++ b/src/lib/commandUtils.ts @@ -2,6 +2,7 @@ // That object also contains some metadata about what to do with the KCL expression, // such as whether we need to create a new variable for it. // This function extracts the value field from those arg payloads and returns + import { Command } from './commandTypes' // The arg object with all its field as natural values that the command to be executed will expect. diff --git a/src/lib/constants.ts b/src/lib/constants.ts index ad4c015d9..3731990b0 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -1,5 +1,4 @@ import { Models } from '@kittycad/lib/dist/types/src' - import { UnitAngle, UnitLength } from '@rust/kcl-lib/bindings/ModelingCmd' export const APP_NAME = 'Modeling App' diff --git a/src/lib/coredump.ts b/src/lib/coredump.ts index bc46eacf5..326cd4871 100644 --- a/src/lib/coredump.ts +++ b/src/lib/coredump.ts @@ -1,14 +1,13 @@ -import { VITE_KC_API_BASE_URL } from 'env' -import CodeManager from 'lang/codeManager' import { CommandLog, EngineCommandManager } from 'lang/std/engineConnection' +import { WebrtcStats } from '@rust/kcl-lib/bindings/WebrtcStats' +import { OsInfo } from '@rust/kcl-lib/bindings/OsInfo' import { isDesktop } from 'lib/isDesktop' -import RustContext from 'lib/rustContext' -import screenshot from 'lib/screenshot' import { APP_VERSION } from 'routes/Settings' import { UAParser } from 'ua-parser-js' - -import { OsInfo } from '@rust/kcl-lib/bindings/OsInfo' -import { WebrtcStats } from '@rust/kcl-lib/bindings/WebrtcStats' +import screenshot from 'lib/screenshot' +import { VITE_KC_API_BASE_URL } from 'env' +import CodeManager from 'lang/codeManager' +import RustContext from 'lib/rustContext' /* eslint-disable suggest-no-throw/suggest-no-throw -- * All the throws in CoreDumpManager are intentional and should be caught and handled properly diff --git a/src/lib/createMachineCommand.ts b/src/lib/createMachineCommand.ts index 82d7089c9..3e0595980 100644 --- a/src/lib/createMachineCommand.ts +++ b/src/lib/createMachineCommand.ts @@ -1,13 +1,11 @@ -import { DEV } from 'env' -import { IS_NIGHTLY_OR_DEBUG } from 'routes/Settings' import { - Actor, AnyStateMachine, ContextFrom, EventFrom, + Actor, StateFrom, } from 'xstate' - +import { isDesktop } from './isDesktop' import { Command, CommandArgument, @@ -16,11 +14,12 @@ import { StateMachineCommandSetConfig, StateMachineCommandSetSchema, } from './commandTypes' -import { isDesktop } from './isDesktop' +import { DEV } from 'env' +import { IS_NIGHTLY_OR_DEBUG } from 'routes/Settings' interface CreateMachineCommandProps< T extends AnyStateMachine, - S extends StateMachineCommandSetSchema, + S extends StateMachineCommandSetSchema > { type: EventFrom['type'] groupId: T['id'] @@ -35,7 +34,7 @@ interface CreateMachineCommandProps< // from a more terse Command Bar Meta definition. export function createMachineCommand< T extends AnyStateMachine, - S extends StateMachineCommandSetSchema, + S extends StateMachineCommandSetSchema >({ groupId, type, @@ -133,7 +132,7 @@ export function createMachineCommand< function buildCommandArguments< T extends AnyStateMachine, S extends StateMachineCommandSetSchema, - CommandName extends EventFrom['type'] = EventFrom['type'], + CommandName extends EventFrom['type'] = EventFrom['type'] >( state: StateFrom, args: CommandConfig['args'], @@ -152,7 +151,7 @@ function buildCommandArguments< export function buildCommandArgument< T extends AnyStateMachine, - O extends StateMachineCommandSetSchema = StateMachineCommandSetSchema, + O extends StateMachineCommandSetSchema = StateMachineCommandSetSchema >( arg: CommandArgumentConfig, context: ContextFrom, diff --git a/src/lib/crossPlatformFetch.ts b/src/lib/crossPlatformFetch.ts index 7e4ac1e9b..7baaa63bc 100644 --- a/src/lib/crossPlatformFetch.ts +++ b/src/lib/crossPlatformFetch.ts @@ -1,6 +1,6 @@ import { DEV } from 'env' -import isomorphicFetch from 'isomorphic-fetch' import { isDesktop } from 'lib/isDesktop' +import isomorphicFetch from 'isomorphic-fetch' // TODO I not sure this file should exist diff --git a/src/lib/desktop.test.ts b/src/lib/desktop.test.ts index 3c6a1234c..2868ceb10 100644 --- a/src/lib/desktop.test.ts +++ b/src/lib/desktop.test.ts @@ -1,9 +1,7 @@ -import { beforeEach, describe, expect, it, vi } from 'vitest' - -import { Configuration } from '@rust/kcl-lib/bindings/Configuration' - +import { vi, describe, it, expect, beforeEach } from 'vitest' import { listProjects } from './desktop' import { DeepPartial } from './types' +import { Configuration } from '@rust/kcl-lib/bindings/Configuration' // Mock the electron window global const mockElectron = { diff --git a/src/lib/desktop.ts b/src/lib/desktop.ts index 1128b136c..0b591d117 100644 --- a/src/lib/desktop.ts +++ b/src/lib/desktop.ts @@ -1,17 +1,13 @@ +import { err } from 'lib/trap' import { Models } from '@kittycad/lib' -import { newKclFile } from 'lang/project' +import { Project, FileEntry } from 'lib/project' + import { defaultAppSettings, initPromise, parseAppSettings, parseProjectSettings, } from 'lang/wasm' -import { FileEntry, Project } from 'lib/project' -import { err } from 'lib/trap' - -import { Configuration } from '@rust/kcl-lib/bindings/Configuration' -import { ProjectConfiguration } from '@rust/kcl-lib/bindings/ProjectConfiguration' - import { DEFAULT_DEFAULT_LENGTH_UNIT, PROJECT_ENTRYPOINT, @@ -24,6 +20,9 @@ import { TOKEN_FILE_NAME, } from './constants' import { DeepPartial } from './types' +import { ProjectConfiguration } from '@rust/kcl-lib/bindings/ProjectConfiguration' +import { Configuration } from '@rust/kcl-lib/bindings/Configuration' +import { newKclFile } from 'lang/project' export async function renameProjectDirectory( projectPath: string, diff --git a/src/lib/desktopFS.ts b/src/lib/desktopFS.ts index f9de5c800..e7b9bf1df 100644 --- a/src/lib/desktopFS.ts +++ b/src/lib/desktopFS.ts @@ -1,19 +1,18 @@ +import { isDesktop } from './isDesktop' +import type { FileEntry } from 'lib/project' import { FILE_EXT, INDEX_IDENTIFIER, MAX_PADDING, ONBOARDING_PROJECT_NAME, } from 'lib/constants' -import type { FileEntry } from 'lib/project' - +import { bracket } from './exampleKcl' +import { PATHS } from './paths' import { createNewProjectDirectory, listProjects, readAppSettingsFile, } from './desktop' -import { bracket } from './exampleKcl' -import { isDesktop } from './isDesktop' -import { PATHS } from './paths' export const isHidden = (fileOrDir: FileEntry) => !!fileOrDir.name?.startsWith('.') diff --git a/src/lib/exceptions.ts b/src/lib/exceptions.ts index 58a83cb7d..d72075221 100644 --- a/src/lib/exceptions.ts +++ b/src/lib/exceptions.ts @@ -1,7 +1,6 @@ import { kclManager } from 'lib/singletons' -import { getModule, reloadModule } from 'lib/wasm_lib_wrapper' +import { reloadModule, getModule } from 'lib/wasm_lib_wrapper' import toast from 'react-hot-toast' - import { reportRejection } from './trap' let initialized = false diff --git a/src/lib/exportMake.ts b/src/lib/exportMake.ts index b2d1f9bac..14ba4fe46 100644 --- a/src/lib/exportMake.ts +++ b/src/lib/exportMake.ts @@ -1,9 +1,8 @@ import { MachineManager } from 'components/MachineManagerProvider' import toast from 'react-hot-toast' - -import { MAKE_TOAST_MESSAGES } from './constants' import { components } from './machine-api' import ModelingAppFile from './modelingAppFile' +import { MAKE_TOAST_MESSAGES } from './constants' // Make files locally from an export call. export async function exportMake({ diff --git a/src/lib/exportSave.ts b/src/lib/exportSave.ts index b778f5679..43683e6da 100644 --- a/src/lib/exportSave.ts +++ b/src/lib/exportSave.ts @@ -1,10 +1,10 @@ -import JSZip from 'jszip' -import toast from 'react-hot-toast' - -import { browserSaveFile } from './browserSaveFile' -import { EXPORT_TOAST_MESSAGES } from './constants' import { isDesktop } from './isDesktop' +import { browserSaveFile } from './browserSaveFile' + +import JSZip from 'jszip' import ModelingAppFile from './modelingAppFile' +import toast from 'react-hot-toast' +import { EXPORT_TOAST_MESSAGES } from './constants' const save_ = async (file: ModelingAppFile, toastId: string) => { try { diff --git a/src/lib/getCurrentProjectFile.test.ts b/src/lib/getCurrentProjectFile.test.ts index 388303b53..78b0cea52 100644 --- a/src/lib/getCurrentProjectFile.test.ts +++ b/src/lib/getCurrentProjectFile.test.ts @@ -1,8 +1,7 @@ import { promises as fs } from 'fs' -import os from 'os' import path from 'path' +import os from 'os' import { v4 as uuidv4 } from 'uuid' - import getCurrentProjectFile from './getCurrentProjectFile' describe('getCurrentProjectFile', () => { diff --git a/src/lib/getCurrentProjectFile.ts b/src/lib/getCurrentProjectFile.ts index b42471ca2..d3638cb26 100644 --- a/src/lib/getCurrentProjectFile.ts +++ b/src/lib/getCurrentProjectFile.ts @@ -1,8 +1,7 @@ -import { Models } from '@kittycad/lib/dist/types/src' -import { Stats } from 'fs' -import * as fs from 'fs/promises' import * as path from 'path' - +import * as fs from 'fs/promises' +import { Stats } from 'fs' +import { Models } from '@kittycad/lib/dist/types/src' import { PROJECT_ENTRYPOINT } from './constants' // Create a const object with the values diff --git a/src/lib/hotkeyWrapper.ts b/src/lib/hotkeyWrapper.ts index 4d7a5d771..ce5bf747e 100644 --- a/src/lib/hotkeyWrapper.ts +++ b/src/lib/hotkeyWrapper.ts @@ -1,6 +1,5 @@ -import { useEffect } from 'react' import { Options, useHotkeys } from 'react-hotkeys-hook' - +import { useEffect } from 'react' import { codeManager } from './singletons' import { Platform } from './utils' diff --git a/src/lib/kclCommands.ts b/src/lib/kclCommands.ts index 63ef23d5b..923c24202 100644 --- a/src/lib/kclCommands.ts +++ b/src/lib/kclCommands.ts @@ -1,24 +1,23 @@ -import { UnitLength_type } from '@kittycad/lib/dist/types/src/models' import { CommandBarOverwriteWarning } from 'components/CommandBarOverwriteWarning' -import { - changeKclSettings, - unitAngleToUnitAng, - unitLengthToUnitLen, -} from 'lang/wasm' -import toast from 'react-hot-toast' - import { Command, CommandArgumentOption } from './commandTypes' +import { codeManager, kclManager } from './singletons' +import { isDesktop } from './isDesktop' import { DEFAULT_DEFAULT_ANGLE_UNIT, DEFAULT_DEFAULT_LENGTH_UNIT, FILE_EXT, } from './constants' -import { isDesktop } from './isDesktop' -import { copyFileShareLink } from './links' -import { baseUnitsUnion } from './settings/settingsTypes' -import { codeManager, kclManager } from './singletons' +import { UnitLength_type } from '@kittycad/lib/dist/types/src/models' import { err, reportRejection } from './trap' import { IndexLoaderData } from './types' +import { copyFileShareLink } from './links' +import { baseUnitsUnion } from './settings/settingsTypes' +import toast from 'react-hot-toast' +import { + changeKclSettings, + unitLengthToUnitLen, + unitAngleToUnitAng, +} from 'lang/wasm' interface OnSubmitProps { sampleName: string diff --git a/src/lib/kclHelpers.test.ts b/src/lib/kclHelpers.test.ts index b322d22ee..18179ed36 100644 --- a/src/lib/kclHelpers.test.ts +++ b/src/lib/kclHelpers.test.ts @@ -1,5 +1,4 @@ import { ParseResult } from 'lang/wasm' - import { getCalculatedKclExpressionValue } from './kclHelpers' describe('KCL expression calculations', () => { diff --git a/src/lib/kclHelpers.ts b/src/lib/kclHelpers.ts index 681b56589..34a65bbf6 100644 --- a/src/lib/kclHelpers.ts +++ b/src/lib/kclHelpers.ts @@ -1,9 +1,8 @@ -import { executeAstMock } from 'lang/langHelpers' +import { err } from './trap' import { parse, resultIsOk } from 'lang/wasm' - +import { executeAstMock } from 'lang/langHelpers' import { KclExpression } from './commandTypes' import { rustContext } from './singletons' -import { err } from './trap' const DUMMY_VARIABLE_NAME = '__result__' diff --git a/src/lib/links.test.ts b/src/lib/links.test.ts index ec6c55309..a65dec09e 100644 --- a/src/lib/links.test.ts +++ b/src/lib/links.test.ts @@ -1,5 +1,4 @@ import { VITE_KC_SITE_APP_URL } from 'env' - import { createCreateFileUrl } from './links' describe(`link creation tests`, () => { diff --git a/src/lib/links.ts b/src/lib/links.ts index 4c93b8bd5..2b31f46eb 100644 --- a/src/lib/links.ts +++ b/src/lib/links.ts @@ -1,10 +1,8 @@ +import { ASK_TO_OPEN_QUERY_PARAM, CREATE_FILE_URL_PARAM } from './constants' +import { stringToBase64 } from './base64' import { VITE_KC_API_BASE_URL, VITE_KC_SITE_APP_URL } from 'env' import toast from 'react-hot-toast' - -import { stringToBase64 } from './base64' -import { ASK_TO_OPEN_QUERY_PARAM, CREATE_FILE_URL_PARAM } from './constants' import { err } from './trap' - export interface FileLinkParams { code: string name: string diff --git a/src/lib/markdown.ts b/src/lib/markdown.ts index 3268cd472..d4afcf746 100644 --- a/src/lib/markdown.ts +++ b/src/lib/markdown.ts @@ -1,5 +1,4 @@ import { MarkedOptions, Renderer, unescape } from '@ts-stack/markdown' - import { openExternalBrowserIfDesktop } from './openWindow' /** diff --git a/src/lib/objectPropertyByPath.ts b/src/lib/objectPropertyByPath.ts index ca164d471..3a9e1ad61 100644 --- a/src/lib/objectPropertyByPath.ts +++ b/src/lib/objectPropertyByPath.ts @@ -2,7 +2,7 @@ import { PathValue, Paths } from './types' export function setPropertyByPath< T extends { [key: string]: any }, - P extends Paths, + P extends Paths >(obj: T, path: P, value: PathValue) { if (typeof path === 'string') { const pList = path.split('.') @@ -25,7 +25,7 @@ export function setPropertyByPath< export function getPropertyByPath< T extends { [key: string]: any }, - P extends Paths, + P extends Paths >(obj: T, path: P): unknown { if (typeof path === 'string') { return path.split('.').reduce((accumulator, currentValue) => { diff --git a/src/lib/openWindow.ts b/src/lib/openWindow.ts index 0c4939794..cc7d8b023 100644 --- a/src/lib/openWindow.ts +++ b/src/lib/openWindow.ts @@ -1,6 +1,5 @@ -import { isDesktop } from 'lib/isDesktop' import { MouseEventHandler } from 'react' - +import { isDesktop } from 'lib/isDesktop' import { reportRejection } from './trap' export const openExternalBrowserIfDesktop = (to?: string) => diff --git a/src/lib/operations.test.ts b/src/lib/operations.test.ts index b2c720691..98f409bda 100644 --- a/src/lib/operations.test.ts +++ b/src/lib/operations.test.ts @@ -1,8 +1,6 @@ import { defaultSourceRange } from 'lang/wasm' - -import { Operation } from '@rust/kcl-lib/bindings/Operation' - import { filterOperations } from './operations' +import { Operation } from '@rust/kcl-lib/bindings/Operation' function stdlib(name: string): Operation { return { diff --git a/src/lib/operations.ts b/src/lib/operations.ts index 81b6a787a..7109488d5 100644 --- a/src/lib/operations.ts +++ b/src/lib/operations.ts @@ -1,5 +1,4 @@ import { CustomIconName } from 'components/CustomIcon' -import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' import { Artifact, getArtifactOfTypes, @@ -8,21 +7,20 @@ import { getSweepEdgeCodeRef, getWallCodeRef, } from 'lang/std/artifactGraph' +import { Operation } from '@rust/kcl-lib/bindings/Operation' +import { codeManager, kclManager, rustContext } from './singletons' +import { err } from './trap' +import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' import { sourceRangeFromRust } from 'lang/wasm' import { CommandBarMachineEvent } from 'machines/commandBarMachine' - -import { Operation } from '@rust/kcl-lib/bindings/Operation' - +import { stringToKclExpression } from './kclHelpers' import { HelixModes, ModelingCommandSchema, } from './commandBarConfigs/modelingCommandConfig' -import { KclExpression } from './commandTypes' -import { stringToKclExpression } from './kclHelpers' import { isDefaultPlaneStr } from './planes' import { Selection, Selections } from './selections' -import { codeManager, kclManager, rustContext } from './singletons' -import { err } from './trap' +import { KclExpression } from './commandTypes' type ExecuteCommandEvent = CommandBarMachineEvent & { type: 'Find and select command' diff --git a/src/lib/paths.test.ts b/src/lib/paths.test.ts index b970bad9b..a6d8cd7ea 100644 --- a/src/lib/paths.test.ts +++ b/src/lib/paths.test.ts @@ -1,6 +1,5 @@ -import * as path from 'path' - import { parseProjectRoute } from './paths' +import * as path from 'path' describe('testing parseProjectRoute', () => { it('should parse a project as a subpath of project dir', async () => { diff --git a/src/lib/paths.ts b/src/lib/paths.ts index fcd6c3198..7320918f1 100644 --- a/src/lib/paths.ts +++ b/src/lib/paths.ts @@ -1,15 +1,13 @@ -import { err } from 'lib/trap' -import { PlatformPath } from 'path' import { onboardingPaths } from 'routes/Onboarding/paths' - -import { Configuration } from '@rust/kcl-lib/bindings/Configuration' - -import { IS_PLAYWRIGHT_KEY } from '../../e2e/playwright/storageStates' import { BROWSER_FILE_NAME, BROWSER_PROJECT_NAME, FILE_EXT } from './constants' -import { readAppSettingsFile } from './desktop' import { isDesktop } from './isDesktop' +import { readAppSettingsFile } from './desktop' import { readLocalStorageAppSettingsFile } from './settings/settingsUtils' +import { err } from 'lib/trap' +import { IS_PLAYWRIGHT_KEY } from '../../e2e/playwright/storageStates' import { DeepPartial } from './types' +import { Configuration } from '@rust/kcl-lib/bindings/Configuration' +import { PlatformPath } from 'path' const prependRoutes = (routesObject: Record) => (prepend: string) => { diff --git a/src/lib/promptToEdit.ts b/src/lib/promptToEdit.ts index 9ba858df8..1578a428e 100644 --- a/src/lib/promptToEdit.ts +++ b/src/lib/promptToEdit.ts @@ -1,18 +1,17 @@ -import { EditorSelection, SelectionRange, Transaction } from '@codemirror/state' import { Models } from '@kittycad/lib' -import { ToastPromptToEditCadSuccess } from 'components/ToastTextToCad' -import { diffLines } from 'diff' -import { modelingMachineEvent } from 'editor/manager' import { VITE_KC_API_BASE_URL } from 'env' +import crossPlatformFetch from './crossPlatformFetch' +import { err, reportRejection } from './trap' +import { Selections } from './selections' import { getArtifactOfTypes } from 'lang/std/artifactGraph' import { ArtifactGraph, SourceRange, topLevelRange } from 'lang/wasm' import toast from 'react-hot-toast' - -import crossPlatformFetch from './crossPlatformFetch' -import { Selections } from './selections' import { codeManager, editorManager, kclManager } from './singletons' -import { err, reportRejection } from './trap' +import { ToastPromptToEditCadSuccess } from 'components/ToastTextToCad' import { uuidv4 } from './utils' +import { diffLines } from 'diff' +import { Transaction, EditorSelection, SelectionRange } from '@codemirror/state' +import { modelingMachineEvent } from 'editor/manager' function sourceIndexToLineColumn( code: string, diff --git a/src/lib/rectangleTool.test.ts b/src/lib/rectangleTool.test.ts index 286def13c..33010c130 100644 --- a/src/lib/rectangleTool.test.ts +++ b/src/lib/rectangleTool.test.ts @@ -1,15 +1,14 @@ -import { getNodeFromPath } from 'lang/queryAst' -import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' -import { - VariableDeclaration, - assertParse, - initPromise, - recast, - topLevelRange, -} from 'lang/wasm' import { expect } from 'vitest' - +import { + recast, + assertParse, + topLevelRange, + VariableDeclaration, + initPromise, +} from 'lang/wasm' import { updateCenterRectangleSketch } from './rectangleTool' +import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' +import { getNodeFromPath } from 'lang/queryAst' import { trap } from './trap' beforeAll(async () => { diff --git a/src/lib/rectangleTool.ts b/src/lib/rectangleTool.ts index 06814c307..bb8509e94 100644 --- a/src/lib/rectangleTool.ts +++ b/src/lib/rectangleTool.ts @@ -10,16 +10,16 @@ import { createTagDeclarator, createUnaryExpression, } from 'lang/modifyAst' -import { ARG_END_ABSOLUTE } from 'lang/std/sketch' -import { - isArrayExpression, - isBinaryExpression, - isCallExpression, - isLiteral, - isLiteralValueNumber, -} from 'lang/util' import { ArrayExpression, CallExpression, PipeExpression } from 'lang/wasm' import { roundOff } from 'lib/utils' +import { + isCallExpression, + isArrayExpression, + isLiteral, + isBinaryExpression, + isLiteralValueNumber, +} from 'lang/util' +import { ARG_END_ABSOLUTE } from 'lang/std/sketch' /** * It does not create the startSketchOn and it does not create the startProfileAt. diff --git a/src/lib/routeLoaders.ts b/src/lib/routeLoaders.ts index 5ef1fc3d6..7da9a221a 100644 --- a/src/lib/routeLoaders.ts +++ b/src/lib/routeLoaders.ts @@ -1,22 +1,21 @@ -import { fileSystemManager } from 'lang/std/fileSystemManager' -import { normalizeLineEndings } from 'lib/codeEditor' +import { LoaderFunction, redirect } from 'react-router-dom' +import { FileLoaderData, HomeLoaderData, IndexLoaderData } from './types' +import { getProjectMetaByRouteId, PATHS } from './paths' +import { isDesktop } from './isDesktop' +import { BROWSER_PATH } from 'lib/paths' import { BROWSER_FILE_NAME, BROWSER_PROJECT_NAME, FILE_EXT, PROJECT_ENTRYPOINT, } from 'lib/constants' -import { BROWSER_PATH } from 'lib/paths' -import { codeManager } from 'lib/singletons' -import { settingsActor } from 'machines/appMachine' -import { LoaderFunction, redirect } from 'react-router-dom' -import { waitFor } from 'xstate' - -import { getProjectInfo } from './desktop' -import { isDesktop } from './isDesktop' -import { PATHS, getProjectMetaByRouteId } from './paths' import { loadAndValidateSettings } from './settings/settingsUtils' -import { FileLoaderData, HomeLoaderData, IndexLoaderData } from './types' +import { codeManager } from 'lib/singletons' +import { fileSystemManager } from 'lang/std/fileSystemManager' +import { getProjectInfo } from './desktop' +import { normalizeLineEndings } from 'lib/codeEditor' +import { settingsActor } from 'machines/appMachine' +import { waitFor } from 'xstate' export const telemetryLoader: LoaderFunction = async ({ params, diff --git a/src/lib/rustContext.ts b/src/lib/rustContext.ts index 41d3fe42a..4f29bc3cf 100644 --- a/src/lib/rustContext.ts +++ b/src/lib/rustContext.ts @@ -1,27 +1,25 @@ -import { EngineCommandManager } from 'lang/std/engineConnection' -import { fileSystemManager } from 'lang/std/fileSystemManager' import { - ExecState, errFromErrWithOutputs, + ExecState, execStateFromRust, initPromise, mockExecStateFromRust, } from 'lang/wasm' -import { DefaultPlaneStr, defaultPlaneStrToKey } from 'lib/planes' -import { err } from 'lib/trap' -import { DeepPartial } from 'lib/types' -import { ModuleType, getModule } from 'lib/wasm_lib_wrapper' -import toast from 'react-hot-toast' - +import { getModule, ModuleType } from 'lib/wasm_lib_wrapper' +import { fileSystemManager } from 'lang/std/fileSystemManager' import type { Configuration } from '@rust/kcl-lib/bindings/Configuration' -import { DefaultPlanes } from '@rust/kcl-lib/bindings/DefaultPlanes' -import { KclError as RustKclError } from '@rust/kcl-lib/bindings/KclError' -import { OutputFormat3d } from '@rust/kcl-lib/bindings/ModelingCmd' +import { DeepPartial } from 'lib/types' import { Node } from '@rust/kcl-lib/bindings/Node' import type { Program } from '@rust/kcl-lib/bindings/Program' import { Context } from '@rust/kcl-wasm-lib/pkg/kcl_wasm_lib' - +import { DefaultPlanes } from '@rust/kcl-lib/bindings/DefaultPlanes' +import { DefaultPlaneStr, defaultPlaneStrToKey } from 'lib/planes' +import { err } from 'lib/trap' +import { EngineCommandManager } from 'lang/std/engineConnection' +import { OutputFormat3d } from '@rust/kcl-lib/bindings/ModelingCmd' import ModelingAppFile from './modelingAppFile' +import toast from 'react-hot-toast' +import { KclError as RustKclError } from '@rust/kcl-lib/bindings/KclError' export default class RustContext { private wasmInitFailed: boolean = true diff --git a/src/lib/selections.test.ts b/src/lib/selections.test.ts index 667eabc04..545dfd2d5 100644 --- a/src/lib/selections.test.ts +++ b/src/lib/selections.test.ts @@ -1,14 +1,13 @@ -import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' -import { Artifact } from 'lang/std/artifactGraph' -import { ArtifactGraph, SourceRange, assertParse, initPromise } from 'lang/wasm' import { expect } from 'vitest' - -import { ArtifactIndex, buildArtifactIndex } from './artifactIndex' +import { assertParse, initPromise, ArtifactGraph, SourceRange } from 'lang/wasm' +import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' import { - Selection, codeToIdSelections, + Selection, findLastRangeStartingBefore, } from './selections' +import { buildArtifactIndex, ArtifactIndex } from './artifactIndex' +import { Artifact } from 'lang/std/artifactGraph' beforeAll(async () => { await initPromise diff --git a/src/lib/selections.ts b/src/lib/selections.ts index c002883ae..0fb624f17 100644 --- a/src/lib/selections.ts +++ b/src/lib/selections.ts @@ -1,47 +1,45 @@ -import { EditorSelection, SelectionRange } from '@codemirror/state' import { Models } from '@kittycad/lib' -import { - SEGMENT_BODIES_PLUS_PROFILE_START, - getParentGroup, -} from 'clientSideScene/sceneEntities' -import { AXIS_GROUP, X_AXIS } from 'clientSideScene/sceneInfra' -import { getNodeFromPath, isSingleCursorInPipe } from 'lang/queryAst' -import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' -import { - Artifact, - ArtifactId, - CodeRef, - getCodeRefsByArtifactId, -} from 'lang/std/artifactGraph' -import { PathToNodeMap } from 'lang/std/sketchcombos' -import { isCursorInSketchCommandRange } from 'lang/util' -import { - ArtifactGraph, - CallExpression, - CallExpressionKw, - Expr, - SourceRange, - defaultSourceRange, - topLevelRange, -} from 'lang/wasm' -import { Program } from 'lang/wasm' import { codeManager, engineCommandManager, kclManager, sceneEntitiesManager, } from 'lib/singletons' -import { err } from 'lib/trap' -import { isNonNullable, uuidv4 } from 'lib/utils' -import { getNormalisedCoordinates, isOverlap } from 'lib/utils' +import { + CallExpression, + SourceRange, + Expr, + defaultSourceRange, + topLevelRange, + ArtifactGraph, + CallExpressionKw, +} from 'lang/wasm' import { ModelingMachineEvent } from 'machines/modelingMachine' -import { Mesh, Object3D, Object3DEventMap } from 'three' - -import { Node } from '@rust/kcl-lib/bindings/Node' - -import { ArtifactEntry, ArtifactIndex } from './artifactIndex' +import { isNonNullable, uuidv4 } from 'lib/utils' +import { EditorSelection, SelectionRange } from '@codemirror/state' +import { getNormalisedCoordinates, isOverlap } from 'lib/utils' +import { isCursorInSketchCommandRange } from 'lang/util' +import { Program } from 'lang/wasm' +import { getNodeFromPath, isSingleCursorInPipe } from 'lang/queryAst' +import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' import { CommandArgument } from './commandTypes' +import { + getParentGroup, + SEGMENT_BODIES_PLUS_PROFILE_START, +} from 'clientSideScene/sceneEntities' +import { Mesh, Object3D, Object3DEventMap } from 'three' +import { AXIS_GROUP, X_AXIS } from 'clientSideScene/sceneInfra' +import { PathToNodeMap } from 'lang/std/sketchcombos' +import { err } from 'lib/trap' +import { + Artifact, + CodeRef, + getCodeRefsByArtifactId, + ArtifactId, +} from 'lang/std/artifactGraph' +import { Node } from '@rust/kcl-lib/bindings/Node' import { DefaultPlaneStr } from './planes' +import { ArtifactEntry, ArtifactIndex } from './artifactIndex' import { rustContext } from './singletons' export const X_AXIS_UUID = 'ad792545-7fd3-482a-a602-a93924e3055b' diff --git a/src/lib/settings/initialSettings.tsx b/src/lib/settings/initialSettings.tsx index de6444b6a..21bccdb79 100644 --- a/src/lib/settings/initialSettings.tsx +++ b/src/lib/settings/initialSettings.tsx @@ -1,13 +1,4 @@ -import { CustomIcon } from 'components/CustomIcon' -import Tooltip from 'components/Tooltip' -import { - CameraSystem, - cameraMouseDragGuards, - cameraSystems, -} from 'lib/cameraControls' import { DEFAULT_PROJECT_NAME } from 'lib/constants' -import { DEFAULT_DEFAULT_LENGTH_UNIT } from 'lib/constants' -import { isDesktop } from 'lib/isDesktop' import { BaseUnit, SettingProps, @@ -15,15 +6,23 @@ import { baseUnitsUnion, } from 'lib/settings/settingsTypes' import { Themes } from 'lib/theme' -import { reportRejection } from 'lib/trap' import { isEnumMember } from 'lib/types' -import { isArray, toSync } from 'lib/utils' +import { + CameraSystem, + cameraMouseDragGuards, + cameraSystems, +} from 'lib/cameraControls' +import { isDesktop } from 'lib/isDesktop' import { useRef } from 'react' - -import { CameraOrbitType } from '@rust/kcl-lib/bindings/CameraOrbitType' +import { CustomIcon } from 'components/CustomIcon' +import Tooltip from 'components/Tooltip' +import { isArray, toSync } from 'lib/utils' +import { reportRejection } from 'lib/trap' import { CameraProjectionType } from '@rust/kcl-lib/bindings/CameraProjectionType' -import { NamedView } from '@rust/kcl-lib/bindings/NamedView' import { OnboardingStatus } from '@rust/kcl-lib/bindings/OnboardingStatus' +import { NamedView } from '@rust/kcl-lib/bindings/NamedView' +import { CameraOrbitType } from '@rust/kcl-lib/bindings/CameraOrbitType' +import { DEFAULT_DEFAULT_LENGTH_UNIT } from 'lib/constants' /** * A setting that can be set at the user or project level @@ -92,8 +91,8 @@ export class Setting { return this._project !== undefined ? this._project : this._user !== undefined - ? this._user - : this._default + ? this._user + : this._default } /** * @param {SettingsLevel} level - The level to get the fallback for diff --git a/src/lib/settings/settingsTypes.ts b/src/lib/settings/settingsTypes.ts index 1244e3fd3..bbf17ec4a 100644 --- a/src/lib/settings/settingsTypes.ts +++ b/src/lib/settings/settingsTypes.ts @@ -1,16 +1,14 @@ import { type Models } from '@kittycad/lib' +import { Setting, settings } from './initialSettings' +import { AtLeast, PathValue, Paths } from 'lib/types' +import { CommandArgumentConfig } from 'lib/commandTypes' +import { Themes } from 'lib/theme' +import { CameraProjectionType } from '@rust/kcl-lib/bindings/CameraProjectionType' import { UnitAngle_type, UnitLength_type, } from '@kittycad/lib/dist/types/src/models' -import { CommandArgumentConfig } from 'lib/commandTypes' -import { Themes } from 'lib/theme' -import { AtLeast, PathValue, Paths } from 'lib/types' - import { CameraOrbitType } from '@rust/kcl-lib/bindings/CameraOrbitType' -import { CameraProjectionType } from '@rust/kcl-lib/bindings/CameraProjectionType' - -import { Setting, settings } from './initialSettings' export interface SettingsViaQueryString { pool: string | null diff --git a/src/lib/settings/settingsUtils.test.ts b/src/lib/settings/settingsUtils.test.ts index de28f6f94..3994662f7 100644 --- a/src/lib/settings/settingsUtils.test.ts +++ b/src/lib/settings/settingsUtils.test.ts @@ -1,14 +1,12 @@ import { DeepPartial } from 'lib/types' - import { Configuration } from '@rust/kcl-lib/bindings/Configuration' - -import { createSettings } from './initialSettings' import { configurationToSettingsPayload, getAllCurrentSettings, projectConfigurationToSettingsPayload, setSettingsAtLevel, } from './settingsUtils' +import { createSettings } from './initialSettings' describe(`testing settings initialization`, () => { it(`sets settings at the 'user' level`, () => { diff --git a/src/lib/settings/settingsUtils.ts b/src/lib/settings/settingsUtils.ts index 4f0af2528..a3cf9f6f6 100644 --- a/src/lib/settings/settingsUtils.ts +++ b/src/lib/settings/settingsUtils.ts @@ -21,11 +21,9 @@ import { Setting, createSettings, settings } from 'lib/settings/initialSettings' import { appThemeToTheme } from 'lib/theme' import { err } from 'lib/trap' import { DeepPartial } from 'lib/types' - import { Configuration } from '@rust/kcl-lib/bindings/Configuration' -import { NamedView } from '@rust/kcl-lib/bindings/NamedView' import { ProjectConfiguration } from '@rust/kcl-lib/bindings/ProjectConfiguration' - +import { NamedView } from '@rust/kcl-lib/bindings/NamedView' import { SaveSettingsPayload, SettingsLevel } from './settingsTypes' /** diff --git a/src/lib/singletons.ts b/src/lib/singletons.ts index 87fcd5688..c54c5d662 100644 --- a/src/lib/singletons.ts +++ b/src/lib/singletons.ts @@ -4,9 +4,8 @@ import EditorManager from 'editor/manager' import { KclManager } from 'lang/KclSingleton' import CodeManager from 'lang/codeManager' import { EngineCommandManager } from 'lang/std/engineConnection' -import RustContext from 'lib/rustContext' - import { uuidv4 } from './utils' +import RustContext from 'lib/rustContext' export const codeManager = new CodeManager() diff --git a/src/lib/tauriFS.test.ts b/src/lib/tauriFS.test.ts index a3167e7ab..b5f7c7640 100644 --- a/src/lib/tauriFS.test.ts +++ b/src/lib/tauriFS.test.ts @@ -1,8 +1,8 @@ -import { MAX_PADDING } from './constants' import { getNextProjectIndex, interpolateProjectNameWithIndex, } from './desktopFS' +import { MAX_PADDING } from './constants' describe('Test project name utility functions', () => { it('interpolates a project name without an index', () => { diff --git a/src/lib/telemetry.test.ts b/src/lib/telemetry.test.ts index 0229d1656..9c1d6b45e 100644 --- a/src/lib/telemetry.test.ts +++ b/src/lib/telemetry.test.ts @@ -1,8 +1,8 @@ import { - MaxWidth, columnWidth, - printDivider, + MaxWidth, printHeader, + printDivider, printRow, } from 'lib/telemetry' diff --git a/src/lib/telemetry.ts b/src/lib/telemetry.ts index dc6507de8..6258d8f89 100644 --- a/src/lib/telemetry.ts +++ b/src/lib/telemetry.ts @@ -1,6 +1,5 @@ -import { writeRawTelemetryFile, writeTelemetryFile } from 'lib/desktop' import { PerformanceMark, getMarks } from 'lib/performance' - +import { writeTelemetryFile, writeRawTelemetryFile } from 'lib/desktop' let args: any = null // Get the longest width of values or column name diff --git a/src/lib/testHelpers.ts b/src/lib/testHelpers.ts index 66df59aa3..b9d70faf9 100644 --- a/src/lib/testHelpers.ts +++ b/src/lib/testHelpers.ts @@ -1,6 +1,5 @@ +import { Program, ExecState, jsAppSettings } from '../lang/wasm' import { Node } from '@rust/kcl-lib/bindings/Node' - -import { ExecState, Program, jsAppSettings } from '../lang/wasm' import { rustContext } from './singletons' export async function enginelessExecutor( diff --git a/src/lib/textToCad.ts b/src/lib/textToCad.ts index b2aec8e46..b9aaef243 100644 --- a/src/lib/textToCad.ts +++ b/src/lib/textToCad.ts @@ -4,19 +4,18 @@ import { ToastTextToCadSuccess, } from 'components/ToastTextToCad' import { VITE_KC_API_BASE_URL } from 'env' -import { isDesktop } from 'lib/isDesktop' -import { fileMachine } from 'machines/fileMachine' import toast from 'react-hot-toast' -import { NavigateFunction } from 'react-router-dom' -import { ContextFrom, EventFrom } from 'xstate' - import { FILE_EXT } from './constants' +import { ContextFrom, EventFrom } from 'xstate' +import { fileMachine } from 'machines/fileMachine' +import { NavigateFunction } from 'react-router-dom' import crossPlatformFetch from './crossPlatformFetch' -import { getNextFileName } from './desktopFS' -import { kclManager } from './singletons' +import { isDesktop } from 'lib/isDesktop' import { Themes } from './theme' +import { getNextFileName } from './desktopFS' import { reportRejection } from './trap' import { toSync } from './utils' +import { kclManager } from './singletons' async function submitTextToCadPrompt( prompt: string, diff --git a/src/lib/types.ts b/src/lib/types.ts index 44a513885..b76a5c8f2 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -1,4 +1,4 @@ -import { FileEntry, Project } from 'lib/project' +import { Project, FileEntry } from 'lib/project' export type IndexLoaderData = { code: string | null @@ -44,30 +44,30 @@ type Prev = [ 18, 19, 20, - ...0[], + ...0[] ] export type Paths = [D] extends [never] ? never : T extends object - ? { - [K in keyof T]-?: K extends string | number - ? `${K}` | Join> - : never - }[keyof T] - : '' + ? { + [K in keyof T]-?: K extends string | number + ? `${K}` | Join> + : never + }[keyof T] + : '' type Idx = K extends keyof T ? T[K] : number extends keyof T - ? K extends `${number}` - ? T[number] - : never + ? K extends `${number}` + ? T[number] : never + : never export type PathValue< T, - P extends Paths, + P extends Paths > = P extends `${infer Key}.${infer Rest}` ? Rest extends Paths, 1> ? PathValue, Rest> @@ -77,8 +77,8 @@ export type PathValue< export type Leaves = [D] extends [never] ? never : T extends object - ? { [K in keyof T]-?: Join> }[keyof T] - : '' + ? { [K in keyof T]-?: Join> }[keyof T] + : '' // Thanks to @micfan on StackOverflow for this utility type: // https://stackoverflow.com/a/57390160/22753272 diff --git a/src/lib/useCalculateKclExpression.ts b/src/lib/useCalculateKclExpression.ts index e3f26e9c8..cc79afafc 100644 --- a/src/lib/useCalculateKclExpression.ts +++ b/src/lib/useCalculateKclExpression.ts @@ -1,15 +1,14 @@ import { useModelingContext } from 'hooks/useModelingContext' +import { kclManager } from 'lib/singletons' import { useKclContext } from 'lang/KclProvider' import { findUniqueName } from 'lang/modifyAst' import { PrevVariable, findAllPreviousVariables } from 'lang/queryAst' -import { getSafeInsertIndex } from 'lang/queryAst/getSafeInsertIndex' import { Expr, SourceRange } from 'lang/wasm' -import { parse, resultIsOk } from 'lang/wasm' -import { kclManager } from 'lib/singletons' -import { err } from 'lib/trap' import { useEffect, useMemo, useRef, useState } from 'react' - import { getCalculatedKclExpressionValue } from './kclHelpers' +import { parse, resultIsOk } from 'lang/wasm' +import { err } from 'lib/trap' +import { getSafeInsertIndex } from 'lang/queryAst/getSafeInsertIndex' const isValidVariableName = (name: string) => /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name) diff --git a/src/lib/usePreviousVarMentions.ts b/src/lib/usePreviousVarMentions.ts index b4ccc509e..66787eaac 100644 --- a/src/lib/usePreviousVarMentions.ts +++ b/src/lib/usePreviousVarMentions.ts @@ -1,5 +1,4 @@ import { CompletionContext } from '@codemirror/autocomplete' - import { usePreviousVariables } from './usePreviousVariables' /// Basically a fork of the `mentions` extension https://github.com/uiwjs/react-codemirror/blob/master/extensions/mentions/src/index.ts diff --git a/src/lib/usePreviousVariables.ts b/src/lib/usePreviousVariables.ts index 1eb041daa..c6ec4be93 100644 --- a/src/lib/usePreviousVariables.ts +++ b/src/lib/usePreviousVariables.ts @@ -1,7 +1,7 @@ import { useModelingContext } from 'hooks/useModelingContext' +import { kclManager } from 'lib/singletons' import { useKclContext } from 'lang/KclProvider' import { findAllPreviousVariables } from 'lang/queryAst' -import { kclManager } from 'lib/singletons' import { useEffect, useState } from 'react' export function usePreviousVariables() { diff --git a/src/lib/utils.test.ts b/src/lib/utils.test.ts index b01f848da..9f95000a5 100644 --- a/src/lib/utils.test.ts +++ b/src/lib/utils.test.ts @@ -1,13 +1,13 @@ -import { SourceRange, topLevelRange } from '../lang/wasm' import { - hasDigitsLeftOfDecimal, - hasLeadingZero, - isClockwise, isOverlap, - onDragNumberCalculation, roundOff, simulateOnMouseDragMatch, + onDragNumberCalculation, + hasLeadingZero, + hasDigitsLeftOfDecimal, + isClockwise, } from './utils' +import { SourceRange, topLevelRange } from '../lang/wasm' describe('testing isOverlapping', () => { testBothOrders(topLevelRange(0, 3), topLevelRange(3, 10)) diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 76abfbf32..94ec96d5d 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,10 +1,10 @@ -import { Binary as BSONBinary } from 'bson' -import { v4 } from 'uuid' -import { AnyMachineSnapshot } from 'xstate' - import { SourceRange } from '../lang/wasm' + +import { v4 } from 'uuid' import { isDesktop } from './isDesktop' +import { AnyMachineSnapshot } from 'xstate' import { AsyncFn } from './types' +import { Binary as BSONBinary } from 'bson' export const uuidv4 = v4 diff --git a/src/lib/utils2d.test.ts b/src/lib/utils2d.test.ts index 67af52a24..d64b0ca92 100644 --- a/src/lib/utils2d.test.ts +++ b/src/lib/utils2d.test.ts @@ -1,5 +1,5 @@ import { Coords2d } from 'lang/std/sketch' -import { initPromise, isPointsCCW } from 'lang/wasm' +import { isPointsCCW, initPromise } from 'lang/wasm' beforeAll(async () => { await initPromise diff --git a/src/lib/utils2d.ts b/src/lib/utils2d.ts index 07f43ceaf..d0e59844c 100644 --- a/src/lib/utils2d.ts +++ b/src/lib/utils2d.ts @@ -1,5 +1,4 @@ import { Coords2d } from 'lang/std/sketch' - import { getAngle } from './utils' export function deg2Rad(deg: number): number { diff --git a/src/lib/varCompletionExtension.ts b/src/lib/varCompletionExtension.ts index 1c7959287..d2a5f08f1 100644 --- a/src/lib/varCompletionExtension.ts +++ b/src/lib/varCompletionExtension.ts @@ -1,9 +1,9 @@ +import { Extension } from '@codemirror/state' import { - Completion, CompletionContext, autocompletion, + Completion, } from '@codemirror/autocomplete' -import { Extension } from '@codemirror/state' /// Basically a fork of the `mentions` extension https://github.com/uiwjs/react-codemirror/blob/master/extensions/mentions/src/index.ts /// But it matches on any word, not just the `@` symbol diff --git a/src/lib/wasm_lib_wrapper.ts b/src/lib/wasm_lib_wrapper.ts index 90579842c..8dbddd847 100644 --- a/src/lib/wasm_lib_wrapper.ts +++ b/src/lib/wasm_lib_wrapper.ts @@ -6,23 +6,24 @@ * A way to bypass this is by reloading the entire .js file so the global wasm variable * gets reinitialized and we do not use that old reference */ + import { - base64_decode as Base64Decode, - change_kcl_settings as ChangeKclSettings, - coredump as CoreDump, - default_app_settings as DefaultAppSettings, - default_project_settings as DefaultProjectSettings, - format_number as FormatNumber, - get_kcl_version as GetKclVersion, - get_tangential_arc_to_info as GetTangentialArcToInfo, - is_kcl_empty_or_only_settings as IsKclEmptyOrOnlySettings, - is_points_ccw as IsPointsCcw, - kcl_lint as KclLint, - kcl_settings as KclSettings, - parse_app_settings as ParseAppSettings, - parse_project_settings as ParseProjectSettings, parse_wasm as ParseWasm, recast_wasm as RecastWasm, + format_number as FormatNumber, + kcl_lint as KclLint, + is_points_ccw as IsPointsCcw, + get_tangential_arc_to_info as GetTangentialArcToInfo, + coredump as CoreDump, + default_app_settings as DefaultAppSettings, + parse_app_settings as ParseAppSettings, + parse_project_settings as ParseProjectSettings, + default_project_settings as DefaultProjectSettings, + base64_decode as Base64Decode, + kcl_settings as KclSettings, + change_kcl_settings as ChangeKclSettings, + is_kcl_empty_or_only_settings as IsKclEmptyOrOnlySettings, + get_kcl_version as GetKclVersion, serialize_configuration as SerializeConfiguration, serialize_project_configuration as SerializeProjectConfiguration, } from '@rust/kcl-wasm-lib/pkg/kcl_wasm_lib' diff --git a/src/machines/appMachine.ts b/src/machines/appMachine.ts index d00522f25..531d78d91 100644 --- a/src/machines/appMachine.ts +++ b/src/machines/appMachine.ts @@ -1,10 +1,9 @@ -import { useSelector } from '@xstate/react' -import { createSettings } from 'lib/settings/initialSettings' import { ActorRefFrom, createActor, setup, spawnChild } from 'xstate' - import { authMachine } from './authMachine' +import { useSelector } from '@xstate/react' import { ACTOR_IDS } from './machineConstants' import { settingsMachine } from './settingsMachine' +import { createSettings } from 'lib/settings/initialSettings' const { AUTH, SETTINGS } = ACTOR_IDS const appMachineActors = { diff --git a/src/machines/authMachine.ts b/src/machines/authMachine.ts index dd4014b3e..8e76ba838 100644 --- a/src/machines/authMachine.ts +++ b/src/machines/authMachine.ts @@ -1,23 +1,22 @@ +import { assign, setup, fromPromise } from 'xstate' import { Models } from '@kittycad/lib' +import withBaseURL from '../lib/withBaseURL' +import { isDesktop } from 'lib/isDesktop' import { - DEV, VITE_KC_API_BASE_URL, VITE_KC_DEV_TOKEN, VITE_KC_SKIP_AUTH, + DEV, } from 'env' -import { COOKIE_NAME } from 'lib/constants' import { getUser as getUserDesktop, readTokenFile, writeTokenFile, } from 'lib/desktop' -import { isDesktop } from 'lib/isDesktop' +import { COOKIE_NAME } from 'lib/constants' import { markOnce } from 'lib/performance' -import { assign, fromPromise, setup } from 'xstate' - -import withBaseURL from '../lib/withBaseURL' -import withBaseUrl from '../lib/withBaseURL' import { ACTOR_IDS } from './machineConstants' +import withBaseUrl from '../lib/withBaseURL' const SKIP_AUTH = VITE_KC_SKIP_AUTH === 'true' && DEV diff --git a/src/machines/commandBarMachine.ts b/src/machines/commandBarMachine.ts index d24ae725b..b8e1a0eb0 100644 --- a/src/machines/commandBarMachine.ts +++ b/src/machines/commandBarMachine.ts @@ -1,6 +1,4 @@ -import { useSelector } from '@xstate/react' -import { MachineManager } from 'components/MachineManagerProvider' -import { authCommands } from 'lib/commandBarConfigs/authCommandConfig' +import { assign, createActor, fromPromise, setup, SnapshotFrom } from 'xstate' import { Command, CommandArgument, @@ -8,8 +6,10 @@ import { KclCommandValue, } from 'lib/commandTypes' import { getCommandArgumentKclValuesOnly } from 'lib/commandUtils' +import { MachineManager } from 'components/MachineManagerProvider' import toast from 'react-hot-toast' -import { SnapshotFrom, assign, createActor, fromPromise, setup } from 'xstate' +import { useSelector } from '@xstate/react' +import { authCommands } from 'lib/commandBarConfigs/authCommandConfig' export type CommandBarContext = { commands: Command[] @@ -134,11 +134,10 @@ export const commandBarMachine = setup({ // that is, the first argument that is not already in the argumentsToSubmit // or hidden, or that is not undefined, or that is not marked as "skippable". // TODO validate the type of the existing arguments - const nonHiddenArgs = Object.entries(selectedCommand.args).filter( - (a) => - a[1].hidden && typeof a[1].hidden === 'function' - ? !a[1].hidden(context) - : !a[1].hidden + const nonHiddenArgs = Object.entries(selectedCommand.args).filter((a) => + a[1].hidden && typeof a[1].hidden === 'function' + ? !a[1].hidden(context) + : !a[1].hidden ) let argIndex = 0 @@ -242,8 +241,8 @@ export const commandBarMachine = setup({ argName in event.data.argDefaultValues ? event.data.argDefaultValues[argName] : arg.skip && 'defaultValue' in arg - ? arg.defaultValue - : undefined + ? arg.defaultValue + : undefined } return args }, diff --git a/src/machines/featureTreeMachine.ts b/src/machines/featureTreeMachine.ts index f971069ff..b436a2a38 100644 --- a/src/machines/featureTreeMachine.ts +++ b/src/machines/featureTreeMachine.ts @@ -1,23 +1,21 @@ -import { - deleteSelectionPromise, - deletionErrorMessage, -} from 'lang/modifyAst/deleteSelection' -import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' import { Artifact, getArtifactFromRange } from 'lang/std/artifactGraph' import { SourceRange } from 'lang/wasm' import { - EnterEditFlowProps, enterAppearanceFlow, enterEditFlow, + EnterEditFlowProps, } from 'lib/operations' import { kclManager } from 'lib/singletons' import { err } from 'lib/trap' import toast from 'react-hot-toast' -import { assign, fromPromise, setup } from 'xstate' - import { Operation } from '@rust/kcl-lib/bindings/Operation' - +import { assign, fromPromise, setup } from 'xstate' import { commandBarActor } from './commandBarMachine' +import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' +import { + deleteSelectionPromise, + deletionErrorMessage, +} from 'lang/modifyAst/deleteSelection' type FeatureTreeEvent = | { @@ -275,10 +273,10 @@ export const featureTreeMachine = setup({ src: 'prepareEditCommand', input: ({ context }) => { const artifact = context.targetSourceRange - ? (getArtifactFromRange( + ? getArtifactFromRange( context.targetSourceRange, kclManager.artifactGraph - ) ?? undefined) + ) ?? undefined : undefined return { // currentOperation is guaranteed to be defined here @@ -329,10 +327,10 @@ export const featureTreeMachine = setup({ src: 'prepareAppearanceCommand', input: ({ context }) => { const artifact = context.targetSourceRange - ? (getArtifactFromRange( + ? getArtifactFromRange( context.targetSourceRange, kclManager.artifactGraph - ) ?? undefined) + ) ?? undefined : undefined return { // currentOperation is guaranteed to be defined here @@ -383,10 +381,10 @@ export const featureTreeMachine = setup({ src: 'sendDeleteCommand', input: ({ context }) => { const artifact = context.targetSourceRange - ? (getArtifactFromRange( + ? getArtifactFromRange( context.targetSourceRange, kclManager.artifactGraph - ) ?? undefined) + ) ?? undefined : undefined return { artifact, diff --git a/src/machines/fileMachine.ts b/src/machines/fileMachine.ts index 19c898a64..f628ed643 100644 --- a/src/machines/fileMachine.ts +++ b/src/machines/fileMachine.ts @@ -1,5 +1,5 @@ -import { FileEntry, Project } from 'lib/project' import { assign, fromPromise, setup } from 'xstate' +import { Project, FileEntry } from 'lib/project' type FileMachineContext = { project: Project diff --git a/src/machines/kclEditorMachine.ts b/src/machines/kclEditorMachine.ts index 35d6aa43a..86c16efe6 100644 --- a/src/machines/kclEditorMachine.ts +++ b/src/machines/kclEditorMachine.ts @@ -1,5 +1,5 @@ +import { assign, createActor, setup, StateFrom } from 'xstate' import { EditorSelection } from '@codemirror/state' -import { StateFrom, assign, createActor, setup } from 'xstate' type SelectionEvent = { codeMirrorSelection: EditorSelection diff --git a/src/machines/modelingMachine.ts b/src/machines/modelingMachine.ts index 9a48ad172..f4b9da995 100644 --- a/src/machines/modelingMachine.ts +++ b/src/machines/modelingMachine.ts @@ -1,77 +1,3 @@ -import { deleteSegment } from 'clientSideScene/ClientSideSceneComp' -import { orthoScale, quaternionFromUpNForward } from 'clientSideScene/helpers' -import { DRAFT_DASHED_LINE } from 'clientSideScene/sceneEntities' -import { DRAFT_POINT } from 'clientSideScene/sceneInfra' -import { createProfileStartHandle } from 'clientSideScene/segments' -import { MachineManager } from 'components/MachineManagerProvider' -import { ModelingMachineContext } from 'components/ModelingMachineProvider' -import { SidebarType } from 'components/ModelingSidebar/ModelingPanes' -import { - applyConstraintEqualAngle, - equalAngleInfo, -} from 'components/Toolbar/EqualAngle' -import { - applyConstraintEqualLength, - setEqualLengthInfo, -} from 'components/Toolbar/EqualLength' -import { - applyConstraintHorzVert, - horzVertInfo, -} from 'components/Toolbar/HorzVert' -import { intersectInfo } from 'components/Toolbar/Intersect' -import { - applyRemoveConstrainingValues, - removeConstrainingValuesInfo, -} from 'components/Toolbar/RemoveConstrainingValues' -import { - absDistanceInfo, - applyConstraintAxisAlign, -} from 'components/Toolbar/SetAbsDistance' -import { angleBetweenInfo } from 'components/Toolbar/SetAngleBetween' -import { - applyConstraintHorzVertAlign, - horzVertDistanceInfo, -} from 'components/Toolbar/SetHorzVertDistance' -import { angleLengthInfo } from 'components/Toolbar/setAngleLength' -import { updateModelingState } from 'lang/modelingWorkflows' -import { - addHelix, - addOffsetPlane, - addShell, - addSweep, - createLiteral, - createLocalName, - deleteNodeInExtrudePipe, - extrudeSketch, - insertNamedConstant, - loftSketches, -} from 'lang/modifyAst' -import { - ChamferParameters, - EdgeTreatmentType, - FilletParameters, - applyEdgeTreatmentToSelection, - getPathToExtrudeForSegmentSelection, - mutateAstWithTagForSketchSegment, -} from 'lang/modifyAst/addEdgeTreatment' -import { - getAxisExpressionAndIndex, - revolveSketch, -} from 'lang/modifyAst/addRevolve' -import { - applyIntersectFromTargetOperatorSelections, - applySubtractFromTargetOperatorSelections, - applyUnionFromTargetOperatorSelections, -} from 'lang/modifyAst/boolean' -import { - deleteSelectionPromise, - deletionErrorMessage, -} from 'lang/modifyAst/deleteSelection' -import { setAppearance } from 'lang/modifyAst/setAppearance' -import { isNodeSafeToReplacePath, stringifyPathToNode } from 'lang/queryAst' -import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' -import { getPathsFromPlaneArtifact } from 'lang/std/artifactGraph' -import { Coords2d } from 'lang/std/sketch' import { CallExpression, CallExpressionKw, @@ -86,35 +12,107 @@ import { resultIsOk, sketchFromKclValue, } from 'lang/wasm' -import { ModelingCommandSchema } from 'lib/commandBarConfigs/modelingCommandConfig' -import { KclCommandValue } from 'lib/commandTypes' -import { EXECUTION_TYPE_REAL } from 'lib/constants' -import { DefaultPlaneStr } from 'lib/planes' import { Axis, DefaultPlaneSelection, - Selection, Selections, + Selection, updateSelections, } from 'lib/selections' -import { - codeManager, - editorManager, - engineCommandManager, - kclManager, - sceneEntitiesManager, - sceneInfra, -} from 'lib/singletons' -import { ToolbarModeName } from 'lib/toolbar' -import { err, reportRejection, trap } from 'lib/trap' -import { isArray, uuidv4 } from 'lib/utils' -import toast from 'react-hot-toast' -import { Mesh, Vector2, Vector3 } from 'three' import { assign, fromPromise, setup } from 'xstate' - -import { Node } from '@rust/kcl-lib/bindings/Node' - +import { SidebarType } from 'components/ModelingSidebar/ModelingPanes' +import { isNodeSafeToReplacePath, stringifyPathToNode } from 'lang/queryAst' +import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils' +import { + kclManager, + sceneInfra, + sceneEntitiesManager, + engineCommandManager, + editorManager, + codeManager, +} from 'lib/singletons' +import { + horzVertInfo, + applyConstraintHorzVert, +} from 'components/Toolbar/HorzVert' +import { + applyConstraintHorzVertAlign, + horzVertDistanceInfo, +} from 'components/Toolbar/SetHorzVertDistance' +import { angleBetweenInfo } from 'components/Toolbar/SetAngleBetween' +import { angleLengthInfo } from 'components/Toolbar/setAngleLength' +import { + applyConstraintEqualLength, + setEqualLengthInfo, +} from 'components/Toolbar/EqualLength' +import { + getAxisExpressionAndIndex, + revolveSketch, +} from 'lang/modifyAst/addRevolve' +import { + addHelix, + addOffsetPlane, + addShell, + addSweep, + createLiteral, + createLocalName, + deleteNodeInExtrudePipe, + extrudeSketch, + insertNamedConstant, + loftSketches, +} from 'lang/modifyAst' +import { + applyEdgeTreatmentToSelection, + ChamferParameters, + EdgeTreatmentType, + FilletParameters, + getPathToExtrudeForSegmentSelection, + mutateAstWithTagForSketchSegment, +} from 'lang/modifyAst/addEdgeTreatment' import { getNodeFromPath } from '../lang/queryAst' +import { + applyConstraintEqualAngle, + equalAngleInfo, +} from 'components/Toolbar/EqualAngle' +import { + applyRemoveConstrainingValues, + removeConstrainingValuesInfo, +} from 'components/Toolbar/RemoveConstrainingValues' +import { intersectInfo } from 'components/Toolbar/Intersect' +import { + absDistanceInfo, + applyConstraintAxisAlign, +} from 'components/Toolbar/SetAbsDistance' +import { ModelingCommandSchema } from 'lib/commandBarConfigs/modelingCommandConfig' +import { err, reportRejection, trap } from 'lib/trap' +import { DefaultPlaneStr } from 'lib/planes' +import { isArray, uuidv4 } from 'lib/utils' +import { Coords2d } from 'lang/std/sketch' +import { deleteSegment } from 'clientSideScene/ClientSideSceneComp' +import toast from 'react-hot-toast' +import { ToolbarModeName } from 'lib/toolbar' +import { orthoScale, quaternionFromUpNForward } from 'clientSideScene/helpers' +import { Mesh, Vector2, Vector3 } from 'three' +import { MachineManager } from 'components/MachineManagerProvider' +import { KclCommandValue } from 'lib/commandTypes' +import { ModelingMachineContext } from 'components/ModelingMachineProvider' +import { + deleteSelectionPromise, + deletionErrorMessage, +} from 'lang/modifyAst/deleteSelection' +import { getPathsFromPlaneArtifact } from 'lang/std/artifactGraph' +import { createProfileStartHandle } from 'clientSideScene/segments' +import { DRAFT_POINT } from 'clientSideScene/sceneInfra' +import { setAppearance } from 'lang/modifyAst/setAppearance' +import { DRAFT_DASHED_LINE } from 'clientSideScene/sceneEntities' +import { Node } from '@rust/kcl-lib/bindings/Node' +import { updateModelingState } from 'lang/modelingWorkflows' +import { EXECUTION_TYPE_REAL } from 'lib/constants' +import { + applyIntersectFromTargetOperatorSelections, + applySubtractFromTargetOperatorSelections, + applyUnionFromTargetOperatorSelections, +} from 'lang/modifyAst/boolean' export const MODELING_PERSIST_KEY = 'MODELING_PERSIST_KEY' @@ -1109,8 +1107,8 @@ export const modelingMachine = setup({ currentTool === 'tangentialArc' ? { type: 'Continue existing profile', data } : currentTool === 'arc' - ? { type: 'Add start point', data } - : { type: 'Add start point', data } + ? { type: 'Add start point', data } + : { type: 'Add start point', data } ), }) }, diff --git a/src/machines/projectsMachine.ts b/src/machines/projectsMachine.ts index 1d91b6191..7344259f6 100644 --- a/src/machines/projectsMachine.ts +++ b/src/machines/projectsMachine.ts @@ -1,7 +1,7 @@ +import { assign, fromPromise, setup } from 'xstate' import { ProjectsCommandSchema } from 'lib/commandBarConfigs/projectsCommandConfig' import { Project } from 'lib/project' import { isArray } from 'lib/utils' -import { assign, fromPromise, setup } from 'xstate' export const projectsMachine = setup({ types: { diff --git a/src/machines/settingsMachine.ts b/src/machines/settingsMachine.ts index 7ea9c919e..758602ebd 100644 --- a/src/machines/settingsMachine.ts +++ b/src/machines/settingsMachine.ts @@ -1,14 +1,23 @@ -import decamelize from 'decamelize' import { - createSettingsCommand, - settingsWithCommandConfigs, -} from 'lib/commandBarConfigs/settingsCommandConfig' -import { Command } from 'lib/commandTypes' -import { Project } from 'lib/project' + AnyActorRef, + assign, + enqueueActions, + fromCallback, + fromPromise, + sendTo, + setup, +} from 'xstate' +import { + Themes, + darkModeMatcher, + getOppositeTheme, + getSystemTheme, + setThemeClass, +} from 'lib/theme' import { - SettingsType, createSettings, settings, + SettingsType, } from 'lib/settings/initialSettings' import { BaseUnit, @@ -25,6 +34,7 @@ import { saveSettings, setSettingsAtLevel, } from 'lib/settings/settingsUtils' +import { NamedView } from '@rust/kcl-lib/bindings/NamedView' import { codeManager, engineCommandManager, @@ -32,27 +42,15 @@ import { sceneEntitiesManager, sceneInfra, } from 'lib/singletons' -import { - Themes, - darkModeMatcher, - getOppositeTheme, - getSystemTheme, - setThemeClass, -} from 'lib/theme' -import { reportRejection } from 'lib/trap' import toast from 'react-hot-toast' +import decamelize from 'decamelize' +import { reportRejection } from 'lib/trap' +import { Project } from 'lib/project' import { - AnyActorRef, - assign, - enqueueActions, - fromCallback, - fromPromise, - sendTo, - setup, -} from 'xstate' - -import { NamedView } from '@rust/kcl-lib/bindings/NamedView' - + createSettingsCommand, + settingsWithCommandConfigs, +} from 'lib/commandBarConfigs/settingsCommandConfig' +import { Command } from 'lib/commandTypes' import { commandBarActor } from './commandBarMachine' type SettingsMachineContext = SettingsType & { @@ -208,7 +206,7 @@ export const settingsMachine = setup({ if (!('data' in event)) return const eventParts = event.type.replace(/^set./, '').split('.') as [ keyof typeof settings, - string, + string ] const truncatedNewValue = event.data.value?.toString().slice(0, 28) const message = diff --git a/src/main.ts b/src/main.ts index b5c267445..aa0697f47 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,41 +1,40 @@ // Some of the following was taken from bits and pieces of the vite-typescript // template that ElectronJS provides. -// @ts-ignore: TS1343 -import * as kittycad from '@kittycad/lib/import' -import { Bonjour, Service } from 'bonjour-service' import dotenv from 'dotenv' import { - BrowserWindow, - Menu, app, - desktopCapturer, - dialog, + BrowserWindow, ipcMain, - nativeTheme, - screen, + dialog, shell, + nativeTheme, + desktopCapturer, systemPreferences, + Menu, + screen, } from 'electron' -import electronUpdater, { type AppUpdater } from 'electron-updater' -import { ZOO_STUDIO_PROTOCOL } from 'lib/constants' -import getCurrentProjectFile from 'lib/getCurrentProjectFile' -import { reportRejection } from 'lib/trap' -import os from 'node:os' -import { Issuer } from 'openid-client' import path from 'path' - -import * as packageJSON from '../package.json' +import { Issuer } from 'openid-client' +import { Bonjour, Service } from 'bonjour-service' +// @ts-ignore: TS1343 +import * as kittycad from '@kittycad/lib/import' +import electronUpdater, { type AppUpdater } from 'electron-updater' +import getCurrentProjectFile from 'lib/getCurrentProjectFile' +import os from 'node:os' +import { reportRejection } from 'lib/trap' +import { ZOO_STUDIO_PROTOCOL } from 'lib/constants' import { argvFromYargs, getPathOrUrlFromArgs, parseCLIArgs, } from './commandLineArgs' +import * as packageJSON from '../package.json' import { buildAndSetMenuForFallback, buildAndSetMenuForModelingPage, buildAndSetMenuForProjectPage, - disableMenu, enableMenu, + disableMenu, } from './menu' let mainWindow: BrowserWindow | null = null @@ -370,7 +369,10 @@ ipcMain.handle('startDeviceFlow', async (_, host: string) => { ipcMain.handle('kittycad', (event, data) => { return data.access .split('.') - .reduce((obj: any, prop: any) => obj[prop], kittycad)(data.args) + .reduce( + (obj: any, prop: any) => obj[prop], + kittycad + )(data.args) }) // Used to find other devices on the local network, e.g. 3D printers, CNC machines, etc. diff --git a/src/menu.ts b/src/menu.ts index dfd5851c6..8384916de 100644 --- a/src/menu.ts +++ b/src/menu.ts @@ -1,11 +1,11 @@ -import { BrowserWindow, Menu, app } from 'electron' -import { projectEditRole } from 'menu/editRole' +import { app, Menu, BrowserWindow } from 'electron' import { projectFileRole } from 'menu/fileRole' +import { projectEditRole } from 'menu/editRole' import { helpRole } from 'menu/helpRole' -import { ZooMenuItemConstructorOptions } from 'menu/roles' import { projectViewRole } from 'menu/viewRole' -import os from 'node:os' +import os from 'node:os' +import { ZooMenuItemConstructorOptions } from 'menu/roles' const isMac = os.platform() === 'darwin' // Default electron menu. diff --git a/src/menu/channels.ts b/src/menu/channels.ts index 56b879005..b01dde3bd 100644 --- a/src/menu/channels.ts +++ b/src/menu/channels.ts @@ -1,5 +1,4 @@ import { BrowserWindow } from 'electron' - import type { Channel } from '../channels' // types for knowing what menu sends what webContent payload diff --git a/src/menu/editRole.ts b/src/menu/editRole.ts index a8232820f..b19b59dda 100644 --- a/src/menu/editRole.ts +++ b/src/menu/editRole.ts @@ -1,9 +1,7 @@ import { BrowserWindow } from 'electron' -import os from 'node:os' - import { typeSafeWebContentsSend } from './channels' +import os from 'node:os' import { ZooMenuItemConstructorOptions } from './roles' - const isMac = os.platform() === 'darwin' export const projectEditRole = ( diff --git a/src/menu/fileRole.ts b/src/menu/fileRole.ts index d4bfb936c..295661301 100644 --- a/src/menu/fileRole.ts +++ b/src/menu/fileRole.ts @@ -1,9 +1,7 @@ import { BrowserWindow } from 'electron' -import os from 'node:os' - import { typeSafeWebContentsSend } from './channels' import { ZooMenuItemConstructorOptions } from './roles' - +import os from 'node:os' const isMac = os.platform() === 'darwin' export const projectFileRole = ( diff --git a/src/menu/helpRole.ts b/src/menu/helpRole.ts index e773a4115..ff4d84325 100644 --- a/src/menu/helpRole.ts +++ b/src/menu/helpRole.ts @@ -1,8 +1,7 @@ -import { BrowserWindow, shell } from 'electron' -import { reportRejection } from 'lib/trap' - -import { typeSafeWebContentsSend } from './channels' +import { shell, BrowserWindow } from 'electron' import { ZooMenuItemConstructorOptions } from './roles' +import { reportRejection } from 'lib/trap' +import { typeSafeWebContentsSend } from './channels' export const helpRole = ( mainWindow: BrowserWindow diff --git a/src/menu/viewRole.ts b/src/menu/viewRole.ts index 13b4105c6..5e16746d9 100644 --- a/src/menu/viewRole.ts +++ b/src/menu/viewRole.ts @@ -1,9 +1,7 @@ import { BrowserWindow } from 'electron' -import os from 'node:os' - -import { typeSafeWebContentsSend } from './channels' import { ZooMenuItemConstructorOptions } from './roles' - +import { typeSafeWebContentsSend } from './channels' +import os from 'node:os' const isMac = os.platform() === 'darwin' export const projectViewRole = ( diff --git a/src/preload.ts b/src/preload.ts index 989be8565..abcbd425c 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -1,12 +1,11 @@ -import chokidar from 'chokidar' -import { MachinesListing } from 'components/MachineManagerProvider' -import { IpcRendererEvent, contextBridge, ipcRenderer } from 'electron' -import fsSync from 'node:fs' +import { ipcRenderer, contextBridge, IpcRendererEvent } from 'electron' +import path from 'path' import fs from 'node:fs/promises' import os from 'node:os' -import path from 'path' - +import fsSync from 'node:fs' import packageJson from '../package.json' +import { MachinesListing } from 'components/MachineManagerProvider' +import chokidar from 'chokidar' import type { Channel } from './channels' import type { WebContentSendPayload } from './menu/channels' diff --git a/src/routes/Home.tsx b/src/routes/Home.tsx index eb54815b8..c3bed4479 100644 --- a/src/routes/Home.tsx +++ b/src/routes/Home.tsx @@ -1,33 +1,32 @@ +import { FormEvent, useEffect, useRef, useState } from 'react' import { ActionButton } from 'components/ActionButton' import { AppHeader } from 'components/AppHeader' -import Loading from 'components/Loading' -import { LowerRightControls } from 'components/LowerRightControls' import ProjectCard from 'components/ProjectCard/ProjectCard' -import { ProjectSearchBar, useProjectSearch } from 'components/ProjectSearchBar' -import { useCreateFileLinkQuery } from 'hooks/useCreateFileLinkQueryWatcher' -import { useMenuListener } from 'hooks/useMenu' -import { useProjectsContext } from 'hooks/useProjectsContext' -import { isDesktop } from 'lib/isDesktop' -import { PATHS } from 'lib/paths' -import { markOnce } from 'lib/performance' -import { Project } from 'lib/project' -import { kclManager } from 'lib/singletons' -import { reportRejection } from 'lib/trap' -import { useSettings } from 'machines/appMachine' -import { authActor } from 'machines/appMachine' -import { commandBarActor } from 'machines/commandBarMachine' -import { FormEvent, useEffect, useRef, useState } from 'react' -import { toast } from 'react-hot-toast' -import { useHotkeys } from 'react-hotkeys-hook' import { useNavigate, useSearchParams } from 'react-router-dom' import { Link } from 'react-router-dom' - +import { toast } from 'react-hot-toast' +import Loading from 'components/Loading' +import { PATHS } from 'lib/paths' import { getNextSearchParams, getSortFunction, getSortIcon, } from '../lib/sorting' +import { useHotkeys } from 'react-hotkeys-hook' +import { isDesktop } from 'lib/isDesktop' +import { kclManager } from 'lib/singletons' +import { LowerRightControls } from 'components/LowerRightControls' +import { ProjectSearchBar, useProjectSearch } from 'components/ProjectSearchBar' +import { Project } from 'lib/project' +import { markOnce } from 'lib/performance' +import { useProjectsContext } from 'hooks/useProjectsContext' +import { commandBarActor } from 'machines/commandBarMachine' +import { useCreateFileLinkQuery } from 'hooks/useCreateFileLinkQueryWatcher' +import { useSettings } from 'machines/appMachine' +import { reportRejection } from 'lib/trap' +import { authActor } from 'machines/appMachine' import type { WebContentSendPayload } from '../menu/channels' +import { useMenuListener } from 'hooks/useMenu' // This route only opens in the desktop context for now, // as defined in Router.tsx, so we can use the desktop APIs and types. diff --git a/src/routes/Onboarding/Camera.tsx b/src/routes/Onboarding/Camera.tsx index b02041bb6..19aa6a19a 100644 --- a/src/routes/Onboarding/Camera.tsx +++ b/src/routes/Onboarding/Camera.tsx @@ -1,13 +1,12 @@ -import { SettingsSection } from 'components/Settings/SettingsSection' +import { OnboardingButtons, useDismiss, useNextClick } from '.' +import { onboardingPaths } from 'routes/Onboarding/paths' import { CameraSystem, cameraMouseDragGuards, cameraSystems, } from 'lib/cameraControls' +import { SettingsSection } from 'components/Settings/SettingsSection' import { settingsActor, useSettings } from 'machines/appMachine' -import { onboardingPaths } from 'routes/Onboarding/paths' - -import { OnboardingButtons, useDismiss, useNextClick } from '.' export default function Units() { useDismiss() diff --git a/src/routes/Onboarding/CmdK.tsx b/src/routes/Onboarding/CmdK.tsx index 58297e8ac..1ed836eb0 100644 --- a/src/routes/Onboarding/CmdK.tsx +++ b/src/routes/Onboarding/CmdK.tsx @@ -1,9 +1,8 @@ -import { COMMAND_PALETTE_HOTKEY } from 'components/CommandBar/CommandBar' import usePlatform from 'hooks/usePlatform' -import { hotkeyDisplay } from 'lib/hotkeyWrapper' -import { onboardingPaths } from 'routes/Onboarding/paths' - import { OnboardingButtons, kbdClasses } from '.' +import { onboardingPaths } from 'routes/Onboarding/paths' +import { hotkeyDisplay } from 'lib/hotkeyWrapper' +import { COMMAND_PALETTE_HOTKEY } from 'components/CommandBar/CommandBar' export default function CmdK() { const platformName = usePlatform() diff --git a/src/routes/Onboarding/CodeEditor.tsx b/src/routes/Onboarding/CodeEditor.tsx index 9a3de1b33..9af30860c 100644 --- a/src/routes/Onboarding/CodeEditor.tsx +++ b/src/routes/Onboarding/CodeEditor.tsx @@ -1,7 +1,6 @@ +import { kbdClasses, OnboardingButtons, useDemoCode } from '.' import { onboardingPaths } from 'routes/Onboarding/paths' -import { OnboardingButtons, kbdClasses, useDemoCode } from '.' - export default function OnboardingCodeEditor() { useDemoCode() diff --git a/src/routes/Onboarding/Export.tsx b/src/routes/Onboarding/Export.tsx index cbf314750..c71455080 100644 --- a/src/routes/Onboarding/Export.tsx +++ b/src/routes/Onboarding/Export.tsx @@ -1,7 +1,6 @@ import { APP_NAME } from 'lib/constants' -import { onboardingPaths } from 'routes/Onboarding/paths' - import { OnboardingButtons } from '.' +import { onboardingPaths } from 'routes/Onboarding/paths' export default function Export() { return ( diff --git a/src/routes/Onboarding/FutureWork.tsx b/src/routes/Onboarding/FutureWork.tsx index bb9686b6d..4be5e0fce 100644 --- a/src/routes/Onboarding/FutureWork.tsx +++ b/src/routes/Onboarding/FutureWork.tsx @@ -1,10 +1,9 @@ +import { OnboardingButtons, useDemoCode } from '.' +import { useEffect } from 'react' import { useModelingContext } from 'hooks/useModelingContext' import { APP_NAME } from 'lib/constants' -import { sceneInfra } from 'lib/singletons' -import { useEffect } from 'react' - -import { OnboardingButtons, useDemoCode } from '.' import { onboardingPaths } from './paths' +import { sceneInfra } from 'lib/singletons' export default function FutureWork() { const { send } = useModelingContext() diff --git a/src/routes/Onboarding/InteractiveNumbers.tsx b/src/routes/Onboarding/InteractiveNumbers.tsx index 65271c2f7..d8a6cb0c5 100644 --- a/src/routes/Onboarding/InteractiveNumbers.tsx +++ b/src/routes/Onboarding/InteractiveNumbers.tsx @@ -1,7 +1,6 @@ -import { bracketWidthConstantLine } from 'lib/exampleKcl' -import { onboardingPaths } from 'routes/Onboarding/paths' - import { OnboardingButtons, kbdClasses, useDemoCode } from '.' +import { onboardingPaths } from 'routes/Onboarding/paths' +import { bracketWidthConstantLine } from 'lib/exampleKcl' export default function OnboardingInteractiveNumbers() { useDemoCode() diff --git a/src/routes/Onboarding/Introduction.tsx b/src/routes/Onboarding/Introduction.tsx index 5c3e4f712..c3103d12c 100644 --- a/src/routes/Onboarding/Introduction.tsx +++ b/src/routes/Onboarding/Introduction.tsx @@ -1,21 +1,20 @@ -import { useLspContext } from 'components/LspProvider' -import { useFileContext } from 'hooks/useFileContext' -import { isKclEmptyOrOnlySettings } from 'lang/wasm' -import { APP_NAME } from 'lib/constants' -import { createAndOpenNewTutorialProject } from 'lib/desktopFS' -import { bracket } from 'lib/exampleKcl' -import { isDesktop } from 'lib/isDesktop' -import { PATHS } from 'lib/paths' -import { codeManager, kclManager } from 'lib/singletons' -import { Themes, getSystemTheme } from 'lib/theme' -import { reportRejection } from 'lib/trap' -import { IndexLoaderData } from 'lib/types' -import { useSettings } from 'machines/appMachine' -import { useEffect, useState } from 'react' -import { useNavigate, useRouteLoaderData } from 'react-router-dom' -import { onboardingPaths } from 'routes/Onboarding/paths' - import { OnboardingButtons, useDemoCode } from '.' +import { onboardingPaths } from 'routes/Onboarding/paths' +import { Themes, getSystemTheme } from 'lib/theme' +import { bracket } from 'lib/exampleKcl' +import { createAndOpenNewTutorialProject } from 'lib/desktopFS' +import { isDesktop } from 'lib/isDesktop' +import { useNavigate, useRouteLoaderData } from 'react-router-dom' +import { codeManager, kclManager } from 'lib/singletons' +import { APP_NAME } from 'lib/constants' +import { useEffect, useState } from 'react' +import { IndexLoaderData } from 'lib/types' +import { PATHS } from 'lib/paths' +import { useFileContext } from 'hooks/useFileContext' +import { useLspContext } from 'components/LspProvider' +import { reportRejection } from 'lib/trap' +import { useSettings } from 'machines/appMachine' +import { isKclEmptyOrOnlySettings } from 'lang/wasm' /** * Show either a welcome screen or a warning screen diff --git a/src/routes/Onboarding/ParametricModeling.tsx b/src/routes/Onboarding/ParametricModeling.tsx index 00f00eaa5..ae13f1ef1 100644 --- a/src/routes/Onboarding/ParametricModeling.tsx +++ b/src/routes/Onboarding/ParametricModeling.tsx @@ -1,10 +1,9 @@ +import { OnboardingButtons, useDemoCode } from '.' +import { onboardingPaths } from 'routes/Onboarding/paths' +import { Themes, getSystemTheme } from 'lib/theme' import { bracketThicknessCalculationLine } from 'lib/exampleKcl' import { isDesktop } from 'lib/isDesktop' -import { Themes, getSystemTheme } from 'lib/theme' import { useSettings } from 'machines/appMachine' -import { onboardingPaths } from 'routes/Onboarding/paths' - -import { OnboardingButtons, useDemoCode } from '.' export default function OnboardingParametricModeling() { useDemoCode() diff --git a/src/routes/Onboarding/ProjectMenu.tsx b/src/routes/Onboarding/ProjectMenu.tsx index e87c9cd6e..db02afc26 100644 --- a/src/routes/Onboarding/ProjectMenu.tsx +++ b/src/routes/Onboarding/ProjectMenu.tsx @@ -1,7 +1,6 @@ -import { isDesktop } from 'lib/isDesktop' -import { onboardingPaths } from 'routes/Onboarding/paths' - import { OnboardingButtons } from '.' +import { onboardingPaths } from 'routes/Onboarding/paths' +import { isDesktop } from 'lib/isDesktop' export default function ProjectMenu() { const onDesktop = isDesktop() diff --git a/src/routes/Onboarding/Sketching.tsx b/src/routes/Onboarding/Sketching.tsx index e47b8f459..7129ee196 100644 --- a/src/routes/Onboarding/Sketching.tsx +++ b/src/routes/Onboarding/Sketching.tsx @@ -1,8 +1,7 @@ -import { codeManager, kclManager } from 'lib/singletons' -import { useEffect } from 'react' -import { onboardingPaths } from 'routes/Onboarding/paths' - import { OnboardingButtons } from '.' +import { onboardingPaths } from 'routes/Onboarding/paths' +import { useEffect } from 'react' +import { codeManager, kclManager } from 'lib/singletons' export default function Sketching() { useEffect(() => { diff --git a/src/routes/Onboarding/Streaming.tsx b/src/routes/Onboarding/Streaming.tsx index a4895c367..bd0028152 100644 --- a/src/routes/Onboarding/Streaming.tsx +++ b/src/routes/Onboarding/Streaming.tsx @@ -1,6 +1,5 @@ -import { onboardingPaths } from 'routes/Onboarding/paths' - import { OnboardingButtons } from '.' +import { onboardingPaths } from 'routes/Onboarding/paths' export default function Streaming() { return ( diff --git a/src/routes/Onboarding/Units.tsx b/src/routes/Onboarding/Units.tsx index c0384d5a7..7ec94ac34 100644 --- a/src/routes/Onboarding/Units.tsx +++ b/src/routes/Onboarding/Units.tsx @@ -1,11 +1,10 @@ import { faArrowRight, faXmark } from '@fortawesome/free-solid-svg-icons' +import { type BaseUnit, baseUnitsUnion } from 'lib/settings/settingsTypes' import { ActionButton } from 'components/ActionButton' import { SettingsSection } from 'components/Settings/SettingsSection' -import { type BaseUnit, baseUnitsUnion } from 'lib/settings/settingsTypes' -import { settingsActor, useSettings } from 'machines/appMachine' -import { onboardingPaths } from 'routes/Onboarding/paths' - import { useDismiss, useNextClick } from '.' +import { onboardingPaths } from 'routes/Onboarding/paths' +import { settingsActor, useSettings } from 'machines/appMachine' export default function Units() { const dismiss = useDismiss() diff --git a/src/routes/Onboarding/UserMenu.tsx b/src/routes/Onboarding/UserMenu.tsx index 8d3f44308..ca2448c1b 100644 --- a/src/routes/Onboarding/UserMenu.tsx +++ b/src/routes/Onboarding/UserMenu.tsx @@ -1,8 +1,7 @@ -import { useUser } from 'machines/appMachine' -import { useEffect, useState } from 'react' -import { onboardingPaths } from 'routes/Onboarding/paths' - import { OnboardingButtons } from '.' +import { onboardingPaths } from 'routes/Onboarding/paths' +import { useEffect, useState } from 'react' +import { useUser } from 'machines/appMachine' export default function UserMenu() { const user = useUser() diff --git a/src/routes/Onboarding/index.tsx b/src/routes/Onboarding/index.tsx index 5f341a8e9..c867e74fc 100644 --- a/src/routes/Onboarding/index.tsx +++ b/src/routes/Onboarding/index.tsx @@ -1,36 +1,35 @@ -import { ActionButton } from 'components/ActionButton' -import { CustomIcon } from 'components/CustomIcon' -import Tooltip from 'components/Tooltip' +import { useHotkeys } from 'react-hotkeys-hook' +import { Outlet, useNavigate } from 'react-router-dom' +import Introduction from './Introduction' +import Camera from './Camera' +import Sketching from './Sketching' +import { useCallback, useEffect } from 'react' +import makeUrlPathRelative from '../../lib/makeUrlPathRelative' +import Streaming from './Streaming' +import CodeEditor from './CodeEditor' +import ParametricModeling from './ParametricModeling' +import InteractiveNumbers from './InteractiveNumbers' +import CmdK from './CmdK' +import UserMenu from './UserMenu' +import ProjectMenu from './ProjectMenu' +import Export from './Export' +import FutureWork from './FutureWork' +import { PATHS } from 'lib/paths' import { useAbsoluteFilePath } from 'hooks/useAbsoluteFilePath' +import { ActionButton } from 'components/ActionButton' +import { onboardingPaths } from 'routes/Onboarding/paths' +import { codeManager, editorManager, kclManager } from 'lib/singletons' +import { bracket } from 'lib/exampleKcl' +import { toSync } from 'lib/utils' +import { reportRejection } from 'lib/trap' import { useNetworkContext } from 'hooks/useNetworkContext' import { NetworkHealthState } from 'hooks/useNetworkStatus' import { EngineConnectionStateType } from 'lang/std/engineConnection' -import { bracket } from 'lib/exampleKcl' -import { PATHS } from 'lib/paths' -import { codeManager, editorManager, kclManager } from 'lib/singletons' -import { reportRejection } from 'lib/trap' -import { toSync } from 'lib/utils' import { settingsActor } from 'machines/appMachine' -import { useCallback, useEffect } from 'react' -import { useHotkeys } from 'react-hotkeys-hook' -import { Outlet, useNavigate } from 'react-router-dom' -import { onboardingPaths } from 'routes/Onboarding/paths' +import { CustomIcon } from 'components/CustomIcon' +import Tooltip from 'components/Tooltip' import { waitFor } from 'xstate' -import makeUrlPathRelative from '../../lib/makeUrlPathRelative' -import Camera from './Camera' -import CmdK from './CmdK' -import CodeEditor from './CodeEditor' -import Export from './Export' -import FutureWork from './FutureWork' -import InteractiveNumbers from './InteractiveNumbers' -import Introduction from './Introduction' -import ParametricModeling from './ParametricModeling' -import ProjectMenu from './ProjectMenu' -import Sketching from './Sketching' -import Streaming from './Streaming' -import UserMenu from './UserMenu' - export const kbdClasses = 'py-0.5 px-1 text-sm rounded bg-chalkboard-10 dark:bg-chalkboard-100 border border-chalkboard-50 border-b-2' diff --git a/src/routes/Settings.tsx b/src/routes/Settings.tsx index f6a024011..9ce3af3c1 100644 --- a/src/routes/Settings.tsx +++ b/src/routes/Settings.tsx @@ -1,21 +1,20 @@ +import { SettingsLevel } from 'lib/settings/settingsTypes' +import { useLocation, useNavigate, useSearchParams } from 'react-router-dom' +import { useHotkeys } from 'react-hotkeys-hook' +import { PATHS } from 'lib/paths' +import { useDotDotSlash } from 'hooks/useDotDotSlash' +import { Fragment, useEffect, useRef } from 'react' import { Dialog, Transition } from '@headlessui/react' import { CustomIcon } from 'components/CustomIcon' -import { AllKeybindingsFields } from 'components/Settings/AllKeybindingsFields' -import { AllSettingsFields } from 'components/Settings/AllSettingsFields' -import { KeybindingsSectionsList } from 'components/Settings/KeybindingsSectionsList' import { SettingsSearchBar } from 'components/Settings/SettingsSearchBar' -import { SettingsSectionsList } from 'components/Settings/SettingsSectionsList' import { SettingsTabs } from 'components/Settings/SettingsTabs' -import { NODE_ENV } from 'env' -import { useDotDotSlash } from 'hooks/useDotDotSlash' +import { SettingsSectionsList } from 'components/Settings/SettingsSectionsList' +import { AllSettingsFields } from 'components/Settings/AllSettingsFields' +import { AllKeybindingsFields } from 'components/Settings/AllKeybindingsFields' +import { KeybindingsSectionsList } from 'components/Settings/KeybindingsSectionsList' import { isDesktop } from 'lib/isDesktop' -import { PATHS } from 'lib/paths' -import { SettingsLevel } from 'lib/settings/settingsTypes' -import { Fragment, useEffect, useRef } from 'react' -import { useHotkeys } from 'react-hotkeys-hook' -import { useLocation, useNavigate, useSearchParams } from 'react-router-dom' - import { IS_PLAYWRIGHT_KEY } from '../../e2e/playwright/storageStates' +import { NODE_ENV } from 'env' const isTestEnv = window?.localStorage.getItem(IS_PLAYWRIGHT_KEY) === 'true' @@ -23,9 +22,9 @@ export const APP_VERSION = isTestEnv && NODE_ENV === 'development' ? '11.22.33' : isDesktop() - ? // @ts-ignore - window.electron.packageJson.version - : 'main' + ? // @ts-ignore + window.electron.packageJson.version + : 'main' export const PACKAGE_NAME = isDesktop() ? window.electron.packageJson.name diff --git a/src/routes/SignIn.tsx b/src/routes/SignIn.tsx index 9fe3e7671..45c711d12 100644 --- a/src/routes/SignIn.tsx +++ b/src/routes/SignIn.tsx @@ -1,21 +1,20 @@ -import { CustomIcon } from 'components/CustomIcon' -import { Logo } from 'components/Logo' -import { APP_NAME } from 'lib/constants' -import { openExternalBrowserIfDesktop } from 'lib/openWindow' +import { ActionButton } from '../components/ActionButton' +import { isDesktop } from '../lib/isDesktop' +import { VITE_KC_SITE_BASE_URL, VITE_KC_API_BASE_URL } from '../env' +import { Themes, getSystemTheme } from '../lib/theme' import { PATHS } from 'lib/paths' -import { reportRejection } from 'lib/trap' +import { APP_NAME } from 'lib/constants' +import { CSSProperties, useCallback, useState } from 'react' +import { Logo } from 'components/Logo' +import { CustomIcon } from 'components/CustomIcon' +import { Link } from 'react-router-dom' +import { APP_VERSION } from './Settings' +import { openExternalBrowserIfDesktop } from 'lib/openWindow' import { toSync } from 'lib/utils' +import { reportRejection } from 'lib/trap' +import toast from 'react-hot-toast' import { authActor } from 'machines/appMachine' import { useSettings } from 'machines/appMachine' -import { CSSProperties, useCallback, useState } from 'react' -import toast from 'react-hot-toast' -import { Link } from 'react-router-dom' - -import { ActionButton } from '../components/ActionButton' -import { VITE_KC_API_BASE_URL, VITE_KC_SITE_BASE_URL } from '../env' -import { isDesktop } from '../lib/isDesktop' -import { Themes, getSystemTheme } from '../lib/theme' -import { APP_VERSION } from './Settings' const subtleBorder = 'border border-solid border-chalkboard-30 dark:border-chalkboard-80' @@ -49,8 +48,8 @@ const SignIn = () => { ? '-dark' : '' : shouldContrast - ? '' - : '-dark', + ? '' + : '-dark', [theme.current] ) diff --git a/src/routes/Telemetry.tsx b/src/routes/Telemetry.tsx index a50cca836..a5cd91b0d 100644 --- a/src/routes/Telemetry.tsx +++ b/src/routes/Telemetry.tsx @@ -1,11 +1,11 @@ +import { useLocation, useNavigate } from 'react-router-dom' +import { useHotkeys } from 'react-hotkeys-hook' +import { PATHS } from 'lib/paths' +import { useDotDotSlash } from 'hooks/useDotDotSlash' +import { Fragment } from 'react' import { Dialog, Transition } from '@headlessui/react' import { CustomIcon } from 'components/CustomIcon' import { TelemetryExplorer } from 'components/TelemetryExplorer' -import { useDotDotSlash } from 'hooks/useDotDotSlash' -import { PATHS } from 'lib/paths' -import { Fragment } from 'react' -import { useHotkeys } from 'react-hotkeys-hook' -import { useLocation, useNavigate } from 'react-router-dom' export const Telemetry = () => { const navigate = useNavigate() diff --git a/src/setupTests.ts b/src/setupTests.ts index bccb50d2d..2c9bd3b0f 100644 --- a/src/setupTests.ts +++ b/src/setupTests.ts @@ -1,8 +1,9 @@ import '@testing-library/jest-dom' -import fetch from 'node-fetch' +import { WebSocket } from 'ws' import { vi } from 'vitest' import 'vitest-webgl-canvas-mock' -import { WebSocket } from 'ws' + +import fetch from 'node-fetch' // @ts-ignore globalThis.fetch = fetch diff --git a/vite.base.config.ts b/vite.base.config.ts index 515e959ee..fd213f2df 100644 --- a/vite.base.config.ts +++ b/vite.base.config.ts @@ -1,7 +1,6 @@ import { builtinModules } from 'node:module' import type { AddressInfo } from 'node:net' import type { ConfigEnv, Plugin, UserConfig } from 'vite' - import pkg from './package.json' export const builtins = [ @@ -60,20 +59,17 @@ export function getBuildDefine(env: ConfigEnv<'build'>) { .filter(({ name }) => name != null) .map(({ name }) => name!) const defineKeys = getDefineKeys(names) - const define = Object.entries(defineKeys).reduce( - (acc, [name, keys]) => { - const { VITE_DEV_SERVER_URL, VITE_NAME } = keys - const def = { - [VITE_DEV_SERVER_URL]: - command === 'serve' - ? JSON.stringify(process.env[VITE_DEV_SERVER_URL]) - : undefined, - [VITE_NAME]: JSON.stringify(name), - } - return { ...acc, ...def } - }, - {} as Record - ) + const define = Object.entries(defineKeys).reduce((acc, [name, keys]) => { + const { VITE_DEV_SERVER_URL, VITE_NAME } = keys + const def = { + [VITE_DEV_SERVER_URL]: + command === 'serve' + ? JSON.stringify(process.env[VITE_DEV_SERVER_URL]) + : undefined, + [VITE_NAME]: JSON.stringify(name), + } + return { ...acc, ...def } + }, {} as Record) return define } @@ -91,8 +87,9 @@ export function pluginExposeRenderer(name: string): Plugin { server.httpServer?.once('listening', () => { const addressInfo = server.httpServer!.address() as AddressInfo // Expose env constant for main process use. - process.env[VITE_DEV_SERVER_URL] = - `http://localhost:${addressInfo?.port}` + process.env[ + VITE_DEV_SERVER_URL + ] = `http://localhost:${addressInfo?.port}` }) }, } diff --git a/vite.config.ts b/vite.config.ts index 2fc8fae39..d4f918055 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,11 +1,11 @@ -// @ts-ignore: No types available -import { lezer } from '@lezer/generator/rollup' -import eslint from '@nabla/vite-plugin-eslint' import react from '@vitejs/plugin-react' +import viteTsconfigPaths from 'vite-tsconfig-paths' +import eslint from '@nabla/vite-plugin-eslint' +import { defineConfig, configDefaults } from 'vitest/config' import version from 'vite-plugin-package-version' import topLevelAwait from 'vite-plugin-top-level-await' -import viteTsconfigPaths from 'vite-tsconfig-paths' -import { configDefaults, defineConfig } from 'vitest/config' +// @ts-ignore: No types available +import { lezer } from '@lezer/generator/rollup' const config = defineConfig({ server: { diff --git a/vite.main.config.ts b/vite.main.config.ts index 9890813e6..89645e874 100644 --- a/vite.main.config.ts +++ b/vite.main.config.ts @@ -1,19 +1,18 @@ -// @ts-ignore: No types available -import { lezer } from '@lezer/generator/rollup' -import vitePluginEslint from '@nabla/vite-plugin-eslint' -import viteJsPluginReact from '@vitejs/plugin-react' import type { ConfigEnv, UserConfig } from 'vite' import { defineConfig, mergeConfig } from 'vite' -import vitePluginPackageVersion from 'vite-plugin-package-version' -import viteTsconfigPaths from 'vite-tsconfig-paths' import { configDefaults } from 'vitest/config' - +import viteTsconfigPaths from 'vite-tsconfig-paths' +import vitePluginEslint from '@nabla/vite-plugin-eslint' +import vitePluginPackageVersion from 'vite-plugin-package-version' import { - external, getBuildConfig, getBuildDefine, + external, pluginHotRestart, } from './vite.base.config' +import viteJsPluginReact from '@vitejs/plugin-react' +// @ts-ignore: No types available +import { lezer } from '@lezer/generator/rollup' // https://vitejs.dev/config export default defineConfig((env) => { diff --git a/vite.preload.config.ts b/vite.preload.config.ts index 898f8df24..c3a78a01a 100644 --- a/vite.preload.config.ts +++ b/vite.preload.config.ts @@ -1,12 +1,11 @@ import type { ConfigEnv, UserConfig } from 'vite' import { defineConfig, mergeConfig } from 'vite' -import viteTsconfigPaths from 'vite-tsconfig-paths' import { configDefaults } from 'vitest/config' - +import viteTsconfigPaths from 'vite-tsconfig-paths' import { - external, getBuildConfig, getBuildDefine, + external, pluginHotRestart, } from './vite.base.config' diff --git a/vite.renderer.config.ts b/vite.renderer.config.ts index 6c6d3c1ea..eaf0eb049 100644 --- a/vite.renderer.config.ts +++ b/vite.renderer.config.ts @@ -1,11 +1,10 @@ -// @ts-ignore: No types available -import { lezer } from '@lezer/generator/rollup' import type { ConfigEnv, UserConfig } from 'vite' import { defineConfig } from 'vite' -import topLevelAwait from 'vite-plugin-top-level-await' -import viteTsconfigPaths from 'vite-tsconfig-paths' - import { pluginExposeRenderer } from './vite.base.config' +import viteTsconfigPaths from 'vite-tsconfig-paths' +import topLevelAwait from 'vite-plugin-top-level-await' +// @ts-ignore: No types available +import { lezer } from '@lezer/generator/rollup' // https://vitejs.dev/config export default defineConfig((env) => { diff --git a/yarn.lock b/yarn.lock index 77b34bc93..102b37a20 100644 --- a/yarn.lock +++ b/yarn.lock @@ -89,7 +89,7 @@ "@jridgewell/trace-mapping" "^0.3.25" jsesc "^3.0.2" -"@babel/generator@^7.26.5", "@babel/generator@^7.27.0": +"@babel/generator@^7.27.0": version "7.27.0" resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.27.0.tgz#764382b5392e5b9aff93cadb190d0745866cbc2c" integrity sha512-VybsKvpiN1gU1sdMZIp7FcqphVVKEwcuj02x73uvcHE0PTihx1nlBcowYWhDwjpoAXRv43+gDzyggGnn1XZhVw== @@ -352,7 +352,7 @@ dependencies: "@babel/types" "^7.26.10" -"@babel/parser@^7.26.7", "@babel/parser@^7.27.0": +"@babel/parser@^7.27.0": version "7.27.0" resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.27.0.tgz#3d7d6ee268e41d2600091cbd4e145ffee85a44ec" integrity sha512-iaepho73/2Pz7w2eMS0Q5f83+0RKI7i4xmiYeBmDzfRVbQtTOG7Ts0S4HzJVsTMGI9keU8rNfuZr8DKfSt7Yyg== @@ -992,7 +992,7 @@ debug "^4.3.1" globals "^11.1.0" -"@babel/traverse@^7.26.10", "@babel/traverse@^7.26.7": +"@babel/traverse@^7.26.10": version "7.27.0" resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.27.0.tgz#11d7e644779e166c0442f9a07274d02cd91d4a70" integrity sha512-19lYZFzYVQkkHkl4Cy4WrAVcqBkgvV2YM2TU3xG6DIwO7O3ecbDPfW3yM3bjAGcqcQHi+CCtjMR3dIEHxsd6bA== @@ -1022,7 +1022,7 @@ "@babel/helper-string-parser" "^7.25.9" "@babel/helper-validator-identifier" "^7.25.9" -"@babel/types@^7.26.7", "@babel/types@^7.27.0": +"@babel/types@^7.27.0": version "7.27.0" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.27.0.tgz#ef9acb6b06c3173f6632d993ecb6d4ae470b4559" integrity sha512-H45s8fVLYjbhFH62dIJ3WtmJ6RSPt/3DRO0ZcT2SUiYiQyz3BLVb9ADEnLl91m74aQPS3AzzeajZHYOalWe3bg== @@ -2275,18 +2275,6 @@ resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf" integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A== -"@trivago/prettier-plugin-sort-imports@^5.2.2": - version "5.2.2" - resolved "https://registry.yarnpkg.com/@trivago/prettier-plugin-sort-imports/-/prettier-plugin-sort-imports-5.2.2.tgz#38983f0b83490a0a7d974a6f1e409fb4bf678d02" - integrity sha512-fYDQA9e6yTNmA13TLVSA+WMQRc5Bn/c0EUBditUHNfMMxN7M82c38b1kEggVE3pLpZ0FwkwJkUEKMiOi52JXFA== - dependencies: - "@babel/generator" "^7.26.5" - "@babel/parser" "^7.26.7" - "@babel/traverse" "^7.26.7" - "@babel/types" "^7.26.7" - javascript-natural-sort "^0.7.1" - lodash "^4.17.21" - "@ts-stack/markdown@^1.5.0": version "1.5.0" resolved "https://registry.yarnpkg.com/@ts-stack/markdown/-/markdown-1.5.0.tgz#5dc298a20dc3dc040143c5a5948201eb6bf5419d" @@ -6265,11 +6253,6 @@ jake@^10.8.5: filelist "^1.0.4" minimatch "^3.1.2" -javascript-natural-sort@^0.7.1: - version "0.7.1" - resolved "https://registry.yarnpkg.com/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz#f9e2303d4507f6d74355a73664d1440fb5a0ef59" - integrity sha512-nO6jcEfZWQXDhOiBtG2KvKyEptz7RVbpGP4vTD2hLBdmNQSsCiicO2Ioinv6UI4y9ukqnBpy+XZ9H6uLNgJTlw== - jest-diff@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-29.7.0.tgz#017934a66ebb7ecf6f205e84699be10afd70458a" @@ -6589,7 +6572,7 @@ lodash.merge@^4.6.2: resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== -lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.2, lodash@^4.17.20, lodash@^4.17.21: +lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.2, lodash@^4.17.20: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -7592,11 +7575,6 @@ prettier@^2.8.8: resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== -prettier@^3.5.3: - version "3.5.3" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.5.3.tgz#4fc2ce0d657e7a02e602549f053b239cb7dfe1b5" - integrity sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw== - pretty-format@^27.0.2: version "27.5.1" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.5.1.tgz#2181879fdea51a7a5851fb39d920faa63f01d88e"