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