@buildcores/render-client 1.2.0 → 1.4.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.
package/dist/types.d.ts CHANGED
@@ -128,6 +128,9 @@ export interface BuildRenderProps {
128
128
  * This object defines which PC components should be included in the 3D sprite render.
129
129
  * Each part category contains an array with a single part ID that will be rendered.
130
130
  *
131
+ * **Note**: If `shareCode` is provided, it will be used instead of `parts`.
132
+ * Using `shareCode` preserves the build's interactive state (including case fan slot placements).
133
+ *
131
134
  * **Current Limitation**: Only 1 part per category is supported. Arrays must contain
132
135
  * exactly one part ID per category. Future versions will support multiple parts per category.
133
136
  *
@@ -149,7 +152,26 @@ export interface BuildRenderProps {
149
152
  * <SpriteRender parts={parts} size={300} />
150
153
  * ```
151
154
  */
152
- parts: RenderBuildRequest;
155
+ parts?: RenderBuildRequest;
156
+ /**
157
+ * Share code of an existing build to render.
158
+ *
159
+ * When provided, the build will be rendered using its existing interactive state,
160
+ * which includes case fan slot placements. This is preferred over `parts` when
161
+ * rendering builds that have already been configured with case fans.
162
+ *
163
+ * If both `shareCode` and `parts` are provided, `shareCode` takes precedence.
164
+ *
165
+ * @example
166
+ * ```tsx
167
+ * <BuildRender
168
+ * shareCode="abc123xyz"
169
+ * size={500}
170
+ * apiConfig={{ environment: 'prod', authToken: 'your-token' }}
171
+ * />
172
+ * ```
173
+ */
174
+ shareCode?: string;
153
175
  /**
154
176
  * Width and height in pixels. If only `size` is provided, both width and height use it.
155
177
  * If `width`/`height` are provided, they override `size` individually.
@@ -199,6 +221,22 @@ export interface BuildRenderProps {
199
221
  * @default 0.2
200
222
  */
201
223
  touchSensitivity?: number;
224
+ /**
225
+ * Show grid in render.
226
+ * Works for both parts and shareCode rendering.
227
+ */
228
+ showGrid?: boolean;
229
+ /**
230
+ * Camera offset X for composition.
231
+ * Positive values shift the build to the right, leaving room for text overlay on the left.
232
+ * Works for both parts and shareCode rendering.
233
+ */
234
+ cameraOffsetX?: number;
235
+ /**
236
+ * Grid appearance settings for thicker/more visible grid in renders.
237
+ * Works for both parts and shareCode rendering.
238
+ */
239
+ gridSettings?: GridSettings;
202
240
  }
203
241
  /**
204
242
  * API configuration for environment and authentication
@@ -268,7 +306,9 @@ export declare enum PartCategory {
268
306
  /** PC Case - The enclosure that houses all components */
269
307
  PCCase = "PCCase",
270
308
  /** CPU Cooler - Air or liquid cooling for the processor */
271
- CPUCooler = "CPUCooler"
309
+ CPUCooler = "CPUCooler",
310
+ /** Case Fans - Additional cooling fans for the case */
311
+ CaseFan = "CaseFan"
272
312
  }
273
313
  /**
274
314
  * Request structure for rendering a PC build.
@@ -365,6 +405,46 @@ export interface RenderBuildRequest {
365
405
  * ```
366
406
  */
367
407
  height?: number;
408
+ /**
409
+ * Render quality profile that controls visual effects and rendering speed.
410
+ *
411
+ * - **cinematic**: All effects enabled (shadows, ambient occlusion, bloom) for highest quality
412
+ * - **flat**: No effects for clean, simple product shots
413
+ * - **fast**: Minimal rendering for fastest processing speed
414
+ *
415
+ * @example
416
+ * ```tsx
417
+ * const request: RenderBuildRequest = {
418
+ * parts: { CPU: ["7xjqsomhr"] },
419
+ * profile: 'cinematic' // High quality with all effects
420
+ * };
421
+ * ```
422
+ *
423
+ * @example Fast rendering
424
+ * ```tsx
425
+ * const request: RenderBuildRequest = {
426
+ * parts: { CPU: ["7xjqsomhr"] },
427
+ * profile: 'fast' // Quick render, minimal effects
428
+ * };
429
+ * ```
430
+ */
431
+ profile?: 'cinematic' | 'flat' | 'fast';
432
+ /**
433
+ * Whether to show the 3D grid in the render.
434
+ * Defaults to true for cinematic profile, false otherwise.
435
+ */
436
+ showGrid?: boolean;
437
+ /**
438
+ * Horizontal offset for the camera view.
439
+ * Positive values shift the build to the right, leaving room for text overlay on the left.
440
+ * Range: -0.3 to 0.3
441
+ */
442
+ cameraOffsetX?: number;
443
+ /**
444
+ * Custom grid appearance settings.
445
+ * Only applies when showGrid is true.
446
+ */
447
+ gridSettings?: GridSettings;
368
448
  }
369
449
  /**
370
450
  * Response structure containing all available parts for each category.
@@ -462,3 +542,127 @@ export interface GetAvailablePartsOptions {
462
542
  /** Number of parts to skip for pagination (default 0) */
463
543
  skip?: number;
464
544
  }
