@ticketboothapp/booking 1.2.27 → 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 +1 -1
- package/src/components/booking/BookingFlowCollage.tsx +10 -5
- package/src/components/booking/BookingProductGrid.tsx +17 -5
- package/src/index.ts +1 -0
- package/src/runtime/index.ts +1 -0
- package/src/runtime/resolve-public-asset-url.ts +16 -0
- package/src/runtime/types.ts +5 -0
package/package.json
CHANGED
|
@@ -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
|
|
38
|
-
|
|
39
|
-
|
|
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';
|
|
@@ -47,8 +47,20 @@ const FILTER_PRODUCT_IDS: Record<string, string[]> = {
|
|
|
47
47
|
export const FILTER_IDS = ['all', 'sunrise', 'moraine-lake', 'lake-louise', 'emerald-lake', 'private'] as const;
|
|
48
48
|
export type FilterId = (typeof FILTER_IDS)[number];
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
/** Only `src` / `webm` — never spread catalog `VideoSources` onto BackgroundPlayer (`longSrc`/`longWebm` are not valid DOM props). */
|
|
51
|
+
function backgroundPlayerSources(
|
|
52
|
+
product: Product,
|
|
53
|
+
staticAssetOrigin: string,
|
|
54
|
+
): { src: string; webm: string } {
|
|
55
|
+
const v = product.videoUrl ?? DEFAULT_VIDEO;
|
|
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
|
+
};
|
|
52
64
|
}
|
|
53
65
|
|
|
54
66
|
function BookingProductTileCollapsed({
|
|
@@ -135,7 +147,7 @@ function BookingProductTileExpanded({
|
|
|
135
147
|
}) {
|
|
136
148
|
const [isClosing, setIsClosing] = useState(false);
|
|
137
149
|
const { locale } = useLocale();
|
|
138
|
-
const { slots, catalog, strings } = useBookingHost();
|
|
150
|
+
const { slots, catalog, strings, env } = useBookingHost();
|
|
139
151
|
const defaultStrings = strings as HostedProductGridStrings;
|
|
140
152
|
const ViaViaImage = slots.Image;
|
|
141
153
|
const ProductTag = slots.ProductTag;
|
|
@@ -206,7 +218,7 @@ function BookingProductTileExpanded({
|
|
|
206
218
|
</motion.svg>
|
|
207
219
|
</button>
|
|
208
220
|
<BackgroundPlayer
|
|
209
|
-
{...
|
|
221
|
+
{...backgroundPlayerSources(product, env.STATIC_ASSET_ORIGIN)}
|
|
210
222
|
autoPlay
|
|
211
223
|
muted
|
|
212
224
|
loop
|
package/src/index.ts
CHANGED
package/src/runtime/index.ts
CHANGED
|
@@ -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
|
+
}
|
package/src/runtime/types.ts
CHANGED
|
@@ -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 {
|