@car-cutter/react-webplayer 0.4.2 → 0.6.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/index.d.ts CHANGED
@@ -1,6 +1,21 @@
1
1
  import { FC } from 'react';
2
2
 
3
- export declare const DEFAULT_EVENT_PREFIX = "cc-webplayer:";
3
+ declare type AspectRatio = `${number}:${number}`;
4
+
5
+ declare type Category = {
6
+ id: string;
7
+ title: string;
8
+ items: Item[];
9
+ };
10
+
11
+ export declare type Composition = {
12
+ aspectRatio: AspectRatio;
13
+ imageHdWidth: ImageWidth;
14
+ imageSubWidths: ImageWidth[];
15
+ categories: Category[];
16
+ };
17
+
18
+ export declare const DEFAULT_EVENT_PREFIX: string = "cc-webplayer:";
4
19
 
5
20
  export declare const EVENT_COMPOSITION_LOAD_ERROR = "composition-load-error";
6
21
 
@@ -20,8 +35,58 @@ export declare const EVENT_HOTSPOTS_OFF = "hotspots-off";
20
35
 
21
36
  export declare const EVENT_HOTSPOTS_ON = "hotspots-on";
22
37
 
38
+ /**
39
+ * Generates a URL for fetching the composition JSON for a given customer and vehicle.
40
+ *
41
+ * @param {string} customerId - The ID of the customer.
42
+ * @param {string} vin - The Vehicle Identification Number.
43
+ * @returns {string} The URL to fetch the composition JSON.
44
+ */
45
+ export declare function generateCompositionUrl(
46
+ customerId: string,
47
+ vin: string
48
+ ): string {
49
+ return `https://cdn.car-cutter.com/gallery/${customerId}/${vin}/composition_v3.json`;
50
+ }
51
+
52
+ declare type Hotspot = {
53
+ title: string;
54
+ icon?: string;
55
+ description?: string;
56
+ position: {
57
+ x: number;
58
+ y: number;
59
+ };
60
+ detail?: {
61
+ type: "image" | "link" | "pdf";
62
+ src: string;
63
+ };
64
+ };
65
+
66
+ declare type ImageItem = { type: "image" } & ImageWithHotspots;
67
+
23
68
  declare type ImageLoadStrategy = "quality" | "speed";
24
69
 
70
+ declare type ImageWidth = number;
71
+
72
+ declare type ImageWithHotspots = {
73
+ src: string;
74
+ hotspots?: Hotspot[];
75
+ };
76
+
77
+ declare type Item = ImageItem | VideoItem | ThreeSixtyItem;
78
+
79
+ declare type ThreeSixtyItem = {
80
+ type: "360";
81
+ images: ImageWithHotspots[];
82
+ };
83
+
84
+ declare type VideoItem = {
85
+ type: "video";
86
+ src: string;
87
+ poster: string;
88
+ };
89
+
25
90
  export declare const WEB_PLAYER_ICON_WC_TAG = "cc-webplayer-icon";
26
91
 
27
92
  export declare const WEB_PLAYER_WC_TAG = "cc-webplayer";
@@ -36,9 +101,9 @@ export declare type WebPlayerIconProps = {
36
101
  };
37
102
 
38
103
  export declare type WebPlayerProps = WebPlayerProps_2 & {
39
- onCompositionLoading?: () => void;
40
- onCompositionLoaded?: () => void;
41
- onCompositionLoadError?: () => void;
104
+ onCompositionLoading?: (url: string) => void;
105
+ onCompositionLoaded?: (composition: Composition) => void;
106
+ onCompositionLoadError?: (error: unknown) => void;
42
107
  onExtendModeOn?: () => void;
43
108
  onExtendModeOff?: () => void;
44
109
  onHotspotsOn?: () => void;
@@ -49,7 +114,7 @@ export declare type WebPlayerProps = WebPlayerProps_2 & {
49
114
 
50
115
  declare type WebPlayerProps_2 = {
51
116
  compositionUrl: string;
52
- flatten?: boolean;
117
+ hideCategories?: boolean;
53
118
  infiniteCarrousel?: boolean;
54
119
  permanentGallery?: boolean;
55
120
  imageLoadStrategy?: ImageLoadStrategy;