diff --git a/frontend/src/components/floating-menus/ColorPicker.svelte b/frontend/src/components/floating-menus/ColorPicker.svelte index d8f62967..3a6774da 100644 --- a/frontend/src/components/floating-menus/ColorPicker.svelte +++ b/frontend/src/components/floating-menus/ColorPicker.svelte @@ -28,7 +28,6 @@ colorEquals, gradientFirstColor, } from "/src/utility-functions/colors"; - import { isPlatformNative } from "/wrapper/pkg/graphite_wasm_wrapper"; import type { FillChoice, MenuDirection, Color } from "/wrapper/pkg/graphite_wasm_wrapper"; type PresetColors = "None" | "Black" | "White" | "Red" | "Yellow" | "Green" | "Cyan" | "Blue" | "Magenta"; @@ -404,7 +403,7 @@ // TODO: Replace this temporary usage of the browser eyedropper API, that only works in Chromium-based browsers, with the custom color sampler system used by the Eyedropper tool function eyedropperSupported(): boolean { // TODO: Implement support in the desktop app for OS-level color picking - if (isPlatformNative()) return false; + if (import.meta.env.MODE === "native") return false; return window.EyeDropper !== undefined; } diff --git a/frontend/src/components/panels/Welcome.svelte b/frontend/src/components/panels/Welcome.svelte index 8a449fa5..8888fcfc 100644 --- a/frontend/src/components/panels/Welcome.svelte +++ b/frontend/src/components/panels/Welcome.svelte @@ -8,7 +8,6 @@ import type { SubscriptionsRouter } from "/src/subscriptions-router"; import { pasteFile } from "/src/utility-functions/files"; import { patchLayout } from "/src/utility-functions/widgets"; - import { isPlatformNative } from "/wrapper/pkg/graphite_wasm_wrapper"; import type { EditorWrapper, Layout } from "/wrapper/pkg/graphite_wasm_wrapper"; const subscriptions = getContext("subscriptions"); @@ -50,7 +49,7 @@ - {#if isPlatformNative()} + {#if import.meta.env.MODE === "native"} You are testing Release Candidate 4 of the 1.0 desktop release. Please regularly check Discord for the next testing build and report issues you encounter. {/if} diff --git a/frontend/src/components/widgets/inputs/NumberInput.svelte b/frontend/src/components/widgets/inputs/NumberInput.svelte index 1344efec..8fa34165 100644 --- a/frontend/src/components/widgets/inputs/NumberInput.svelte +++ b/frontend/src/components/widgets/inputs/NumberInput.svelte @@ -4,7 +4,7 @@ import FieldInput from "/src/components/widgets/inputs/FieldInput.svelte"; import { PRESS_REPEAT_DELAY_MS, PRESS_REPEAT_INTERVAL_MS } from "/src/managers/input"; import { browserVersion } from "/src/utility-functions/platform"; - import { evaluateMathExpression, isPlatformNative } from "/wrapper/pkg/graphite_wasm_wrapper"; + import { evaluateMathExpression } from "/wrapper/pkg/graphite_wasm_wrapper"; import type { ActionShortcut, EditorWrapper, NumberInputIncrementBehavior, NumberInputMode } from "/wrapper/pkg/graphite_wasm_wrapper"; const BUTTONS_LEFT = 0b0000_0001; @@ -391,7 +391,7 @@ // Because "mousemove" (and similarly, the "pointermove" event we use) is defined as not being a user-initiated "engagement gesture" event, // Safari never lets us to enter pointer lock while the mouse button is held down and we are awaiting movement to begin dragging the slider. const isSafari = browserVersion().toLowerCase().includes("safari"); - const usePointerLock = !isSafari && !isPlatformNative(); + const usePointerLock = !isSafari && import.meta.env.MODE !== "native"; // On Safari, we use a workaround involving an alternative strategy where we hide the cursor while it's within the web page // (but we can't hide it when it ventures outside the page), taking advantage of a separate (helpful) Safari bug where it @@ -404,7 +404,7 @@ // Enter dragging state if (usePointerLock) target.requestPointerLock(); - if (isPlatformNative()) { + if (import.meta.env.MODE === "native") { editor.appWindowPointerLock(); } initialValueBeforeDragging = value; diff --git a/frontend/src/components/window/MainWindow.svelte b/frontend/src/components/window/MainWindow.svelte index 0806730f..59320d84 100644 --- a/frontend/src/components/window/MainWindow.svelte +++ b/frontend/src/components/window/MainWindow.svelte @@ -10,7 +10,6 @@ import type { AppWindowStore } from "/src/stores/app-window"; import type { DialogStore } from "/src/stores/dialog"; import type { TooltipStore } from "/src/stores/tooltip"; - import { isPlatformNative } from "/wrapper/pkg/graphite_wasm_wrapper"; const dialog = getContext("dialog"); const tooltip = getContext("tooltip"); @@ -29,7 +28,7 @@ {#if $tooltip.visible} {/if} - {#if isPlatformNative() && new Date() > new Date("2026-04-30")} + {#if import.meta.env.MODE === "native" && new Date() > new Date("2026-04-30")}

diff --git a/frontend/src/components/window/TitleBar.svelte b/frontend/src/components/window/TitleBar.svelte index 1d46dd00..8ce8f6ee 100644 --- a/frontend/src/components/window/TitleBar.svelte +++ b/frontend/src/components/window/TitleBar.svelte @@ -10,7 +10,6 @@ import type { SubscriptionsRouter } from "/src/subscriptions-router"; import { patchLayout } from "/src/utility-functions/widgets"; import type { EditorWrapper, Layout } from "/wrapper/pkg/graphite_wasm_wrapper"; - import { isPlatformNative } from "/wrapper/pkg/graphite_wasm_wrapper"; const keyboardLockApiSupported = navigator.keyboard !== undefined && "lock" in navigator.keyboard; @@ -22,8 +21,8 @@ let menuBarLayout: Layout = []; - $: showFullscreenButton = $appWindow.platform === "Web" || $fullscreen.windowFullscreen || (isPlatformNative() && $appWindow.fullscreen); - $: isFullscreen = isPlatformNative() ? $appWindow.fullscreen : $fullscreen.windowFullscreen; + $: showFullscreenButton = $appWindow.platform === "Web" || $fullscreen.windowFullscreen || (import.meta.env.MODE === "native" && $appWindow.fullscreen); + $: isFullscreen = import.meta.env.MODE === "native" ? $appWindow.fullscreen : $fullscreen.windowFullscreen; // On Mac, the menu bar height needs to be scaled by the inverse of the UI scale to fit its native window buttons $: height = $appWindow.platform === "Mac" ? 28 * (1 / $appWindow.uiScale) : 28; @@ -59,7 +58,7 @@ : undefined} tooltipShortcut={$tooltip.fullscreenShortcut} on:click={() => { - if (isPlatformNative()) editor.appWindowFullscreen(); + if (import.meta.env.MODE === "native") editor.appWindowFullscreen(); else ($fullscreen.windowFullscreen ? exitFullscreen : enterFullscreen)(); }} > diff --git a/frontend/src/utility-functions/input.ts b/frontend/src/utility-functions/input.ts index d2004843..330a3bcb 100644 --- a/frontend/src/utility-functions/input.ts +++ b/frontend/src/utility-functions/input.ts @@ -7,7 +7,6 @@ import { pasteFile } from "/src/utility-functions/files"; import { makeKeyboardModifiersBitfield, textInputCleanup, getLocalizedScanCode } from "/src/utility-functions/keyboard-entry"; import { operatingSystem } from "/src/utility-functions/platform"; import type { EditorWrapper } from "/wrapper/pkg/graphite_wasm_wrapper"; -import { isPlatformNative } from "/wrapper/pkg/graphite_wasm_wrapper"; const BUTTON_LEFT = 0; const BUTTON_MIDDLE = 1; @@ -36,9 +35,9 @@ export async function shouldRedirectKeyboardEventToBackend(e: KeyboardEvent, dia const accelKey = operatingSystem() === "Mac" ? e.metaKey : e.ctrlKey; // Cut, copy, and paste is handled in the backend on desktop - if (isPlatformNative() && accelKey && ["KeyX", "KeyC", "KeyV"].includes(key)) return true; + if (import.meta.env.MODE === "native" && accelKey && ["KeyX", "KeyC", "KeyV"].includes(key)) return true; // But on web, we want to not redirect paste - if (!isPlatformNative() && key === "KeyV" && accelKey) return false; + if (import.meta.env.MODE !== "native" && key === "KeyV" && accelKey) return false; // Don't redirect user input from text entry into HTML elements if (targetIsTextField(e.target || undefined) && key !== "Escape" && !(accelKey && ["Enter", "NumpadEnter"].includes(key))) return false; @@ -57,7 +56,7 @@ export async function shouldRedirectKeyboardEventToBackend(e: KeyboardEvent, dia if (window.document.querySelector("[data-floating-menu-content]")) return false; // Web-only keyboard shortcuts - if (!isPlatformNative()) { + if (import.meta.env.MODE !== "native") { // Don't redirect a fullscreen request, but process it immediately instead if (((operatingSystem() !== "Mac" && key === "F11") || (operatingSystem() === "Mac" && e.ctrlKey && e.metaKey && key === "KeyF")) && e.type === "keydown" && !e.repeat) { e.preventDefault(); diff --git a/frontend/wrapper/src/editor_wrapper.rs b/frontend/wrapper/src/editor_wrapper.rs index 54a048ce..190a1cbf 100644 --- a/frontend/wrapper/src/editor_wrapper.rs +++ b/frontend/wrapper/src/editor_wrapper.rs @@ -909,18 +909,6 @@ impl EditorWrapper { // Static functions callable from JavaScript without an Editor instance // ==================================================================== -#[wasm_bindgen(js_name = isPlatformNative)] -pub fn is_platform_native() -> bool { - #[cfg(feature = "native")] - { - true - } - #[cfg(not(feature = "native"))] - { - false - } -} - #[wasm_bindgen(js_name = evaluateMathExpression)] pub fn evaluate_math_expression(expression: &str) -> Option { let value = math_parser::evaluate(expression)