mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-20 11:28:30 +08:00
Refactor platform detection to use import.meta.env.MODE instead of isPlatformNative()
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<SubscriptionsRouter>("subscriptions");
|
||||
@@ -50,7 +49,7 @@
|
||||
</LayoutCol>
|
||||
<LayoutCol class="bottom-message">
|
||||
<TextLabel italic={true} disabled={true}>
|
||||
{#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}
|
||||
</TextLabel>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<DialogStore>("dialog");
|
||||
const tooltip = getContext<TooltipStore>("tooltip");
|
||||
@@ -29,7 +28,7 @@
|
||||
{#if $tooltip.visible}
|
||||
<Tooltip />
|
||||
{/if}
|
||||
{#if isPlatformNative() && new Date() > new Date("2026-04-30")}
|
||||
{#if import.meta.env.MODE === "native" && new Date() > new Date("2026-04-30")}
|
||||
<LayoutCol class="release-candidate-expiry">
|
||||
<TextLabel>
|
||||
<p>
|
||||
|
||||
@@ -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)();
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user