545
+ /**
546
+ * Extended part details including category information
547
+ */
548
+ export interface PartDetailsWithCategory {
549
+ /** Unique part identifier (BuildCores ID) */
550
+ id: string;
551
+ /** Human-readable part name */
552
+ name: string;
553
+ /** URL to part image (may be null) */
554
+ image: string | null;
555
+ /** Part category */
556
+ category: PartCategory;
557
+ }
558
+ /**
559
+ * Response from the get build by share code endpoint.
560
+ * Contains build metadata and parts organized by category.
561
+ *
562
+ * @example
563
+ * ```tsx
564
+ * const build = await getBuildByShareCode('abc123xyz', config);
565
+ * console.log(build.name); // "My Gaming PC"
566
+ * console.log(build.parts.CPU); // ["7xjqsomhr"]
567
+ * console.log(build.partDetails.CPU[0].name); // "AMD Ryzen 7 9800X3D"
568
+ * ```
569
+ */
570
+ export interface BuildResponse {
571
+ /** The share code of the build */
572
+ shareCode: string;
573
+ /** Build name/title */
574
+ name: string;
575
+ /** Build description */
576
+ description: string;
577
+ /**
578
+ * Part IDs mapped by category.
579
+ * Use these IDs directly with RenderBuildRequest.
580
+ */
581
+ parts: {
582
+ [K in PartCategory]?: string[];
583
+ };
584
+ /**
585
+ * Detailed part information mapped by category.
586
+ * Includes name, image URL, and category for each part.
587
+ */
588
+ partDetails: {
589
+ [K in PartCategory]?: PartDetailsWithCategory[];
590
+ };
591
+ }
592
+ /**
593
+ * Response from the get parts by IDs endpoint.
594
+ *
595
+ * @example
596
+ * ```tsx
597
+ * const response = await getPartsByIds(['7xjqsomhr', 'z7pyphm9k'], config);
598
+ * response.parts.forEach(part => {
599
+ * console.log(`${part.name} (${part.category})`);
600
+ * });
601
+ * ```
602
+ */
603
+ export interface PartsResponse {
604
+ /** Array of part details */
605
+ parts: PartDetailsWithCategory[];
606
+ }
607
+ /**
608
+ * Grid appearance settings for renders
609
+ */
610
+ export interface GridSettings {
611
+ /** Grid cell line thickness (default: 0.6) */
612
+ cellThickness?: number;
613
+ /** Grid section line thickness (default: 1.2) */
614
+ sectionThickness?: number;
615
+ /** Grid color as hex string (default: #6f6f6f) */
616
+ color?: string;
617
+ /** Distance at which grid starts to fade (default: 3) */
618
+ fadeDistance?: number;
619
+ /** Render order for depth sorting (default: 0, use -1 to render before other objects) */
620
+ renderOrder?: number;
621
+ }
622
+ /**
623
+ * Options for rendering a build by share code
624
+ */
625
+ export interface RenderByShareCodeOptions {
626
+ /** Output format - video (MP4) or sprite (WebP sprite sheet) */
627
+ format?: "video" | "sprite";
628
+ /** Desired canvas pixel width (256-8192) */
629
+ width?: number;
630
+ /** Desired canvas pixel height (256-8192) */
631
+ height?: number;
632
+ /** Render quality profile */
633
+ profile?: "cinematic" | "flat" | "fast";
634
+ /** Show grid in render (default: true for cinematic profile) */
635
+ showGrid?: boolean;
636
+ /** Camera offset X for composition (positive = shift build right to leave room for text overlay) */
637
+ cameraOffsetX?: number;
638
+ /** Grid appearance settings (for thicker/more visible grid in renders) */
639
+ gridSettings?: GridSettings;
640
+ /** Polling interval in milliseconds (default: 1500) */
641
+ pollIntervalMs?: number;
642
+ /** Timeout in milliseconds (default: 120000 = 2 minutes) */
643
+ timeoutMs?: number;
644
+ }
645
+ /**
646
+ * Response from the render by share code endpoint (job creation).
647
+ */
648
+ export interface RenderByShareCodeJobResponse {
649
+ /** Unique job identifier for polling status */
650
+ job_id: string;
651
+ /** Current job status */
652
+ status: "queued" | "processing" | "completed" | "error";
653
+ /** The share code of the build being rendered */
654
+ share_code: string;
655
+ }
656
+ /**
657
+ * Final response after render by share code completes.
658
+ *
659
+ * @example
660
+ * ```tsx
661
+ * const result = await renderByShareCode('abc123xyz', config);
662
+ * // Use result.videoUrl to display the rendered video
663
+ * ```
664
+ */
665
+ export interface RenderByShareCodeResponse {
666
+ /** URL to the rendered video or sprite sheet */
667
+ videoUrl: string;
668
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildcores/render-client",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "type": "module",
5
5
  "description": "React component for interactive 360-degree video rendering",
6
6
  "repository": {