mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
refactor: replace import.meta.env.DEV checks with isDevEnv() utility function
This commit is contained in:
parent
c22bec6485
commit
c0d48a6b9d
8 changed files with 18 additions and 10 deletions
|
@ -36,6 +36,7 @@ import {
|
|||
preventUnload,
|
||||
resolvablePromise,
|
||||
isRunningInIframe,
|
||||
isDevEnv,
|
||||
} from "@excalidraw/excalidraw/utils";
|
||||
import {
|
||||
GithubIcon,
|
||||
|
@ -383,7 +384,7 @@ const ExcalidrawWrapper = () => {
|
|||
const [, forceRefresh] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (import.meta.env.DEV) {
|
||||
if (isDevEnv()) {
|
||||
const debugState = loadSavedDebugState();
|
||||
|
||||
if (debugState.enabled && !window.visualDebug) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import { LanguageList } from "../app-language/LanguageList";
|
|||
import { isExcalidrawPlusSignedUser } from "../app_constants";
|
||||
|
||||
import { saveDebugState } from "./DebugCanvas";
|
||||
import { isDevEnv } from "@excalidraw/excalidraw/utils";
|
||||
|
||||
export const AppMainMenu: React.FC<{
|
||||
onCollabDialogOpen: () => any;
|
||||
|
@ -57,7 +58,7 @@ export const AppMainMenu: React.FC<{
|
|||
>
|
||||
{isExcalidrawPlusSignedUser ? "Sign in" : "Sign up"}
|
||||
</MainMenu.ItemLink>
|
||||
{import.meta.env.DEV && (
|
||||
{isDevEnv() && (
|
||||
<MainMenu.Item
|
||||
icon={eyeIcon}
|
||||
onClick={() => {
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
// place here categories that you want to track. We want to track just a
|
||||
|
||||
import { isDevEnv } from "./utils";
|
||||
|
||||
// small subset of categories at a given time.
|
||||
const ALLOWED_CATEGORIES_TO_TRACK = new Set(["command_palette", "export"]);
|
||||
|
||||
|
@ -21,7 +24,7 @@ export const trackEvent = (
|
|||
return;
|
||||
}
|
||||
|
||||
if (import.meta.env.DEV) {
|
||||
if (isDevEnv()) {
|
||||
// comment out to debug in dev
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import { newElement, newLinearElement, newTextElement } from "./element";
|
|||
import { randomId } from "./random";
|
||||
|
||||
import type { NonDeletedExcalidrawElement } from "./element/types";
|
||||
import { isDevEnv } from "./utils";
|
||||
|
||||
export type ChartElements = readonly NonDeletedExcalidrawElement[];
|
||||
|
||||
|
@ -373,7 +374,7 @@ const chartTypeBar = (
|
|||
y,
|
||||
groupId,
|
||||
backgroundColor,
|
||||
import.meta.env.DEV,
|
||||
isDevEnv(),
|
||||
),
|
||||
];
|
||||
};
|
||||
|
@ -455,7 +456,7 @@ const chartTypeLine = (
|
|||
y,
|
||||
groupId,
|
||||
backgroundColor,
|
||||
import.meta.env.DEV,
|
||||
isDevEnv(),
|
||||
),
|
||||
line,
|
||||
...lines,
|
||||
|
|
|
@ -14,7 +14,7 @@ import { useUIAppState } from "../../context/ui-appState";
|
|||
import { atom, useSetAtom } from "../../editor-jotai";
|
||||
import { useOutsideClick } from "../../hooks/useOutsideClick";
|
||||
import { KEYS } from "../../keys";
|
||||
import { updateObject } from "../../utils";
|
||||
import { isDevEnv, updateObject } from "../../utils";
|
||||
import { useDevice, useExcalidrawSetAppState } from "../App";
|
||||
import { Island } from "../Island";
|
||||
|
||||
|
@ -52,7 +52,7 @@ export const SidebarInner = forwardRef(
|
|||
}: SidebarProps & Omit<React.RefAttributes<HTMLDivElement>, "onSelect">,
|
||||
ref: React.ForwardedRef<HTMLDivElement>,
|
||||
) => {
|
||||
if (import.meta.env.DEV && onDock && docked == null) {
|
||||
if (isDevEnv() && onDock && docked == null) {
|
||||
console.warn(
|
||||
"Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`",
|
||||
);
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
import BinaryHeap from "../binaryheap";
|
||||
import { getSizeFromPoints } from "../points";
|
||||
import { aabbForElement, pointInsideBounds } from "../shapes";
|
||||
import { invariant, isAnyTrue, tupleToCoors } from "../utils";
|
||||
import { invariant, isAnyTrue, isDevEnv, tupleToCoors } from "../utils";
|
||||
|
||||
import {
|
||||
bindPointToSnapToElementOutline,
|
||||
|
@ -248,7 +248,7 @@ const handleSegmentRenormalization = (
|
|||
);
|
||||
}
|
||||
|
||||
import.meta.env.DEV &&
|
||||
isDevEnv() &&
|
||||
invariant(
|
||||
validateElbowPoints(nextPoints),
|
||||
"Invalid elbow points with fixed segments",
|
||||
|
|
|
@ -10,6 +10,7 @@ import {
|
|||
} from "../constants";
|
||||
import { getLineHeight } from "../fonts";
|
||||
import { randomInteger, randomId } from "../random";
|
||||
|
||||
import { getFontString, getUpdatedTimestamp } from "../utils";
|
||||
|
||||
import { getResizedElementAbsoluteCoords } from "./bounds";
|
||||
|
|
|
@ -3,6 +3,7 @@ import fallbackLangData from "./locales/en.json";
|
|||
import percentages from "./locales/percentages.json";
|
||||
|
||||
import type { NestedKeyOf } from "./utility-types";
|
||||
import { isDevEnv } from "./utils";
|
||||
|
||||
const COMPLETION_THRESHOLD = 85;
|
||||
|
||||
|
@ -73,7 +74,7 @@ export const languages: Language[] = [
|
|||
];
|
||||
|
||||
const TEST_LANG_CODE = "__test__";
|
||||
if (import.meta.env.DEV) {
|
||||
if (isDevEnv()) {
|
||||
languages.unshift(
|
||||
{ code: TEST_LANG_CODE, label: "test language" },
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue