@car-cutter/react-webplayer 3.0.0 → 3.0.2

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.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./shared-Bps5mZ-a.cjs");require("react/jsx-runtime");const P=require("react"),S=require("react-dom/client");var W=Object.defineProperty,L=(e,t,o)=>t in e?W(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,b=(e,t,o)=>(L(e,typeof t!="symbol"?t+"":t,o),o);const I={stringify:e=>e,parse:e=>e},R={stringify:e=>`${e}`,parse:e=>parseFloat(e)},V={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},M={stringify:e=>e.name,parse:(e,t,o)=>{const i=(()=>{if(typeof window<"u"&&e in window)return window[e];if(typeof global<"u"&&e in global)return global[e]})();return typeof i=="function"?i.bind(o):void 0}},D={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)},y={string:I,number:R,boolean:V,function:M,json:D};function w(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,o,i)=>`${o}-${i.toLowerCase()}`)}const m=Symbol.for("r2wc.render"),T=Symbol.for("r2wc.connected"),u=Symbol.for("r2wc.context"),l=Symbol.for("r2wc.props");function G(e,t,o){var i,O,A;t.props||(t.props=e.propTypes?Object.keys(e.propTypes):[]);const d=Array.isArray(t.props)?t.props.slice():Object.keys(t.props),p={},f={},h={};for(const s of d){p[s]=Array.isArray(t.props)?"string":t.props[s];const r=w(s);f[s]=r,h[r]=s}class g extends HTMLElement{constructor(){super(),b(this,i,!0),b(this,O),b(this,A,{}),b(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[l].container=this.container;for(const r of d){const _=f[r],c=this.getAttribute(_),a=p[r],E=a?y[a]:null;E!=null&&E.parse&&c&&(this[l][r]=E.parse(c,_,this))}}static get observedAttributes(){return Object.keys(h)}connectedCallback(){this[T]=!0,this[m]()}disconnectedCallback(){this[T]=!1,this[u]&&o.unmount(this[u]),delete this[u]}attributeChangedCallback(r,_,c){const a=h[r],E=p[a],N=E?y[E]:null;a in p&&N!=null&&N.parse&&c&&(this[l][a]=N.parse(c,r,this),this[m]())}[(i=T,O=u,A=l,m)](){this[T]&&(this[u]?o.update(this[u],this[l]):this[u]=o.mount(this.container,e,this[l]))}}for(const s of d){const r=f[s],_=p[s];Object.defineProperty(g.prototype,s,{enumerable:!0,configurable:!0,get(){return this[l][s]},set(c){this[l][s]=c;const a=_?y[_]:null;if(a!=null&&a.stringify){const E=a.stringify(c,r,this);this.getAttribute(r)!==E&&this.setAttribute(r,E)}else this[m]()}})}return g}function F(e,t,o){const i=S.createRoot(e),O=P.createElement(t,o);return i.render(O),{root:i,ReactComponent:t}}function v({root:e,ReactComponent:t},o){const i=P.createElement(t,o);e.render(i)}function Y({root:e}){setTimeout(()=>{e.unmount()},0)}function C(e,t={}){return G(e,t,{mount:F,update:v,unmount:Y})}const j=C(n.WebPlayerWithInjectedStyles,{shadow:"closed",props:{compositionUrl:"string",hideCategoriesNav:"boolean",infiniteCarrousel:"boolean",permanentGallery:"boolean",integration:"boolean",maxItemsShown:"number",minMediaWidth:"number",maxMediaWidth:"number",mediaLoadStrategy:"string",preloadRange:"number",autoLoad360:"boolean",autoLoadInterior360:"boolean",categoriesFilter:"string",extendBehavior:"string",eventPrefix:"string",demoSpin:"boolean",reverse360:"boolean"}}),k=C(n.WebPlayerCustomMedia,{shadow:"closed",props:{index:"number",thumbnailSrc:"string"}}),x=C(n.WebPlayerIcon,{shadow:"closed",props:{name:"string"}});function B(){customElements.define(n.WEB_PLAYER_WC_TAG,j),customElements.define(n.WEB_PLAYER_CUSTOM_MEDIA_WC_TAG,k),customElements.define(n.WEB_PLAYER_ICON_WC_TAG,x)}function H(){n.checkCustomElementsDefinition()||B()}H();exports.DEFAULT_EVENT_PREFIX=n.DEFAULT_EVENT_PREFIX;exports.EVENT_COMPOSITION_LOADED=n.EVENT_COMPOSITION_LOADED;exports.EVENT_COMPOSITION_LOADING=n.EVENT_COMPOSITION_LOADING;exports.EVENT_COMPOSITION_LOAD_ERROR=n.EVENT_COMPOSITION_LOAD_ERROR;exports.EVENT_EXTEND_MODE_OFF=n.EVENT_EXTEND_MODE_OFF;exports.EVENT_EXTEND_MODE_ON=n.EVENT_EXTEND_MODE_ON;exports.EVENT_GALLERY_CLOSE=n.EVENT_GALLERY_CLOSE;exports.EVENT_GALLERY_OPEN=n.EVENT_GALLERY_OPEN;exports.EVENT_HOTSPOTS_OFF=n.EVENT_HOTSPOTS_OFF;exports.EVENT_HOTSPOTS_ON=n.EVENT_HOTSPOTS_ON;exports.EVENT_ITEM_CHANGE=n.EVENT_ITEM_CHANGE;exports.WEB_PLAYER_ICON_WC_TAG=n.WEB_PLAYER_ICON_WC_TAG;exports.WEB_PLAYER_WC_TAG=n.WEB_PLAYER_WC_TAG;exports.WebPlayer=n.WebPlayer;exports.WebPlayerCustomMedia=n.WebPlayerCustomMedia$1;exports.WebPlayerIcon=n.WebPlayerIcon$1;exports.generateCompositionUrl=n.generateCompositionUrl;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./shared-BWLUv51h.cjs");require("react/jsx-runtime");const P=require("react"),I=require("react-dom/client");var S=Object.defineProperty,L=(e,n,o)=>n in e?S(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o,p=(e,n,o)=>(L(e,typeof n!="symbol"?n+"":n,o),o);const W={stringify:e=>e,parse:e=>e},V={stringify:e=>`${e}`,parse:e=>parseFloat(e)},R={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},D={stringify:e=>e.name,parse:(e,n,o)=>{const i=(()=>{if(typeof window<"u"&&e in window)return window[e];if(typeof global<"u"&&e in global)return global[e]})();return typeof i=="function"?i.bind(o):void 0}},M={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)},f={string:W,number:V,boolean:R,function:D,json:M};function w(e){return e.replace(/([a-z0-9])([A-Z])/g,(n,o,i)=>`${o}-${i.toLowerCase()}`)}const O=Symbol.for("r2wc.render"),N=Symbol.for("r2wc.connected"),u=Symbol.for("r2wc.context"),c=Symbol.for("r2wc.props");function Y(e,n,o){var i,b,C;n.props||(n.props=e.propTypes?Object.keys(e.propTypes):[]);const m=Array.isArray(n.props)?n.props.slice():Object.keys(n.props),T={},d={},y={};for(const s of m){T[s]=Array.isArray(n.props)?"string":n.props[s];const r=w(s);d[s]=r,y[r]=s}class g extends HTMLElement{constructor(){super(),p(this,i,!0),p(this,b),p(this,C,{}),p(this,"container"),n.shadow?this.container=this.attachShadow({mode:n.shadow}):this.container=this,this[c].container=this.container;for(const r of m){const _=d[r],l=this.getAttribute(_),a=T[r],E=a?f[a]:null;E!=null&&E.parse&&l&&(this[c][r]=E.parse(l,_,this))}}static get observedAttributes(){return Object.keys(y)}connectedCallback(){this[N]=!0,this[O]()}disconnectedCallback(){this[N]=!1,this[u]&&o.unmount(this[u]),delete this[u]}attributeChangedCallback(r,_,l){const a=y[r],E=T[a],A=E?f[E]:null;a in T&&A!=null&&A.parse&&l&&(this[c][a]=A.parse(l,r,this),this[O]())}[(i=N,b=u,C=c,O)](){this[N]&&(this[u]?o.update(this[u],this[c]):this[u]=o.mount(this.container,e,this[c]))}}for(const s of m){const r=d[s],_=T[s];Object.defineProperty(g.prototype,s,{enumerable:!0,configurable:!0,get(){return this[c][s]},set(l){this[c][s]=l;const a=_?f[_]:null;if(a!=null&&a.stringify){const E=a.stringify(l,r,this);this.getAttribute(r)!==E&&this.setAttribute(r,E)}else this[O]()}})}return g}function G(e,n,o){const i=I.createRoot(e),b=P.createElement(n,o);return i.render(b),{root:i,ReactComponent:n}}function F({root:e,ReactComponent:n},o){const i=P.createElement(n,o);e.render(i)}function v({root:e}){setTimeout(()=>{e.unmount()},0)}function h(e,n={}){return Y(e,n,{mount:G,update:F,unmount:v})}const j=h(t.WebPlayerWithInjectedStyles,{shadow:"closed",props:{compositionUrl:"string",hideCategoriesNav:"boolean",infiniteCarrousel:"boolean",permanentGallery:"boolean",integration:"boolean",maxItemsShown:"number",minMediaWidth:"number",maxMediaWidth:"number",mediaLoadStrategy:"string",preloadRange:"number",autoLoad360:"boolean",autoLoadInterior360:"boolean",categoriesFilter:"string",extendBehavior:"string",eventPrefix:"string",demoSpin:"boolean",reverse360:"boolean",analyticsEventPrefix:"string",analyticsUrl:"string",analyticsBearer:"string",analyticsSimpleRequestsOnly:"boolean",analyticsDryRun:"boolean",analyticsDebug:"boolean"}}),x=h(t.WebPlayerCustomMedia,{shadow:"closed",props:{index:"number",thumbnailSrc:"string"}}),B=h(t.WebPlayerIcon,{shadow:"closed",props:{name:"string"}});function k(){customElements.define(t.WEB_PLAYER_WC_TAG,j),customElements.define(t.WEB_PLAYER_CUSTOM_MEDIA_WC_TAG,x),customElements.define(t.WEB_PLAYER_ICON_WC_TAG,B)}function H(){t.checkCustomElementsDefinition()||k()}H();exports.ANALYTICS_EVENT_IDENTIFY=t.ANALYTICS_EVENT_IDENTIFY;exports.ANALYTICS_EVENT_PAGE=t.ANALYTICS_EVENT_PAGE;exports.ANALYTICS_EVENT_TRACK=t.ANALYTICS_EVENT_TRACK;exports.DEFAULT_EVENT_PREFIX=t.DEFAULT_EVENT_PREFIX;exports.EVENT_COMPOSITION_LOADED=t.EVENT_COMPOSITION_LOADED;exports.EVENT_COMPOSITION_LOADING=t.EVENT_COMPOSITION_LOADING;exports.EVENT_COMPOSITION_LOAD_ERROR=t.EVENT_COMPOSITION_LOAD_ERROR;exports.EVENT_EXTEND_MODE_OFF=t.EVENT_EXTEND_MODE_OFF;exports.EVENT_EXTEND_MODE_ON=t.EVENT_EXTEND_MODE_ON;exports.EVENT_GALLERY_CLOSE=t.EVENT_GALLERY_CLOSE;exports.EVENT_GALLERY_OPEN=t.EVENT_GALLERY_OPEN;exports.EVENT_HOTSPOTS_OFF=t.EVENT_HOTSPOTS_OFF;exports.EVENT_HOTSPOTS_ON=t.EVENT_HOTSPOTS_ON;exports.EVENT_ITEM_CHANGE=t.EVENT_ITEM_CHANGE;exports.WEB_PLAYER_ICON_WC_TAG=t.WEB_PLAYER_ICON_WC_TAG;exports.WEB_PLAYER_WC_TAG=t.WEB_PLAYER_WC_TAG;exports.WebPlayer=t.WebPlayer;exports.WebPlayerCustomMedia=t.WebPlayerCustomMedia$1;exports.WebPlayerIcon=t.WebPlayerIcon$1;exports.generateCompositionUrl=t.generateCompositionUrl;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,107 @@
1
1
  import { FC } from 'react';
