sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
7d7849380dac244b69f2d3e5b457b871b4eed470be9ce4d188630c6f2b846673
TypeScript
609
21
// In-memory, per-tab share-token store keyed by roomId. // Never persisted (fresh share per tab lifetime). const store = new Map<string, string>(); export function rememberShareToken(roomId: string, token: string): void { store.set(roomId, token); } export function getShareToken(roomId: string): string | undefined ...
4b9695edcc10cacbda0450d5b53989c8c8e76460e59c6b9abe99324debf1fb07
TypeScript
646
31
/** * Simple room tracking for localStorage-based room persistence. * * Stores only the last visited room ID. */ const LAST_ROOM_KEY = "zndraw_last_room"; /** * Get the last visited room ID from localStorage. * * Returns * ------- * string | null * The room ID or null if not set. */ export function get...
3454a0b7df95bc8aa8170c11fdffd642201553d6c7ce9798594778585c3b9027
TypeScript
702
28
/** * Property Inspector types for per-particle and global property display. */ import type { PropertyMeta } from "../myapi/client"; export interface PropertyInfo { key: string; metadata: PropertyMeta; category: "per-particle" | "global"; prefix: string; // "arrays", "calc", "info", etc. enabled: boolean; } ex...
e2764e0182845f4bf348b6206465ef83f84797773f121b33832075e3942d8d54
TypeScript
729
21
/** * Checks if a value is a hex color string (e.g., "#FF5733" or "#abc") * @param value The value to check * @returns True if the value is a hex color string */ export const isHexColor = (value: any): boolean => { if (typeof value !== "string") return false; // Match #RGB or #RRGGBB format return /^#[0-9A-Fa-f]...
2ba7b7d70317139a6fd936e0c96cfc486cbeb4f13230eb9d98e68b733344d464
TypeScript
744
21
import { isAxiosError } from "axios"; /** * Coerce a thrown error (typically from axios) into a flat error string. * * Handles FastAPI's three common detail shapes: * - Plain string: returned as-is. * - Validation array: joined into a single semicolon-separated string. * - Missing/unknown: falls back to th...
a734eb00943b845f602aefa77e30343f98595ccf68739867c0e67f23c18e4439
TypeScript
747
25
/** * Layout constants for consistent spacing across the application. * These ensure proper alignment of fixed UI elements. */ export const LAYOUT_CONSTANTS = { /** Height of the top AppBar in pixels */ APPBAR_HEIGHT: 50, /** Height of the bottom FrameProgressBar in pixels */ PROGRESSBAR_HEIGHT: 45, /** Widt...
f140c46774e92faac18031dc309dfd25a5fb1941b5ff97e12fbb6d3e48a8edeb
TypeScript
787
25
/** * Utility functions for bookmark key conversion. * JSON serialization converts integer keys to strings, so we need to convert them back. */ /** * Convert bookmark string keys from JSON to number keys. * * @param bookmarks - Bookmarks object with string keys from JSON * @returns Bookmarks object with number ...
0d3042e54a28c46ba6558a1c9aeab74fc57751449f1ee848f0fce45eda70c470
TypeScript
793
26
import type { DockviewApi } from "dockview-react"; import { beforeEach, describe, expect, it } from "vitest"; import { useDockviewApi } from "../dockviewApiStore"; describe("dockviewApiStore", () => { beforeEach(() => { useDockviewApi.getState().setApi(null); }); it("defaults to null", () => { expect(useDockvi...
faa655d7ee21e260e84ba1efa4d3b83d0d65cdddaed6f23424ec497072227e1c
TypeScript
799
31
/** * Utility functions for downloading screenshots. */ /** * Download a screenshot blob to the client's browser. * * Creates a temporary download link and triggers a file download. * * @param blob - Screenshot PNG blob * @param filename - Optional filename (defaults to timestamp-based name) */ export functio...
133059eb7df4c083794d85a622131450bb6bbb56b1f4cab8615d99bbc01b89a3
TypeScript
833
38
export interface ChatMessage { id: number; room_id: string; user_id: string; content: string; created_at: string; // ISO datetime updated_at: string | null; email: string | null; } /** Socket event payload for `message_new`. Matches backend `MessageNew`. */ export interface MessageNewEvent { id: number; room_...
98d2bb91ad6863222aceffc087b1adce435b35c218dd78c85c3b4111e2db7f9b
TypeScript
845
24
import { useEffect } from "react"; import { useAppStore } from "../store"; /** * Registers frame data keys needed by a geometry for prefetching. * * Call from each geometry component with the list of frame-level keys * it will query (e.g. "arrays.positions", "arrays.colors"). The * prefetcher reads these registra...
8144138764c0c83ab25c75634b4be07f9b13b30da81a341eeeca933250dc5ce8
TypeScript
891
23
/** * Barrel re-exports for socket handler factories and types. * * Each handler factory accepts a HandlerContext and returns an object of * event handler functions. useSocketManager calls these factories inside * its useEffect, registers the handlers on socket.on(), and deregisters * them in the cleanup function...
dc96da6e346d4aa2f051c0cc7ad9d53444f3f3cfb712e47538042b9cc5efb65f
TypeScript
990
25
import { io } from "socket.io-client"; import { acquireToken, type AuthResult } from "./utils/auth"; import { getShareToken } from "./utils/shareToken"; export const socket = io(undefined, { autoConnect: false }); /** * (Re)connect the socket with a valid JWT. * * Always acquires a fresh token via acquireToken(), ...
f872fee6013c75da6fa0c010dc5070c0cb0167ddf671b833383f204bf7b29178
TypeScript
998
48
/** * Task status types matching backend TaskStatus enum values. */ export type TaskStatus = | "pending" | "claimed" | "running" | "completed" | "failed" | "cancelled"; /** * Task status event data received via socket. * Broadcast when task state changes (task_status_event). */ export interface TaskStatusEv...
d82a66711bb32a2154b231ce1bb96f93403d3add8ce3b6d4408821d95f853dc9
TypeScript
1,044
29
import type { StateCreator } from "zustand"; import type { AppState } from "../../../store"; import type { DrawingSubSlice } from "./drawingSubSlice"; import { createDrawingSubSlice } from "./drawingSubSlice"; import type { EditingSubSlice } from "./editingSubSlice"; import { createEditingSubSlice } from "./editingSub...
9c03245a5cc2b4bc294b309bbc426945a43d50df721c3d60db77d15ad432968c
TypeScript
1,046
41
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { type DefaultCameraResponse, getDefaultCamera, setDefaultCamera, } from "../myapi/client"; import { useAppStore } from "../store"; const defaultCameraKeys = { all: (roomId: string) => ["defaultCamera", roomId] as const, }; expo...
cd186ea7e0a6d544707cc4b96bbace3c3e73f4afca9d39623e65916835e87cd8
TypeScript
1,123
35
import * as THREE from "three"; /** * Reusable THREE.js objects to avoid creating new instances in render loops. * These objects reduce garbage collection pressure and improve performance. * * IMPORTANT: These objects are shared across all geometry components. * Always clone or copy values before storing them per...
4937ee34a10f76f7743e898989e37ff8355e0a1e9a1e40c41781bdf34e79cd80
TypeScript
1,166
51
import { vi } from "vitest"; // Mock the panels registry to avoid loading all panel components (which pull // in Three.js, plotly, etc.) via the activityBarSlice → registry chain. vi.mock("./panels/registry", () => ({ PANELS: { selections: { kind: "tool" }, modifiers: { kind: "tool" }, analysis: { kind: "tool" ...
e03f5b8c96190b5bb4f182012e7dc67aba92fa2b077363ad6d68bbb387f972a8
TypeScript
1,181
33
/** * Factory for creating consistent invalidate handlers. * * Fetches data from the server and updates the store. * Uses a `getRoomId` getter so the handler always reads the current roomId * at event-fire time (same behavior as the original closure). * * If the incoming event payload carries a `room_address` an...
d290373b14678df1eca9c5f22e7cf68eb18c512d2bfae59ca2aff5d6955a65cd
TypeScript
1,238
42
import { useQuery, useQueryClient } from "@tanstack/react-query"; import { useEffect } from "react"; import { listProviders } from "../myapi/client"; import { socket } from "../socket"; import { useAppStore } from "../store"; /** * Query hook for filesystem providers in the current room. * * Sets ``staleTime: 5_000...
7a38385228eaa34a748872997b7773ef5267f271e94dc8515dbcc402cf63d115
TypeScript
1,278
43
import type { DockviewApi } from "dockview-react"; import { useCallback } from "react"; import { useNavigate } from "react-router-dom"; import { useAppStore } from "../store"; type ApiResolver = DockviewApi | null | (() => DockviewApi | null); interface LeaveRoomOptions { api: ApiResolver; showConfirm?: (message: s...
628a4df9cc0f5bcedb8820ed80f604ead8c0a709b0b23738ae7dbdb6b911b590
TypeScript
1,369
46
import type { HandlerContext } from "./types"; /** Socket event payload for the `invalidate` event. */ export interface InvalidateEvent { roomId: string; userName: string; category: string; extension: string; sessionId?: string; } /** Socket event payload for the `schema_invalidate` event. */ export interface Sc...
d347b706df9a43a5486ea5961e597c83010320c1d3845d5db6b587f62b7e16cd
TypeScript
1,411
54
import { useInfiniteQuery, useMutation, useQueryClient, } from "@tanstack/react-query"; import { createChatMessage, editChatMessage, getChatMessages, } from "../myapi/client"; import type { ChatMessage, ChatMessagesResponse } from "../types/chat"; // Fetch chat messages with infinite scroll support export const ...
266247e0ef710e68cddbc10d342684d508f48cc2b51ab3033e5f054e36b9b961
TypeScript
1,444
72
import { create } from "zustand"; import { immer } from "zustand/middleware/immer"; type GeometryMode = "list" | "create" | "edit"; type GeometryState = { mode: GeometryMode; selectedKey: string | null; formData: Record<string, any>; selectedType: string | null; searchFilter: string; }; type GeometryActions = {...
3c1fcce5caf475200047c652b3a7cce73fdaab6107988edc6e5f19b03efd41e5
TypeScript
1,625
49
import { merge } from "lodash"; /** * Utility functions for handling geometry defaults from Pydantic models. * Follows Single Responsibility Principle - Pydantic is the single source of truth for defaults. */ /** * Merges geometry data with defaults from Pydantic models. * * This ensures that all required field...
70c861d95b2b2b72c3ace4ee3feca7f6de837e982f08d76465d83c08a866faec
TypeScript
1,635
63
/** * Form data persistence utilities using localStorage. * * Stores form data per room/user/job with a 7-day TTL. */ const FORM_STORAGE_PREFIX = "zndraw:form"; const FORM_TTL_MS = 7 * 24 * 60 * 60 * 1000; // 7 days interface StoredFormData { data: Record<string, unknown>; timestamp: number; } const getStorage...
1dec723e9d21a521e39c83e5a2ebfe645a88c42cc6fb9984d35a99ae957320fe
TypeScript
1,747
72
import { keepPreviousData, useQuery, useQueryClient, } from "@tanstack/react-query"; import { useEffect } from "react"; import { type Task, getFrameMetadata, listTasksForJob } from "../myapi/client"; import { socket } from "../socket"; import type { TaskStatusEvent } from "../types/jobs"; export type { Task }; exp...
f13c31bc0a9041fb20416f7de7fff43cbad283ca0f14953e88f4d0810c8c2f6a
TypeScript
1,752
53
import type { StateCreator } from "zustand"; import type { GlobalSettings } from "../../myapi/client"; import type { UserInfo } from "../../utils/auth"; import type { AppState, InitializationError } from "../../store"; export interface ConnectionSlice { roomId: string | null; user: UserInfo | null; sessionId: strin...
89279a774d9dabf2e55c474c7408cb1c19d00f8522bffd7c94ae160386a93be0
TypeScript
1,786
55
import { useDockviewApi } from "../../stores/dockviewApiStore"; import { closePlotTab, openPlotTab } from "../../panels/plotViewFactory"; import type { HandlerContext } from "./types"; /** Socket event payload for the `figure_invalidate` event. */ export interface FigureInvalidateEvent { key: string; operation?: "se...
4e6559fc5d9ae269d5d724672be8705665eb8defecd024083b56b3c4a094df4b
TypeScript
1,928
61
import type { DragEvent } from "react"; import { useCallback, useRef } from "react"; import { useAppStore } from "../store"; import type { BarPosition } from "./registry"; const DRAG_MIME = "application/x-zndraw-panel-id"; /** * Drag-hover state machine for an ActivityBar / SidebarZone / BottomZone. * * Tracks `dr...
0aad3f3f7516dbe38db907bc9496ec66bc8c1b4c40d18e9de8d8dbffbbf8933b
TypeScript
1,937
71
import { test, expect } from "@playwright/test"; import { BASE_URL, PY, waitForScene, createTestRoom } from "./helpers"; let ROOM: string; /** * Open the geometry panel by clicking the sidebar "Manage geometries" button. */ async function openGeometryPanel(page: import("@playwright/test").Page) { const manageBtn =...
7c09b187adead0d8eb0589e0e349211a43f9dd7101cf3f8a7a7353809ef20a58
TypeScript
2,172
86
import type { DockviewApi } from "dockview-react"; export function plotPanelId(figureKey: string): string { return `plot-${figureKey}`; } const PLOT_ID_PREFIX = "plot-"; const VIEWER_PANEL_ID = "viewer"; /** * Resolves which group a new plot tab should open in. * * Rules (first match wins): * 1. If any existing...
3e358285b74671f7ac538fc6765f0054a19de0979ddb6499ca7b88c9af5b5cf4
TypeScript
2,334
73
/** * React Query hooks for Property Inspector functionality. * Handles fetching and categorizing frame properties. */ import { keepPreviousData, useQueries, useQuery, useQueryClient, } from "@tanstack/react-query"; import { categorizeProperties, getFrameMetadata } from "../myapi/client"; import { getFrameBatch...
9a13ea3c52706deb8c2aa67bce8f6c3c6b01c92178b84a9ccf5e457578c65d40
TypeScript
2,429
66
import type { QueryClient } from "@tanstack/react-query"; import type { GlobalSettings } from "../../myapi/client"; import type { InitializationError, Progress } from "../../store"; import type { UserInfo } from "../../utils/auth"; /** * Flat dependency context passed to all handler factories. * * Fields mirror the...
cd777685dc67382cfca1a694f67fa5621bfebae2274fd9a5e42a0f0f4c224a01
TypeScript
2,471
89
import type { StateCreator } from "zustand"; import { updateSelection as updateSelectionAPI } from "../../../myapi/client"; import type { AppState } from "../../../store"; export interface SelectionSubSlice { selections: Record<string, number[]>; selectionGroups: Record<string, Record<string, number[]>>; setSelect...
5059c6c097ee2c107d825da5154992abeb1e46d06731064f3c25f37cd83fc6e9
TypeScript
2,562
85
// src/hooks/useMoleculeImage.ts // Custom hook for fetching and managing molecule images from SMILES notation // Uses react-query for efficient caching and deduplication import { useColorScheme } from "@mui/material/styles"; import { useQuery } from "@tanstack/react-query"; import { useEffect, useState } from "react"...
a6203997ea4764fbe6573a6a289aaabaf2f9d642d06ae1656063cd6ba4e840b0
TypeScript
2,613
95
import { debounce } from "lodash"; import { useEffect, useMemo, useRef } from "react"; import { createGeometry } from "../myapi/client"; import { useAppStore } from "../store"; /** * Hook for managing geometry persistence to the server * * Handles debounced persistence with proper cleanup and race condition prevent...
2e623d9893c597cb57c27bc182f4e7342783833f9aee2b9b750a835b8f24b99f
TypeScript
2,616
86
import { execSync, spawn, type ChildProcess } from "child_process"; import { writeFileSync, unlinkSync } from "fs"; import { tmpdir } from "os"; import { join } from "path"; import type { Page, Browser, BrowserContext } from "@playwright/test"; export const BASE_URL = process.env.ZNDRAW_URL || "http://localhost:8000";...
3727e7c0f3ec0b143e0a258d5fb2e835f0b4ee3f31233946865b88a81f394df2
TypeScript
2,642
88
import { test, expect } from "@playwright/test"; import { BASE_URL, PY, waitForScene, createTestRoom } from "./helpers"; let ROOM: string; test.describe("Chat Features", () => { test.describe.configure({ mode: "serial" }); test.beforeAll(() => { ROOM = createTestRoom("test-chat-features"); PY(` from zndraw imp...
219eabd0995236e33b59ba63a91cab51b65fa33521efb154d398f6212874015e
TypeScript
2,698
96
import { test, expect } from "@playwright/test"; import { BASE_URL, CLI, PY, waitForScene } from "./helpers"; const ROOM = "test-frame-invalidation"; test.describe("Frame Invalidation", () => { test.describe.configure({ mode: "serial" }); test.beforeAll(() => { CLI(`rooms create --room ${ROOM}`); PY(` from znd...
e0abefd64aa413850647c01fa08a09f1e0f815eeec8a076f5fcba2f41d51b4f6
TypeScript
2,801
92
import { useQueryClient } from "@tanstack/react-query"; import { useEffect, useRef } from "react"; import { useAppStore } from "../store"; import { prefetchFrame } from "./useFrameBatch"; const PREFETCH_AHEAD = 3; /** * Batch-prefetches upcoming frames during playback. * * Uses a Zustand store subscription (not a ...
9b25fac82c3d8d8633fed3a192ad9f10f0491aae7297ba93583c9b1569594ee6
TypeScript
2,831
104
import { useAppStore } from "../../store"; import type { HandlerContext } from "./types"; // --- Typed event interfaces --- export interface FrameUpdateEvent { frame: number; } export interface FramesInvalidateEvent { room_id: string; room_address: string; action: "add" | "delete" | "modify" | "clear"; indices?...
daf17f1f2a06858bb22cd0a3037b90268161321f5da7eac8db8c4354d9602509
TypeScript
2,959
105
/** * Parses a semantic version string into its components. * Handles pre-release versions like "0.6.0a4" and dev versions like "0.1.dev383+g..." */ export function parseVersion( version: string, ): { major: number; minor: number; patch: number } | null { // Handle dev versions: "0.1.dev383+g..." -> treat as X.Y.0...
e4f83a7dacca51997f3579dcc6c8f665dfacc856dd9233fdc48a0fc6d6d24596
TypeScript
3,017
117
import { execSync } from "node:child_process"; import react from "@vitejs/plugin-react-swc"; import { defineConfig } from "vitest/config"; /** * Gets the Python package version from the installed zndraw package. * Falls back to "0.0.0-dev" if unable to retrieve. */ function getPythonPackageVersion(): string { try ...
a0915af6361e8b5d2a4d5827fadf6e9c739bc6c8135067240975e6f882493a16
TypeScript
3,043
115
/** * Utility functions for formatting property values consistently across components. * Centralizes formatting logic to maintain DRY principle. */ import type { PropertyInfo } from "../types/property-inspector"; /** * Check if a value is array-like (includes regular arrays and TypedArrays). */ export const isAr...
b23fa5f77e9712949ffc940413cbfe006d50ae5ea83e3d80d9ee00903ec9982d
TypeScript
3,093
109
import { useAppStore } from "../../store"; import type { MessageEditedEvent, MessageNewEvent } from "../../types/chat"; import type { HandlerContext } from "./types"; /** Socket event payload for the `typing` event. */ export interface TypingEvent { user_id: string; email: string; is_typing: boolean; } interface C...
71d26c395ada654cad59524049ceb3ac2ba3d0e74701b8d0b4ad1a558c7917c5
TypeScript
3,192
116
import { useQuery, useQueryClient } from "@tanstack/react-query"; import { useEffect, useMemo } from "react"; import { getJobSchema, listJobs } from "../myapi/client"; import { socket } from "../socket"; type DisplayScope = "public" | "internal" | "private"; export interface ParsedJobName { scope: string; displaySc...
6414e1165b99cc9ceb91e5a9d6f511fbd7f5d3db213f10306003f4fd6e27eb24
TypeScript
3,195
117
import { throttle } from "lodash"; import { useCallback, useEffect, useMemo, useState } from "react"; import { updateStep } from "../myapi/client"; import { socket } from "../socket"; import { useAppStore } from "../store"; interface StepControlHook { setStep: (frame: number) => void; remoteLocked: boolean; } /** ...
6845d02771abb2cd874de7b94476fe185d820fa071dfb6bdfdff4480c32ae0e0
TypeScript
3,206
113
import type * as THREE from "three"; import type { StateCreator } from "zustand"; import { createGeometry, getGeometry } from "../../../myapi/client"; import type { AppState } from "../../../store"; import { getActiveCurves, selectPreferredCurve } from "./geometrySubSlice"; export interface DrawingSubSlice { drawingP...
bcacf84e2003b34603d0e7f38dbde91852636083fd86b80ae64bfd32e301e822
TypeScript
3,208
101
import { type RefObject, useCallback, useEffect, useRef } from "react"; import type * as THREE from "three"; import { useAppStore } from "../store"; import { convertInstancedMeshToMerged, disposeMesh, } from "../utils/convertInstancedMesh"; /** * Hook that manages the merged mesh for GPU pathtracing. * * GPU path...
5b48a63357d0541dc3e5bf24a07af635e5eacaaf4b39ddb3930ac3c173defdfe
TypeScript
3,243
96
/** * Hook to access PropertyInspector settings and fetch property values. * PropertyInspector is now a scene geometry object. * * Performance optimized: * - Category filtering to avoid fetching unused properties * - Conditional fetching based on enabled state * - Memoized property categorization */ import { u...
3570ea1d83d92ffcbcfb0c668d3eae9de1a5039ad5e77dec9609a287894462b4
TypeScript
3,316
114
import type { StateCreator } from "zustand"; import type { AppState, Progress } from "../../store"; export interface UISlice { chatUnreadCount: number; typingUsers: Set<string>; snackbar: { open: boolean; message: string; severity: "success" | "info" | "warning" | "error"; } | null; progressTrackers: Record...
81cf8ee6094f6e9e7dc45cc885f20ceb39904ed73ffbc58e150f3b9971e7de61
TypeScript
3,332
132
import type { Room } from "../../myapi/client"; import { useRoomsStore } from "../../roomsStore"; import { useAppStore } from "../../store"; import type { HandlerContext } from "./types"; // --- Typed event interfaces --- export interface RoomUpdateEvent { room_id: string; frame_count?: number | null; [key: string...
111d928542e2941e9cc7ff696f7da2d8e69436ca035b50215f632077e91e39d9
TypeScript
3,437
119
/** * Camera utilities for handling CurveAttachment and position resolution. * * Cameras can use either direct coordinates or CurveAttachment for position/target. * These utilities help resolve and type-check camera position types. */ /** * CurveAttachment references a Curve geometry with progress along the curv...
bdc6743e98e73e6601de61d4d5eedc3719dbed309e32992b0ad2f6953cd45d9a
TypeScript
3,483
129
import { useEffect, useState } from "react"; import { isCurveAttachment } from "../utils/cameraUtils"; export interface ControlsState { enabled: boolean; enablePan: boolean; enableRotate: boolean; enableZoom: boolean; /** Whether position can be changed (XYZ mode) */ positionEditable: boolean; /** Whether targe...
490bd8f4515142986a5e3195e7279dbb83dac0a27a8fcca451b34b99dde583d7
TypeScript
3,560
143
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { type GeometryListResponse, type GeometryResponse, createGeometry, deleteGeometry, getGeometry, listGeometries, } from "../myapi/client"; /** * Hook to fetch the list of geometry keys for a room */ export const useGeometries...
a693a78ae1ac26628499f0f8801ae43a98a5bb75ee7b4e5ba6677afeb0e25f30
TypeScript
3,575
149
import type { Task } from "../hooks/useSchemas"; import type { TaskStateDuration, TaskStatus } from "../types/jobs"; /** * Calculate duration spent in each task state * @param task Task object with timestamps * @returns TaskStateDuration object with durations in milliseconds */ export function calculateTaskDuratio...
ab551fffe60d3e7e9dbb71611a8ec49fa4019cbe45f3fc73dd59663b1e9642e9
TypeScript
3,805
130
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { type FigureData, type FigureListResponse, createFigure, deleteFigure, getFigure, listFigures, } from "../myapi/client"; import { useAppStore } from "../store"; // Define query keys for caching and invalidation const figuresKe...
14ee26350918b6399903d3032c8f5dcbb69343aed601b31c181951db0e73231f
TypeScript
3,973
131
import type { StateCreator } from "zustand"; import { deleteBookmark as deleteBookmarkAPI, setBookmark as setBookmarkAPI, updateFrameSelection as updateFrameSelectionAPI, } from "../../myapi/client"; import type { AppState } from "../../store"; export interface PlaybackSlice { currentFrame: number; frameCount: nu...
22878c08b7ce281ddbea5361d8138b68f88408a93c14cc7b19fd4f7973236603
TypeScript
3,974
144
/** * Hook for syncing OrbitControls changes back to Camera geometry via REST. * * When attached to a Camera geometry with XYZ (direct coordinate) position/target, * user interactions via OrbitControls update the geometry data. */ import { debounce } from "lodash"; import { useCallback, useEffect, useMemo, useRef...
8e9a95759b04665f699c494e4a89906bcc29982ed499b628277e38f50e558d90
TypeScript
4,203
132
import { useEffect, useRef } from "react"; import { useAppStore } from "../store"; /** * Hook to track frame load time when not playing. * Measures the time from when a frame changes until the scene is fully rendered. * Uses Zustand subscription for efficient change detection instead of RAF polling. */ export cons...
2d9d0e5a664619dfd4a514bb92e1fd41e8e5151b2ec6610dd66f8b0205665a1d
TypeScript
4,389
135
import { beforeEach, describe, expect, it } from "vitest"; import { useAppStore } from "../../../store"; describe("activityBarSlice", () => { beforeEach(() => { useAppStore.getState().resetLayout(); }); it("initial state has all tool panels on left bar", () => { const s = useAppStore.getState(); expect(s.lef...
4cae1661cc40a164e94b7b5c47bddd58fc4646d4af6a999f5ca91c58e9f13f20
TypeScript
4,433
172
import type { StateCreator } from "zustand"; import { acquireEditLock, getEditLockStatus, releaseEditLock, } from "../../myapi/client"; import type { AppState } from "../../store"; export interface LockSlice { userLock: string | null; userLockMessage: string | null; lockToken: string | null; lockRenewalInterval...
7518a0062d52e734f1b5f614eeefe99fea014520db2d0fa71a424b3183c8a9e3
TypeScript
4,573
149
import { test, expect } from "@playwright/test"; import { BASE_URL, CLI, PY, waitForScene } from "./helpers"; const ROOM = "test-geometry"; const ROOM_DEL = "test-geometry-del"; /** * Open the geometry panel by clicking the sidebar "Manage geometries" button. * The button is a ListItemButton inside a Tooltip with t...
1aad4e24b902e4d4b05e8f8e50043239d6dc73fd36224b99449a556cc31e3305
TypeScript
5,034
182
import type { StateCreator } from "zustand"; import type { AppState } from "../../store"; import { type BarPosition, BOTTOM_DEFAULT_PX, BOTTOM_MAX_PX, BOTTOM_MIN_PX, getDefaultsForBar, type PanelId, PANELS, SIDEBAR_DEFAULT_PX, SIDEBAR_MAX_PX, SIDEBAR_MIN_PX, } from "../../panels/registry"; export interface A...
5e28afd17d5b1b8f199361852bb5d0b495c4343e8aaa7f60199203ed2a577340
TypeScript
5,037
171
import { test, expect } from "@playwright/test"; import { BASE_URL, CLI, PY, waitForScene } from "./helpers"; const ROOM = "test-camera-session"; /** Open the geometry panel by clicking sidebar button. */ async function openGeometryPanel(page: import("@playwright/test").Page) { await page.getByRole("button", { name:...
5f8cb1f0b35fb9637837a438c60d6d06415c193c775790143ed543f9a1a1147a
TypeScript
5,106
118
import { materialRenderers } from "@jsonforms/material-renderers"; import CustomColorPicker, { customColorPickerTester, } from "../components/jsonforms-renderers/CustomColorPicker"; import CustomDynamicEnumWithColorPicker, { customDynamicEnumWithColorPickerTester, } from "../components/jsonforms-renderers/CustomDynam...
6e22cf248bd7f7a60a3250e6ad52e9116de55cab958d55e55df0c7a7ea6c7dbb
TypeScript
5,236
188
import { type GeometryData, getAllBookmarks, getGeometry, listGeometries, listSelectionGroups, } from "../../myapi/client"; import { useAppStore } from "../../store"; import type { HandlerContext } from "./types"; import { createInvalidateHandler } from "./utils"; // --- Typed event interfaces --- export interfa...
31b3fc9debfd47a704a4a3173385594fa1443e982892b86c6e4117acbff0e757
TypeScript
5,294
190
/** * Authentication utilities for browser client. * * Uses fastapi-users backend (zndraw-auth): * - Guest: POST /v1/auth/guest → {access_token, token_type} * - Login: POST /v1/auth/jwt/login → {access_token, token_type} * - Register: POST /v1/auth/register → UserRead (no token) * - User info: GET /v1/auth/users...
5dfafa97ab4900ab542470d07d5228abe93b97f7ebd5d0ceed51db0889a8de9a
TypeScript
5,393
204
import { test, expect } from "@playwright/test"; import { BASE_URL, CLI, PY, waitForScene } from "./helpers"; const ROOM = "test-editing"; const ROOM_LOCK = "test-editing-lock"; function setupRoom(room: string) { CLI(`rooms create --room ${room}`); PY(` from zndraw import ZnDraw import ase vis = ZnDraw(url='${BASE_...
2370679b8ef703413bdfffb3bee96dbf1a2c4b151a1d9f42c26df50517db5eb5
TypeScript
5,539
183
import type { QueryClient } from "@tanstack/react-query"; import { type FrameResponse, getFrames } from "../myapi/client"; /** Max retries for retriable 404s (provider computing frames). */ const MAX_RETRIES = 15; interface PendingBatch { keys: Set<string>; promise: Promise<FrameResponse | null>; controller: Abort...
f986c612d80ee8b983d7799756adfff8cc4c74b6e2fb0cee4c4fe371ebe7c7d7
TypeScript
5,766
183
import { test, expect } from "@playwright/test"; import { BASE_URL, CLI, PY, waitForScene } from "./helpers"; const ROOM = "test-extensions"; /** * Open the modifier panel by clicking the sidebar "Modifier tools" button * and wait for the panel heading to appear. */ async function openModifierPanel(page: import("@...
59c4830ab86cf60e05b5d9ea13f91bd0e3918e4ef166f435ec33e95e60c3ab12
TypeScript
6,203
214
import type * as THREE from "three"; import type { StateCreator } from "zustand"; import { partialUpdateFrame } from "../../../myapi/client"; import type { AppState } from "../../../store"; export interface EditingSubSlice { transformMode: "translate" | "rotate" | "scale"; editingSelectedAxis: "x" | "y" | "z" | null...
e101e07c6ae0289be3ec6e819749b29f3e3b14a3ddc13b6046b2f15cc8011c99
TypeScript
6,552
196
import { test, expect } from "@playwright/test"; import { BASE_URL, CLI, PY, waitForScene } from "./helpers"; const ROOM = "test-frames"; /** * Wait for the frame counter to show the expected total frame count, * confirming that all frames have been indexed by the frontend. */ async function waitForFrameCount( pa...
4babaf752f949de8562c73f4b2dc5cf8a111298306c1e401660cf1be4dd18b24
TypeScript
6,826
230
import { test, expect } from "@playwright/test"; import { BASE_URL, CLI, PY, waitForScene, spawnPY, waitForBgReady, createTestRoom, } from "./helpers"; test.describe("Registration", () => { test.describe.configure({ mode: "serial" }); test("register_job makes extension appear in modifier panel", async ({ p...
edfc754d6ed7053bae07c67a509f5fc2b36aaacbcf7c7298802d68e54dac97d5
TypeScript
6,932
240
/** * Transform processor for filtering geometry data based on frame data. * * Transforms allow dynamic filtering of geometry properties (positions, radii, colors) * based on indices extracted from frame data (e.g., constraint indices). */ /** * InArrayTransform filters array data to only include elements at spe...
232c866d6ee7e07e26d766185187098a953a16282981bff5cda0634f8a23ad95
TypeScript
7,081
226
import type * as THREE from "three"; import type { StateCreator } from "zustand"; import { createGeometry, getGeometry, updateActiveCamera, } from "../../../myapi/client"; import type { AppState } from "../../../store"; /** Returns keys of active curves. */ export const getActiveCurves = (geometries: Record<string,...
4cb15abe10d7f09e61dc78758b41ffa77229376e43a9fbee5ae76314a03d4b6b
TypeScript
7,086
255
import { test, expect } from "@playwright/test"; import { BASE_URL, CLI, PY, waitForScene, createAuthContext, createTestRoom, } from "./helpers"; let ROOM: string; test.describe("Socket Sync — Multi-Tab", () => { test.describe.configure({ mode: "serial" }); test.beforeAll(() => { ROOM = createTestRoom("tes...
412e2b7e915138e5dd206c14067cb6025df128aac802c6a2b8e322e96f029244
TypeScript
7,135
255
import { useCallback, useEffect } from "react"; import { useAppStore } from "../store"; import { isInputFocused } from "../utils/keyboard"; import { useStepControl } from "./useStepControl"; export const useKeyboardShortcuts = () => { const currentFrame = useAppStore((state) => state.currentFrame); const frameCount ...
e83039431b2ff55cb39b390fb4022e30d013fa4c94bf2c0b3697632587d5ccb1
TypeScript
7,658
231
import * as THREE from "three"; /** * Converts an InstancedMesh to a single merged Mesh with vertex colors. * Required for GPU path tracing which does not support instancing. * * This is FAR more efficient than creating N individual meshes: * - Memory: 1 geometry + 1 material instead of N geometries + N materials...
28652fd3f0b8c4a9a8026bb3bb2f74a85fdfafc08b44f6622e89ae41f70c21db
TypeScript
8,059
254
import { test, expect } from "@playwright/test"; import { BASE_URL, PY, createTestRoom } from "./helpers"; let ROOM: string; test.describe("UI Panels & Chat", () => { test.describe.configure({ mode: "serial" }); test.beforeAll(() => { ROOM = createTestRoom("test-ui"); PY(` from zndraw import ZnDraw import ase ...
5eaad357edd4cb75faa38cf222d3348bba80ad0210f7b1070751b326bf577589
TypeScript
8,285
248
import { useQueryClient } from "@tanstack/react-query"; import { useEffect, useRef } from "react"; import type * as THREE from "three"; import { useAppStore } from "../store"; import { applyTransformToPositions, convertFloat32ToPositionArray, convertPositionArrayToFloat32, getRelativePositions, } from "../utils/geo...
7cb4325d7b7cf6138d9c63a391ad4bace3b4ee9c98b23d08083226c203ce0d80
TypeScript
8,667
239
import { useQueryClient } from "@tanstack/react-query"; import { useEffect } from "react"; import { connectWithAuth, socket } from "../socket"; import { useAppStore } from "../store"; import { createChatHandlers, createConnectionHandlers, createFigureHandlers, createFrameHandlers, createGeometryHandlers, createRo...
aabe05b7f6715f83caa916c1ff2712ce34feec247fc0203a8c868668886c6b5a
TypeScript
9,330
311
import { createRoom, type GeometryData, getEditLockStatus, getFrameSelection, getGlobalSettings, getServerVersion, listGeometries, listSelectionGroups, getAllBookmarks, } from "../../myapi/client"; import { connectWithAuth, socket } from "../../socket"; import { useAppStore } from "../../store"; import { logou...
5fdb3556e531d4c5f42d803c75f0f73847753ba87b08623041f946aa6742d14e
TypeScript
11,331
403
/** * Type definitions for geometry data props. * Backend uses strict list-only format: * - Position/Rotation/Scale: string (dynamic) | number[][] (Vec3 list) * - Color: string (dynamic) | string[] * - Size/Radius: string (dynamic) | number[] * Single-element lists broadcast to all instances. */ import { type T...
b75989e879142f841fbe25008dde9253872ccfa62fec22190fe6ed31d1d127b2
TypeScript
12,067
435
/** * Utility functions for array editing in geometry forms. * All configuration is derived from JSON schema - no hardcoded field types. */ /** * CSS hex color string type (e.g., "#FF0000"). * Matches three.js Color.set() expected format for hex strings. */ export type HexColorString = `#${string}`; /** * Chec...
551e08820ce7ee2e3b4bda7cf7dd91855ecf08bbf1d5cf3c0fd16071619efce1
TypeScript
12,359
374
import { useEffect, useMemo, useRef } from "react"; import * as THREE from "three"; import { useAppStore } from "../store"; import { type ScaleData as UtilScaleData, applyTransformToPositions, applyTransformToRotations, applyTransformToScales, getInitialRotations, getInitialScales, getRelativePositions, isPosit...
51b9ec982f417222489ff6411a5173290b008958a0683f21ee23956bb33324e8
TypeScript
14,353
485
/** * TypeScript implementation of msgpack-numpy decoder. * * This is a rewrite of https://github.com/emerald-geomodelling/msgpack-numpy-js * with the following improvements: * - TypeScript for type safety * - Returns multi-dimensional arrays in row-major (C-order) format * - Avoids double loops and transpositio...
ddafa7bb700c790a831564649b81a0a37c2ebbea7acff310f01f13009a8dfa2b
TypeScript
20,435
692
import * as THREE from "three"; /** * Utility functions for geometry editing with transform controls */ // Type for static scale data from backend (always per-instance anisotropic) export type ScaleData = [number, number, number][]; /** * Check if a position property is static (number[][]) rather than dynamic (st...
e0abfa5fe4a5d63975f3ef9938e3b6f440d1faa3cb9e607e81ad50f253b540fb
TypeScript
30,014
905
import { test } from "@playwright/test"; import * as path from "path"; import { fileURLToPath } from "url"; import { BASE_URL, PY, waitForScene, spawnPY, waitForBgReady } from "./helpers"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const SCREENSHOTS_DIR = path.resolv...
aad5a9d38df59f446634f2f6c83efb4acd35b067151a51ffe8293c1d2172d800
TypeScript
33,801
1,326
import axios from "axios"; import { useAppStore } from "../store"; import { acquireToken, getToken, logout } from "../utils/auth"; import { getShareToken } from "../utils/shareToken"; import { packBinary, unpackBinary } from "../utils/msgpack-numpy"; import type { ChatMessage, ChatMessagesResponse } from "../types/chat...