Compare commits

..
Author SHA1 Message Date
Uriel ca358b6394 Merge branch 'main' into support-inches 2025-07-09 17:47:33 -04:00
Uriel 66ec595c09 keep underlying representation in meters 2025-07-02 21:25:45 -04:00
Uriel be8c000b36 lint 2025-06-22 06:02:29 -04:00
Uriel b2f74640f7 change manual proportion's height estimate 2025-06-22 05:50:20 -04:00
Uriel 8b67ee1a36 Merge branch 'main' into support-inches 2025-06-20 21:02:08 -04:00
Uriel 6293cf4c83 Merge branch 'main' into support-inches 2025-06-14 03:24:57 -04:00
Uriel 8a05572715 format 2025-05-24 17:24:15 -04:00
Uriel 8232a9342a start adding support for inches 2025-05-15 23:40:05 -04:00
27 changed files with 757 additions and 1211 deletions

No files matched your search

@@ -1,34 +0,0 @@
# This workflow will build the update manifest for the updater and update a GitHub release
name: Generate update manifest
on:
workflow_dispatch:
release:
types: [released]
jobs:
generate-manifest:
runs-on: ubuntu-22.04
steps:
- uses: actions/setup-node@v4
with:
node-version: '22.x'
- name: Generate update-manifest.json
run: |
npx @slimevr/update-manifest-generator@latest
- uses: actions/upload-artifact@v4
with:
name: "update-manifest.json"
path: ./update-manifest.json
- name: Upload update-manifest.json to release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ secrets.UPDATE_MANIFEST_RELEASE_TAG }}
files: ./update-manifest.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Generated
+447 -1031
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -129,7 +129,7 @@
enable = true;
toolchain = fenixpkgs.fromToolchainName {
name = rust_toolchain.toolchain.channel;
sha256 = "sha256-yMuSb5eQPO/bHv+Bcf/US8LVMbf/G/0MSfiPwBhiPpk=";
sha256 = "sha256-VZZnlyP69+Y3crrLHQyJirqlHrTtGTsyiSnZB8jEvVo=";
};
components = rust_toolchain.toolchain.components;
};
+1 -1
View File
@@ -19,7 +19,6 @@
"@tauri-apps/api": "^2.0.2",
"@tauri-apps/plugin-dialog": "^2.0.0",
"@tauri-apps/plugin-fs": "^2.0.0",
"@tauri-apps/plugin-http": "^2.5.0",
"@tauri-apps/plugin-os": "^2.0.0",
"@tauri-apps/plugin-shell": "^2.0.0",
"@tauri-apps/plugin-store": "^2.0.0",
@@ -27,6 +26,7 @@
"@twemoji/svg": "^15.0.0",
"browser-fs-access": "^0.35.0",
"classnames": "^2.5.1",
"convert": "^5.10.0",
"flatbuffers": "22.10.26",
"intl-pluralrules": "^2.0.1",
"ip-num": "^1.5.1",
+5
View File
@@ -676,6 +676,11 @@ settings-interface-appearance-font_size-description = This affects the font size
settings-interface-appearance-decorations = Use the system native decorations
settings-interface-appearance-decorations-description = This will not render the top bar of the interface and will use the operating system's instead.
settings-interface-appearance-decorations-label = Use native decorations
settings-interface-appearance-unit_system = Select unit system
settings-interface-appearance-unit_system-description = Change if you want to use the metric system or the imperial system for body measurements.
settings-interface-appearance-unit_system-placeholder = Select the unit system to use
settings-interface-appearance-unit_system-metric = Metric units
settings-interface-appearance-unit_system-imperial = Imperial units
## Notification settings
settings-interface-notifications = Notifications
-1
View File
@@ -54,7 +54,6 @@ dirs-next = "2.0.0"
discord-sdk = "0.3.6"
tokio = { version = "1.37.0", features = ["time"] }
itertools = "0.13.0"
tauri-plugin-http = "2.5.0"
[target.'cfg(windows)'.dependencies]
win32job = "1"
-8
View File
@@ -31,14 +31,6 @@
{
"identifier": "fs:scope",
"allow": [{ "path": "$APPDATA" }, { "path": "$APPDATA/**" }]
},
{
"identifier": "http:default",
"allow": [
{
"url": "https://github.com/SlimeVR/SlimeVR-Tracker-ESP/releases/download/*"
}
]
}
]
}
-1
View File
@@ -254,7 +254,6 @@ fn setup_tauri(
.plugin(tauri_plugin_os::init())
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_store::Builder::default().build())
.plugin(tauri_plugin_http::init())
.invoke_handler(tauri::generate_handler![
update_window_state,
logging,
+2 -2
View File
@@ -105,7 +105,7 @@ pub fn create_tray<R: Runtime>(app: &tauri::AppHandle<R>) -> tauri::Result<()> {
.title("SlimeVR")
.tooltip("SlimeVR")
.icon_as_template(true)
.show_menu_on_left_click(false)
.menu_on_left_click(false)
.icon(if cfg!(target_os = "macos") {
include_image!("icons/appleTrayIcon.png")
} else {
@@ -146,7 +146,7 @@ pub fn create_tray<R: Runtime>(app: &tauri::AppHandle<R>) -> tauri::Result<()> {
_ => {}
})
// We don't want this as we open the window on left click
.show_menu_on_left_click(false)
.menu_on_left_click(false)
.build(app)?;
app.manage(TrayAvailable(true));
+1 -1
View File
@@ -28,7 +28,7 @@
},
"rpm": {
"depends": [
"java-latest-openjdk",
"java-17-openjdk",
"udev"
],
"files": {
+6 -6
View File
@@ -72,7 +72,7 @@ export function DropdownItems({
<div
ref={ref}
className={classNames(
'z-[1000] fixed rounded shadow',
'z-[1000] fixed rounded shadow w-fit',
'overflow-y-auto dropdown-scroll overflow-x-hidden text-background-10',
variant == 'primary' && 'bg-background-60',
variant == 'secondary' && 'bg-background-70',
@@ -100,13 +100,13 @@ export function DropdownItems({
style={item.fontName ? { fontFamily: item.fontName } : {}}
className={classNames(
'py-2 px-4 min-w-max cursor-pointer first-of-type:*:pointer-events-none',
variant == 'primary' &&
'checked-hover:bg-background-50 text-background-20 ' +
variant === 'primary' &&
'data-checked:bg-background-40 hover:bg-background-50 text-background-20 ' +
'checked-hover:text-background-10',
variant == 'secondary' &&
'checked-hover:bg-background-60 text-background-20 ' +
variant === 'secondary' &&
'data-checked:bg-background-50 hover:bg-background-60 text-background-20 ' +
'checked-hover:text-background-10',
variant == 'tertiary' &&
variant === 'tertiary' &&
'bg-accent-background-30 checked-hover:bg-accent-background-20'
)}
onClick={() => {
@@ -0,0 +1,75 @@
import { defaultConfig, UnitType, useConfig } from '@/hooks/config';
import { useLocaleConfig } from '@/i18n/config';
import convert from 'convert';
import { useMemo } from 'react';
export function HeightDisplay({
height,
/**
* Unit type of only the input height
*/
heightUnit = 'm',
unitDisplay = 'short',
className,
roundInches = false,
}: {
heightUnit?: 'm' | 'cm' | 'in';
height: number;
unitDisplay?: 'narrow' | 'short' | 'long';
className?: string;
roundInches?: boolean;
}) {
const { currentLocales } = useLocaleConfig();
const { config } = useConfig();
const cmFormat = useMemo(
() =>
new Intl.NumberFormat(currentLocales, {
style: 'unit',
unit: 'centimeter',
unitDisplay,
maximumFractionDigits: 2,
}),
[currentLocales, unitDisplay]
);
const [footFormat, inchesFormat] = useMemo(
() => [
new Intl.NumberFormat(currentLocales, {
style: 'unit',
unit: 'foot',
unitDisplay: 'narrow',
maximumFractionDigits: 0,
roundingMode: 'trunc',
}),
new Intl.NumberFormat(currentLocales, {
style: 'unit',
unit: 'inch',
unitDisplay: 'narrow',
maximumFractionDigits: 1,
roundingMode: 'trunc',
}),
],
[currentLocales]
);
const value = useMemo(() => {
const unitSystem = config?.unitSystem ?? defaultConfig.unitSystem;
if (unitSystem === UnitType.Metric) {
return cmFormat.format(convert(height, heightUnit).to('cm'));
} else {
let totalInches = convert(height, heightUnit).to('inches');
if (roundInches) totalInches = Math.round(totalInches);
const feet = Math.trunc(totalInches / 12);
const remainingInches = totalInches % 12;
return (
(feet ? footFormat.format(feet) : '') +
inchesFormat.format(remainingInches)
);
}
}, [config?.unitSystem, height, heightUnit]);
return <span className={className}>{value}</span>;
}
+2 -2
View File
@@ -1,7 +1,7 @@
import { useLocalization } from '@fluent/react';
import { useEffect, useMemo, useContext } from 'react';
import { useForm } from 'react-hook-form';
import { useConfig } from '@/hooks/config';
import { defaultConfig, useConfig } from '@/hooks/config';
import { LangContext } from '@/i18n/config';
import { langs } from '@/i18n/names';
import { Dropdown, DropdownDirection } from './Dropdown';
@@ -17,7 +17,7 @@ export function LangSelector({
const { l10n } = useLocalization();
const { config, setConfig } = useConfig();
const { control, watch, handleSubmit } = useForm<{ lang: string }>({
defaultValues: { lang: config?.lang || 'en' },
defaultValues: { lang: config?.lang ?? defaultConfig.lang },
});
const languagesItems = useMemo(
+26 -27
View File
@@ -1,7 +1,7 @@
import { Control, Controller } from 'react-hook-form';
import { Button } from './Button';
import { Typography } from './Typography';
import { useCallback, useMemo } from 'react';
import { ReactNode, useMemo } from 'react';
import { useLocaleConfig } from '@/i18n/config';
export function NumberSelector({
@@ -14,34 +14,33 @@ export function NumberSelector({
step,
doubleStep,
disabled = false,
showButtonWithNumber = false,
showButtonWithNumber,
}: {
label?: string;
valueLabelFormat?: (value: number) => string;
valueLabelFormat?: (value: number) => string | ReactNode;
control: Control<any>;
name: string;
min: number;
max: number;
step: number | ((value: number, add: boolean) => number);
doubleStep?: number;
step: number | ((value: number, sign: number) => number);
doubleStep?: number | ((value: number, sign: number) => number);
disabled?: boolean;
showButtonWithNumber?: boolean;
showButtonWithNumber?: number;
}) {
const { currentLocales } = useLocaleConfig();
const stepFn =
typeof step === 'function'
? step
: (value: number, add: boolean) =>
+(add ? value + step : value - step).toFixed(2);
: (value: number, sign: number) => +(value + step * sign).toFixed(2);
const doubleStepFn = useCallback(
(value: number, add: boolean) =>
doubleStep === undefined
? 0
: +(add ? value + doubleStep : value - doubleStep).toFixed(2),
[doubleStep]
);
const doubleStepFn =
typeof doubleStep === 'function'
? doubleStep
: (value: number, sign: number) =>
doubleStep === undefined
? 0
: +(value + doubleStep * sign).toFixed(2);
const decimalFormat = useMemo(
() =>
@@ -66,19 +65,19 @@ export function NumberSelector({
<Button
variant="tertiary"
rounded
onClick={() => onChange(doubleStepFn(value, false))}
disabled={doubleStepFn(value, false) < min || disabled}
onClick={() => onChange(doubleStepFn(value, -1))}
disabled={doubleStepFn(value, -1) < min || disabled}
>
{showButtonWithNumber
? decimalFormat.format(-doubleStep)
{showButtonWithNumber !== undefined
? decimalFormat.format(-showButtonWithNumber)
: '--'}
</Button>
)}
<Button
variant="tertiary"
rounded
onClick={() => onChange(stepFn(value, false))}
disabled={stepFn(value, false) < min || disabled}
onClick={() => onChange(stepFn(value, -1))}
disabled={stepFn(value, -1) < min || disabled}
>
-
</Button>
@@ -90,8 +89,8 @@ export function NumberSelector({
<Button
variant="tertiary"
rounded
onClick={() => onChange(stepFn(value, true))}
disabled={stepFn(value, true) > max || disabled}
onClick={() => onChange(stepFn(value, 1))}
disabled={stepFn(value, 1) > max || disabled}
>
+
</Button>
@@ -99,11 +98,11 @@ export function NumberSelector({
<Button
variant="tertiary"
rounded
onClick={() => onChange(doubleStepFn(value, true))}
disabled={doubleStepFn(value, true) > max || disabled}
onClick={() => onChange(doubleStepFn(value, 1))}
disabled={doubleStepFn(value, 1) > max || disabled}
>
{showButtonWithNumber
? decimalFormat.format(doubleStep)
{showButtonWithNumber !== undefined
? decimalFormat.format(showButtonWithNumber)
: '++'}
</Button>
)}
@@ -0,0 +1,54 @@
import { defaultConfig, UnitType, useConfig } from '@/hooks/config';
import { Dropdown, DropdownDirection } from './Dropdown';
import { useForm } from 'react-hook-form';
import { useEffect, useMemo } from 'react';
import { useLocalization } from '@fluent/react';
export function UnitSelector({
direction = 'up',
alignment = 'right',
}: {
direction?: DropdownDirection;
alignment?: 'right' | 'left';
}) {
const { l10n } = useLocalization();
const { config, setConfig } = useConfig();
const { control, watch, handleSubmit } = useForm<{ unitSystem: UnitType }>({
defaultValues: {
unitSystem: config?.unitSystem ?? defaultConfig.unitSystem,
},
});
const unitItems = useMemo(
() =>
Object.values(UnitType).map((type) => ({
label: l10n.getString(
`settings-interface-appearance-unit_system-${type}`
),
value: type,
})),
[l10n]
);
useEffect(() => {
const subscription = watch(() => handleSubmit(onSubmit)());
return () => subscription.unsubscribe();
}, []);
const onSubmit = (value: { unitSystem: UnitType }) => {
setConfig({ unitSystem: value.unitSystem });
};
return (
<Dropdown
control={control}
name="unitSystem"
placeholder={l10n.getString(
'settings-interface-appearance-unit_system-placeholder'
)}
items={unitItems}
direction={direction}
alignment={alignment}
></Dropdown>
);
}
+3 -1
View File
@@ -4,6 +4,7 @@ import { Button } from '@/components/commons/Button';
import { SlimeVRIcon } from '@/components/commons/icon/SimevrIcon';
import { LangSelector } from '@/components/commons/LangSelector';
import { Typography } from '@/components/commons/Typography';
import { UnitSelector } from '@/components/commons/UnitSelector';
export function HomePage() {
const { l10n } = useLocalization();
@@ -23,8 +24,9 @@ export function HomePage() {
{l10n.getString('onboarding-home-start')}
</Button>
</div>
<div className="absolute right-4 bottom-4 z-50">
<div className="flex flex-col gap-3 absolute right-4 bottom-4 z-50">
<LangSelector />
<UnitSelector />
</div>
<div
className="absolute bg-accent-background-50 w-full rounded-full"
@@ -32,9 +32,9 @@ import { FullResetIcon } from '@/components/commons/icon/ResetIcon';
import { ImportIcon } from '@/components/commons/icon/ImportIcon';
import { HumanIcon } from '@/components/commons/icon/HumanIcon';
import { Typography } from '@/components/commons/Typography';
import { useLocaleConfig } from '@/i18n/config';
import { useNavigate } from 'react-router-dom';
import { ResetButton } from '@/components/home/ResetButton';
import { HeightDisplay } from '@/components/commons/HeightDisplay';
import { Vector3 } from 'three';
function IconButton({
@@ -406,7 +406,6 @@ function ButtonsControl({ control }: { control: ManualProportionControls }) {
export function ManualProportionsPage() {
const { applyProgress, state } = useOnboarding();
const { useRPCPacket } = useWebsocketAPI();
const { currentLocales } = useLocaleConfig();
const [userHeight, setUserHeight] = useState(0);
@@ -421,15 +420,6 @@ export function ManualProportionsPage() {
});
const { precise, ratio } = watch();
const { cmFormat } = useMemo(() => {
const cmFormat = Intl.NumberFormat(currentLocales, {
style: 'unit',
unit: 'centimeter',
maximumFractionDigits: 1,
});
return { cmFormat };
}, [currentLocales]);
useEffect(() => {
localStorage.setItem('ratioMode', ratio?.toString() ?? 'true');
}, [ratio]);
@@ -491,7 +481,7 @@ export function ManualProportionsPage() {
>
<div className="h-14 bg-background-50 p-4 flex items-center rounded-lg min-w-36 justify-center">
<Typography variant="main-title">
{cmFormat.format((userHeight * 100) / 0.936)}
<HeightDisplay height={userHeight / 0.936} />
</Typography>
</div>
</Tooltip>
@@ -2,8 +2,7 @@ import { useWebsocketAPI } from '@/hooks/websocket-api';
import { Button } from '@/components/commons/Button';
import { Typography } from '@/components/commons/Typography';
import { useLocalization } from '@fluent/react';
import { useEffect, useMemo } from 'react';
import { useLocaleConfig } from '@/i18n/config';
import { useEffect } from 'react';
import {
DEFAULT_FULL_HEIGHT,
EYE_HEIGHT_TO_HEIGHT_RATIO,
@@ -19,11 +18,16 @@ import {
import { NumberSelector } from '@/components/commons/NumberSelector';
import { useOnboarding } from '@/hooks/onboarding';
import { MIN_HEIGHT } from '@/hooks/manual-proportions';
import { HeightDisplay } from '@/components/commons/HeightDisplay';
import { useUnit } from '@/hooks/config';
import convert from 'convert';
interface HeightForm {
height: number;
}
const INCH_IN_METER = convert(1, 'inch').to('m');
export function ManualHeightStep({
nextStep,
prevStep,
@@ -41,8 +45,8 @@ export function ManualHeightStep({
defaultValues: { height: DEFAULT_FULL_HEIGHT },
});
const { sendRPCPacket } = useWebsocketAPI();
const { currentLocales } = useLocaleConfig();
const height = watch('height');
const currentUnit = useUnit();
// Load the last configured height
useEffect(() => {
@@ -53,16 +57,6 @@ export function ManualHeightStep({
});
}, [currentHeight]);
const mFormat = useMemo(
() =>
new Intl.NumberFormat(currentLocales, {
style: 'unit',
unit: 'meter',
maximumFractionDigits: 2,
}),
[currentLocales]
);
const submitFullHeight = (values: HeightForm) => {
const newHeight = values.height * EYE_HEIGHT_TO_HEIGHT_RATIO;
setHmdHeight(newHeight);
@@ -104,17 +98,36 @@ export function ManualHeightStep({
'onboarding-scaled_proportions-manual_height-height-v2'
)}
valueLabelFormat={(value) =>
isNaN(value)
? l10n.getString(
'onboarding-scaled_proportions-manual_height-unknown'
)
: mFormat.format(value)
isNaN(value) ? (
l10n.getString(
'onboarding-scaled_proportions-manual_height-unknown'
)
) : (
<HeightDisplay
height={value}
unitDisplay="narrow"
roundInches
/>
)
}
min={MIN_HEIGHT}
max={4}
step={0.01}
showButtonWithNumber
doubleStep={0.1}
step={
currentUnit === 'm'
? 0.01
: (v, s) =>
Math.round((v + INCH_IN_METER * s) / INCH_IN_METER) *
INCH_IN_METER
}
showButtonWithNumber={currentUnit === 'm' ? 10 : 12}
doubleStep={
currentUnit === 'm'
? 0.1
: (v, s) =>
Math.round(
(v + convert(1, 'ft').to('m') * s) / INCH_IN_METER
) * INCH_IN_METER
}
/>
</div>
<div className="flex flex-col self-center items-center justify-center">
@@ -124,7 +137,7 @@ export function ManualHeightStep({
)}
</Typography>
<Typography>
{mFormat.format(height * EYE_HEIGHT_TO_HEIGHT_RATIO)}
<HeightDisplay height={height * EYE_HEIGHT_TO_HEIGHT_RATIO} />
</Typography>
</div>
</div>
@@ -18,6 +18,7 @@ import { Range } from '@/components/commons/Range';
import { Dropdown } from '@/components/commons/Dropdown';
import { ArrowRightLeftIcon } from '@/components/commons/icon/ArrowIcons';
import { isTrayAvailable } from '@/utils/tauri';
import { UnitSelector } from '@/components/commons/UnitSelector';
import { isTauri } from '@tauri-apps/api/core';
import { TauriFileInput } from '@/components/commons/TauriFileInput';
@@ -552,6 +553,20 @@ export function InterfaceSettings() {
<div className="grid sm:grid-cols-2 pb-4">
<LangSelector alignment="left" />
</div>
<Typography bold>
{l10n.getString('settings-interface-appearance-unit_system')}
</Typography>
<div className="flex flex-col pt-1 pb-2">
<Typography color="secondary">
{l10n.getString(
'settings-interface-appearance-unit_system-description'
)}
</Typography>
</div>
<div className="grid sm:grid-cols-2 pb-4">
<UnitSelector alignment="left" />
</div>
</>
</SettingsPagePaneLayout>
</form>
+8 -2
View File
@@ -114,6 +114,13 @@ export function Serial() {
}
);
useEffect(() => {
if (consoleRef.current)
consoleRef.current.scrollTo({
top: consoleRef.current.scrollHeight,
});
}, [consoleContent]);
useEffect(() => {
const id = setInterval(() => {
if (!isSerialOpen) {
@@ -241,7 +248,7 @@ export function Serial() {
</div>
<div className="bg-background-80 rounded-lg flex-grow h-0 flex flex-col p-2">
<div
className="flex-grow overflow-auto overscroll-y-contain snap-y snap-proximity"
className="flex-grow overflow-x-auto overflow-y-auto"
ref={consoleRef}
>
<div className="flex select-text">
@@ -251,7 +258,6 @@ export function Serial() {
: l10n.getString('settings-serial-connection_lost')}
</pre>
</div>
<div className="snap-end" />
</div>
<div className="border-t-2 pt-2 border-background-60 border-solid gap-2 flex flex-row">
<div className="xs:flex flex-grow xs:flex-wrap gap-2 grid grid-cols-2">
+16 -1
View File
@@ -1,4 +1,4 @@
import { createContext, useContext, useState } from 'react';
import { createContext, useContext, useMemo, useState } from 'react';
import {
defaultValues as defaultDevSettings,
DeveloperModeWidgetForm,
@@ -25,6 +25,11 @@ export enum AssignMode {
All = 'all',
}
export enum UnitType {
Metric = 'metric',
Imperial = 'imperial',
}
export interface Config {
debug: boolean;
lang: string;
@@ -46,6 +51,7 @@ export interface Config {
showNavbarOnboarding: boolean;
vrcMutedWarnings: string[];
bvhDirectory: string | null;
unitSystem: UnitType;
}
export interface ConfigContext {
@@ -73,6 +79,7 @@ export const defaultConfig: Config = {
decorations: false,
showNavbarOnboarding: true,
vrcMutedWarnings: [],
unitSystem: UnitType.Metric,
devSettings: defaultDevSettings,
bvhDirectory: null,
};
@@ -201,3 +208,11 @@ export function useConfig() {
}
return context;
}
export function useUnit() {
const { config } = useConfig();
return useMemo(() => {
const unitSystem = config?.unitSystem ?? defaultConfig.unitSystem;
return unitSystem === UnitType.Metric ? 'm' : 'in';
}, [config?.unitSystem]);
}
+41 -39
View File
@@ -1,9 +1,11 @@
import { BoardType, DeviceDataT } from 'solarxr-protocol';
import { fetch as tauriFetch } from '@tauri-apps/plugin-http';
import { cacheWrap } from './cache';
import semver from 'semver';
import { hostname, locale, platform, version } from '@tauri-apps/plugin-os';
type DeployDataJson = Map<string, string>;
type DeployData = Map<number, Date>;
export interface FirmwareRelease {
name: string;
version: string;
@@ -24,49 +26,49 @@ const hash = (str: string) => {
return (hash >>> 0) / 2 ** 32;
};
const uniqueUserKey = `${await hostname()}-${await locale()}-${platform()}-${version()}`;
const firstAsset = (assets: any[], name: string) =>
assets.find((asset: any) => asset.name === name && asset.browser_download_url);
const checkUserCanUpdate = async (url: string, fwVersion: string) => {
if (!url) return true;
const deployDataJson = JSON.parse(
(await cacheWrap(
`firmware-${fwVersion}-deploy`,
() =>
tauriFetch(url)
.then((res) => res.text())
.catch(() => null),
60 * 60 * 1000
)) || 'null'
const processDeployData = (sortedMap: [string, string][]) => {
const deployData: DeployData = new Map();
let minTime = 0;
for (const [percent, date] of sortedMap) {
const d = new Date(date);
if (d.getTime() <= minTime) return null; // Dates in the wrong order / cancel
minTime = d.getTime();
deployData.set(parseFloat(percent), new Date(date));
}
return deployData;
};
const checkUserCanUpdate = async (deployAssetUrl: string) => {
if (!deployAssetUrl) return false;
const deployDataJson: DeployData | null = await fetch(deployAssetUrl)
.then((res) => res.json())
.catch(() => null);
if (!deployDataJson) return false;
const deployDataMap = new Map(
Object.entries(deployDataJson)
) as unknown as DeployDataJson;
const sortedMap = [...deployDataMap].sort(
([a], [b]) => parseFloat(b) - parseFloat(a)
);
if (!deployDataJson) return true;
const deployData = (
Object.entries(deployDataJson).map(([key, val]) => {
return [parseFloat(key), new Date(val as string)];
}) as [number, Date][]
).sort(([a], [b]) => a - b);
if (sortedMap.keys().find((key) => key > 1 || key <= 0)) return false; // values outside boundaries / cancel
if (deployData.find(([key]) => key > 1 || key <= 0)) return false; // values outside boundaries / cancel
if (
deployData.find(
([, date], index) =>
index > 0 && date.getTime() < deployData[index - 1][1].getTime()
)
)
return false; // Dates in the wrong order / cancel
const todayUpdateRange = deployData.find(([, date], index) => {
if (index === 0 && Date.now() < date.getTime()) return true;
return Date.now() >= date.getTime();
})?.[0];
const deployData = processDeployData(sortedMap);
if (!deployData) return false;
const todayUpdateRange = deployData
.entries()
.find(([, date]) => Date.now() >= date.getTime())?.[0];
if (!todayUpdateRange) return false;
const uniqueUserKey = `${await hostname()}-${await locale()}-${platform()}-${version()}`;
// Make it so the hash change every version. Prevent the same user from getting the same delay
return hash(`${uniqueUserKey}-${fwVersion}`) <= todayUpdateRange;
return hash(`${uniqueUserKey}-${version}`) <= todayUpdateRange;
};
export async function fetchCurrentFirmwareRelease(): Promise<FirmwareRelease | null> {
@@ -85,6 +87,7 @@ export async function fetchCurrentFirmwareRelease(): Promise<FirmwareRelease | n
const processedReleses = [];
for (const release of releases) {
const fwAsset = firstAsset(release.assets, 'BOARD_SLIMEVR-firmware.bin');
const deployAsset = firstAsset(release.assets, 'deploy.json');
if (!release.assets || !fwAsset /* || release.prerelease */) continue;
let version = release.tag_name;
@@ -92,11 +95,10 @@ export async function fetchCurrentFirmwareRelease(): Promise<FirmwareRelease | n
version = version.substring(1);
}
const deployAsset = firstAsset(release.assets, 'deploy.json');
const userCanUpdate = await checkUserCanUpdate(
deployAsset?.browser_download_url,
version
);
const userCanUpdate = !deployAsset
? true
: await checkUserCanUpdate(deployAsset?.browser_download_url);
processedReleses.push({
name: release.name,
version,
+4
View File
@@ -2,6 +2,7 @@ import { createContext, useContext, useEffect, useMemo, useState } from 'react';
import { useWebsocketAPI } from './websocket-api';
import { RpcMessage, SettingsRequestT, SettingsResponseT } from 'solarxr-protocol';
import { MIN_HEIGHT } from './manual-proportions';
import convert from 'convert';
export interface HeightContext {
hmdHeight: number | null;
@@ -73,4 +74,7 @@ export const EYE_HEIGHT_TO_HEIGHT_RATIO = 0.936;
// Based on average human height (1.65m)
// From https://ourworldindata.org/human-height (January 2024)
export const DEFAULT_FULL_HEIGHT = 1.65;
export const DEFAULT_FULL_HEIGHT_INCHES = Math.round(
convert(DEFAULT_FULL_HEIGHT, 'm').to('in')
);
export const DEFAULT_EYE_HEIGHT = DEFAULT_FULL_HEIGHT * EYE_HEIGHT_TO_HEIGHT_RATIO;
+3 -1
View File
@@ -258,10 +258,12 @@ const config = {
addUtilities({
'.text-main-title': textConfig('calc(var(--font-size-title) / 16)', 700),
'.text-section-title': textConfig('calc(var(--font-size-vr) / 16)', 700),
'.text-standard': textConfig('calc(var(--font-size-standard) / 16)', 500),
'.text-standard-bold': textConfig('calc(var(--font-size-standard) / 16)', 700),
'.text-vr-accesible': textConfig('calc(var(--font-size-vr) / 16)', 500),
'.text-vr-accesible-bold': textConfig('calc(var(--font-size-vr) / 16)', 700),
'.text-standard-bold': textConfig('calc(var(--font-size-standard) / 16)', 700),
});
}),
plugin(function ({ addVariant }) {
+1 -1
View File
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "es2022",
"lib": ["dom", "dom.iterable", "ES2023"],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
+8 -16
View File
@@ -62,9 +62,6 @@ importers:
'@tauri-apps/plugin-fs':
specifier: ^2.0.0
version: 2.0.0
'@tauri-apps/plugin-http':
specifier: ^2.5.0
version: 2.5.0
'@tauri-apps/plugin-os':
specifier: ^2.0.0
version: 2.0.0
@@ -86,6 +83,9 @@ importers:
classnames:
specifier: ^2.5.1
version: 2.5.1
convert:
specifier: ^5.10.0
version: 5.10.0
flatbuffers:
specifier: 22.10.26
version: 22.10.26
@@ -488,7 +488,6 @@ packages:
'@dword-design/[email protected]':
resolution: {integrity: sha512-16A97RKtn21xLWI7Y7VhFz4WCWui+TLit/J5/l77BDpWmPi2LzgjQzDbafDDw7OUeY6GEAi/M4jdbuQhsIbSEg==}
engines: {node: '>=14'}
deprecated: Use lodash and endent
'@esbuild/[email protected]':
resolution: {integrity: sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==}
@@ -1183,9 +1182,6 @@ packages:
'@tauri-apps/[email protected]':
resolution: {integrity: sha512-3wSwmG+1kr6WrgAFKK5ijkNFPp8TT3FLj3YHUb5EwMO+3FxX4uWlfSWkeeBy+Kc1RsKzugtYLuuya+98Flj+3w==}
'@tauri-apps/[email protected]':
resolution: {integrity: sha512-hRNcdercfgpzgFrMXWwNDBN0B7vNzOzRepy6ZAmhxi5mDLVPNrTpo9MGg2tN/F7JRugj4d2aF7E1rtPXAHaetg==}
'@tauri-apps/[email protected]':
resolution: {integrity: sha512-jIsbxGWS+As1ZN7umo90nkql/ZAbrDK0GBT6UsgHSz5zSwwArICsZFFwE1pLZip5yoiV5mn3TGG2c1+v+0puzQ==}
engines: {node: '>= 10'}
@@ -1257,9 +1253,6 @@ packages:
'@tauri-apps/[email protected]':
resolution: {integrity: sha512-BNEeQQ5aH8J5SwYuWgRszVyItsmquRuzK2QRkVj8Z0sCsLnSvJFYI3JHRzzr3ltZGq1nMPtblrlZzuKqVzRawA==}
'@tauri-apps/[email protected]':
resolution: {integrity: sha512-l4M2DUIsOBIMrbj4dJZwrB4mJiB7OA/2Tj3gEbX2fjq5MOpETklJPKfDvzUTDwuq4lIKCKKykz8E8tpOgvi0EQ==}
'@tauri-apps/[email protected]':
resolution: {integrity: sha512-M7hG/nNyQYTJxVG/UhTKhp9mpXriwWzrs9mqDreB8mIgqA3ek5nHLdwRZJWhkKjZrnDT4v9CpA9BhYeplTlAiA==}
@@ -1878,6 +1871,9 @@ packages:
resolution: {integrity: sha512-cj09EBuObp9gZNQCzc7hByQyrs6jVGE+o9kSJmeUoj+GiPiJvi5LYqEH/Hmme4+MTLHM+Ejtq+FChpjjEnsPdQ==}
engines: {node: '>= 4'}
[email protected]:
resolution: {integrity: sha512-1agZ7UULsa0AVUZefVDmfy7hdHDIm7hr/tB8scKwSy8HE8a+5c3EQsCTEQfx6/+8LGNa7Re2+4fir9mKxFsBuw==}
[email protected]:
resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==}
@@ -5415,8 +5411,6 @@ snapshots:
'@tauri-apps/[email protected]': {}
'@tauri-apps/[email protected]': {}
'@tauri-apps/[email protected]':
optional: true
@@ -5468,10 +5462,6 @@ snapshots:
dependencies:
'@tauri-apps/api': 2.0.2
'@tauri-apps/[email protected]':
dependencies:
'@tauri-apps/api': 2.6.0
'@tauri-apps/[email protected]':
dependencies:
'@tauri-apps/api': 2.0.2
@@ -6172,6 +6162,8 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]: {}
[email protected]:
+1 -1
View File
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.82"
channel = "1.81"
profile = "default"
components = ["rustc", "cargo", "clippy", "rustfmt", "rust-analyzer", "rust-src"]