2
2
  import { PropsWithChildren } from 'react';
3
3
 
4
+ export declare const ANALYTICS_EVENT_IDENTIFY = "analytics-identify";
5
+
6
+ export declare const ANALYTICS_EVENT_PAGE = "analytics-page";
7
+
8
+ export declare const ANALYTICS_EVENT_TRACK = "analytics-track";
9
+
10
+ declare type AnalyticsEventBase = {
11
+ type: AnalyticsEventType;
12
+ timestamp: string;
13
+ instance_id: string;
14
+ };
15
+
16
+ declare type AnalyticsEventType =
17
+ | AnalyticsEventTypeIdentify
18
+ | AnalyticsEventTypePage
19
+ | AnalyticsEventTypeTrack;
20
+
21
+ declare type AnalyticsEventTypeIdentify = "identify";
22
+
23
+ declare type AnalyticsEventTypePage = "page";
24
+
25
+ declare type AnalyticsEventTypeTrack = "track";
26
+
27
+ declare type AnalyticsIdentifyEvent = Omit<AnalyticsEventBase, "type"> &
28
+ AnalyticsIdentifyEventProps;
29
+
30
+ declare type AnalyticsIdentifyEventProps = {
31
+ type: AnalyticsEventTypeIdentify;
32
+ browser_id: string;
33
+ session_id: string;
34
+ referrer: string;
35
+ origin: string;
36
+ page_url: string;
37
+ user_agent: string;
38
+ wp_properties: {
39
+ composition_url: string;
40
+
41
+ // Integration mode
42
+ integration: boolean;
43
+ max_items_shown: number;
44
+
45
+ // Layout
46
+ hide_categories_nav: boolean;
47
+ infinite_carrousel: boolean;
48
+ permanent_gallery: boolean;
49
+
50
+ // Medias loading
51
+ media_load_strategy: string;
52
+ min_media_width: number;
53
+ max_media_width: number;
54
+ preload_range: number;
55
+ auto_load_360: boolean;
56
+ auto_load_interior_360: boolean;
57
+
58
+ // Miscellaneous
59
+ categories_filter: string;
60
+ extend_behavior: string;
61
+ event_prefix: string;
62
+ demo_spin: boolean;
63
+ reverse_360: boolean;
64
+ };
65
+ };
66
+
67
+ declare type AnalyticsPageEvent = Omit<AnalyticsEventBase, "type"> &
68
+ AnalyticsPageEventProps;
69
+
70
+ declare type AnalyticsPageEventProps = {
71
+ type: AnalyticsEventTypePage;
72
+ category_id: string;
73
+ category_name: string;
74
+ items_count: number;
75
+ page_properties: {
76
+ item_type: string;
77
+ item_position: number;
78
+ };
79
+ };
80
+
81
+ declare type AnalyticsTrackEvent = Omit<AnalyticsEventBase, "type"> &
82
+ AnalyticsTrackEventProps;
83
+
84
+ declare type AnalyticsTrackEventProps = {
85
+ type: AnalyticsEventTypeTrack;
86
+ category_id: string;
87
+ category_name: string;
88
+ item_type: string;
89
+ item_position: number;
90
+ action_properties: {
91
+ action_name: string;
92
+ action_field: string;
93
+ action_value:
94
+ | bigint
95
+ | boolean
96
+ | null
97
+ | number
98
+ | string
99
+ | symbol
100
+ | undefined
101
+ | object;
102
+ };
103
+ };
104
+
4
105
  declare type AspectRatio = `${number}:${number}`;
