Merge pull request #249 from SnowLuma/dev
chore: promote dev → main (4e62fdc)
This commit is contained in:
65 files changed
+3200
-209
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "snowluma-monorepo",
|
||||
"version": "1.12.5",
|
||||
"version": "1.12.6",
|
||||
"description": "SnowLuma monorepo workspace (pnpm)",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/bridge",
|
||||
"version": "1.12.5",
|
||||
"version": "1.12.6",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "SnowLuma bridge — QQ NT desktop client lifecycle: hook injection (via native addon), per-PID HookSession orchestration, pipe-watcher for process discovery, and the BridgeManagerSink interface that lets the hook layer call back into a UIN-keyed session router without depending on @snowluma/core. Consumed by the top-level app entry (which constructs the BridgeManager from @snowluma/core and injects it as the sink) and by the WebUI server (read-only HookProcessInfo views).",
|
||||
|
||||
@@ -2,6 +2,7 @@ import net from 'net';
|
||||
import { mkdtemp, rm, writeFile } from 'fs/promises';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import { Duplex } from 'stream';
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { listLiveLinuxPipePids, QqHookClient } from '../src/qq-hook-client';
|
||||
|
||||
@@ -44,7 +45,7 @@ describe('listLiveLinuxPipePids', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe.skipIf(process.platform === 'win32')('QqHookClient — pipe close mid-send', () => {
|
||||
describe('QqHookClient — pipe close mid-send', () => {
|
||||
// Regression: when the control pipe closes while a send() is awaiting its
|
||||
// ack, rejectControlPending() rejects BOTH the ack and reply deferreds. The
|
||||
// reply is only `await`ed after the ack, so if the ack rejects first the
|
||||
@@ -54,10 +55,6 @@ describe.skipIf(process.platform === 'win32')('QqHookClient — pipe close mid-s
|
||||
// guard on each deferred prevents it; without the guard this test trips the
|
||||
// unhandledRejection assertion below.
|
||||
it('does not raise an unhandled rejection', async () => {
|
||||
const dir = await mkdtemp(path.join(os.tmpdir(), 'snowluma-pipe-'));
|
||||
const prevRuntimeDir = process.env.SNOWLUMA_HOOK_RUNTIME_DIR;
|
||||
process.env.SNOWLUMA_HOOK_RUNTIME_DIR = dir;
|
||||
|
||||
const PID = 778899;
|
||||
const helloFrame = (): Buffer => {
|
||||
const h = Buffer.alloc(40);
|
||||
@@ -69,10 +66,23 @@ describe.skipIf(process.platform === 'win32')('QqHookClient — pipe close mid-s
|
||||
};
|
||||
|
||||
let controlConn: net.Socket | null = null;
|
||||
const controlServer = net.createServer((sock) => { controlConn = sock; sock.write(helloFrame()); });
|
||||
const recvServer = net.createServer((sock) => { sock.write(helloFrame()); });
|
||||
await new Promise<void>((r) => controlServer.listen(path.join(dir, `mojo.${PID}.control.sock`), () => r()));
|
||||
await new Promise<void>((r) => recvServer.listen(path.join(dir, `mojo.${PID}.recv.sock`), () => r()));
|
||||
let signalControlWrite!: () => void;
|
||||
const controlWriteStarted = new Promise<void>((resolve) => { signalControlWrite = resolve; });
|
||||
const createConnection = vi.spyOn(net, 'createConnection').mockImplementation((() => {
|
||||
const socket = new Duplex({
|
||||
read() { /* peer data is injected with emit('data') */ },
|
||||
write(_chunk, _encoding, callback) {
|
||||
signalControlWrite();
|
||||
callback();
|
||||
},
|
||||
}) as net.Socket;
|
||||
controlConn = socket;
|
||||
queueMicrotask(() => {
|
||||
socket.emit('connect');
|
||||
queueMicrotask(() => socket.emit('data', helloFrame()));
|
||||
});
|
||||
return socket;
|
||||
}) as typeof net.createConnection);
|
||||
|
||||
const unhandled: unknown[] = [];
|
||||
const onUnhandled = (reason: unknown): void => { unhandled.push(reason); };
|
||||
@@ -81,28 +91,25 @@ describe.skipIf(process.platform === 'win32')('QqHookClient — pipe close mid-s
|
||||
const client = new QqHookClient(PID);
|
||||
client.on('error', () => { /* socket reset on destroy — ignore */ });
|
||||
try {
|
||||
await client.connectAll({ recv: true });
|
||||
await client.connect();
|
||||
|
||||
// Start a reply-expecting send, let it reach the in-flight (awaiting-ack)
|
||||
// state, then have the "hook" drop the pipe before it answers.
|
||||
const sent = client.send('noop', null, { wantReply: true, ackTimeoutMs: 1000, replyTimeoutMs: 1000 })
|
||||
.then(() => 'resolved' as const, (e: unknown) => e);
|
||||
await new Promise((r) => setTimeout(r, 30));
|
||||
await controlWriteStarted;
|
||||
controlConn?.destroy();
|
||||
|
||||
const outcome = await sent;
|
||||
await new Promise((r) => setTimeout(r, 50)); // let Node surface any unhandled rejection
|
||||
await new Promise<void>((resolve) => setImmediate(resolve));
|
||||
|
||||
expect(outcome).toBeInstanceOf(Error);
|
||||
expect((outcome as Error).message).toBe('control pipe closed');
|
||||
expect(unhandled, `unhandled rejections leaked: ${unhandled.map(String).join(', ')}`).toHaveLength(0);
|
||||
} finally {
|
||||
process.off('unhandledRejection', onUnhandled);
|
||||
client.close();
|
||||
await new Promise<void>((r) => controlServer.close(() => r()));
|
||||
await new Promise<void>((r) => recvServer.close(() => r()));
|
||||
if (prevRuntimeDir === undefined) delete process.env.SNOWLUMA_HOOK_RUNTIME_DIR;
|
||||
else process.env.SNOWLUMA_HOOK_RUNTIME_DIR = prevRuntimeDir;
|
||||
await rm(dir, { recursive: true, force: true });
|
||||
createConnection.mockRestore();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/common",
|
||||
"version": "1.12.5",
|
||||
"version": "1.12.6",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "SnowLuma shared infrastructure — leaf-package utilities with zero business dependencies. Logger / hex codec / log file transport / log line summariser / packet sender wire-protocol types / runtime config loader. Consumed by @snowluma/protocol, @snowluma/core, and @snowluma/onebot. Per-file subpath exports keep import sites unambiguous and let the bundler tree-shake aggressively (importing `@snowluma/common/hex` doesn't pull in `node:fs` from the logger transport).",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/core",
|
||||
"version": "1.12.5",
|
||||
"version": "1.12.6",
|
||||
"description": "SnowLuma core - NTQQ packet sniffer with Node.js native addon",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
||||
@@ -61,8 +61,8 @@ export class GroupAlbumApi {
|
||||
groupId: groupId.toString(),
|
||||
albumId,
|
||||
field3: 0,
|
||||
attachInfo,
|
||||
field5: '',
|
||||
field4: '',
|
||||
pageInfo: attachInfo,
|
||||
},
|
||||
traceId,
|
||||
extMap: [{ key: 'fc-appid', value: '100' }],
|
||||
|
||||
@@ -58,6 +58,9 @@ export interface GroupFolderInfo {
|
||||
creator: number;
|
||||
creatorName: string;
|
||||
totalFileCount: number;
|
||||
lastUploadTime: number;
|
||||
lastUploader: number;
|
||||
lastUploaderName: string;
|
||||
}
|
||||
|
||||
export interface GroupFilesResult {
|
||||
@@ -592,6 +595,8 @@ export class GroupFileApi {
|
||||
const folder = item.folderInfo;
|
||||
const creator = toInt(folder.creatorUin);
|
||||
const cached = this.ctx.identity.findGroupMember(groupId, creator);
|
||||
const lastUploader = toInt(folder.modifierUin);
|
||||
const lastUploaderCached = this.ctx.identity.findGroupMember(groupId, lastUploader);
|
||||
folders.push({
|
||||
folderId: typeof folder.folderId === 'string' ? folder.folderId : '',
|
||||
folderName: typeof folder.folderName === 'string' ? folder.folderName : '',
|
||||
@@ -602,6 +607,12 @@ export class GroupFileApi {
|
||||
|| cached?.nickname
|
||||
|| '',
|
||||
totalFileCount: toInt(folder.totalFileCount),
|
||||
lastUploadTime: toInt(folder.modifiedTime),
|
||||
lastUploader,
|
||||
lastUploaderName: (typeof folder.modifierName === 'string' && folder.modifierName)
|
||||
|| lastUploaderCached?.card
|
||||
|| lastUploaderCached?.nickname
|
||||
|| '',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { OnlineDeviceInfo } from '@snowluma/protocol/events';
|
||||
import type { BridgeContext } from './bridge-context';
|
||||
|
||||
export interface BridgeInterface extends BridgeContext {
|
||||
@@ -5,4 +6,7 @@ export interface BridgeInterface extends BridgeContext {
|
||||
/** False only when every attached QQ process is confirmed stale.
|
||||
* An unarmed watchdog remains true for compatibility. */
|
||||
readonly receiveHealthy: boolean;
|
||||
/** Latest device snapshot observed on this Bridge lifecycle. `null` means
|
||||
* QQ has not emitted its cache notification since SnowLuma attached. */
|
||||
getOnlineClients(): readonly Readonly<OnlineDeviceInfo>[] | null;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import { IdentityService } from '@snowluma/protocol/identity-service';
|
||||
import { MSG_PUSH_CMD, parseMsgPush, SysMsgDedup } from '@snowluma/protocol/msg-push';
|
||||
import { KICK_NT_CMD, parseKickNT } from '@snowluma/protocol/kick-nt';
|
||||
import { IncomingPacketPipeline, type CmdParser } from '@snowluma/protocol/packet-pipeline';
|
||||
import type { OnlineDeviceInfo } from '@snowluma/protocol/events';
|
||||
import { buildApiHub, type ApiHub } from './apis';
|
||||
import {
|
||||
AiVoiceChatType,
|
||||
@@ -35,6 +36,7 @@ export class Bridge implements BridgeInterface {
|
||||
private msgRandom_ = (Date.now() & 0xFFFFFFFF) >>> 0;
|
||||
// Per-account dedup for QQ NT's already-deduped system pushes (#137).
|
||||
private readonly sysMsgDedup_ = new SysMsgDedup();
|
||||
private onlineClients_: readonly Readonly<OnlineDeviceInfo>[] | null = null;
|
||||
|
||||
constructor(identity: IdentityService) {
|
||||
this.identity = identity;
|
||||
@@ -94,6 +96,13 @@ export class Bridge implements BridgeInterface {
|
||||
});
|
||||
this.pipeline.registerCmd(MSG_PUSH_CMD, (pkt, identity) => parseMsgPush(pkt, identity, this.sysMsgDedup_));
|
||||
this.pipeline.registerCmd(KICK_NT_CMD, parseKickNT);
|
||||
this.events.on('online_devices_changed', (event) => {
|
||||
const snapshot = event.devices.map((device) => Object.freeze({ ...device }));
|
||||
this.onlineClients_ = Object.freeze(snapshot);
|
||||
log.debug('online-device snapshot updated: uin=%s clients=%d types=%s',
|
||||
this.identity.uin, snapshot.length,
|
||||
snapshot.map((device) => device.clientType).join(','));
|
||||
});
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
@@ -102,6 +111,7 @@ export class Bridge implements BridgeInterface {
|
||||
this.packetClientsByPid_.clear();
|
||||
this.packetClient_ = null;
|
||||
this.packetClientPid_ = null;
|
||||
this.onlineClients_ = null;
|
||||
try {
|
||||
this.identity.close();
|
||||
} finally {
|
||||
@@ -202,6 +212,9 @@ export class Bridge implements BridgeInterface {
|
||||
}
|
||||
this.receiveHealthByPid_.set(pid, healthy);
|
||||
}
|
||||
getOnlineClients(): readonly Readonly<OnlineDeviceInfo>[] | null {
|
||||
return this.onlineClients_;
|
||||
}
|
||||
onPacket(pkt: PacketInfo): void {
|
||||
this.pipeline.process(pkt);
|
||||
}
|
||||
|
||||
@@ -100,6 +100,8 @@ export interface UiAppearance {
|
||||
reduceMotion: boolean;
|
||||
/** Hard-disable all UI animations (stronger than reduceMotion). */
|
||||
disableMotion: boolean;
|
||||
/** Use SnowLuma's adaptive cursor and custom context menu. */
|
||||
customPointerSystem: boolean;
|
||||
highContrast: boolean;
|
||||
sidebarPinned: boolean;
|
||||
timeFormat: TimeFormat;
|
||||
@@ -226,6 +228,7 @@ const DEFAULT_APPEARANCE: UiAppearance = {
|
||||
density: 'cozy',
|
||||
reduceMotion: false,
|
||||
disableMotion: false,
|
||||
customPointerSystem: false,
|
||||
highContrast: false,
|
||||
sidebarPinned: false,
|
||||
timeFormat: '24h',
|
||||
@@ -520,6 +523,7 @@ export function normalizeAppearance(value: unknown, imageState: ServerImageState
|
||||
density: oneOf<Density>(v.density, ['cozy', 'compact'], DEFAULT_APPEARANCE.density),
|
||||
reduceMotion: boolOr(v.reduceMotion, DEFAULT_APPEARANCE.reduceMotion),
|
||||
disableMotion: boolOr(v.disableMotion, DEFAULT_APPEARANCE.disableMotion),
|
||||
customPointerSystem: boolOr(v.customPointerSystem, DEFAULT_APPEARANCE.customPointerSystem),
|
||||
highContrast: boolOr(v.highContrast, DEFAULT_APPEARANCE.highContrast),
|
||||
sidebarPinned: boolOr(v.sidebarPinned, DEFAULT_APPEARANCE.sidebarPinned),
|
||||
timeFormat: oneOf<TimeFormat>(v.timeFormat, ['12h', '24h'], DEFAULT_APPEARANCE.timeFormat),
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import type { pb } from '@snowluma/proton';
|
||||
|
||||
interface GroupAlbumMediaListReqInfoWireOracle {
|
||||
reserved?: pb<4, string>;
|
||||
pageInfo?: pb<5, string>;
|
||||
}
|
||||
|
||||
export interface GroupAlbumMediaListRequestWireOracle {
|
||||
reqInfo?: pb<4, GroupAlbumMediaListReqInfoWireOracle>;
|
||||
}
|
||||
@@ -1,10 +1,23 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { GetMediaListResponse } from '@snowluma/proto-defs/oidb-actions/group-album';
|
||||
import { protobuf_encode } from '@snowluma/proton';
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import { GroupAlbumApi } from '../../src/bridge/apis/group-album';
|
||||
import { mockBridge } from './_helpers';
|
||||
import type { GroupAlbumMediaListRequestWireOracle } from './group-album-wire-fixture';
|
||||
|
||||
describe('apis/group-album', () => {
|
||||
it('encodes the next-page cursor in the page-info field', async () => {
|
||||
const bridge = mockBridge();
|
||||
const cursor = '{"IndexType":"next","Loc":{"batch_id":2147483650}}';
|
||||
|
||||
await new GroupAlbumApi(bridge as never).getMediaList(12345, 'album-id', cursor);
|
||||
|
||||
const [, requestBytes] = bridge.sendRawPacket.mock.calls[0]!;
|
||||
const request = protobuf_decode<GroupAlbumMediaListRequestWireOracle>(requestBytes);
|
||||
expect(request.reqInfo?.pageInfo).toBe(cursor);
|
||||
expect(request.reqInfo?.reserved).toBeNull();
|
||||
});
|
||||
|
||||
it('accepts a successful media-list response with an omitted zero retCode', async () => {
|
||||
const bridge = mockBridge();
|
||||
bridge.sendRawPacket.mockResolvedValueOnce({
|
||||
|
||||
@@ -503,7 +503,18 @@ describe('apis/group-file', () => {
|
||||
isEnd: true,
|
||||
items: [
|
||||
{ type: 1, fileInfo: { fileId: 'f1', fileName: 'a.txt', uploaderUin: 1, uploaderName: 'alice' } },
|
||||
{ type: 2, folderInfo: { folderId: 'd1', folderName: 'dir', creatorUin: 2, creatorName: 'bob' } },
|
||||
{
|
||||
type: 2,
|
||||
folderInfo: {
|
||||
folderId: 'd1',
|
||||
folderName: 'dir',
|
||||
creatorUin: 2,
|
||||
creatorName: 'bob',
|
||||
modifiedTime: 200,
|
||||
modifierUin: 5_000_000_001n,
|
||||
modifierName: 'alice',
|
||||
},
|
||||
},
|
||||
],
|
||||
} as any,
|
||||
},
|
||||
@@ -513,7 +524,15 @@ describe('apis/group-file', () => {
|
||||
expect(out.files).toHaveLength(1);
|
||||
expect(out.files[0]).toMatchObject({ fileId: 'f1', fileName: 'a.txt', uploader: 1, uploaderName: 'alice' });
|
||||
expect(out.folders).toHaveLength(1);
|
||||
expect(out.folders[0]).toMatchObject({ folderId: 'd1', folderName: 'dir', creator: 2, creatorName: 'bob' });
|
||||
expect(out.folders[0]).toMatchObject({
|
||||
folderId: 'd1',
|
||||
folderName: 'dir',
|
||||
creator: 2,
|
||||
creatorName: 'bob',
|
||||
lastUploadTime: 200,
|
||||
lastUploader: 5_000_000_001,
|
||||
lastUploaderName: 'alice',
|
||||
});
|
||||
});
|
||||
|
||||
it('getUrl builds the https URL from downloadDns + hex-encoded path', async () => {
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { PacketInfo } from '@snowluma/common/protocol-types';
|
||||
import type { OnlineDeviceInfo, QQEventVariant } from '@snowluma/protocol/events';
|
||||
import { IdentityService } from '@snowluma/protocol/identity-service';
|
||||
import { Bridge } from '../src/bridge/bridge';
|
||||
|
||||
function packet(sequence: number): PacketInfo {
|
||||
return {
|
||||
pid: 1,
|
||||
uin: '10001',
|
||||
serviceCmd: 'test.online_devices',
|
||||
seqId: sequence,
|
||||
retCode: 0,
|
||||
fromClient: false,
|
||||
body: new Uint8Array(0),
|
||||
};
|
||||
}
|
||||
|
||||
function device(overrides: Partial<OnlineDeviceInfo> = {}): OnlineDeviceInfo {
|
||||
return {
|
||||
appId: 537242075,
|
||||
instanceId: 202,
|
||||
clientType: 1,
|
||||
platform: 3,
|
||||
deviceName: 'DESKTOP-TEST',
|
||||
deviceKind: 'computer',
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe('Bridge online-device snapshot', () => {
|
||||
it('distinguishes not-yet-observed from an observed empty snapshot', () => {
|
||||
const bridge = new Bridge(IdentityService.memory('10001'));
|
||||
let current: OnlineDeviceInfo[] = [device()];
|
||||
bridge.registerCmd('test.online_devices', () => [{
|
||||
kind: 'online_devices_changed',
|
||||
time: 1710000000,
|
||||
selfUin: 10001,
|
||||
devices: current,
|
||||
} satisfies QQEventVariant]);
|
||||
|
||||
expect(bridge.getOnlineClients()).toBeNull();
|
||||
|
||||
bridge.onPacket(packet(1));
|
||||
expect(bridge.getOnlineClients()).toEqual([device()]);
|
||||
|
||||
current = [];
|
||||
bridge.onPacket(packet(2));
|
||||
expect(bridge.getOnlineClients()).toEqual([]);
|
||||
});
|
||||
|
||||
it('owns an immutable copy and clears it when the Bridge is disposed', () => {
|
||||
const bridge = new Bridge(IdentityService.memory('10001'));
|
||||
const source = device();
|
||||
bridge.registerCmd('test.online_devices', () => [{
|
||||
kind: 'online_devices_changed',
|
||||
time: 1710000000,
|
||||
selfUin: 10001,
|
||||
devices: [source],
|
||||
}]);
|
||||
|
||||
bridge.onPacket(packet(1));
|
||||
const snapshot = bridge.getOnlineClients();
|
||||
expect(snapshot).not.toBeNull();
|
||||
expect(snapshot?.[0]).not.toBe(source);
|
||||
expect(Object.isFrozen(snapshot)).toBe(true);
|
||||
expect(Object.isFrozen(snapshot?.[0])).toBe(true);
|
||||
|
||||
source.deviceName = 'MUTATED';
|
||||
expect(bridge.getOnlineClients()?.[0]?.deviceName).toBe('DESKTOP-TEST');
|
||||
|
||||
bridge.dispose();
|
||||
expect(bridge.getOnlineClients()).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -15,7 +15,7 @@ import type { GroupMemberInfo, QQGroupInfo } from '@snowluma/protocol/qq-info';
|
||||
import type {
|
||||
GroupChange, NewFriend, FriendRecall, OperatorInfo, SelfJoinInGroup, GroupAdmin,
|
||||
InputStatusNotify, NotifyMessageBody, GroupNameChange, GroupSpecialTitleChange,
|
||||
ProfileLikeTip,
|
||||
OnlineDeviceNotify, ProfileLikeTip,
|
||||
} from '@snowluma/proto-defs/notify';
|
||||
import type { PushMsg } from '@snowluma/proto-defs/message';
|
||||
import type {
|
||||
@@ -449,6 +449,131 @@ describe('parseMsgPush Event0x210 subType=277 (input status → 对方正在输
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseMsgPush Event0x210 subType=349 (online-device snapshot)', () => {
|
||||
it('decodes the complete device fields recovered from the QQ wire handler', () => {
|
||||
const content = protobuf_encode<OnlineDeviceNotify>({
|
||||
appId: 537242075,
|
||||
instanceId: 101,
|
||||
clientType: 1,
|
||||
platform: 3,
|
||||
devices: [
|
||||
{
|
||||
appId: 537242075,
|
||||
instanceId: 202,
|
||||
clientType: 1,
|
||||
platform: 3,
|
||||
deviceName: 'DESKTOP-TEST',
|
||||
},
|
||||
{
|
||||
appId: 537242075,
|
||||
instanceId: 203,
|
||||
clientType: 5,
|
||||
platform: 3,
|
||||
deviceName: 'DESKTOP-DUPLICATE',
|
||||
},
|
||||
{
|
||||
appId: 537242075,
|
||||
instanceId: 303,
|
||||
clientType: 4,
|
||||
platform: 2,
|
||||
deviceName: 'Pixel 9',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const events = parseMsgPush(
|
||||
makeEvent0x210PacketAny(349, content),
|
||||
makeIdentity(),
|
||||
);
|
||||
|
||||
expect(events).toEqual([{
|
||||
kind: 'online_devices_changed',
|
||||
time: 1710000000,
|
||||
selfUin: Number(SELF_UIN),
|
||||
devices: [
|
||||
{
|
||||
appId: 537242075,
|
||||
instanceId: 202,
|
||||
clientType: 1,
|
||||
platform: 3,
|
||||
deviceName: 'DESKTOP-TEST',
|
||||
deviceKind: 'computer',
|
||||
},
|
||||
{
|
||||
appId: 537242075,
|
||||
instanceId: 303,
|
||||
clientType: 4,
|
||||
platform: 2,
|
||||
deviceName: 'Pixel 9',
|
||||
deviceKind: 'phone',
|
||||
},
|
||||
],
|
||||
}]);
|
||||
});
|
||||
|
||||
it('normalizes packed wire client types before classification and deduplication', () => {
|
||||
const content = protobuf_encode<OnlineDeviceNotify>({
|
||||
devices: [
|
||||
{
|
||||
appId: 1001,
|
||||
instanceId: 202,
|
||||
clientType: 83714, // 0x14702 -> phone client type 2
|
||||
platform: 3,
|
||||
deviceName: 'BOT-HOST',
|
||||
},
|
||||
{
|
||||
appId: 1001,
|
||||
instanceId: 203,
|
||||
clientType: 65799, // 0x10107 -> phone client type 7
|
||||
platform: 2,
|
||||
deviceName: 'MOBILE-DUPLICATE',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const events = parseMsgPush(
|
||||
makeEvent0x210PacketAny(349, content),
|
||||
makeIdentity(),
|
||||
);
|
||||
|
||||
expect(events).toEqual([{
|
||||
kind: 'online_devices_changed',
|
||||
time: 1710000000,
|
||||
selfUin: Number(SELF_UIN),
|
||||
devices: [{
|
||||
appId: 1001,
|
||||
instanceId: 202,
|
||||
clientType: 2,
|
||||
platform: 3,
|
||||
deviceName: 'BOT-HOST',
|
||||
deviceKind: 'phone',
|
||||
}],
|
||||
}]);
|
||||
});
|
||||
|
||||
it('rejects entries that omit required identity fields', () => {
|
||||
const content = protobuf_encode<OnlineDeviceNotify>({
|
||||
devices: [{ instanceId: 202, platform: 3, deviceName: 'BROKEN' }],
|
||||
});
|
||||
const captured: string[] = [];
|
||||
const unsubscribe = subscribeLogs((entry) => {
|
||||
if (entry.scope === 'MsgPush' && /online-device entry 0/.test(entry.message)) {
|
||||
captured.push(entry.message);
|
||||
}
|
||||
});
|
||||
try {
|
||||
expect(parseMsgPush(
|
||||
makeEvent0x210PacketAny(349, content),
|
||||
makeIdentity(),
|
||||
)).toEqual([]);
|
||||
expect(captured).toHaveLength(1);
|
||||
expect(captured[0]).toMatch(/appIdPresent=false clientTypePresent=false/);
|
||||
} finally {
|
||||
unsubscribe();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseMsgPush Event0x210 subType=39 (profile like → 名片赞)', () => {
|
||||
// 0x210/39 is multiplexed; body.msgContent decodes as ProfileLikeTip and is a
|
||||
// like only when inner msgType==0 && subType==203. Proto shape from NapCat's
|
||||
|
||||
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/mcp",
|
||||
"version": "1.12.5",
|
||||
"version": "1.12.6",
|
||||
"description": "MCP server exposing the SnowLuma OneBot action catalog (docs + JSON Schemas) and optional execution to LLM clients.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -3660,6 +3660,18 @@
|
||||
"total_file_count": {
|
||||
"type": "integer",
|
||||
"description": "文件夹内文件总数"
|
||||
},
|
||||
"last_upload_time": {
|
||||
"type": "integer",
|
||||
"description": "最后上传时间戳"
|
||||
},
|
||||
"last_uploader": {
|
||||
"type": "integer",
|
||||
"description": "最后上传者 QQ 号"
|
||||
},
|
||||
"last_uploader_name": {
|
||||
"type": "string",
|
||||
"description": "最后上传者昵称"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4590,6 +4602,18 @@
|
||||
"total_file_count": {
|
||||
"type": "integer",
|
||||
"description": "文件夹内文件总数"
|
||||
},
|
||||
"last_upload_time": {
|
||||
"type": "integer",
|
||||
"description": "最后上传时间戳"
|
||||
},
|
||||
"last_uploader": {
|
||||
"type": "integer",
|
||||
"description": "最后上传者 QQ 号"
|
||||
},
|
||||
"last_uploader_name": {
|
||||
"type": "string",
|
||||
"description": "最后上传者昵称"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4958,14 +4982,42 @@
|
||||
{
|
||||
"name": "get_online_clients",
|
||||
"aliases": [],
|
||||
"summary": "获取在线客户端(占位,OneBot v11 形状)",
|
||||
"returns": "{ clients }:在线设备列表(占位,clients 恒为空数组)。",
|
||||
"summary": "获取在线客户端",
|
||||
"returns": "{ clients }:QQ 本次会话最近推送的在线设备快照。",
|
||||
"returnsSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"clients": {
|
||||
"type": "array",
|
||||
"description": "在线设备列表(占位,恒空)"
|
||||
"description": "在线设备列表",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"app_id": {
|
||||
"type": "integer",
|
||||
"description": "客户端 ID"
|
||||
},
|
||||
"device_name": {
|
||||
"type": "string",
|
||||
"description": "设备名称"
|
||||
},
|
||||
"device_kind": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"电脑",
|
||||
"Pad",
|
||||
"手机",
|
||||
"未知设备"
|
||||
],
|
||||
"description": "设备类别"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"app_id",
|
||||
"device_name",
|
||||
"device_kind"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -4973,11 +5025,28 @@
|
||||
]
|
||||
},
|
||||
"readOnly": true,
|
||||
"params": [],
|
||||
"params": [
|
||||
{
|
||||
"name": "no_cache",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"default": false,
|
||||
"desc": "是否强制刷新;QQ 当前仅暴露本地快照,true 会明确失败"
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"properties": {
|
||||
"no_cache": {
|
||||
"type": "boolean",
|
||||
"description": "是否强制刷新;QQ 当前仅暴露本地快照,true 会明确失败",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "扩展"
|
||||
@@ -5751,7 +5820,7 @@
|
||||
"name": "get_stranger_info",
|
||||
"aliases": [],
|
||||
"summary": "获取陌生人信息",
|
||||
"returns": "陌生人资料:QQ 号、昵称、性别、年龄,命中资料时另含等级。",
|
||||
"returns": "陌生人资料:QQ 号、昵称、性别、年龄与个性签名,命中资料时另含等级。",
|
||||
"returnsSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -5771,6 +5840,10 @@
|
||||
"type": "integer",
|
||||
"description": "年龄"
|
||||
},
|
||||
"long_nick": {
|
||||
"type": "string",
|
||||
"description": "个性签名"
|
||||
},
|
||||
"qq_level": {
|
||||
"type": "integer",
|
||||
"description": "QQ 等级(仅查到资料时返回)"
|
||||
@@ -5784,7 +5857,8 @@
|
||||
"user_id",
|
||||
"nickname",
|
||||
"sex",
|
||||
"age"
|
||||
"age",
|
||||
"long_nick"
|
||||
]
|
||||
},
|
||||
"readOnly": true,
|
||||
|
||||
@@ -3663,6 +3663,18 @@ export const ACTIONS: CatalogAction[] = [
|
||||
"total_file_count": {
|
||||
"type": "integer",
|
||||
"description": "文件夹内文件总数"
|
||||
},
|
||||
"last_upload_time": {
|
||||
"type": "integer",
|
||||
"description": "最后上传时间戳"
|
||||
},
|
||||
"last_uploader": {
|
||||
"type": "integer",
|
||||
"description": "最后上传者 QQ 号"
|
||||
},
|
||||
"last_uploader_name": {
|
||||
"type": "string",
|
||||
"description": "最后上传者昵称"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4593,6 +4605,18 @@ export const ACTIONS: CatalogAction[] = [
|
||||
"total_file_count": {
|
||||
"type": "integer",
|
||||
"description": "文件夹内文件总数"
|
||||
},
|
||||
"last_upload_time": {
|
||||
"type": "integer",
|
||||
"description": "最后上传时间戳"
|
||||
},
|
||||
"last_uploader": {
|
||||
"type": "integer",
|
||||
"description": "最后上传者 QQ 号"
|
||||
},
|
||||
"last_uploader_name": {
|
||||
"type": "string",
|
||||
"description": "最后上传者昵称"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4961,14 +4985,42 @@ export const ACTIONS: CatalogAction[] = [
|
||||
{
|
||||
"name": "get_online_clients",
|
||||
"aliases": [],
|
||||
"summary": "获取在线客户端(占位,OneBot v11 形状)",
|
||||
"returns": "{ clients }:在线设备列表(占位,clients 恒为空数组)。",
|
||||
"summary": "获取在线客户端",
|
||||
"returns": "{ clients }:QQ 本次会话最近推送的在线设备快照。",
|
||||
"returnsSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"clients": {
|
||||
"type": "array",
|
||||
"description": "在线设备列表(占位,恒空)"
|
||||
"description": "在线设备列表",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"app_id": {
|
||||
"type": "integer",
|
||||
"description": "客户端 ID"
|
||||
},
|
||||
"device_name": {
|
||||
"type": "string",
|
||||
"description": "设备名称"
|
||||
},
|
||||
"device_kind": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"电脑",
|
||||
"Pad",
|
||||
"手机",
|
||||
"未知设备"
|
||||
],
|
||||
"description": "设备类别"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"app_id",
|
||||
"device_name",
|
||||
"device_kind"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -4976,11 +5028,28 @@ export const ACTIONS: CatalogAction[] = [
|
||||
]
|
||||
},
|
||||
"readOnly": true,
|
||||
"params": [],
|
||||
"params": [
|
||||
{
|
||||
"name": "no_cache",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"default": false,
|
||||
"desc": "是否强制刷新;QQ 当前仅暴露本地快照,true 会明确失败"
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"properties": {
|
||||
"no_cache": {
|
||||
"type": "boolean",
|
||||
"description": "是否强制刷新;QQ 当前仅暴露本地快照,true 会明确失败",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "扩展"
|
||||
@@ -5754,7 +5823,7 @@ export const ACTIONS: CatalogAction[] = [
|
||||
"name": "get_stranger_info",
|
||||
"aliases": [],
|
||||
"summary": "获取陌生人信息",
|
||||
"returns": "陌生人资料:QQ 号、昵称、性别、年龄,命中资料时另含等级。",
|
||||
"returns": "陌生人资料:QQ 号、昵称、性别、年龄与个性签名,命中资料时另含等级。",
|
||||
"returnsSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -5774,6 +5843,10 @@ export const ACTIONS: CatalogAction[] = [
|
||||
"type": "integer",
|
||||
"description": "年龄"
|
||||
},
|
||||
"long_nick": {
|
||||
"type": "string",
|
||||
"description": "个性签名"
|
||||
},
|
||||
"qq_level": {
|
||||
"type": "integer",
|
||||
"description": "QQ 等级(仅查到资料时返回)"
|
||||
@@ -5787,7 +5860,8 @@ export const ACTIONS: CatalogAction[] = [
|
||||
"user_id",
|
||||
"nickname",
|
||||
"sex",
|
||||
"age"
|
||||
"age",
|
||||
"long_nick"
|
||||
]
|
||||
},
|
||||
"readOnly": true,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/onebot",
|
||||
"version": "1.12.5",
|
||||
"version": "1.12.6",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "SnowLuma OneBot v11 adapter — the protocol translation layer that maps the public OneBot vocabulary (HTTP / WebSocket actions, message segments, post events) onto @snowluma/core's typed Api hub (`bridge.apis.<area>.method()`). Owns network adapters (HTTP server / HTTP client / WS server / WS client), the registered action handlers, the receive-side event→OneBot converter, message-id hashing, message store (SQLite-backed event history), media store, and the OneBot instance + manager that ties one OneBotConfig to one Bridge. Per-file subpath exports mirror the legacy `core/src/onebot/*` layout 1:1 so the previous `import { … } from '../onebot/<x>'` collapses to `import { … } from '@snowluma/onebot/<x>'`.",
|
||||
|
||||
@@ -1199,25 +1199,60 @@ export const actions = [
|
||||
},
|
||||
}),
|
||||
|
||||
// get_online_clients — 在线设备列表。NapCat 也拿不到(注册监听后 sleep 500ms
|
||||
// 直接返回空),且其返回是裸数组 [],偏离 OneBot v11 / go-cqhttp 规范。
|
||||
// SnowLuma 暂无对应单包 SSO cmd,返回 OneBot v11 标准空壳 { clients: [] }
|
||||
// ——刻意采用规范形状而非 NapCat 的裸 [],故对照 NapCat 客户端此处不严格 parity。
|
||||
defineAction({
|
||||
name: 'get_online_clients',
|
||||
summary: '获取在线客户端(占位,OneBot v11 形状)',
|
||||
summary: '获取在线客户端',
|
||||
readOnly: true,
|
||||
returns: '{ clients }:在线设备列表(占位,clients 恒为空数组)。',
|
||||
returns: '{ clients }:QQ 本次会话最近推送的在线设备快照。',
|
||||
returnsSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
clients: { type: 'array', description: '在线设备列表(占位,恒空)' },
|
||||
clients: {
|
||||
type: 'array',
|
||||
description: '在线设备列表',
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
app_id: { type: 'integer', description: '客户端 ID' },
|
||||
device_name: { type: 'string', description: '设备名称' },
|
||||
device_kind: {
|
||||
type: 'string',
|
||||
enum: ['电脑', 'Pad', '手机', '未知设备'],
|
||||
description: '设备类别',
|
||||
},
|
||||
},
|
||||
required: ['app_id', 'device_name', 'device_kind'],
|
||||
},
|
||||
},
|
||||
},
|
||||
required: ['clients'],
|
||||
},
|
||||
params: {},
|
||||
run: async () => {
|
||||
return okResponse({ clients: [] });
|
||||
params: {
|
||||
no_cache: f.bool().default(false).describe('是否强制刷新;QQ 当前仅暴露本地快照,true 会明确失败'),
|
||||
},
|
||||
run: async (p, ctx) => {
|
||||
if (p.no_cache) {
|
||||
return failedResponse(RETCODE.ACTION_FAILED,
|
||||
'online-client fresh refresh is unavailable; QQ exposes only its local snapshot');
|
||||
}
|
||||
const snapshot = ctx.bridge.getOnlineClients();
|
||||
if (snapshot === null) {
|
||||
return failedResponse(RETCODE.ACTION_FAILED,
|
||||
'online-client snapshot has not been observed in this session');
|
||||
}
|
||||
const kindLabels = {
|
||||
computer: '电脑',
|
||||
pad: 'Pad',
|
||||
phone: '手机',
|
||||
unknown: '未知设备',
|
||||
} as const;
|
||||
return okResponse({
|
||||
clients: snapshot.map((device) => ({
|
||||
app_id: device.appId,
|
||||
device_name: device.deviceName,
|
||||
device_kind: kindLabels[device.deviceKind],
|
||||
})),
|
||||
});
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -2050,7 +2085,7 @@ export const actions = [
|
||||
summary: '设置个性签名(longNick/long_nick,严格 string)',
|
||||
params: { longNick: f.raw(), long_nick: f.raw() },
|
||||
run: async (p, ctx) => {
|
||||
const longNick = p.longNick || p.long_nick;
|
||||
const longNick = p.longNick !== undefined ? p.longNick : p.long_nick;
|
||||
if (typeof longNick !== 'string') return failedResponse(RETCODE.BAD_REQUEST, 'invalid longNick');
|
||||
await ctx.bridge.apis.profile.setSelfLongNick(longNick);
|
||||
return okResponse({});
|
||||
|
||||
@@ -32,7 +32,7 @@ export const actions = [
|
||||
name: 'get_stranger_info',
|
||||
summary: '获取陌生人信息',
|
||||
readOnly: true,
|
||||
returns: '陌生人资料:QQ 号、昵称、性别、年龄,命中资料时另含等级。',
|
||||
returns: '陌生人资料:QQ 号、昵称、性别、年龄与个性签名,命中资料时另含等级。',
|
||||
returnsSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
@@ -40,19 +40,24 @@ export const actions = [
|
||||
nickname: { type: 'string', description: '昵称' },
|
||||
sex: { type: 'string', description: '性别(male/female/unknown)' },
|
||||
age: { type: 'integer', description: '年龄' },
|
||||
long_nick: { type: 'string', description: '个性签名' },
|
||||
qq_level: { type: 'integer', description: 'QQ 等级(仅查到资料时返回)' },
|
||||
level: { type: 'integer', description: 'QQ 等级,同 qq_level(仅查到资料时返回)' },
|
||||
},
|
||||
required: ['user_id', 'nickname', 'sex', 'age'],
|
||||
required: ['user_id', 'nickname', 'sex', 'age', 'long_nick'],
|
||||
},
|
||||
params: { user_id: f.userId().describe('QQ 号') },
|
||||
run: async (p, ctx) => {
|
||||
const userId = p.user_id;
|
||||
if (ctx.getStrangerInfo) {
|
||||
const info = await ctx.getStrangerInfo(userId);
|
||||
return okResponse(info ?? { user_id: userId, nickname: '', sex: 'unknown', age: 0 });
|
||||
return okResponse(info ?? {
|
||||
user_id: userId, nickname: '', sex: 'unknown', age: 0, long_nick: '',
|
||||
});
|
||||
}
|
||||
return okResponse({ user_id: userId, nickname: '', sex: 'unknown', age: 0 });
|
||||
return okResponse({
|
||||
user_id: userId, nickname: '', sex: 'unknown', age: 0, long_nick: '',
|
||||
});
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -66,4 +71,3 @@ export const actions = [
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
@@ -113,6 +113,9 @@ export const actions = [
|
||||
creator: { type: 'integer', description: '创建者 QQ 号' },
|
||||
create_name: { type: 'string', description: '创建者昵称' },
|
||||
total_file_count: { type: 'integer', description: '文件夹内文件总数' },
|
||||
last_upload_time: { type: 'integer', description: '最后上传时间戳' },
|
||||
last_uploader: { type: 'integer', description: '最后上传者 QQ 号' },
|
||||
last_uploader_name: { type: 'string', description: '最后上传者昵称' },
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -165,6 +168,9 @@ export const actions = [
|
||||
creator: { type: 'integer', description: '创建者 QQ 号' },
|
||||
create_name: { type: 'string', description: '创建者昵称' },
|
||||
total_file_count: { type: 'integer', description: '文件夹内文件总数' },
|
||||
last_upload_time: { type: 'integer', description: '最后上传时间戳' },
|
||||
last_uploader: { type: 'integer', description: '最后上传者 QQ 号' },
|
||||
last_uploader_name: { type: 'string', description: '最后上传者昵称' },
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -290,4 +296,3 @@ export const actions = [
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
@@ -97,6 +97,8 @@ const CONVERTERS: ConverterRegistry = {
|
||||
// Internal-only: async voice-to-text result, correlated by a pending
|
||||
// fetch_ptt_text; never emitted as an OneBot event.
|
||||
ptt_trans_result: null,
|
||||
// Internal-only cache snapshot consumed by Bridge.getOnlineClients().
|
||||
online_devices_changed: null,
|
||||
};
|
||||
|
||||
export async function convertEvent(
|
||||
|
||||
@@ -210,6 +210,9 @@ export async function getGroupFiles(
|
||||
creator: folder.creator,
|
||||
create_name: folder.creatorName,
|
||||
total_file_count: folder.totalFileCount,
|
||||
last_upload_time: folder.lastUploadTime,
|
||||
last_uploader: folder.lastUploader,
|
||||
last_uploader_name: folder.lastUploaderName,
|
||||
} as JsonObject)),
|
||||
};
|
||||
}
|
||||
@@ -225,6 +228,7 @@ export async function getStrangerInfo(
|
||||
nickname: p.nickname,
|
||||
sex: p.sex,
|
||||
age: p.age,
|
||||
long_nick: p.sign,
|
||||
qq_level: p.level,
|
||||
level: p.level,
|
||||
};
|
||||
@@ -236,6 +240,7 @@ export async function getStrangerInfo(
|
||||
nickname: p.nickname,
|
||||
sex: p.sex,
|
||||
age: p.age,
|
||||
long_nick: p.sign,
|
||||
qq_level: p.level,
|
||||
level: p.level,
|
||||
};
|
||||
|
||||
@@ -22,6 +22,21 @@ describe('action-docs', () => {
|
||||
expect(duration).toMatchObject({ type: 'int', required: false, default: 1800 });
|
||||
});
|
||||
|
||||
it.each(['get_group_root_files', 'get_group_files_by_folder'])(
|
||||
'documents folder last-upload metadata for %s',
|
||||
(name) => {
|
||||
const action = docs.find((d) => d.name === name);
|
||||
const properties = action?.returnsSchema?.properties as Record<string, any> | undefined;
|
||||
const folderProperties = properties?.folders?.items?.properties as Record<string, unknown> | undefined;
|
||||
|
||||
expect(folderProperties).toEqual(expect.objectContaining({
|
||||
last_upload_time: expect.objectContaining({ type: 'integer' }),
|
||||
last_uploader: expect.objectContaining({ type: 'integer' }),
|
||||
last_uploader_name: expect.objectContaining({ type: 'string' }),
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
it('renders markdown with header + an action section', () => {
|
||||
const md = renderActionDocsMarkdown(docs);
|
||||
expect(md).toContain('# OneBot Actions');
|
||||
|
||||
@@ -11,6 +11,7 @@ import type {
|
||||
import {
|
||||
getFriendList,
|
||||
getGroupInfo,
|
||||
getGroupFiles,
|
||||
getGroupList,
|
||||
getGroupMemberInfo,
|
||||
getGroupMemberList,
|
||||
@@ -89,9 +90,15 @@ function makeMember(uin: number, nickname: string, card = ''): GroupMemberInfo {
|
||||
};
|
||||
}
|
||||
|
||||
function makeProfile(uin: number, nickname: string, sex: 'male' | 'female' | 'unknown' = 'unknown', age = 0): UserProfileInfo {
|
||||
function makeProfile(
|
||||
uin: number,
|
||||
nickname: string,
|
||||
sex: 'male' | 'female' | 'unknown' = 'unknown',
|
||||
age = 0,
|
||||
sign = '',
|
||||
): UserProfileInfo {
|
||||
return {
|
||||
uin, uid: `u_${uin}`, nickname, remark: '', qid: '', sex, age, sign: '', avatar: '',
|
||||
uin, uid: `u_${uin}`, nickname, remark: '', qid: '', sex, age, sign, avatar: '',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -158,6 +165,35 @@ describe('onebot/contact-actions / getFriendList', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('onebot/contact-actions / getGroupFiles', () => {
|
||||
it('returns folder last-upload metadata in OneBot field names', async () => {
|
||||
const list = vi.fn(async () => ({
|
||||
files: [],
|
||||
folders: [{
|
||||
folderId: 'd1',
|
||||
folderName: 'dir',
|
||||
createTime: 100,
|
||||
creator: 123,
|
||||
creatorName: 'creator',
|
||||
totalFileCount: 2,
|
||||
lastUploadTime: 200,
|
||||
lastUploader: 5_000_000_001,
|
||||
lastUploaderName: 'uploader',
|
||||
}],
|
||||
}));
|
||||
const bridge = fakeBridge({ apis: { groupFile: { list } } });
|
||||
|
||||
const out = await getGroupFiles(bridge, 12345, '/');
|
||||
|
||||
expect(out.folders).toEqual([expect.objectContaining({
|
||||
last_upload_time: 200,
|
||||
last_uploader: 5_000_000_001,
|
||||
last_uploader_name: 'uploader',
|
||||
})]);
|
||||
expect(list).toHaveBeenCalledWith(12345, '/');
|
||||
});
|
||||
});
|
||||
|
||||
describe('onebot/contact-actions / getGroupList', () => {
|
||||
it('triggers fetch when the in-memory roster is empty', async () => {
|
||||
const fetched = [makeGroup(100, 'Group A')];
|
||||
@@ -353,10 +389,16 @@ describe('onebot/contact-actions / getGroupMemberInfo', () => {
|
||||
describe('onebot/contact-actions / getStrangerInfo', () => {
|
||||
it('returns a fetched profile', async () => {
|
||||
const bridge = fakeBridge({
|
||||
fetchUserProfile: vi.fn(async () => makeProfile(55555, 'Eve', 'female', 25)),
|
||||
fetchUserProfile: vi.fn(async () => makeProfile(55555, 'Eve', 'female', 25, 'Stay curious')),
|
||||
});
|
||||
const out = await getStrangerInfo(bridge, 55555);
|
||||
expect(out).toMatchObject({ user_id: 55555, nickname: 'Eve', sex: 'female', age: 25 });
|
||||
expect(out).toMatchObject({
|
||||
user_id: 55555,
|
||||
nickname: 'Eve',
|
||||
sex: 'female',
|
||||
age: 25,
|
||||
long_nick: 'Stay curious',
|
||||
});
|
||||
});
|
||||
|
||||
it('falls back to identity.findUserProfile when fetch fails but the profile is cached', async () => {
|
||||
@@ -364,11 +406,15 @@ describe('onebot/contact-actions / getStrangerInfo', () => {
|
||||
fetchUserProfile: vi.fn(async () => { throw new Error('net'); }),
|
||||
identity: fakeIdentity({
|
||||
findUserProfile: (uin: number) =>
|
||||
uin === 66666 ? makeProfile(66666, 'Frank', 'male', 30) : null,
|
||||
uin === 66666 ? makeProfile(66666, 'Frank', 'male', 30, 'Cached signature') : null,
|
||||
}),
|
||||
});
|
||||
const out = await getStrangerInfo(bridge, 66666);
|
||||
expect(out).toMatchObject({ user_id: 66666, nickname: 'Frank' });
|
||||
expect(out).toMatchObject({
|
||||
user_id: 66666,
|
||||
nickname: 'Frank',
|
||||
long_nick: 'Cached signature',
|
||||
});
|
||||
});
|
||||
|
||||
it('returns null when neither fetch nor cache produces a profile', async () => {
|
||||
|
||||
@@ -121,6 +121,45 @@ function makeHandler(ctx: ApiActionContext): ApiHandler {
|
||||
return new ApiHandler(ctx);
|
||||
}
|
||||
|
||||
describe('extended-actions / set_self_longnick', () => {
|
||||
it('accepts an empty longNick to clear the signature', async () => {
|
||||
const setSelfLongNick = vi.fn(async () => undefined);
|
||||
const bridge = fakeBridge({ setSelfLongNick });
|
||||
|
||||
const response = await makeHandler(fakeCtx(bridge)).handle('set_self_longnick', {
|
||||
longNick: '',
|
||||
});
|
||||
|
||||
expect(response).toMatchObject({ status: 'ok', retcode: 0 });
|
||||
expect(setSelfLongNick).toHaveBeenCalledWith('');
|
||||
});
|
||||
|
||||
it('accepts an empty long_nick compatibility alias', async () => {
|
||||
const setSelfLongNick = vi.fn(async () => undefined);
|
||||
const bridge = fakeBridge({ setSelfLongNick });
|
||||
|
||||
const response = await makeHandler(fakeCtx(bridge)).handle('set_self_longnick', {
|
||||
long_nick: '',
|
||||
});
|
||||
|
||||
expect(response).toMatchObject({ status: 'ok', retcode: 0 });
|
||||
expect(setSelfLongNick).toHaveBeenCalledWith('');
|
||||
});
|
||||
|
||||
it.each([
|
||||
['missing value', {}],
|
||||
['non-string value', { longNick: 0 }],
|
||||
])('rejects %s without calling the bridge', async (_case, params) => {
|
||||
const setSelfLongNick = vi.fn(async () => undefined);
|
||||
const bridge = fakeBridge({ setSelfLongNick });
|
||||
|
||||
const response = await makeHandler(fakeCtx(bridge)).handle('set_self_longnick', params);
|
||||
|
||||
expect(response).toMatchObject({ status: 'failed', retcode: 1400 });
|
||||
expect(setSelfLongNick).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('extended-actions / group notice options', () => {
|
||||
it('coerces and forwards every supported announcement option', async () => {
|
||||
const sendNotice = vi.fn(async () => ({ ec: 0 }));
|
||||
@@ -1020,9 +1059,9 @@ describe('extended-actions / ocr_image', () => {
|
||||
// NOTE two deliberate divergences from NapCat:
|
||||
// • _get_model_show reuses NapCat's array/variants shape but ECHOES the
|
||||
// requested model instead of NapCat's hardcoded 'napcat'.
|
||||
// • get_online_clients returns the OneBot-v11/go-cqhttp { clients: [] }
|
||||
// envelope, NOT NapCat's (non-standard) bare []. A strict-NapCat client
|
||||
// would expect an array here; we intentionally follow the spec instead.
|
||||
// • get_online_clients returns the OneBot-v11/go-cqhttp { clients }
|
||||
// envelope, NOT NapCat's (non-standard) bare array. Its contents come from
|
||||
// the latest QQ online-device snapshot observed by this Bridge lifecycle.
|
||||
|
||||
describe('extended-actions / TierB compat stubs', () => {
|
||||
it('_get_model_show returns the napcat-shaped variants array, echoing the model', async () => {
|
||||
@@ -1048,10 +1087,55 @@ describe('extended-actions / TierB compat stubs', () => {
|
||||
expect(res).toMatchObject({ status: 'ok', retcode: 0, data: null });
|
||||
});
|
||||
|
||||
it('get_online_clients returns the OneBot-standard {clients:[]} envelope', async () => {
|
||||
const res = await makeHandler(fakeCtx(fakeBridge())).handle('get_online_clients', {});
|
||||
expect(res.status).toBe('ok');
|
||||
expect(res.data).toMatchObject({ clients: [] });
|
||||
it('get_online_clients returns the latest observed QQ device snapshot', async () => {
|
||||
const getOnlineClients = vi.fn(() => [{
|
||||
appId: 537242075,
|
||||
instanceId: 202,
|
||||
clientType: 1,
|
||||
platform: 3,
|
||||
deviceName: 'DESKTOP-TEST',
|
||||
deviceKind: 'computer',
|
||||
}]);
|
||||
const res = await makeHandler(fakeCtx(fakeBridge({ getOnlineClients })))
|
||||
.handle('get_online_clients', {});
|
||||
|
||||
expect(getOnlineClients).toHaveBeenCalledOnce();
|
||||
expect(res).toMatchObject({
|
||||
status: 'ok',
|
||||
retcode: 0,
|
||||
data: {
|
||||
clients: [{
|
||||
app_id: 537242075,
|
||||
device_name: 'DESKTOP-TEST',
|
||||
device_kind: '电脑',
|
||||
}],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('get_online_clients reports an unavailable snapshot instead of a false empty list', async () => {
|
||||
const res = await makeHandler(fakeCtx(fakeBridge({ getOnlineClients: () => null })))
|
||||
.handle('get_online_clients', {});
|
||||
|
||||
expect(res).toMatchObject({ status: 'failed', retcode: 100 });
|
||||
expect(res.wording).toMatch(/snapshot has not been observed/i);
|
||||
});
|
||||
|
||||
it('get_online_clients preserves an observed empty snapshot as a successful result', async () => {
|
||||
const res = await makeHandler(fakeCtx(fakeBridge({ getOnlineClients: () => [] })))
|
||||
.handle('get_online_clients', {});
|
||||
|
||||
expect(res).toMatchObject({ status: 'ok', retcode: 0, data: { clients: [] } });
|
||||
});
|
||||
|
||||
it('get_online_clients rejects a forced refresh that QQ does not expose on the packet wire', async () => {
|
||||
const getOnlineClients = vi.fn(() => []);
|
||||
const res = await makeHandler(fakeCtx(fakeBridge({ getOnlineClients })))
|
||||
.handle('get_online_clients', { no_cache: true });
|
||||
|
||||
expect(res).toMatchObject({ status: 'failed', retcode: 100 });
|
||||
expect(res.wording).toMatch(/fresh refresh is unavailable/i);
|
||||
expect(getOnlineClients).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('_mark_all_as_read passes every observed session to the batched SSO implementation', async () => {
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { ApiActionContext } from '../src/api-handler';
|
||||
import { actions } from '../src/actions/friend';
|
||||
|
||||
const getStrangerInfo = actions.find((action) => action.names[0] === 'get_stranger_info');
|
||||
if (!getStrangerInfo) throw new Error('get_stranger_info action missing');
|
||||
|
||||
describe('get_stranger_info action', () => {
|
||||
it('returns an empty long_nick when no profile provider is available', async () => {
|
||||
const response = await getStrangerInfo.toHandler({} as ApiActionContext)({ user_id: 123456 });
|
||||
|
||||
expect(response).toMatchObject({
|
||||
status: 'ok',
|
||||
retcode: 0,
|
||||
data: {
|
||||
user_id: 123456,
|
||||
nickname: '',
|
||||
sex: 'unknown',
|
||||
age: 0,
|
||||
long_nick: '',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('documents long_nick as a required string response field', () => {
|
||||
const schema = getStrangerInfo.describe().returnsSchema;
|
||||
|
||||
expect(schema).toMatchObject({
|
||||
type: 'object',
|
||||
properties: {
|
||||
long_nick: { type: 'string', description: '个性签名' },
|
||||
},
|
||||
});
|
||||
expect(schema?.required).toContain('long_nick');
|
||||
});
|
||||
});
|
||||
@@ -138,6 +138,36 @@ describe('decodeEvent0x2DC subType=16 — GroupMsgEmojiLike', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('decodes a full PushMsg whose envelope sequence carries high uint32 bits', () => {
|
||||
const content = buildReactContent({
|
||||
groupUin: BigInt(GROUP_ID),
|
||||
field13: 35,
|
||||
groupReactionData: {
|
||||
data: {
|
||||
data: {
|
||||
groupReactionTarget: { seq: 4242n },
|
||||
groupReactionDataContent: {
|
||||
code: '76', count: 1, operatorUid: 'u_operator_xxx', type: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const packet = buildPushPacket(content, {
|
||||
msgId: 123n,
|
||||
sequence: 0x1_0000_0007n,
|
||||
});
|
||||
|
||||
const [event] = parseMsgPush(packet, makeIdentity()) as GroupMsgEmojiLikeEvent[];
|
||||
expect(event).toMatchObject({
|
||||
kind: 'group_msg_emoji_like',
|
||||
groupId: GROUP_ID,
|
||||
msgSeq: 4242,
|
||||
emojiId: '76',
|
||||
});
|
||||
expect(buildContext(packet, makeIdentity())?.head.sequence).toBe(7);
|
||||
});
|
||||
|
||||
it('accepts a sign-extended negative ContentHead field 4 without losing its low 32 bits', () => {
|
||||
const packet = buildPushPacket(new Uint8Array(0), {
|
||||
msgId: encodeSignedInt32Varint(-1),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/proto-defs",
|
||||
"version": "1.12.5",
|
||||
"version": "1.12.6",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "SnowLuma QQ/Lagrange wire-protobuf type definitions. Pure TypeScript interfaces with proton's `pb<N, T>` marker types — `@snowluma/proton`'s vite plugin compiles them into zero-runtime encoder/decoder functions at the call sites in `@snowluma/core` (and any downstream consumer). Exposed as per-file subpaths (`@snowluma/proto-defs/oidb`, `@snowluma/proto-defs/message`, …) so the import-site shape mirrors the legacy `bridge/proto/proton/*` layout and avoids name collisions across files (notably `highway.ts` and `oidb-actions/media.ts` share NTV2-prefixed names).",
|
||||
|
||||
@@ -95,6 +95,30 @@ export interface FriendRequest {
|
||||
info?: pb<1, FriendRequestInfo>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Online-device snapshot carried by Event 0x210 / subType 349.
|
||||
*
|
||||
* Field numbers were recovered from QQ NT's OnRecvOnLineDev decoder. The
|
||||
* outer four fields describe the current client, while field 5 contains the
|
||||
* online-device entries exposed by getOnLineDev's kernel cache.
|
||||
*/
|
||||
export interface OnlineDeviceNotifyItem {
|
||||
appId?: pb<1, uint_32>;
|
||||
instanceId?: pb<2, uint_32>;
|
||||
/** Packed terminal value; QQ normalizes it to the low byte before use. */
|
||||
clientType?: pb<3, uint_32>;
|
||||
platform?: pb<4, uint_32>;
|
||||
deviceName?: pb<5, string>;
|
||||
}
|
||||
|
||||
export interface OnlineDeviceNotify {
|
||||
appId?: pb<1, uint_32>;
|
||||
instanceId?: pb<2, uint_32>;
|
||||
clientType?: pb<3, uint_32>;
|
||||
platform?: pb<4, uint_32>;
|
||||
devices?: pb_repeated<5, OnlineDeviceNotifyItem>;
|
||||
}
|
||||
|
||||
export interface FriendRecallTipInfo {
|
||||
tip?: pb<2, string>;
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ export interface ExtMapEntry {
|
||||
value?: pb<2, string>;
|
||||
}
|
||||
export interface ReqInfo {
|
||||
groupId?: pb<1, string>;
|
||||
albumId?: pb<2, string>;
|
||||
field3?: pb<3, int_32>;
|
||||
attachInfo?: pb<4, string>;
|
||||
field5?: pb<5, string>;
|
||||
groupId?: pb<1, string>;
|
||||
albumId?: pb<2, string>;
|
||||
field3?: pb<3, int_32>;
|
||||
field4?: pb<4, string>;
|
||||
pageInfo?: pb<5, string>;
|
||||
}
|
||||
export interface GetMediaListRequest {
|
||||
field1?: pb<1, int_32>;
|
||||
@@ -213,4 +213,4 @@ export interface DeleteMediasResponse {
|
||||
field1?: pb<1, int_32>;
|
||||
field2?: pb<2, int_32>;
|
||||
field3?: pb<3, string>;
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,8 @@ export interface OidbGroupFileListFolderResp {
|
||||
creatorUin?: pb<6, uint_32>;
|
||||
creatorName?: pb<7, string>;
|
||||
totalFileCount?: pb<8, uint_32>;
|
||||
modifierUin?: pb<9, uint_64>;
|
||||
modifierName?: pb<10, string>;
|
||||
}
|
||||
export interface OidbGroupFileListFileResp {
|
||||
fileId?: pb<1, string>;
|
||||
@@ -239,4 +241,4 @@ export interface OidbGroupFileCountViewReq {
|
||||
export interface OidbGroupFileCountViewResp {
|
||||
count?: pb<3, OidbGroupFileCountResp>;
|
||||
space?: pb<4, OidbGroupFileSpaceResp>;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/protocol",
|
||||
"version": "1.12.5",
|
||||
"version": "1.12.6",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "SnowLuma protocol — the protocol-layer between QQ wire bytes and typed events. Owns: identity service (uid↔uin cache with SQLite persistence), event bus, packet pipeline (incoming SSO packet → QQEventVariant), msg-push decoders, element-builder (MessageElement → wire elems[]), highway upload protocol (file/image/video/ptt), OIDB envelope helper, and the event/notice/request type vocabulary. Consumers (@snowluma/core, @snowluma/onebot) talk to this package through `BridgeContext` for runtime calls and the standalone classes (IdentityService, BridgeEventBus, IncomingPacketPipeline) for composition. Per-file subpath exports mirror the legacy `core/src/bridge/*` layout 1:1 so the previous `import { …} from '../bridge/<x>'` collapses to `import { … } from '@snowluma/protocol/<x>'`.",
|
||||
|
||||
@@ -486,6 +486,28 @@ export interface FriendInputStatusEvent extends QQEvent {
|
||||
statusText: string;
|
||||
}
|
||||
|
||||
export type OnlineDeviceKind = 'computer' | 'pad' | 'phone' | 'unknown';
|
||||
|
||||
/** One entry from QQ NT's online-device cache notification. */
|
||||
export interface OnlineDeviceInfo {
|
||||
appId: number;
|
||||
instanceId: number;
|
||||
clientType: number;
|
||||
platform: number;
|
||||
deviceName: string;
|
||||
deviceKind: OnlineDeviceKind;
|
||||
}
|
||||
|
||||
/**
|
||||
* Full online-device snapshot pushed through Event 0x210 / subType 349.
|
||||
* Internal-only: Bridge consumes this to maintain the query snapshot; it is
|
||||
* not forwarded as an OneBot event.
|
||||
*/
|
||||
export interface OnlineDevicesChangedEvent extends QQEvent {
|
||||
kind: 'online_devices_changed';
|
||||
devices: OnlineDeviceInfo[];
|
||||
}
|
||||
|
||||
export type QQEventVariant =
|
||||
| FriendMessage
|
||||
| GroupMessage
|
||||
@@ -510,4 +532,5 @@ export type QQEventVariant =
|
||||
| GroupCardChangeEvent
|
||||
| GroupTitleChangeEvent
|
||||
| FriendProfileLikeEvent
|
||||
| OnlineDevicesChangedEvent
|
||||
| BotOfflineEvent;
|
||||
@@ -4,6 +4,8 @@ import type {
|
||||
FriendAddEvent,
|
||||
FriendPokeEvent,
|
||||
FriendRequestEvent,
|
||||
OnlineDeviceInfo,
|
||||
OnlineDeviceKind,
|
||||
QQEventVariant,
|
||||
} from '../../events';
|
||||
import type {
|
||||
@@ -12,6 +14,7 @@ import type {
|
||||
GeneralGrayTipInfo,
|
||||
InputStatusNotify,
|
||||
NewFriend,
|
||||
OnlineDeviceNotify,
|
||||
ProfileLikeTip,
|
||||
} from '@snowluma/proto-defs/notify';
|
||||
import type { PttTransPush } from '@snowluma/proto-defs/ptt-trans';
|
||||
@@ -42,6 +45,7 @@ export const decodeEvent0x210: MsgPushDecoder = (ctx) => {
|
||||
return decodeFriendRecall(ctx);
|
||||
case Event0x210SubType.FriendPokeNotice: return decodeFriendPoke(ctx);
|
||||
case Event0x210SubType.InputStatusNotice: return decodeInputStatus(ctx);
|
||||
case Event0x210SubType.OnlineDevicesNotice: return decodeOnlineDevices(ctx);
|
||||
case Event0x210SubType.ProfileLikeNotice: return decodeProfileLike(ctx);
|
||||
// 179 + 226 both carry the NewFriend payload — see enum comment.
|
||||
case Event0x210SubType.NewFriendNotice:
|
||||
@@ -66,6 +70,63 @@ export const decodeEvent0x210: MsgPushDecoder = (ctx) => {
|
||||
return [];
|
||||
};
|
||||
|
||||
const COMPUTER_CLIENT_TYPES = new Set([1, 5, 15]);
|
||||
const PHONE_CLIENT_TYPES = new Set([2, 3, 4, 6, 7, 12]);
|
||||
const PAD_CLIENT_TYPES = new Set([8, 9, 10, 11, 13]);
|
||||
|
||||
function onlineDeviceKind(clientType: number): OnlineDeviceKind {
|
||||
if (COMPUTER_CLIENT_TYPES.has(clientType)) return 'computer';
|
||||
if (PHONE_CLIENT_TYPES.has(clientType)) return 'phone';
|
||||
if (PAD_CLIENT_TYPES.has(clientType)) return 'pad';
|
||||
unknownLog.warn('online-device snapshot contains unknown clientType=%d', clientType);
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
function onlineDeviceClientType(rawClientType: number): number {
|
||||
// QQ's OnRecvSysMsg path stores this wire field as an unsigned byte before
|
||||
// it reaches DecodeOnLineDev. Higher bits carry terminal metadata and must
|
||||
// not participate in device classification (live examples: 0x14702 -> 2,
|
||||
// 0x10107 -> 7).
|
||||
return rawClientType & 0xff;
|
||||
}
|
||||
|
||||
function decodeOnlineDevices(ctx: MsgPushContext): QQEventVariant[] {
|
||||
const notify = protobuf_decode<OnlineDeviceNotify>(ctx.content);
|
||||
if (!notify) return [];
|
||||
const devices: OnlineDeviceInfo[] = [];
|
||||
const seenDeviceKinds = new Set<OnlineDeviceKind>();
|
||||
for (const [index, item] of (notify.devices ?? []).entries()) {
|
||||
const appId = item.appId ?? 0;
|
||||
const rawClientType = item.clientType ?? 0;
|
||||
if (appId <= 0 || rawClientType <= 0) {
|
||||
throw new Error(
|
||||
`online-device entry ${index} is missing appId or clientType `
|
||||
+ `(appIdPresent=${item.appId != null} clientTypePresent=${item.clientType != null})`,
|
||||
);
|
||||
}
|
||||
const clientType = onlineDeviceClientType(rawClientType);
|
||||
const deviceKind = onlineDeviceKind(clientType);
|
||||
// QQ's DecodeOnLineDevList exposes one entry per derived devUid
|
||||
// (computer/pad/phone), retaining the first item in each category.
|
||||
if (seenDeviceKinds.has(deviceKind)) continue;
|
||||
seenDeviceKinds.add(deviceKind);
|
||||
devices.push({
|
||||
appId,
|
||||
instanceId: item.instanceId ?? 0,
|
||||
clientType,
|
||||
platform: item.platform ?? 0,
|
||||
deviceName: item.deviceName ?? '',
|
||||
deviceKind,
|
||||
});
|
||||
}
|
||||
return [{
|
||||
kind: 'online_devices_changed',
|
||||
time: ctx.head.timestamp,
|
||||
selfUin: ctx.selfUin,
|
||||
devices,
|
||||
}];
|
||||
}
|
||||
|
||||
// Voice-to-text async result push. Wire shape (live-verified):
|
||||
// { f1: uint, f2: { f1 = msgId (echoes the request), f8 = text, ... } }
|
||||
// `msgId` is the correlation key a pending fetch_ptt_text waits on; we surface
|
||||
|
||||
@@ -84,6 +84,12 @@ export enum Event0x210SubType {
|
||||
* `onInputStatusPush`.
|
||||
*/
|
||||
InputStatusNotice = 277,
|
||||
/**
|
||||
* QQ NT online-device cache update. The payload is a snapshot with repeated
|
||||
* device entries; the kernel's getOnLineDev call only replays this cache and
|
||||
* does not issue a separate network request.
|
||||
*/
|
||||
OnlineDevicesNotice = 349,
|
||||
/**
|
||||
* Group-app state push (troop shortcut bar / discussion app).
|
||||
*
|
||||
|
||||
@@ -57,6 +57,13 @@ const MESSAGE_KINDS = new Set<QQEventVariant['kind']>([
|
||||
'friend_message', 'group_message', 'temp_message',
|
||||
]);
|
||||
|
||||
// Replacement snapshots describe the complete current state. They are
|
||||
// idempotent, but not duplicate events: a later snapshot may legitimately
|
||||
// reuse the enclosing system-message identity while carrying new state.
|
||||
const STATE_SNAPSHOT_KINDS = new Set<QQEventVariant['kind']>([
|
||||
'online_devices_changed',
|
||||
]);
|
||||
|
||||
/**
|
||||
* Summarise a body that decoded to zero elements despite carrying content —
|
||||
* each element's field names, every `commonElem`'s serviceType/businessType +
|
||||
@@ -127,7 +134,12 @@ export function parseMsgPush(
|
||||
// messages have their own NT dedup path and the forward re-parse re-runs
|
||||
// this without a tracker. A push that decodes to a message kind, or to
|
||||
// nothing, is never deduped here.
|
||||
if (dedup && out.length > 0 && out.every((ev) => !MESSAGE_KINDS.has(ev.kind))) {
|
||||
if (
|
||||
dedup
|
||||
&& out.length > 0
|
||||
&& out.every((ev) => !MESSAGE_KINDS.has(ev.kind))
|
||||
&& out.every((ev) => !STATE_SNAPSHOT_KINDS.has(ev.kind))
|
||||
) {
|
||||
if (dedup.seenDuplicate(ctx.head, ctx.fromUin)) {
|
||||
log.debug('dropped duplicate system push (kinds=%s seq=%d from=%d msgType=%d msgId=%d)',
|
||||
out.map((ev) => ev.kind).join(','), ctx.head.sequence, ctx.fromUin, ctx.head.msgType, ctx.head.msgId);
|
||||
|
||||
@@ -12,7 +12,7 @@ import { describe, expect, it } from 'vitest';
|
||||
import type { PacketInfo } from '@snowluma/common/protocol-types';
|
||||
import { protobuf_encode } from '@snowluma/proton';
|
||||
import type { PushMsg, PushMsgBody } from '@snowluma/proto-defs/message';
|
||||
import type { GroupChange } from '@snowluma/proto-defs/notify';
|
||||
import type { GroupChange, OnlineDeviceNotify } from '@snowluma/proto-defs/notify';
|
||||
import type { IdentityService } from '../../src/identity-service';
|
||||
import { parseMsgPush, SysMsgDedup } from '../../src/msg-push';
|
||||
|
||||
@@ -40,6 +40,18 @@ function memberIncreasePush(opts: { groupId: number; memberUin: number; sequence
|
||||
});
|
||||
}
|
||||
|
||||
function onlineDevicesPush(deviceName: string): PacketInfo {
|
||||
return pushPacket({
|
||||
responseHead: { fromUin: 2000000001, fromUid: '' },
|
||||
contentHead: { msgType: 528, subType: 349, sequence: 800, timestamp: 1781540572, msgId: 555 },
|
||||
body: {
|
||||
msgContent: protobuf_encode<OnlineDeviceNotify>({
|
||||
devices: [{ appId: 537242075, instanceId: 202, clientType: 1, platform: 3, deviceName }],
|
||||
}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
describe('SysMsgDedup', () => {
|
||||
it('flags the second push with the same (msgType, subType, fromUin, seq, msgId)', () => {
|
||||
const d = new SysMsgDedup();
|
||||
@@ -115,4 +127,15 @@ describe('parseMsgPush — system-push dedup (#137)', () => {
|
||||
expect(parseMsgPush(chat(), identity, dedup)).toHaveLength(1);
|
||||
expect(parseMsgPush(chat(), identity, dedup)).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('does not dedup replacement state snapshots with the same server identity', () => {
|
||||
const dedup = new SysMsgDedup();
|
||||
|
||||
expect(parseMsgPush(onlineDevicesPush('DESKTOP-A'), identity, dedup)).toMatchObject([
|
||||
{ kind: 'online_devices_changed', devices: [{ deviceName: 'DESKTOP-A' }] },
|
||||
]);
|
||||
expect(parseMsgPush(onlineDevicesPush('DESKTOP-B'), identity, dedup)).toMatchObject([
|
||||
{ kind: 'online_devices_changed', devices: [{ deviceName: 'DESKTOP-B' }] },
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -8,6 +8,37 @@ import type { SendPacketResult } from '@snowluma/common/packet-sender';
|
||||
|
||||
import { ListGroupFilesPage } from '../../../src/oidb-services/group-file/list-group-files-page';
|
||||
|
||||
function wireVarint(value: bigint): number[] {
|
||||
const out: number[] = [];
|
||||
let remaining = value;
|
||||
do {
|
||||
const byte = Number(remaining & 0x7fn);
|
||||
remaining >>= 7n;
|
||||
out.push(remaining === 0n ? byte : byte | 0x80);
|
||||
} while (remaining !== 0n);
|
||||
return out;
|
||||
}
|
||||
|
||||
function varintField(fieldNumber: number, value: bigint): number[] {
|
||||
return [...wireVarint(BigInt(fieldNumber << 3)), ...wireVarint(value)];
|
||||
}
|
||||
|
||||
function bytesField(fieldNumber: number, value: Uint8Array): number[] {
|
||||
return [
|
||||
...wireVarint(BigInt((fieldNumber << 3) | 2)),
|
||||
...wireVarint(BigInt(value.length)),
|
||||
...value,
|
||||
];
|
||||
}
|
||||
|
||||
function stringField(fieldNumber: number, value: string): number[] {
|
||||
return bytesField(fieldNumber, new TextEncoder().encode(value));
|
||||
}
|
||||
|
||||
function messageField(fieldNumber: number, value: number[]): number[] {
|
||||
return bytesField(fieldNumber, Uint8Array.from(value));
|
||||
}
|
||||
|
||||
function makeDeps(body?: OidbGroupFileViewResp) {
|
||||
const responseData = body !== undefined
|
||||
? Buffer.from(protobuf_encode<OidbBase<OidbGroupFileViewResp>>({ body }))
|
||||
@@ -48,6 +79,46 @@ describe('ListGroupFilesPage namespace', () => {
|
||||
expect(out?.items).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('decodes the folder last-upload metadata from the QQ wire fields', async () => {
|
||||
// Independent wire fixture confirmed against QQ's group-file list decoder:
|
||||
// folder fields 5/9/10 are modify time, modifier UIN, and modifier name.
|
||||
const folder = [
|
||||
...stringField(1, 'd1'),
|
||||
...stringField(3, 'dir'),
|
||||
...varintField(4, 100n),
|
||||
...varintField(5, 200n),
|
||||
...varintField(6, 123n),
|
||||
...stringField(7, 'creator'),
|
||||
...varintField(8, 2n),
|
||||
...varintField(9, 5_000_000_001n),
|
||||
...stringField(10, 'uploader'),
|
||||
];
|
||||
const item = [...varintField(1, 2n), ...messageField(2, folder)];
|
||||
const list = [...varintField(4, 1n), ...messageField(5, item)];
|
||||
const body = messageField(2, list);
|
||||
const responseData = Buffer.from(messageField(4, body));
|
||||
const deps = {
|
||||
sendRawPacket: vi.fn(async (): Promise<SendPacketResult> => ({
|
||||
success: true,
|
||||
gotResponse: true,
|
||||
errorCode: 0,
|
||||
errorMessage: '',
|
||||
responseData,
|
||||
})),
|
||||
};
|
||||
|
||||
const out = await ListGroupFilesPage.invoke(deps, {
|
||||
groupId: 1, targetDirectory: '/', startIndex: 0, pageSize: 10,
|
||||
});
|
||||
const decoded = out?.items?.[0]?.folderInfo as Record<string, unknown> | undefined;
|
||||
|
||||
expect(decoded).toMatchObject({
|
||||
modifiedTime: 200,
|
||||
modifierUin: 5_000_000_001n,
|
||||
modifierName: 'uploader',
|
||||
});
|
||||
});
|
||||
|
||||
it('returns null when the server elides the list slot', async () => {
|
||||
const deps = makeDeps({});
|
||||
const out = await ListGroupFilesPage.invoke(deps, {
|
||||
|
||||
@@ -36,6 +36,13 @@ describe('SetSelfLongNick namespace', () => {
|
||||
expect(env.body?.profile).toEqual({ tag: 102, value: 'hello world' });
|
||||
});
|
||||
|
||||
it('omits the value field when clearing the signature', async () => {
|
||||
const deps = makeDeps();
|
||||
await SetSelfLongNick.invoke(deps, { longNick: '' });
|
||||
const [, bytes] = deps.sendRawPacket.mock.calls[0]!;
|
||||
expect(Buffer.from(bytes).toString('hex')).toBe('08aa221002220708914e12020866');
|
||||
});
|
||||
|
||||
it('coerces non-string longNick into a string (defensive)', async () => {
|
||||
const deps = makeDeps();
|
||||
// simulate a misbehaving caller passing a number
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/proton",
|
||||
"version": "1.12.5",
|
||||
"version": "1.12.6",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "Compile-time protobuf encoder/decoder generator for SnowLuma. TypeScript interfaces → fully-inlined, zero-runtime protobuf codec functions. Vendored from SnowLuma/protobuf-dsl (reference copy under dev/protobuf-dsl/) with edge-case fixes applied.",
|
||||
|
||||
@@ -119,9 +119,9 @@ function __readVarint64(data, offset, end) {
|
||||
}
|
||||
function __readVarint32Value(data, offset, end) {
|
||||
const [value, next] = __readVarint64(data, offset, end);
|
||||
if (value > 0xffffffffn && value < 0xffffffff80000000n) {
|
||||
throw new Error('protobuf uint32 field varint overflow');
|
||||
}
|
||||
// QQ-compatible protobuf runtimes consume a complete, well-formed uint32
|
||||
// value varint and retain its low 32 bits. Keep tags and lengths on
|
||||
// __readVarint32 so malformed framing still fails before it affects bounds.
|
||||
return [Number(BigInt.asUintN(32, value)), next];
|
||||
}
|
||||
function __skipVarint(data, offset, end) {
|
||||
|
||||
@@ -169,7 +169,7 @@ interface Int32Msg {
|
||||
])).value).toBe(-1);
|
||||
});
|
||||
|
||||
it('accepts sign-extended 10-byte values for uint_32 fields without accepting real overflow', () => {
|
||||
it('retains the low 32 bits of extended uint_32 field varints', () => {
|
||||
const { dec } = makeRoundTripFromSchema(
|
||||
`interface Uint32Msg { value: pb<1, uint_32>; }`,
|
||||
'Uint32Msg',
|
||||
@@ -183,12 +183,28 @@ interface Int32Msg {
|
||||
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01,
|
||||
])).value).toBe(0xfffffffe);
|
||||
|
||||
// 2^32 is neither uint32 nor a sign-extended negative int32, so accepting
|
||||
// ten-byte compatibility must not turn genuine overflow into truncation.
|
||||
expect(() => dec(Uint8Array.from([
|
||||
// QQ-compatible uint32 readers consume up to a full 64-bit varint and
|
||||
// retain its low 32 bits. Some push-envelope sequences use that wire
|
||||
// representation, so values with non-zero high bits must remain decodable.
|
||||
expect(dec(Uint8Array.from([
|
||||
0x08,
|
||||
0x80, 0x80, 0x80, 0x80, 0x10,
|
||||
]))).toThrow(/uint32 field varint overflow/);
|
||||
])).value).toBe(0);
|
||||
expect(dec(Uint8Array.from([
|
||||
0x08,
|
||||
0x87, 0x80, 0x80, 0x80, 0x10,
|
||||
])).value).toBe(7);
|
||||
|
||||
// Compatibility applies only to complete uint64 varints. Truncated input
|
||||
// and values wider than 64 bits must still fail loudly.
|
||||
expect(() => dec(Uint8Array.from([
|
||||
0x08,
|
||||
0x80,
|
||||
]))).toThrow(/truncated uint64 varint/);
|
||||
expect(() => dec(Uint8Array.from([
|
||||
0x08,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x02,
|
||||
]))).toThrow(/uint64 varint overflow/);
|
||||
});
|
||||
|
||||
it('rejects malformed length-delimited fields without leaving parent bounds', () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/runtime",
|
||||
"version": "1.12.5",
|
||||
"version": "1.12.6",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "index.mjs",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"name": "MotricSeven",
|
||||
"email": "motricseven@gmail.com"
|
||||
},
|
||||
"version": "1.12.5",
|
||||
"version": "1.12.6",
|
||||
"description": "TypeScript SDK for SnowLuma OneBot HTTP and WebSocket transports",
|
||||
"keywords": [
|
||||
"snowluma",
|
||||
|
||||
@@ -22,6 +22,7 @@ import type {
|
||||
GetGroupMemberListParams,
|
||||
GetGroupMessageHistoryParams,
|
||||
GetMediaParams,
|
||||
GetOnlineClientsParams,
|
||||
GetPrivateFileUrlParams,
|
||||
GroupForwardMessageParams,
|
||||
GroupIdParams,
|
||||
@@ -199,7 +200,7 @@ export interface SnowLumaActionMap {
|
||||
get_emoji_likes: { params: GetEmojiLikesParams; data: JsonObject };
|
||||
fetch_emoji_like: { params: FetchEmojiLikeParams; data: JsonObject };
|
||||
get_friends_with_category: { params: JsonObject; data: FriendCategoryResult[] };
|
||||
get_online_clients: { params: JsonObject; data: OnlineClientsInfo };
|
||||
get_online_clients: { params: GetOnlineClientsParams; data: OnlineClientsInfo };
|
||||
_get_model_show: { params: JsonObject; data: { variants: JsonArray } };
|
||||
_set_model_show: { params: JsonObject; data: EmptyData };
|
||||
'.get_word_slices': { params: JsonObject; data: JsonValue };
|
||||
|
||||
@@ -36,6 +36,8 @@ export interface NoCacheParams extends JsonObject {
|
||||
no_cache?: boolean;
|
||||
}
|
||||
|
||||
export interface GetOnlineClientsParams extends NoCacheParams {}
|
||||
|
||||
export interface GetGroupListParams extends NoCacheParams {}
|
||||
|
||||
export interface GetGroupInfoParams extends GroupIdParams {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { JsonArray, JsonObject, JsonValue } from './json';
|
||||
import type { JsonObject, JsonValue } from './json';
|
||||
|
||||
export interface SendMessageResult {
|
||||
message_id: number;
|
||||
@@ -116,8 +116,14 @@ export interface ClientKeyInfo {
|
||||
expireTime: string;
|
||||
}
|
||||
|
||||
export interface OnlineClientInfo {
|
||||
app_id: number;
|
||||
device_name: string;
|
||||
device_kind: '电脑' | 'Pad' | '手机' | '未知设备';
|
||||
}
|
||||
|
||||
export interface OnlineClientsInfo {
|
||||
clients: JsonArray;
|
||||
clients: OnlineClientInfo[];
|
||||
}
|
||||
|
||||
export interface UrlSafetyInfo {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"name": "MotricSeven",
|
||||
"email": "motricseven@gmail.com"
|
||||
},
|
||||
"version": "1.12.5",
|
||||
"version": "1.12.6",
|
||||
"description": "Shared SnowLuma UI primitives — Tailwind 4 theme tokens + shadcn-style atomic components",
|
||||
"keywords": [
|
||||
"snowluma",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/websocket",
|
||||
"version": "1.12.5",
|
||||
"version": "1.12.6",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "webui",
|
||||
"private": true,
|
||||
"version": "1.12.5",
|
||||
"version": "1.12.6",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc -b && vite build",
|
||||
"test": "vitest run",
|
||||
"typecheck": "tsc -b",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview"
|
||||
@@ -17,6 +18,7 @@
|
||||
"@radix-ui/react-label": "^2.1.3",
|
||||
"@radix-ui/react-scroll-area": "^1.2.4",
|
||||
"@radix-ui/react-separator": "^1.1.3",
|
||||
"@radix-ui/react-slider": "^1.4.3",
|
||||
"@radix-ui/react-slot": "^1.1.3",
|
||||
"@radix-ui/react-tooltip": "^1.1.9",
|
||||
"@snowluma/common": "workspace:*",
|
||||
@@ -47,6 +49,7 @@
|
||||
"tailwindcss": "^4.2.2",
|
||||
"typescript": "catalog:",
|
||||
"typescript-eslint": "^8.58.2",
|
||||
"vite": "catalog:"
|
||||
"vite": "catalog:",
|
||||
"vitest": "^4.1.4"
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,16 @@ import { ConsentPage } from '@/components/pages/consent-page';
|
||||
import { ApiProvider, createApiClient, useApi, type ApiClient } from '@/lib/api';
|
||||
import { DebugTaskProvider } from '@/contexts/DebugTaskContext';
|
||||
import { TaskBadge } from '@/components/debug/task-badge';
|
||||
import { AdaptivePointer } from '@/components/ui/adaptive-pointer';
|
||||
import { GlobalContextMenu } from '@/components/ui/global-context-menu';
|
||||
import type { AgreementsPayload } from '@/lib/api/types';
|
||||
import { appRouter } from '@/router';
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<ThemeProvider>
|
||||
<AdaptivePointer />
|
||||
<GlobalContextMenu />
|
||||
<AuthBoundary />
|
||||
</ThemeProvider>
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createContext, useContext, useId, useRef, useState, type ReactNode } from 'react';
|
||||
import { createContext, useContext, useId, useRef, useState, type ComponentProps, type ReactNode } from 'react';
|
||||
import { motion } from 'motion/react';
|
||||
import {
|
||||
Accessibility, AlertTriangle, Bell, Bug, Check, Clock, Code2, Download, ExternalLink, Github, Image as ImageIcon,
|
||||
@@ -252,6 +252,27 @@ function SettingRow({
|
||||
);
|
||||
}
|
||||
|
||||
function SliderSettingRow({
|
||||
label,
|
||||
hint,
|
||||
...sliderProps
|
||||
}: {
|
||||
label: string;
|
||||
hint?: ReactNode;
|
||||
} & Omit<ComponentProps<typeof Slider>, 'label'>) {
|
||||
const hintId = useId();
|
||||
return (
|
||||
<div className="flex flex-col gap-2.5 px-5 py-4">
|
||||
<Slider
|
||||
{...sliderProps}
|
||||
label={label}
|
||||
aria-describedby={hint ? hintId : undefined}
|
||||
/>
|
||||
{hint && <p id={hintId} className="text-[12px] leading-snug text-muted-foreground">{hint}</p>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// A settings group: a card whose header sits above a hairline-divided list of rows.
|
||||
function Group({
|
||||
title, description, icon: Icon, children,
|
||||
@@ -497,21 +518,17 @@ function AppearancePanel() {
|
||||
<SettingRow label="圆角">
|
||||
<Segmented value={a.radius} options={RADIUS_OPTIONS.map((r) => ({ value: r.value, label: r.label }))} onChange={(radius) => setAppearance({ radius })} />
|
||||
</SettingRow>
|
||||
<SettingRow label={`界面缩放(${Math.round(a.uiScale * 100)}%)`} hint="整体放大或缩小界面,适合高分屏或视力需要。" layout="stack">
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="text-meta text-muted-foreground tabular-nums">{Math.round(UI_SCALE.min * 100)}%</span>
|
||||
<Slider
|
||||
min={UI_SCALE.min}
|
||||
max={UI_SCALE.max}
|
||||
step={UI_SCALE.step}
|
||||
value={a.uiScale}
|
||||
onChange={(e) => setAppearance({ uiScale: Number(e.target.value) })}
|
||||
className="flex-1"
|
||||
aria-label="界面缩放"
|
||||
/>
|
||||
<span className="text-meta text-muted-foreground tabular-nums">{Math.round(UI_SCALE.max * 100)}%</span>
|
||||
</div>
|
||||
</SettingRow>
|
||||
<SliderSettingRow
|
||||
label="界面缩放"
|
||||
hint="整体放大或缩小界面,适合高分屏或视力需要。"
|
||||
min={UI_SCALE.min}
|
||||
max={UI_SCALE.max}
|
||||
step={UI_SCALE.step}
|
||||
value={a.uiScale}
|
||||
valueLabelFormat={(nextValue) => `${Math.round(nextValue * 100)}%`}
|
||||
onValueChange={(uiScale) => setAppearance({ uiScale })}
|
||||
aria-valuetext={`${Math.round(a.uiScale * 100)}%`}
|
||||
/>
|
||||
<SettingRow label="显示密度">
|
||||
<Segmented value={a.density} options={DENSITY_OPTIONS} onChange={(density) => setAppearance({ density })} />
|
||||
</SettingRow>
|
||||
@@ -521,7 +538,14 @@ function AppearancePanel() {
|
||||
|
||||
<TopbarPanel />
|
||||
|
||||
<Group title="无障碍与侧栏" icon={Accessibility} description="动效、对比度与侧栏默认状态。">
|
||||
<Group title="交互与无障碍" icon={Accessibility} description="光标、右键菜单、动效、对比度与侧栏行为。">
|
||||
<SettingRow label="自定义光标与右键菜单" hint="默认关闭;开启后使用主题化光标与 SnowLuma 右键菜单,关闭后立即恢复浏览器原生行为。" layout="inline">
|
||||
<ToggleSwitch
|
||||
value={a.customPointerSystem}
|
||||
onChange={(customPointerSystem) => setAppearance({ customPointerSystem })}
|
||||
ariaLabel="自定义光标与右键菜单"
|
||||
/>
|
||||
</SettingRow>
|
||||
<SettingRow label="减弱动效" hint="弱化页面切换、弹簧等装饰性动画(保留轻微淡入),对低端设备与晕动敏感者更友好。" layout="inline">
|
||||
<ToggleSwitch value={a.reduceMotion} onChange={(reduceMotion) => setAppearance({ reduceMotion })} ariaLabel="减弱动效" />
|
||||
</SettingRow>
|
||||
@@ -660,26 +684,27 @@ function BackgroundCard({
|
||||
|
||||
{a.background.hasImage && (
|
||||
<>
|
||||
<SettingRow label={`遮罩强度(${Math.round(a.background.imageOpacity * 100)}%)`} hint="越高越能盖住壁纸、提升前景可读性。" layout="stack">
|
||||
<Slider
|
||||
min={0}
|
||||
max={1}
|
||||
step={0.05}
|
||||
value={a.background.imageOpacity}
|
||||
onChange={(e) => setAppearance({ background: { imageOpacity: Number(e.target.value) } })}
|
||||
aria-label="遮罩强度"
|
||||
/>
|
||||
</SettingRow>
|
||||
<SettingRow label={`模糊(${a.background.imageBlur}px)`} layout="stack">
|
||||
<Slider
|
||||
min={0}
|
||||
max={40}
|
||||
step={1}
|
||||
value={a.background.imageBlur}
|
||||
onChange={(e) => setAppearance({ background: { imageBlur: Number(e.target.value) } })}
|
||||
aria-label="背景模糊"
|
||||
/>
|
||||
</SettingRow>
|
||||
<SliderSettingRow
|
||||
label="遮罩强度"
|
||||
hint="越高越能盖住壁纸、提升前景可读性。"
|
||||
min={0}
|
||||
max={1}
|
||||
step={0.05}
|
||||
value={a.background.imageOpacity}
|
||||
valueLabelFormat={(nextValue) => `${Math.round(nextValue * 100)}%`}
|
||||
onValueChange={(imageOpacity) => setAppearance({ background: { imageOpacity } })}
|
||||
aria-valuetext={`${Math.round(a.background.imageOpacity * 100)}%`}
|
||||
/>
|
||||
<SliderSettingRow
|
||||
label="背景模糊"
|
||||
min={0}
|
||||
max={40}
|
||||
step={1}
|
||||
value={a.background.imageBlur}
|
||||
valueLabelFormat={(nextValue) => `${nextValue}px`}
|
||||
onValueChange={(imageBlur) => setAppearance({ background: { imageBlur } })}
|
||||
aria-valuetext={`${a.background.imageBlur} 像素`}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
|
||||
@@ -0,0 +1,304 @@
|
||||
import * as React from 'react';
|
||||
import {
|
||||
motion,
|
||||
useMotionValue,
|
||||
useReducedMotion,
|
||||
useSpring,
|
||||
} from 'motion/react';
|
||||
import { useTheme } from '@/contexts/ThemeContext';
|
||||
|
||||
const POINTER_MEDIA = '(hover: hover) and (pointer: fine)';
|
||||
const MODE_PROPERTY = '--snowluma-cursor-mode';
|
||||
const RESIZE_MODE_PROPERTY = '--snowluma-cursor-resize-mode';
|
||||
const POINTER_SPRING = { stiffness: 1000, damping: 50 } as const;
|
||||
|
||||
const CURSOR_MODES = [
|
||||
'default',
|
||||
'target',
|
||||
'text',
|
||||
'grab',
|
||||
'grabbing',
|
||||
'move',
|
||||
'ew-resize',
|
||||
'ns-resize',
|
||||
'nwse-resize',
|
||||
'nesw-resize',
|
||||
'not-allowed',
|
||||
'wait',
|
||||
'crosshair',
|
||||
'copy',
|
||||
'zoom-in',
|
||||
'zoom-out',
|
||||
'help',
|
||||
'hidden',
|
||||
] as const;
|
||||
|
||||
type CursorMode = (typeof CURSOR_MODES)[number];
|
||||
|
||||
interface CursorContext {
|
||||
mode: CursorMode;
|
||||
anchor: Element | null;
|
||||
tracksPointerRegion: boolean;
|
||||
}
|
||||
|
||||
function useMediaQuery(query: string): boolean {
|
||||
const [matches, setMatches] = React.useState(false);
|
||||
|
||||
React.useEffect(() => {
|
||||
const media = window.matchMedia(query);
|
||||
const update = () => setMatches(media.matches);
|
||||
update();
|
||||
media.addEventListener('change', update);
|
||||
return () => media.removeEventListener('change', update);
|
||||
}, [query]);
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
function readCursorMode(element: Element): CursorMode {
|
||||
const value = getComputedStyle(element).getPropertyValue(MODE_PROPERTY).trim();
|
||||
return (CURSOR_MODES as readonly string[]).includes(value)
|
||||
? value as CursorMode
|
||||
: 'default';
|
||||
}
|
||||
|
||||
/**
|
||||
* CSS owns the semantic mapping. JavaScript only reads the resolved custom
|
||||
* property and finds the outermost element that still belongs to that mode.
|
||||
* This keeps nested SVGs/spans inside a button attached to the whole button.
|
||||
*/
|
||||
function resolveCursorContext(
|
||||
target: EventTarget | null,
|
||||
clientX: number,
|
||||
clientY: number,
|
||||
): CursorContext {
|
||||
if (!(target instanceof Element)) {
|
||||
return { mode: 'default', anchor: null, tracksPointerRegion: false };
|
||||
}
|
||||
|
||||
const styles = getComputedStyle(target);
|
||||
const resizeModeValue = styles.getPropertyValue(RESIZE_MODE_PROPERTY).trim();
|
||||
const resizeMode = (CURSOR_MODES as readonly string[]).includes(resizeModeValue)
|
||||
? resizeModeValue as CursorMode
|
||||
: null;
|
||||
|
||||
if (resizeMode) {
|
||||
const rect = target.getBoundingClientRect();
|
||||
const inResizeCorner = clientX >= rect.right - 18
|
||||
&& clientX <= rect.right
|
||||
&& clientY >= rect.bottom - 18
|
||||
&& clientY <= rect.bottom;
|
||||
if (inResizeCorner) {
|
||||
return { mode: resizeMode, anchor: null, tracksPointerRegion: true };
|
||||
}
|
||||
}
|
||||
|
||||
const modeValue = styles.getPropertyValue(MODE_PROPERTY).trim();
|
||||
const mode = (CURSOR_MODES as readonly string[]).includes(modeValue)
|
||||
? modeValue as CursorMode
|
||||
: 'default';
|
||||
if (mode !== 'target') {
|
||||
return { mode, anchor: null, tracksPointerRegion: Boolean(resizeMode) };
|
||||
}
|
||||
|
||||
let anchor = target;
|
||||
let parent = target.parentElement;
|
||||
while (parent && readCursorMode(parent) === mode) {
|
||||
anchor = parent;
|
||||
parent = parent.parentElement;
|
||||
}
|
||||
return { mode, anchor, tracksPointerRegion: Boolean(resizeMode) };
|
||||
}
|
||||
|
||||
function clamp(value: number, min: number, max: number): number {
|
||||
return Math.min(max, Math.max(min, value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Global adaptive cursor for fine-pointer desktop environments.
|
||||
*
|
||||
* All cursor semantics and visual variants live in index.css. The component
|
||||
* only tracks the pointer, reads the CSS-selected mode, and supplies target
|
||||
* geometry for Mikk Martin-style target morphing.
|
||||
*/
|
||||
export function AdaptivePointer() {
|
||||
const { appearance } = useTheme();
|
||||
const systemReducedMotion = useReducedMotion();
|
||||
const finePointer = useMediaQuery(POINTER_MEDIA);
|
||||
const enabled = appearance.customPointerSystem
|
||||
&& finePointer
|
||||
&& !appearance.reduceMotion
|
||||
&& !appearance.disableMotion
|
||||
&& !systemReducedMotion;
|
||||
|
||||
const cursorRef = React.useRef<HTMLDivElement>(null);
|
||||
const rawX = useMotionValue(-100);
|
||||
const rawY = useMotionValue(-100);
|
||||
const x = useSpring(rawX, POINTER_SPRING);
|
||||
const y = useSpring(rawY, POINTER_SPRING);
|
||||
|
||||
React.useEffect(() => {
|
||||
const cursor = cursorRef.current;
|
||||
if (!enabled || !cursor) return;
|
||||
|
||||
const root = document.documentElement;
|
||||
const lastPoint = { x: -100, y: -100 };
|
||||
let context: CursorContext = { mode: 'default', anchor: null, tracksPointerRegion: false };
|
||||
let lastEventTarget: EventTarget | null = null;
|
||||
let targetObserver: ResizeObserver | null = null;
|
||||
|
||||
root.dataset.cursorSystem = 'custom';
|
||||
cursor.dataset.visible = 'false';
|
||||
|
||||
const stopObservingTarget = () => {
|
||||
targetObserver?.disconnect();
|
||||
targetObserver = null;
|
||||
};
|
||||
|
||||
const setMode = (mode: CursorMode) => {
|
||||
cursor.dataset.mode = mode;
|
||||
if (mode !== 'target') {
|
||||
cursor.style.removeProperty('--cursor-target-width');
|
||||
cursor.style.removeProperty('--cursor-target-height');
|
||||
cursor.style.removeProperty('--cursor-target-radius');
|
||||
}
|
||||
};
|
||||
|
||||
const positionTarget = () => {
|
||||
const anchor = context.anchor;
|
||||
if (context.mode !== 'target' || !anchor?.isConnected) return false;
|
||||
|
||||
const rect = anchor.getBoundingClientRect();
|
||||
if (rect.width <= 0 || rect.height <= 0) return false;
|
||||
|
||||
const centerX = rect.left + rect.width / 2;
|
||||
const centerY = rect.top + rect.height / 2;
|
||||
const magneticX = clamp((lastPoint.x - centerX) / Math.max(rect.width / 2, 1), -1, 1) * 10;
|
||||
const magneticY = clamp((lastPoint.y - centerY) / Math.max(rect.height / 2, 1), -1, 1) * 10;
|
||||
const radius = getComputedStyle(anchor).borderRadius || '0.75rem';
|
||||
|
||||
cursor.style.setProperty('--cursor-target-width', `${rect.width}px`);
|
||||
cursor.style.setProperty('--cursor-target-height', `${rect.height}px`);
|
||||
cursor.style.setProperty('--cursor-target-radius', radius);
|
||||
rawX.set(centerX + magneticX);
|
||||
rawY.set(centerY + magneticY);
|
||||
return true;
|
||||
};
|
||||
|
||||
const observeTarget = (anchor: Element | null) => {
|
||||
stopObservingTarget();
|
||||
if (!anchor) return;
|
||||
targetObserver = new ResizeObserver(positionTarget);
|
||||
targetObserver.observe(anchor);
|
||||
};
|
||||
|
||||
const applyContext = (next: CursorContext) => {
|
||||
const targetChanged = next.anchor !== context.anchor;
|
||||
context = next;
|
||||
setMode(next.mode);
|
||||
if (targetChanged) observeTarget(next.mode === 'target' ? next.anchor : null);
|
||||
};
|
||||
|
||||
const positionAtPointer = () => {
|
||||
if (context.mode === 'target' && positionTarget()) return;
|
||||
rawX.set(lastPoint.x);
|
||||
rawY.set(lastPoint.y);
|
||||
};
|
||||
|
||||
const refreshContext = (target: EventTarget | null) => {
|
||||
lastEventTarget = target;
|
||||
applyContext(resolveCursorContext(target, lastPoint.x, lastPoint.y));
|
||||
positionAtPointer();
|
||||
};
|
||||
|
||||
const onPointerMove = (event: PointerEvent) => {
|
||||
if (event.pointerType === 'touch') return;
|
||||
lastPoint.x = event.clientX;
|
||||
lastPoint.y = event.clientY;
|
||||
cursor.dataset.visible = 'true';
|
||||
if (event.target !== lastEventTarget || context.tracksPointerRegion) refreshContext(event.target);
|
||||
else positionAtPointer();
|
||||
};
|
||||
|
||||
const onPointerOver = (event: PointerEvent) => {
|
||||
if (event.pointerType === 'touch') return;
|
||||
lastPoint.x = event.clientX;
|
||||
lastPoint.y = event.clientY;
|
||||
cursor.dataset.visible = 'true';
|
||||
refreshContext(event.target);
|
||||
};
|
||||
|
||||
const onPointerOut = (event: PointerEvent) => {
|
||||
if (event.relatedTarget === null) cursor.dataset.visible = 'false';
|
||||
};
|
||||
|
||||
const onPointerDown = (event: PointerEvent) => {
|
||||
if (event.pointerType === 'touch') return;
|
||||
cursor.dataset.pressed = 'true';
|
||||
refreshContext(event.target);
|
||||
if (context.mode === 'grab') setMode('grabbing');
|
||||
};
|
||||
|
||||
const restorePointerContext = () => {
|
||||
cursor.dataset.pressed = 'false';
|
||||
const target = document.elementFromPoint(lastPoint.x, lastPoint.y);
|
||||
refreshContext(target);
|
||||
};
|
||||
|
||||
const onDragStart = () => {
|
||||
cursor.dataset.pressed = 'true';
|
||||
setMode('grabbing');
|
||||
};
|
||||
|
||||
const onViewportChange = () => positionTarget();
|
||||
const hide = () => { cursor.dataset.visible = 'false'; };
|
||||
const onVisibilityChange = () => {
|
||||
if (document.visibilityState !== 'visible') hide();
|
||||
};
|
||||
|
||||
window.addEventListener('pointermove', onPointerMove, { passive: true });
|
||||
window.addEventListener('pointerover', onPointerOver, { passive: true });
|
||||
window.addEventListener('pointerout', onPointerOut, { passive: true });
|
||||
window.addEventListener('pointerdown', onPointerDown, { capture: true, passive: true });
|
||||
window.addEventListener('pointerup', restorePointerContext, { capture: true, passive: true });
|
||||
window.addEventListener('pointercancel', restorePointerContext, { capture: true, passive: true });
|
||||
window.addEventListener('dragstart', onDragStart, { capture: true });
|
||||
window.addEventListener('dragend', restorePointerContext, { capture: true });
|
||||
window.addEventListener('scroll', onViewportChange, { capture: true, passive: true });
|
||||
window.addEventListener('resize', onViewportChange, { passive: true });
|
||||
window.addEventListener('blur', hide);
|
||||
document.addEventListener('visibilitychange', onVisibilityChange);
|
||||
|
||||
return () => {
|
||||
stopObservingTarget();
|
||||
delete root.dataset.cursorSystem;
|
||||
cursor.dataset.visible = 'false';
|
||||
window.removeEventListener('pointermove', onPointerMove);
|
||||
window.removeEventListener('pointerover', onPointerOver);
|
||||
window.removeEventListener('pointerout', onPointerOut);
|
||||
window.removeEventListener('pointerdown', onPointerDown, { capture: true });
|
||||
window.removeEventListener('pointerup', restorePointerContext, { capture: true });
|
||||
window.removeEventListener('pointercancel', restorePointerContext, { capture: true });
|
||||
window.removeEventListener('dragstart', onDragStart, { capture: true });
|
||||
window.removeEventListener('dragend', restorePointerContext, { capture: true });
|
||||
window.removeEventListener('scroll', onViewportChange, { capture: true });
|
||||
window.removeEventListener('resize', onViewportChange);
|
||||
window.removeEventListener('blur', hide);
|
||||
document.removeEventListener('visibilitychange', onVisibilityChange);
|
||||
};
|
||||
}, [enabled, rawX, rawY]);
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
ref={cursorRef}
|
||||
className="adaptive-cursor"
|
||||
data-mode="default"
|
||||
data-visible="false"
|
||||
data-pressed="false"
|
||||
style={{ x, y }}
|
||||
aria-hidden="true"
|
||||
>
|
||||
<span className="adaptive-cursor-shape" />
|
||||
</motion.div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,510 @@
|
||||
import * as React from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { AnimatePresence, motion } from 'motion/react';
|
||||
import {
|
||||
ArrowLeft,
|
||||
ClipboardPaste,
|
||||
Copy,
|
||||
ExternalLink,
|
||||
Image as ImageIcon,
|
||||
Link2,
|
||||
RefreshCw,
|
||||
Scissors,
|
||||
TextSelect,
|
||||
type LucideIcon,
|
||||
} from 'lucide-react';
|
||||
import { useTheme } from '@/contexts/ThemeContext';
|
||||
|
||||
type TextEditor = HTMLInputElement | HTMLTextAreaElement | HTMLElement;
|
||||
|
||||
interface SelectionSnapshot {
|
||||
editor: TextEditor | null;
|
||||
editorStart: number | null;
|
||||
editorEnd: number | null;
|
||||
range: Range | null;
|
||||
selectedText: string;
|
||||
}
|
||||
|
||||
interface ContextSnapshot extends SelectionSnapshot {
|
||||
target: Element;
|
||||
link: HTMLAnchorElement | null;
|
||||
image: HTMLImageElement | null;
|
||||
}
|
||||
|
||||
interface MenuState {
|
||||
id: number;
|
||||
x: number;
|
||||
y: number;
|
||||
keyboard: boolean;
|
||||
snapshot: ContextSnapshot;
|
||||
}
|
||||
|
||||
interface MenuAction {
|
||||
id: string;
|
||||
label: string;
|
||||
icon: LucideIcon;
|
||||
shortcut?: string;
|
||||
disabled?: boolean;
|
||||
disabledReason?: string;
|
||||
run: () => void | Promise<void>;
|
||||
}
|
||||
|
||||
const TEXT_INPUT_SELECTOR = [
|
||||
'input:not([type])',
|
||||
'input[type="text"]',
|
||||
'input[type="search"]',
|
||||
'input[type="url"]',
|
||||
'input[type="tel"]',
|
||||
'input[type="password"]',
|
||||
'input[type="email"]',
|
||||
'textarea',
|
||||
'[contenteditable]:not([contenteditable="false"])',
|
||||
].join(',');
|
||||
|
||||
function clamp(value: number, min: number, max: number): number {
|
||||
return Math.min(max, Math.max(min, value));
|
||||
}
|
||||
|
||||
function findEditor(target: Element): TextEditor | null {
|
||||
const candidate = target.closest(TEXT_INPUT_SELECTOR);
|
||||
if (
|
||||
candidate instanceof HTMLInputElement
|
||||
|| candidate instanceof HTMLTextAreaElement
|
||||
|| (candidate instanceof HTMLElement && candidate.isContentEditable)
|
||||
) return candidate;
|
||||
return null;
|
||||
}
|
||||
|
||||
function captureSelection(target: Element): SelectionSnapshot {
|
||||
const editor = findEditor(target);
|
||||
if (editor instanceof HTMLInputElement || editor instanceof HTMLTextAreaElement) {
|
||||
const start = editor.selectionStart;
|
||||
const end = editor.selectionEnd;
|
||||
return {
|
||||
editor,
|
||||
editorStart: start,
|
||||
editorEnd: end,
|
||||
range: null,
|
||||
selectedText: start !== null && end !== null ? editor.value.slice(start, end) : '',
|
||||
};
|
||||
}
|
||||
|
||||
const selection = window.getSelection();
|
||||
const range = selection?.rangeCount ? selection.getRangeAt(0).cloneRange() : null;
|
||||
const selectionInsideEditor = editor instanceof HTMLElement
|
||||
&& range !== null
|
||||
&& editor.contains(range.commonAncestorContainer);
|
||||
|
||||
return {
|
||||
editor,
|
||||
editorStart: null,
|
||||
editorEnd: null,
|
||||
range: selectionInsideEditor ? range : null,
|
||||
selectedText: editor instanceof HTMLElement && !selectionInsideEditor
|
||||
? ''
|
||||
: selection?.toString() ?? '',
|
||||
};
|
||||
}
|
||||
|
||||
function restoreRange(snapshot: SelectionSnapshot): Range {
|
||||
if (!(snapshot.editor instanceof HTMLElement) || !snapshot.range) {
|
||||
throw new Error('无法恢复文本选区');
|
||||
}
|
||||
snapshot.editor.focus({ preventScroll: true });
|
||||
const range = snapshot.range.cloneRange();
|
||||
const selection = window.getSelection();
|
||||
if (!selection) throw new Error('浏览器未提供文本选区');
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
return range;
|
||||
}
|
||||
|
||||
function emitInput(target: TextEditor, inputType: string, data: string | null) {
|
||||
target.dispatchEvent(new InputEvent('input', {
|
||||
bubbles: true,
|
||||
composed: true,
|
||||
inputType,
|
||||
data,
|
||||
}));
|
||||
}
|
||||
|
||||
function replaceSelection(snapshot: SelectionSnapshot, value: string, inputType: string) {
|
||||
const { editor } = snapshot;
|
||||
if (editor instanceof HTMLInputElement || editor instanceof HTMLTextAreaElement) {
|
||||
if (snapshot.editorStart === null || snapshot.editorEnd === null) {
|
||||
throw new Error('当前输入框不支持选区替换');
|
||||
}
|
||||
editor.focus({ preventScroll: true });
|
||||
editor.setRangeText(value, snapshot.editorStart, snapshot.editorEnd, 'end');
|
||||
emitInput(editor, inputType, value || null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(editor instanceof HTMLElement)) throw new Error('缺少可编辑文本目标');
|
||||
const range = restoreRange(snapshot);
|
||||
range.deleteContents();
|
||||
if (value) {
|
||||
const text = document.createTextNode(value);
|
||||
range.insertNode(text);
|
||||
range.setStartAfter(text);
|
||||
}
|
||||
range.collapse(true);
|
||||
const selection = window.getSelection();
|
||||
selection?.removeAllRanges();
|
||||
selection?.addRange(range);
|
||||
emitInput(editor, inputType, value || null);
|
||||
}
|
||||
|
||||
function selectEditorContents(editor: TextEditor) {
|
||||
editor.focus({ preventScroll: true });
|
||||
if (editor instanceof HTMLInputElement || editor instanceof HTMLTextAreaElement) {
|
||||
editor.select();
|
||||
return;
|
||||
}
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(editor);
|
||||
const selection = window.getSelection();
|
||||
if (!selection) throw new Error('浏览器未提供文本选区');
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
}
|
||||
|
||||
function legacyCopy(value: string): boolean {
|
||||
const active = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
||||
const selection = window.getSelection();
|
||||
const ranges = selection
|
||||
? Array.from({ length: selection.rangeCount }, (_, index) => selection.getRangeAt(index).cloneRange())
|
||||
: [];
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.value = value;
|
||||
textarea.setAttribute('readonly', '');
|
||||
textarea.style.position = 'fixed';
|
||||
textarea.style.left = '-9999px';
|
||||
textarea.style.opacity = '0';
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
|
||||
try {
|
||||
const exec = (document as unknown as { execCommand(command: string): boolean }).execCommand;
|
||||
return exec.call(document, 'copy');
|
||||
} finally {
|
||||
textarea.remove();
|
||||
active?.focus({ preventScroll: true });
|
||||
if (selection) {
|
||||
selection.removeAllRanges();
|
||||
ranges.forEach((range) => selection.addRange(range));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function writeClipboard(value: string) {
|
||||
let clipboardError: unknown;
|
||||
try {
|
||||
if (!navigator.clipboard?.writeText) throw new Error('Clipboard API unavailable');
|
||||
await navigator.clipboard.writeText(value);
|
||||
return;
|
||||
} catch (error) {
|
||||
clipboardError = error;
|
||||
}
|
||||
|
||||
if (legacyCopy(value)) return;
|
||||
throw clipboardError instanceof Error
|
||||
? clipboardError
|
||||
: new Error('浏览器拒绝写入剪贴板');
|
||||
}
|
||||
|
||||
async function readClipboard(): Promise<string> {
|
||||
if (!navigator.clipboard?.readText) {
|
||||
throw new Error('当前页面没有读取剪贴板的权限');
|
||||
}
|
||||
return navigator.clipboard.readText();
|
||||
}
|
||||
|
||||
function openInNewTab(url: string) {
|
||||
window.open(url, '_blank', 'noopener,noreferrer');
|
||||
}
|
||||
|
||||
function platformShortcut(key: string): string {
|
||||
return /Mac|iPhone|iPad|iPod/i.test(navigator.platform) ? `⌘${key}` : `Ctrl+${key}`;
|
||||
}
|
||||
|
||||
function buildActionGroups(snapshot: ContextSnapshot): MenuAction[][] {
|
||||
const groups: MenuAction[][] = [];
|
||||
const contextual: MenuAction[] = [];
|
||||
|
||||
if (snapshot.link) {
|
||||
const href = snapshot.link.href;
|
||||
contextual.push(
|
||||
{ id: 'open-link', label: '在新标签页打开链接', icon: ExternalLink, run: () => openInNewTab(href) },
|
||||
{ id: 'copy-link', label: '复制链接地址', icon: Link2, run: () => writeClipboard(href) },
|
||||
);
|
||||
}
|
||||
|
||||
if (snapshot.image) {
|
||||
const src = snapshot.image.currentSrc || snapshot.image.src;
|
||||
contextual.push(
|
||||
{ id: 'open-image', label: '在新标签页打开图片', icon: ImageIcon, run: () => openInNewTab(src) },
|
||||
{ id: 'copy-image-url', label: '复制图片地址', icon: Copy, run: () => writeClipboard(src) },
|
||||
);
|
||||
}
|
||||
if (contextual.length) groups.push(contextual);
|
||||
|
||||
if (snapshot.editor) {
|
||||
const hasSelection = snapshot.selectedText.length > 0;
|
||||
groups.push([
|
||||
{
|
||||
id: 'cut',
|
||||
label: '剪切',
|
||||
icon: Scissors,
|
||||
shortcut: platformShortcut('X'),
|
||||
disabled: !hasSelection,
|
||||
run: async () => {
|
||||
await writeClipboard(snapshot.selectedText);
|
||||
replaceSelection(snapshot, '', 'deleteByCut');
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'copy',
|
||||
label: '复制',
|
||||
icon: Copy,
|
||||
shortcut: platformShortcut('C'),
|
||||
disabled: !hasSelection,
|
||||
run: () => writeClipboard(snapshot.selectedText),
|
||||
},
|
||||
{
|
||||
id: 'paste',
|
||||
label: '粘贴',
|
||||
icon: ClipboardPaste,
|
||||
shortcut: platformShortcut('V'),
|
||||
disabled: !navigator.clipboard?.readText,
|
||||
disabledReason: '当前页面没有读取剪贴板的权限',
|
||||
run: async () => replaceSelection(snapshot, await readClipboard(), 'insertFromPaste'),
|
||||
},
|
||||
{
|
||||
id: 'select-all',
|
||||
label: '全选',
|
||||
icon: TextSelect,
|
||||
shortcut: platformShortcut('A'),
|
||||
run: () => selectEditorContents(snapshot.editor!),
|
||||
},
|
||||
]);
|
||||
} else if (snapshot.selectedText) {
|
||||
groups.push([{
|
||||
id: 'copy-selection',
|
||||
label: '复制选中文本',
|
||||
icon: Copy,
|
||||
shortcut: platformShortcut('C'),
|
||||
run: () => writeClipboard(snapshot.selectedText),
|
||||
}]);
|
||||
}
|
||||
|
||||
groups.push([
|
||||
{
|
||||
id: 'back',
|
||||
label: '返回上一页',
|
||||
icon: ArrowLeft,
|
||||
disabled: window.history.length <= 1,
|
||||
run: () => window.history.back(),
|
||||
},
|
||||
{ id: 'reload', label: '刷新页面', icon: RefreshCw, shortcut: platformShortcut('R'), run: () => window.location.reload() },
|
||||
{ id: 'copy-page-url', label: '复制当前页面地址', icon: Link2, run: () => writeClipboard(window.location.href) },
|
||||
]);
|
||||
|
||||
return groups;
|
||||
}
|
||||
|
||||
export function GlobalContextMenu() {
|
||||
const { appearance } = useTheme();
|
||||
const enabled = appearance.customPointerSystem;
|
||||
const [menu, setMenu] = React.useState<MenuState | null>(null);
|
||||
const [position, setPosition] = React.useState({ x: -9999, y: -9999, ready: false });
|
||||
const [busyAction, setBusyAction] = React.useState<string | null>(null);
|
||||
const [error, setError] = React.useState<string | null>(null);
|
||||
const menuRef = React.useRef<HTMLDivElement>(null);
|
||||
const sequence = React.useRef(0);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!enabled) return;
|
||||
|
||||
const onContextMenu = (event: MouseEvent) => {
|
||||
if (event.shiftKey || !window.matchMedia('(hover: hover) and (pointer: fine)').matches) return;
|
||||
if (!(event.target instanceof Element)) return;
|
||||
if (event.target.closest('[data-context-menu="native"]')) return;
|
||||
if (event.target.closest('.global-context-menu')) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
const target = event.target;
|
||||
const keyboard = event.clientX === 0 && event.clientY === 0;
|
||||
const rect = target.getBoundingClientRect();
|
||||
const x = keyboard ? rect.left + Math.min(rect.width / 2, 24) : event.clientX;
|
||||
const y = keyboard ? rect.top + Math.min(rect.height, 24) : event.clientY;
|
||||
|
||||
setError(null);
|
||||
setBusyAction(null);
|
||||
setPosition({ x, y, ready: false });
|
||||
setMenu({
|
||||
id: ++sequence.current,
|
||||
x,
|
||||
y,
|
||||
keyboard,
|
||||
snapshot: {
|
||||
target,
|
||||
link: target.closest('a[href]'),
|
||||
image: target.closest('img'),
|
||||
...captureSelection(target),
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
window.addEventListener('contextmenu', onContextMenu, { capture: true });
|
||||
return () => window.removeEventListener('contextmenu', onContextMenu, { capture: true });
|
||||
}, [enabled]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (enabled) return;
|
||||
setMenu(null);
|
||||
setError(null);
|
||||
setBusyAction(null);
|
||||
}, [enabled]);
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
const node = menuRef.current;
|
||||
if (!menu || !node) return;
|
||||
const rect = node.getBoundingClientRect();
|
||||
const edge = 8;
|
||||
setPosition({
|
||||
x: clamp(menu.x, edge, Math.max(edge, window.innerWidth - rect.width - edge)),
|
||||
y: clamp(menu.y, edge, Math.max(edge, window.innerHeight - rect.height - edge)),
|
||||
ready: true,
|
||||
});
|
||||
}, [error, menu]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!menu) return;
|
||||
const close = () => setMenu(null);
|
||||
const onPointerDown = (event: PointerEvent) => {
|
||||
if (menuRef.current?.contains(event.target as Node)) return;
|
||||
close();
|
||||
};
|
||||
const onKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape') {
|
||||
event.preventDefault();
|
||||
close();
|
||||
return;
|
||||
}
|
||||
if (!['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)) return;
|
||||
const items = Array.from(menuRef.current?.querySelectorAll<HTMLButtonElement>('[role="menuitem"]:not(:disabled)') ?? []);
|
||||
if (!items.length) return;
|
||||
event.preventDefault();
|
||||
const current = items.indexOf(document.activeElement as HTMLButtonElement);
|
||||
let next = 0;
|
||||
if (event.key === 'End') next = items.length - 1;
|
||||
else if (event.key === 'ArrowUp') next = current <= 0 ? items.length - 1 : current - 1;
|
||||
else if (event.key === 'ArrowDown') next = current < 0 || current === items.length - 1 ? 0 : current + 1;
|
||||
items[next]?.focus({ preventScroll: true });
|
||||
};
|
||||
|
||||
window.addEventListener('pointerdown', onPointerDown, { capture: true });
|
||||
window.addEventListener('keydown', onKeyDown, { capture: true });
|
||||
window.addEventListener('scroll', close, { capture: true, passive: true });
|
||||
window.addEventListener('resize', close, { passive: true });
|
||||
window.addEventListener('blur', close);
|
||||
return () => {
|
||||
window.removeEventListener('pointerdown', onPointerDown, { capture: true });
|
||||
window.removeEventListener('keydown', onKeyDown, { capture: true });
|
||||
window.removeEventListener('scroll', close, { capture: true });
|
||||
window.removeEventListener('resize', close);
|
||||
window.removeEventListener('blur', close);
|
||||
};
|
||||
}, [menu]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (menu?.keyboard && position.ready) {
|
||||
menuRef.current?.querySelector<HTMLButtonElement>('[role="menuitem"]:not(:disabled)')?.focus({ preventScroll: true });
|
||||
}
|
||||
}, [menu, position.ready]);
|
||||
|
||||
const groups = enabled && menu ? buildActionGroups(menu.snapshot) : [];
|
||||
|
||||
const runAction = async (action: MenuAction) => {
|
||||
if (action.disabled || busyAction) return;
|
||||
setBusyAction(action.id);
|
||||
setError(null);
|
||||
try {
|
||||
await action.run();
|
||||
if (menu?.keyboard && menu.snapshot.target instanceof HTMLElement) {
|
||||
menu.snapshot.target.focus({ preventScroll: true });
|
||||
}
|
||||
setMenu(null);
|
||||
} catch (cause) {
|
||||
const message = cause instanceof Error ? cause.message : String(cause);
|
||||
console.error(`[context-menu] ${action.id} failed`, cause);
|
||||
setError(message || '操作失败');
|
||||
} finally {
|
||||
setBusyAction(null);
|
||||
}
|
||||
};
|
||||
|
||||
return createPortal(
|
||||
<AnimatePresence initial={false}>
|
||||
{enabled && menu && (
|
||||
<motion.div
|
||||
key={menu.id}
|
||||
ref={menuRef}
|
||||
role="menu"
|
||||
aria-label="右键菜单"
|
||||
className="global-context-menu"
|
||||
style={{
|
||||
left: position.x,
|
||||
top: position.y,
|
||||
visibility: position.ready ? 'visible' : 'hidden',
|
||||
transformOrigin: `${menu.x > window.innerWidth / 2 ? 'right' : 'left'} ${menu.y > window.innerHeight / 2 ? 'bottom' : 'top'}`,
|
||||
}}
|
||||
initial={{ opacity: 0, scale: 0.96, y: -4 }}
|
||||
animate={{ opacity: 1, scale: 1, y: 0 }}
|
||||
exit={{ opacity: 0, scale: 0.98, y: -2, transition: { duration: 0.12, ease: 'easeIn' } }}
|
||||
transition={{ type: 'spring', duration: 0.3, bounce: 0 }}
|
||||
>
|
||||
{groups.map((group, groupIndex) => (
|
||||
<React.Fragment key={group.map((action) => action.id).join(':')}>
|
||||
{groupIndex > 0 && <div className="global-context-menu-separator" role="separator" />}
|
||||
<div className="global-context-menu-group">
|
||||
{group.map((action) => {
|
||||
const Icon = action.icon;
|
||||
const busy = busyAction === action.id;
|
||||
return (
|
||||
<button
|
||||
key={action.id}
|
||||
type="button"
|
||||
role="menuitem"
|
||||
tabIndex={-1}
|
||||
disabled={action.disabled || Boolean(busyAction)}
|
||||
aria-busy={busy || undefined}
|
||||
data-cursor={busy ? 'wait' : undefined}
|
||||
title={action.disabled ? action.disabledReason : undefined}
|
||||
className="global-context-menu-item"
|
||||
onClick={() => void runAction(action)}
|
||||
>
|
||||
<Icon className="global-context-menu-icon" aria-hidden="true" />
|
||||
<span className="global-context-menu-label">{action.label}</span>
|
||||
{action.shortcut && <kbd className="global-context-menu-shortcut">{action.shortcut}</kbd>}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</React.Fragment>
|
||||
))}
|
||||
{error && (
|
||||
<div className="global-context-menu-error" role="alert">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>,
|
||||
document.body,
|
||||
);
|
||||
}
|
||||
@@ -38,7 +38,7 @@ const ScrollBar = React.forwardRef<
|
||||
ref={ref}
|
||||
orientation={orientation}
|
||||
className={cn(
|
||||
'flex touch-none select-none p-0.5 transition-colors',
|
||||
'flex touch-none select-none p-0.5 transition-colors cursor-grab active:cursor-grabbing',
|
||||
orientation === 'vertical' && 'h-full w-2 border-l border-l-transparent',
|
||||
orientation === 'horizontal' && 'h-2 w-full flex-col border-t border-t-transparent',
|
||||
className
|
||||
|
||||
@@ -1,28 +1,365 @@
|
||||
import * as React from 'react';
|
||||
import * as SliderPrimitive from '@radix-ui/react-slider';
|
||||
import {
|
||||
motion,
|
||||
useMotionTemplate,
|
||||
useMotionValue,
|
||||
useMotionValueEvent,
|
||||
useReducedMotion,
|
||||
useSpring,
|
||||
useTransform,
|
||||
type MotionValue,
|
||||
} from 'motion/react';
|
||||
import { useTheme } from '@/contexts/ThemeContext';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'value'> {
|
||||
type RootProps = React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>;
|
||||
type ObscuredRanges = [[number, number], [number, number]];
|
||||
|
||||
export interface SliderProps extends Omit<
|
||||
RootProps,
|
||||
'children' | 'defaultValue' | 'min' | 'max' | 'orientation' | 'step' | 'value' | 'onValueChange'
|
||||
> {
|
||||
value: number;
|
||||
min: number;
|
||||
max: number;
|
||||
step?: number;
|
||||
label: string;
|
||||
valueLabelFormat?: (value: number) => React.ReactNode;
|
||||
onValueChange?: (value: number) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Themed range input. Styling lives in index.css (`.slider`); here we just
|
||||
* compute the filled-track percentage and expose it as `--slider-pct` for the
|
||||
* WebKit track gradient (Firefox fills natively via ::-moz-range-progress).
|
||||
*/
|
||||
export function Slider({ value, min, max, className, style, ...props }: SliderProps) {
|
||||
const pct = max > min ? Math.min(100, Math.max(0, ((value - min) / (max - min)) * 100)) : 0;
|
||||
const POSITION_SPRING = { type: 'spring', stiffness: 2000, damping: 40, mass: 0.01 } as const;
|
||||
const STRETCH_SPRING = { stiffness: 2000, damping: 40, mass: 1 } as const;
|
||||
const VISIBILITY_SPRING = { stiffness: 1000, damping: 20, mass: 0.01 } as const;
|
||||
const HANDLE_WIDTH = 24;
|
||||
|
||||
function clamp(value: number, min: number, max: number): number {
|
||||
return Math.min(max, Math.max(min, value));
|
||||
}
|
||||
|
||||
function mapRange(
|
||||
value: number,
|
||||
inputMin: number,
|
||||
inputMax: number,
|
||||
outputMin: number,
|
||||
outputMax: number,
|
||||
shouldClamp = true,
|
||||
): number {
|
||||
if (inputMin === inputMax) return outputMin;
|
||||
const progress = (value - inputMin) / (inputMax - inputMin);
|
||||
const mapped = outputMin + (outputMax - outputMin) * progress;
|
||||
return shouldClamp ? clamp(mapped, Math.min(outputMin, outputMax), Math.max(outputMin, outputMax)) : mapped;
|
||||
}
|
||||
|
||||
function snapValue(value: number, min: number, max: number, step: number): number {
|
||||
const snapped = min + Math.round((value - min) / step) * step;
|
||||
return clamp(Number(snapped.toFixed(12)), min, max);
|
||||
}
|
||||
|
||||
function circleEase(value: number): number {
|
||||
return Math.sqrt(Math.max(0, 1 - (value - 1) ** 2));
|
||||
}
|
||||
|
||||
function SliderTick({
|
||||
springX,
|
||||
percentage,
|
||||
position,
|
||||
last,
|
||||
obscuredRanges,
|
||||
}: {
|
||||
springX: MotionValue<number>;
|
||||
percentage: number;
|
||||
position: string;
|
||||
last: boolean;
|
||||
obscuredRanges: React.RefObject<ObscuredRanges>;
|
||||
}) {
|
||||
const opacity = useTransform(springX, (current) => {
|
||||
const coveredByText = obscuredRanges.current.some(([start, end]) => start <= percentage && end >= percentage);
|
||||
if (last || coveredByText) return 0;
|
||||
return Number(current + 8 <= percentage || current - 8 > percentage);
|
||||
});
|
||||
const transition = useTransform(springX, (current) => (
|
||||
current + 8 <= percentage || current - 8 > percentage ? 'opacity 0.1s' : 'opacity 0s'
|
||||
));
|
||||
|
||||
return (
|
||||
<input
|
||||
type="range"
|
||||
value={value}
|
||||
min={min}
|
||||
max={max}
|
||||
className={cn('slider', className)}
|
||||
style={{ '--slider-pct': `${pct}%`, ...style } as React.CSSProperties}
|
||||
{...props}
|
||||
<motion.span
|
||||
className="slider-tick"
|
||||
style={{ left: position, opacity, transition }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function SliderTicks({
|
||||
springX,
|
||||
min,
|
||||
max,
|
||||
step,
|
||||
obscuredRanges,
|
||||
}: {
|
||||
springX: MotionValue<number>;
|
||||
min: number;
|
||||
max: number;
|
||||
step: number;
|
||||
obscuredRanges: React.RefObject<ObscuredRanges>;
|
||||
}) {
|
||||
const rawIntervals = (max - min) / step;
|
||||
const intervals = Math.round(rawIntervals);
|
||||
if (Math.abs(rawIntervals - intervals) > 1e-6 || intervals <= 1 || intervals > 16) return null;
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
className="slider-ticks"
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
transition={{ duration: 0.3 }}
|
||||
>
|
||||
{Array.from({ length: intervals }, (_, index) => {
|
||||
const ratio = (index + 1) / intervals;
|
||||
const percentage = ratio * 100;
|
||||
const compensation = percentage < 50
|
||||
? ratio * HANDLE_WIDTH - HANDLE_WIDTH / 2
|
||||
: -ratio * HANDLE_WIDTH + HANDLE_WIDTH / 2;
|
||||
|
||||
return (
|
||||
<SliderTick
|
||||
key={index}
|
||||
springX={springX}
|
||||
percentage={percentage}
|
||||
position={`calc(${percentage}% + ${compensation}px)`}
|
||||
last={index === intervals - 1}
|
||||
obscuredRanges={obscuredRanges}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</motion.div>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* SnowLuma's themed integration of Mikk Martin's slider interaction model.
|
||||
* The Radix thumb owns keyboard, pointer and assistive-technology semantics;
|
||||
* the remaining layers reproduce the original visual and spring behavior.
|
||||
*
|
||||
* Reference: https://mikkmartin.co/repo/slider
|
||||
*/
|
||||
export function Slider({
|
||||
value,
|
||||
min,
|
||||
max,
|
||||
step = 1,
|
||||
label,
|
||||
valueLabelFormat,
|
||||
onValueChange,
|
||||
className,
|
||||
style,
|
||||
disabled,
|
||||
onPointerDown,
|
||||
onPointerMove,
|
||||
onPointerUp,
|
||||
onPointerCancel,
|
||||
'aria-label': ariaLabel,
|
||||
'aria-valuetext': ariaValueText,
|
||||
'aria-describedby': ariaDescribedBy,
|
||||
...props
|
||||
}: SliderProps) {
|
||||
const { appearance } = useTheme();
|
||||
const systemReducedMotion = useReducedMotion();
|
||||
const reduceMotion = Boolean(appearance.reduceMotion || appearance.disableMotion || systemReducedMotion);
|
||||
const initialValue = snapValue(value, min, max, step);
|
||||
const [currentValue, setCurrentValue] = React.useState(initialValue);
|
||||
const rootRef = React.useRef<HTMLDivElement>(null);
|
||||
const labelRef = React.useRef<HTMLSpanElement>(null);
|
||||
const valueLabelRef = React.useRef<HTMLSpanElement>(null);
|
||||
const draggingRef = React.useRef(false);
|
||||
const obscuredRanges = React.useRef<ObscuredRanges>([[0, 0], [0, 0]]);
|
||||
|
||||
const valueMotion = useMotionValue(currentValue);
|
||||
const pointerProgress = useMotionValue(0);
|
||||
const pointerPercent = useTransform(pointerProgress, [0, 1], [0, 100], { clamp: false });
|
||||
const valuePercent = useTransform(valueMotion, [min, max], [0, 100], { clamp: false });
|
||||
const blendedPercent = useTransform(pointerPercent, (pointer) => (
|
||||
draggingRef.current ? (pointer + 2 * valuePercent.get()) / 3 : valuePercent.get()
|
||||
));
|
||||
const springX = useSpring(blendedPercent, POSITION_SPRING);
|
||||
|
||||
const stretch = useSpring(1, STRETCH_SPRING);
|
||||
const inverseStretch = useTransform(stretch, (scale) => 2 - scale);
|
||||
const transformOrigin = useMotionValue<'left' | 'right'>('left');
|
||||
const shiftX = useTransform(stretch, (scale) => (
|
||||
(1 - scale) * (transformOrigin.get() === 'right' ? 100 : -100)
|
||||
));
|
||||
|
||||
const handleCompensation = useTransform(springX, (percentage) => (
|
||||
percentage <= 50
|
||||
? HANDLE_WIDTH * percentage / 100
|
||||
: HANDLE_WIDTH * (100 - percentage) / 100
|
||||
));
|
||||
const fillWidth = useMotionTemplate`calc(${springX}% + ${handleCompensation}px)`;
|
||||
|
||||
const handleVisibility = useSpring(1, VISIBILITY_SPRING);
|
||||
const handleHeight = useTransform(handleVisibility, [0, 1], [32, 24]);
|
||||
|
||||
const formattedValue = valueLabelFormat ? valueLabelFormat(currentValue) : currentValue;
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
const snapped = snapValue(value, min, max, step);
|
||||
valueMotion.set(snapped);
|
||||
if (snapped !== currentValue) setCurrentValue(snapped);
|
||||
const nextPercentage = mapRange(snapped, min, max, 0, 100);
|
||||
if (reduceMotion) springX.jump(nextPercentage);
|
||||
else blendedPercent.set(nextPercentage);
|
||||
}, [blendedPercent, currentValue, max, min, reduceMotion, springX, step, value, valueMotion]);
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
const root = rootRef.current;
|
||||
const labelNode = labelRef.current;
|
||||
const valueNode = valueLabelRef.current;
|
||||
if (!root || !labelNode || !valueNode) return;
|
||||
|
||||
const update = () => {
|
||||
const width = root.offsetWidth;
|
||||
if (width <= 0) return;
|
||||
const toPercentage = (pixels: number) => pixels / width * 100;
|
||||
obscuredRanges.current = [
|
||||
[toPercentage(labelNode.offsetLeft), toPercentage(labelNode.offsetLeft + labelNode.offsetWidth)],
|
||||
[toPercentage(valueNode.offsetLeft), toPercentage(valueNode.offsetLeft + valueNode.offsetWidth)],
|
||||
];
|
||||
};
|
||||
|
||||
update();
|
||||
const observer = new ResizeObserver(update);
|
||||
observer.observe(root);
|
||||
observer.observe(labelNode);
|
||||
observer.observe(valueNode);
|
||||
return () => observer.disconnect();
|
||||
}, [formattedValue, label]);
|
||||
|
||||
useMotionValueEvent(blendedPercent, 'change', (latest) => {
|
||||
if (reduceMotion) springX.jump(latest);
|
||||
});
|
||||
|
||||
useMotionValueEvent(springX, 'change', (percentage) => {
|
||||
const root = rootRef.current;
|
||||
if (!root) return;
|
||||
const toPercentage = (pixels: number) => pixels / root.offsetWidth * 100;
|
||||
const handleHalf = toPercentage(12);
|
||||
const padding = toPercentage(4);
|
||||
const [labelRange, valueRange] = obscuredRanges.current;
|
||||
const hidden = (
|
||||
(percentage > labelRange[0] - padding + handleHalf && percentage < labelRange[1] + handleHalf + padding)
|
||||
|| (percentage > valueRange[0] - padding + handleHalf && percentage < 99)
|
||||
);
|
||||
if (reduceMotion) handleVisibility.jump(hidden ? 0 : 1);
|
||||
else handleVisibility.set(hidden ? 0 : 1);
|
||||
});
|
||||
|
||||
const release = React.useCallback(() => {
|
||||
pointerProgress.set(valuePercent.get() / 100);
|
||||
draggingRef.current = false;
|
||||
if (reduceMotion) stretch.jump(1);
|
||||
else stretch.set(1);
|
||||
}, [pointerProgress, reduceMotion, stretch, valuePercent]);
|
||||
|
||||
React.useEffect(() => {
|
||||
window.addEventListener('pointerup', release);
|
||||
window.addEventListener('pointercancel', release);
|
||||
return () => {
|
||||
window.removeEventListener('pointerup', release);
|
||||
window.removeEventListener('pointercancel', release);
|
||||
};
|
||||
}, [release]);
|
||||
|
||||
const updatePointer = React.useCallback((clientX: number) => {
|
||||
const root = rootRef.current;
|
||||
if (!root) return;
|
||||
const { left, width } = root.getBoundingClientRect();
|
||||
if (width <= 0) return;
|
||||
|
||||
const normalized = (clientX - left) / width;
|
||||
pointerProgress.set(clamp(normalized, 0, 1));
|
||||
|
||||
if (reduceMotion) return;
|
||||
if (normalized < 0) {
|
||||
transformOrigin.set('right');
|
||||
const eased = circleEase(mapRange(normalized, 0, -3, 0, 1));
|
||||
stretch.jump(mapRange(eased, 0, 1, 1, 1.02));
|
||||
} else if (normalized > 1) {
|
||||
transformOrigin.set('left');
|
||||
const eased = circleEase(mapRange(normalized, 1, 3, 0, 1));
|
||||
stretch.jump(mapRange(eased, 0, 1, 1, 1.02));
|
||||
}
|
||||
}, [pointerProgress, reduceMotion, stretch, transformOrigin]);
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
ref={rootRef}
|
||||
className={cn('slider-root group/slider', className)}
|
||||
data-disabled={disabled ? '' : undefined}
|
||||
style={{ ...style, x: shiftX, scaleX: stretch, scaleY: inverseStretch, transformOrigin }}
|
||||
onPointerDown={(event) => {
|
||||
draggingRef.current = true;
|
||||
updatePointer(event.clientX);
|
||||
onPointerDown?.(event);
|
||||
}}
|
||||
onPointerMove={(event) => {
|
||||
if (draggingRef.current) updatePointer(event.clientX);
|
||||
onPointerMove?.(event);
|
||||
}}
|
||||
onPointerUp={(event) => {
|
||||
release();
|
||||
onPointerUp?.(event);
|
||||
}}
|
||||
onPointerCancel={(event) => {
|
||||
release();
|
||||
onPointerCancel?.(event);
|
||||
}}
|
||||
>
|
||||
<SliderPrimitive.Root
|
||||
{...props}
|
||||
className="slider-radix-root"
|
||||
min={min}
|
||||
max={max}
|
||||
step={step}
|
||||
value={[currentValue]}
|
||||
disabled={disabled}
|
||||
onValueChange={([nextValue]) => {
|
||||
setCurrentValue(nextValue);
|
||||
valueMotion.set(nextValue);
|
||||
blendedPercent.jump(mapRange(nextValue, min, max, 0, 100));
|
||||
onValueChange?.(nextValue);
|
||||
}}
|
||||
>
|
||||
<SliderPrimitive.Thumb
|
||||
className="slider-native-thumb"
|
||||
aria-label={ariaLabel ?? label}
|
||||
aria-valuetext={ariaValueText}
|
||||
aria-describedby={ariaDescribedBy}
|
||||
/>
|
||||
</SliderPrimitive.Root>
|
||||
|
||||
<motion.div className="slider-active-range" style={{ width: fillWidth }} aria-hidden>
|
||||
<span className="slider-handle-slot">
|
||||
<motion.span
|
||||
className="slider-handle-line"
|
||||
style={{ opacity: handleVisibility, height: handleHeight }}
|
||||
/>
|
||||
</span>
|
||||
</motion.div>
|
||||
|
||||
<SliderTicks
|
||||
springX={springX}
|
||||
min={min}
|
||||
max={max}
|
||||
step={step}
|
||||
obscuredRanges={obscuredRanges}
|
||||
/>
|
||||
|
||||
<div className="slider-labels" aria-hidden>
|
||||
<span ref={labelRef}>{label}</span>
|
||||
<span ref={valueLabelRef} className="slider-value-label">{formattedValue}</span>
|
||||
</div>
|
||||
</motion.div>
|
||||
);
|
||||
}
|
||||
@@ -110,6 +110,7 @@ export const DEFAULT_APPEARANCE: UiAppearance = {
|
||||
density: 'cozy',
|
||||
reduceMotion: false,
|
||||
disableMotion: false,
|
||||
customPointerSystem: false,
|
||||
highContrast: false,
|
||||
sidebarPinned: false,
|
||||
timeFormat: '24h',
|
||||
|
||||
+647
-51
@@ -232,6 +232,519 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* ──────────────────────────────────────────────
|
||||
Adaptive cursor system
|
||||
|
||||
CSS is the single source of truth for cursor semantics. The React layer
|
||||
only reads --snowluma-cursor-mode, follows the pointer, and supplies the
|
||||
hovered target's bounds. Coarse pointers and reduced-motion environments
|
||||
never receive data-cursor-system="custom", so native cursors remain intact.
|
||||
────────────────────────────────────────────── */
|
||||
@media (hover: hover) and (pointer: fine) {
|
||||
html {
|
||||
--snowluma-cursor-mode: default;
|
||||
}
|
||||
|
||||
/* Native textarea resize handles are pseudo-elements, so the tracker reads
|
||||
this CSS-owned regional mode only inside the bottom-right 18px hot zone. */
|
||||
.resize-y { --snowluma-cursor-resize-mode: ns-resize; }
|
||||
.resize-x { --snowluma-cursor-resize-mode: ew-resize; }
|
||||
.resize { --snowluma-cursor-resize-mode: nwse-resize; }
|
||||
.resize-none { --snowluma-cursor-resize-mode: initial; }
|
||||
|
||||
/* Clickable targets morph the dot into the complete hit surface. */
|
||||
:where(
|
||||
button,
|
||||
a[href],
|
||||
summary,
|
||||
select,
|
||||
label[for],
|
||||
input[type="button"],
|
||||
input[type="submit"],
|
||||
input[type="reset"],
|
||||
input[type="checkbox"],
|
||||
input[type="radio"],
|
||||
input[type="file"],
|
||||
input[type="image"],
|
||||
[role="button"],
|
||||
[role="link"],
|
||||
[role="tab"],
|
||||
[role="checkbox"],
|
||||
[role="radio"],
|
||||
[role="switch"],
|
||||
[role="menuitem"],
|
||||
[role="option"],
|
||||
[data-cursor-target],
|
||||
.cursor-pointer
|
||||
) {
|
||||
--snowluma-cursor-mode: target;
|
||||
}
|
||||
|
||||
/* Text entry and selectable/editor surfaces use a narrow I-beam capsule. */
|
||||
:where(
|
||||
input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="image"]):not([type="hidden"]),
|
||||
textarea,
|
||||
[contenteditable]:not([contenteditable="false"]),
|
||||
pre,
|
||||
code,
|
||||
.font-mono,
|
||||
.select-text,
|
||||
.cursor-text
|
||||
) {
|
||||
--snowluma-cursor-mode: text;
|
||||
}
|
||||
|
||||
:where(input[type="color"], .cursor-crosshair, .cursor-cell) {
|
||||
--snowluma-cursor-mode: crosshair;
|
||||
}
|
||||
|
||||
:where(input[type="range"], [draggable="true"], .slider-root, .cursor-grab) {
|
||||
--snowluma-cursor-mode: grab;
|
||||
}
|
||||
:where(input[type="range"], [draggable="true"], .slider-root, .cursor-grab):active,
|
||||
:where([aria-grabbed="true"], .cursor-grabbing, .ui-draggable-dragging) {
|
||||
--snowluma-cursor-mode: grabbing;
|
||||
}
|
||||
|
||||
:where(.cursor-move, .cursor-all-scroll) {
|
||||
--snowluma-cursor-mode: move;
|
||||
}
|
||||
:where(.cursor-ew-resize, .cursor-col-resize, .ui-resizable-e, .ui-resizable-w) {
|
||||
--snowluma-cursor-mode: ew-resize;
|
||||
}
|
||||
:where(.cursor-ns-resize, .cursor-row-resize, .ui-resizable-n, .ui-resizable-s) {
|
||||
--snowluma-cursor-mode: ns-resize;
|
||||
}
|
||||
:where(.cursor-nwse-resize, .cursor-nw-resize, .cursor-se-resize, .ui-resizable-nw, .ui-resizable-se) {
|
||||
--snowluma-cursor-mode: nwse-resize;
|
||||
}
|
||||
:where(.cursor-nesw-resize, .cursor-ne-resize, .cursor-sw-resize, .ui-resizable-ne, .ui-resizable-sw) {
|
||||
--snowluma-cursor-mode: nesw-resize;
|
||||
}
|
||||
|
||||
:where([aria-busy="true"], .cursor-wait, .cursor-progress) {
|
||||
--snowluma-cursor-mode: wait;
|
||||
}
|
||||
:where(.cursor-copy) { --snowluma-cursor-mode: copy; }
|
||||
:where(.cursor-zoom-in) { --snowluma-cursor-mode: zoom-in; }
|
||||
:where(.cursor-zoom-out) { --snowluma-cursor-mode: zoom-out; }
|
||||
:where(.cursor-help) { --snowluma-cursor-mode: help; }
|
||||
:where(:disabled, [aria-disabled="true"], .cursor-not-allowed, .cursor-no-drop) {
|
||||
--snowluma-cursor-mode: not-allowed;
|
||||
}
|
||||
|
||||
/* Explicit data attributes are the escape hatch for third-party widgets. */
|
||||
[data-cursor="default"] { --snowluma-cursor-mode: default; }
|
||||
[data-cursor="target"] { --snowluma-cursor-mode: target; }
|
||||
[data-cursor="text"] { --snowluma-cursor-mode: text; }
|
||||
[data-cursor="grab"] { --snowluma-cursor-mode: grab; }
|
||||
[data-cursor="grabbing"] { --snowluma-cursor-mode: grabbing; }
|
||||
[data-cursor="move"] { --snowluma-cursor-mode: move; }
|
||||
[data-cursor="ew-resize"] { --snowluma-cursor-mode: ew-resize; }
|
||||
[data-cursor="ns-resize"] { --snowluma-cursor-mode: ns-resize; }
|
||||
[data-cursor="nwse-resize"] { --snowluma-cursor-mode: nwse-resize; }
|
||||
[data-cursor="nesw-resize"] { --snowluma-cursor-mode: nesw-resize; }
|
||||
[data-cursor="not-allowed"] { --snowluma-cursor-mode: not-allowed; }
|
||||
[data-cursor="wait"] { --snowluma-cursor-mode: wait; }
|
||||
[data-cursor="crosshair"] { --snowluma-cursor-mode: crosshair; }
|
||||
[data-cursor="copy"] { --snowluma-cursor-mode: copy; }
|
||||
[data-cursor="zoom-in"] { --snowluma-cursor-mode: zoom-in; }
|
||||
[data-cursor="zoom-out"] { --snowluma-cursor-mode: zoom-out; }
|
||||
[data-cursor="help"] { --snowluma-cursor-mode: help; }
|
||||
[data-cursor="hidden"] { --snowluma-cursor-mode: hidden; }
|
||||
|
||||
/* Applied only after the tracker mounts, so a JavaScript failure can never
|
||||
strand the application without a usable native pointer. */
|
||||
html[data-cursor-system="custom"],
|
||||
html[data-cursor-system="custom"] body,
|
||||
html[data-cursor-system="custom"] *,
|
||||
html[data-cursor-system="custom"] *::before,
|
||||
html[data-cursor-system="custom"] *::after {
|
||||
cursor: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
.adaptive-cursor {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 2147483647;
|
||||
width: 0;
|
||||
height: 0;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
will-change: transform, opacity;
|
||||
transition-property: opacity;
|
||||
transition-duration: 120ms;
|
||||
transition-timing-function: ease-out;
|
||||
}
|
||||
|
||||
html[data-cursor-system="custom"] .adaptive-cursor[data-visible="true"] {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.adaptive-cursor-shape {
|
||||
--cursor-width: 1.125rem;
|
||||
--cursor-height: 1.125rem;
|
||||
--cursor-radius: 9999px;
|
||||
--cursor-scale: 1;
|
||||
--cursor-fill: color-mix(in oklab, var(--primary) 82%, var(--foreground));
|
||||
--cursor-stroke: color-mix(in oklab, var(--primary) 34%, transparent);
|
||||
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: block;
|
||||
width: var(--cursor-width);
|
||||
height: var(--cursor-height);
|
||||
border: 1px solid var(--cursor-stroke);
|
||||
border-radius: var(--cursor-radius);
|
||||
background: var(--cursor-fill);
|
||||
box-shadow:
|
||||
0 1px 3px oklch(0% 0 0 / 0.16),
|
||||
0 0 0 3px color-mix(in oklab, var(--background) 34%, transparent);
|
||||
opacity: 1;
|
||||
translate: -50% -50%;
|
||||
scale: var(--cursor-scale);
|
||||
transition-property: width, height, border-radius, background-color, border-color, box-shadow, opacity, scale;
|
||||
transition-duration: 180ms;
|
||||
transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
|
||||
}
|
||||
|
||||
.adaptive-cursor-shape::before,
|
||||
.adaptive-cursor-shape::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition-property: opacity, transform;
|
||||
transition-duration: 140ms;
|
||||
transition-timing-function: ease-out;
|
||||
}
|
||||
|
||||
.adaptive-cursor[data-pressed="true"] .adaptive-cursor-shape {
|
||||
--cursor-scale: 0.8;
|
||||
}
|
||||
|
||||
/* Mikk-style target morph: bounds and radius come from the hovered element. */
|
||||
.adaptive-cursor[data-mode="target"] .adaptive-cursor-shape {
|
||||
--cursor-width: var(--cursor-target-width, 1.125rem);
|
||||
--cursor-height: var(--cursor-target-height, 1.125rem);
|
||||
--cursor-radius: var(--cursor-target-radius, var(--radius));
|
||||
--cursor-fill: color-mix(in oklab, var(--primary) 14%, transparent);
|
||||
--cursor-stroke: color-mix(in oklab, var(--primary) 28%, transparent);
|
||||
box-shadow:
|
||||
0 4px 18px -10px color-mix(in oklab, var(--primary) 56%, transparent),
|
||||
inset 0 1px color-mix(in oklab, var(--primary-foreground) 16%, transparent);
|
||||
}
|
||||
.adaptive-cursor[data-mode="target"][data-pressed="true"] .adaptive-cursor-shape {
|
||||
--cursor-scale: 0.96;
|
||||
--cursor-fill: color-mix(in oklab, var(--primary) 23%, transparent);
|
||||
}
|
||||
|
||||
/* Narrow but visibly substantial text caret capsule. */
|
||||
.adaptive-cursor[data-mode="text"] .adaptive-cursor-shape {
|
||||
--cursor-width: 0.25rem;
|
||||
--cursor-height: 1.75rem;
|
||||
--cursor-fill: color-mix(in oklab, var(--primary) 84%, var(--foreground));
|
||||
--cursor-stroke: color-mix(in oklab, var(--background) 48%, transparent);
|
||||
box-shadow:
|
||||
0 0 0 1px color-mix(in oklab, var(--background) 52%, transparent),
|
||||
0 2px 8px color-mix(in oklab, var(--primary) 46%, transparent);
|
||||
}
|
||||
|
||||
/* Grab / grabbing: a compact four-dot grip compresses under load. */
|
||||
.adaptive-cursor[data-mode="grab"] .adaptive-cursor-shape,
|
||||
.adaptive-cursor[data-mode="grabbing"] .adaptive-cursor-shape {
|
||||
--cursor-width: 1.5rem;
|
||||
--cursor-height: 1.5rem;
|
||||
--cursor-fill: color-mix(in oklab, var(--primary) 16%, var(--background));
|
||||
--cursor-stroke: color-mix(in oklab, var(--primary) 52%, transparent);
|
||||
}
|
||||
.adaptive-cursor[data-mode="grabbing"] .adaptive-cursor-shape {
|
||||
--cursor-width: 1.2rem;
|
||||
--cursor-height: 1.2rem;
|
||||
--cursor-fill: color-mix(in oklab, var(--primary) 28%, var(--background));
|
||||
}
|
||||
.adaptive-cursor[data-mode="grab"] .adaptive-cursor-shape::before,
|
||||
.adaptive-cursor[data-mode="grabbing"] .adaptive-cursor-shape::before {
|
||||
width: 0.1875rem;
|
||||
height: 0.1875rem;
|
||||
border-radius: 9999px;
|
||||
background: var(--primary);
|
||||
box-shadow: 0.375rem 0 var(--primary), 0 0.375rem var(--primary), 0.375rem 0.375rem var(--primary);
|
||||
opacity: 0.88;
|
||||
transform: translate(-0.28125rem, -0.28125rem);
|
||||
}
|
||||
.adaptive-cursor[data-mode="grabbing"] .adaptive-cursor-shape::before {
|
||||
box-shadow: 0.3rem 0 var(--primary), 0 0.3rem var(--primary), 0.3rem 0.3rem var(--primary);
|
||||
transform: translate(-0.24375rem, -0.24375rem);
|
||||
}
|
||||
|
||||
/* Move and all resize directions share one CSS arrow glyph. */
|
||||
.adaptive-cursor[data-mode="move"] .adaptive-cursor-shape,
|
||||
.adaptive-cursor[data-mode$="resize"] .adaptive-cursor-shape {
|
||||
--cursor-width: 1.625rem;
|
||||
--cursor-height: 0.875rem;
|
||||
--cursor-fill: color-mix(in oklab, var(--primary) 15%, var(--background));
|
||||
--cursor-stroke: color-mix(in oklab, var(--primary) 48%, transparent);
|
||||
}
|
||||
.adaptive-cursor[data-mode="move"] .adaptive-cursor-shape {
|
||||
--cursor-width: 1.625rem;
|
||||
--cursor-height: 1.625rem;
|
||||
}
|
||||
.adaptive-cursor[data-mode="move"] .adaptive-cursor-shape::before,
|
||||
.adaptive-cursor[data-mode$="resize"] .adaptive-cursor-shape::before {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
background: var(--primary);
|
||||
opacity: 0.9;
|
||||
transform: translate(-50%, -50%);
|
||||
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 8h12M5 5 2 8l3 3m6-6 3 3-3 3' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
|
||||
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 8h12M5 5 2 8l3 3m6-6 3 3-3 3' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
|
||||
}
|
||||
.adaptive-cursor[data-mode="move"] .adaptive-cursor-shape::before {
|
||||
-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1v14M1 8h14M5 4 8 1l3 3m-6 8 3 3 3-3M4 5 1 8l3 3m8-6 3 3-3 3' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
||||
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1v14M1 8h14M5 4 8 1l3 3m-6 8 3 3 3-3M4 5 1 8l3 3m8-6 3 3-3 3' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
||||
}
|
||||
.adaptive-cursor[data-mode="ns-resize"] .adaptive-cursor-shape::before { transform: translate(-50%, -50%) rotate(90deg); }
|
||||
.adaptive-cursor[data-mode="nwse-resize"] .adaptive-cursor-shape::before { transform: translate(-50%, -50%) rotate(45deg); }
|
||||
.adaptive-cursor[data-mode="nesw-resize"] .adaptive-cursor-shape::before { transform: translate(-50%, -50%) rotate(-45deg); }
|
||||
|
||||
/* Disabled / forbidden action. */
|
||||
.adaptive-cursor[data-mode="not-allowed"] .adaptive-cursor-shape {
|
||||
--cursor-width: 1.45rem;
|
||||
--cursor-height: 1.45rem;
|
||||
--cursor-fill: color-mix(in oklab, var(--destructive) 8%, var(--background));
|
||||
--cursor-stroke: color-mix(in oklab, var(--destructive) 76%, transparent);
|
||||
border-width: 2px;
|
||||
box-shadow: 0 2px 8px color-mix(in oklab, var(--destructive) 22%, transparent);
|
||||
}
|
||||
.adaptive-cursor[data-mode="not-allowed"] .adaptive-cursor-shape::after {
|
||||
width: 1rem;
|
||||
height: 2px;
|
||||
border-radius: 9999px;
|
||||
background: var(--destructive);
|
||||
opacity: 0.9;
|
||||
transform: translate(-50%, -50%) rotate(-45deg);
|
||||
}
|
||||
|
||||
/* Busy state: a CSS-only spinner, used only while motion is allowed. */
|
||||
.adaptive-cursor[data-mode="wait"] .adaptive-cursor-shape {
|
||||
--cursor-width: 1.4rem;
|
||||
--cursor-height: 1.4rem;
|
||||
--cursor-fill: color-mix(in oklab, var(--background) 84%, transparent);
|
||||
--cursor-stroke: color-mix(in oklab, var(--primary) 22%, transparent);
|
||||
border-width: 2px;
|
||||
}
|
||||
.adaptive-cursor[data-mode="wait"] .adaptive-cursor-shape::before {
|
||||
inset: -2px;
|
||||
border: 2px solid transparent;
|
||||
border-top-color: var(--primary);
|
||||
border-right-color: color-mix(in oklab, var(--primary) 55%, transparent);
|
||||
border-radius: 9999px;
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
animation: adaptive-cursor-spin 700ms linear infinite;
|
||||
}
|
||||
@keyframes adaptive-cursor-spin { to { rotate: 1turn; } }
|
||||
|
||||
/* Precision selection. */
|
||||
.adaptive-cursor[data-mode="crosshair"] .adaptive-cursor-shape {
|
||||
--cursor-width: 1.25rem;
|
||||
--cursor-height: 1.25rem;
|
||||
--cursor-fill: transparent;
|
||||
--cursor-stroke: color-mix(in oklab, var(--primary) 45%, transparent);
|
||||
box-shadow: none;
|
||||
}
|
||||
.adaptive-cursor[data-mode="crosshair"] .adaptive-cursor-shape::before,
|
||||
.adaptive-cursor[data-mode="crosshair"] .adaptive-cursor-shape::after {
|
||||
border-radius: 9999px;
|
||||
background: var(--primary);
|
||||
opacity: 0.9;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
.adaptive-cursor[data-mode="crosshair"] .adaptive-cursor-shape::before { width: 1.6rem; height: 2px; }
|
||||
.adaptive-cursor[data-mode="crosshair"] .adaptive-cursor-shape::after { width: 2px; height: 1.6rem; }
|
||||
|
||||
/* Copy uses two offset sheets. */
|
||||
.adaptive-cursor[data-mode="copy"] .adaptive-cursor-shape {
|
||||
--cursor-width: 1.45rem;
|
||||
--cursor-height: 1.45rem;
|
||||
--cursor-fill: color-mix(in oklab, var(--primary) 13%, var(--background));
|
||||
--cursor-stroke: color-mix(in oklab, var(--primary) 45%, transparent);
|
||||
}
|
||||
.adaptive-cursor[data-mode="copy"] .adaptive-cursor-shape::before,
|
||||
.adaptive-cursor[data-mode="copy"] .adaptive-cursor-shape::after {
|
||||
width: 0.55rem;
|
||||
height: 0.65rem;
|
||||
border: 1.5px solid var(--primary);
|
||||
border-radius: 0.15rem;
|
||||
background: var(--background);
|
||||
opacity: 0.95;
|
||||
}
|
||||
.adaptive-cursor[data-mode="copy"] .adaptive-cursor-shape::before { transform: translate(-65%, -65%); }
|
||||
.adaptive-cursor[data-mode="copy"] .adaptive-cursor-shape::after { transform: translate(-30%, -30%); }
|
||||
|
||||
/* Zoom modes share a lens; the second line appears only for zoom-in. */
|
||||
.adaptive-cursor[data-mode="zoom-in"] .adaptive-cursor-shape,
|
||||
.adaptive-cursor[data-mode="zoom-out"] .adaptive-cursor-shape {
|
||||
--cursor-width: 1.3rem;
|
||||
--cursor-height: 1.3rem;
|
||||
--cursor-fill: color-mix(in oklab, var(--primary) 10%, var(--background));
|
||||
--cursor-stroke: color-mix(in oklab, var(--primary) 62%, transparent);
|
||||
border-width: 2px;
|
||||
box-shadow: 0 2px 8px color-mix(in oklab, var(--primary) 18%, transparent);
|
||||
}
|
||||
.adaptive-cursor[data-mode="zoom-in"] .adaptive-cursor-shape::before,
|
||||
.adaptive-cursor[data-mode="zoom-out"] .adaptive-cursor-shape::before {
|
||||
width: 0.55rem;
|
||||
height: 2px;
|
||||
border-radius: 9999px;
|
||||
background: var(--primary);
|
||||
opacity: 0.9;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
.adaptive-cursor[data-mode="zoom-in"] .adaptive-cursor-shape::after {
|
||||
width: 2px;
|
||||
height: 0.55rem;
|
||||
border-radius: 9999px;
|
||||
background: var(--primary);
|
||||
opacity: 0.9;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.adaptive-cursor[data-mode="help"] .adaptive-cursor-shape {
|
||||
--cursor-width: 1.35rem;
|
||||
--cursor-height: 1.35rem;
|
||||
--cursor-fill: color-mix(in oklab, var(--primary) 14%, var(--background));
|
||||
--cursor-stroke: color-mix(in oklab, var(--primary) 55%, transparent);
|
||||
}
|
||||
.adaptive-cursor[data-mode="help"] .adaptive-cursor-shape::before {
|
||||
content: '?';
|
||||
color: var(--primary);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
opacity: 0.95;
|
||||
transform: translate(-50%, -52%);
|
||||
}
|
||||
|
||||
.adaptive-cursor[data-mode="hidden"] .adaptive-cursor-shape {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
/* ──────────────────────────────────────────────
|
||||
Global context menu
|
||||
────────────────────────────────────────────── */
|
||||
.global-context-menu {
|
||||
position: fixed;
|
||||
z-index: 2147483646;
|
||||
width: min(15.5rem, calc(100vw - 1rem));
|
||||
padding: 0.375rem;
|
||||
border-radius: calc(var(--radius) + 0.25rem);
|
||||
background: color-mix(in oklab, var(--popover) 92%, transparent);
|
||||
color: var(--popover-foreground);
|
||||
box-shadow:
|
||||
0 0 0 1px color-mix(in oklab, var(--foreground) 9%, transparent),
|
||||
0 2px 5px -2px oklch(0% 0 0 / 0.18),
|
||||
0 18px 48px -20px oklch(0% 0 0 / 0.42);
|
||||
outline: none;
|
||||
overflow: hidden;
|
||||
backdrop-filter: blur(20px) saturate(1.15);
|
||||
}
|
||||
|
||||
.global-context-menu-group {
|
||||
display: grid;
|
||||
gap: 0.125rem;
|
||||
}
|
||||
|
||||
.global-context-menu-separator {
|
||||
height: 1px;
|
||||
margin: 0.375rem 0.5rem;
|
||||
background: color-mix(in oklab, var(--border) 74%, transparent);
|
||||
}
|
||||
|
||||
.global-context-menu-item {
|
||||
display: grid;
|
||||
grid-template-columns: 1.125rem minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
width: 100%;
|
||||
min-height: 2.5rem;
|
||||
padding: 0 0.625rem;
|
||||
border: 0;
|
||||
border-radius: calc(var(--radius) - 0.125rem);
|
||||
background: transparent;
|
||||
color: var(--popover-foreground);
|
||||
font: inherit;
|
||||
text-align: left;
|
||||
scale: 1;
|
||||
outline: none;
|
||||
transition-property: color, background-color, box-shadow, scale, opacity;
|
||||
transition-duration: 140ms;
|
||||
transition-timing-function: ease-out;
|
||||
}
|
||||
.global-context-menu-item:hover,
|
||||
.global-context-menu-item:focus-visible {
|
||||
background: color-mix(in oklab, var(--primary) 12%, var(--accent));
|
||||
color: var(--foreground);
|
||||
}
|
||||
.global-context-menu-item:focus-visible {
|
||||
box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--ring) 45%, transparent);
|
||||
}
|
||||
.global-context-menu-item:active:not(:disabled) {
|
||||
scale: 0.96;
|
||||
}
|
||||
.global-context-menu-item:disabled {
|
||||
color: color-mix(in oklab, var(--muted-foreground) 62%, transparent);
|
||||
opacity: 0.62;
|
||||
}
|
||||
|
||||
.global-context-menu-icon {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
justify-self: center;
|
||||
color: var(--muted-foreground);
|
||||
stroke-width: 1.8;
|
||||
}
|
||||
.global-context-menu-item:hover .global-context-menu-icon,
|
||||
.global-context-menu-item:focus-visible .global-context-menu-icon {
|
||||
color: var(--primary);
|
||||
}
|
||||
|
||||
.global-context-menu-label {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 500;
|
||||
line-height: 1.25rem;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.global-context-menu-shortcut {
|
||||
color: var(--muted-foreground);
|
||||
font-family: var(--font-sans);
|
||||
font-size: 0.6875rem;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.01em;
|
||||
line-height: 1rem;
|
||||
}
|
||||
|
||||
.global-context-menu-error {
|
||||
margin: 0.375rem 0.25rem 0.125rem;
|
||||
padding: 0.5rem 0.625rem;
|
||||
border-radius: calc(var(--radius) - 0.25rem);
|
||||
background: color-mix(in oklab, var(--destructive) 10%, transparent);
|
||||
color: var(--destructive);
|
||||
font-size: 0.75rem;
|
||||
line-height: 1.125rem;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
/* ──────────────────────────────────────────────
|
||||
Customization layers (driven by ThemeContext via
|
||||
data-* attributes + CSS vars on <html>)
|
||||
@@ -431,67 +944,150 @@ html {
|
||||
}
|
||||
|
||||
/* ──────────────────────────────────────────────
|
||||
Custom range slider (via the <Slider> component, class `.slider`).
|
||||
The component sets `--slider-pct` for the WebKit filled track; Firefox
|
||||
uses native ::-moz-range-progress.
|
||||
Elastic range slider. Interaction and geometry intentionally follow the
|
||||
Mikk Martin slider demo; only the palette and focus treatment are themed.
|
||||
────────────────────────────────────────────── */
|
||||
.slider {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
.slider-root {
|
||||
position: relative;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
/* Match the track height so WebKit can't top-align a short track inside a
|
||||
taller input; the 1rem thumb overflows symmetrically as the grab target. */
|
||||
height: 0.375rem;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
.slider::-webkit-slider-runnable-track {
|
||||
height: 0.375rem;
|
||||
border-radius: 9999px;
|
||||
background: linear-gradient(to right,
|
||||
var(--primary) var(--slider-pct, 0%),
|
||||
var(--muted) var(--slider-pct, 0%));
|
||||
}
|
||||
.slider::-webkit-slider-thumb {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
margin-top: -0.3125rem; /* center the 1rem thumb on the 0.375rem track */
|
||||
height: 1rem;
|
||||
width: 1rem;
|
||||
border-radius: 9999px;
|
||||
background: var(--background);
|
||||
border: 2px solid var(--primary);
|
||||
box-shadow: 0 1px 2px rgb(0 0 0 / 0.18);
|
||||
transition: transform 0.12s ease;
|
||||
}
|
||||
.slider:active::-webkit-slider-thumb { transform: scale(1.12); }
|
||||
.slider:focus-visible::-webkit-slider-thumb {
|
||||
box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 40%, transparent);
|
||||
}
|
||||
.slider::-moz-range-track {
|
||||
height: 0.375rem;
|
||||
border-radius: 9999px;
|
||||
min-width: 0;
|
||||
height: 3rem;
|
||||
align-items: center;
|
||||
overflow: clip;
|
||||
border: 0.5px solid var(--border);
|
||||
border-radius: 0.75rem;
|
||||
background: var(--muted);
|
||||
cursor: grab;
|
||||
touch-action: none;
|
||||
user-select: none;
|
||||
backdrop-filter: blur(20px);
|
||||
transition-property: background-color, border-color, box-shadow;
|
||||
transition-duration: 150ms;
|
||||
transition-timing-function: ease-out;
|
||||
}
|
||||
.slider::-moz-range-progress {
|
||||
height: 0.375rem;
|
||||
.slider-root:hover {
|
||||
border-color: color-mix(in oklab, var(--primary) 24%, var(--border));
|
||||
background: color-mix(in oklab, var(--primary) 6%, var(--muted));
|
||||
}
|
||||
.slider-root:active { cursor: grabbing; }
|
||||
.slider-root:has(.slider-native-thumb:focus-visible) {
|
||||
box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 30%, transparent);
|
||||
}
|
||||
.slider-root[data-disabled] {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.5;
|
||||
}
|
||||
.slider-radix-root {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.slider-native-thumb {
|
||||
width: 1.25rem;
|
||||
height: 2.75rem;
|
||||
border: 0;
|
||||
border-radius: 9999px;
|
||||
background: transparent;
|
||||
opacity: 0;
|
||||
outline: none;
|
||||
}
|
||||
.slider-active-range {
|
||||
height: 100%;
|
||||
border-radius: 0.75rem;
|
||||
background: color-mix(in oklab, var(--primary) 18%, var(--muted));
|
||||
transition-property: background-color;
|
||||
transition-duration: 150ms;
|
||||
transition-timing-function: ease-out;
|
||||
}
|
||||
.slider-root:hover .slider-active-range {
|
||||
background: color-mix(in oklab, var(--primary) 26%, var(--muted));
|
||||
}
|
||||
.slider-handle-slot {
|
||||
margin-left: auto;
|
||||
display: flex;
|
||||
width: 1.5rem;
|
||||
height: 100%;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: grab;
|
||||
}
|
||||
.slider-root:active .slider-handle-slot { cursor: grabbing; }
|
||||
.slider-handle-line {
|
||||
display: block;
|
||||
width: 0.125rem;
|
||||
border-radius: 9999px;
|
||||
background: color-mix(in oklab, var(--primary) 64%, transparent);
|
||||
transition-property: background-color;
|
||||
transition-duration: 150ms;
|
||||
transition-timing-function: ease-out;
|
||||
}
|
||||
.slider-root:hover .slider-handle-line {
|
||||
background: var(--primary);
|
||||
}
|
||||
.slider::-moz-range-thumb {
|
||||
height: 1rem;
|
||||
width: 1rem;
|
||||
border: 2px solid var(--primary);
|
||||
.slider-ticks {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
pointer-events: none;
|
||||
}
|
||||
.slider-tick {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: 0.25rem;
|
||||
height: 0.25rem;
|
||||
border-radius: 9999px;
|
||||
background: var(--background);
|
||||
box-shadow: 0 1px 2px rgb(0 0 0 / 0.18);
|
||||
background: color-mix(in oklab, var(--muted-foreground) 24%, transparent);
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
.slider:focus-visible::-moz-range-thumb {
|
||||
box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 40%, transparent);
|
||||
.slider-root:hover .slider-tick {
|
||||
background: color-mix(in oklab, var(--primary) 34%, transparent);
|
||||
}
|
||||
.slider-labels {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding-inline: 1.25rem;
|
||||
color: var(--muted-foreground);
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.5rem;
|
||||
pointer-events: none;
|
||||
transition-property: color;
|
||||
transition-duration: 150ms;
|
||||
transition-timing-function: ease-out;
|
||||
}
|
||||
.slider-root:hover .slider-labels {
|
||||
color: var(--foreground);
|
||||
}
|
||||
.slider-value-label {
|
||||
color: var(--foreground);
|
||||
font-variant-numeric: tabular-nums;
|
||||
letter-spacing: -0.025em;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
html[data-reduce-motion="1"] .slider-root,
|
||||
html[data-reduce-motion="1"] .slider-active-range,
|
||||
html[data-reduce-motion="1"] .slider-handle-line,
|
||||
html[data-reduce-motion="1"] .slider-labels {
|
||||
transition-duration: 0s !important;
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.slider-root,
|
||||
.slider-active-range,
|
||||
.slider-handle-line,
|
||||
.slider-labels {
|
||||
transition-duration: 0s !important;
|
||||
}
|
||||
}
|
||||
/* The global reduce-motion rule can't match pseudo-elements, so kill the
|
||||
thumb's active-scale transition explicitly. */
|
||||
html[data-reduce-motion="1"] .slider::-webkit-slider-thumb { transition: none !important; }
|
||||
|
||||
/* ──────────────────────────────────────────────
|
||||
gridstack dashboard — mesh the library's item shell with our cards.
|
||||
|
||||
@@ -90,7 +90,7 @@ export function defaultOverviewMobile(): UiLayoutItem[] {
|
||||
* Bring any stored overview layout up to the current grid catalogue:
|
||||
* - expand the legacy single `stats` block into the 5 individual tiles
|
||||
* (inheriting its visibility),
|
||||
* - keep stored coords/visibility for known widgets, assign the default
|
||||
* - keep stored coords/visibility/config for known widgets, assign the default
|
||||
* placement to any widget missing coords,
|
||||
* - append catalogue widgets the stored layout predates (visible),
|
||||
* - drop unknown ids.
|
||||
@@ -117,7 +117,8 @@ export function migrateOverviewBlocks(stored: UiLayoutItem[] | undefined): UiLay
|
||||
const coords = validCoords(item)
|
||||
? { x: item!.x!, y: item!.y!, w: item!.w!, h: item!.h! }
|
||||
: { ...spec.def };
|
||||
return { id: spec.id, visible, ...coords };
|
||||
const config = isObj(item?.config) ? { config: { ...item.config } } : {};
|
||||
return { id: spec.id, visible, ...coords, ...config };
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -363,6 +363,8 @@ export interface UiAppearance {
|
||||
density: Density;
|
||||
reduceMotion: boolean;
|
||||
disableMotion: boolean;
|
||||
/** Master switch for the adaptive cursor and custom context menu. */
|
||||
customPointerSystem: boolean;
|
||||
highContrast: boolean;
|
||||
/** Pin the sidebar permanently expanded, opting out of the hover-expand rail. */
|
||||
sidebarPinned: boolean;
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { migrateOverviewBlocks } from '../src/lib/dashboard-layout';
|
||||
|
||||
describe('migrateOverviewBlocks', () => {
|
||||
it('preserves saved widget configuration while restoring the grid', () => {
|
||||
const migrated = migrateOverviewBlocks([
|
||||
{
|
||||
id: 'account',
|
||||
visible: true,
|
||||
x: 8,
|
||||
y: 14,
|
||||
w: 4,
|
||||
h: 1,
|
||||
config: { uin: '123456789' },
|
||||
},
|
||||
]);
|
||||
|
||||
expect(migrated.find((item) => item.id === 'account')).toEqual({
|
||||
id: 'account',
|
||||
visible: true,
|
||||
x: 8,
|
||||
y: 14,
|
||||
w: 4,
|
||||
h: 1,
|
||||
config: { uin: '123456789' },
|
||||
});
|
||||
});
|
||||
});
|
||||
Generated
+235
@@ -370,6 +370,9 @@ importers:
|
||||
'@radix-ui/react-separator':
|
||||
specifier: ^1.1.3
|
||||
version: 1.1.8(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)
|
||||
'@radix-ui/react-slider':
|
||||
specifier: ^1.4.3
|
||||
version: 1.4.3(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)
|
||||
'@radix-ui/react-slot':
|
||||
specifier: ^1.1.3
|
||||
version: 1.2.4(@types/react@19.2.14)(react@19.2.5)
|
||||
@@ -458,6 +461,9 @@ importers:
|
||||
vite:
|
||||
specifier: 'catalog:'
|
||||
version: 8.1.0(@types/node@25.6.0)(esbuild@0.28.1)(jiti@2.6.1)(sass@1.99.0)(tsx@4.21.0)
|
||||
vitest:
|
||||
specifier: ^4.1.4
|
||||
version: 4.1.4(@types/node@25.6.0)(@vitest/coverage-istanbul@4.1.4)(@vitest/coverage-v8@4.1.4)(vite@8.1.0(@types/node@25.6.0)(esbuild@0.28.1)(jiti@2.6.1)(sass@1.99.0)(tsx@4.21.0))
|
||||
|
||||
packages:
|
||||
|
||||
@@ -928,9 +934,15 @@ packages:
|
||||
'@radix-ui/number@1.1.1':
|
||||
resolution: {integrity: sha512-MkKCwxlXTgz6CFoJx3pCwn07GKp36+aZyu/u2Ln2VrA5DcdyCZkASEDBTd8x5whTQQL5CiYf4prXKLcgQdv29g==}
|
||||
|
||||
'@radix-ui/number@1.1.2':
|
||||
resolution: {integrity: sha512-ceTwaxc4I5IOi97DgCotl3pqiyRGvffcc0oOsE2dQYaJOFIDsDt4VWG6xEbg1QePv9QWausCEIppud/tJ1wNig==}
|
||||
|
||||
'@radix-ui/primitive@1.1.3':
|
||||
resolution: {integrity: sha512-JTF99U/6XIjCBo0wqkU5sK10glYe27MRRsfwoiq5zzOEZLHU3A3KCMa5X/azekYRCJ0HlwI0crAXS/5dEHTzDg==}
|
||||
|
||||
'@radix-ui/primitive@1.1.5':
|
||||
resolution: {integrity: sha512-d86WIWFYNtGA0H/d8exstrTRTp7eWJYlYJbtNofxr/3ljupZYn6EFDG/Qgu/0Kc8v7yMUxySagqJsL1+PdYjWg==}
|
||||
|
||||
'@radix-ui/react-alert-dialog@1.1.15':
|
||||
resolution: {integrity: sha512-oTVLkEw5GpdRe29BqJ0LSDFWI3qu0vR1M0mUkOQWDIUnY/QIkLpgDMWuKxP94c2NAC2LGcgVhG1ImF3jkZ5wXw==}
|
||||
peerDependencies:
|
||||
@@ -970,6 +982,19 @@ packages:
|
||||
'@types/react-dom':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-collection@1.1.12':
|
||||
resolution: {integrity: sha512-nb67INpE0IahJKN7EYPp9m9YGwYeKlnzxT3MwXVkgCskaSJia97kG4T0ywpjNUSSnoJk/uvk12V8vbrEHEj+/Q==}
|
||||
peerDependencies:
|
||||
'@types/react': '*'
|
||||
'@types/react-dom': '*'
|
||||
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
peerDependenciesMeta:
|
||||
'@types/react':
|
||||
optional: true
|
||||
'@types/react-dom':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-collection@1.1.7':
|
||||
resolution: {integrity: sha512-Fh9rGN0MoI4ZFUNyfFVNU4y9LUz93u9/0K+yLgA2bwRojxM8JU1DyvvMBabnZPBgMWREAJvU2jjVzq+LrFUglw==}
|
||||
peerDependencies:
|
||||
@@ -992,6 +1017,15 @@ packages:
|
||||
'@types/react':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-compose-refs@1.1.3':
|
||||
resolution: {integrity: sha512-rYOP8OMnuuPMQF1uhPVlGNcCDlkokKqGFE3JcxFViIkAXP7EvFWUliJAstrapypaBLJNHbZL6jGhbVDGTwmVhA==}
|
||||
peerDependencies:
|
||||
'@types/react': '*'
|
||||
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
peerDependenciesMeta:
|
||||
'@types/react':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-context@1.1.2':
|
||||
resolution: {integrity: sha512-jCi/QKUM2r1Ju5a3J64TH2A5SpKAgh0LpknyqdQ4m6DCV0xJ2HG1xARRwNGPQfi1SLdLWZ1OJz6F4OMBBNiGJA==}
|
||||
peerDependencies:
|
||||
@@ -1001,6 +1035,15 @@ packages:
|
||||
'@types/react':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-context@1.2.0':
|
||||
resolution: {integrity: sha512-fOE+JtN9rygNZkCnHRBEP0TAvLldlhyOxMsbwFvTP4nAs+nBmfnna+o/Zski2wkmY1YMrFC0aSzsHoLY47iLrg==}
|
||||
peerDependencies:
|
||||
'@types/react': '*'
|
||||
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
peerDependenciesMeta:
|
||||
'@types/react':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-dialog@1.1.15':
|
||||
resolution: {integrity: sha512-TCglVRtzlffRNxRMEyR36DGBLJpeusFcgMVD9PZEzAKnUs1lKCgX5u9BmC2Yg+LL9MgZDugFFs1Vl+Jp4t/PGw==}
|
||||
peerDependencies:
|
||||
@@ -1023,6 +1066,15 @@ packages:
|
||||
'@types/react':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-direction@1.1.2':
|
||||
resolution: {integrity: sha512-C3vFhbyi4SW3PmbAi6Awpu4OzJtd0MxGurvSsYtr7p7nM8RNB3VAF3CUmnp2j50knpkrRcB7+ycVXzgLgF6yNA==}
|
||||
peerDependencies:
|
||||
'@types/react': '*'
|
||||
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
peerDependenciesMeta:
|
||||
'@types/react':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-dismissable-layer@1.1.11':
|
||||
resolution: {integrity: sha512-Nqcp+t5cTB8BinFkZgXiMJniQH0PsUt2k51FUhbdfeKvc4ACcG2uQniY/8+h1Yv6Kza4Q7lD7PQV0z0oicE0Mg==}
|
||||
peerDependencies:
|
||||
@@ -1158,6 +1210,19 @@ packages:
|
||||
'@types/react-dom':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-primitive@2.1.7':
|
||||
resolution: {integrity: sha512-bC3NiwsprbxKjuon9l7X6BUTw7FPVzEYaL92MPEY5SCd/9hUTPXVFtVwRix7778wtRsVao+zE062gL79FZleeQ==}
|
||||
peerDependencies:
|
||||
'@types/react': '*'
|
||||
'@types/react-dom': '*'
|
||||
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
peerDependenciesMeta:
|
||||
'@types/react':
|
||||
optional: true
|
||||
'@types/react-dom':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-roving-focus@1.1.11':
|
||||
resolution: {integrity: sha512-7A6S9jSgm/S+7MdtNDSb+IU859vQqJ/QAtcYQcfFC6W8RS4IxIZDldLR0xqCFZ6DCyrQLjLPsxtTNch5jVA4lA==}
|
||||
peerDependencies:
|
||||
@@ -1210,6 +1275,19 @@ packages:
|
||||
'@types/react-dom':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-slider@1.4.3':
|
||||
resolution: {integrity: sha512-CWVVj+XaTom0SKCqw1EUgb0NuiLwS+N3OFG73mVEezKEjgNIvZiu0EevMelSSU+CbX3owbqJweG2gPU31WGC5A==}
|
||||
peerDependencies:
|
||||
'@types/react': '*'
|
||||
'@types/react-dom': '*'
|
||||
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
peerDependenciesMeta:
|
||||
'@types/react':
|
||||
optional: true
|
||||
'@types/react-dom':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-slot@1.2.3':
|
||||
resolution: {integrity: sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==}
|
||||
peerDependencies:
|
||||
@@ -1228,6 +1306,15 @@ packages:
|
||||
'@types/react':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-slot@1.3.0':
|
||||
resolution: {integrity: sha512-MojKku4U/miO8Av4Dkb+ctMAQx7JmY96LmtDQlAarCRtd7rN52QCSzBF+XAvr5S6coSVj9HEPBgHAHKEJVk/WA==}
|
||||
peerDependencies:
|
||||
'@types/react': '*'
|
||||
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
peerDependenciesMeta:
|
||||
'@types/react':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-switch@1.2.6':
|
||||
resolution: {integrity: sha512-bByzr1+ep1zk4VubeEVViV592vu2lHE2BZY5OnzehZqOOgogN80+mNtCqPkhn2gklJqOpxWgPoYTSnhBCqpOXQ==}
|
||||
peerDependencies:
|
||||
@@ -1285,6 +1372,15 @@ packages:
|
||||
'@types/react':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-use-controllable-state@1.2.3':
|
||||
resolution: {integrity: sha512-PLzC90MS+ReootmjC597dvopoelpZ8Q61HJkDXZSExitIq7PL55vHNnesAHwguHK0aPfBnpdNzQtv1uliaqQrA==}
|
||||
peerDependencies:
|
||||
'@types/react': '*'
|
||||
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
peerDependenciesMeta:
|
||||
'@types/react':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-use-effect-event@0.0.2':
|
||||
resolution: {integrity: sha512-Qp8WbZOBe+blgpuUT+lw2xheLP8q0oatc9UpmiemEICxGvFLYmHm9QowVZGHtJlGbS6A6yJ3iViad/2cVjnOiA==}
|
||||
peerDependencies:
|
||||
@@ -1294,6 +1390,15 @@ packages:
|
||||
'@types/react':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-use-effect-event@0.0.3':
|
||||
resolution: {integrity: sha512-6c8ZqvPTWILEKnyVkP53EGRCcpnJiKTC21sS/6R1GF5xKyHJJWQEPfkqlcgUkdRQivd6tb23abUwe4ngWmY0JA==}
|
||||
peerDependencies:
|
||||
'@types/react': '*'
|
||||
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
peerDependenciesMeta:
|
||||
'@types/react':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-use-escape-keydown@1.1.1':
|
||||
resolution: {integrity: sha512-Il0+boE7w/XebUHyBjroE+DbByORGR9KKmITzbR7MyQ4akpORYP/ZmbhAr0DG7RmmBqoOnZdy2QlvajJ2QA59g==}
|
||||
peerDependencies:
|
||||
@@ -1312,6 +1417,15 @@ packages:
|
||||
'@types/react':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-use-layout-effect@1.1.2':
|
||||
resolution: {integrity: sha512-jrBWOxZITuGcnjRCM2t2U5ZPkCLxD+Ym6DjfssS5haTj2iiak/DOb64JeN6OdLfLgptb6/e2kKR+ZuTrGoZTPA==}
|
||||
peerDependencies:
|
||||
'@types/react': '*'
|
||||
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
peerDependenciesMeta:
|
||||
'@types/react':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-use-previous@1.1.1':
|
||||
resolution: {integrity: sha512-2dHfToCj/pzca2Ck724OZ5L0EVrr3eHRNsG/b3xQJLA2hZpVCS99bLAX+hm1IHXDEnzU6by5z/5MIY794/a8NQ==}
|
||||
peerDependencies:
|
||||
@@ -1321,6 +1435,15 @@ packages:
|
||||
'@types/react':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-use-previous@1.1.2':
|
||||
resolution: {integrity: sha512-IGBQPtRFdhN6MQ8dbegVmBq1LVZluya3F1jWY+puIcQC3MHctRwTDSBWCkL/3ZcnMJLTMJ++Z+ktmvg0F89iCw==}
|
||||
peerDependencies:
|
||||
'@types/react': '*'
|
||||
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
peerDependenciesMeta:
|
||||
'@types/react':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-use-rect@1.1.1':
|
||||
resolution: {integrity: sha512-QTYuDesS0VtuHNNvMh+CjlKJ4LJickCMUAqjlE3+j8w+RlRpwyX3apEQKGFzbZGdo7XNG1tXa+bQqIE7HIXT2w==}
|
||||
peerDependencies:
|
||||
@@ -1339,6 +1462,15 @@ packages:
|
||||
'@types/react':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-use-size@1.1.2':
|
||||
resolution: {integrity: sha512-giWQp+4mxjBPt4KZ0MmyuykFNWfbDxKt4x+fPkRYmgRFJSbCZFzUglvMb/Kjn38tm10YP4ufiQZDx3zna4LU6w==}
|
||||
peerDependencies:
|
||||
'@types/react': '*'
|
||||
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
peerDependenciesMeta:
|
||||
'@types/react':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-visually-hidden@1.2.3':
|
||||
resolution: {integrity: sha512-pzJq12tEaaIhqjbzpCuv/OypJY/BPavOofm+dbab+MHLajy277+1lLm6JFcGgF5eskJ6mquGirhXY2GD/8u8Ug==}
|
||||
peerDependencies:
|
||||
@@ -3669,8 +3801,12 @@ snapshots:
|
||||
|
||||
'@radix-ui/number@1.1.1': {}
|
||||
|
||||
'@radix-ui/number@1.1.2': {}
|
||||
|
||||
'@radix-ui/primitive@1.1.3': {}
|
||||
|
||||
'@radix-ui/primitive@1.1.5': {}
|
||||
|
||||
'@radix-ui/react-alert-dialog@1.1.15(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)':
|
||||
dependencies:
|
||||
'@radix-ui/primitive': 1.1.3
|
||||
@@ -3710,6 +3846,18 @@ snapshots:
|
||||
'@types/react': 19.2.14
|
||||
'@types/react-dom': 19.2.3(@types/react@19.2.14)
|
||||
|
||||
'@radix-ui/react-collection@1.1.12(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)':
|
||||
dependencies:
|
||||
'@radix-ui/react-compose-refs': 1.1.3(@types/react@19.2.14)(react@19.2.5)
|
||||
'@radix-ui/react-context': 1.2.0(@types/react@19.2.14)(react@19.2.5)
|
||||
'@radix-ui/react-primitive': 2.1.7(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)
|
||||
'@radix-ui/react-slot': 1.3.0(@types/react@19.2.14)(react@19.2.5)
|
||||
react: 19.2.5
|
||||
react-dom: 19.2.5(react@19.2.5)
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
'@types/react-dom': 19.2.3(@types/react@19.2.14)
|
||||
|
||||
'@radix-ui/react-collection@1.1.7(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)':
|
||||
dependencies:
|
||||
'@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.14)(react@19.2.5)
|
||||
@@ -3728,12 +3876,24 @@ snapshots:
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
|
||||
'@radix-ui/react-compose-refs@1.1.3(@types/react@19.2.14)(react@19.2.5)':
|
||||
dependencies:
|
||||
react: 19.2.5
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
|
||||
'@radix-ui/react-context@1.1.2(@types/react@19.2.14)(react@19.2.5)':
|
||||
dependencies:
|
||||
react: 19.2.5
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
|
||||
'@radix-ui/react-context@1.2.0(@types/react@19.2.14)(react@19.2.5)':
|
||||
dependencies:
|
||||
react: 19.2.5
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
|
||||
'@radix-ui/react-dialog@1.1.15(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)':
|
||||
dependencies:
|
||||
'@radix-ui/primitive': 1.1.3
|
||||
@@ -3762,6 +3922,12 @@ snapshots:
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
|
||||
'@radix-ui/react-direction@1.1.2(@types/react@19.2.14)(react@19.2.5)':
|
||||
dependencies:
|
||||
react: 19.2.5
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
|
||||
'@radix-ui/react-dismissable-layer@1.1.11(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)':
|
||||
dependencies:
|
||||
'@radix-ui/primitive': 1.1.3
|
||||
@@ -3887,6 +4053,15 @@ snapshots:
|
||||
'@types/react': 19.2.14
|
||||
'@types/react-dom': 19.2.3(@types/react@19.2.14)
|
||||
|
||||
'@radix-ui/react-primitive@2.1.7(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)':
|
||||
dependencies:
|
||||
'@radix-ui/react-slot': 1.3.0(@types/react@19.2.14)(react@19.2.5)
|
||||
react: 19.2.5
|
||||
react-dom: 19.2.5(react@19.2.5)
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
'@types/react-dom': 19.2.3(@types/react@19.2.14)
|
||||
|
||||
'@radix-ui/react-roving-focus@1.1.11(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)':
|
||||
dependencies:
|
||||
'@radix-ui/primitive': 1.1.3
|
||||
@@ -3959,6 +4134,25 @@ snapshots:
|
||||
'@types/react': 19.2.14
|
||||
'@types/react-dom': 19.2.3(@types/react@19.2.14)
|
||||
|
||||
'@radix-ui/react-slider@1.4.3(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)':
|
||||
dependencies:
|
||||
'@radix-ui/number': 1.1.2
|
||||
'@radix-ui/primitive': 1.1.5
|
||||
'@radix-ui/react-collection': 1.1.12(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)
|
||||
'@radix-ui/react-compose-refs': 1.1.3(@types/react@19.2.14)(react@19.2.5)
|
||||
'@radix-ui/react-context': 1.2.0(@types/react@19.2.14)(react@19.2.5)
|
||||
'@radix-ui/react-direction': 1.1.2(@types/react@19.2.14)(react@19.2.5)
|
||||
'@radix-ui/react-primitive': 2.1.7(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)
|
||||
'@radix-ui/react-use-controllable-state': 1.2.3(@types/react@19.2.14)(react@19.2.5)
|
||||
'@radix-ui/react-use-layout-effect': 1.1.2(@types/react@19.2.14)(react@19.2.5)
|
||||
'@radix-ui/react-use-previous': 1.1.2(@types/react@19.2.14)(react@19.2.5)
|
||||
'@radix-ui/react-use-size': 1.1.2(@types/react@19.2.14)(react@19.2.5)
|
||||
react: 19.2.5
|
||||
react-dom: 19.2.5(react@19.2.5)
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
'@types/react-dom': 19.2.3(@types/react@19.2.14)
|
||||
|
||||
'@radix-ui/react-slot@1.2.3(@types/react@19.2.14)(react@19.2.5)':
|
||||
dependencies:
|
||||
'@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.14)(react@19.2.5)
|
||||
@@ -3973,6 +4167,13 @@ snapshots:
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
|
||||
'@radix-ui/react-slot@1.3.0(@types/react@19.2.14)(react@19.2.5)':
|
||||
dependencies:
|
||||
'@radix-ui/react-compose-refs': 1.1.3(@types/react@19.2.14)(react@19.2.5)
|
||||
react: 19.2.5
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
|
||||
'@radix-ui/react-switch@1.2.6(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)':
|
||||
dependencies:
|
||||
'@radix-ui/primitive': 1.1.3
|
||||
@@ -4038,6 +4239,14 @@ snapshots:
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
|
||||
'@radix-ui/react-use-controllable-state@1.2.3(@types/react@19.2.14)(react@19.2.5)':
|
||||
dependencies:
|
||||
'@radix-ui/react-use-effect-event': 0.0.3(@types/react@19.2.14)(react@19.2.5)
|
||||
'@radix-ui/react-use-layout-effect': 1.1.2(@types/react@19.2.14)(react@19.2.5)
|
||||
react: 19.2.5
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
|
||||
'@radix-ui/react-use-effect-event@0.0.2(@types/react@19.2.14)(react@19.2.5)':
|
||||
dependencies:
|
||||
'@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.14)(react@19.2.5)
|
||||
@@ -4045,6 +4254,13 @@ snapshots:
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
|
||||
'@radix-ui/react-use-effect-event@0.0.3(@types/react@19.2.14)(react@19.2.5)':
|
||||
dependencies:
|
||||
'@radix-ui/react-use-layout-effect': 1.1.2(@types/react@19.2.14)(react@19.2.5)
|
||||
react: 19.2.5
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
|
||||
'@radix-ui/react-use-escape-keydown@1.1.1(@types/react@19.2.14)(react@19.2.5)':
|
||||
dependencies:
|
||||
'@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.14)(react@19.2.5)
|
||||
@@ -4058,12 +4274,24 @@ snapshots:
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
|
||||
'@radix-ui/react-use-layout-effect@1.1.2(@types/react@19.2.14)(react@19.2.5)':
|
||||
dependencies:
|
||||
react: 19.2.5
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
|
||||
'@radix-ui/react-use-previous@1.1.1(@types/react@19.2.14)(react@19.2.5)':
|
||||
dependencies:
|
||||
react: 19.2.5
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
|
||||
'@radix-ui/react-use-previous@1.1.2(@types/react@19.2.14)(react@19.2.5)':
|
||||
dependencies:
|
||||
react: 19.2.5
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
|
||||
'@radix-ui/react-use-rect@1.1.1(@types/react@19.2.14)(react@19.2.5)':
|
||||
dependencies:
|
||||
'@radix-ui/rect': 1.1.1
|
||||
@@ -4078,6 +4306,13 @@ snapshots:
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
|
||||
'@radix-ui/react-use-size@1.1.2(@types/react@19.2.14)(react@19.2.5)':
|
||||
dependencies:
|
||||
'@radix-ui/react-use-layout-effect': 1.1.2(@types/react@19.2.14)(react@19.2.5)
|
||||
react: 19.2.5
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
|
||||
'@radix-ui/react-visually-hidden@1.2.3(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)':
|
||||
dependencies:
|
||||
'@radix-ui/react-primitive': 2.1.3(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)
|
||||
|
||||
Reference in new issue
Block a user