@roomle/embedding-lib 5.0.1-debug.1 → 5.1.0-alpha.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/.releaserc.json +1 -1
- package/docs/md/web/embedding/CHANGELOG.md +9 -4
- package/drag-in-CXLxdfa-.mjs +265 -0
- package/drag-in-gOPgOymI.mjs +7 -0
- package/index.d.ts +48 -6
- package/package.json +2 -2
- package/roomle-embedding-lib.es.js +175 -134
- package/roomle-embedding-lib.es.min.js +8 -8
- package/roomle-embedding-lib.umd.js +14 -8
- package/roomle-embedding-lib.umd.min.js +14 -8
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
var M = Object.defineProperty;
|
|
2
2
|
var v = (t, e, s) => e in t ? M(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
|
|
3
|
-
var
|
|
3
|
+
var l = (t, e, s) => v(t, typeof e != "symbol" ? e + "" : e, s);
|
|
4
4
|
class P {
|
|
5
5
|
constructor(e, s, r, o) {
|
|
6
|
-
|
|
6
|
+
l(this, "_side");
|
|
7
7
|
// for better debugging (who handles message? iframe or website?)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
l(this, "_incomingMessageBus");
|
|
9
|
+
l(this, "_outgoingMessageBus", null);
|
|
10
|
+
l(this, "_execMessage", null);
|
|
11
11
|
this._side = e, this._incomingMessageBus = s, this._outgoingMessageBus = r, this._execMessage = o, this._incomingMessageBus.addEventListener(
|
|
12
12
|
"message",
|
|
13
13
|
this._handleMessage.bind(this)
|
|
@@ -21,25 +21,25 @@ class P {
|
|
|
21
21
|
}
|
|
22
22
|
sendMessage(e, s = []) {
|
|
23
23
|
return new Promise((r, o) => {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
if (!
|
|
27
|
-
return
|
|
24
|
+
const i = new MessageChannel();
|
|
25
|
+
i.port1.onmessage = (n) => {
|
|
26
|
+
if (!n || !n.data)
|
|
27
|
+
return i.port1.close(), i.port2.close(), o(
|
|
28
28
|
new Error(
|
|
29
29
|
this._side + " received message but response can not be interpreted"
|
|
30
30
|
)
|
|
31
31
|
);
|
|
32
|
-
let
|
|
32
|
+
let c;
|
|
33
33
|
try {
|
|
34
|
-
|
|
35
|
-
} catch (
|
|
36
|
-
return
|
|
34
|
+
c = JSON.parse(n.data);
|
|
35
|
+
} catch (a) {
|
|
36
|
+
return i.port1.close(), i.port2.close(), this._prepareError(a), o(a);
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
c.error ? o(c.error) : c.result !== void 0 ? r(c.result) : r(void 0), i.port1.close(), i.port2.close();
|
|
39
39
|
};
|
|
40
|
-
let
|
|
40
|
+
let g = "";
|
|
41
41
|
try {
|
|
42
|
-
|
|
42
|
+
g = JSON.stringify({ message: e, args: s });
|
|
43
43
|
} catch {
|
|
44
44
|
return o(
|
|
45
45
|
new Error(
|
|
@@ -49,8 +49,8 @@ class P {
|
|
|
49
49
|
}
|
|
50
50
|
if (!this._outgoingMessageBus)
|
|
51
51
|
return o(new Error(this._side + ": outgoing bus not set yet"));
|
|
52
|
-
this._outgoingMessageBus.postMessage(
|
|
53
|
-
|
|
52
|
+
this._outgoingMessageBus.postMessage(g, "*", [
|
|
53
|
+
i.port2
|
|
54
54
|
]);
|
|
55
55
|
});
|
|
56
56
|
}
|
|
@@ -70,20 +70,20 @@ class P {
|
|
|
70
70
|
if (o === void 0)
|
|
71
71
|
return;
|
|
72
72
|
o.then(
|
|
73
|
-
(
|
|
74
|
-
let
|
|
75
|
-
typeof
|
|
76
|
-
JSON.stringify({ error:
|
|
77
|
-
) :
|
|
78
|
-
JSON.stringify({ result: a })
|
|
79
|
-
) : s.postMessage(
|
|
73
|
+
(i = {}) => {
|
|
74
|
+
let g, n;
|
|
75
|
+
typeof i == "object" && i !== null && (g = i.error, n = i.result), g ? s.postMessage(
|
|
76
|
+
JSON.stringify({ error: g })
|
|
77
|
+
) : n !== void 0 ? s.postMessage(
|
|
80
78
|
JSON.stringify({ result: n })
|
|
79
|
+
) : s.postMessage(
|
|
80
|
+
JSON.stringify({ result: i })
|
|
81
81
|
);
|
|
82
82
|
},
|
|
83
|
-
(
|
|
83
|
+
(i) => {
|
|
84
84
|
s.postMessage(
|
|
85
85
|
JSON.stringify({
|
|
86
|
-
error: this._prepareError(
|
|
86
|
+
error: this._prepareError(i)
|
|
87
87
|
})
|
|
88
88
|
);
|
|
89
89
|
}
|
|
@@ -108,37 +108,37 @@ const p = ".", E = {
|
|
|
108
108
|
REQUEST_BOOT: "requestBoot",
|
|
109
109
|
SETUP: "setup",
|
|
110
110
|
WEBSITE_READY: "websiteReady"
|
|
111
|
-
},
|
|
111
|
+
}, D = async (t, e) => {
|
|
112
112
|
if (typeof t != "string")
|
|
113
113
|
throw new Error(
|
|
114
114
|
'Configurator ID is not a string type: "' + typeof t + '"'
|
|
115
115
|
);
|
|
116
|
-
const s = e.customApiUrl ? e.customApiUrl : "https://api.roomle.com/v2", r = e.overrideTenant || 9, o = s + "/configurators/" + t,
|
|
117
|
-
const
|
|
118
|
-
apiKey:
|
|
116
|
+
const s = e.customApiUrl ? e.customApiUrl : "https://api.roomle.com/v2", r = e.overrideTenant || 9, o = s + "/configurators/" + t, i = "roomle_portal_v2", g = "03-" + window.btoa((/* @__PURE__ */ new Date()).toISOString() + ";anonymous;" + i), n = () => {
|
|
117
|
+
const u = {
|
|
118
|
+
apiKey: i,
|
|
119
119
|
currentTenant: r,
|
|
120
120
|
locale: "en",
|
|
121
121
|
language: "en",
|
|
122
122
|
device: 1,
|
|
123
|
-
token:
|
|
123
|
+
token: g,
|
|
124
124
|
platform: "web"
|
|
125
125
|
};
|
|
126
|
-
return new Headers(
|
|
127
|
-
},
|
|
126
|
+
return new Headers(u);
|
|
127
|
+
}, c = new Request(o, {
|
|
128
128
|
method: "GET",
|
|
129
|
-
headers:
|
|
129
|
+
headers: n(),
|
|
130
130
|
mode: "cors",
|
|
131
131
|
cache: "default"
|
|
132
|
-
}),
|
|
133
|
-
return
|
|
134
|
-
},
|
|
132
|
+
}), a = await fetch(c), { configurator: f } = await a.json();
|
|
133
|
+
return f;
|
|
134
|
+
}, H = () => {
|
|
135
135
|
try {
|
|
136
136
|
return window.self !== window.top;
|
|
137
137
|
} catch {
|
|
138
138
|
return !0;
|
|
139
139
|
}
|
|
140
|
-
},
|
|
141
|
-
const t =
|
|
140
|
+
}, F = ["127.0.0.1", "localhost", "0.0.0.0"], C = () => {
|
|
141
|
+
const t = H();
|
|
142
142
|
let e = window.location.href;
|
|
143
143
|
if (t) {
|
|
144
144
|
if (!document.referrer)
|
|
@@ -147,35 +147,37 @@ const p = ".", E = {
|
|
|
147
147
|
}
|
|
148
148
|
const { hostname: s } = new URL(e);
|
|
149
149
|
return s;
|
|
150
|
-
}, B = (t) => !!(
|
|
150
|
+
}, B = (t) => !!(F.includes(t) || t.endsWith("roomle.com") || t.endsWith("gitlab.io") || t.endsWith("gitlab.com")), A = [
|
|
151
151
|
"language",
|
|
152
152
|
"browserLanguage",
|
|
153
153
|
"userLanguage",
|
|
154
154
|
"systemLanguage"
|
|
155
|
-
],
|
|
155
|
+
], U = (t = null) => {
|
|
156
156
|
const e = window.navigator;
|
|
157
157
|
if (t)
|
|
158
158
|
return t.substr(0, 2);
|
|
159
159
|
if (Array.isArray(e.languages) && e.languages.length > 0)
|
|
160
160
|
return e.languages[0].substr(0, 2);
|
|
161
|
-
for (let s = 0, r =
|
|
162
|
-
const o = e[
|
|
161
|
+
for (let s = 0, r = A.length; s < r; s++) {
|
|
162
|
+
const o = e[A[s]];
|
|
163
163
|
if (o)
|
|
164
164
|
return o.substr(0, 2);
|
|
165
165
|
}
|
|
166
166
|
return "en";
|
|
167
|
-
},
|
|
167
|
+
}, k = (t, e) => {
|
|
168
168
|
const s = JSON.parse(JSON.stringify(t));
|
|
169
|
-
return
|
|
170
|
-
},
|
|
169
|
+
return O(s, e);
|
|
170
|
+
}, O = (t, e) => {
|
|
171
171
|
for (const s in e)
|
|
172
172
|
try {
|
|
173
|
-
e[s].constructor === Object ? t[s] =
|
|
173
|
+
e[s].constructor === Object ? t[s] = O(t[s], e[s]) : t[s] = e[s];
|
|
174
174
|
} catch {
|
|
175
175
|
t[s] = e[s];
|
|
176
176
|
}
|
|
177
177
|
return t;
|
|
178
|
-
}
|
|
178
|
+
};
|
|
179
|
+
var x = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
|
|
180
|
+
const W = {
|
|
179
181
|
mobileLandscape: !0,
|
|
180
182
|
floorMaterialRootTag: "materials_root",
|
|
181
183
|
buttons: {
|
|
@@ -195,32 +197,32 @@ const p = ".", E = {
|
|
|
195
197
|
featureFlags: {
|
|
196
198
|
mocAr: !0
|
|
197
199
|
}
|
|
198
|
-
},
|
|
200
|
+
}, G = "(idle)", J = (t) => (w(t), t != null && t.customApiUrl && (t.customApiUrl = decodeURIComponent(t.customApiUrl)), t.shareUrl && (t.deeplink = t.shareUrl.replace(
|
|
199
201
|
z,
|
|
200
|
-
|
|
201
|
-
)), t),
|
|
202
|
+
Y
|
|
203
|
+
)), t), w = (t) => {
|
|
202
204
|
if (!t)
|
|
203
205
|
return;
|
|
204
206
|
const e = Object.keys(t);
|
|
205
207
|
for (const s of e) {
|
|
206
208
|
const r = t[s];
|
|
207
|
-
if (!Array.isArray(r) && typeof r == "object" && r !== null &&
|
|
209
|
+
if (!Array.isArray(r) && typeof r == "object" && r !== null && w(r), Array.isArray(r))
|
|
208
210
|
for (const o of r)
|
|
209
|
-
|
|
211
|
+
w(o);
|
|
210
212
|
(r === "true" || r === "false") && (t[s] = r === "true");
|
|
211
213
|
}
|
|
212
|
-
},
|
|
214
|
+
}, V = (t, e) => {
|
|
213
215
|
e.configuratorId = t.id;
|
|
214
216
|
const s = t.settings || {};
|
|
215
|
-
return !e.overrideTenant && t.tenant && (e.overrideTenant = t.tenant),
|
|
217
|
+
return !e.overrideTenant && t.tenant && (e.overrideTenant = t.tenant), k(s, e);
|
|
216
218
|
}, $ = () => {
|
|
217
219
|
const t = {
|
|
218
|
-
...
|
|
220
|
+
...W
|
|
219
221
|
};
|
|
220
|
-
t.locale || (t.locale =
|
|
222
|
+
t.locale || (t.locale = U()), t.id === G && delete t.id;
|
|
221
223
|
const e = C();
|
|
222
|
-
return e && B(e) && (t.configuratorId = "demoConfigurator"), t.customApiUrl =
|
|
223
|
-
}, z = "<CONF_ID>",
|
|
224
|
+
return e && B(e) && (t.configuratorId = "demoConfigurator"), t.customApiUrl = x.VITE_RAPI_URL, t.emails = !1, t;
|
|
225
|
+
}, z = "<CONF_ID>", Y = "#CONFIGURATIONID#", L = () => /(android)/i.test(navigator.userAgent), R = (t, e, s) => {
|
|
224
226
|
let r = null;
|
|
225
227
|
Object.defineProperty(t, e, {
|
|
226
228
|
get() {
|
|
@@ -232,75 +234,108 @@ const p = ".", E = {
|
|
|
232
234
|
), console.warn("{ mute: true, value: () => void }"), r = o);
|
|
233
235
|
}
|
|
234
236
|
});
|
|
235
|
-
},
|
|
237
|
+
}, T = () => window.innerHeight * 0.01 + "px", b = (t) => {
|
|
236
238
|
t && setTimeout(
|
|
237
|
-
() => t.style.setProperty(y,
|
|
239
|
+
() => t.style.setProperty(y, T()),
|
|
238
240
|
0
|
|
239
241
|
);
|
|
240
|
-
},
|
|
242
|
+
}, S = "rml-styles", q = 450, y = "--rml-full-height", d = {
|
|
241
243
|
CONTAINER: "rml-container",
|
|
242
244
|
FILL: "rml-fill",
|
|
243
245
|
POSITION: "rml-pos",
|
|
244
246
|
TRANSITION: "rml-transition",
|
|
245
247
|
ANDROID_HEIGHT: "rml-android-height",
|
|
246
248
|
OVERFLOW_HIDDEN: "rml-overflow-hidden"
|
|
247
|
-
},
|
|
248
|
-
class
|
|
249
|
-
constructor(e, s, r, o) {
|
|
250
|
-
|
|
249
|
+
}, I = /* @__PURE__ */ new Map();
|
|
250
|
+
class Q {
|
|
251
|
+
constructor(e, s, r, o, i) {
|
|
252
|
+
l(this, "ui", {
|
|
253
|
+
callbacks: null
|
|
254
|
+
});
|
|
255
|
+
l(this, "extended", {
|
|
251
256
|
callbacks: null
|
|
252
257
|
});
|
|
253
|
-
|
|
258
|
+
l(this, "configurator", {
|
|
254
259
|
callbacks: null
|
|
255
260
|
});
|
|
256
|
-
|
|
261
|
+
l(this, "analytics", {
|
|
257
262
|
callbacks: {}
|
|
258
263
|
});
|
|
259
|
-
|
|
264
|
+
l(this, "global", {
|
|
260
265
|
callbacks: {}
|
|
261
266
|
});
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
267
|
+
l(this, "plugins", {});
|
|
268
|
+
l(this, "_waitForIframe");
|
|
269
|
+
l(this, "_container");
|
|
270
|
+
l(this, "_messageHandler");
|
|
271
|
+
l(this, "_configuratorSettings");
|
|
272
|
+
l(this, "_initData", {});
|
|
273
|
+
l(this, "_iframe");
|
|
274
|
+
l(this, "pluginsLoaded", []);
|
|
268
275
|
if (!e || typeof e.id != "string")
|
|
269
276
|
throw new Error(
|
|
270
277
|
"Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person"
|
|
271
278
|
);
|
|
272
|
-
if (
|
|
279
|
+
if (I.has(s))
|
|
273
280
|
throw new Error("There is already an instance on this DOM element");
|
|
274
|
-
if (!!!document.getElementById(
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
(
|
|
281
|
+
if (!!!document.getElementById(S)) {
|
|
282
|
+
const c = r.zIndex || 9999999, a = document.createElement("style");
|
|
283
|
+
a.type = "text/css", a.id = S;
|
|
284
|
+
const f = "transition:all ease-in-out " + q + "ms;", u = ["-webkit-", "-o-"].reduce(
|
|
285
|
+
(m, _) => m += _ + f,
|
|
279
286
|
""
|
|
280
|
-
) +
|
|
281
|
-
|
|
282
|
-
.${
|
|
283
|
-
.${
|
|
284
|
-
.${
|
|
285
|
-
.${
|
|
286
|
-
.${
|
|
287
|
-
.${
|
|
288
|
-
`, document.head.appendChild(
|
|
287
|
+
) + f, h = T();
|
|
288
|
+
a.innerHTML = `
|
|
289
|
+
.${d.CONTAINER}{${y}:${h};}
|
|
290
|
+
.${d.POSITION}{position:fixed;top:0;left:0;z-index:${c};opacity:0}
|
|
291
|
+
.${d.TRANSITION}{${u}}
|
|
292
|
+
.${d.FILL}{width:100%;height:100%;opacity:1}
|
|
293
|
+
.${d.ANDROID_HEIGHT}{height:calc(var(${y},1vh)*100)}
|
|
294
|
+
.${d.OVERFLOW_HIDDEN}{overflow:hidden}
|
|
295
|
+
`, document.head.appendChild(a);
|
|
289
296
|
}
|
|
290
|
-
this._onResize = this._onResize.bind(this),
|
|
291
|
-
const
|
|
297
|
+
this._onResize = this._onResize.bind(this), L() && window.addEventListener("resize", this._onResize), this._container = s, this._initData = r, this._configuratorSettings = e;
|
|
298
|
+
const n = this._createIframe();
|
|
292
299
|
this._onUseFullPage = this._onUseFullPage.bind(this), this._executeMessage = this._executeMessage.bind(this), this._onBackToWebsite = this._onBackToWebsite.bind(this), this._messageHandler = new P(
|
|
293
300
|
"website",
|
|
294
301
|
window,
|
|
295
302
|
null,
|
|
296
303
|
this._executeMessage
|
|
297
|
-
), this._waitForIframe =
|
|
304
|
+
), this._waitForIframe = i, this._container.appendChild(n), this._iframe = n;
|
|
305
|
+
for (const c of o)
|
|
306
|
+
typeof c == "string" && c === "dragIn" ? this.pluginsLoaded.push(
|
|
307
|
+
new Promise((a, f) => {
|
|
308
|
+
try {
|
|
309
|
+
import("./drag-in-CXLxdfa-.mjs").then(
|
|
310
|
+
({ DragIn: u }) => {
|
|
311
|
+
const h = new u(this._iframe);
|
|
312
|
+
h.setInstance(this.ui), this.plugins.dragIn = h, a();
|
|
313
|
+
}
|
|
314
|
+
);
|
|
315
|
+
} catch (u) {
|
|
316
|
+
f(u);
|
|
317
|
+
}
|
|
318
|
+
})
|
|
319
|
+
) : c.name && c.loader && this.pluginsLoaded.push(
|
|
320
|
+
new Promise((a, f) => {
|
|
321
|
+
try {
|
|
322
|
+
c.loader().then((u) => {
|
|
323
|
+
const h = new u(this._iframe);
|
|
324
|
+
h.setInstance(this.ui), this.plugins[c.name] = h, a();
|
|
325
|
+
});
|
|
326
|
+
} catch (u) {
|
|
327
|
+
f(u);
|
|
328
|
+
}
|
|
329
|
+
})
|
|
330
|
+
);
|
|
331
|
+
I.set(s, !0);
|
|
298
332
|
}
|
|
299
|
-
static createPlanner(e, s, r) {
|
|
333
|
+
static createPlanner(e, s, r, o = []) {
|
|
300
334
|
return this._create(
|
|
301
335
|
e,
|
|
302
336
|
s,
|
|
303
|
-
r
|
|
337
|
+
r,
|
|
338
|
+
o
|
|
304
339
|
);
|
|
305
340
|
}
|
|
306
341
|
/**
|
|
@@ -309,11 +344,12 @@ class K {
|
|
|
309
344
|
* @param container DOM container in which the configurator should be placed
|
|
310
345
|
* @param initData settings with which the configurator should be started
|
|
311
346
|
*/
|
|
312
|
-
static createConfigurator(e, s, r) {
|
|
347
|
+
static createConfigurator(e, s, r, o = []) {
|
|
313
348
|
return this._create(
|
|
314
349
|
e,
|
|
315
350
|
s,
|
|
316
|
-
r
|
|
351
|
+
r,
|
|
352
|
+
o
|
|
317
353
|
);
|
|
318
354
|
}
|
|
319
355
|
/**
|
|
@@ -323,11 +359,12 @@ class K {
|
|
|
323
359
|
* @param container DOM container in which the configurator should be placed
|
|
324
360
|
* @param initData settings with which the configurator should be started
|
|
325
361
|
*/
|
|
326
|
-
static create(e, s, r) {
|
|
362
|
+
static create(e, s, r, o) {
|
|
327
363
|
return this._create(
|
|
328
364
|
e,
|
|
329
365
|
s,
|
|
330
|
-
r
|
|
366
|
+
r,
|
|
367
|
+
o
|
|
331
368
|
);
|
|
332
369
|
}
|
|
333
370
|
/**
|
|
@@ -336,38 +373,42 @@ class K {
|
|
|
336
373
|
* @param container DOM container in which the configurator should be placed
|
|
337
374
|
* @param initData settings with which the configurator should be started
|
|
338
375
|
*/
|
|
339
|
-
static createViewer(e, s, r) {
|
|
376
|
+
static createViewer(e, s, r, o = []) {
|
|
340
377
|
return this._create(
|
|
341
378
|
e,
|
|
342
379
|
s,
|
|
343
|
-
r
|
|
380
|
+
r,
|
|
381
|
+
o
|
|
344
382
|
);
|
|
345
383
|
}
|
|
346
|
-
static _create(e, s, r) {
|
|
347
|
-
return new Promise(async (
|
|
384
|
+
static async _create(e, s, r, o) {
|
|
385
|
+
return new Promise(async (i, g) => {
|
|
348
386
|
try {
|
|
349
|
-
const
|
|
387
|
+
const n = O(
|
|
350
388
|
$(),
|
|
351
|
-
|
|
389
|
+
J(r)
|
|
352
390
|
);
|
|
353
|
-
|
|
354
|
-
const
|
|
391
|
+
n.featureFlags || (n.featureFlags = {}), typeof n.featureFlags.realPartList != "boolean" && (n.featureFlags.realPartList = !0), typeof n.featureFlags.globalCallbacks != "boolean" && (n.featureFlags.globalCallbacks = !0), typeof n.featureFlags.mocAr != "boolean" && (n.featureFlags.mocAr = !1);
|
|
392
|
+
const c = await D(
|
|
355
393
|
e,
|
|
356
|
-
|
|
394
|
+
n
|
|
357
395
|
);
|
|
358
|
-
|
|
359
|
-
|
|
396
|
+
r = V(c, n);
|
|
397
|
+
const a = new this(
|
|
398
|
+
c,
|
|
360
399
|
s,
|
|
361
400
|
r,
|
|
362
|
-
o
|
|
401
|
+
o,
|
|
402
|
+
i
|
|
363
403
|
);
|
|
364
|
-
|
|
365
|
-
|
|
404
|
+
return await Promise.allSettled(a.pluginsLoaded), a;
|
|
405
|
+
} catch (n) {
|
|
406
|
+
return g(n);
|
|
366
407
|
}
|
|
367
408
|
});
|
|
368
409
|
}
|
|
369
410
|
teardown() {
|
|
370
|
-
this._container &&
|
|
411
|
+
this._container && I.delete(this._container);
|
|
371
412
|
const e = this._container.querySelector("iframe");
|
|
372
413
|
e && this._container.removeChild(e), window.removeEventListener("resize", this._onResize);
|
|
373
414
|
}
|
|
@@ -375,33 +416,33 @@ class K {
|
|
|
375
416
|
var r;
|
|
376
417
|
const e = document.createElement("iframe");
|
|
377
418
|
let s = ((r = this._configuratorSettings) == null ? void 0 : r.url) || "https://www.roomle.com/t/cp/";
|
|
378
|
-
return this._initData.useLocalRoomle && (s = location.href.replace("embedding.html", "")), location.href.includes("roomle.gitlab.io") && (s = location.href.replace("embedding.html", "index.html")), this._initData.overrideServerUrl && (s = this._initData.overrideServerUrl), e.src = s, e.classList.add(
|
|
419
|
+
return this._initData.useLocalRoomle && (s = location.href.replace("embedding.html", "")), location.href.includes("roomle.gitlab.io") && (s = location.href.replace("embedding.html", "index.html")), this._initData.overrideServerUrl && (s = this._initData.overrideServerUrl), e.src = s, e.classList.add(d.CONTAINER), e.classList.add(d.FILL), e;
|
|
379
420
|
}
|
|
380
421
|
_onResize() {
|
|
381
|
-
|
|
422
|
+
b(this._iframe);
|
|
382
423
|
}
|
|
383
424
|
_onUseFullPage() {
|
|
384
|
-
this._iframe.classList.add(
|
|
425
|
+
this._iframe.classList.add(d.POSITION), document.documentElement.classList.add(d.OVERFLOW_HIDDEN), window.document.body.classList.add(d.OVERFLOW_HIDDEN), L() && (b(this._iframe), this._iframe.classList.add(d.ANDROID_HEIGHT));
|
|
385
426
|
}
|
|
386
427
|
_onBackToWebsite() {
|
|
387
|
-
this._iframe.classList.remove(
|
|
428
|
+
this._iframe.classList.remove(d.POSITION), this._iframe.classList.remove(d.ANDROID_HEIGHT), document.documentElement.classList.remove(d.OVERFLOW_HIDDEN), window.document.body.classList.remove(d.OVERFLOW_HIDDEN);
|
|
388
429
|
}
|
|
389
430
|
_executeMessage({ message: e, args: s }, r) {
|
|
390
|
-
var
|
|
391
|
-
if (!r.source || r.source !== ((
|
|
431
|
+
var c;
|
|
432
|
+
if (!r.source || r.source !== ((c = this._iframe) == null ? void 0 : c.contentWindow))
|
|
392
433
|
return;
|
|
393
434
|
if (e === E.REQUEST_BOOT)
|
|
394
435
|
return this._messageHandler.setOutgoingMessageBus(r.source), Promise.resolve({ result: this._initData });
|
|
395
436
|
if (e === E.SETUP) {
|
|
396
|
-
const { methods:
|
|
397
|
-
return
|
|
398
|
-
const
|
|
399
|
-
this[
|
|
400
|
-
return this._messageHandler.sendMessage(
|
|
437
|
+
const { methods: a, callbacks: f } = s[0];
|
|
438
|
+
return a.forEach((u) => {
|
|
439
|
+
const h = u.split(p), m = h[0], _ = h[1];
|
|
440
|
+
this[m] || (this[m] = {}), this[m][_] = (function() {
|
|
441
|
+
return this._messageHandler.sendMessage(u, [...arguments]);
|
|
401
442
|
}).bind(this);
|
|
402
|
-
}),
|
|
403
|
-
const
|
|
404
|
-
this[
|
|
443
|
+
}), f.forEach((u) => {
|
|
444
|
+
const h = u.split(p), m = h[0], _ = h[1], N = h[2];
|
|
445
|
+
this[m] || (this[m] = {}), this[m][_] || (this[m][_] = {}), this[m][_][N] = () => {
|
|
405
446
|
};
|
|
406
447
|
}), R(
|
|
407
448
|
this.ui.callbacks,
|
|
@@ -416,16 +457,16 @@ class K {
|
|
|
416
457
|
0
|
|
417
458
|
), Promise.resolve({ result: null });
|
|
418
459
|
}
|
|
419
|
-
const o = e.split(p),
|
|
420
|
-
if (
|
|
421
|
-
const
|
|
460
|
+
const o = e.split(p), i = o[0], g = o[1], n = o.length === 3 ? o[2] : null;
|
|
461
|
+
if (n && this[i][g][n]) {
|
|
462
|
+
const a = this[i][g][n](
|
|
422
463
|
...s
|
|
423
464
|
);
|
|
424
|
-
return
|
|
465
|
+
return a instanceof Promise ? a.then((f) => ({ result: f })) : a !== void 0 ? Promise.resolve({ result: a }) : Promise.resolve({ result: null });
|
|
425
466
|
}
|
|
426
467
|
return Promise.reject('Message "' + e + '" is unkown');
|
|
427
468
|
}
|
|
428
469
|
}
|
|
429
470
|
export {
|
|
430
|
-
|
|
471
|
+
Q as default
|
|
431
472
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var R=Object.defineProperty,
|
|
2
|
-
.${
|
|
3
|
-
.${
|
|
4
|
-
.${
|
|
5
|
-
.${
|
|
6
|
-
.${
|
|
7
|
-
.${
|
|
8
|
-
`,document.head.appendChild(
|
|
1
|
+
var R=Object.defineProperty,S=(s,e,t)=>e in s?R(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,c=(s,e,t)=>S(s,typeof e!="symbol"?e+"":e,t);class A{constructor(e,t,r,i){c(this,"_side"),c(this,"_incomingMessageBus"),c(this,"_outgoingMessageBus",null),c(this,"_execMessage",null),this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=r,this._execMessage=i,this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,t=[]){return new Promise((r,i)=>{const o=new MessageChannel;o.port1.onmessage=n=>{if(!n||!n.data)return o.port1.close(),o.port2.close(),i(new Error(this._side+" received message but response can not be interpreted"));let a;try{a=JSON.parse(n.data)}catch(l){return o.port1.close(),o.port2.close(),this._prepareError(l),i(l)}a.error?i(a.error):a.result!==void 0?r(a.result):r(void 0),o.port1.close(),o.port2.close()};let u="";try{u=JSON.stringify({message:e,args:t})}catch{return i(new Error(this._side+": can not create command because it is not JSON.stringify able"))}if(!this._outgoingMessageBus)return i(new Error(this._side+": outgoing bus not set yet"));this._outgoingMessageBus.postMessage(u,"*",[o.port2])})}_handleMessage(e){const t=e.ports&&Array.isArray(e.ports)&&e.ports.length>0?e.ports[0]:null;if(e.data&&t)try{const r=JSON.parse(e.data);if(!this._execMessage)return t.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(r.args)||(r.args=[r.args]);const i=this._execMessage(r,e);if(i===void 0)return;i.then((o={})=>{let u,n;typeof o=="object"&&o!==null&&(u=o.error,n=o.result),u?t.postMessage(JSON.stringify({error:u})):n!==void 0?t.postMessage(JSON.stringify({result:n})):t.postMessage(JSON.stringify({result:o}))},o=>{t.postMessage(JSON.stringify({error:this._prepareError(o)}))})}catch(r){t.postMessage(JSON.stringify({error:this._prepareError(r)}))}}_prepareError(e){if(typeof e=="string"){const t=this._side+": "+e;return console.error(t),t}return e.message=this._side+": "+e.message,console.error(e),e.message}}const p=".",w={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},P=async(s,e)=>{if(typeof s!="string")throw new Error('Configurator ID is not a string type: "'+typeof s+'"');const t=e.customApiUrl?e.customApiUrl:"https://api.roomle.com/v2",r=e.overrideTenant||9,i=t+"/configurators/"+s,o="roomle_portal_v2",u="03-"+window.btoa(new Date().toISOString()+";anonymous;"+o),n=()=>{const d={apiKey:o,currentTenant:r,locale:"en",language:"en",device:1,token:u,platform:"web"};return new Headers(d)},a=new Request(i,{method:"GET",headers:n(),mode:"cors",cache:"default"}),l=await fetch(a),{configurator:g}=await l.json();return g},F=()=>{try{return window.self!==window.top}catch{return!0}},U=["127.0.0.1","localhost","0.0.0.0"],B=()=>{const s=F();let e=window.location.href;if(s){if(!document.referrer)return null;e=document.referrer}const{hostname:t}=new URL(e);return t},H=s=>!!(U.includes(s)||s.endsWith("roomle.com")||s.endsWith("gitlab.io")||s.endsWith("gitlab.com")),E=["language","browserLanguage","userLanguage","systemLanguage"],k=(s=null)=>{const e=window.navigator;if(s)return s.substr(0,2);if(Array.isArray(e.languages)&&e.languages.length>0)return e.languages[0].substr(0,2);for(let t=0,r=E.length;t<r;t++){const i=e[E[t]];if(i)return i.substr(0,2)}return"en"},x=(s,e)=>{const t=JSON.parse(JSON.stringify(s));return y(t,e)},y=(s,e)=>{for(const t in e)try{e[t].constructor===Object?s[t]=y(s[t],e[t]):s[t]=e[t]}catch{s[t]=e[t]}return s};var W={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const C={mobileLandscape:!0,floorMaterialRootTag:"materials_root",buttons:{renderimage:!0,requestproduct:!0,requestplan:!0,load_product:!0,partlist_print:!0},helpcenter:{roomdesigner:!0,configurator:!1,disable:!1},firstPersonView:!0,saveToIdb:!0,featureFlags:{mocAr:!0}},J="(idle)",$=s=>(b(s),s!=null&&s.customApiUrl&&(s.customApiUrl=decodeURIComponent(s.customApiUrl)),s.shareUrl&&(s.deeplink=s.shareUrl.replace(j,G)),s),b=s=>{if(!s)return;const e=Object.keys(s);for(const t of e){const r=s[t];if(!Array.isArray(r)&&typeof r=="object"&&r!==null&&b(r),Array.isArray(r))for(const i of r)b(i);(r==="true"||r==="false")&&(s[t]=r==="true")}},V=(s,e)=>{e.configuratorId=s.id;const t=s.settings||{};return!e.overrideTenant&&s.tenant&&(e.overrideTenant=s.tenant),x(t,e)},z=()=>{const s={...C};s.locale||(s.locale=k()),s.id===J&&delete s.id;const e=B();return e&&H(e)&&(s.configuratorId="demoConfigurator"),s.customApiUrl=W.VITE_RAPI_URL,s.emails=!1,s},j="<CONF_ID>",G="#CONFIGURATIONID#",v=()=>/(android)/i.test(navigator.userAgent),T=(s,e,t)=>{let r=null;Object.defineProperty(s,e,{get(){return r||t},set(i){i!=null&&i.mute?r=i.value:(console.warn("You override Roomle defined behaviour. To disalbe this warning pass in an object with the following properties"),console.warn("{ mute: true, value: () => void }"),r=i)}})},L=()=>window.innerHeight*.01+"px",M=s=>{s&&setTimeout(()=>s.style.setProperty(I,L()),0)},N="rml-styles",q=450,I="--rml-full-height",h={CONTAINER:"rml-container",FILL:"rml-fill",POSITION:"rml-pos",TRANSITION:"rml-transition",ANDROID_HEIGHT:"rml-android-height",OVERFLOW_HIDDEN:"rml-overflow-hidden"},O=new Map;class Y{constructor(e,t,r,i,o){if(c(this,"ui",{callbacks:null}),c(this,"extended",{callbacks:null}),c(this,"configurator",{callbacks:null}),c(this,"analytics",{callbacks:{}}),c(this,"global",{callbacks:{}}),c(this,"plugins",{}),c(this,"_waitForIframe"),c(this,"_container"),c(this,"_messageHandler"),c(this,"_configuratorSettings"),c(this,"_initData",{}),c(this,"_iframe"),c(this,"pluginsLoaded",[]),!e||typeof e.id!="string")throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(O.has(t))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(N)){const n=r.zIndex||9999999,a=document.createElement("style");a.type="text/css",a.id=N;const l="transition:all ease-in-out "+q+"ms;",g=["-webkit-","-o-"].reduce((f,m)=>f+=m+l,"")+l,d=L();a.innerHTML=`
|
|
2
|
+
.${h.CONTAINER}{${I}:${d};}
|
|
3
|
+
.${h.POSITION}{position:fixed;top:0;left:0;z-index:${n};opacity:0}
|
|
4
|
+
.${h.TRANSITION}{${g}}
|
|
5
|
+
.${h.FILL}{width:100%;height:100%;opacity:1}
|
|
6
|
+
.${h.ANDROID_HEIGHT}{height:calc(var(${I},1vh)*100)}
|
|
7
|
+
.${h.OVERFLOW_HIDDEN}{overflow:hidden}
|
|
8
|
+
`,document.head.appendChild(a)}this._onResize=this._onResize.bind(this),v()&&window.addEventListener("resize",this._onResize),this._container=t,this._initData=r,this._configuratorSettings=e;const u=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._executeMessage=this._executeMessage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._messageHandler=new A("website",window,null,this._executeMessage),this._waitForIframe=o,this._container.appendChild(u),this._iframe=u;for(const n of i)typeof n=="string"&&n==="dragIn"?this.pluginsLoaded.push(new Promise((a,l)=>{try{import("./drag-in-gOPgOymI.mjs").then(({DragIn:g})=>{const d=new g(this._iframe);d.setInstance(this.ui),this.plugins.dragIn=d,a()})}catch(g){l(g)}})):n.name&&n.loader&&this.pluginsLoaded.push(new Promise((a,l)=>{try{n.loader().then(g=>{const d=new g(this._iframe);d.setInstance(this.ui),this.plugins[n.name]=d,a()})}catch(g){l(g)}}));O.set(t,!0)}static createPlanner(e,t,r,i=[]){return this._create(e,t,r,i)}static createConfigurator(e,t,r,i=[]){return this._create(e,t,r,i)}static create(e,t,r,i){return this._create(e,t,r,i)}static createViewer(e,t,r,i=[]){return this._create(e,t,r,i)}static async _create(e,t,r,i){return new Promise(async(o,u)=>{try{const n=y(z(),$(r));n.featureFlags||(n.featureFlags={}),typeof n.featureFlags.realPartList!="boolean"&&(n.featureFlags.realPartList=!0),typeof n.featureFlags.globalCallbacks!="boolean"&&(n.featureFlags.globalCallbacks=!0),typeof n.featureFlags.mocAr!="boolean"&&(n.featureFlags.mocAr=!1);const a=await P(e,n);r=V(a,n);const l=new this(a,t,r,i,o);return await Promise.allSettled(l.pluginsLoaded),l}catch(n){return u(n)}})}teardown(){this._container&&O.delete(this._container);const e=this._container.querySelector("iframe");e&&this._container.removeChild(e),window.removeEventListener("resize",this._onResize)}_createIframe(){var e;const t=document.createElement("iframe");let r=((e=this._configuratorSettings)==null?void 0:e.url)||"https://www.roomle.com/t/cp/";return this._initData.useLocalRoomle&&(r=location.href.replace("embedding.html","")),location.href.includes("roomle.gitlab.io")&&(r=location.href.replace("embedding.html","index.html")),this._initData.overrideServerUrl&&(r=this._initData.overrideServerUrl),t.src=r,t.classList.add(h.CONTAINER),t.classList.add(h.FILL),t}_onResize(){M(this._iframe)}_onUseFullPage(){this._iframe.classList.add(h.POSITION),document.documentElement.classList.add(h.OVERFLOW_HIDDEN),window.document.body.classList.add(h.OVERFLOW_HIDDEN),v()&&(M(this._iframe),this._iframe.classList.add(h.ANDROID_HEIGHT))}_onBackToWebsite(){this._iframe.classList.remove(h.POSITION),this._iframe.classList.remove(h.ANDROID_HEIGHT),document.documentElement.classList.remove(h.OVERFLOW_HIDDEN),window.document.body.classList.remove(h.OVERFLOW_HIDDEN)}_executeMessage({message:e,args:t},r){var i;if(!r.source||r.source!==((i=this._iframe)==null?void 0:i.contentWindow))return;if(e===w.REQUEST_BOOT)return this._messageHandler.setOutgoingMessageBus(r.source),Promise.resolve({result:this._initData});if(e===w.SETUP){const{methods:l,callbacks:g}=t[0];return l.forEach(d=>{const f=d.split(p),m=f[0],_=f[1];this[m]||(this[m]={}),this[m][_]=function(){return this._messageHandler.sendMessage(d,[...arguments])}.bind(this)}),g.forEach(d=>{const f=d.split(p),m=f[0],_=f[1],D=f[2];this[m]||(this[m]={}),this[m][_]||(this[m][_]={}),this[m][_][D]=()=>{}}),T(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),T(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>this._messageHandler.sendMessage(w.WEBSITE_READY),0),Promise.resolve({result:null})}const o=e.split(p),u=o[0],n=o[1],a=o.length===3?o[2]:null;if(a&&this[u][n][a]){const l=this[u][n][a](...t);return l instanceof Promise?l.then(g=>({result:g})):l!==void 0?Promise.resolve({result:l}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}}export{Y as default};
|