@ticketboothapp/booking 1.2.28 → 1.2.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ticketboothapp/booking",
3
- "version": "1.2.28",
3
+ "version": "1.2.29",
4
4
  "private": false,
5
5
  "sideEffects": [
6
6
  "**/*.css",
@@ -3,7 +3,7 @@
3
3
  import { useState, useRef, useEffect, useCallback } from 'react';
4
4
  import BackgroundPlayer from 'next-video/background-player';
5
5
  import type { VideoSources } from '../../../../../src/constants/products';
6
- import { useBookingHost } from '../../runtime';
6
+ import { resolvePublicAssetUrl, useBookingHost } from '../../runtime';
7
7
  import { useTranslations } from '../../../../../src/lib/booking/i18n';
8
8
  import styles from './BookingFlowCollage.module.css';
9
9
 
@@ -29,14 +29,19 @@ export function BookingFlowCollage({
29
29
  imageIds,
30
30
  altPrefix = 'Tour',
31
31
  }: BookingFlowCollageProps) {
32
- const { catalog, slots } = useBookingHost();
32
+ const { catalog, slots, env } = useBookingHost();
33
33
  const ViaViaImage = slots.Image;
34
34
  const ImageModal = slots.ImageModal;
35
35
  const videoSrc = video ?? DEFAULT_VIDEO;
36
36
  // Use long version in BookingFlow when available; fall back to short
37
- const videoForCollage = (videoSrc.longSrc && videoSrc.longWebm)
38
- ? { src: videoSrc.longSrc, webm: videoSrc.longWebm }
39
- : { src: videoSrc.src, webm: videoSrc.webm };
37
+ const videoForCollageRaw =
38
+ videoSrc.longSrc && videoSrc.longWebm
39
+ ? { src: videoSrc.longSrc, webm: videoSrc.longWebm }
40
+ : { src: videoSrc.src, webm: videoSrc.webm };
41
+ const videoForCollage = {
42
+ src: resolvePublicAssetUrl(env.STATIC_ASSET_ORIGIN, videoForCollageRaw.src),
43
+ webm: resolvePublicAssetUrl(env.STATIC_ASSET_ORIGIN, videoForCollageRaw.webm),
44
+ };
40
45
  const posterUrl =
41
46
  videoPosterImageId && catalog.getImageUrl
42
47
  ? String(catalog.getImageUrl(videoPosterImageId))
@@ -6,7 +6,7 @@ import {
6
6
  useBookingDialog,
7
7
  type ProductGridRestoreState,
8
8
  } from '../../providers/booking-dialog-provider';
9
- import { useBookingHost } from '../../runtime';
9
+ import { resolvePublicAssetUrl, useBookingHost } from '../../runtime';
10
10
  import { useLocale, useTranslations } from '../../../../../src/lib/booking/i18n';
11
11
  import type { Product } from '../../../../../src/constants/products';
12
12
  import BackgroundPlayer from 'next-video/background-player';
@@ -48,12 +48,19 @@ export const FILTER_IDS = ['all', 'sunrise', 'moraine-lake', 'lake-louise', 'eme
48
48
  export type FilterId = (typeof FILTER_IDS)[number];
49
49
 
50
50
  /** Only `src` / `webm` — never spread catalog `VideoSources` onto BackgroundPlayer (`longSrc`/`longWebm` are not valid DOM props). */
51
- function backgroundPlayerSources(product: Product): { src: string; webm: string } {
51
+ function backgroundPlayerSources(
52
+ product: Product,
53
+ staticAssetOrigin: string,
54
+ ): { src: string; webm: string } {
52
55
  const v = product.videoUrl ?? DEFAULT_VIDEO;
53
- if (v.longSrc && v.longWebm) {
54
- return { src: v.longSrc, webm: v.longWebm };
55
- }
56
- return { src: v.src, webm: v.webm };
56
+ const raw =
57
+ v.longSrc && v.longWebm
58
+ ? { src: v.longSrc, webm: v.longWebm }
59
+ : { src: v.src, webm: v.webm };
60
+ return {
61
+ src: resolvePublicAssetUrl(staticAssetOrigin, raw.src),
62
+ webm: resolvePublicAssetUrl(staticAssetOrigin, raw.webm),
63
+ };
57
64
  }
58
65
 
59
66
  function BookingProductTileCollapsed({
@@ -140,7 +147,7 @@ function BookingProductTileExpanded({
140
147
  }) {
141
148
  const [isClosing, setIsClosing] = useState(false);
142
149
  const { locale } = useLocale();
143
- const { slots, catalog, strings } = useBookingHost();
150
+ const { slots, catalog, strings, env } = useBookingHost();
144
151
  const defaultStrings = strings as HostedProductGridStrings;
145
152
  const ViaViaImage = slots.Image;
146
153
  const ProductTag = slots.ProductTag;
@@ -211,7 +218,7 @@ function BookingProductTileExpanded({
211
218
  </motion.svg>
212
219
  </button>
213
220
  <BackgroundPlayer
214
- {...backgroundPlayerSources(product)}
221
+ {...backgroundPlayerSources(product, env.STATIC_ASSET_ORIGIN)}
215
222
  autoPlay
216
223
  muted
217
224
  loop
package/src/index.ts CHANGED
@@ -39,6 +39,7 @@ export {
39
39
  BookingHostProvider,
40
40
  useBookingHost,
41
41
  useBookingHostOptional,
42
+ resolvePublicAssetUrl,
42
43
  } from './runtime';
43
44
 
44
45
  export {
@@ -11,3 +11,4 @@ export {
11
11
  useBookingHost,
12
12
  useBookingHostOptional,
13
13
  } from './BookingHostContext';
14
+ export { resolvePublicAssetUrl } from './resolve-public-asset-url';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Prefix root-relative public paths (`/videos/…`) when the booking UI runs off-origin
3
+ * (e.g. Ticketbooth dashboard). Empty `staticAssetOrigin` keeps paths relative (main Via Via site).
4
+ */
5
+ export function resolvePublicAssetUrl(
6
+ staticAssetOrigin: string | undefined,
7
+ path: string,
8
+ ): string {
9
+ const p = path?.trim() ?? '';
10
+ if (!p) return p;
11
+ if (/^https?:\/\//i.test(p)) return p;
12
+ const normalizedPath = p.startsWith('/') ? p : `/${p}`;
13
+ const base = (staticAssetOrigin ?? '').trim().replace(/\/+$/, '');
14
+ if (!base) return normalizedPath;
15
+ return `${base}${normalizedPath}`;
16
+ }
@@ -16,6 +16,11 @@ export interface BookingRuntimeEnv {
16
16
  readonly BASIC_AUTH: string;
17
17
  readonly GA4_MEASUREMENT_ID: string;
18
18
  readonly META_PIXEL_ID: string;
19
+ /**
20
+ * Origin for root-relative media (`/videos/…`, etc.) when the host is not viavia.com.
21
+ * Empty string = keep relative URLs (production Via Via site).
22
+ */
23
+ readonly STATIC_ASSET_ORIGIN: string;
19
24
  }
20
25
 
21
26
  export interface BookingRuntimeAnalytics {