@roomle/embedding-lib 5.25.0-alpha.3 → 5.25.0-alpha.5

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