@roomle/embedding-lib 7.3.0-alpha.4 → 8.0.0-alpha.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.
@@ -1,8 +1,6 @@
1
- import { n as e } from "./comlink-BipJ8Ikr.mjs";
2
- import { t } from "./browser-C_Dfiou7.mjs";
3
- import { t as n } from "./utils-i2eOrtnv.mjs";
1
+ import { t as e } from "./browser-CW9o-dtT.mjs";
4
2
  //#region packages/common/src/utils/message-handler.ts
5
- var r = class {
3
+ var t = class {
6
4
  _side;
7
5
  _incomingMessageBus = null;
8
6
  _outgoingMessageBus = null;
@@ -68,37 +66,37 @@ var r = class {
68
66
  }
69
67
  return e.message = this._side + ": " + e.message, console.error(e), e.message;
70
68
  }
71
- }, i = () => {
69
+ }, n = () => {
72
70
  try {
73
71
  return window.self !== window.top;
74
72
  } catch {
75
73
  return !0;
76
74
  }
77
- }, a = [
75
+ }, r = [
78
76
  "127.0.0.1",
79
77
  "localhost",
80
78
  "0.0.0.0"
81
- ], o = () => {
82
- let e = i(), t = window.location.href;
79
+ ], i = () => {
80
+ let e = n(), t = window.location.href;
83
81
  if (e) {
84
82
  if (!document.referrer) return null;
85
83
  t = document.referrer;
86
84
  }
87
- let { hostname: n } = new URL(t);
88
- return n;
89
- }, s = (e) => {
85
+ let { hostname: r } = new URL(t);
86
+ return r;
87
+ }, a = (e) => {
90
88
  let t = /* @__PURE__ */ new RegExp(/^(10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.)/);
91
- return !!(a.includes(e) || t.test(e) || e.endsWith("roomle.com") || e.endsWith("gitlab.io") || e.endsWith("gitlab.com"));
92
- }, c = (e, t) => l(JSON.parse(JSON.stringify(e)), t), l = (e, t) => {
89
+ return !!(r.includes(e) || t.test(e) || e.endsWith("roomle.com") || e.endsWith("gitlab.io") || e.endsWith("gitlab.com"));
90
+ }, o = (e, t) => s(JSON.parse(JSON.stringify(e)), t), s = (e, t) => {
93
91
  for (let n in t) try {
94
- t[n].constructor === Object ? e[n] = l(e[n], t[n]) : e[n] = t[n];
92
+ t[n].constructor === Object ? e[n] = s(e[n], t[n]) : e[n] = t[n];
95
93
  } catch {
96
94
  e[n] = t[n];
97
95
  }
98
96
  return e;
99
- }, u = /* @__PURE__ */ function(e) {
97
+ }, c = /* @__PURE__ */ function(e) {
100
98
  return e.BOTTOM_BAR = "bottom_bar", e.PARTLIST_BOUNDS = "partlist_bounds", e.INTERACTION_NOTES = "interaction_notes", e.PARAMETER_GROUPS = "parameter_groups", e;
101
- }({}), d = (e) => JSON.parse(JSON.stringify(e)), f = {
99
+ }({}), l = (e) => JSON.parse(JSON.stringify(e)), u = {
102
100
  mobileLandscape: !0,
103
101
  floorMaterialRootTag: "materials_root",
104
102
  buttons: {
@@ -108,7 +106,7 @@ var r = class {
108
106
  load_product: !0,
109
107
  partlist_print: !0
110
108
  },
111
- elements: { [u.INTERACTION_NOTES]: !0 },
109
+ elements: { [c.INTERACTION_NOTES]: !0 },
112
110
  helpcenter: {
113
111
  roomdesigner: !0,
114
112
  configurator: !1,
@@ -127,32 +125,32 @@ var r = class {
127
125
  },
128
126
  rotationSnapDegrees: 10,
129
127
  interactionsCollapsed: !1
130
- }, p = (e) => (h(e), e?.customApiUrl && (e.customApiUrl = decodeURIComponent(e.customApiUrl)), e.shareUrl && (e.deeplink = e.shareUrl.replace(_, v)), e), m = (e) => e.trim() !== "" && Number.isFinite(Number(e.trim())), h = (e) => {
128
+ }, d = (e) => (p(e), e?.customApiUrl && (e.customApiUrl = decodeURIComponent(e.customApiUrl)), e.shareUrl && (e.deeplink = e.shareUrl.replace(h, g)), e), f = (e) => e.trim() !== "" && Number.isFinite(Number(e.trim())), p = (e) => {
131
129
  if (!e || typeof e != "object") return;
132
130
  let t = Object.keys(e);
133
131
  for (let n of t) {
134
132
  let t = e[n];
135
- if (!Array.isArray(t) && typeof t == "object" && t && h(t), Array.isArray(t)) for (let e of t) h(e);
136
- t === "true" || t === "false" ? e[n] = t === "true" : typeof t == "string" && m(t) && (e[n] = Number(t));
133
+ if (!Array.isArray(t) && typeof t == "object" && t && p(t), Array.isArray(t)) for (let e of t) p(e);
134
+ t === "true" || t === "false" ? e[n] = t === "true" : typeof t == "string" && f(t) && (e[n] = Number(t));
137
135
  }
138
- }, g = () => {
139
- let e = d(f);
140
- e.locale ||= t(null, !0), e.id === "(idle)" && delete e.id;
141
- let n = o();
142
- return n && s(n) && (e.configuratorId = "demoConfigurator"), e.customApiUrl = "https://rubens.alpha.roomle.com/api/v2", e.emails = !1, e;
143
- }, _ = "<CONF_ID>", v = "#CONFIGURATIONID#", y = (e) => {
136
+ }, m = () => {
137
+ let t = l(u);
138
+ t.locale ||= e(null, !0), t.id === "(idle)" && delete t.id;
139
+ let n = i();
140
+ return n && a(n) && (t.configuratorId = "demoConfigurator"), t.customApiUrl = "https://rubens.alpha.roomle.com/api/v2", t.emails = !1, t;
141
+ }, h = "<CONF_ID>", g = "#CONFIGURATIONID#", _ = (e) => {
144
142
  let t = e.featureFlags;
145
143
  if (!t || typeof t != "object" || Array.isArray(t)) return;
146
144
  let n = t;
147
145
  "enableTwoLevelCatalog" in n && typeof n.enableTwoLevelCatalog == "boolean" && (e.enableTwoLevelCatalog === !1 || e.enableTwoLevelCatalog === void 0) && (e.enableTwoLevelCatalog = n.enableTwoLevelCatalog), "webGpu" in n && typeof n.webGpu == "boolean" && (e.webGpu === !1 || e.webGpu === void 0) && (e.webGpu = n.webGpu);
148
- }, b = (e) => {
146
+ }, v = (e) => {
149
147
  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);
150
- }, x = (e, t) => {
151
- let n = d(t), r = g();
152
- b(r);
153
- let i = c(c(r, e.settings || {}), n);
154
- return i.configuratorId = e.id, !i.overrideTenant && e.tenant && (i.overrideTenant = e.tenant), y(i), i;
155
- }, S = () => /(android)/i.test(navigator.userAgent), C = class {
148
+ }, y = (e, t) => {
149
+ let n = l(t), r = m();
150
+ v(r);
151
+ let i = o(o(r, e.settings || {}), n);
152
+ return i.configuratorId = e.id, !i.overrideTenant && e.tenant && (i.overrideTenant = e.tenant), _(i), i;
153
+ }, b = () => /(android)/i.test(navigator.userAgent), x = class {
156
154
  _messageHandler = null;
157
155
  isSetupDone = !1;
158
156
  viewName = "main";
@@ -194,7 +192,7 @@ var r = class {
194
192
  setupPlugins(e, t, n = "website") {
195
193
  for (let r of e) typeof r == "string" && r === "dragIn" ? this.pluginsLoaded.push(new Promise((e, r) => {
196
194
  try {
197
- import("./drag-in-BCnrHxxt.mjs").then((e) => e.n).then(({ DragIn: i }) => {
195
+ import("./drag-in-ClPpCYyi.mjs").then((e) => e.n).then(({ DragIn: i }) => {
198
196
  let a = new i(this.ui, t, n, this.viewName);
199
197
  a.init().then(() => {
200
198
  this.plugins.dragIn = a, e();
@@ -216,7 +214,7 @@ var r = class {
216
214
  }
217
215
  }));
218
216
  }
219
- }, w = () => {
217
+ }, S = () => {
220
218
  let e, t;
221
219
  return {
222
220
  promise: new Promise((n, r) => {
@@ -225,7 +223,7 @@ var r = class {
225
223
  resolve: e,
226
224
  reject: t
227
225
  };
228
- }, T = {
226
+ }, C = {
229
227
  SDK: "extended",
230
228
  CONFIGURATOR_SDK: "configurator",
231
229
  CALLBACKS: "callbacks",
@@ -233,20 +231,20 @@ var r = class {
233
231
  ANALYTICS: "analytics",
234
232
  GLOBAL: "global",
235
233
  RAPI: "rapi"
236
- }, E = ".", D = T.SDK + "." + T.CALLBACKS, O = {
234
+ }, w = ".", T = C.SDK + "." + C.CALLBACKS, E = {
237
235
  REQUEST_BOOT: "requestBoot",
238
236
  SETUP: "setup",
239
237
  WEBSITE_READY: "websiteReady"
240
- }, k = {
238
+ }, D = {
241
239
  GET_METHODS: "getMethods",
242
240
  RETURN_METHODS: "returnMethods",
243
241
  REGISTER_CUSTOM_VIEW: "registerCustomView",
244
242
  REGISTER_CUSTOM_VIEW_DONE: "registerCustomViewDone"
245
- }, A = ["constructor", "callbacks"], j = (e) => e[0] !== "_" && !A.includes(e), M = (e, t, n = !1) => {
243
+ }, O = ["constructor", "callbacks"], k = (e) => e[0] !== "_" && !O.includes(e), A = (e, t, n = !1) => {
246
244
  if (!e) return [];
247
- let r = Object.getOwnPropertyNames(e), i = n ? T.CALLBACKS + "." : "";
248
- return r.filter(j).map((e) => t + "." + i + e);
249
- }, N = async (e, t) => {
245
+ let r = Object.getOwnPropertyNames(e), i = n ? C.CALLBACKS + "." : "";
246
+ return r.filter(k).map((e) => t + "." + i + e);
247
+ }, j = async (e, t) => {
250
248
  if (typeof e != "string") throw Error("Configurator ID is not a string type: \"" + typeof e + "\"");
251
249
  let n = t.customApiUrl ? t.customApiUrl : "https://api.roomle.com/v2", r = t.overrideTenant || 9, i = n + "/configurators/" + e, a = "03-" + window.btoa((/* @__PURE__ */ new Date()).toISOString() + ";anonymous;roomle_portal_v2"), o = new Request(i, {
252
250
  method: "GET",
@@ -263,7 +261,7 @@ var r = class {
263
261
  cache: "default"
264
262
  }), { configurator: s } = await (await fetch(o)).json();
265
263
  return s;
266
- }, P = "data-rml-interaction-container", F = (e, t, n) => {
264
+ }, M = "data-rml-interaction-container", N = (e, t, n) => {
267
265
  let r = null;
268
266
  Object.defineProperty(e, t, {
269
267
  get() {
@@ -273,39 +271,39 @@ var r = class {
273
271
  e?.mute ? r = e.value : (console.warn("You override Roomle defined behaviour. To disalbe this warning pass in an object with the following properties"), console.warn("{ mute: true, value: () => void }"), r = e);
274
272
  }
275
273
  });
276
- }, I = () => window.innerHeight * .01 + "px", L = (e) => {
277
- e && setTimeout(() => e.style.setProperty(B, I()), 0);
278
- }, R = "rml-styles", z = 450, B = "--rml-full-height", V = {
274
+ }, P = () => window.innerHeight * .01 + "px", F = (e) => {
275
+ e && setTimeout(() => e.style.setProperty(R, P()), 0);
276
+ }, I = "rml-styles", L = 450, R = "--rml-full-height", z = {
279
277
  CONTAINER: "rml-container",
280
278
  FILL: "rml-fill",
281
279
  POSITION: "rml-pos",
282
280
  TRANSITION: "rml-transition",
283
281
  ANDROID_HEIGHT: "rml-android-height",
284
282
  OVERFLOW_HIDDEN: "rml-overflow-hidden"
285
- }, H = /* @__PURE__ */ new Map(), U = class extends C {
283
+ }, B = /* @__PURE__ */ new Map(), V = class extends x {
286
284
  static createPlanner(e, t, n, r = []) {
287
285
  return this._create(e, t, n, r);
288
286
  }
289
- static async connect(e, t = []) {
290
- let n = new C();
291
- n.viewName = e;
292
- let { resolve: i, promise: a } = w(), { resolve: o, promise: s } = w(), c = new r("custom-view-" + e, window, window.parent, ({ message: e, args: t }) => {
287
+ static async connect(e, n = []) {
288
+ let r = new x();
289
+ r.viewName = e;
290
+ let { resolve: i, promise: a } = S(), { resolve: o, promise: s } = S(), c = new t("custom-view-" + e, window, window.parent, ({ message: e, args: t }) => {
293
291
  switch (e) {
294
- case k.REGISTER_CUSTOM_VIEW_DONE:
292
+ case D.REGISTER_CUSTOM_VIEW_DONE:
295
293
  i();
296
294
  break;
297
- case k.RETURN_METHODS:
298
- n.handleSetup(t[0]), o();
295
+ case D.RETURN_METHODS:
296
+ r.handleSetup(t[0]), o();
299
297
  break;
300
- default: if (n.isSetupDone) return n.executeMessage({
298
+ default: if (r.isSetupDone) return r.executeMessage({
301
299
  message: e,
302
300
  args: t
303
301
  });
304
302
  }
305
303
  });
306
- n.setMessageHandler(c);
304
+ r.setMessageHandler(c);
307
305
  let l = [e];
308
- return c.sendMessage(k.REGISTER_CUSTOM_VIEW, l), await a, c.sendMessage(k.GET_METHODS, l), await s, n.setupPlugins(t, document.body, "custom-view"), await Promise.allSettled(n.pluginsLoaded), n;
306
+ return c.sendMessage(D.REGISTER_CUSTOM_VIEW, l), await a, c.sendMessage(D.GET_METHODS, l), await s, r.setupPlugins(n, document.body, "custom-view"), await Promise.allSettled(r.pluginsLoaded), r;
309
307
  }
310
308
  static createConfigurator(e, t, n, r = []) {
311
309
  return this._create(e, t, n, r);
@@ -316,23 +314,14 @@ var r = class {
316
314
  static createViewer(e, t, n, r = []) {
317
315
  return this._create(e, t, n, r);
318
316
  }
319
- static hiMessageHandler = null;
320
- static setupHi(t) {
321
- console.warn("[DEPRECATED] RoomleEmbeddingApi.setupHi() is deprecated and will be removed.\nMigration: import { setupHi } from '@roomle/embedding-lib/hi'; setupHi(libraryIdOrOptions, callbacks);"), this.hiMessageHandler && window.removeEventListener("message", this.hiMessageHandler), this.hiMessageHandler = (r) => {
322
- if (r.data.type === "connect_hi" && r.data.port) {
323
- let i = r.data.port;
324
- i.start?.(), e(n(t), i);
325
- }
326
- }, window.addEventListener("message", this.hiMessageHandler);
327
- }
328
317
  static async _create(e, t, n, r) {
329
318
  return new Promise(async (i, a) => {
330
319
  try {
331
- let a = p(n), o = g();
332
- b(o);
333
- let s = await N(e, c(o, a));
334
- n = x(s, a);
335
- let l = new this(s, t, n, r, i);
320
+ let a = d(n), s = m();
321
+ v(s);
322
+ let c = await j(e, o(s, a));
323
+ n = y(c, a);
324
+ let l = new this(c, t, n, r, i);
336
325
  return await Promise.allSettled(l.pluginsLoaded), l;
337
326
  } catch (e) {
338
327
  return a(e);
@@ -344,53 +333,53 @@ var r = class {
344
333
  _configuratorSettings;
345
334
  _initData = {};
346
335
  _iframe;
347
- constructor(e, t, n, i, a) {
336
+ constructor(e, n, r, i, a) {
348
337
  if (super(), !e || typeof e.id != "string") throw Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");
349
- if (H.has(t)) throw Error("There is already an instance on this DOM element");
350
- if (!document.getElementById(R)) {
351
- let e = n.zIndex || 9999999, t = document.createElement("style");
352
- t.type = "text/css", t.id = R;
353
- let r = "transition:all ease-in-out " + z + "ms;", i = ["-webkit-", "-o-"].reduce((e, t) => e += t + r, "") + r, a = I();
338
+ if (B.has(n)) throw Error("There is already an instance on this DOM element");
339
+ if (!document.getElementById(I)) {
340
+ let e = r.zIndex || 9999999, t = document.createElement("style");
341
+ t.type = "text/css", t.id = I;
342
+ let n = "transition:all ease-in-out " + L + "ms;", i = ["-webkit-", "-o-"].reduce((e, t) => e += t + n, "") + n, a = P();
354
343
  t.innerHTML = `
355
- .${V.CONTAINER}{${B}:${a};}
356
- .${V.POSITION}{position:fixed;top:0;left:0;z-index:${e};opacity:0}
357
- .${V.TRANSITION}{${i}}
358
- .${V.FILL}{width:100%;height:100%;opacity:1}
359
- .${V.ANDROID_HEIGHT}{height:calc(var(${B},1vh)*100)}
360
- .${V.OVERFLOW_HIDDEN}{overflow:hidden}
344
+ .${z.CONTAINER}{${R}:${a};}
345
+ .${z.POSITION}{position:fixed;top:0;left:0;z-index:${e};opacity:0}
346
+ .${z.TRANSITION}{${i}}
347
+ .${z.FILL}{width:100%;height:100%;opacity:1}
348
+ .${z.ANDROID_HEIGHT}{height:calc(var(${R},1vh)*100)}
349
+ .${z.OVERFLOW_HIDDEN}{overflow:hidden}
361
350
  `, document.head.appendChild(t);
362
351
  }
363
352
  this._executeMessage = this._executeMessage.bind(this);
364
- let o = new r("website", window, null, this._executeMessage);
365
- this.setMessageHandler(o), this._onResize = this._onResize.bind(this), S() && window.addEventListener("resize", this._onResize), this._container = t, this._initData = n, this._configuratorSettings = e;
353
+ let o = new t("website", window, null, this._executeMessage);
354
+ this.setMessageHandler(o), this._onResize = this._onResize.bind(this), b() && window.addEventListener("resize", this._onResize), this._container = n, this._initData = r, this._configuratorSettings = e;
366
355
  let s = this._createIframe();
367
- this._onUseFullPage = this._onUseFullPage.bind(this), this._onBackToWebsite = this._onBackToWebsite.bind(this), this._waitForIframe = a, this._container.appendChild(s), this._iframe = s, this.setupPlugins(i, this._iframe), H.set(t, !0);
356
+ this._onUseFullPage = this._onUseFullPage.bind(this), this._onBackToWebsite = this._onBackToWebsite.bind(this), this._waitForIframe = a, this._container.appendChild(s), this._iframe = s, this.setupPlugins(i, this._iframe), B.set(n, !0);
368
357
  }
369
358
  teardown() {
370
- this._container && H.delete(this._container);
359
+ this._container && B.delete(this._container);
371
360
  let e = this._container.querySelector("iframe");
372
361
  e && this._container.removeChild(e), window.removeEventListener("resize", this._onResize);
373
362
  }
374
363
  _createIframe() {
375
364
  let e = document.createElement("iframe"), t = this._configuratorSettings?.url || "https://www.roomle.com/t/cp/";
376
- 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(V.CONTAINER), e.classList.add(V.FILL), e;
365
+ 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(z.CONTAINER), e.classList.add(z.FILL), e;
377
366
  }
378
367
  _onResize() {
379
- L(this._iframe);
368
+ F(this._iframe);
380
369
  }
381
370
  _onUseFullPage() {
382
- this._iframe.classList.add(V.POSITION), document.documentElement.classList.add(V.OVERFLOW_HIDDEN), window.document.body.classList.add(V.OVERFLOW_HIDDEN), S() && (L(this._iframe), this._iframe.classList.add(V.ANDROID_HEIGHT));
371
+ this._iframe.classList.add(z.POSITION), document.documentElement.classList.add(z.OVERFLOW_HIDDEN), window.document.body.classList.add(z.OVERFLOW_HIDDEN), b() && (F(this._iframe), this._iframe.classList.add(z.ANDROID_HEIGHT));
383
372
  }
384
373
  _onBackToWebsite() {
385
- this._iframe.classList.remove(V.POSITION), this._iframe.classList.remove(V.ANDROID_HEIGHT), document.documentElement.classList.remove(V.OVERFLOW_HIDDEN), window.document.body.classList.remove(V.OVERFLOW_HIDDEN);
374
+ this._iframe.classList.remove(z.POSITION), this._iframe.classList.remove(z.ANDROID_HEIGHT), document.documentElement.classList.remove(z.OVERFLOW_HIDDEN), window.document.body.classList.remove(z.OVERFLOW_HIDDEN);
386
375
  }
387
376
  _executeMessage({ message: e, args: t }, n) {
388
- if (n.source && n.source === this._iframe?.contentWindow) return e === O.REQUEST_BOOT ? this._messageHandler ? (this._messageHandler.setOutgoingMessageBus(n.source), Promise.resolve({ result: this._initData })) : (console.error("MessageHandler not set"), Promise.resolve({ error: "MessageHandler not set" })) : e === O.SETUP ? (this.handleSetup(t[0]), F(this.ui.callbacks, "onUseFullPage", this._onUseFullPage), F(this.ui.callbacks, "onBackToWebsite", this._onBackToWebsite), this._waitForIframe(this), setTimeout(() => {
377
+ if (n.source && n.source === this._iframe?.contentWindow) return e === E.REQUEST_BOOT ? this._messageHandler ? (this._messageHandler.setOutgoingMessageBus(n.source), Promise.resolve({ result: this._initData })) : (console.error("MessageHandler not set"), Promise.resolve({ error: "MessageHandler not set" })) : e === E.SETUP ? (this.handleSetup(t[0]), N(this.ui.callbacks, "onUseFullPage", this._onUseFullPage), N(this.ui.callbacks, "onBackToWebsite", this._onBackToWebsite), this._waitForIframe(this), setTimeout(() => {
389
378
  if (!this._messageHandler) {
390
379
  console.error("MessageHandler not set");
391
380
  return;
392
381
  }
393
- this._messageHandler.sendMessage(O.WEBSITE_READY);
382
+ this._messageHandler.sendMessage(E.WEBSITE_READY);
394
383
  }, 0), Promise.resolve({ result: null })) : this.executeMessage({
395
384
  message: e,
396
385
  args: t
@@ -398,4 +387,4 @@ var r = class {
398
387
  }
399
388
  };
400
389
  //#endregion
401
- export { O as HANDSHAKE_MESSAGES, P as INTERACTION_CONTAINER_SELECTOR, T as NAMESPACE, E as NAMESPACE_SEPARATOR, D as SDK_CALLBACK, k as WELL_KNOWN_MESSAGES, U as default, N as getConfiguratorSettings, M as getMethodNames, j as isExposable };
390
+ export { E as HANDSHAKE_MESSAGES, M as INTERACTION_CONTAINER_SELECTOR, C as NAMESPACE, w as NAMESPACE_SEPARATOR, T as SDK_CALLBACK, D as WELL_KNOWN_MESSAGES, V as default, j as getConfiguratorSettings, A as getMethodNames, k as isExposable };