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