bookito-widget 1.3.0-beta.3 → 1.3.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/README.md +24 -34
- package/dist/bookito-widget.css +1 -1
- package/dist/bookito-widget.iife.js +33 -33
- package/dist/bookito-widget.js +5213 -5250
- package/dist/bookito-widget.umd.js +112 -1
- package/dist/bookito-widget.window.js +112 -1
- package/dist/src/embed/mount.d.ts +1 -1
- package/dist/src/embed/open-modal.d.ts +1 -1
- package/package.json +5 -5
- package/dist/bookito-widget.loader.js +0 -1
- package/dist/src/embed/normalize-options.d.ts +0 -10
- package/dist/src/loader/hotel-api.d.ts +0 -12
- package/dist/src/loader/hotel-id-source.d.ts +0 -4
- package/dist/src/loader/loader-config.d.ts +0 -2
- package/dist/src/loader/run-loader.d.ts +0 -7
- package/dist/src/loader.d.ts +0 -1
|
@@ -8,5 +8,5 @@ export type InitializeBookitoWidgetOptionsType = BookitoWidgetPropsType & {
|
|
|
8
8
|
container: HTMLElement | string;
|
|
9
9
|
customCss?: string;
|
|
10
10
|
};
|
|
11
|
-
export declare function mountBookitoWidget(
|
|
11
|
+
export declare function mountBookitoWidget(options: InitializeBookitoWidgetOptionsType): MountedWidgetType;
|
|
12
12
|
export declare function unmountBookitoWidget(container: HTMLElement | string): void;
|
|
@@ -8,4 +8,4 @@ export type OpenBookitoModalOptionsType = {
|
|
|
8
8
|
language?: SupportedLanguageType;
|
|
9
9
|
onCloseModal?: () => void;
|
|
10
10
|
};
|
|
11
|
-
export declare function openBookitoModal(
|
|
11
|
+
export declare function openBookitoModal(options: OpenBookitoModalOptionsType): MountedWidgetType;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bookito-widget",
|
|
3
|
-
"version": "1.3.0
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Embeddable Bookito booking widget for hotel websites",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"main": "./dist/bookito-widget.umd.js",
|
|
12
12
|
"module": "./dist/bookito-widget.js",
|
|
13
13
|
"types": "./dist/src/index.d.ts",
|
|
14
|
-
"unpkg": "./dist/bookito-widget.
|
|
15
|
-
"jsdelivr": "./dist/bookito-widget.
|
|
14
|
+
"unpkg": "./dist/bookito-widget.iife.js",
|
|
15
|
+
"jsdelivr": "./dist/bookito-widget.iife.js",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
18
|
"types": "./dist/src/index.d.ts",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"scripts": {
|
|
28
28
|
"dev": "vite",
|
|
29
29
|
"build": "run-p type-check \"build-only {@}\" --",
|
|
30
|
-
"build:lib": "vite build --config vite.library.config.ts && vite build --config vite.embed.config.ts
|
|
31
|
-
"preview:embed": "VITE_STAGE=prerelease npm run build:lib && vite preview --config vite.embed.config.ts --outDir . --port 5175 --strictPort --open /embed-test/
|
|
30
|
+
"build:lib": "vite build --config vite.library.config.ts && vite build --config vite.embed.config.ts",
|
|
31
|
+
"preview:embed": "VITE_STAGE=prerelease npm run build:lib && vite preview --config vite.embed.config.ts --outDir . --port 5175 --strictPort --open /embed-test/",
|
|
32
32
|
"build-only": "vite build",
|
|
33
33
|
"preview": "vite preview",
|
|
34
34
|
"test:unit": "vitest --project unit",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(){var e={carlito_federation:{production:`https://federation-prod.carlito-app.com`,prerelease:`https://federation-staging.carlito-app.com`,development:`https://federation-staging.carlito-app.com`},gateway:{production:`https://epificcu94.execute-api.eu-central-1.amazonaws.com/production`,prerelease:`https://4kkst32tm6.execute-api.eu-central-1.amazonaws.com/staging`,development:`https://4kkst32tm6.execute-api.eu-central-1.amazonaws.com/staging`},main_content:{development:`https://strapi-dev.carlito-app.com`,prerelease:`https://strapi-dev.carlito-app.com`,production:`https://strapi-prod.carlito-app.com`}};function t(){return`prerelease`}function n(n,a=t()){if(n===`main_content`){let e=i(void 0);if(e)return e}if(n===`carlito_federation`){let e=r(a);if(e)return e}return e[n][a]}function r(e){return e===`development`||e===`prerelease`?i(void 0):``}function i(e){return e?.trim().replace(/\/+$/,``)??``}var a=2e3;function o(){let e=t(),r=e===`production`,i=r?`legacy`:`legacy-next`,o=r?`latest`:`next`;return{legacyUrl:`https://unpkg.com/bookito-widget@${i}/dist/bookito-widget.umd.js`,strapiUrl:n(`main_content`,e),timeoutMs:a,vueUrl:`https://unpkg.com/bookito-widget@${o}/dist/bookito-widget.iife.js`}}var s=[`useNewGuestApp`],c=/^\d+$/;async function l(e,t,n){if(!c.test(t))return{ok:!1,reason:`invalid_hotel_id`};let r=s.map((e,t)=>`fields[${t}]=${e}`).join(`&`),i=new AbortController,a=setTimeout(()=>i.abort(),n);try{let n=await fetch(`${e}/api/hotels/${t}?${r}`,{signal:i.signal});return n.ok?{ok:!0,hotel:u(await n.json())}:{ok:!1,reason:`http_${n.status}`}}catch{return{ok:!1,reason:i.signal.aborted?`timeout`:`request_failed`}}finally{clearTimeout(a)}}function u(e){return{useNewGuestApp:(e.data?.attributes??e.data??{}).useNewGuestApp===!0}}function d(){let e,t=new Promise(t=>{e=t}),n=t=>{let n=f(t);n&&e&&(e(n),e=void 0)},r=()=>{for(let e of document.querySelectorAll(`bookito-widget`))n(e.getAttribute(`auth-id`)||e.getAttribute(`authId`))};if(r(),e){let e=new MutationObserver(r);e.observe(document.documentElement,{childList:!0,subtree:!0}),t.then(()=>e.disconnect())}return{firstId:t,offer:n}}function f(e){return typeof e==`number`?String(e):typeof e==`string`?e.trim():``}var p=globalThis;async function m(e){if(p.bookitoWidget)return;let t=[],{firstId:n,offer:r}=d(),i,a=e=>{if(!i){t.push(e);return}h(i,e)},o={initialize(e){a([`initialize`,e]),r(e?.authId)},openBookitoModal(e){a([`openBookitoModal`,e]),r(e?.authId)},unmount(e){a([`unmount`,e])}};p.bookitoWidget=o;let s=await n,c=e.legacyUrl,u=await l(e.strapiUrl,s,e.timeoutMs);u.ok||console.warn(`bookito-widget: hotel flag unavailable (${u.reason}), loading the legacy widget`);let f=u.ok&&u.hotel.useNewGuestApp?e.vueUrl:c,m=()=>{let e=p.bookitoWidget;if(!(!e||e===o)){i=e;for(let n of t.splice(0))h(e,n)}};g(f,m,()=>{if(f===c){console.error(`bookito-widget: could not load ${f}`);return}console.warn(`bookito-widget: could not load ${f}, loading the legacy widget`),g(c,m,()=>{console.error(`bookito-widget: could not load ${c}`)})})}function h(e,[t,n]){let r=e[t];if(typeof r!=`function`){console.warn(`bookito-widget: the loaded widget has no ${t}, call skipped`);return}try{r.call(e,n)}catch(e){console.error(`bookito-widget: ${t} failed`,e)}}function g(e,t,n){let r=document.createElement(`script`);r.src=e,r.addEventListener(`load`,t),r.addEventListener(`error`,n),document.head.append(r)}m(o())})();
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BookitoWidgetViewModeType } from '../../features/event-feed/model/widget.types';
|
|
2
|
-
import { SupportedLanguageType } from '../../shared/config/languages';
|
|
3
|
-
import { InitializeBookitoWidgetOptionsType } from './mount';
|
|
4
|
-
import { OpenBookitoModalOptionsType } from './open-modal';
|
|
5
|
-
export declare function normalizeInitializeOptions(options: InitializeBookitoWidgetOptionsType): InitializeBookitoWidgetOptionsType;
|
|
6
|
-
export declare function normalizeOpenModalOptions(options: OpenBookitoModalOptionsType): OpenBookitoModalOptionsType;
|
|
7
|
-
export declare function resolveLanguage(value: unknown): SupportedLanguageType;
|
|
8
|
-
export declare function resolveViewMode(value: unknown): BookitoWidgetViewModeType;
|
|
9
|
-
export declare function isTruthy(value: unknown): boolean;
|
|
10
|
-
export declare function optionalString(value: unknown): string | undefined;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type FallbackReasonType = 'invalid_hotel_id' | 'request_failed' | 'timeout' | `http_${number}`;
|
|
2
|
-
export type LoaderHotelType = {
|
|
3
|
-
useNewGuestApp: boolean;
|
|
4
|
-
};
|
|
5
|
-
export type HotelResultType = {
|
|
6
|
-
ok: true;
|
|
7
|
-
hotel: LoaderHotelType;
|
|
8
|
-
} | {
|
|
9
|
-
ok: false;
|
|
10
|
-
reason: FallbackReasonType;
|
|
11
|
-
};
|
|
12
|
-
export declare function getHotel(strapiUrl: string, hotelId: string, timeoutMs: number): Promise<HotelResultType>;
|
package/dist/src/loader.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|