Nav core + back stack + shortcuts

This commit is contained in:
loucass003 committed 2026-10-25 01:15:43 +02:00
1 parent 52bf583397
commit 69f5282ecc
29 files changed
+2283 -141

No files matched your search

+52
View File
@@ -1,9 +1,12 @@
import eslint from '@eslint/js';
import betterTailwind from 'eslint-plugin-better-tailwindcss';
import boundaries from 'eslint-plugin-boundaries';
import jsxA11y from 'eslint-plugin-jsx-a11y';
import solid from 'eslint-plugin-solid/configs/typescript';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import l10n from './eslint/l10n.js';
import layers from './eslint/layers.js';
// Each entry is allowed only in the files listed in `allowedIn`
const restricted = {
@@ -27,6 +30,12 @@ const restricted = {
selector: "MemberExpression[property.name='electronAPI']",
message: 'Use platform from @/lib/platform.',
},
keydown: {
allowedIn: ['src/lib/keyboard.ts', 'src/ui/motion/**'],
selector:
"CallExpression[callee.property.name='addEventListener'][arguments.0.value=/^key(down|up)$/]",
message: 'Use useShortcut from @/lib/keyboard, Escape goes to the back stack (useBack).',
},
android: {
allowedIn: ['src/app/platform/**', 'src/env.d.ts'],
selector: "Identifier[name='__ANDROID__']",
@@ -114,6 +123,49 @@ export default tseslint.config(
},
},
...restrictedOverrides(),
{
files: ['src/lib/**/*.{ts,tsx}'],
plugins: { layers },
rules: { 'layers/no-jsx': 'error' },
},
// Peer range stops at ESLint 9 but the rules only read JSX attributes
{ files: ['src/**/*.tsx'], ...jsxA11y.flatConfigs.recommended },
// Long class strings wrap into a multiline template literal, fixed by lint:fix
{
files: ['src/**/*.tsx'],
plugins: { 'better-tailwindcss': betterTailwind },
settings: { 'better-tailwindcss': { entryPoint: 'src/styles.css' } },
rules: {
'better-tailwindcss/enforce-consistent-line-wrapping': [
'error',
// Packed lines, no line per variant group. Wider than prettier so
// only really long strings wrap at JSX indentation depth.
{ printWidth: 100, group: 'never', preferSingleLine: true, strictness: 'loose' },
],
},
},
// Solid compiles `ref={x}` into an assignment the rule cannot see
{ files: ['src/**/*.tsx'], rules: { 'no-unassigned-vars': 'off' } },
// Motion hooks belong to ui primitives, pages only use the containers
{
files: ['src/**/*.{ts,tsx}'],
ignores: ['src/ui/**'],
rules: {
'no-restricted-imports': [
'error',
{
paths: [
{
name: '@/ui/motion',
importNames: ['useMotionItem'],
message: 'Only ui primitives register motion items.',
},
],
patterns: [{ group: ['@/ui/motion/*'], message: 'Import from @/ui/motion.' }],
},
],
},
},
// Local rules run in node
{ files: ['eslint/**/*.js'], languageOptions: { globals: globals.node } },
// Tests build their own bundles with made-up ids
+14
View File
@@ -0,0 +1,14 @@
// lib holds services and reactive state, anything that renders lives in ui
const noJsx = {
meta: {
type: 'problem',
messages: { jsx: 'No JSX in lib, components belong in ui.' },
schema: [],
},
create(context) {
const report = (node) => context.report({ node, messageId: 'jsx' });
return { JSXElement: report, JSXFragment: report };
},
};
export default { rules: { 'no-jsx': noJsx } };
+2
View File
@@ -43,7 +43,9 @@
"@types/node": "26.6.5",
"eslint": "10.13.0",
"eslint-import-resolver-typescript": "^4.4.4",
"eslint-plugin-better-tailwindcss": "4.10.0",
"eslint-plugin-boundaries": "7.3.0",
"eslint-plugin-jsx-a11y": "6.10.2",
"eslint-plugin-solid": "0.18.1",
"globals": "17.13.0",
"jsdom": "30.1.3",
+6 -1
View File
@@ -1,5 +1,10 @@
import { DesignPage } from '@/pages/design/design-page';
import { MotionRoot } from '@/ui/motion';
export function App() {
return <DesignPage />;
return (
<MotionRoot>
<DesignPage />
</MotionRoot>
);
}
+2
View File
@@ -5,6 +5,7 @@ import { render } from 'solid-js/web';
import { App } from '@/app/app';
import { createPlatform } from '@/app/platform/detect';
import { initErrorReporting } from '@/domain/error-reporting';
import { initKeyboard } from '@/lib/keyboard';
import { initL10n } from '@/lib/l10n';
import { setPlatform } from '@/lib/platform';
import { loadPrefs } from '@/lib/storage';
@@ -19,5 +20,6 @@ setClient(createSocketClient({ url: serverUrl() }));
await initErrorReporting();
await loadPrefs();
await initL10n();
initKeyboard();
render(() => <App />, root);
+85
View File
@@ -0,0 +1,85 @@
import { createRoot, createSignal } from 'solid-js';
import { afterEach, describe, expect, it, vi } from 'vitest';
import {
canHandleBack,
dismiss,
handleBack,
modalOpen,
pushBack,
setBackFallback,
useBack,
} from '@/lib/back-stack';
afterEach(() => setBackFallback(null));
describe('back stack', () => {
it('handles the most recent entry first', () => {
const calls: string[] = [];
const removeA = pushBack(() => calls.push('a'));
const removeB = pushBack(() => calls.push('b'));
expect(handleBack()).toBe(true);
removeB();
expect(handleBack()).toBe(true);
removeA();
expect(calls).toEqual(['b', 'a']);
expect(handleBack()).toBe(false);
});
it('falls back to history under the overlays', () => {
const back = vi.fn();
const [can, setCan] = createSignal(false);
setBackFallback({ can, back });
expect(canHandleBack()).toBe(false);
expect(handleBack()).toBe(false);
setCan(true);
expect(canHandleBack()).toBe(true);
const overlay = vi.fn();
const remove = pushBack(overlay);
handleBack();
expect(overlay).toHaveBeenCalledOnce();
expect(back).not.toHaveBeenCalled();
remove();
handleBack();
expect(back).toHaveBeenCalledOnce();
});
it('dismiss closes overlays but never goes back in history', () => {
const back = vi.fn();
setBackFallback({ can: () => true, back });
const overlay = vi.fn();
const remove = pushBack(overlay);
expect(dismiss()).toBe(true);
remove();
expect(dismiss()).toBe(false);
expect(overlay).toHaveBeenCalledOnce();
expect(back).not.toHaveBeenCalled();
});
it('tracks modal entries', () => {
const removePlain = pushBack(() => {});
expect(modalOpen()).toBe(false);
const removeModal = pushBack(() => {}, { modal: true });
expect(modalOpen()).toBe(true);
removeModal();
removePlain();
expect(modalOpen()).toBe(false);
});
it('useBack pushes while `when` holds and on top of older entries', () => {
const calls: string[] = [];
const removeOld = pushBack(() => calls.push('old'));
const [open, setOpen] = createSignal(false);
const dispose = createRoot((dispose) => {
useBack(() => calls.push('overlay'), { when: open });
return dispose;
});
handleBack();
setOpen(true);
handleBack();
setOpen(false);
handleBack();
dispose();
removeOld();
expect(calls).toEqual(['old', 'overlay', 'old']);
});
});
+62
View File
@@ -0,0 +1,62 @@
import { type Accessor, createEffect, createSignal, onCleanup } from 'solid-js';
export interface BackOptions {
// Dialogs: page-scope shortcuts are suspended while one is on the stack
modal?: boolean;
}
export interface BackFallback {
can: Accessor<boolean>;
back(): void;
}
interface Entry {
handle: () => void;
modal: boolean;
}
const [entries, setEntries] = createSignal<readonly Entry[]>([]);
const [fallback, setFallback] = createSignal<BackFallback | null>(null);
export function pushBack(handle: () => void, options: BackOptions = {}): () => void {
const entry: Entry = { handle, modal: options.modal ?? false };
setEntries((list) => [...list, entry]);
return () => setEntries((list) => list.filter((e) => e !== entry));
}
export function useBack(
handle: () => void,
options: BackOptions & { when?: Accessor<boolean> } = {}
) {
createEffect(() => {
if (options.when && !options.when()) return;
onCleanup(pushBack(handle, options));
});
}
export function setBackFallback(next: BackFallback | null) {
setFallback(() => next);
}
export function dismiss(): boolean {
const top = entries().at(-1);
if (!top) return false;
top.handle();
return true;
}
export function handleBack(): boolean {
if (dismiss()) return true;
const history = fallback();
if (!history?.can()) return false;
history.back();
return true;
}
export function canHandleBack(): boolean {
return entries().length > 0 || (fallback()?.can() ?? false);
}
export function modalOpen(): boolean {
return entries().some((e) => e.modal);
}
+125
View File
@@ -0,0 +1,125 @@
import { createRoot } from 'solid-js';
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
import { pushBack, setBackFallback } from '@/lib/back-stack';
import { captureKeys, initKeyboard, shortcuts, useShortcut } from '@/lib/keyboard';
import { setPlatform } from '@/lib/platform';
import { fakePlatform } from '@/lib/platform-fake';
let uninstall: () => void;
const disposers: (() => void)[] = [];
function shortcut(...args: Parameters<typeof useShortcut>) {
createRoot((dispose) => {
useShortcut(...args);
disposers.push(dispose);
});
}
function press(
key: string,
init: KeyboardEventInit = {},
target: EventTarget = document.body
) {
const event = new KeyboardEvent('keydown', {
key,
bubbles: true,
cancelable: true,
...init,
});
target.dispatchEvent(event);
return event;
}
beforeAll(() => setPlatform(fakePlatform()));
beforeEach(() => {
uninstall = initKeyboard();
});
afterEach(() => {
uninstall();
disposers.splice(0).forEach((d) => d());
document.body.innerHTML = '';
});
describe('keyboard', () => {
it('sends Escape to the top overlay', () => {
const back = vi.fn();
const remove = pushBack(back);
const event = press('Escape');
remove();
expect(back).toHaveBeenCalledOnce();
expect(event.defaultPrevented).toBe(true);
expect(press('Escape').defaultPrevented).toBe(false);
});
it('never sends Escape to history', () => {
const history = vi.fn();
setBackFallback({ can: () => true, back: history });
press('Escape');
setBackFallback(null);
expect(history).not.toHaveBeenCalled();
});
it('matches Mod as Ctrl off macOS and ignores shift on symbols', () => {
const k = vi.fn();
const help = vi.fn();
shortcut('Mod+K', k, { scope: 'global' });
shortcut('?', help, { scope: 'global' });
press('k', { ctrlKey: true });
press('K', { ctrlKey: true, shiftKey: true });
press('?', { shiftKey: true });
expect(k).toHaveBeenCalledOnce();
expect(help).toHaveBeenCalledOnce();
});
it('ignores shortcuts while typing unless opted in', () => {
const plain = vi.fn();
const typed = vi.fn();
shortcut('F1', plain);
shortcut('F2', typed, { inTextEntry: true });
const input = document.createElement('input');
document.body.append(input);
press('F1', {}, input);
press('F2', {}, input);
expect(plain).not.toHaveBeenCalled();
expect(typed).toHaveBeenCalledOnce();
});
it('suspends page shortcuts while a dialog is open', () => {
const page = vi.fn();
const global = vi.fn();
shortcut('F1', page);
shortcut('F2', global, { scope: 'global' });
const remove = pushBack(() => {}, { modal: true });
press('F1');
press('F2');
remove();
press('F1');
expect(page).toHaveBeenCalledOnce();
expect(global).toHaveBeenCalledOnce();
});
it('gives every key to a capture, Escape included', () => {
const back = vi.fn();
const f1 = vi.fn();
const captured: string[] = [];
const removeBack = pushBack(back);
shortcut('F1', f1);
const release = captureKeys((e) => captured.push(e.key));
press('Escape');
press('F1');
release();
removeBack();
expect(captured).toEqual(['Escape', 'F1']);
expect(back).not.toHaveBeenCalled();
expect(f1).not.toHaveBeenCalled();
});
it('lists labelled shortcuts and warns on duplicates', () => {
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
shortcut('F1', () => {}, { label: 'help' });
shortcut('F1', () => {});
shortcut('F1', () => {}, { scope: 'global' });
expect(warn).toHaveBeenCalledOnce();
expect(shortcuts()).toEqual([{ combo: 'F1', scope: 'page', label: 'help' }]);
});
});
+176
View File
@@ -0,0 +1,176 @@
import { createSignal, onCleanup } from 'solid-js';
import { dismiss, modalOpen } from '@/lib/back-stack';
import { platform } from '@/lib/platform';
export type ShortcutScope = 'global' | 'page';
export interface ShortcutOptions {
scope?: ShortcutScope;
label?: string;
inTextEntry?: boolean;
}
export interface ShortcutInfo {
combo: string;
scope: ShortcutScope;
label: string;
}
interface Combo {
key: string;
ctrl: boolean;
alt: boolean;
meta: boolean;
shift: boolean | null;
}
interface Shortcut {
combo: string;
parsed: Combo;
fn: (e: KeyboardEvent) => void;
scope: ShortcutScope;
label?: string;
inTextEntry: boolean;
}
const TEXT_INPUT_TYPES = new Set([
'text',
'search',
'url',
'tel',
'email',
'password',
'number',
'date',
'datetime-local',
'month',
'week',
'time',
]);
// A field where keystrokes are text
export function isTextEntry(el: EventTarget | null): boolean {
if (!(el instanceof HTMLElement)) return false;
if (el.isContentEditable) return true;
if (el instanceof HTMLTextAreaElement || el instanceof HTMLSelectElement) return true;
return el instanceof HTMLInputElement && TEXT_INPUT_TYPES.has(el.type);
}
function normalizeKey(key: string): string {
return key.length === 1 ? key.toLowerCase() : key;
}
// "Mod+K", "Shift+F1", "?". Mod is Cmd on macOS, Ctrl elsewhere
function parseCombo(combo: string): Combo {
const parts = combo.split('+');
const key = normalizeKey(parts.pop() ?? '');
const mods = new Set(parts.map((p) => p.toLowerCase()));
const mod = mods.has('mod');
const mac = platform.os === 'macos';
const symbol =
key.length === 1 && key.toUpperCase() === key.toLowerCase() && key !== ' ';
return {
key,
ctrl: mods.has('ctrl') || (mod && !mac),
alt: mods.has('alt'),
meta: mods.has('meta') || (mod && mac),
shift: symbol && !mods.has('shift') ? null : mods.has('shift'),
};
}
function matches(c: Combo, e: KeyboardEvent): boolean {
return (
normalizeKey(e.key) === c.key &&
e.ctrlKey === c.ctrl &&
e.altKey === c.alt &&
e.metaKey === c.meta &&
(c.shift === null || e.shiftKey === c.shift)
);
}
const [registered, setRegistered] = createSignal<readonly Shortcut[]>([]);
const captures: ((e: KeyboardEvent) => void)[] = [];
// Cheatsheet source
export function shortcuts(): ShortcutInfo[] {
return registered().flatMap((s) =>
s.label ? [{ combo: s.combo, scope: s.scope, label: s.label }] : []
);
}
export function useShortcut(
combo: string,
fn: (e: KeyboardEvent) => void,
options: ShortcutOptions = {}
) {
const shortcut: Shortcut = {
combo,
parsed: parseCombo(combo),
fn,
scope: options.scope ?? 'page',
label: options.label,
inTextEntry: options.inTextEntry ?? false,
};
if (import.meta.env.DEV) {
const same = registered().find(
(s) =>
s.scope === shortcut.scope &&
JSON.stringify(s.parsed) === JSON.stringify(shortcut.parsed)
);
if (same)
console.warn(`Shortcut ${combo} registered twice in scope ${shortcut.scope}`);
}
setRegistered((list) => [...list, shortcut]);
onCleanup(() => setRegistered((list) => list.filter((s) => s !== shortcut)));
}
export function captureKeys(fn: (e: KeyboardEvent) => void): () => void {
captures.push(fn);
return () => {
const i = captures.lastIndexOf(fn);
if (i >= 0) captures.splice(i, 1);
};
}
export function isCapturing(): boolean {
return captures.length > 0;
}
function onCapturePhase(e: KeyboardEvent) {
const capture = captures.at(-1);
if (!capture) return;
e.preventDefault();
e.stopPropagation();
capture(e);
}
function onBubblePhase(e: KeyboardEvent) {
if (e.defaultPrevented || isCapturing()) return;
if (e.key === 'Escape' && !e.ctrlKey && !e.altKey && !e.metaKey && !e.shiftKey) {
// Never history: desktop Escape does not go to the previous page
if (dismiss()) e.preventDefault();
return;
}
const typing = isTextEntry(e.target);
const suspended = modalOpen();
// Latest registration wins
for (const s of [...registered()].reverse()) {
if (!matches(s.parsed, e)) continue;
if (typing && !s.inTextEntry) continue;
if (s.scope === 'page' && suspended) continue;
e.preventDefault();
s.fn(e);
return;
}
}
export function initKeyboard(target: Window = window): () => void {
target.addEventListener('keydown', onCapturePhase, true);
target.addEventListener('keydown', onBubblePhase);
return () => {
target.removeEventListener('keydown', onCapturePhase, true);
target.removeEventListener('keydown', onBubblePhase);
};
}
-5
View File
@@ -5,11 +5,6 @@ export {
type MessageArgs,
type MessageId,
} from '@/lib/l10n/translate';
export {
Localized,
type LocalizedElems,
type LocalizedProps,
} from '@/lib/l10n/localized';
export {
DEFAULT_LOCALE,
availableLocales,
@@ -1,5 +1,6 @@
import { For } from 'solid-js';
import { IconGallery } from './icon-gallery';
import { MotionDemo } from './motion-demo';
// Dev only token and primitive showcase
@@ -116,6 +117,7 @@ export function DesignPage() {
</div>
</div>
<MotionDemo />
<IconGallery />
</div>
);
+11 -3
View File
@@ -130,7 +130,10 @@ const ICONS: IconEntry[] = [
['material-symbols/head-mounted-device-rounded', HeadMountedDeviceIcon],
['slime/hip', HipIcon],
['material-symbols/home', HomeIcon],
['material-symbols/horizontal-align-center-rounded', HorizontalAlignCenterIcon],
[
'material-symbols/horizontal-align-center-rounded',
HorizontalAlignCenterIcon,
],
['slime/layout', LayoutIcon],
['material-symbols/lightbulb-rounded', LightbulbIcon],
['slime/lower-arm', LowerArmIcon],
@@ -218,11 +221,16 @@ export function IconGallery() {
<For each={ICONS}>
{([path, icon]) => (
<div
class="bg-surface-control hover:bg-surface-hover flex min-w-0 flex-col items-center gap-xs rounded-md p-sm text-center"
class="
bg-surface-control hover:bg-surface-hover flex min-w-0 flex-col items-center gap-xs
rounded-md p-sm text-center
"
title={path}
>
<Dynamic component={icon} />
<span class="w-full truncate">{path.slice(path.indexOf('/') + 1)}</span>
<span class="w-full truncate">
{path.slice(path.indexOf('/') + 1)}
</span>
</div>
)}
</For>
@@ -0,0 +1,234 @@
/* eslint-disable no-restricted-imports -- dev demo registers raw elements, primitives come later */
import { createSignal, For, type JSX, onCleanup, Show } from 'solid-js';
import { canHandleBack, setBackFallback, useBack } from '@/lib/back-stack';
import { useShortcut } from '@/lib/keyboard';
import {
type Direction,
MotionGrid,
MotionList,
MotionRegion,
MotionToolbar,
motionActive,
motionEditing,
onBump,
type MotionItemOptions,
useMotionItem,
} from '@/ui/motion';
// Dev only playground for arrows, Ctrl/Alt+Arrow, Tab and gamepad
const CONTROL =
'bg-surface-control hover:bg-surface-hover rounded-md px-md py-xs text-left';
function DemoButton(
props: { children: JSX.Element; onClick?: () => void } & MotionItemOptions
) {
let ref!: HTMLButtonElement;
useMotionItem(() => ref, props);
return (
<button
ref={ref}
type="button"
class={CONTROL}
onClick={() => props.onClick?.()}
>
{props.children}
</button>
);
}
function DemoInput(props: { type: string; label: string } & MotionItemOptions) {
let ref!: HTMLInputElement;
useMotionItem(() => ref, props);
return (
<label class="flex items-center gap-sm">
<span class="w-24 shrink-0">{props.label}</span>
<input
ref={ref}
type={props.type}
class="bg-surface-well rounded-md px-sm py-xs"
/>
</label>
);
}
// Pad: A enters edit mode, then left/right change the value. Keyboard: owns left/right.
function DemoDial() {
let ref!: HTMLButtonElement;
const [value, setValue] = createSignal(0);
const { editing } = useMotionItem(() => ref, {
owns: 'horizontal',
edit: true,
});
function onKeyDown(e: KeyboardEvent) {
if (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return;
e.preventDefault();
setValue((v) => v + (e.key === 'ArrowLeft' ? -1 : 1));
}
return (
<button ref={ref} type="button" class={CONTROL} onKeyDown={onKeyDown}>
dial {value()} {editing() ? '(editing)' : '(pad: A to edit)'}
</button>
);
}
function Status() {
const [bump, setBump] = createSignal<Direction | null>(null);
const [shortcutHits, setShortcutHits] = createSignal(0);
onCleanup(onBump(setBump));
useShortcut('Mod+K', () => setShortcutHits((n) => n + 1));
return (
<div class="font-mono flex flex-wrap gap-lg">
<span>active: {String(motionActive())}</span>
<span>editing: {motionEditing() ? 'yes' : 'no'}</span>
<span>last bump: {bump() ?? '-'}</span>
<span>Mod+K hits: {shortcutHits()}</span>
</div>
);
}
// Inline stand-ins for overlays until dialogs exist. Closing puts focus back on the opener.
function DemoOverlay(props: {
title: string;
modal?: boolean;
onClose: () => void;
children?: JSX.Element;
}) {
const opener = document.activeElement;
function close() {
props.onClose();
if (opener instanceof HTMLElement) opener.focus();
}
useBack(close, {
get modal() {
return props.modal;
},
});
return (
<MotionRegion class="surface-overlay flex flex-col gap-sm rounded-lg p-md">
<span>
{props.title} {props.modal ? '(modal: Mod+K suspended)' : ''}
</span>
<MotionList class="flex flex-col gap-sm">
{props.children}
<DemoButton onClick={close}>close</DemoButton>
</MotionList>
</MotionRegion>
);
}
function BackStackDemo() {
const [page, setPage] = createSignal(1);
const [panel, setPanel] = createSignal(false);
const [dialog, setDialog] = createSignal(false);
const [log, setLog] = createSignal<string[]>([]);
function record(line: string) {
setLog((list) => [line, ...list].slice(0, 5));
}
// Fake router history under the overlays: pad B goes back, Escape does not
setBackFallback({
can: () => page() > 1,
back: () => {
record(`history: page ${page()} -> ${page() - 1}`);
setPage((p) => p - 1);
},
});
onCleanup(() => setBackFallback(null));
return (
<div class="flex flex-col gap-sm">
<span class="font-mono">
page {page()}, can handle back: {String(canHandleBack())}
</span>
<MotionToolbar class="flex flex-wrap gap-sm">
<DemoButton onClick={() => setPage((p) => p + 1)}>next page</DemoButton>
<DemoButton onClick={() => setPanel(true)}>open panel</DemoButton>
</MotionToolbar>
<Show when={panel()}>
<DemoOverlay
title="panel"
onClose={() => {
record('panel closed');
setPanel(false);
}}
>
<DemoInput type="text" label="Escape here" owns="horizontal" />
<DemoButton onClick={() => setDialog(true)}>
open dialog on top
</DemoButton>
</DemoOverlay>
</Show>
<Show when={dialog()}>
<DemoOverlay
title="dialog"
modal
onClose={() => {
record('dialog closed');
setDialog(false);
}}
/>
</Show>
<ol class="font-mono flex flex-col">
<For each={log()}>{(line) => <li>{line}</li>}</For>
</ol>
</div>
);
}
export function MotionDemo() {
return (
<div class="surface-page flex flex-col gap-md rounded-lg p-lg">
<span class="text-section">motion</span>
<Status />
<div class="flex gap-lg">
<MotionRegion class="surface-sidebar flex w-40 shrink-0 flex-col gap-sm rounded-lg p-md">
<For each={['home', 'body', 'setup', 'settings']}>
{(name) => <DemoButton>{name}</DemoButton>}
</For>
</MotionRegion>
<MotionRegion class="flex flex-1 flex-col gap-lg">
<MotionToolbar class="flex gap-sm">
<For each={['bold', 'italic', 'underline', 'strike']}>
{(name) => <DemoButton>{name}</DemoButton>}
</For>
</MotionToolbar>
<MotionGrid class="grid grid-cols-3 gap-sm">
<For each={Array.from({ length: 8 }, (_, i) => i + 1)}>
{(n) => <DemoButton>card {n}</DemoButton>}
</For>
</MotionGrid>
<MotionList class="flex flex-col gap-sm">
<DemoInput type="text" label="text" owns="horizontal" />
<DemoInput type="number" label="number" owns="all" />
<DemoInput type="range" label="range" owns="horizontal" />
<DemoDial />
</MotionList>
<BackStackDemo />
<MotionList class="bg-surface-well flex h-40 flex-col gap-xs overflow-auto rounded-md p-sm">
<For each={Array.from({ length: 20 }, (_, i) => i + 1)}>
{(n) => <DemoButton>scroll row {n}</DemoButton>}
</For>
</MotionList>
<MotionRegion
trap
class="surface-card flex flex-col gap-sm rounded-lg p-md"
>
<span>trapped region: moves bump, leave with Tab or the mouse</span>
<MotionToolbar class="flex gap-sm">
<DemoButton>ok</DemoButton>
<DemoButton>cancel</DemoButton>
</MotionToolbar>
</MotionRegion>
</MotionRegion>
</div>
</div>
);
}
+4
View File
@@ -580,6 +580,10 @@
outline-offset: 2px;
}
.motion-active :focus-visible {
outline: none;
}
::-webkit-scrollbar {
width: 8px;
height: 8px;
@@ -1,12 +1,7 @@
import { render } from '@solidjs/testing-library';
import { describe, expect, it } from 'vitest';
import {
createBundle,
setL10nBundles,
Localized,
type LocalizedElems,
} from '@/lib/l10n';
import { splitMarkup } from '@/lib/l10n/localized';
import { createBundle, setL10nBundles } from '@/lib/l10n';
import { Localized, type LocalizedElems, splitMarkup } from '@/ui/localized';
function renderLocalized(id: string, elems: LocalizedElems) {
return render(() => <Localized id={id} elems={elems} />);
@@ -1,5 +1,5 @@
import type { JSX } from 'solid-js';
import { t, type MessageArgs, type MessageId } from '@/lib/l10n/translate';
import { t, type MessageArgs, type MessageId } from '@/lib/l10n';
export type LocalizedElems = Partial<
Record<string, (children: string) => JSX.Element>
+83
View File
@@ -0,0 +1,83 @@
import {
createContext,
type JSX,
mergeProps,
onCleanup,
splitProps,
useContext,
} from 'solid-js';
import {
attachContainer,
createContainer,
type MotionContainer,
type MotionEntry,
type MotionLayout,
type MotionOrientation,
} from './core';
export const MotionParent = createContext<MotionContainer | null>(null);
export interface MotionContainerProps extends JSX.HTMLAttributes<HTMLDivElement> {
entry?: MotionEntry;
}
type ContainerElementProps = MotionContainerProps & {
orientation?: MotionOrientation;
trap?: boolean;
};
function renderContainer(layout: MotionLayout, props: ContainerElementProps) {
const [local, rest] = splitProps(props, [
'orientation',
'trap',
'entry',
'children',
]);
const parent = useContext(MotionParent);
const container = createContainer(layout, parent, {
orientation: () => local.orientation ?? 'vertical',
entry: () => local.entry ?? 'last',
trap: () => local.trap ?? false,
});
if (parent) onCleanup(attachContainer(container));
return (
<div {...rest} ref={(el) => (container.el = el)}>
<MotionParent.Provider value={parent ? container : null}>
{local.children}
</MotionParent.Provider>
</div>
);
}
// Children in DOM order along one axis, bumps at the ends
export function MotionList(
props: MotionContainerProps & { orientation?: MotionOrientation }
) {
return renderContainer('list', props);
}
export function MotionToolbar(props: MotionContainerProps) {
return renderContainer(
'list',
mergeProps({ role: 'toolbar' as const }, props, {
orientation: 'horizontal' as const,
})
);
}
// Moves to the aligned child in the next row or column, bumps at the edges
export function MotionGrid(props: MotionContainerProps) {
return renderContainer('grid', props);
}
// A screen area (rail, page, dialog). Its children form a list, moves out of it
// pick the nearest sibling region by geometry. `trap` keeps moves inside.
export function MotionRegion(
props: MotionContainerProps & {
orientation?: MotionOrientation;
trap?: boolean;
}
) {
return renderContainer('region', props);
}
+547
View File
@@ -0,0 +1,547 @@
import { createSignal } from 'solid-js';
import { handleBack, pushBack } from '@/lib/back-stack';
import { isCapturing, isTextEntry } from '@/lib/keyboard';
import { motionTuning } from './tuning';
export type Direction = 'up' | 'down' | 'left' | 'right';
// Which arrow directions the focused item keeps for itself
export type MotionOwns = 'none' | 'horizontal' | 'all';
// Where focus lands when a move enters a container
export type MotionEntry = 'last' | 'first' | 'nearest';
export type MotionLayout = 'list' | 'grid' | 'region' | 'root';
export type MotionOrientation = 'vertical' | 'horizontal';
export interface MotionItem {
kind: 'item';
el: HTMLElement;
parent: MotionContainer;
owns(): MotionOwns;
// Pad only: directions reach the widget after A enters edit mode
edit(): boolean;
}
export interface MotionContainer {
kind: MotionLayout;
el: HTMLElement | null;
parent: MotionContainer | null;
readonly orientation: MotionOrientation;
readonly entry: MotionEntry;
// Moves never leave it (dialogs)
readonly trap: boolean;
children: Set<MotionNode>;
last: MotionNode | null;
}
export type MotionNode = MotionItem | MotionContainer;
interface Rect {
left: number;
top: number;
right: number;
bottom: number;
}
const ZERO: Rect = { left: 0, top: 0, right: 0, bottom: 0 };
const ARROW: Record<Direction, string> = {
up: 'ArrowUp',
down: 'ArrowDown',
left: 'ArrowLeft',
right: 'ArrowRight',
};
const KEY_DIR: Record<string, Direction | undefined> = {
ArrowUp: 'up',
ArrowDown: 'down',
ArrowLeft: 'left',
ArrowRight: 'right',
};
const items = new WeakMap<HTMLElement, MotionItem>();
const synthetic = new WeakSet<Event>();
const bumpListeners = new Set<(dir: Direction) => void>();
let root: MotionContainer | null = null;
// Last focused rect, so a move after focus was lost resumes nearby
let origin: Rect | null = null;
let releaseEdit: (() => void) | null = null;
const [active, setActive] = createSignal(false);
const [editing, setEditing] = createSignal<MotionItem | null>(null);
// Directional motion in use: the ring is shown
export const motionActive = active;
export const motionEditing = editing;
export function setMotionActive(on: boolean) {
setActive(on);
if (!on) exitEdit();
}
export function onBump(cb: (dir: Direction) => void): () => void {
bumpListeners.add(cb);
return () => bumpListeners.delete(cb);
}
export function createContainer(
kind: MotionLayout,
parent: MotionContainer | null,
options: {
orientation?: () => MotionOrientation;
entry?: () => MotionEntry;
trap?: () => boolean;
} = {}
): MotionContainer {
return {
kind,
el: null,
parent,
get orientation() {
return options.orientation?.() ?? 'vertical';
},
get entry() {
return options.entry?.() ?? 'last';
},
get trap() {
return options.trap?.() ?? false;
},
children: new Set(),
last: null,
};
}
export function setMotionRoot(container: MotionContainer | null) {
root = container;
}
export function attachContainer(container: MotionContainer): () => void {
container.parent?.children.add(container);
return () => {
const parent = container.parent;
if (!parent) return;
parent.children.delete(container);
if (parent.last === container) parent.last = null;
};
}
export function registerItem(
parent: MotionContainer,
el: HTMLElement,
owns: () => MotionOwns,
edit: () => boolean
): () => void {
const item: MotionItem = { kind: 'item', el, parent, owns, edit };
items.set(el, item);
parent.children.add(item);
return () => {
items.delete(el);
parent.children.delete(item);
if (parent.last === item) parent.last = null;
if (editing() === item) exitEdit();
};
}
function elOf(node: MotionNode): HTMLElement | null {
return node.el;
}
function rectOf(node: MotionNode): Rect {
return elOf(node)?.getBoundingClientRect() ?? ZERO;
}
function visible(el: HTMLElement): boolean {
if (!el.isConnected || el.closest('[inert]')) return false;
return typeof el.checkVisibility === 'function' ? el.checkVisibility() : true;
}
function navigable(node: MotionNode): boolean {
if (node.kind === 'item') {
return (
visible(node.el) && (node.el as Partial<HTMLButtonElement>).disabled !== true
);
}
if (node.el && !visible(node.el)) return false;
for (const child of node.children) if (navigable(child)) return true;
return false;
}
function domOrder(a: MotionNode, b: MotionNode): number {
const ea = elOf(a);
const eb = elOf(b);
if (!ea || !eb || ea === eb) return 0;
return ea.compareDocumentPosition(eb) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
}
function ordered(container: MotionContainer): MotionNode[] {
return [...container.children].filter(navigable).sort(domOrder);
}
function isVertical(dir: Direction): boolean {
return dir === 'up' || dir === 'down';
}
function isBackward(dir: Direction): boolean {
return dir === 'up' || dir === 'left';
}
// Gap along the move axis, or null when `to` is not in that direction
function gapToward(from: Rect, to: Rect, dir: Direction): number | null {
const gap = {
up: from.top - to.bottom,
down: to.top - from.bottom,
left: from.left - to.right,
right: to.left - from.right,
}[dir];
return gap >= -1 ? Math.max(0, gap) : null;
}
function crossOverlap(from: Rect, to: Rect, dir: Direction): number {
return isVertical(dir)
? Math.min(from.right, to.right) - Math.max(from.left, to.left)
: Math.min(from.bottom, to.bottom) - Math.max(from.top, to.top);
}
function crossDistance(from: Rect, to: Rect, dir: Direction): number {
return isVertical(dir)
? Math.abs(from.left + from.right - to.left - to.right) / 2
: Math.abs(from.top + from.bottom - to.top - to.bottom) / 2;
}
function lessThan(a: number[], b: number[]): boolean {
for (let i = 0; i < a.length; i++) {
if (a[i] !== b[i]) return a[i]! < b[i]!;
}
return false;
}
// Cross-axis alignment first, then distance along the axis, then off-axis distance
function pickInDirection(
from: Rect,
candidates: MotionNode[],
dir: Direction,
alignedOnly: boolean
): MotionNode | null {
let best: MotionNode | null = null;
let bestScore: number[] = [];
for (const candidate of candidates) {
const rect = rectOf(candidate);
const gap = gapToward(from, rect, dir);
if (gap === null) continue;
const aligned = crossOverlap(from, rect, dir) > 0;
if (alignedOnly && !aligned) continue;
const score = [aligned ? 0 : 1, gap, crossDistance(from, rect, dir)];
if (best === null || lessThan(score, bestScore)) {
best = candidate;
bestScore = score;
}
}
return best;
}
function nearest(from: Rect, candidates: MotionNode[]): MotionNode | null {
let best: MotionNode | null = null;
let bestDistance = Infinity;
for (const candidate of candidates) {
const r = rectOf(candidate);
const dx = Math.max(0, r.left - from.right, from.left - r.right);
const dy = Math.max(0, r.top - from.bottom, from.top - r.bottom);
const distance = Math.hypot(dx, dy);
if (distance < bestDistance) {
best = candidate;
bestDistance = distance;
}
}
return best;
}
// Next sibling inside `container`, or null to bubble up
function step(
container: MotionContainer,
node: MotionNode,
dir: Direction
): MotionNode | null {
const siblings = ordered(container);
if (container.kind === 'grid') {
return pickInDirection(
rectOf(node),
siblings.filter((s) => s !== node),
dir,
true
);
}
if (isVertical(dir) !== (container.orientation === 'vertical')) return null;
const i = siblings.indexOf(node);
if (i < 0) return null;
return siblings[i + (isBackward(dir) ? -1 : 1)] ?? null;
}
// The item focus lands on when entering `node`
function enter(node: MotionNode, from: Rect): MotionItem | null {
if (node.kind === 'item') return node;
const children = ordered(node);
if (!children.length) return null;
let pick: MotionNode | null = null;
if (node.entry === 'last' && node.last && children.includes(node.last))
pick = node.last;
else if (node.entry === 'first') pick = children[0]!;
pick ??= nearest(from, children) ?? children[0]!;
return enter(pick, from);
}
// Item to container to parent; geometry only between regions
function resolve(item: MotionItem, dir: Direction): MotionItem | null {
const from = item.el.getBoundingClientRect();
let node: MotionNode = item;
for (
let container: MotionContainer | null = item.parent;
container;
container = container.parent
) {
const next =
node.kind === 'region'
? pickInDirection(
rectOf(node),
ordered(container).filter((s) => s !== node),
dir,
false
)
: step(container, node, dir);
const target = next && enter(next, from);
if (target) return target;
if (container.trap) return null;
node = container;
}
return null;
}
function scrollableToward(el: HTMLElement, dir: Direction): HTMLElement | null {
const vertical = isVertical(dir);
for (let n = el.parentElement; n; n = n.parentElement) {
const style = getComputedStyle(n);
const overflow = vertical ? style.overflowY : style.overflowX;
if (overflow !== 'auto' && overflow !== 'scroll') continue;
const pos = vertical ? n.scrollTop : n.scrollLeft;
const span = vertical ? n.clientHeight : n.clientWidth;
const max = vertical
? n.scrollHeight - n.clientHeight
: n.scrollWidth - n.clientWidth;
// A vertical column reports a few px of sideways overflow (scrollbar, scaled child)
if (max <= Math.max(8, span * 0.1)) continue;
const atEdge = isBackward(dir) ? pos <= 1 : pos >= max - 1;
if (!atEdge) return n;
}
return null;
}
function focused(): HTMLElement | null {
const el = document.activeElement;
return el instanceof HTMLElement && el !== document.body ? el : null;
}
function focusItem(item: MotionItem) {
item.el.focus({ preventScroll: true });
item.el.scrollIntoView?.({ block: 'nearest', inline: 'nearest' });
}
export function move(dir: Direction) {
const el = focused();
const item = el ? items.get(el) : undefined;
// Not on an item: resume at the remembered item, or nearest to where focus was last
if (!item) {
placeCursor();
return;
}
const target = resolve(item, dir);
// Scroll the region the cursor sits in rather than leaving it early
const scroller = scrollableToward(item.el, dir);
if (scroller && (!target || !scroller.contains(target.el))) {
const span = isVertical(dir) ? scroller.clientHeight : scroller.clientWidth;
const by = (isBackward(dir) ? -1 : 1) * span * motionTuning.scrollFraction;
scroller.scrollBy(isVertical(dir) ? { top: by } : { left: by });
return;
}
if (!target) {
for (const cb of bumpListeners) cb(dir);
return;
}
focusItem(target);
}
// Dispatch a keydown so the widget runs its own logic; true when it was consumed
function synthKey(el: HTMLElement, key: string): boolean {
const event = new KeyboardEvent('keydown', {
key,
code: key,
bubbles: true,
cancelable: true,
});
synthetic.add(event);
el.dispatchEvent(event);
return event.defaultPrevented;
}
function press(el: HTMLElement) {
if (el.getAttribute('aria-disabled') === 'true') return;
if (!synthKey(el, 'Enter')) el.click();
}
function ownsOf(el: HTMLElement): MotionOwns {
return items.get(el)?.owns() ?? 'none';
}
function ownsDirection(owns: MotionOwns, dir: Direction): boolean {
return owns === 'all' || (owns === 'horizontal' && !isVertical(dir));
}
function enterEdit(item: MotionItem) {
exitEdit();
setEditing(item);
releaseEdit = pushBack(exitEdit);
}
function exitEdit() {
releaseEdit?.();
releaseEdit = null;
setEditing(null);
}
function placeCursor() {
const target = root && enter(root, origin ?? ZERO);
if (target) focusItem(target);
}
// A pad's first press after pointer use only reveals the ring
function reveal(): boolean {
if (active()) return false;
setActive(true);
if (focused()) return true;
placeCursor();
return true;
}
export function padMove(dir: Direction) {
if (reveal()) return;
const el = focused();
if (el) {
const edited = editing();
if (edited?.el === el) {
synthKey(el, ARROW[dir]);
return;
}
const item = items.get(el);
if (!item?.edit() && ownsDirection(ownsOf(el), dir) && synthKey(el, ARROW[dir]))
return;
}
move(dir);
}
export function padActivate() {
if (reveal()) return;
const el = focused();
if (!el) return;
if (editing()) {
exitEdit();
return;
}
const item = items.get(el);
if (item?.edit()) {
enterEdit(item);
return;
}
press(el);
}
export function padBack() {
setActive(true);
handleBack();
}
export function padConnected() {
setActive(true);
if (!focused()) placeCursor();
}
// Ctrl/Alt+Arrow moves from anywhere, Ctrl/Alt+Enter/Space activates.
// Ctrl/Alt+Left/Right in a text field stay word jumps.
function onForceKey(e: KeyboardEvent) {
if (synthetic.has(e) || isCapturing()) return;
if (!(e.ctrlKey || e.altKey) || e.metaKey || e.shiftKey) return;
const dir = KEY_DIR[e.key];
if (dir) {
if (!isVertical(dir) && isTextEntry(e.target)) return;
e.preventDefault();
e.stopPropagation();
setActive(true);
exitEdit();
move(dir);
return;
}
const el = focused();
if ((e.key === 'Enter' || e.key === ' ') && el) {
e.preventDefault();
e.stopPropagation();
setActive(true);
press(el);
}
}
// Plain arrows move focus unless the focused item owns that axis
function onKey(e: KeyboardEvent) {
if (synthetic.has(e) || e.defaultPrevented || isCapturing()) return;
if (e.key === 'Tab') {
setActive(true);
return;
}
const dir = KEY_DIR[e.key];
if (!dir || e.ctrlKey || e.altKey || e.metaKey || e.shiftKey) return;
const el = focused();
if (el && (editing()?.el === el || ownsDirection(ownsOf(el), dir))) return;
e.preventDefault();
setActive(true);
move(dir);
}
function onFocusIn(e: FocusEvent) {
const item = e.target instanceof HTMLElement ? items.get(e.target) : undefined;
if (editing() && editing() !== item) exitEdit();
if (!item) return;
let node: MotionNode = item;
for (
let container: MotionContainer | null = item.parent;
container;
container = container.parent
) {
container.last = node;
node = container;
}
}
// Still measurable during the blur, so a later move can resume
function onFocusOut(e: FocusEvent) {
const el = e.target;
if (!(el instanceof HTMLElement) || !el.getClientRects().length) return;
const r = el.getBoundingClientRect();
origin = { left: r.left, top: r.top, right: r.right, bottom: r.bottom };
}
function onPointerDown(e: PointerEvent) {
if (e.isTrusted) setMotionActive(false);
}
export function initMotion(): () => void {
window.addEventListener('keydown', onForceKey, true);
window.addEventListener('keydown', onKey);
window.addEventListener('pointerdown', onPointerDown, true);
document.addEventListener('focusin', onFocusIn);
document.addEventListener('focusout', onFocusOut, true);
return () => {
window.removeEventListener('keydown', onForceKey, true);
window.removeEventListener('keydown', onKey);
window.removeEventListener('pointerdown', onPointerDown, true);
document.removeEventListener('focusin', onFocusIn);
document.removeEventListener('focusout', onFocusOut, true);
exitEdit();
setActive(false);
origin = null;
};
}
@@ -0,0 +1,26 @@
import { describe, expect, it } from 'vitest';
import { repeatInterval, resolveStick } from './gamepad';
import { motionTuning } from './tuning';
describe('resolveStick', () => {
it('commits above the enter deadzone and holds down to the exit one', () => {
expect(resolveStick(0.3, 0, null)).toBeNull();
expect(resolveStick(0.4, 0, null)).toBe('right');
expect(resolveStick(0.3, 0, 'right')).toBe('right');
expect(resolveStick(0.2, 0, 'right')).toBeNull();
});
it('keeps the held axis on a diagonal until the other clearly leads', () => {
expect(resolveStick(0.6, 0.7, 'right')).toBe('right');
expect(resolveStick(0.4, 0.8, 'right')).toBe('down');
expect(resolveStick(-0.7, -0.6, 'up')).toBe('up');
});
});
describe('repeatInterval', () => {
it('ramps down to the minimum', () => {
expect(repeatInterval(0)).toBe(motionTuning.repeatStartMs);
expect(repeatInterval(1)).toBeLessThan(motionTuning.repeatStartMs);
expect(repeatInterval(100)).toBe(motionTuning.repeatMinMs);
});
});
+169
View File
@@ -0,0 +1,169 @@
import type { Direction } from './core';
import { motionTuning } from './tuning';
const BUTTON_A = 0;
const BUTTON_B = 1;
const DPAD: Record<number, Direction> = {
12: 'up',
13: 'down',
14: 'left',
15: 'right',
};
export interface GamepadFrame {
buttons: Set<number>;
axX: number;
axY: number;
}
export interface PadCommands {
move(dir: Direction): void;
activate(): void;
back(): void;
connected(): void;
}
export function decodeInput(pads: readonly (Gamepad | null)[]): GamepadFrame {
const buttons = new Set<number>();
const stronger = (a: number, b: number) => (Math.abs(a) > Math.abs(b) ? a : b);
let axX = 0;
let axY = 0;
for (const pad of pads) {
if (!pad) continue;
pad.buttons.forEach((b, i) => {
if (b.pressed) buttons.add(i);
});
axX = stronger(pad.axes[0] ?? 0, axX);
axY = stronger(pad.axes[1] ?? 0, axY);
}
return { buttons, axX, axY };
}
export function resolveStick(
axX: number,
axY: number,
prev: Direction | null
): Direction | null {
const ax = Math.abs(axX);
const ay = Math.abs(axY);
const mag = Math.max(ax, ay);
if (mag < motionTuning.deadzoneExit) return null;
if (mag < motionTuning.deadzoneEnter && !prev) return null;
const ratio = motionTuning.axisSwitchRatio;
let horizontal = ax > ay;
if (prev === 'left' || prev === 'right') horizontal = ax * ratio >= ay;
else if (prev === 'up' || prev === 'down') horizontal = ax >= ay * ratio;
if (horizontal) return axX > 0 ? 'right' : 'left';
return axY > 0 ? 'down' : 'up';
}
export function pressedDirections(
frame: GamepadFrame,
stickDir: Direction | null
): Set<Direction> {
const dirs = new Set<Direction>();
for (const i of frame.buttons) {
const dir = DPAD[i];
if (dir) dirs.add(dir);
}
if (stickDir) dirs.add(stickDir);
return dirs;
}
export function repeatInterval(repeats: number): number {
return Math.max(
motionTuning.repeatMinMs,
motionTuning.repeatStartMs - motionTuning.repeatRampMs * repeats
);
}
interface Held {
firedAt: number;
repeats: number;
}
export function startGamepad(commands: PadCommands): () => void {
if (typeof navigator === 'undefined' || !navigator.getGamepads) return () => {};
const pads = new Set<number>();
const held = new Map<Direction, Held>();
let prevButtons = new Set<number>();
let stickDir: Direction | null = null;
let rafId = 0;
function resetHeld() {
held.clear();
prevButtons = new Set();
stickDir = null;
}
function pressDir(dir: Direction, now: number) {
const state = held.get(dir);
if (!state) {
held.set(dir, { firedAt: now, repeats: 0 });
commands.move(dir);
return;
}
const wait =
state.repeats === 0 ? motionTuning.repeatDelayMs : repeatInterval(state.repeats);
if (now - state.firedAt < wait) return;
state.firedAt = now;
state.repeats++;
commands.move(dir);
}
function poll() {
const now = performance.now();
const frame = decodeInput(navigator.getGamepads());
stickDir = resolveStick(frame.axX, frame.axY, stickDir);
const dirs = pressedDirections(frame, stickDir);
const { buttons } = frame;
if (buttons.has(BUTTON_A) && !prevButtons.has(BUTTON_A)) commands.activate();
if (buttons.has(BUTTON_B) && !prevButtons.has(BUTTON_B)) commands.back();
prevButtons = buttons;
for (const dir of dirs) pressDir(dir, now);
for (const dir of [...held.keys()]) {
if (!dirs.has(dir)) held.delete(dir);
}
rafId = pads.size > 0 ? requestAnimationFrame(poll) : 0;
}
function startLoop() {
if (!rafId) rafId = requestAnimationFrame(poll);
}
function onConnect(e: GamepadEvent) {
pads.add(e.gamepad.index);
startLoop();
commands.connected();
}
function onDisconnect(e: GamepadEvent) {
pads.delete(e.gamepad.index);
}
window.addEventListener('gamepadconnected', onConnect);
window.addEventListener('gamepaddisconnected', onDisconnect);
window.addEventListener('blur', resetHeld);
document.addEventListener('visibilitychange', resetHeld);
for (const pad of navigator.getGamepads()) {
if (pad) pads.add(pad.index);
}
if (pads.size) startLoop();
return () => {
if (rafId) cancelAnimationFrame(rafId);
rafId = 0;
window.removeEventListener('gamepadconnected', onConnect);
window.removeEventListener('gamepaddisconnected', onDisconnect);
window.removeEventListener('blur', resetHeld);
document.removeEventListener('visibilitychange', resetHeld);
resetHeld();
pads.clear();
};
}
+21
View File
@@ -0,0 +1,21 @@
export {
MotionGrid,
MotionList,
MotionRegion,
MotionToolbar,
type MotionContainerProps,
} from './containers';
export {
type Direction,
move,
motionActive,
motionEditing,
type MotionEntry,
type MotionOrientation,
type MotionOwns,
onBump,
setMotionActive,
} from './core';
export { controllerMotionPref, MotionRoot } from './motion-root';
export { motionTuning } from './tuning';
export { type MotionItemOptions, useMotionItem } from './use-motion-item';
+113
View File
@@ -0,0 +1,113 @@
import { createEffect, createSignal, onCleanup, onMount } from 'solid-js';
import { type Direction, motionActive, motionEditing, onBump } from './core';
import { motionTuning } from './tuning';
const BUMP: Record<Direction, [number, number]> = {
up: [0, -1],
down: [0, 1],
left: [-1, 0],
right: [1, 0],
};
function reducedMotion(): boolean {
return (
window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false
);
}
// Overlay that glides to the focused element while directional motion is in use
export function MotionRing() {
let ring!: HTMLDivElement;
let frame = 0;
// Element the ring currently sits on, null while hidden
let placedOn: HTMLElement | null = null;
const [target, setTarget] = createSignal<HTMLElement | null>(null);
function place() {
cancelAnimationFrame(frame);
frame = 0;
const el = target();
if (!el || !el.isConnected || !motionActive()) {
ring.style.opacity = '0';
placedOn = null;
return;
}
const r = el.getBoundingClientRect();
const pad = motionTuning.ringPaddingPx;
// Glide only to a new target; appearing, scrolling and resizing snap
const glide = placedOn !== null && placedOn !== el;
ring.style.transitionDuration = glide
? `${motionTuning.ringGlideMs}ms`
: '0ms';
ring.style.transform = `translate(${r.left - pad}px, ${r.top - pad}px)`;
ring.style.width = `${r.width + pad * 2}px`;
ring.style.height = `${r.height + pad * 2}px`;
ring.style.opacity = '1';
placedOn = el;
}
function schedule() {
if (!frame) frame = requestAnimationFrame(place);
}
function onFocusIn(e: FocusEvent) {
setTarget(e.target instanceof HTMLElement ? e.target : null);
}
function onFocusOut(e: FocusEvent) {
if (!e.relatedTarget) setTarget(null);
}
onMount(() => {
const active = document.activeElement;
if (active instanceof HTMLElement && active !== document.body)
setTarget(active);
document.addEventListener('focusin', onFocusIn);
document.addEventListener('focusout', onFocusOut);
window.addEventListener('scroll', place, true);
window.addEventListener('resize', place);
const stopBump = onBump((dir) => {
if (!placedOn || reducedMotion() || !ring.animate) return;
const [x, y] = BUMP[dir];
const px = motionTuning.bumpPx;
ring.animate(
[
{ translate: '0 0' },
{ translate: `${x * px}px ${y * px}px` },
{ translate: '0 0' },
],
{ duration: motionTuning.bumpMs, easing: 'ease-out' }
);
});
onCleanup(() => {
document.removeEventListener('focusin', onFocusIn);
document.removeEventListener('focusout', onFocusOut);
window.removeEventListener('scroll', place, true);
window.removeEventListener('resize', place);
stopBump();
cancelAnimationFrame(frame);
});
});
createEffect(() => {
const el = target();
motionActive();
schedule();
if (!el || typeof ResizeObserver === 'undefined') return;
const observer = new ResizeObserver(schedule);
observer.observe(el);
onCleanup(() => observer.disconnect());
});
return (
<div
ref={ring}
data-editing={motionEditing() ? '' : undefined}
class="
pointer-events-none fixed top-0 left-0 z-50 rounded-md border-2 border-focus opacity-0
transition-[transform,width,height] ease-out motion-reduce:transition-none
data-editing:border-4 data-editing:border-accent
"
/>
);
}
@@ -0,0 +1,53 @@
import { createEffect, type JSX, onCleanup, onMount } from 'solid-js';
import * as v from 'valibot';
import { definePref } from '@/lib/storage';
import { MotionParent } from './containers';
import {
createContainer,
initMotion,
motionActive,
padActivate,
padBack,
padConnected,
padMove,
setMotionRoot,
} from './core';
import { startGamepad } from './gamepad';
import { MotionRing } from './motion-ring';
export const controllerMotionPref = definePref(
'controllerNav',
v.boolean(),
true
);
export function MotionRoot(props: { children: JSX.Element }) {
const root = createContainer('root', null);
setMotionRoot(root);
onCleanup(() => setMotionRoot(null));
onMount(() => onCleanup(initMotion()));
createEffect(() => {
if (!controllerMotionPref()) return;
onCleanup(
startGamepad({
move: padMove,
activate: padActivate,
back: padBack,
connected: padConnected,
})
);
});
createEffect(() =>
document.documentElement.classList.toggle('motion-active', motionActive())
);
return (
<MotionParent.Provider value={root}>
{props.children}
<MotionRing />
</MotionParent.Provider>
);
}
+253
View File
@@ -0,0 +1,253 @@
import { cleanup, render, screen } from '@solidjs/testing-library';
import type { JSX } from 'solid-js';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { handleBack } from '@/lib/back-stack';
import {
type Direction,
motionEditing,
onBump,
padActivate,
padMove,
setMotionActive,
} from './core';
import { MotionList, MotionRegion, MotionToolbar } from './containers';
import { MotionRoot } from './motion-root';
import { type MotionItemOptions, useMotionItem } from './use-motion-item';
afterEach(() => {
setMotionActive(false);
cleanup();
});
function Item(props: { name: string } & MotionItemOptions) {
let ref!: HTMLButtonElement;
useMotionItem(() => ref, props);
return <button ref={ref}>{props.name}</button>;
}
function Field(props: { name: string } & MotionItemOptions) {
let ref!: HTMLInputElement;
useMotionItem(() => ref, props);
return <input ref={ref} aria-label={props.name} />;
}
function setup(tree: () => JSX.Element) {
render(() => <MotionRoot>{tree()}</MotionRoot>);
}
const KEYS: Record<Direction, string> = {
up: 'ArrowUp',
down: 'ArrowDown',
left: 'ArrowLeft',
right: 'ArrowRight',
};
function arrow(dir: Direction, init: KeyboardEventInit = {}) {
const target = document.activeElement ?? document.body;
const event = new KeyboardEvent('keydown', {
key: KEYS[dir],
bubbles: true,
cancelable: true,
...init,
});
target.dispatchEvent(event);
return event;
}
function button(name: string) {
return screen.getByRole('button', { name });
}
function focused() {
return document.activeElement;
}
// jsdom has no layout
function place(
el: HTMLElement,
left: number,
top: number,
width: number,
height: number
) {
vi.spyOn(el, 'getBoundingClientRect').mockReturnValue({
left,
top,
width,
height,
right: left + width,
bottom: top + height,
x: left,
y: top,
toJSON: () => ({}),
});
}
describe('motion moves', () => {
it('steps along a list and bubbles out of a nested toolbar', () => {
setup(() => (
<MotionList>
<Item name="a" />
<MotionToolbar>
<Item name="b1" />
<Item name="b2" />
</MotionToolbar>
<Item name="c" />
</MotionList>
));
button('a').focus();
arrow('down');
expect(focused()).toBe(button('b1'));
arrow('right');
expect(focused()).toBe(button('b2'));
arrow('down');
expect(focused()).toBe(button('c'));
// Re-entering the toolbar lands on the remembered item
arrow('up');
expect(focused()).toBe(button('b2'));
});
it('bumps at the end instead of wrapping', () => {
const bumps: Direction[] = [];
const stop = onBump((dir) => bumps.push(dir));
setup(() => (
<MotionList>
<Item name="a" />
<Item name="b" />
</MotionList>
));
button('b').focus();
arrow('down');
arrow('right');
stop();
expect(focused()).toBe(button('b'));
expect(bumps).toEqual(['down', 'right']);
});
it('leaves owned axes to the widget', () => {
setup(() => (
<MotionList>
<Field name="field" owns="horizontal" />
<Item name="next" />
</MotionList>
));
const field = screen.getByLabelText('field');
field.focus();
expect(arrow('left').defaultPrevented).toBe(false);
expect(focused()).toBe(field);
expect(arrow('down').defaultPrevented).toBe(true);
expect(focused()).toBe(button('next'));
});
it('force moves with Ctrl+Arrow out of a widget that owns everything', () => {
setup(() => (
<MotionList>
<Field name="field" owns="all" />
<Item name="next" />
</MotionList>
));
screen.getByLabelText('field').focus();
arrow('down');
expect(focused()).toBe(screen.getByLabelText('field'));
arrow('down', { ctrlKey: true });
expect(focused()).toBe(button('next'));
});
it('crosses between regions by geometry', () => {
setup(() => (
<>
<MotionRegion data-testid="rail">
<Item name="rail" />
</MotionRegion>
<MotionRegion data-testid="page">
<Item name="p1" />
<Item name="p2" />
</MotionRegion>
</>
));
place(screen.getByTestId('rail'), 0, 0, 100, 500);
place(button('rail'), 10, 10, 80, 40);
place(screen.getByTestId('page'), 100, 0, 400, 500);
place(button('p1'), 110, 10, 200, 40);
place(button('p2'), 110, 60, 200, 40);
button('p2').focus();
arrow('left');
expect(focused()).toBe(button('rail'));
arrow('right');
// Remembered item of the page region
expect(focused()).toBe(button('p2'));
});
it('keeps moves inside a trapped region', () => {
const bumps: Direction[] = [];
const stop = onBump((dir) => bumps.push(dir));
setup(() => (
<>
<MotionRegion data-testid="page">
<Item name="page" />
</MotionRegion>
<MotionRegion data-testid="dialog" trap>
<Item name="ok" />
</MotionRegion>
</>
));
place(screen.getByTestId('page'), 0, 0, 500, 500);
place(button('page'), 10, 10, 80, 40);
place(screen.getByTestId('dialog'), 100, 100, 200, 100);
place(button('ok'), 110, 110, 80, 40);
button('ok').focus();
arrow('up');
stop();
expect(focused()).toBe(button('ok'));
expect(bumps).toEqual(['up']);
});
});
describe('pad', () => {
it('only reveals on the first press', () => {
setup(() => (
<MotionList>
<Item name="a" />
<Item name="b" />
</MotionList>
));
button('a').focus();
padMove('down');
expect(focused()).toBe(button('a'));
padMove('down');
expect(focused()).toBe(button('b'));
});
it('edit mode sends directions to the widget until back', () => {
const keys: string[] = [];
function Dial() {
let ref!: HTMLButtonElement;
useMotionItem(() => ref, { edit: true });
return (
<button ref={ref} onKeyDown={(e) => keys.push(e.key)}>
dial
</button>
);
}
setup(() => (
<MotionList>
<Dial />
<Item name="b" />
</MotionList>
));
button('dial').focus();
setMotionActive(true);
padMove('down');
expect(focused()).toBe(button('b'));
button('dial').focus();
padActivate();
expect(motionEditing()?.el).toBe(button('dial'));
padMove('down');
expect(focused()).toBe(button('dial'));
expect(keys).toEqual(['ArrowDown']);
expect(handleBack()).toBe(true);
expect(motionEditing()).toBeNull();
padMove('down');
expect(focused()).toBe(button('b'));
});
});
+19
View File
@@ -0,0 +1,19 @@
// Every feel value of directional motion lives here
export const motionTuning = {
// Held direction: first repeat after the delay, then the interval shrinks per repeat down to the minimum
repeatDelayMs: 350,
repeatStartMs: 100,
repeatMinMs: 50,
repeatRampMs: 10,
// Stick deadzone with hysteresis: commit above enter, release below exit
deadzoneEnter: 0.35,
deadzoneExit: 0.25,
// A held diagonal switches axis only when the other axis leads by this much
axisSwitchRatio: 1.4,
// Part of the visible span scrolled when a move stays inside a scroller
scrollFraction: 0.6,
ringGlideMs: 120,
ringPaddingPx: 3,
bumpPx: 4,
bumpMs: 160,
};
@@ -0,0 +1,36 @@
import { type Accessor, onCleanup, onMount, useContext } from 'solid-js';
import { motionEditing, type MotionOwns, registerItem } from './core';
import { MotionParent } from './containers';
export interface MotionItemOptions {
// passthrough (none), owns-horizontal, owns-all
owns?: MotionOwns | Accessor<MotionOwns>;
// Pad: A enters edit mode, then every direction goes to the widget
edit?: boolean | Accessor<boolean>;
}
function read<T>(value: T | Accessor<T> | undefined, fallback: T): T {
if (value === undefined) return fallback;
return typeof value === 'function' ? (value as Accessor<T>)() : value;
}
// Registers a focusable element with the enclosing motion container. No-op outside MotionRoot.
export function useMotionItem(
ref: () => HTMLElement | undefined,
options: MotionItemOptions = {}
) {
const parent = useContext(MotionParent);
onMount(() => {
const el = ref();
if (!parent || !el) return;
onCleanup(
registerItem(
parent,
el,
() => read(options.owns, 'none'),
() => read(options.edit, false)
)
);
});
return { editing: () => motionEditing()?.el === ref() };
}
+1 -1
View File
@@ -1,4 +1,4 @@
import {
import type {
OpenDialogOptions,
OpenDialogReturnValue,
SaveDialogOptions,
+2 -2
View File
@@ -1,10 +1,10 @@
import {
import type {
OpenDialogOptions,
OpenDialogReturnValue,
SaveDialogOptions,
SaveDialogReturnValue,
} from 'electron';
import {
import type {
CrashReportKind,
DiscordPresence,
ErrorReportingState,
+182 -121
View File
@@ -432,9 +432,15 @@ importers:
eslint-import-resolver-typescript:
specifier: ^4.4.4
version: 4.4.5([email protected])([email protected]([email protected])([email protected]))([email protected])
eslint-plugin-better-tailwindcss:
specifier: 4.10.0
version: 4.10.0([email protected]([email protected])([email protected]))([email protected])([email protected])
eslint-plugin-boundaries:
specifier: 7.3.0
version: 7.3.0(@typescript-eslint/[email protected]([email protected]([email protected])([email protected]))([email protected])([email protected]))([email protected])([email protected]([email protected])([email protected]))([email protected])
eslint-plugin-jsx-a11y:
specifier: 6.10.2
version: 6.10.2([email protected]([email protected])([email protected]))
eslint-plugin-solid:
specifier: 0.18.1
version: 0.18.1([email protected]([email protected])([email protected]))([email protected])([email protected])
@@ -447,15 +453,9 @@ importers:
prettier:
specifier: 3.9.10
version: 3.9.10
svgo:
specifier: 4.1.0
version: 4.1.0
tailwindcss:
specifier: 4.3.3
version: 4.3.3
tsx:
specifier: 4.23.15
version: 4.23.15
typescript:
specifier: ~6.0.3
version: 6.0.3
@@ -762,6 +762,9 @@ packages:
resolution: {integrity: sha512-3LKP7F2+atl9vJFhaBjn4nOaSWahZ/yWjOvA4e5pnXkt2qyXRCHLxoBQy81GFtLGCq7K9lPm9R517M1U+/90Qg==}
engines: {node: '>=18'}
'@dual-bundle/[email protected]':
resolution: {integrity: sha512-id+7YRUgoUX6CgV0DtuhirQWodeeA7Lf4i2x71JS/vtA5pRb/hIGWlw+G6MeXvsM+MXrz0VAydTGElX1rAfgPg==}
'@dword-design/[email protected]':
resolution: {integrity: sha512-OFmAmzKiDUh9m7WRMYcoEOPI7b5tS5hdqQmtKDwF+ZssVJv8a+GHo9VOtFsmlw3h8Roh/9QzFWIsjSFZyQUMdg==}
@@ -1319,6 +1322,10 @@ packages:
resolution: {integrity: sha512-MwcE1P+AZ4C6DWlpin/OmOA54mmIZ/+xZuJiQd4SyB29oAJjN30UW9wkKNptW2ctp4cEsvhlLY/CsQ1uoHDloQ==}
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
'@eslint/[email protected]':
resolution: {integrity: sha512-rVcxLmwSkEL3aWS3vAgsTRrQHoYE1b0XcgDtKHDJ92XOkyUpcbS/g0tUJKhvCtlEhYzgKBWsgDd+Z/aPhd166w==}
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
'@eslint/[email protected]':
resolution: {integrity: sha512-4IlJx0X0qftVsN5E+/vGujTRIFtwuLbNsVUe7TO6zYPDR1O6nFwvwhIKEKSrl6dZchmYBITazxKoUYOjdtjlRg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
@@ -2845,6 +2852,11 @@ packages:
cpu: [x64]
os: [win32]
'@valibot/[email protected]':
resolution: {integrity: sha512-a0M+uwCuQZEPAo65NYkFSJ14O5c213KoSZmPdoCfuFvUhfULi4T2Z6Tpjv6lTVMW9RoLm74RpRAjNEa43KcN+g==}
peerDependencies:
valibot: ^1.5.0
'@vitejs/[email protected]':
resolution: {integrity: sha512-gUu9hwfWvvEDBBmgtAowQCojwZmJ5mcLn3aufeCsitijs3+f2NsrPtlAWIR6OPiqljl96GVCUbLe0HyqIpVaoA==}
engines: {node: ^14.18.0 || >=16.0.0}
@@ -3008,6 +3020,9 @@ packages:
resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==}
engines: {node: '>=12'}
[email protected]:
resolution: {integrity: sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ==}
[email protected]:
resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==}
engines: {node: '>=8'}
@@ -3048,6 +3063,14 @@ packages:
[email protected]:
resolution: {integrity: sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==}
[email protected]:
resolution: {integrity: sha512-9WTZxEjsZ7b13TH8JPmbV2z8CHbl80/2hm3XPEG4JgNdQLK81IBRXmSxHfMAOkSqQeRxT/0dwNDz2GOm3zzpcQ==}
engines: {node: '>=4'}
[email protected]:
resolution: {integrity: sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==}
engines: {node: '>= 0.4'}
[email protected]:
resolution: {integrity: sha512-g+8yxHUZ60RcyaUpfNzy56OtWW+x9cyEe9j+CranqLiqbju2yf/Cy6ZtYK40EZxtrdHllzlVZgLmcOUCTlJ7Jg==}
@@ -3096,9 +3119,6 @@ packages:
[email protected]:
resolution: {integrity: sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==}
[email protected]:
resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==}
[email protected]:
resolution: {integrity: sha512-d0II/GO9uf9lfUHH2BQsjxzRJZBdsjgsBiW4BvhWk/3qoKwQFjIDVN19PfX8F2D/r9PCMTtLWjYVCFrpeYUzsw==}
deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
@@ -3312,10 +3332,6 @@ packages:
[email protected]:
resolution: {integrity: sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==}
[email protected]:
resolution: {integrity: sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==}
engines: {node: '>=16'}
[email protected]:
resolution: {integrity: sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==}
engines: {node: '>=18'}
@@ -3374,21 +3390,10 @@ packages:
[email protected]:
resolution: {integrity: sha512-COtn4EROW5dBGlE/4PiKnh6rZpAPxDeFLaEEwt4i10jpDMFt2EhQGS79QmmrO+iKCHv0PU/HrOWEhijFd1x99Q==}
[email protected]:
resolution: {integrity: sha512-rZZVSLle8v0+EY8QAkDWrKhpgt6SA5OtHsgBnsj6ZaLb5dmDVOWUDtQitd9ydxxvEjhewNudS6eTVU7uOyzvXw==}
[email protected]:
resolution: {integrity: sha512-OA0mILzGc1kCOCSJerOeqDxDQ4HOh+G8NbOJFOTgOCzpw7fCBubk0fEyxp8AgOL/jvLgYA/uV0cMbe43ElF1JA==}
engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0, npm: '>=7.0.0'}
[email protected]:
resolution: {integrity: sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA==}
engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0}
[email protected]:
resolution: {integrity: sha512-wD5oz5xibMOPHzy13CyGmogB3phdvcDaB5t0W/Nr5Z2O/agcB8YwOz6e2Lsp10pNDzBoDO9nVa3RGs/2BttpHQ==}
engines: {node: '>= 6'}
[email protected]:
resolution: {integrity: sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==}
@@ -3397,13 +3402,12 @@ packages:
engines: {node: '>=4'}
hasBin: true
[email protected]:
resolution: {integrity: sha512-0LrrStPOdJj+SPCCrGhzryycLjwcgUSHBtxNA8aIDxf0GLsRh1cKYhB00Gd1lDOS4yGH69+SNn13+TWbVHETFQ==}
engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0, npm: '>=7.0.0'}
[email protected]:
resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==}
[email protected]:
resolution: {integrity: sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==}
[email protected]:
resolution: {integrity: sha512-JQUCCK+/CAGbGGx618PlFZMXH81Jtj7t73CHv9dd/zVWvxgGT2zLFRjnKb+Ng46GIwcy+f7f88qd4duqllK+WQ==}
engines: {node: ^22.14.0 || >=24.0.0}
@@ -3546,19 +3550,6 @@ packages:
[email protected]:
resolution: {integrity: sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==}
[email protected]:
resolution: {integrity: sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==}
[email protected]:
resolution: {integrity: sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==}
[email protected]:
resolution: {integrity: sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==}
engines: {node: '>= 4'}
[email protected]:
resolution: {integrity: sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==}
[email protected]:
resolution: {integrity: sha512-zIHwmZPRshsCdpMDyVsqGmgyP0yT8GAgXUnkdAoJisxvf33k7yO6OuoKmcTGuXPWSsm8Oh88nZicRLA9Y0rUeA==}
engines: {node: '>=12'}
@@ -3630,6 +3621,9 @@ packages:
[email protected]:
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
[email protected]:
resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==}
[email protected]:
resolution: {integrity: sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==}
@@ -3640,10 +3634,6 @@ packages:
resolution: {integrity: sha512-9vhedylFonb2YGogzUKX6+Ja72gOJbN1QHAqdrvqLwhdl/QWbKopzoUC9EbQNVsAns/bx/4uyqalrQAoy1IByw==}
engines: {node: '>=10.13.0'}
[email protected]:
resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==}
engines: {node: '>=0.12'}
[email protected]:
resolution: {integrity: sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==}
engines: {node: '>=0.12'}
@@ -3809,6 +3799,19 @@ packages:
eslint-import-resolver-webpack:
optional: true
[email protected]:
resolution: {integrity: sha512-EvcfEScF7N39LXuqX8fDnDsgylhbBZe5bbNb+6oN8ht06ou3MvwfPQ5hVgm2LWIPLOB5LBwNDCY6gBQGW4KHGA==}
engines: {node: ^20.19.0 || ^22.12.0 || >=23.0.0}
peerDependencies:
eslint: ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0
oxlint: ^1.35.0
tailwindcss: ^3.3.0 || ^4.1.17
peerDependenciesMeta:
eslint:
optional: true
oxlint:
optional: true
[email protected]:
resolution: {integrity: sha512-NzzcW1FN7LEuHEdEPuPGzpqADfO0r6VL3z57gqDfasiU5pEUqKCF7PeUpbyuLW7qHfLR4QQcXSBRjJf/nYl5Bw==}
engines: {node: '>=18.18'}
@@ -3825,6 +3828,12 @@ packages:
'@typescript-eslint/parser':
optional: true
[email protected]:
resolution: {integrity: sha512-scB3nz4WmG75pV8+3eRUQOHZlNSUhFNq37xnpgRkCCELU3XMvXAxLk1eqWWyE22Ki4Q01Fnsw9BA3cJHDPgn2Q==}
engines: {node: '>=4.0'}
peerDependencies:
eslint: ^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9
[email protected]:
resolution: {integrity: sha512-ifetmTcxWfz+4qRW3pH/ujdTq2jQIj59AxJMIN26K5avYgU8dxycUETQonWiW+wPrYXA0j3Try0l1CnwVQtDqQ==}
engines: {node: ^14.18.0 || >=16.0.0}
@@ -4699,6 +4708,13 @@ packages:
[email protected]:
resolution: {integrity: sha512-VSWXYUnsPu9+WYKkfmJyLKtIvaRJi1kXUqVmBACORXZQxT5oZDsoZ2vQP+bQFDnWtpI/4eq3MLoRMjI2fnLzTQ==}
[email protected]:
resolution: {integrity: sha512-0K65Lea881pHotoGEa5gDlMxt3pctLi2RplBb7Ezh4rRdLEOtgi7n4EwK9lamnUCkKBqaeKRVebTq6BAxSkpXQ==}
[email protected]:
resolution: {integrity: sha512-MbjN408fEndfiQXbFQ1vnd+1NoLDsnQW41410oQBXiyXDMYH5z505juWa4KUE1LqxRC7DgOgZDbKLxHIwm27hA==}
engines: {node: '>=0.10'}
[email protected]:
resolution: {integrity: sha512-0/BnGCCfyUMkBpeDgWihanIAF9JmZhHBgUhEqzvf+adhNGLoP6TaiI5oF8oyb3I45P+PcnrqihSf01M0l0G5+Q==}
@@ -5000,12 +5016,12 @@ packages:
[email protected]:
resolution: {integrity: sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==}
[email protected]:
resolution: {integrity: sha512-aylIc7Z9y4yzHYAJNuESG3hfhC+0Ibp/MAMiaOZgNv4pmEdFyfZhhhny4MNiAfWdBQ1RQ2mfDWmM1x8SvGyp8g==}
[email protected]:
resolution: {integrity: sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==}
[email protected]:
resolution: {integrity: sha512-rz9YOBGItdSbe7HcSArUbhiAv4SB/4DKRYg96CSFS2CcIYMbUvBtZlzA1NCbk2AdgbmYwMqwNblLpR441lLeiQ==}
[email protected]:
resolution: {integrity: sha512-eRtbOb1N5iyH0tkQDAoQ4Ipsp/5qSR79Dzrz8hEPxRX10RWWR/iQXdoKmBSRCThY1Fh5EhISDtpSc93fpxUniQ==}
engines: {node: '>=12.13'}
@@ -5288,9 +5304,6 @@ packages:
resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
[email protected]:
resolution: {integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==}
[email protected]:
resolution: {integrity: sha512-pJTS2+T0oGIwgjGpw7sIRU8RQMcUoKCDWFLdBqKB2BNmGpbBMH2sdqAaOXUg8OzonZHU0L7vfJu1mJFEiYDWOQ==}
@@ -5965,10 +5978,6 @@ packages:
resolution: {integrity: sha512-6R3J5M4AcbtLUdZmRv2SygeVaM7IhrLXu9BmnOGmmACak8fiUtOsYNWUS4uK7upbmHIBbLBeFeI//477BKLBzA==}
engines: {node: '>=11.0.0'}
[email protected]:
resolution: {integrity: sha512-42tBVwLWnaQvW5zc4HbZrTuWccECCZfBi92FDuwtqxasH+JbPB3/FOKb1m222K42R4WxuxzzMsTswfzgtSu64Q==}
engines: {node: '>=11.0.0'}
[email protected]:
resolution: {integrity: sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==}
engines: {node: '>=v12.22.7'}
@@ -6189,6 +6198,10 @@ packages:
resolution: {integrity: sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==}
engines: {node: '>=18'}
[email protected]:
resolution: {integrity: sha512-o7+c9bW6zpAdJHTtujeePODAhkuicdAryFsfVKwA+wGw89wJ4GTY484WTucM9hLtDEOpOvI+aHnzqnC5lHp4Rg==}
engines: {node: '>= 0.4'}
[email protected]:
resolution: {integrity: sha512-6CC9uyBL+/48dYizRf7H7VAYCMCNTBeM78x/VTUe9bFEaxBepPJDa1Ow99LqI/1yF7kuy7Q3cQsYMrcjGUcskA==}
engines: {node: '>= 0.4'}
@@ -6273,11 +6286,6 @@ packages:
resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}
engines: {node: '>= 0.4'}
[email protected]:
resolution: {integrity: sha512-bkxnTg1kSU0guhIBmibA6UUhrQmPVA1XsQLN+ylCd+UWzbnLkySOcXpyk1mrl05f+pcaCx2eHb+sp6BgMZWX+Q==}
engines: {node: '>=16'}
hasBin: true
[email protected]:
resolution: {integrity: sha512-upi/0ZGkYgEcLeGieoz8gT74oWHA0E7JivX7aN9mAf+Tc7BQoRBvnIGHoPDw+f9TXTW4s6kGYCZJtauP6OYp7g==}
hasBin: true
@@ -6286,6 +6294,19 @@ packages:
resolution: {integrity: sha512-eNRKgb3z66Yp3D2CixVujOUvXLFUTij/zVnV8KRyvFdQwpz7I5DS8UfRkTeLzb64u+dkzDSdelE24izu+zSSUg==}
engines: {node: ^14.18.0 || >=16.0.0}
[email protected]:
resolution: {integrity: sha512-U+/AXT6LWsxnj2vz9HeUuPWBNgdWxjyIEjEPdbJARC9txmgPzo2VEdqnFo4hHaNyMPtycyVJrSaQYeQv/PoyyA==}
engines: {node: ^14.18.0 || >=16.0.0}
[email protected]:
resolution: {integrity: sha512-je9J5UYRsTJqAjYrIBMMlge8T/rreRd44pJxgG5Zx/zeo4kAC/liUKqzztRZrGlYRJLvIf2Cb1DVJMTXSzEShA==}
engines: {node: '>=18.18'}
peerDependencies:
'@eslint/css': '>=1.0.0'
peerDependenciesMeta:
'@eslint/css':
optional: true
[email protected]:
resolution: {integrity: sha512-tUJaGhvqbJFiVKJu6EU5n//KvGdVvY3L3VOFNqjztk13+ifAk00pcSNHBTgHfUiBGOEzDn0gFRbSmsftUV1lXA==}
@@ -6407,9 +6428,17 @@ packages:
[email protected]:
resolution: {integrity: sha512-6s5V71mX8qBUmlgbrfL33xDUwO0fq48rxAu2LBE11WBeGdpCPOsXksQbZJHvHwhrd3QjUusd3mAOM5Gg0mFBLg==}
[email protected]:
resolution: {integrity: sha512-zbem3rfRS8BgeNK50Zz5SIQgXzLafiHjOwUAvk/38/o1jHn/V5QAgVUcz884or7WYcPaH3N2CIfUc2u0ul7UcA==}
engines: {node: '>=10.13.0'}
[email protected]:
resolution: {integrity: sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==}
[email protected]:
resolution: {integrity: sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==}
engines: {node: '>=6'}
[email protected]:
resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}
@@ -7202,6 +7231,8 @@ snapshots:
dependencies:
discord-api-types: 0.38.46
'@dual-bundle/[email protected]': {}
'@dword-design/[email protected]':
dependencies:
babel-plugin-add-module-exports: 1.0.4
@@ -7614,6 +7645,11 @@ snapshots:
dependencies:
'@types/json-schema': 7.0.15
'@eslint/[email protected]':
dependencies:
mdn-data: 2.37.2
source-map-js: 1.2.2
'@eslint/[email protected]([email protected])':
dependencies:
ajv: 6.14.0
@@ -9004,6 +9040,10 @@ snapshots:
'@unrs/[email protected]':
optional: true
'@valibot/[email protected]([email protected]([email protected]))':
dependencies:
valibot: 1.5.0([email protected])
'@vitejs/[email protected]([email protected])([email protected](@types/[email protected])([email protected])([email protected]))':
dependencies:
'@babel/core': 7.29.0([email protected])
@@ -9242,6 +9282,8 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]: {}
[email protected]: {}
@@ -9271,6 +9313,10 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]: {}
[email protected]: {}
[email protected](@babel/[email protected]([email protected])):
@@ -9315,8 +9361,6 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]:
optional: true
@@ -9555,8 +9599,6 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]: {}
[email protected]: {}
@@ -9599,36 +9641,19 @@ snapshots:
[email protected]: {}
[email protected]:
dependencies:
boolbase: 1.0.0
css-what: 7.0.0
domhandler: 5.0.3
domutils: 3.2.2
nth-check: 2.1.1
[email protected]:
dependencies:
mdn-data: 2.0.28
source-map-js: 1.2.2
[email protected]:
dependencies:
mdn-data: 2.27.1
source-map-js: 1.2.2
[email protected]: {}
[email protected]: {}
[email protected]: {}
[email protected]:
dependencies:
css-tree: 2.2.1
[email protected]: {}
[email protected]: {}
[email protected](@noble/[email protected]):
dependencies:
whatwg-mimetype: 5.0.0
@@ -9785,24 +9810,6 @@ snapshots:
[email protected]: {}
[email protected]:
dependencies:
domelementtype: 2.3.0
domhandler: 5.0.3
entities: 4.5.0
[email protected]: {}
[email protected]:
dependencies:
domelementtype: 2.3.0
[email protected]:
dependencies:
dom-serializer: 2.0.0
domelementtype: 2.3.0
domhandler: 5.0.3
[email protected]:
dependencies:
dotenv: 16.6.1
@@ -9908,6 +9915,8 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]:
dependencies:
iconv-lite: 0.6.3
@@ -9922,8 +9931,6 @@ snapshots:
graceful-fs: 4.2.11
tapable: 2.3.3
[email protected]: {}
[email protected]: {}
[email protected]: {}
@@ -10141,6 +10148,7 @@ snapshots:
'@esbuild/win32-arm64': 0.28.2
'@esbuild/win32-ia32': 0.28.2
'@esbuild/win32-x64': 0.28.2
optional: true
[email protected]: {}
@@ -10239,6 +10247,23 @@ snapshots:
transitivePeerDependencies:
- supports-color
[email protected]([email protected]([email protected])([email protected]))([email protected])([email protected]):
dependencies:
'@eslint/css-tree': 4.1.2
'@valibot/to-json-schema': 1.8.0([email protected]([email protected]))
enhanced-resolve: 5.26.0
jiti: 2.7.0
synckit: 0.12.3
tailwind-csstree: 0.3.3
tailwindcss: 4.3.3
tsconfig-paths-webpack-plugin: 4.2.0
valibot: 1.5.0([email protected])
optionalDependencies:
eslint: 10.13.0([email protected])([email protected])
transitivePeerDependencies:
- '@eslint/css'
- typescript
[email protected](@typescript-eslint/[email protected]([email protected]([email protected])([email protected]))([email protected])([email protected]))([email protected])([email protected]([email protected])([email protected]))([email protected]):
dependencies:
'@boundaries/elements': 3.2.0
@@ -10312,6 +10337,25 @@ snapshots:
- eslint-import-resolver-webpack
- supports-color
[email protected]([email protected]([email protected])([email protected])):
dependencies:
aria-query: 5.3.2
array-includes: 3.1.9
array.prototype.flatmap: 1.3.3
ast-types-flow: 0.0.8
axe-core: 4.14.0
axobject-query: 4.1.0
damerau-levenshtein: 1.0.8
emoji-regex: 9.2.2
eslint: 10.13.0([email protected])([email protected])
hasown: 2.0.4
jsx-ast-utils: 3.3.5
language-tags: 1.0.9
minimatch: 3.1.5
object.fromentries: 2.0.8
safe-regex-test: 1.1.0
string.prototype.includes: 2.0.1
[email protected]([email protected]([email protected]([email protected])([email protected])))([email protected]([email protected])([email protected]))([email protected]):
dependencies:
eslint: 9.39.4([email protected])([email protected])
@@ -11277,6 +11321,12 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]:
dependencies:
language-subtag-registry: 0.3.23
[email protected]: {}
[email protected]:
@@ -11643,10 +11693,10 @@ snapshots:
dependencies:
'@types/mdast': 4.0.4
[email protected]: {}
[email protected]: {}
[email protected]: {}
[email protected]:
dependencies:
is-what: 4.1.16
@@ -12005,10 +12055,6 @@ snapshots:
dependencies:
path-key: 4.0.0
[email protected]:
dependencies:
boolbase: 1.0.0
[email protected]:
dependencies:
fast-safe-stringify: 2.1.1
@@ -12819,8 +12865,6 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]:
dependencies:
xmlchars: 2.2.0
@@ -13054,6 +13098,12 @@ snapshots:
get-east-asian-width: 1.5.0
strip-ansi: 7.2.0
[email protected]:
dependencies:
call-bind: 1.0.9
define-properties: 1.2.1
es-abstract: 1.24.2
[email protected]:
dependencies:
call-bind: 1.0.9
@@ -13163,16 +13213,6 @@ snapshots:
[email protected]: {}
[email protected]:
dependencies:
commander: 11.1.0
css-select: 6.0.0
css-tree: 3.2.1
css-what: 7.0.0
csso: 5.0.5
picocolors: 1.1.1
sax: 1.6.1
[email protected]([email protected]):
dependencies:
call-me-maybe: 1.0.2
@@ -13193,6 +13233,13 @@ snapshots:
dependencies:
'@pkgr/core': 0.3.6
[email protected]:
dependencies:
'@dual-bundle/import-meta-resolve': 4.2.1
'@pkgr/core': 0.3.6
[email protected]: {}
[email protected]: {}
[email protected]([email protected])([email protected]):
@@ -13334,6 +13381,13 @@ snapshots:
[email protected]: {}
[email protected]:
dependencies:
chalk: 4.1.2
enhanced-resolve: 5.26.0
tapable: 2.3.3
tsconfig-paths: 4.2.0
[email protected]:
dependencies:
'@types/json5': 0.0.29
@@ -13341,6 +13395,12 @@ snapshots:
minimist: 1.2.8
strip-bom: 3.0.0
[email protected]:
dependencies:
json5: 2.2.3
minimist: 1.2.8
strip-bom: 3.0.0
[email protected]: {}
[email protected]: {}
@@ -13355,6 +13415,7 @@ snapshots:
esbuild: 0.28.2
optionalDependencies:
fsevents: 2.3.3
optional: true
[email protected]: {}