5
106
 
6
107
  declare type Category = {
@@ -43,7 +144,7 @@ declare type ExtendBehavior = "full_screen" | "event" | "none";
43
144
  /**
44
145
  * Generates a URL for fetching the composition JSON for a given customer and vehicle.
45
146
  *
46
- * @param {string} customerToken - The CarCutter Customer Token (computed by hasing the Customer ID with SHA-256).
147
+ * @param {string} customerToken - The CarCutter Customer Token (computed by hashing the Customer ID with SHA-256).
47
148
  * @param {string} vin - The Vehicle Identification Number.
48
149
  * @returns {string} The URL to fetch the composition JSON.
49
150
  */
@@ -58,6 +159,7 @@ declare type Hotspot = {
58
159
  title: string;
59
160
  icon?: string;
60
161
  description?: string;
162
+ type?: "damage" | "feature";
61
163
  position: {
62
164
  x: number;
63
165
  y: number;
@@ -129,8 +231,10 @@ declare type WebPlayerIconName =
129
231
  | "UI_PLAY" // Play video
130
232
  | "UI_PLUS" // Increase zoom
131
233
  | "UI_REDUCE" // Reducing an extended view
132
- | "UI_360" // 360-degree view
133
- | "UI_INTERIOR_360" // interior 360 view
234
+ | "UI_360" // Exterior 360 view
235
+ | "UI_360_PLAY" // Play exterior 360
236
+ | "UI_INTERIOR_360" // Interior 360 view
237
+ | "UI_INTERIOR_360_PLAY" // Play interior 360 view
134
238
  | "UI_VOLUME" // Video volume
135
239
  | "UI_VOLUME_OFF" // Muted video
136
240
  | "CONTROLS_PREV" // Go to previous media
@@ -156,6 +260,9 @@ export declare type WebPlayerProps = PropsWithChildren<WebPlayerProps_2> & {
156
260
  onHotspotsOff?: () => void;
157
261
  onGalleryOpen?: () => void;
158
262
  onGalleryClose?: () => void;
263
+ onAnalyticsIdentify?: (event: AnalyticsIdentifyEvent) => void;
264
+ onAnalyticsPage?: (event: AnalyticsPageEvent) => void;
265
+ onAnalyticsTrack?: (event: AnalyticsTrackEvent) => void;
159
266
  } & Pick<React.HTMLAttributes<HTMLElement>, "className" | "style">;
160
267
 
161
268
  declare type WebPlayerProps_2 = {
@@ -184,6 +291,14 @@ declare type WebPlayerProps_2 = {
184
291
  eventPrefix?: string;
185
292
  demoSpin?: boolean;
186
293
  reverse360?: boolean;
294
+
295
+ // Analytics
296
+ analyticsEventPrefix?: string;
297
+ analyticsUrl?: string;
298
+ analyticsBearer?: string;
299
+ analyticsSimpleRequestsOnly?: boolean;
300
+ analyticsDryRun?: boolean;
301
+ analyticsDebug?: boolean;
187
302
  };
188
303
 
189
304
  export { }
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { W as P, a as S, b as W, c as w, d as I, e as L, f as M } from "./shared-BOKJghvy.js";
2
- import { D as oe, j as re, E as se, k as ie, n as ae, m as ce, r as le, q as ue, p as pe, o as me, l as be, g as fe, h as Ee, i as de, s as he } from "./shared-BOKJghvy.js";
1
+ import { W as S, a as P, b as I, c as W, d as w, e as L, f as D } from "./shared-nW6KBfyK.js";
2
+ import { A as oe, s as re, t as se, D as ie, j as ae, E as le, k as ce, n as ue, m as pe, r as me, q as Ee, p as be, o as fe, l as de, g as he, h as ye, i as _e, u as ge } from "./shared-nW6KBfyK.js";
3
3
  import "react/jsx-runtime";
4
- import A from "react";
5
- import { createRoot as D } from "react-dom/client";
6
- var R = Object.defineProperty, V = (e, t, n) => t in e ? R(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, f = (e, t, n) => (V(e, typeof t != "symbol" ? t + "" : t, n), n);
4
+ import N from "react";
5
+ import { createRoot as R } from "react-dom/client";
6
+ var V = Object.defineProperty, M = (e, t, n) => t in e ? V(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, b = (e, t, n) => (M(e, typeof t != "symbol" ? t + "" : t, n), n);
7
7
  const v = {
8
8
  stringify: (e) => e,
9
9
  parse: (e) => e
@@ -27,7 +27,7 @@ const v = {
27
27
  }, F = {
28
28
  stringify: (e) => JSON.stringify(e),
29
29
  parse: (e) => JSON.parse(e)
30
- }, O = {
30
+ }, T = {
31
31
  string: v,
32
32
  number: x,
33
33
  boolean: j,
@@ -40,9 +40,9 @@ function G(e) {
40
40
  (t, n, r) => `${n}-${r.toLowerCase()}`
41
41
  );
42
42
  }
43
- const E = Symbol.for("r2wc.render"), d = Symbol.for("r2wc.connected"), u = Symbol.for("r2wc.context"), l = Symbol.for("r2wc.props");
43
+ const f = Symbol.for("r2wc.render"), d = Symbol.for("r2wc.connected"), u = Symbol.for("r2wc.context"), c = Symbol.for("r2wc.props");
44
44
  function Y(e, t, n) {
45
- var r, b, C;
45
+ var r, E, C;
46
46
  t.props || (t.props = e.propTypes ? Object.keys(e.propTypes) : []);
47
47
  const h = Array.isArray(t.props) ? t.props.slice() : Object.keys(t.props), m = {}, y = {}, _ = {};
48
48
  for (const s of h) {
@@ -50,78 +50,78 @@ function Y(e, t, n) {
50
50
  const o = G(s);
51
51
  y[s] = o, _[o] = s;
52
52
  }
53
- class N extends HTMLElement {
53
+ class A extends HTMLElement {
54
54
  constructor() {
55
- super(), f(this, r, !0), f(this, b), f(this, C, {}), f(this, "container"), t.shadow ? this.container = this.attachShadow({
55
+ super(), b(this, r, !0), b(this, E), b(this, C, {}), b(this, "container"), t.shadow ? this.container = this.attachShadow({
56
56
  mode: t.shadow
57
- }) : this.container = this, this[l].container = this.container;
57
+ }) : this.container = this, this[c].container = this.container;
58
58
  for (const o of h) {
59
- const p = y[o], c = this.getAttribute(p), i = m[o], a = i ? O[i] : null;
60
- a != null && a.parse && c && (this[l][o] = a.parse(c, p, this));
59
+ const p = y[o], l = this.getAttribute(p), i = m[o], a = i ? T[i] : null;
60
+ a != null && a.parse && l && (this[c][o] = a.parse(l, p, this));
61
61
  }
62
62
  }
63
63
  static get observedAttributes() {
64
64
  return Object.keys(_);
65
65
  }
66
66
  connectedCallback() {
67
- this[d] = !0, this[E]();
67
+ this[d] = !0, this[f]();
68
68
  }
69
69
  disconnectedCallback() {
70
70
  this[d] = !1, this[u] && n.unmount(this[u]), delete this[u];
71
71
  }
72
- attributeChangedCallback(o, p, c) {
73
- const i = _[o], a = m[i], g = a ? O[a] : null;
74
- i in m && g != null && g.parse && c && (this[l][i] = g.parse(c, o, this), this[E]());
72
+ attributeChangedCallback(o, p, l) {
73
+ const i = _[o], a = m[i], g = a ? T[a] : null;
74
+ i in m && g != null && g.parse && l && (this[c][i] = g.parse(l, o, this), this[f]());
75
75
  }
76
- [(r = d, b = u, C = l, E)]() {
77
- this[d] && (this[u] ? n.update(this[u], this[l]) : this[u] = n.mount(
76
+ [(r = d, E = u, C = c, f)]() {
77
+ this[d] && (this[u] ? n.update(this[u], this[c]) : this[u] = n.mount(
78
78
  this.container,
79
79
  e,
80
- this[l]
80
+ this[c]
81
81
  ));
82
82
  }
83
83
  }
84
84
  for (const s of h) {
85
85
  const o = y[s], p = m[s];
86
- Object.defineProperty(N.prototype, s, {
86
+ Object.defineProperty(A.prototype, s, {
87
87
  enumerable: !0,
88
88
  configurable: !0,
89
89
  get() {
90
- return this[l][s];
90
+ return this[c][s];
91
91
  },
92
- set(c) {
93
- this[l][s] = c;
94
- const i = p ? O[p] : null;
92
+ set(l) {
93
+ this[c][s] = l;
94
+ const i = p ? T[p] : null;
95
95
  if (i != null && i.stringify) {
96
- const a = i.stringify(c, o, this);
96
+ const a = i.stringify(l, o, this);
97
97
  this.getAttribute(o) !== a && this.setAttribute(o, a);
98
98
  } else
99
- this[E]();
99
+ this[f]();
100
100
  }
101
101
  });
102
102
  }
103
- return N;
103
+ return A;
104
104
  }
105
105
  function B(e, t, n) {
106
- const r = D(e), b = A.createElement(t, n);
107
- return r.render(b), {
106
+ const r = R(e), E = N.createElement(t, n);
107
+ return r.render(E), {
108
108
  root: r,
109
109
  ReactComponent: t
110
110
  };
111
111
  }
112
- function H({ root: e, ReactComponent: t }, n) {
113
- const r = A.createElement(t, n);
112
+ function U({ root: e, ReactComponent: t }, n) {
113
+ const r = N.createElement(t, n);
114
114
  e.render(r);
115
115
  }
116
- function U({ root: e }) {
116
+ function H({ root: e }) {
117
117
  setTimeout(() => {
118
118
  e.unmount();
119
119
  }, 0);
120
120
  }
121
- function T(e, t = {}) {
122
- return Y(e, t, { mount: B, update: H, unmount: U });
121
+ function O(e, t = {}) {
122
+ return Y(e, t, { mount: B, update: U, unmount: H });
123
123
  }
124
- const $ = T(P, {
124
+ const $ = O(S, {
125
125
  shadow: "closed",
126
126
  props: {
127
127
  compositionUrl: "string",
@@ -143,46 +143,56 @@ const $ = T(P, {
143
143
  extendBehavior: "string",
144
144
  eventPrefix: "string",
145
145
  demoSpin: "boolean",
146
- reverse360: "boolean"
146
+ reverse360: "boolean",
147
+ // Analytics
148
+ analyticsEventPrefix: "string",
149
+ analyticsUrl: "string",
150
+ analyticsBearer: "string",
151
+ analyticsSimpleRequestsOnly: "boolean",
152
+ analyticsDryRun: "boolean",
153
+ analyticsDebug: "boolean"
147
154
  }
148
- }), J = T(S, {
155
+ }), J = O(P, {
149
156
  shadow: "closed",
150
157
  props: {
151
158
  index: "number",
152
159
  thumbnailSrc: "string"
153
160
  }
154
- }), X = T(W, {
161
+ }), X = O(I, {
155
162
  shadow: "closed",
156
163
  props: {
157
164
  name: "string"
158
165
  }
159
166
  });
160
167
  function q() {
161
- customElements.define(I, $), customElements.define(
168
+ customElements.define(w, $), customElements.define(
162
169
  L,
163
170
  J
164
- ), customElements.define(M, X);
171
+ ), customElements.define(D, X);
165
172
  }
166
173
  function z() {
167
- w() || q();
174
+ W() || q();
168
175
  }
169
176
  z();
170
177
  export {
171
- oe as DEFAULT_EVENT_PREFIX,
172
- re as EVENT_COMPOSITION_LOADED,
173
- se as EVENT_COMPOSITION_LOADING,
174
- ie as EVENT_COMPOSITION_LOAD_ERROR,
175
- ae as EVENT_EXTEND_MODE_OFF,
176
- ce as EVENT_EXTEND_MODE_ON,
177
- le as EVENT_GALLERY_CLOSE,
178
- ue as EVENT_GALLERY_OPEN,
179
- pe as EVENT_HOTSPOTS_OFF,
180
- me as EVENT_HOTSPOTS_ON,
181
- be as EVENT_ITEM_CHANGE,
182
- M as WEB_PLAYER_ICON_WC_TAG,
183
- I as WEB_PLAYER_WC_TAG,
184
- fe as WebPlayer,
185
- Ee as WebPlayerCustomMedia,
186
- de as WebPlayerIcon,
187
- he as generateCompositionUrl
178
+ oe as ANALYTICS_EVENT_IDENTIFY,
179
+ re as ANALYTICS_EVENT_PAGE,
180
+ se as ANALYTICS_EVENT_TRACK,
181
+ ie as DEFAULT_EVENT_PREFIX,
182
+ ae as EVENT_COMPOSITION_LOADED,
183
+ le as EVENT_COMPOSITION_LOADING,
184
+ ce as EVENT_COMPOSITION_LOAD_ERROR,
185
+ ue as EVENT_EXTEND_MODE_OFF,
186
+ pe as EVENT_EXTEND_MODE_ON,
187
+ me as EVENT_GALLERY_CLOSE,
188
+ Ee as EVENT_GALLERY_OPEN,
189
+ be as EVENT_HOTSPOTS_OFF,
190
+ fe as EVENT_HOTSPOTS_ON,
191
+ de as EVENT_ITEM_CHANGE,
192
+ D as WEB_PLAYER_ICON_WC_TAG,
193
+ w as WEB_PLAYER_WC_TAG,
194
+ he as WebPlayer,
195
+ ye as WebPlayerCustomMedia,
196
+ _e as WebPlayerIcon,
197
+ ge as generateCompositionUrl
188
198
  };
package/dist/legacy.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./shared-Bps5mZ-a.cjs");require("react/jsx-runtime");const W=require("react"),y=require("react-dom");var S=Object.defineProperty,L=(e,t,r)=>t in e?S(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,O=(e,t,r)=>(L(e,typeof t!="symbol"?t+"":t,r),r);const I={stringify:e=>e,parse:e=>e},V={stringify:e=>`${e}`,parse:e=>parseFloat(e)},M={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},R={stringify:e=>e.name,parse:(e,t,r)=>{const s=(()=>{if(typeof window<"u"&&e in window)return window[e];if(typeof global<"u"&&e in global)return global[e]})();return typeof s=="function"?s.bind(r):void 0}},D={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)},N={string:I,number:V,boolean:M,function:R,json:D};function w(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,r,s)=>`${r}-${s.toLowerCase()}`)}const b=Symbol.for("r2wc.render"),d=Symbol.for("r2wc.connected"),u=Symbol.for("r2wc.context"),l=Symbol.for("r2wc.props");function G(e,t,r){var s,A,P;t.props||(t.props=e.propTypes?Object.keys(e.propTypes):[]);const T=Array.isArray(t.props)?t.props.slice():Object.keys(t.props),p={},m={},f={};for(const i of T){p[i]=Array.isArray(t.props)?"string":t.props[i];const o=w(i);m[i]=o,f[o]=i}class g extends HTMLElement{constructor(){super(),O(this,s,!0),O(this,A),O(this,P,{}),O(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[l].container=this.container;for(const o of T){const _=m[o],c=this.getAttribute(_),a=p[o],E=a?N[a]:null;E!=null&&E.parse&&c&&(this[l][o]=E.parse(c,_,this))}}static get observedAttributes(){return Object.keys(f)}connectedCallback(){this[d]=!0,this[b]()}disconnectedCallback(){this[d]=!1,this[u]&&r.unmount(this[u]),delete this[u]}attributeChangedCallback(o,_,c){const a=f[o],E=p[a],h=E?N[E]:null;a in p&&h!=null&&h.parse&&c&&(this[l][a]=h.parse(c,o,this),this[b]())}[(s=d,A=u,P=l,b)](){this[d]&&(this[u]?r.update(this[u],this[l]):this[u]=r.mount(this.container,e,this[l]))}}for(const i of T){const o=m[i],_=p[i];Object.defineProperty(g.prototype,i,{enumerable:!0,configurable:!0,get(){return this[l][i]},set(c){this[l][i]=c;const a=_?N[_]:null;if(a!=null&&a.stringify){const E=a.stringify(c,o,this);this.getAttribute(o)!==E&&this.setAttribute(o,E)}else this[b]()}})}return g}function F(e,t,r){const s=W.createElement(t,r);return y.render(s,e),{container:e,ReactComponent:t}}function v({container:e,ReactComponent:t},r){const s=W.createElement(t,r);y.render(s,e)}function Y({container:e}){y.unmountComponentAtNode(e)}function C(e,t={}){return G(e,t,{mount:F,update:v,unmount:Y})}const j=C(n.WebPlayerWithInjectedStyles,{shadow:"closed",props:{compositionUrl:"string",hideCategoriesNav:"boolean",infiniteCarrousel:"boolean",permanentGallery:"boolean",minMediaWidth:"number",maxMediaWidth:"number",mediaLoadStrategy:"string",preloadRange:"number",autoLoad360:"boolean",autoLoadInterior360:"boolean",categoriesFilter:"string",extendBehavior:"string",eventPrefix:"string",demoSpin:"boolean",reverse360:"boolean"}}),k=C(n.WebPlayerCustomMedia,{shadow:"closed",props:{index:"number",thumbnailSrc:"string"}}),B=C(n.WebPlayerIcon,{shadow:"closed",props:{name:"string"}});function $(){customElements.define(n.WEB_PLAYER_WC_TAG,j),customElements.define(n.WEB_PLAYER_CUSTOM_MEDIA_WC_TAG,k),customElements.define(n.WEB_PLAYER_ICON_WC_TAG,B)}function x(){n.checkCustomElementsDefinition()||$()}x();exports.DEFAULT_EVENT_PREFIX=n.DEFAULT_EVENT_PREFIX;exports.EVENT_COMPOSITION_LOADED=n.EVENT_COMPOSITION_LOADED;exports.EVENT_COMPOSITION_LOADING=n.EVENT_COMPOSITION_LOADING;exports.EVENT_COMPOSITION_LOAD_ERROR=n.EVENT_COMPOSITION_LOAD_ERROR;exports.EVENT_EXTEND_MODE_OFF=n.EVENT_EXTEND_MODE_OFF;exports.EVENT_EXTEND_MODE_ON=n.EVENT_EXTEND_MODE_ON;exports.EVENT_GALLERY_CLOSE=n.EVENT_GALLERY_CLOSE;exports.EVENT_GALLERY_OPEN=n.EVENT_GALLERY_OPEN;exports.EVENT_HOTSPOTS_OFF=n.EVENT_HOTSPOTS_OFF;exports.EVENT_HOTSPOTS_ON=n.EVENT_HOTSPOTS_ON;exports.EVENT_ITEM_CHANGE=n.EVENT_ITEM_CHANGE;exports.WEB_PLAYER_ICON_WC_TAG=n.WEB_PLAYER_ICON_WC_TAG;exports.WEB_PLAYER_WC_TAG=n.WEB_PLAYER_WC_TAG;exports.WebPlayer=n.WebPlayer;exports.WebPlayerCustomMedia=n.WebPlayerCustomMedia$1;exports.WebPlayerIcon=n.WebPlayerIcon$1;exports.generateCompositionUrl=n.generateCompositionUrl;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./shared-BWLUv51h.cjs");require("react/jsx-runtime");const I=require("react"),f=require("react-dom");var S=Object.defineProperty,L=(e,n,r)=>n in e?S(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,p=(e,n,r)=>(L(e,typeof n!="symbol"?n+"":n,r),r);const W={stringify:e=>e,parse:e=>e},V={stringify:e=>`${e}`,parse:e=>parseFloat(e)},R={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},D={stringify:e=>e.name,parse:(e,n,r)=>{const s=(()=>{if(typeof window<"u"&&e in window)return window[e];if(typeof global<"u"&&e in global)return global[e]})();return typeof s=="function"?s.bind(r):void 0}},M={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)},A={string:W,number:V,boolean:R,function:D,json:M};function w(e){return e.replace(/([a-z0-9])([A-Z])/g,(n,r,s)=>`${r}-${s.toLowerCase()}`)}const b=Symbol.for("r2wc.render"),N=Symbol.for("r2wc.connected"),u=Symbol.for("r2wc.context"),c=Symbol.for("r2wc.props");function Y(e,n,r){var s,C,g;n.props||(n.props=e.propTypes?Object.keys(e.propTypes):[]);const O=Array.isArray(n.props)?n.props.slice():Object.keys(n.props),T={},d={},m={};for(const i of O){T[i]=Array.isArray(n.props)?"string":n.props[i];const o=w(i);d[i]=o,m[o]=i}class P extends HTMLElement{constructor(){super(),p(this,s,!0),p(this,C),p(this,g,{}),p(this,"container"),n.shadow?this.container=this.attachShadow({mode:n.shadow}):this.container=this,this[c].container=this.container;for(const o of O){const _=d[o],l=this.getAttribute(_),a=T[o],E=a?A[a]:null;E!=null&&E.parse&&l&&(this[c][o]=E.parse(l,_,this))}}static get observedAttributes(){return Object.keys(m)}connectedCallback(){this[N]=!0,this[b]()}disconnectedCallback(){this[N]=!1,this[u]&&r.unmount(this[u]),delete this[u]}attributeChangedCallback(o,_,l){const a=m[o],E=T[a],y=E?A[E]:null;a in T&&y!=null&&y.parse&&l&&(this[c][a]=y.parse(l,o,this),this[b]())}[(s=N,C=u,g=c,b)](){this[N]&&(this[u]?r.update(this[u],this[c]):this[u]=r.mount(this.container,e,this[c]))}}for(const i of O){const o=d[i],_=T[i];Object.defineProperty(P.prototype,i,{enumerable:!0,configurable:!0,get(){return this[c][i]},set(l){this[c][i]=l;const a=_?A[_]:null;if(a!=null&&a.stringify){const E=a.stringify(l,o,this);this.getAttribute(o)!==E&&this.setAttribute(o,E)}else this[b]()}})}return P}function G(e,n,r){const s=I.createElement(n,r);return f.render(s,e),{container:e,ReactComponent:n}}function F({container:e,ReactComponent:n},r){const s=I.createElement(n,r);f.render(s,e)}function v({container:e}){f.unmountComponentAtNode(e)}function h(e,n={}){return Y(e,n,{mount:G,update:F,unmount:v})}const j=h(t.WebPlayerWithInjectedStyles,{shadow:"closed",props:{compositionUrl:"string",hideCategoriesNav:"boolean",infiniteCarrousel:"boolean",permanentGallery:"boolean",minMediaWidth:"number",maxMediaWidth:"number",mediaLoadStrategy:"string",preloadRange:"number",autoLoad360:"boolean",autoLoadInterior360:"boolean",categoriesFilter:"string",extendBehavior:"string",eventPrefix:"string",demoSpin:"boolean",reverse360:"boolean",analyticsEventPrefix:"string",analyticsUrl:"string",analyticsBearer:"string",analyticsSimpleRequestsOnly:"boolean",analyticsDryRun:"boolean",analyticsDebug:"boolean"}}),B=h(t.WebPlayerCustomMedia,{shadow:"closed",props:{index:"number",thumbnailSrc:"string"}}),k=h(t.WebPlayerIcon,{shadow:"closed",props:{name:"string"}});function x(){customElements.define(t.WEB_PLAYER_WC_TAG,j),customElements.define(t.WEB_PLAYER_CUSTOM_MEDIA_WC_TAG,B),customElements.define(t.WEB_PLAYER_ICON_WC_TAG,k)}function $(){t.checkCustomElementsDefinition()||x()}$();exports.ANALYTICS_EVENT_IDENTIFY=t.ANALYTICS_EVENT_IDENTIFY;exports.ANALYTICS_EVENT_PAGE=t.ANALYTICS_EVENT_PAGE;exports.ANALYTICS_EVENT_TRACK=t.ANALYTICS_EVENT_TRACK;exports.DEFAULT_EVENT_PREFIX=t.DEFAULT_EVENT_PREFIX;exports.EVENT_COMPOSITION_LOADED=t.EVENT_COMPOSITION_LOADED;exports.EVENT_COMPOSITION_LOADING=t.EVENT_COMPOSITION_LOADING;exports.EVENT_COMPOSITION_LOAD_ERROR=t.EVENT_COMPOSITION_LOAD_ERROR;exports.EVENT_EXTEND_MODE_OFF=t.EVENT_EXTEND_MODE_OFF;exports.EVENT_EXTEND_MODE_ON=t.EVENT_EXTEND_MODE_ON;exports.EVENT_GALLERY_CLOSE=t.EVENT_GALLERY_CLOSE;exports.EVENT_GALLERY_OPEN=t.EVENT_GALLERY_OPEN;exports.EVENT_HOTSPOTS_OFF=t.EVENT_HOTSPOTS_OFF;exports.EVENT_HOTSPOTS_ON=t.EVENT_HOTSPOTS_ON;exports.EVENT_ITEM_CHANGE=t.EVENT_ITEM_CHANGE;exports.WEB_PLAYER_ICON_WC_TAG=t.WEB_PLAYER_ICON_WC_TAG;exports.WEB_PLAYER_WC_TAG=t.WEB_PLAYER_WC_TAG;exports.WebPlayer=t.WebPlayer;exports.WebPlayerCustomMedia=t.WebPlayerCustomMedia$1;exports.WebPlayerIcon=t.WebPlayerIcon$1;exports.generateCompositionUrl=t.generateCompositionUrl;
package/dist/legacy.d.ts CHANGED
@@ -1,6 +1,107 @@
1
1
  import { FC } from 'react';
2
2
  import { PropsWithChildren } from 'react';
3
3
 
4
+ export declare const ANALYTICS_EVENT_IDENTIFY = "analytics-identify";
5
+
6
+ export declare const ANALYTICS_EVENT_PAGE = "analytics-page";
7
+
8
+ export declare const ANALYTICS_EVENT_TRACK = "analytics-track";
9
+
10
+ declare type AnalyticsEventBase = {
11
+ type: AnalyticsEventType;
12
+ timestamp: string;
13
+ instance_id: string;
14
+ };
15
+
16
+ declare type AnalyticsEventType =
17
+ | AnalyticsEventTypeIdentify
18
+ | AnalyticsEventTypePage
19
+ | AnalyticsEventTypeTrack;
20
+
21
+ declare type AnalyticsEventTypeIdentify = "identify";
22
+
23
+ declare type AnalyticsEventTypePage = "page";
24
+
25
+ declare type AnalyticsEventTypeTrack = "track";
26
+
27
+ declare type AnalyticsIdentifyEvent = Omit<AnalyticsEventBase, "type"> &
28
+ AnalyticsIdentifyEventProps;
29
+
30
+ declare type AnalyticsIdentifyEventProps = {
31
+ type: AnalyticsEventTypeIdentify;
32
+ browser_id: string;
33
+ session_id: string;
34
+ referrer: string;
35
+ origin: string;
36
+ page_url: string;
37
+ user_agent: string;
38
+ wp_properties: {
39
+ composition_url: string;
40
+
41
+ // Integration mode
42
+ integration: boolean;
43
+ max_items_shown: number;
44
+
45
+ // Layout
46
+ hide_categories_nav: boolean;
47
+ infinite_carrousel: boolean;
48
+ permanent_gallery: boolean;
49
+
50
+ // Medias loading
51
+ media_load_strategy: string;
52
+ min_media_width: number;
53
+ max_media_width: number;
54
+ preload_range: number;
55
+ auto_load_360: boolean;
56
+ auto_load_interior_360: boolean;
57
+
58
+ // Miscellaneous
59
+ categories_filter: string;
60
+ extend_behavior: string;
61
+ event_prefix: string;
62
+ demo_spin: boolean;
63
+ reverse_360: boolean;
64
+ };
65
+ };
66
+
67
+ declare type AnalyticsPageEvent = Omit<AnalyticsEventBase, "type"> &
68
+ AnalyticsPageEventProps;
69
+
70
+ declare type AnalyticsPageEventProps = {
71
+ type: AnalyticsEventTypePage;
72
+ category_id: string;
73
+ category_name: string;
74
+ items_count: number;
75
+ page_properties: {
76
+ item_type: string;
77
+ item_position: number;
78
+ };
79
+ };
80
+
81
+ declare type AnalyticsTrackEvent = Omit<AnalyticsEventBase, "type"> &
82
+ AnalyticsTrackEventProps;
83
+
84
+ declare type AnalyticsTrackEventProps = {
85
+ type: AnalyticsEventTypeTrack;
86
+ category_id: string;
87
+ category_name: string;
88
+ item_type: string;
89
+ item_position: number;
90
+ action_properties: {
91
+ action_name: string;
92
+ action_field: string;
93
+ action_value:
94
+ | bigint
95
+ | boolean
96
+ | null
97
+ | number
98
+ | string
99
+ | symbol
100
+ | undefined
101
+ | object;
102
+ };
103
+ };
104
+
4
105
  declare type AspectRatio = `${number}:${number}`;
5
106
 
6
107
  declare type Category = {
@@ -43,7 +144,7 @@ declare type ExtendBehavior = "full_screen" | "event" | "none";
43
144
  /**
44
145
  * Generates a URL for fetching the composition JSON for a given customer and vehicle.
45
146
  *
46
- * @param {string} customerToken - The CarCutter Customer Token (computed by hasing the Customer ID with SHA-256).
147
+ * @param {string} customerToken - The CarCutter Customer Token (computed by hashing the Customer ID with SHA-256).
47
148
  * @param {string} vin - The Vehicle Identification Number.
48
149
  * @returns {string} The URL to fetch the composition JSON.
49
150
  */
@@ -58,6 +159,7 @@ declare type Hotspot = {
58
159
  title: string;
59
160
  icon?: string;
60
161
  description?: string;
162
+ type?: "damage" | "feature";
61
163
  position: {
62
164
  x: number;
63
165
  y: number;
@@ -129,8 +231,10 @@ declare type WebPlayerIconName =
129
231
  | "UI_PLAY" // Play video
130
232
  | "UI_PLUS" // Increase zoom
131
233
  | "UI_REDUCE" // Reducing an extended view
132
- | "UI_360" // 360-degree view
133
- | "UI_INTERIOR_360" // interior 360 view
234
+ | "UI_360" // Exterior 360 view
235
+ | "UI_360_PLAY" // Play exterior 360
236
+ | "UI_INTERIOR_360" // Interior 360 view
237
+ | "UI_INTERIOR_360_PLAY" // Play interior 360 view
134
238
  | "UI_VOLUME" // Video volume
135
239
  | "UI_VOLUME_OFF" // Muted video
136
240
  | "CONTROLS_PREV" // Go to previous media
@@ -156,6 +260,9 @@ export declare type WebPlayerProps = PropsWithChildren<WebPlayerProps_2> & {
156
260
  onHotspotsOff?: () => void;
157
261
  onGalleryOpen?: () => void;
158
262
  onGalleryClose?: () => void;
263
+ onAnalyticsIdentify?: (event: AnalyticsIdentifyEvent) => void;
264
+ onAnalyticsPage?: (event: AnalyticsPageEvent) => void;
265
+ onAnalyticsTrack?: (event: AnalyticsTrackEvent) => void;
159
266
  } & Pick<React.HTMLAttributes<HTMLElement>, "className" | "style">;
160
267
 
161
268
  declare type WebPlayerProps_2 = {
@@ -184,6 +291,14 @@ declare type WebPlayerProps_2 = {
184
291
  eventPrefix?: string;
185
292
  demoSpin?: boolean;
186
293
  reverse360?: boolean;
294
+
295
+ // Analytics
296
+ analyticsEventPrefix?: string;
297
+ analyticsUrl?: string;
298
+ analyticsBearer?: string;
299
+ analyticsSimpleRequestsOnly?: boolean;
300
+ analyticsDryRun?: boolean;
301
+ analyticsDebug?: boolean;
187
302
  };
188
303
 
189
304
  export { }