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