Skip to content

Commit

Permalink
[BUG] Vite Server Crashing Chrome (#1108)
Browse files Browse the repository at this point in the history
* Isolated at least one issue to pickup interface

* fix(vite-server)!: Vite server working with Chrome.

Removed circular dependencies and isolated key structures into separate
files. Cleanup still needed.

* fix(vite-server)!: Readd panels and modals, fix imports, cleanup.

* Formatted

* Formatted
  • Loading branch information
HunterBarclay authored Sep 5, 2024
1 parent 43f9225 commit e008481
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import InputSystem from "@/systems/input/InputSystem"
import SynthesisBrain from "@/systems/simulation/synthesis_brain/SynthesisBrain"
import { SynthesisIcons } from "@/ui/components/StyledComponents"
import { usePanelControlContext } from "@/ui/PanelContext"
import { ConfigurationType, setSelectedConfigurationType } from "@/ui/panels/configuring/assembly-config/ConfigurePanel"
import { setSelectedScheme } from "@/ui/panels/configuring/assembly-config/interfaces/inputs/ConfigureInputsInterface"
import {
setSelectedConfigurationType,
ConfigurationType,
} from "@/ui/panels/configuring/assembly-config/ConfigurationType"

const AssignNewSchemeModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
const { openPanel } = usePanelControlContext()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import InputSchemeManager from "@/systems/input/InputSchemeManager"
import DefaultInputs from "@/systems/input/DefaultInputs"
import { SynthesisIcons } from "@/ui/components/StyledComponents"
import { usePanelControlContext } from "@/ui/PanelContext"
import { ConfigurationType, setSelectedConfigurationType } from "@/ui/panels/configuring/assembly-config/ConfigurePanel"
import { setSelectedScheme } from "@/ui/panels/configuring/assembly-config/interfaces/inputs/ConfigureInputsInterface"
import {
ConfigurationType,
setSelectedConfigurationType,
} from "@/ui/panels/configuring/assembly-config/ConfigurationType"

const NewInputSchemeModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
const { openPanel } = usePanelControlContext()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { useModalControlContext } from "@/ui/ModalContext"
import { usePanelControlContext } from "@/ui/PanelContext"
import { Box } from "@mui/material"
import { useEffect, useReducer } from "react"
import { ConfigurationType, setSelectedConfigurationType } from "./assembly-config/ConfigurePanel"
import { setSelectedScheme } from "./assembly-config/interfaces/inputs/ConfigureInputsInterface"
import { ConfigurationType, setSelectedConfigurationType } from "./assembly-config/ConfigurationType"

/** We store the selected brain index globally to specify which robot the input scheme should be bound to. */
let selectedBrainIndexGlobal: number | undefined = undefined
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/** An event to save whatever configuration interface is open when it is closed */
export class ConfigurationSavedEvent extends Event {
public constructor() {
super("ConfigurationSaved")

window.dispatchEvent(this)
}

public static Listen(func: (e: Event) => void) {
window.addEventListener("ConfigurationSaved", func)
}

public static RemoveListener(func: (e: Event) => void) {
window.removeEventListener("ConfigurationSaved", func)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export enum ConfigurationType {
ROBOT,
FIELD,
INPUTS,
}

let selectedConfigurationType: ConfigurationType = ConfigurationType.ROBOT

export function setSelectedConfigurationType(type: ConfigurationType) {
selectedConfigurationType = type
}

export function getConfigurationType() {
return selectedConfigurationType
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import ConfigureSubsystemsInterface from "./interfaces/ConfigureSubsystemsInterf
import SequentialBehaviorsInterface from "./interfaces/SequentialBehaviorsInterface"
import ConfigureShotTrajectoryInterface from "./interfaces/ConfigureShotTrajectoryInterface"
import ConfigureGamepiecePickupInterface from "./interfaces/ConfigureGamepiecePickupInterface"
import { ConfigurationSavedEvent } from "./ConfigurationSavedEvent"
import { ConfigurationType, getConfigurationType, setSelectedConfigurationType } from "./ConfigurationType"

enum ConfigMode {
SUBSYSTEMS,
Expand All @@ -29,23 +31,6 @@ enum ConfigMode {
SCORING_ZONES,
}

// eslint-disable-next-line react-refresh/only-export-components
export enum ConfigurationType {
ROBOT,
FIELD,
INPUTS,
}

let selectedConfigurationType: ConfigurationType = ConfigurationType.ROBOT
// eslint-disable-next-line react-refresh/only-export-components
export function setSelectedConfigurationType(type: ConfigurationType) {
selectedConfigurationType = type
}

function getConfigurationType() {
return selectedConfigurationType
}

/** Option for selecting a robot of field */
class AssemblySelectionOption extends SelectMenuOption {
assemblyObject: MirabufSceneObject
Expand Down Expand Up @@ -125,7 +110,7 @@ class ConfigModeSelectionOption extends SelectMenuOption {
}
}

const robotModes = [
const robotModes: ConfigModeSelectionOption[] = [
new ConfigModeSelectionOption("Intake", ConfigMode.INTAKE),
new ConfigModeSelectionOption("Ejector", ConfigMode.EJECTOR),
new ConfigModeSelectionOption(
Expand All @@ -140,7 +125,9 @@ const robotModes = [
),
new ConfigModeSelectionOption("Controls", ConfigMode.CONTROLS),
]
const fieldModes = [new ConfigModeSelectionOption("Scoring Zones", ConfigMode.SCORING_ZONES)]
const fieldModes: ConfigModeSelectionOption[] = [
new ConfigModeSelectionOption("Scoring Zones", ConfigMode.SCORING_ZONES),
]

interface ConfigModeSelectionProps {
configurationType: ConfigurationType
Expand Down Expand Up @@ -207,23 +194,6 @@ const ConfigInterface: React.FC<ConfigInterfaceProps> = ({ configMode, assembly,
}
}

/** An event to save whatever configuration interface is open when it is closed */
export class ConfigurationSavedEvent extends Event {
public constructor() {
super("ConfigurationSaved")

window.dispatchEvent(this)
}

public static Listen(func: (e: Event) => void) {
window.addEventListener("ConfigurationSaved", func)
}

public static RemoveListener(func: (e: Event) => void) {
window.removeEventListener("ConfigurationSaved", func)
}
}

const ConfigurePanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
const { openPanel, closePanel } = usePanelControlContext()
const [configurationType, setConfigurationType] = useState<ConfigurationType>(getConfigurationType())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import {
ThreeMatrix4_Array,
} from "@/util/TypeConversions"
import { useTheme } from "@/ui/ThemeContext"
import { ConfigurationSavedEvent } from "../ConfigurePanel"
import Button from "@/ui/components/Button"
import { Spacer } from "@/ui/components/StyledComponents"
import { ConfigurationSavedEvent } from "../ConfigurationSavedEvent"

// slider constants
const MIN_ZONE_SIZE = 0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from "@/util/TypeConversions"
import { useTheme } from "@/ui/ThemeContext"
import { RigidNodeId } from "@/mirabuf/MirabufParser"
import { ConfigurationSavedEvent } from "../ConfigurePanel"
import { ConfigurationSavedEvent } from "../ConfigurationSavedEvent"
import Button from "@/ui/components/Button"
import { Spacer } from "@/ui/components/StyledComponents"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import MirabufSceneObject from "@/mirabuf/MirabufSceneObject"
import SelectMenu, { SelectMenuOption } from "@/ui/components/SelectMenu"
import React, { useMemo, useState } from "react"
import { ConfigurationSavedEvent } from "../ConfigurePanel"
import { ConfigurationSavedEvent } from "../ConfigurationSavedEvent"
import World from "@/systems/World"
import SliderDriver from "@/systems/simulation/driver/SliderDriver"
import HingeDriver from "@/systems/simulation/driver/HingeDriver"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import PreferencesSystem from "@/systems/preferences/PreferencesSystem"
import SequenceableBehavior from "@/systems/simulation/behavior/synthesis/SequenceableBehavior"
import GenericArmBehavior from "@/systems/simulation/behavior/synthesis/GenericArmBehavior"
import SynthesisBrain from "@/systems/simulation/synthesis_brain/SynthesisBrain"
import { ConfigurationSavedEvent } from "../ConfigurePanel"
import { ConfigurationSavedEvent } from "../ConfigurationSavedEvent"
import { SectionLabel, Spacer, SynthesisIcons } from "@/ui/components/StyledComponents"

/** Grey label for a child behavior name */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useState } from "react"
import { ConfigurationSavedEvent } from "../../ConfigurePanel"
import { ConfigurationSavedEvent } from "../../ConfigurationSavedEvent"
import SelectMenu, { SelectMenuOption } from "@/ui/components/SelectMenu"
import InputSystem from "@/systems/input/InputSystem"
import InputSchemeManager, { InputScheme } from "@/systems/input/InputSchemeManager"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import InputSchemeManager, { InputScheme } from "@/systems/input/InputSchemeMana
import Checkbox from "@/ui/components/Checkbox"
import EditInputInterface from "./EditInputInterface"
import { useCallback, useEffect, useRef, useState } from "react"
import { ConfigurationSavedEvent } from "../../ConfigurePanel"
import { ConfigurationSavedEvent } from "../../ConfigurationSavedEvent"
import { SectionDivider } from "@/ui/components/StyledComponents"

interface ConfigSchemeProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import PreferencesSystem from "@/systems/preferences/PreferencesSystem"
import { Box } from "@mui/material"
import { ButtonIcon, SectionDivider, SectionLabel, SynthesisIcons } from "@/ui/components/StyledComponents"
import { LabelSize } from "@/ui/components/Label"
import { ConfigurationSavedEvent } from "../../ConfigurePanel"
import { ConfigurationSavedEvent } from "../../ConfigurationSavedEvent"

const saveZones = (zones: ScoringZonePreferences[] | undefined, field: MirabufSceneObject | undefined) => {
if (!zones || !field) return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import PreferencesSystem from "@/systems/preferences/PreferencesSystem"
import World from "@/systems/World"
import MirabufSceneObject from "@/mirabuf/MirabufSceneObject"
import { Box } from "@mui/material"
import { ConfigurationSavedEvent } from "../../ConfigurePanel"
import { ConfigurationSavedEvent } from "../../ConfigurationSavedEvent"
import { AddButtonInteractiveColor, DeleteButton, EditButton } from "@/ui/components/StyledComponents"

const saveZones = (zones: ScoringZonePreferences[] | undefined, field: MirabufSceneObject | undefined) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ToggleButton, ToggleButtonGroup } from "@/ui/components/ToggleButtonGro
import { Alliance, ScoringZonePreferences } from "@/systems/preferences/PreferenceTypes"
import { RigidNodeId } from "@/mirabuf/MirabufParser"
import { DeltaFieldTransforms_PhysicalProp as DeltaFieldTransforms_VisualProperties } from "@/util/threejs/MeshCreation"
import { ConfigurationSavedEvent } from "../../ConfigurePanel"
import { ConfigurationSavedEvent } from "../../ConfigurationSavedEvent"

/**
* Saves ejector configuration to selected field.
Expand Down

0 comments on commit e008481

Please sign in to comment.