@roomstay/frontend 2.4.4-3 → 2.4.4-4
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.
|
@@ -54,32 +54,25 @@ class BaseEngine {
|
|
|
54
54
|
// TODO: Update these calls
|
|
55
55
|
RoomstayThemeEngine_1.default.EngineContainer = container;
|
|
56
56
|
// Move style to shadow dom
|
|
57
|
-
const
|
|
57
|
+
const copyStyle2ShadowDom = (styleEl) => {
|
|
58
|
+
if (styleEl === null || styleEl === void 0 ? void 0 : styleEl.shadowRoot) {
|
|
59
|
+
RoomstayThemeEngine_1.default.EngineContainer.appendChild(styleEl.shadowRoot);
|
|
60
|
+
styleEl.remove();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
58
63
|
const observer = new MutationObserver(function (mutations) {
|
|
59
64
|
mutations.forEach(function (mutation) {
|
|
60
65
|
var _a;
|
|
61
|
-
console.log({
|
|
62
|
-
'mutation.addedNodes': mutation.addedNodes,
|
|
63
|
-
});
|
|
64
66
|
for (let i = 0; i < mutation.addedNodes.length; i++) {
|
|
65
67
|
const el = mutation.addedNodes[i];
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
+
if ((_a = el.classList) === null || _a === void 0 ? void 0 : _a.includes('roomstay-booking-style')) {
|
|
69
|
+
console.log('added node', el);
|
|
70
|
+
copyStyle2ShadowDom(el);
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
73
|
});
|
|
71
74
|
});
|
|
72
|
-
|
|
73
|
-
childList: true,
|
|
74
|
-
});
|
|
75
|
-
Array.from(document.getElementsByClassName('roomstay-booking-style'))
|
|
76
|
-
.concat(insertedNodes)
|
|
77
|
-
.forEach((styleEl) => {
|
|
78
|
-
if (styleEl === null || styleEl === void 0 ? void 0 : styleEl.shadowRoot) {
|
|
79
|
-
RoomstayThemeEngine_1.default.EngineContainer.appendChild(styleEl.shadowRoot);
|
|
80
|
-
styleEl.remove();
|
|
81
|
-
}
|
|
82
|
-
});
|
|
75
|
+
Array.from(document.getElementsByClassName('roomstay-booking-style')).forEach(copyStyle2ShadowDom);
|
|
83
76
|
RoomstayThemeEngine_1.default.init();
|
|
84
77
|
}
|
|
85
78
|
getInitialSession() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseEngine.js","sourceRoot":"/","sources":["src/engines/BaseEngine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,0FAAkE;AAClE,kFAA0D;AAK1D,IAAY,mBAMX;AAND,WAAY,mBAAmB;IAC3B,wCAAiB,CAAA;IACjB,yDAAkC,CAAA;IAClC,4CAAqB,CAAA;IACrB,uDAAgC,CAAA;IAChC,oCAAa,CAAA;AACjB,CAAC,EANW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAM9B;AAED,MAAsB,UAAU;IAQ5B,YAAY,gBAA6B,EAAE,MAAU;
|
|
1
|
+
{"version":3,"file":"BaseEngine.js","sourceRoot":"/","sources":["src/engines/BaseEngine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,0FAAkE;AAClE,kFAA0D;AAK1D,IAAY,mBAMX;AAND,WAAY,mBAAmB;IAC3B,wCAAiB,CAAA;IACjB,yDAAkC,CAAA;IAClC,4CAAqB,CAAA;IACrB,uDAAgC,CAAA;IAChC,oCAAa,CAAA;AACjB,CAAC,EANW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAM9B;AAED,MAAsB,UAAU;IAQ5B,YAAY,gBAA6B,EAAE,MAAU;QAuCrC,UAAK,GAAG,GAAS,EAAE;YAC/B,MAAM,WAAW,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;YACtF,IAAI,SAAS,GAAQ,IAAI,CAAC;YAC1B,IAAI,WAAW,EAAE;gBACb,IAAI,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;oBAC5B,SAAS,GAAG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UAAU,SAAS;YACrD,SAAS,CAAC,OAAO,CAAC,UAAU,QAAQ;;gBAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBACjD,MAAM,EAAE,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;oBAClC,IAAI,MAAC,EAAU,CAAC,SAAS,0CAAE,QAAQ,CAAC,wBAAwB,CAAC,EAAE;wBAC3D,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;wBAC9B,mBAAmB,CAAC,EAAE,CAAC,CAAC;qBAC3B;iBACJ;YACL,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC,wBAAwB,CAAC,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAEnG,6BAAmB,CAAC,IAAI,EAAE,CAAC;IAC/B,CAAC;IAqBM,iBAAiB;QACpB,IAAI,IAAI,CAAC,cAAc,EAAE;YACrB,OAAO,IAAI,CAAC,cAAc,CAAC;SAC9B;QAED,OAAO,CAAC,KAAK,CAAC,0DAA0D,CAAC,CAAC;QAC1E,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,kBAAkB;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAEM,SAAS,CAAC,MAAS;QACtB,kCAAkC;QAClC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;IAC/B,CAAC;IAEM,SAAS;QACZ,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAEM,SAAS;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;CAGJ;AA7FD,gCA6FC","sourcesContent":["import { RoomstaySession } from '@/models/RoomstaySession';\nimport RoomstayThemeEngine from '@/providers/RoomstayThemeEngine';\nimport SessionProvider from '@/providers/SessionProvider';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface BaseEngineConfig {}\n\nexport enum BookingEngineSource {\n Inline = 'inline',\n RecentSearches = 'recent-searches',\n Fullpage = 'fullpage',\n BookingWizard = 'booking-wizard',\n Auth = 'auth',\n}\n\nexport abstract class BaseEngine<C extends BaseEngineConfig> {\n protected source!: BookingEngineSource;\n protected readonly bookingContainer: HTMLElement;\n protected sessionProvider!: SessionProvider;\n protected initialSession!: RoomstaySession;\n\n protected engineConfig!: C;\n\n constructor(bookingContainer: HTMLElement, config?: C) {\n const shadow = bookingContainer.attachShadow({\n mode: 'open',\n });\n const container = document.createElement('div');\n container.classList.add('roomstay-booking-container');\n shadow.appendChild(container);\n this.bookingContainer = container;\n\n if (this.engineConfig) {\n this.setConfig(config as C);\n }\n\n // TODO: Update these calls\n RoomstayThemeEngine.EngineContainer = container;\n\n // Move style to shadow dom\n const copyStyle2ShadowDom = (styleEl: any) => {\n if (styleEl?.shadowRoot) {\n RoomstayThemeEngine.EngineContainer.appendChild(styleEl.shadowRoot);\n styleEl.remove();\n }\n };\n const observer = new MutationObserver(function (mutations) {\n mutations.forEach(function (mutation) {\n for (let i = 0; i < mutation.addedNodes.length; i++) {\n const el = mutation.addedNodes[i];\n if ((el as any).classList?.includes('roomstay-booking-style')) {\n console.log('added node', el);\n copyStyle2ShadowDom(el);\n }\n }\n });\n });\n Array.from(document.getElementsByClassName('roomstay-booking-style')).forEach(copyStyle2ShadowDom);\n\n RoomstayThemeEngine.init();\n }\n\n public readonly start = async () => {\n const queryParams = new URLSearchParams(window.location.hash.replace(/^#\\/.+\\//, ''));\n let sessionId: any = null;\n if (queryParams) {\n if (queryParams.has('session')) {\n sessionId = queryParams.get('session');\n }\n }\n\n this.sessionProvider = new SessionProvider();\n this.sessionProvider.initialize(sessionId, this.source).then(async () => {\n this.initialSession = await this.sessionProvider.getSession();\n });\n\n setTimeout(() => {\n this.render();\n }, 1);\n };\n\n public getInitialSession(): RoomstaySession | null {\n if (this.initialSession) {\n return this.initialSession;\n }\n\n console.error('Tried Loading session without engine initializing first.');\n return null;\n }\n\n public getSessionProvider() {\n return this.sessionProvider;\n }\n\n public setConfig(config: C) {\n // TODO: add hook updates in here.\n this.engineConfig = config;\n }\n\n public getConfig() {\n return this.engineConfig;\n }\n\n public getSource(): BookingEngineSource {\n return this.source;\n }\n\n protected abstract render(): Promise<void>;\n}\n"]}
|