diff --git a/src/frontend/src/components/forms/fields/TreeField.tsx b/src/frontend/src/components/forms/fields/TreeField.tsx index 4ff583f395..a9a9165cdd 100644 --- a/src/frontend/src/components/forms/fields/TreeField.tsx +++ b/src/frontend/src/components/forms/fields/TreeField.tsx @@ -24,7 +24,7 @@ import { ModelInformationDict } from '@lib/enums/ModelInformation'; import type { ModelType } from '@lib/enums/ModelType'; import { apiUrl } from '@lib/functions/Api'; import { cancelEvent } from '@lib/functions/Events'; -import { getDetailUrl, navigateToLink } from '@lib/index'; +import { getDetailUrl, navigateToLink } from '@lib/functions/Navigation'; import type { ApiFormFieldType } from '@lib/types/Forms'; import { useApi } from '../../../contexts/ApiContext'; import { diff --git a/src/frontend/src/components/render/Instance.tsx b/src/frontend/src/components/render/Instance.tsx index 8e8353781e..e0ae4b04d8 100644 --- a/src/frontend/src/components/render/Instance.tsx +++ b/src/frontend/src/components/render/Instance.tsx @@ -31,9 +31,9 @@ export type { InstanceRenderInterface } from '@lib/types/Rendering'; import { getBaseUrl, getDetailUrl, - navigateToLink, - shortenString -} from '@lib/index'; + navigateToLink +} from '@lib/functions/Navigation'; +import { shortenString } from '@lib/functions/String'; import { IconLink } from '@tabler/icons-react'; import { useApi } from '../../contexts/ApiContext'; import { usePluginState } from '../../states/PluginState'; diff --git a/src/frontend/src/components/render/ModelHoverCard.tsx b/src/frontend/src/components/render/ModelHoverCard.tsx index 6de4dd694b..4866af6c00 100644 --- a/src/frontend/src/components/render/ModelHoverCard.tsx +++ b/src/frontend/src/components/render/ModelHoverCard.tsx @@ -12,7 +12,7 @@ import type { NavigateFunction } from 'react-router-dom'; import { ModelInformationDict } from '@lib/enums/ModelInformation'; import type { ModelType } from '@lib/enums/ModelType'; -import { getDetailUrl, navigateToLink } from '@lib/index'; +import { getDetailUrl, navigateToLink } from '@lib/functions/Navigation'; import { IconLink } from '@tabler/icons-react'; /** diff --git a/src/frontend/src/main.tsx b/src/frontend/src/main.tsx index 14ade14584..1bbb000b3f 100644 --- a/src/frontend/src/main.tsx +++ b/src/frontend/src/main.tsx @@ -10,13 +10,13 @@ import 'mantine-datatable/styles.css'; import 'react-grid-layout/css/styles.css'; import 'react-resizable/css/styles.css'; -import type * as LinguiCore from '@lingui/core'; -import type * as LinguiReact from '@lingui/react'; +import * as LinguiCore from '@lingui/core'; +import * as LinguiReact from '@lingui/react'; // Global types to be exported for use in plugins -import type * as MantineCore from '@mantine/core'; -import type * as MantineNotifications from '@mantine/notifications'; +import * as MantineCore from '@mantine/core'; +import * as MantineNotifications from '@mantine/notifications'; import * as React from 'react'; -import type * as ReactDOM from 'react-dom'; +import * as ReactDOM from 'react-dom'; import * as ReactDOMClient from 'react-dom/client'; import './styles/overrides.css'; @@ -24,7 +24,6 @@ import './styles/overrides.css'; import { getBaseUrl } from '@lib/functions/Navigation'; import type { HostList } from '@lib/types/Server'; import MainView from './views/MainView'; -import { loadWindowGlobals } from './window'; // define settings declare global { @@ -123,5 +122,11 @@ ReactDOMClient.createRoot( ); -// Load globals onto the window object, so that they can be accessed by plugins without requiring direct imports -loadWindowGlobals(); +// All window globals assigned here since these modules are already statically bundled +window.React = React; +window.ReactDOM = ReactDOM; +window.ReactDOMClient = ReactDOMClient; +window.MantineCore = MantineCore; +window.MantineNotifications = MantineNotifications; +window.LinguiCore = LinguiCore; +window.LinguiReact = LinguiReact; diff --git a/src/frontend/src/tables/bom/UsedInTable.tsx b/src/frontend/src/tables/bom/UsedInTable.tsx index 28cb1f2060..407e5203a5 100644 --- a/src/frontend/src/tables/bom/UsedInTable.tsx +++ b/src/frontend/src/tables/bom/UsedInTable.tsx @@ -2,11 +2,12 @@ import { t } from '@lingui/core/macro'; import { Alert, Divider, Group, Stack, Text } from '@mantine/core'; import { useCallback, useMemo, useState } from 'react'; +import { RowEditAction } from '@lib/components/RowActions'; import { ApiEndpoints } from '@lib/enums/ApiEndpoints'; import { ModelType } from '@lib/enums/ModelType'; import { apiUrl } from '@lib/functions/Api'; import useTable from '@lib/hooks/UseTable'; -import { ActionButton, RowEditAction, UserRoles } from '@lib/index'; +import { ActionButton, UserRoles } from '@lib/index'; import type { TableFilter } from '@lib/types/Filters'; import type { RowAction, TableColumn } from '@lib/types/Tables'; import { IconExclamationCircle, IconReplace } from '@tabler/icons-react'; diff --git a/src/frontend/src/tables/general/ParameterTable.tsx b/src/frontend/src/tables/general/ParameterTable.tsx index 996f53698d..05f3ce1227 100644 --- a/src/frontend/src/tables/general/ParameterTable.tsx +++ b/src/frontend/src/tables/general/ParameterTable.tsx @@ -1,9 +1,8 @@ +import { RowDeleteAction, RowEditAction } from '@lib/components/RowActions'; import useTable from '@lib/hooks/UseTable'; import { ApiEndpoints, ModelType, - RowDeleteAction, - RowEditAction, YesNoButton, apiUrl, formatDecimal diff --git a/src/frontend/src/tables/general/ParameterTemplateTable.tsx b/src/frontend/src/tables/general/ParameterTemplateTable.tsx index 035dfc3260..912c1a423d 100644 --- a/src/frontend/src/tables/general/ParameterTemplateTable.tsx +++ b/src/frontend/src/tables/general/ParameterTemplateTable.tsx @@ -1,11 +1,13 @@ +import { + RowDeleteAction, + RowDuplicateAction, + RowEditAction +} from '@lib/components/RowActions'; import useTable from '@lib/hooks/UseTable'; import { AddItemButton, ApiEndpoints, type ApiFormFieldSet, - RowDeleteAction, - RowDuplicateAction, - RowEditAction, UserRoles, apiUrl } from '@lib/index'; diff --git a/src/frontend/src/tables/machine/MachineListTable.tsx b/src/frontend/src/tables/machine/MachineListTable.tsx index d6e1e1d74a..e8c3b99948 100644 --- a/src/frontend/src/tables/machine/MachineListTable.tsx +++ b/src/frontend/src/tables/machine/MachineListTable.tsx @@ -23,6 +23,7 @@ import { useCallback, useMemo, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { AddItemButton } from '@lib/components/AddItemButton'; +import { RowDeleteAction, RowEditAction } from '@lib/components/RowActions'; import { StylishText } from '@lib/components/StylishText'; import { YesNoButton } from '@lib/components/YesNoButton'; import { @@ -32,7 +33,7 @@ import { import { ApiEndpoints } from '@lib/enums/ApiEndpoints'; import { apiUrl } from '@lib/functions/Api'; import useTable from '@lib/hooks/UseTable'; -import { RowDeleteAction, RowEditAction, formatDecimal } from '@lib/index'; +import { formatDecimal } from '@lib/index'; import type { RowAction, TableColumn } from '@lib/types/Tables'; import type { InvenTreeTableProps } from '@lib/types/Tables'; import { Trans } from '@lingui/react/macro'; diff --git a/src/frontend/src/tables/settings/GroupTable.tsx b/src/frontend/src/tables/settings/GroupTable.tsx index 656e177429..cafb9121d4 100644 --- a/src/frontend/src/tables/settings/GroupTable.tsx +++ b/src/frontend/src/tables/settings/GroupTable.tsx @@ -15,8 +15,9 @@ import { ApiEndpoints } from '@lib/enums/ApiEndpoints'; import { ModelType } from '@lib/enums/ModelType'; import { UserRoles } from '@lib/enums/Roles'; import { apiUrl } from '@lib/functions/Api'; +import { getDetailUrl } from '@lib/functions/Navigation'; import useTable from '@lib/hooks/UseTable'; -import { type ApiFormModalProps, getDetailUrl } from '@lib/index'; +import type { ApiFormModalProps } from '@lib/index'; import type { TableColumn, TableState } from '@lib/types/Tables'; import { IconUsersGroup } from '@tabler/icons-react'; import { useNavigate } from 'react-router-dom'; diff --git a/src/frontend/src/tables/settings/UserTable.tsx b/src/frontend/src/tables/settings/UserTable.tsx index f93fbc2300..cd8c189511 100644 --- a/src/frontend/src/tables/settings/UserTable.tsx +++ b/src/frontend/src/tables/settings/UserTable.tsx @@ -22,8 +22,9 @@ import { ApiEndpoints } from '@lib/enums/ApiEndpoints'; import { ModelType } from '@lib/enums/ModelType'; import { UserRoles } from '@lib/enums/Roles'; import { apiUrl } from '@lib/functions/Api'; +import { getDetailUrl } from '@lib/functions/Navigation'; import useTable from '@lib/hooks/UseTable'; -import { type ApiFormModalProps, getDetailUrl } from '@lib/index'; +import type { ApiFormModalProps } from '@lib/index'; import type { TableFilter } from '@lib/types/Filters'; import type { TableColumn, TableState } from '@lib/types/Tables'; import { showNotification } from '@mantine/notifications'; diff --git a/src/frontend/src/tables/stock/TransferOrderLineItemTable.tsx b/src/frontend/src/tables/stock/TransferOrderLineItemTable.tsx index 531ef4da69..c59fedceed 100644 --- a/src/frontend/src/tables/stock/TransferOrderLineItemTable.tsx +++ b/src/frontend/src/tables/stock/TransferOrderLineItemTable.tsx @@ -1,3 +1,9 @@ +import { + RowDeleteAction, + RowDuplicateAction, + RowEditAction, + RowViewAction +} from '@lib/components/RowActions'; import { ApiEndpoints } from '@lib/enums/ApiEndpoints'; import { apiUrl } from '@lib/functions/Api'; import useTable from '@lib/hooks/UseTable'; @@ -6,10 +12,6 @@ import { AddItemButton, ModelType, ProgressBar, - RowDeleteAction, - RowDuplicateAction, - RowEditAction, - RowViewAction, UserRoles, formatDecimal } from '@lib/index'; diff --git a/src/frontend/src/window.tsx b/src/frontend/src/window.tsx deleted file mode 100644 index a6f3d19f3f..0000000000 --- a/src/frontend/src/window.tsx +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Expose certain globals to the window object, so that they can be accessed by plugins, - * without requiring plugins to import these dependencies directly. - */ -export function loadWindowGlobals() { - // (window as any).React = React; - import('react').then((module) => { - window.React = module; - }); - - // (window as any).ReactDOM = ReactDOM; - import('react-dom').then((module) => { - window.ReactDOM = module; - }); - - // (window as any).ReactDOMClient = ReactDOMClient; - import('react-dom/client').then((module) => { - window.ReactDOMClient = module; - }); - - // (window as any).MantineCore = MantineCore; - import('@mantine/core').then((module) => { - window.MantineCore = module; - }); - - // (window as any).MantineNotifications = MantineNotifications; - import('@mantine/notifications').then((module) => { - window.MantineNotifications = module; - }); - - import('@lingui/core').then((module) => { - window.LinguiCore = module; - }); - - import('@lingui/react').then((module) => { - window.LinguiReact = module; - }); -}