@buildcores/render-client 1.0.11 → 1.1.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/api.d.ts +3 -3
- package/dist/index.d.ts +49 -6
- package/dist/index.esm.js +14 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +14 -5
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +46 -3
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RenderBuildRequest, AvailablePartsResponse, ApiConfig } from "./types";
|
|
1
|
+
import { RenderBuildRequest, AvailablePartsResponse, ApiConfig, PartCategory, GetAvailablePartsOptions } from "./types";
|
|
2
2
|
declare const API_BASE_URL = "https://www.renderapi.buildcores.com";
|
|
3
3
|
export declare const API_ENDPOINTS: {
|
|
4
4
|
readonly RENDER_BUILD_EXPERIMENTAL: "/render-build-experimental";
|
|
@@ -65,7 +65,7 @@ export interface RenderAPIService {
|
|
|
65
65
|
* @param config - API configuration (environment, auth token) - required
|
|
66
66
|
* @returns Promise with available parts by category
|
|
67
67
|
*/
|
|
68
|
-
getAvailableParts(config: ApiConfig): Promise<AvailablePartsResponse>;
|
|
68
|
+
getAvailableParts(category: PartCategory, config: ApiConfig, options?: GetAvailablePartsOptions): Promise<AvailablePartsResponse>;
|
|
69
69
|
}
|
|
70
70
|
export declare const buildApiUrl: (endpoint: string, config: ApiConfig) => string;
|
|
71
71
|
export declare const buildHeaders: (config: ApiConfig) => Record<string, string>;
|
|
@@ -77,5 +77,5 @@ export declare const renderBuild: (request: RenderBuildRequest, config: ApiConfi
|
|
|
77
77
|
timeoutMs?: number;
|
|
78
78
|
}) => Promise<RenderBuildAsyncResponse>;
|
|
79
79
|
export declare const renderSpriteExperimental: (request: RenderBuildRequest, config: ApiConfig) => Promise<RenderSpriteResponse>;
|
|
80
|
-
export declare const getAvailableParts: (config: ApiConfig) => Promise<AvailablePartsResponse>;
|
|
80
|
+
export declare const getAvailableParts: (category: PartCategory, config: ApiConfig, options?: GetAvailablePartsOptions) => Promise<AvailablePartsResponse>;
|
|
81
81
|
export { API_BASE_URL };
|
package/dist/index.d.ts
CHANGED
|
@@ -177,6 +177,13 @@ interface BuildRenderProps {
|
|
|
177
177
|
* ```
|
|
178
178
|
*/
|
|
179
179
|
apiConfig: ApiConfig;
|
|
180
|
+
/**
|
|
181
|
+
* Options to configure the internal useSpriteRender hook
|
|
182
|
+
* (e.g., choose async vs experimental rendering flow)
|
|
183
|
+
*/
|
|
184
|
+
useSpriteRenderOptions?: {
|
|
185
|
+
mode?: "async" | "experimental";
|
|
186
|
+
};
|
|
180
187
|
/**
|
|
181
188
|
* Optional mouse sensitivity for dragging (default: 0.05).
|
|
182
189
|
*
|
|
@@ -391,9 +398,45 @@ interface PartDetails {
|
|
|
391
398
|
/** URL to part image */
|
|
392
399
|
image: string;
|
|
393
400
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
401
|
+
/**
|
|
402
|
+
* Pagination metadata for available parts responses
|
|
403
|
+
*/
|
|
404
|
+
interface AvailablePartsPagination {
|
|
405
|
+
/** Total number of parts available for this category */
|
|
406
|
+
total: number;
|
|
407
|
+
/** Number of parts returned in this response */
|
|
408
|
+
limit: number;
|
|
409
|
+
/** Number of parts skipped */
|
|
410
|
+
skip: number;
|
|
411
|
+
/** Whether there are more parts available */
|
|
412
|
+
hasNext: boolean;
|
|
413
|
+
/** Whether there are previous parts available */
|
|
414
|
+
hasPrev: boolean;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Response envelope for the available parts endpoint.
|
|
418
|
+
* Returns parts for the requested category under `data` keyed by category name.
|
|
419
|
+
*/
|
|
420
|
+
interface AvailablePartsResponse {
|
|
421
|
+
/**
|
|
422
|
+
* Parts grouped by category. Only the requested category key is expected
|
|
423
|
+
* to be present in the response.
|
|
424
|
+
*/
|
|
425
|
+
data: Partial<Record<PartCategory, PartDetails[]>>;
|
|
426
|
+
/** The requested category */
|
|
427
|
+
category: PartCategory;
|
|
428
|
+
/** Optional pagination information */
|
|
429
|
+
pagination?: AvailablePartsPagination;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Query options for fetching available parts
|
|
433
|
+
*/
|
|
434
|
+
interface GetAvailablePartsOptions {
|
|
435
|
+
/** Number of parts to return (default 20, min 1, max 100) */
|
|
436
|
+
limit?: number;
|
|
437
|
+
/** Number of parts to skip for pagination (default 0) */
|
|
438
|
+
skip?: number;
|
|
439
|
+
}
|
|
397
440
|
|
|
398
441
|
declare const BuildRender: React.FC<BuildRenderProps>;
|
|
399
442
|
|
|
@@ -544,13 +587,13 @@ interface RenderAPIService {
|
|
|
544
587
|
* @param config - API configuration (environment, auth token) - required
|
|
545
588
|
* @returns Promise with available parts by category
|
|
546
589
|
*/
|
|
547
|
-
getAvailableParts(config: ApiConfig): Promise<AvailablePartsResponse>;
|
|
590
|
+
getAvailableParts(category: PartCategory, config: ApiConfig, options?: GetAvailablePartsOptions): Promise<AvailablePartsResponse>;
|
|
548
591
|
}
|
|
549
592
|
declare const buildApiUrl: (endpoint: string, config: ApiConfig) => string;
|
|
550
593
|
declare const buildHeaders: (config: ApiConfig) => Record<string, string>;
|
|
551
594
|
declare const renderBuildExperimental: (request: RenderBuildRequest, config: ApiConfig) => Promise<RenderBuildResponse>;
|
|
552
595
|
declare const renderSpriteExperimental: (request: RenderBuildRequest, config: ApiConfig) => Promise<RenderSpriteResponse>;
|
|
553
|
-
declare const getAvailableParts: (config: ApiConfig) => Promise<AvailablePartsResponse>;
|
|
596
|
+
declare const getAvailableParts: (category: PartCategory, config: ApiConfig, options?: GetAvailablePartsOptions) => Promise<AvailablePartsResponse>;
|
|
554
597
|
|
|
555
598
|
export { API_BASE_URL, API_ENDPOINTS, BuildRender, BuildRenderVideo, DragIcon, InstructionTooltip, LoadingErrorOverlay, PartCategory, arePartsEqual, buildApiUrl, buildHeaders, calculateCircularFrame, calculateCircularTime, getAvailableParts, renderBuildExperimental, renderSpriteExperimental, useBouncePatternProgress, useBuildRender, useSpriteRender, useSpriteScrubbing, useVideoScrubbing };
|
|
556
|
-
export type { ApiConfig, AvailablePartsResponse, BuildRenderProps, BuildRenderVideoProps, PartDetails, RenderAPIService, RenderBuildRequest, RenderBuildResponse, RenderSpriteResponse, UseBuildRenderOptions, UseBuildRenderReturn, UseSpriteRenderOptions, UseSpriteRenderReturn };
|
|
599
|
+
export type { ApiConfig, AvailablePartsResponse, BuildRenderProps, BuildRenderVideoProps, GetAvailablePartsOptions, PartDetails, RenderAPIService, RenderBuildRequest, RenderBuildResponse, RenderSpriteResponse, UseBuildRenderOptions, UseBuildRenderReturn, UseSpriteRenderOptions, UseSpriteRenderReturn };
|
package/dist/index.esm.js
CHANGED
|
@@ -458,15 +458,24 @@ const renderSpriteExperimental = async (request, config) => {
|
|
|
458
458
|
},
|
|
459
459
|
};
|
|
460
460
|
};
|
|
461
|
-
const getAvailableParts = async (config) => {
|
|
462
|
-
const
|
|
461
|
+
const getAvailableParts = async (category, config, options) => {
|
|
462
|
+
const base = buildApiUrl(API_ENDPOINTS.AVAILABLE_PARTS, config);
|
|
463
|
+
const params = new URLSearchParams();
|
|
464
|
+
params.set("category", category);
|
|
465
|
+
if (typeof options?.limit === "number")
|
|
466
|
+
params.set("limit", String(options.limit));
|
|
467
|
+
if (typeof options?.skip === "number")
|
|
468
|
+
params.set("skip", String(options.skip));
|
|
469
|
+
const separator = base.includes("?") ? "&" : "?";
|
|
470
|
+
const url = `${base}${separator}${params.toString()}`;
|
|
471
|
+
const response = await fetch(url, {
|
|
463
472
|
method: "GET",
|
|
464
473
|
headers: buildHeaders(config),
|
|
465
474
|
});
|
|
466
475
|
if (!response.ok) {
|
|
467
476
|
throw new Error(`Get available parts failed: ${response.status} ${response.statusText}`);
|
|
468
477
|
}
|
|
469
|
-
return response.json();
|
|
478
|
+
return (await response.json());
|
|
470
479
|
};
|
|
471
480
|
|
|
472
481
|
/**
|
|
@@ -729,7 +738,7 @@ const InstructionTooltip = ({ isVisible, progressValue, instructionIcon, }) => {
|
|
|
729
738
|
} })) }));
|
|
730
739
|
};
|
|
731
740
|
|
|
732
|
-
const BuildRender = ({ parts, width, height, size, apiConfig, mouseSensitivity = 0.2, touchSensitivity = 0.2, }) => {
|
|
741
|
+
const BuildRender = ({ parts, width, height, size, apiConfig, useSpriteRenderOptions, mouseSensitivity = 0.2, touchSensitivity = 0.2, }) => {
|
|
733
742
|
const canvasRef = useRef(null);
|
|
734
743
|
const [img, setImg] = useState(null);
|
|
735
744
|
const [isLoading, setIsLoading] = useState(true);
|
|
@@ -737,7 +746,7 @@ const BuildRender = ({ parts, width, height, size, apiConfig, mouseSensitivity =
|
|
|
737
746
|
const displayW = width ?? size ?? 300;
|
|
738
747
|
const displayH = height ?? size ?? 300;
|
|
739
748
|
// Use custom hook for sprite rendering
|
|
740
|
-
const { spriteSrc, isRenderingSprite, renderError, spriteMetadata } = useSpriteRender(parts, apiConfig);
|
|
749
|
+
const { spriteSrc, isRenderingSprite, renderError, spriteMetadata } = useSpriteRender(parts, apiConfig, undefined, useSpriteRenderOptions);
|
|
741
750
|
const { value: progressValue, isBouncing } = useBouncePatternProgress(bouncingAllowed);
|
|
742
751
|
const total = spriteMetadata ? spriteMetadata.totalFrames : 72;
|
|
743
752
|
const cols = spriteMetadata ? spriteMetadata.cols : 12;
|