diff --git a/bun.lockb b/bun.lockb index f36000aa..65f64203 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 0af639ac..6869b910 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,8 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "react-is": "^18.3.1", - "react-redux": "^8.0.5", - "react-select": "^5.7.0", + "react-redux": "^9.1.2", + "react-select": "^5.8.1", "react-textarea-autosize": "^8.4.0", "redux-logger": "^3.0.6", "styled-components": "^6.0.0-beta.5", diff --git a/src/components/three-fiber/canvas-router.tsx b/src/components/three-fiber/canvas-router.tsx index 8d4dddd1..e6c6ef0b 100644 --- a/src/components/three-fiber/canvas-router.tsx +++ b/src/components/three-fiber/canvas-router.tsx @@ -12,7 +12,7 @@ import {Canvas} from '@react-three/fiber'; import {DefinitionVersionMap, KeyColorType} from '@the-via/reader'; import cubeySrc from 'assets/models/cubey.glb'; import glbSrc from 'assets/models/keyboard_components.glb'; -import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; +import React, {Suspense, useCallback, useEffect, useMemo, useRef} from 'react'; import {shallowEqual} from 'react-redux'; import { getCustomDefinitions, @@ -40,6 +40,7 @@ import {Test} from '../n-links/keyboard/test'; import {Camera} from './camera'; import {LoaderCubey} from './loader-cubey'; import {UpdateUVMaps} from './update-uv-maps'; + useGLTF.preload(cubeySrc, true, true); useGLTF.preload(glbSrc, true, true); @@ -62,7 +63,21 @@ const KeyboardBG: React.FC<{ ); }, shallowEqual); + export const CanvasRouter = () => { + return ( + + + + ); +}; + +const LazyRouter = React.lazy(async () => { + await document.fonts.load('bold 16px Fira Sans').finally(); + return {default: NonSuspenseCanvasRouter}; +}); + +export const NonSuspenseCanvasRouter = () => { const [path] = useLocation(); const body = useRef(document.body); const containerRef = useRef(null); @@ -75,9 +90,9 @@ export const CanvasRouter = () => { const definitionVersion = useAppSelector(getDesignDefinitionVersion); const theme = useAppSelector(getSelectedTheme); const accentColor = useMemo(() => theme[KeyColorType.Accent].c, [theme]); - const [fontLoaded, setLoaded] = useState(false); const showLoader = path === '/' && (!selectedDefinition || loadProgress !== 1); + useGLTF(glbSrc, true, true); const versionDefinitions: DefinitionVersionMap[] = useMemo( () => localDefinitions.filter( @@ -105,15 +120,8 @@ export const CanvasRouter = () => { ); const hideTerrainBG = showLoader; - useEffect(() => { - // Block rendering due to font legend being required to render keyboardss - document.fonts.load('bold 16px Fira Sans').finally(() => { - setLoaded(true); - }); - }, []); return ( <> -
{ ref={containerRef} > + { ) ) : null} - {fontLoaded ? ( - - ) : null} +
diff --git a/src/components/three-fiber/key-group.tsx b/src/components/three-fiber/key-group.tsx index 714518d3..a999b06a 100644 --- a/src/components/three-fiber/key-group.tsx +++ b/src/components/three-fiber/key-group.tsx @@ -1,27 +1,27 @@ import {useGLTF} from '@react-three/drei'; +import {ThreeEvent} from '@react-three/fiber'; +import glbSrc from 'assets/models/keyboard_components.glb'; import {useMemo} from 'react'; import {getBasicKeyToByte} from 'src/store/definitionsSlice'; import {useAppDispatch, useAppSelector} from 'src/store/hooks'; import {getSelectedKey} from 'src/store/keymapSlice'; -import {Keycap} from './unit-key/keycap'; +import {getExpressions} from 'src/store/macrosSlice'; +import {getSelectedSRGBTheme} from 'src/store/settingsSlice'; +import {KeyGroupProps, KeysKeys} from 'src/types/keyboard-rendering'; +import {getRGB} from 'src/utils/color-math'; import { calculateKeyboardFrameDimensions, CSSVarObject, KeycapMetric, } from 'src/utils/keyboard-rendering'; -import {getSelectedSRGBTheme} from 'src/store/settingsSlice'; -import {ThreeEvent} from '@react-three/fiber'; -import {getRGB} from 'src/utils/color-math'; +import {useSkipFontCheck} from 'src/utils/use-skip-font-check'; import {Color} from 'three'; -import glbSrc from 'assets/models/keyboard_components.glb'; -import {getExpressions} from 'src/store/macrosSlice'; import { getKeycapSharedProps, getKeysKeys, getLabels, } from '../n-links/key-group'; -import {KeyGroupProps, KeysKeys} from 'src/types/keyboard-rendering'; -import {useSkipFontCheck} from 'src/utils/use-skip-font-check'; +import {Keycap} from './unit-key/keycap'; const getSRGBArray = (keyColors: number[][]) => { return keyColors.map(([hue, sat]) => { @@ -73,23 +73,25 @@ export const KeyGroup: React.FC>> = ( const elems = useMemo(() => { return props.keys.map((k, i) => { const {meshKey} = keysKeys.coords[i]; + const {key, ...otherProps} = getKeycapSharedProps( + k, + i, + props, + keysKeys, + selectedKeyIndex, + labels, + skipFontCheck, + ); return k.d ? null : ( ); }); diff --git a/src/shims/via-app-store.ts b/src/shims/via-app-store.ts index 02bfebcc..88d7ed32 100644 --- a/src/shims/via-app-store.ts +++ b/src/shims/via-app-store.ts @@ -1,5 +1,5 @@ -import type {StoreData} from '../types/types'; import defaultsDeep from 'lodash.defaultsdeep'; +import type {StoreData} from '../types/types'; export class Store { store: StoreData; diff --git a/src/utils/device-store.ts b/src/utils/device-store.ts index ecfd1e88..6690f58d 100644 --- a/src/utils/device-store.ts +++ b/src/utils/device-store.ts @@ -10,13 +10,12 @@ import {TestKeyboardSoundsMode} from 'src/components/void/test-keyboard-sounds'; import {THEMES} from 'src/utils/themes'; import {Store} from '../shims/via-app-store'; import type { + AuthorizedDevice, DefinitionIndex, - VendorProductIdMap, Settings, - AuthorizedDevice, + VendorProductIdMap, } from '../types/types'; import {getVendorProductId} from './hid-keyboards'; - let deviceStore: Store; const defaultStoreData = { definitionIndex: {