@buildcores/render-client 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,379 @@
1
+ import * as React$1 from 'react';
2
+ import React__default, { RefObject } from 'react';
3
+
4
+ interface BuildRenderProps {
5
+ /**
6
+ * Parts configuration for the build render.
7
+ *
8
+ * This object defines which PC components should be included in the 3D render.
9
+ * Each part category contains an array with a single part ID that will be rendered.
10
+ *
11
+ * **Current Limitation**: Only 1 part per category is supported. Arrays must contain
12
+ * exactly one part ID per category. Future versions will support multiple parts per category.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * const parts = {
17
+ * parts: {
18
+ * CPU: ["7xjqsomhr"], // AMD Ryzen 7 9800X3D
19
+ * GPU: ["z7pyphm9k"], // ASUS GeForce RTX 5080 ASTRAL
20
+ * RAM: ["dpl1iyvb5"], // PNY DDR5
21
+ * Motherboard: ["iwin2u9vx"], // Asus ROG STRIX X870E-E GAMING WIFI
22
+ * PSU: ["m4kilv190"], // LIAN LI 1300W
23
+ * Storage: ["0bkvs17po"], // SAMSUNG 990 EVO
24
+ * PCCase: ["qq9jamk7c"], // MONTECH KING 95 PRO
25
+ * CPUCooler: ["62d8zelr5"], // ARCTIC LIQUID FREEZER 360
26
+ * }
27
+ * };
28
+ *
29
+ * <BuildRender parts={parts} size={300} />
30
+ * ```
31
+ *
32
+ * @example Minimal build (only required components)
33
+ * ```tsx
34
+ * const parts = {
35
+ * parts: {
36
+ * CPU: ["7xjqsomhr"], // Single CPU required
37
+ * Motherboard: ["iwin2u9vx"], // Single motherboard required
38
+ * PCCase: ["qq9jamk7c"], // Single case required
39
+ * }
40
+ * };
41
+ * ```
42
+ *
43
+ * Note: Part IDs must correspond to valid components in the BuildCores database.
44
+ * Use the available parts API to get valid part IDs for each category.
45
+ */
46
+ parts: RenderBuildRequest;
47
+ /**
48
+ * Video size in pixels (width and height will be the same).
49
+ *
50
+ * This determines the resolution of the rendered 3D video. Higher values
51
+ * provide better quality but may impact performance.
52
+ *
53
+ * @example
54
+ * ```tsx
55
+ * <BuildRender parts={parts} size={300} /> // 300x300px
56
+ * <BuildRender parts={parts} size={500} /> // 500x500px
57
+ * <BuildRender parts={parts} size={800} /> // 800x800px - high quality
58
+ * ```
59
+ *
60
+ * Recommended sizes:
61
+ * - 300px: Good for thumbnails or small previews
62
+ * - 500px: Standard size for most use cases
63
+ * - 800px+: High quality for detailed viewing
64
+ */
65
+ size: number;
66
+ /**
67
+ * Optional mouse sensitivity for dragging (default: 0.005).
68
+ *
69
+ * Controls how responsive the 3D model rotation is to mouse movements.
70
+ * Lower values make rotation slower and more precise, higher values make it faster.
71
+ *
72
+ * @example
73
+ * ```tsx
74
+ * <BuildRender
75
+ * parts={parts}
76
+ * size={300}
77
+ * mouseSensitivity={0.003} // Slower, more precise
78
+ * />
79
+ *
80
+ * <BuildRender
81
+ * parts={parts}
82
+ * size={300}
83
+ * mouseSensitivity={0.01} // Faster rotation
84
+ * />
85
+ * ```
86
+ *
87
+ * @default 0.005
88
+ */
89
+ mouseSensitivity?: number;
90
+ /**
91
+ * Optional touch sensitivity for dragging (default: 0.01).
92
+ *
93
+ * Controls how responsive the 3D model rotation is to touch gestures on mobile devices.
94
+ * Generally set higher than mouseSensitivity for better touch experience.
95
+ *
96
+ * @example
97
+ * ```tsx
98
+ * <BuildRender
99
+ * parts={parts}
100
+ * size={300}
101
+ * touchSensitivity={0.008} // Slower touch rotation
102
+ * />
103
+ *
104
+ * <BuildRender
105
+ * parts={parts}
106
+ * size={300}
107
+ * touchSensitivity={0.015} // Faster touch rotation
108
+ * />
109
+ * ```
110
+ *
111
+ * @default 0.01
112
+ */
113
+ touchSensitivity?: number;
114
+ }
115
+ /**
116
+ * Enum defining all available PC part categories that can be rendered.
117
+ *
118
+ * Each category represents a different type of computer component that can be
119
+ * included in the 3D build visualization.
120
+ *
121
+ * @example
122
+ * ```tsx
123
+ * // All available categories
124
+ * const categories = [
125
+ * PartCategory.CPU, // "CPU"
126
+ * PartCategory.GPU, // "GPU"
127
+ * PartCategory.RAM, // "RAM"
128
+ * PartCategory.Motherboard,// "Motherboard"
129
+ * PartCategory.PSU, // "PSU"
130
+ * PartCategory.Storage, // "Storage"
131
+ * PartCategory.PCCase, // "PCCase"
132
+ * PartCategory.CPUCooler, // "CPUCooler"
133
+ * ];
134
+ * ```
135
+ */
136
+ declare enum PartCategory {
137
+ /** Central Processing Unit - The main processor */
138
+ CPU = "CPU",
139
+ /** Graphics Processing Unit - Video card for rendering */
140
+ GPU = "GPU",
141
+ /** Random Access Memory - System memory modules */
142
+ RAM = "RAM",
143
+ /** Main circuit board that connects all components */
144
+ Motherboard = "Motherboard",
145
+ /** Power Supply Unit - Provides power to all components */
146
+ PSU = "PSU",
147
+ /** Storage devices like SSDs, HDDs, NVMe drives */
148
+ Storage = "Storage",
149
+ /** PC Case - The enclosure that houses all components */
150
+ PCCase = "PCCase",
151
+ /** CPU Cooler - Air or liquid cooling for the processor */
152
+ CPUCooler = "CPUCooler"
153
+ }
154
+ /**
155
+ * Request structure for rendering a PC build.
156
+ *
157
+ * This interface defines the parts configuration that will be sent to the
158
+ * rendering service to generate a 3D visualization of a PC build.
159
+ *
160
+ * **Current Limitation**: Only one part per category is supported. Each category
161
+ * array must contain exactly one part ID. Future versions will support multiple
162
+ * parts per category for comparison views.
163
+ *
164
+ * @example Basic build configuration
165
+ * ```tsx
166
+ * const buildRequest: RenderBuildRequest = {
167
+ * parts: {
168
+ * CPU: ["7xjqsomhr"], // AMD Ryzen 7 9800X3D
169
+ * GPU: ["z7pyphm9k"], // ASUS GeForce RTX 5080 ASTRAL
170
+ * RAM: ["dpl1iyvb5"], // PNY DDR5
171
+ * Motherboard: ["iwin2u9vx"], // Asus ROG STRIX X870E-E GAMING WIFI
172
+ * PSU: ["m4kilv190"], // LIAN LI 1300W
173
+ * Storage: ["0bkvs17po"], // SAMSUNG 990 EVO
174
+ * PCCase: ["qq9jamk7c"], // MONTECH KING 95 PRO
175
+ * CPUCooler: ["62d8zelr5"], // ARCTIC LIQUID FREEZER 360
176
+ * }
177
+ * };
178
+ * ```
179
+ *
180
+ * @example Minimal build (only required components)
181
+ * ```tsx
182
+ * const minimalBuild: RenderBuildRequest = {
183
+ * parts: {
184
+ * CPU: ["7xjqsomhr"], // Single CPU
185
+ * Motherboard: ["iwin2u9vx"], // Single motherboard
186
+ * PCCase: ["qq9jamk7c"], // Single case
187
+ * }
188
+ * };
189
+ * ```
190
+ *
191
+ * @example Gaming build configuration
192
+ * ```tsx
193
+ * const gamingBuild: RenderBuildRequest = {
194
+ * parts: {
195
+ * CPU: ["x2thvstj3"], // AMD Ryzen 7 9700X
196
+ * GPU: ["4a0mjb360"], // PNY GeForce RTX 5060 Ti 16GB
197
+ * RAM: ["46rwpop35"], // G.SKILL NEO RGB DDR5
198
+ * Motherboard: ["xy81tonxw"], // Asus ROG STRIX B850-A GAMING WIFI
199
+ * PSU: ["v0qv6k9dp"], // MSI 850W
200
+ * Storage: ["0bs8cxv4c"], // CORSAIR T500
201
+ * PCCase: ["kb76dp9aw"], // LIAN LI O11 VISION
202
+ * CPUCooler: ["0vajcxkzq"], // BE QUIET PURE ROCK 2 AIR
203
+ * }
204
+ * };
205
+ * ```
206
+ */
207
+ interface RenderBuildRequest {
208
+ /**
209
+ * Object mapping part categories to arrays of part IDs.
210
+ *
211
+ * **Current Requirements**:
212
+ * - Keys are part categories (CPU, GPU, RAM, etc.)
213
+ * - Values are arrays containing exactly one part ID string
214
+ * - All categories are optional - include only the parts you want to render
215
+ * - Part IDs must be valid identifiers from the BuildCores parts database
216
+ *
217
+ * **Future Enhancement**: Multiple parts per category will be supported for comparison views.
218
+ *
219
+ * @see PartCategory for all available categories
220
+ * @see AvailablePartsResponse for getting valid part IDs
221
+ */
222
+ parts: {
223
+ [K in PartCategory]?: string[];
224
+ };
225
+ }
226
+ /**
227
+ * Response structure containing all available parts for each category.
228
+ *
229
+ * This type represents the response from the available parts API endpoint,
230
+ * providing arrays of valid part IDs for each component category.
231
+ *
232
+ * @example Using available parts response
233
+ * ```tsx
234
+ * const availableParts: AvailablePartsResponse = {
235
+ * CPU: [
236
+ * { id: "7xjqsomhr", name: "AMD Ryzen 7 9800X3D", image: "https://..." },
237
+ * { id: "x2thvstj3", name: "AMD Ryzen 7 9700X", image: "https://..." },
238
+ * ],
239
+ * GPU: [
240
+ * { id: "z7pyphm9k", name: "ASUS GeForce RTX 5080 ASTRAL", image: "https://..." },
241
+ * { id: "4a0mjb360", name: "PNY GeForce RTX 5060 Ti 16GB", image: "https://..." },
242
+ * ],
243
+ * // ... all other categories
244
+ * };
245
+ *
246
+ * // Select one part per category for current build request
247
+ * const buildRequest: RenderBuildRequest = {
248
+ * parts: {
249
+ * CPU: [availableParts.CPU[0].id], // Select first available CPU ID
250
+ * GPU: [availableParts.GPU[1].id], // Select second available GPU ID
251
+ * RAM: [availableParts.RAM[0].id], // Select first available RAM ID
252
+ * }
253
+ * };
254
+ * ```
255
+ *
256
+ * @example Dynamic part selection
257
+ * ```tsx
258
+ * // Function to create build with user-selected parts
259
+ * const createBuild = (selectedPartIds: Record<string, string>) => {
260
+ * const buildRequest: RenderBuildRequest = {
261
+ * parts: {
262
+ * CPU: [selectedPartIds.cpu], // Single selected CPU ID
263
+ * GPU: [selectedPartIds.gpu], // Single selected GPU ID
264
+ * RAM: [selectedPartIds.ram], // Single selected RAM ID
265
+ * // ... other single selections
266
+ * }
267
+ * };
268
+ * return buildRequest;
269
+ * };
270
+ * ```
271
+ */
272
+ /**
273
+ * Individual part information with details
274
+ */
275
+ interface PartDetails {
276
+ /** Unique part identifier */
277
+ id: string;
278
+ /** Human-readable part name */
279
+ name: string;
280
+ /** URL to part image */
281
+ image: string;
282
+ }
283
+ type AvailablePartsResponse = {
284
+ [K in PartCategory]: PartDetails[];
285
+ };
286
+
287
+ declare const BuildRender: React.FC<BuildRenderProps>;
288
+
289
+ declare const calculateCircularTime: (startTime: number, deltaX: number, sensitivity: number, duration: number) => number;
290
+ interface UseVideoScrubbingOptions {
291
+ mouseSensitivity?: number;
292
+ touchSensitivity?: number;
293
+ progressSensitivity?: number;
294
+ useProgressScrubbing?: boolean;
295
+ }
296
+ declare const useVideoScrubbing: (videoRef: RefObject<HTMLVideoElement | null>, options?: UseVideoScrubbingOptions) => {
297
+ isDragging: boolean;
298
+ handleMouseDown: (e: React.MouseEvent) => void;
299
+ handleTouchStart: (e: React.TouchEvent) => void;
300
+ hasDragged: React$1.MutableRefObject<boolean>;
301
+ };
302
+
303
+ declare function useBouncePatternProgress(enabled?: boolean): {
304
+ value: number;
305
+ isBouncing: boolean;
306
+ };
307
+
308
+ /**
309
+ * Compares two RenderBuildRequest objects for equality by checking if the same IDs
310
+ * are present in each category array, regardless of order.
311
+ */
312
+ declare const arePartsEqual: (parts1: RenderBuildRequest, parts2: RenderBuildRequest) => boolean;
313
+ interface UseBuildRenderReturn {
314
+ videoSrc: string | null;
315
+ isRenderingBuild: boolean;
316
+ renderError: string | null;
317
+ }
318
+ declare const useBuildRender: (parts: RenderBuildRequest, onLoadStart?: () => void) => UseBuildRenderReturn;
319
+
320
+ interface DragIconProps {
321
+ width?: number;
322
+ height?: number;
323
+ className?: string;
324
+ style?: React__default.CSSProperties;
325
+ }
326
+ declare const DragIcon: React__default.FC<DragIconProps>;
327
+
328
+ interface LoadingErrorOverlayProps {
329
+ isVisible: boolean;
330
+ renderError?: string;
331
+ size: number;
332
+ }
333
+ declare const LoadingErrorOverlay: React__default.FC<LoadingErrorOverlayProps>;
334
+
335
+ interface InstructionTooltipProps {
336
+ isVisible: boolean;
337
+ progressValue: number;
338
+ instructionIcon?: string;
339
+ }
340
+ declare const InstructionTooltip: React__default.FC<InstructionTooltipProps>;
341
+
342
+ declare const API_BASE_URL = "https://squid-app-7aeyk.ondigitalocean.app";
343
+ declare const API_ENDPOINTS: {
344
+ readonly RENDER_BUILD_EXPERIMENTAL: "/render-build-experimental";
345
+ readonly AVAILABLE_PARTS: "/available-parts";
346
+ };
347
+ interface RenderBuildResponse {
348
+ /**
349
+ * The rendered MP4 video as a Blob
350
+ */
351
+ video: Blob;
352
+ /**
353
+ * Optional metadata about the render
354
+ */
355
+ metadata?: {
356
+ duration?: number;
357
+ size?: number;
358
+ format?: string;
359
+ };
360
+ }
361
+ interface RenderAPIService {
362
+ /**
363
+ * Submit a render build request
364
+ * @param parts - The parts configuration for the build
365
+ * @returns Promise with the rendered MP4 video
366
+ */
367
+ renderBuildExperimental(parts: RenderBuildRequest): Promise<RenderBuildResponse>;
368
+ /**
369
+ * Get available parts for building
370
+ * @returns Promise with available parts by category
371
+ */
372
+ getAvailableParts(): Promise<AvailablePartsResponse>;
373
+ }
374
+ declare const buildApiUrl: (endpoint: string) => string;
375
+ declare const renderBuildExperimental: (request: RenderBuildRequest) => Promise<RenderBuildResponse>;
376
+ declare const getAvailableParts: () => Promise<AvailablePartsResponse>;
377
+
378
+ export { API_BASE_URL, API_ENDPOINTS, BuildRender, DragIcon, InstructionTooltip, LoadingErrorOverlay, PartCategory, arePartsEqual, buildApiUrl, calculateCircularTime, getAvailableParts, renderBuildExperimental, useBouncePatternProgress, useBuildRender, useVideoScrubbing };
379
+ export type { AvailablePartsResponse, BuildRenderProps, PartDetails, RenderAPIService, RenderBuildRequest, RenderBuildResponse, UseBuildRenderReturn };