@roomle/embedding-lib 0.0.0-dev-a4754cb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.releaserc.json +60 -0
- package/README.md +13 -0
- package/browser-BxG7yIaK.mjs +16 -0
- package/browser-CW9o-dtT.mjs +18 -0
- package/comlink-B2Kj_5Ge.mjs +206 -0
- package/comlink-B5lV2OWp.mjs +226 -0
- package/drag-ghost-BOwjMbG3.mjs +65 -0
- package/drag-ghost-BQ8r6NVo.mjs +60 -0
- package/drag-in-BP_E53zb.mjs +102 -0
- package/drag-in-QhL3zGC0.mjs +108 -0
- package/embedding-plugins.d.ts +2 -0
- package/embedding-plugins.js +2 -0
- package/embedding-plugins.min.js +2 -0
- package/from-custom-view-BM_zRJCf.mjs +227 -0
- package/from-custom-view-D2Z1YmCx.mjs +226 -0
- package/from-website-CPVeVVMI.mjs +123 -0
- package/from-website-DlklVbxU.mjs +118 -0
- package/hi-mcp-server-BtrPxgNY.mjs +5278 -0
- package/hi-mcp-server-ukmMIPNu.mjs +4866 -0
- package/hi.d.ts +2 -0
- package/hi.js +182 -0
- package/hi.min.js +167 -0
- package/package.json +50 -0
- package/packages/embedding-lib/src/connector.d.ts +44 -0
- package/packages/embedding-lib/src/embedding-plugins.d.ts +9 -0
- package/packages/embedding-lib/src/hi.d.ts +22 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-callbacks.d.ts +3 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/agent-facing.d.ts +35 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/hi-mcp-server.d.ts +3 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/mcp-tool.d.ts +69 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/plan-history.d.ts +33 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/planner-api.d.ts +32 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/skills.d.ts +23 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/tool-executors.d.ts +4 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp-tools.d.ts +11 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-order-manager.d.ts +3 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-assistant.d.ts +55 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-requests.d.ts +35 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-setup.d.ts +6 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-utils.d.ts +8 -0
- package/packages/embedding-lib/src/plugins/constants.d.ts +19 -0
- package/packages/embedding-lib/src/plugins/drag-in.d.ts +32 -0
- package/packages/embedding-lib/src/plugins/strategy/drag-phase.d.ts +25 -0
- package/packages/embedding-lib/src/plugins/strategy/from-custom-view.d.ts +39 -0
- package/packages/embedding-lib/src/plugins/strategy/from-website.d.ts +45 -0
- package/packages/embedding-lib/src/plugins/strategy/types.d.ts +14 -0
- package/packages/embedding-lib/src/plugins/types.d.ts +35 -0
- package/packages/embedding-lib/src/roomle-embedding-lib.d.ts +82 -0
- package/packages/embedding-lib/src/utils.d.ts +35 -0
- package/roomle-embedding-lib.d.ts +6 -0
- package/roomle-embedding-lib.js +396 -0
- package/roomle-embedding-lib.min.js +366 -0
- package/utils-DxJ3PcKe.mjs +131 -0
- package/utils-wJ80awOA.mjs +123 -0
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
import { t as e } from "./browser-CW9o-dtT.mjs";
|
|
2
|
+
//#region packages/common/src/utils/message-handler.ts
|
|
3
|
+
var t = class {
|
|
4
|
+
_side;
|
|
5
|
+
_incomingMessageBus = null;
|
|
6
|
+
_outgoingMessageBus = null;
|
|
7
|
+
_execMessage = null;
|
|
8
|
+
constructor(e, t, n, r) {
|
|
9
|
+
this._side = e, this._incomingMessageBus = t, this._outgoingMessageBus = n, this._execMessage = r, this._incomingMessageBus && this._incomingMessageBus.addEventListener("message", this._handleMessage.bind(this));
|
|
10
|
+
}
|
|
11
|
+
setOutgoingMessageBus(e) {
|
|
12
|
+
this._outgoingMessageBus = e;
|
|
13
|
+
}
|
|
14
|
+
setMessageExecution(e) {
|
|
15
|
+
this._execMessage = e;
|
|
16
|
+
}
|
|
17
|
+
sendMessage(e, t = []) {
|
|
18
|
+
return new Promise((n, r) => {
|
|
19
|
+
if (this._incomingMessageBus === this._outgoingMessageBus) return n(void 0);
|
|
20
|
+
let i = new MessageChannel();
|
|
21
|
+
i.port1.onmessage = (e) => {
|
|
22
|
+
if (!e || !e.data) return i.port1.close(), i.port2.close(), r(/* @__PURE__ */ Error(this._side + " received message but response can not be interpreted"));
|
|
23
|
+
let t;
|
|
24
|
+
try {
|
|
25
|
+
t = JSON.parse(e.data);
|
|
26
|
+
} catch (e) {
|
|
27
|
+
return i.port1.close(), i.port2.close(), this._prepareError(e), r(e);
|
|
28
|
+
}
|
|
29
|
+
t.error ? r(t.error) : t.result === void 0 ? n(void 0) : n(t.result), i.port1.close(), i.port2.close();
|
|
30
|
+
};
|
|
31
|
+
let a = "";
|
|
32
|
+
try {
|
|
33
|
+
a = JSON.stringify({
|
|
34
|
+
message: e,
|
|
35
|
+
args: t
|
|
36
|
+
});
|
|
37
|
+
} catch {
|
|
38
|
+
return r(/* @__PURE__ */ Error(this._side + ": can not create command because it is not JSON.stringify able"));
|
|
39
|
+
}
|
|
40
|
+
if (!this._outgoingMessageBus) return r(/* @__PURE__ */ Error(this._side + ": outgoing bus not set yet"));
|
|
41
|
+
this._outgoingMessageBus.postMessage(a, "*", [i.port2]);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
_handleMessage(e) {
|
|
45
|
+
let t = e.ports && Array.isArray(e.ports) && e.ports.length > 0 ? e.ports[0] : null;
|
|
46
|
+
if (e.data && (typeof e.data == "string" || e.data.type !== "connect_hi") && t) try {
|
|
47
|
+
let n = JSON.parse(e.data);
|
|
48
|
+
if (!this._execMessage) return t.postMessage(JSON.stringify({ error: this._side + " is not ready to handle messages" }));
|
|
49
|
+
Array.isArray(n.args) || (n.args = [n.args]);
|
|
50
|
+
let r = this._execMessage(n, e);
|
|
51
|
+
if (r === void 0) return;
|
|
52
|
+
r.then((e = {}) => {
|
|
53
|
+
let n, r;
|
|
54
|
+
typeof e == "object" && e && (n = e.error, r = e.result), n ? t.postMessage(JSON.stringify({ error: n })) : r === void 0 ? t.postMessage(JSON.stringify({ result: e })) : t.postMessage(JSON.stringify({ result: r }));
|
|
55
|
+
}, (e) => {
|
|
56
|
+
t.postMessage(JSON.stringify({ error: this._prepareError(e) }));
|
|
57
|
+
});
|
|
58
|
+
} catch (e) {
|
|
59
|
+
t.postMessage(JSON.stringify({ error: this._prepareError(e) }));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
_prepareError(e) {
|
|
63
|
+
if (typeof e == "string") {
|
|
64
|
+
let t = this._side + ": " + e;
|
|
65
|
+
return console.error(t), t;
|
|
66
|
+
}
|
|
67
|
+
return e.message = this._side + ": " + e.message, console.error(e), e.message;
|
|
68
|
+
}
|
|
69
|
+
}, n = () => {
|
|
70
|
+
try {
|
|
71
|
+
return window.self !== window.top;
|
|
72
|
+
} catch {
|
|
73
|
+
return !0;
|
|
74
|
+
}
|
|
75
|
+
}, r = [
|
|
76
|
+
"127.0.0.1",
|
|
77
|
+
"localhost",
|
|
78
|
+
"0.0.0.0"
|
|
79
|
+
], i = () => {
|
|
80
|
+
let e = n(), t = window.location.href;
|
|
81
|
+
if (e) {
|
|
82
|
+
if (!document.referrer) return null;
|
|
83
|
+
t = document.referrer;
|
|
84
|
+
}
|
|
85
|
+
let { hostname: r } = new URL(t);
|
|
86
|
+
return r;
|
|
87
|
+
}, a = (e) => {
|
|
88
|
+
let t = /* @__PURE__ */ new RegExp(/^(10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.)/);
|
|
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) => {
|
|
91
|
+
for (let n in t) try {
|
|
92
|
+
t[n].constructor === Object ? e[n] = s(e[n], t[n]) : e[n] = t[n];
|
|
93
|
+
} catch {
|
|
94
|
+
e[n] = t[n];
|
|
95
|
+
}
|
|
96
|
+
return e;
|
|
97
|
+
}, c = /* @__PURE__ */ function(e) {
|
|
98
|
+
return e.BOTTOM_BAR = "bottom_bar", e.PARTLIST_BOUNDS = "partlist_bounds", e.INTERACTION_NOTES = "interaction_notes", e.PARAMETER_GROUPS = "parameter_groups", e;
|
|
99
|
+
}({}), l = (e) => JSON.parse(JSON.stringify(e)), u = {
|
|
100
|
+
mobileLandscape: !0,
|
|
101
|
+
floorMaterialRootTag: "materials_root",
|
|
102
|
+
buttons: {
|
|
103
|
+
renderimage: !0,
|
|
104
|
+
requestproduct: !0,
|
|
105
|
+
requestplan: !0,
|
|
106
|
+
load_product: !0,
|
|
107
|
+
partlist_print: !0
|
|
108
|
+
},
|
|
109
|
+
elements: { [c.INTERACTION_NOTES]: !0 },
|
|
110
|
+
helpcenter: {
|
|
111
|
+
roomdesigner: !0,
|
|
112
|
+
configurator: !1,
|
|
113
|
+
disable: !1
|
|
114
|
+
},
|
|
115
|
+
firstPersonView: !0,
|
|
116
|
+
saveToIdb: !0,
|
|
117
|
+
enableTwoLevelCatalog: !1,
|
|
118
|
+
webGpu: !1,
|
|
119
|
+
positionInputDrawer: !1,
|
|
120
|
+
featureFlags: {
|
|
121
|
+
mocAr: !0,
|
|
122
|
+
wallAutoHeight: !1,
|
|
123
|
+
curvedWalls: !1,
|
|
124
|
+
openCloseAnimation: !0,
|
|
125
|
+
localExport3d: !1
|
|
126
|
+
},
|
|
127
|
+
configuratorZoom: !1,
|
|
128
|
+
rotationSnapDegrees: 10,
|
|
129
|
+
interactionsCollapsed: !1
|
|
130
|
+
}, 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
|
+
if (!e || typeof e != "object") return;
|
|
132
|
+
let t = Object.keys(e);
|
|
133
|
+
for (let n of t) {
|
|
134
|
+
let t = e[n];
|
|
135
|
+
if (!Array.isArray(t) && typeof t == "object" && t && p(t), Array.isArray(t)) for (let e of t) p(e);
|
|
136
|
+
t === "true" || t === "false" ? e[n] = t === "true" : typeof t == "string" && f(t) && (e[n] = Number(t));
|
|
137
|
+
}
|
|
138
|
+
}, m = () => {
|
|
139
|
+
let t = l(u);
|
|
140
|
+
t.locale ||= e(null, !0), t.id === "(idle)" && delete t.id;
|
|
141
|
+
let n = i();
|
|
142
|
+
return n && a(n) && (t.configuratorId = "demoConfigurator"), t.customApiUrl = void 0, t.emails = !1, t;
|
|
143
|
+
}, h = "<CONF_ID>", g = "#CONFIGURATIONID#", _ = (e) => {
|
|
144
|
+
let t = e.featureFlags;
|
|
145
|
+
if (!t || typeof t != "object" || Array.isArray(t)) return;
|
|
146
|
+
let n = t;
|
|
147
|
+
"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
|
+
}, v = (e) => {
|
|
149
|
+
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
|
+
}, y = (e, t) => {
|
|
151
|
+
let n = l(t), r = m();
|
|
152
|
+
v(r);
|
|
153
|
+
let i = o(o(r, e.settings || {}), n);
|
|
154
|
+
return i.configuratorId = e.id, !i.overrideTenant && e.tenant && (i.overrideTenant = e.tenant), _(i), i;
|
|
155
|
+
}, b = () => /(android)/i.test(navigator.userAgent), x = class {
|
|
156
|
+
_messageHandler = null;
|
|
157
|
+
isSetupDone = !1;
|
|
158
|
+
viewName = "main";
|
|
159
|
+
plugins = {};
|
|
160
|
+
pluginsLoaded = [];
|
|
161
|
+
ui = { callbacks: null };
|
|
162
|
+
extended = { callbacks: null };
|
|
163
|
+
configurator = { callbacks: null };
|
|
164
|
+
analytics = { callbacks: {} };
|
|
165
|
+
rapi = { callbacks: {} };
|
|
166
|
+
global = { callbacks: {} };
|
|
167
|
+
setMessageHandler(e) {
|
|
168
|
+
this._messageHandler = e;
|
|
169
|
+
}
|
|
170
|
+
handleSetup(e) {
|
|
171
|
+
let { methods: t, callbacks: n } = e;
|
|
172
|
+
t.forEach((e) => {
|
|
173
|
+
let t = e.split("."), n = t[0], r = t[1];
|
|
174
|
+
this[n] || (this[n] = {}), this[n][r] = function() {
|
|
175
|
+
if (!this._messageHandler) {
|
|
176
|
+
console.error("MessageHandler not set");
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
return this._messageHandler.sendMessage(e, [...arguments]);
|
|
180
|
+
}.bind(this);
|
|
181
|
+
}), n.forEach((e) => {
|
|
182
|
+
let t = e.split("."), n = t[0], r = t[1], i = t[2];
|
|
183
|
+
this[n] || (this[n] = {}), this[n][r] || (this[n][r] = {}), this[n][r][i] = () => void 0;
|
|
184
|
+
}), this.isSetupDone = !0;
|
|
185
|
+
}
|
|
186
|
+
executeMessage({ message: e, args: t }) {
|
|
187
|
+
let n = e.split("."), r = n[0], i = n[1], a = n.length === 3 ? n[2] : null;
|
|
188
|
+
if (a && this[r][i][a]) {
|
|
189
|
+
let e = this[r][i][a](...t);
|
|
190
|
+
return e instanceof Promise ? e.then((e) => ({ result: e })) : e === void 0 ? Promise.resolve({ result: null }) : Promise.resolve({ result: e });
|
|
191
|
+
}
|
|
192
|
+
return Promise.reject("Message \"" + e + "\" is unkown");
|
|
193
|
+
}
|
|
194
|
+
setupPlugins(e, t, n = "website") {
|
|
195
|
+
for (let r of e) typeof r == "string" && r === "dragIn" ? this.pluginsLoaded.push(new Promise((e, r) => {
|
|
196
|
+
try {
|
|
197
|
+
import("./drag-in-QhL3zGC0.mjs").then((e) => e.n).then(({ DragIn: i }) => {
|
|
198
|
+
let a = new i(this.ui, t, n, this.viewName);
|
|
199
|
+
a.init().then(() => {
|
|
200
|
+
this.plugins.dragIn = a, e();
|
|
201
|
+
}, r);
|
|
202
|
+
});
|
|
203
|
+
} catch (e) {
|
|
204
|
+
r(e);
|
|
205
|
+
}
|
|
206
|
+
})) : r.name && r.loader && this.pluginsLoaded.push(new Promise((e, i) => {
|
|
207
|
+
try {
|
|
208
|
+
r.loader().then((a) => {
|
|
209
|
+
let o = new a(this.ui, t, n, this.viewName);
|
|
210
|
+
o.init().then(() => {
|
|
211
|
+
this.plugins[r.name] = o, e();
|
|
212
|
+
}, i);
|
|
213
|
+
});
|
|
214
|
+
} catch (e) {
|
|
215
|
+
i(e);
|
|
216
|
+
}
|
|
217
|
+
}));
|
|
218
|
+
}
|
|
219
|
+
}, S = () => {
|
|
220
|
+
let e, t;
|
|
221
|
+
return {
|
|
222
|
+
promise: new Promise((n, r) => {
|
|
223
|
+
e = n, t = r;
|
|
224
|
+
}),
|
|
225
|
+
resolve: e,
|
|
226
|
+
reject: t
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region packages/common/src/utils/rapi-version.ts
|
|
231
|
+
(/* @__PURE__ */ "/items./items/{id}./items/{id}/renderings./items/{id}/conversions./items/{id}/3d-exports./items/{id}/perspectiveImage./items/{id}/perspectiveImageHD./items/{id}/topImage./items/{id}/tags./items/{id}/tagConnections./items/{id}/additionalContents./items/{id}/assetProcessings./items/{id}/3dAssets/{format}./items/{id}/3dAssets/{format}/{dummyFileName}./configurations./configurations/{id}./configurations/{id}/shares./configurations/{id}/renderings./configurations/{id}/3d-exports./configurations/{id}/3dAssets/{format}./configurations/{id}/3dAssets/{format}/{dummyFileName}./auth/signin./auth/signout./auth/reset./auth/reset/confirm./auth/change/pwd./auth/context./assets/analyze./version".split(".")).map((e) => RegExp("^" + e.replace(/\{[^}]+\}/g, "[^/]+") + "/?$"));
|
|
232
|
+
var C = /\/v[23]\/?$/, w = (e, t) => C.test(e) ? e.replace(C, "/v2") + t : e + t, T = {
|
|
233
|
+
SDK: "extended",
|
|
234
|
+
CONFIGURATOR_SDK: "configurator",
|
|
235
|
+
CALLBACKS: "callbacks",
|
|
236
|
+
UI: "ui",
|
|
237
|
+
ANALYTICS: "analytics",
|
|
238
|
+
GLOBAL: "global",
|
|
239
|
+
RAPI: "rapi"
|
|
240
|
+
}, E = ".", D = T.SDK + "." + T.CALLBACKS, O = {
|
|
241
|
+
REQUEST_BOOT: "requestBoot",
|
|
242
|
+
SETUP: "setup",
|
|
243
|
+
WEBSITE_READY: "websiteReady"
|
|
244
|
+
}, k = {
|
|
245
|
+
GET_METHODS: "getMethods",
|
|
246
|
+
RETURN_METHODS: "returnMethods",
|
|
247
|
+
REGISTER_CUSTOM_VIEW: "registerCustomView",
|
|
248
|
+
REGISTER_CUSTOM_VIEW_DONE: "registerCustomViewDone"
|
|
249
|
+
}, A = ["constructor", "callbacks"], j = (e) => e[0] !== "_" && !A.includes(e), M = (e, t, n = !1) => {
|
|
250
|
+
if (!e) return [];
|
|
251
|
+
let r = Object.getOwnPropertyNames(e), i = n ? T.CALLBACKS + "." : "";
|
|
252
|
+
return r.filter(j).map((e) => t + "." + i + e);
|
|
253
|
+
}, N = async (e, t) => {
|
|
254
|
+
if (typeof e != "string") throw Error("Configurator ID is not a string type: \"" + typeof e + "\"");
|
|
255
|
+
let n = t.customApiUrl ? t.customApiUrl : "https://api.roomle.com/v2", r = t.overrideTenant || 9, i = w(n, "/configurators/" + e), a = "03-" + window.btoa((/* @__PURE__ */ new Date()).toISOString() + ";anonymous;roomle_portal_v2"), o = new Request(i, {
|
|
256
|
+
method: "GET",
|
|
257
|
+
headers: new Headers({
|
|
258
|
+
apiKey: "roomle_portal_v2",
|
|
259
|
+
currentTenant: r,
|
|
260
|
+
locale: "en",
|
|
261
|
+
language: "en",
|
|
262
|
+
device: 1,
|
|
263
|
+
token: a,
|
|
264
|
+
platform: "web"
|
|
265
|
+
}),
|
|
266
|
+
mode: "cors",
|
|
267
|
+
cache: "default"
|
|
268
|
+
}), { configurator: s } = await (await fetch(o)).json();
|
|
269
|
+
return s;
|
|
270
|
+
}, P = "data-rml-interaction-container", F = (e, t, n) => {
|
|
271
|
+
let r = null;
|
|
272
|
+
Object.defineProperty(e, t, {
|
|
273
|
+
get() {
|
|
274
|
+
return r || n;
|
|
275
|
+
},
|
|
276
|
+
set(e) {
|
|
277
|
+
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);
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}, I = () => window.innerHeight * .01 + "px", L = (e) => {
|
|
281
|
+
e && setTimeout(() => e.style.setProperty(B, I()), 0);
|
|
282
|
+
}, R = "rml-styles", z = 450, B = "--rml-full-height", V = {
|
|
283
|
+
CONTAINER: "rml-container",
|
|
284
|
+
FILL: "rml-fill",
|
|
285
|
+
POSITION: "rml-pos",
|
|
286
|
+
TRANSITION: "rml-transition",
|
|
287
|
+
ANDROID_HEIGHT: "rml-android-height",
|
|
288
|
+
OVERFLOW_HIDDEN: "rml-overflow-hidden"
|
|
289
|
+
}, H = /* @__PURE__ */ new Map(), U = class extends x {
|
|
290
|
+
static createPlanner(e, t, n, r = []) {
|
|
291
|
+
return this._create(e, t, n, r);
|
|
292
|
+
}
|
|
293
|
+
static async connect(e, n = []) {
|
|
294
|
+
let r = new x();
|
|
295
|
+
r.viewName = e;
|
|
296
|
+
let { resolve: i, promise: a } = S(), { resolve: o, promise: s } = S(), c = new t("custom-view-" + e, window, window.parent, ({ message: e, args: t }) => {
|
|
297
|
+
switch (e) {
|
|
298
|
+
case k.REGISTER_CUSTOM_VIEW_DONE:
|
|
299
|
+
i();
|
|
300
|
+
break;
|
|
301
|
+
case k.RETURN_METHODS:
|
|
302
|
+
r.handleSetup(t[0]), o();
|
|
303
|
+
break;
|
|
304
|
+
default: if (r.isSetupDone) return r.executeMessage({
|
|
305
|
+
message: e,
|
|
306
|
+
args: t
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
r.setMessageHandler(c);
|
|
311
|
+
let l = [e];
|
|
312
|
+
return c.sendMessage(k.REGISTER_CUSTOM_VIEW, l), await a, c.sendMessage(k.GET_METHODS, l), await s, r.setupPlugins(n, document.body, "custom-view"), await Promise.allSettled(r.pluginsLoaded), r;
|
|
313
|
+
}
|
|
314
|
+
static createConfigurator(e, t, n, r = []) {
|
|
315
|
+
return this._create(e, t, n, r);
|
|
316
|
+
}
|
|
317
|
+
static create(e, t, n, r) {
|
|
318
|
+
return this._create(e, t, n, r);
|
|
319
|
+
}
|
|
320
|
+
static createViewer(e, t, n, r = []) {
|
|
321
|
+
return this._create(e, t, n, r);
|
|
322
|
+
}
|
|
323
|
+
static async _create(e, t, n, r) {
|
|
324
|
+
return new Promise(async (i, a) => {
|
|
325
|
+
try {
|
|
326
|
+
let a = d(n), s = m();
|
|
327
|
+
v(s);
|
|
328
|
+
let c = await N(e, o(s, a));
|
|
329
|
+
n = y(c, a);
|
|
330
|
+
let l = new this(c, t, n, r, i);
|
|
331
|
+
return await Promise.allSettled(l.pluginsLoaded), l;
|
|
332
|
+
} catch (e) {
|
|
333
|
+
return a(e);
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
_waitForIframe;
|
|
338
|
+
_container;
|
|
339
|
+
_configuratorSettings;
|
|
340
|
+
_initData = {};
|
|
341
|
+
_iframe;
|
|
342
|
+
constructor(e, n, r, i, a) {
|
|
343
|
+
if (super(), !e || typeof e.id != "string") throw Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");
|
|
344
|
+
if (H.has(n)) throw Error("There is already an instance on this DOM element");
|
|
345
|
+
if (!document.getElementById(R)) {
|
|
346
|
+
let e = r.zIndex || 9999999, t = document.createElement("style");
|
|
347
|
+
t.type = "text/css", t.id = R;
|
|
348
|
+
let n = "transition:all ease-in-out " + z + "ms;", i = ["-webkit-", "-o-"].reduce((e, t) => e += t + n, "") + n, a = I();
|
|
349
|
+
t.innerHTML = `
|
|
350
|
+
.${V.CONTAINER}{${B}:${a};}
|
|
351
|
+
.${V.POSITION}{position:fixed;top:0;left:0;z-index:${e};opacity:0}
|
|
352
|
+
.${V.TRANSITION}{${i}}
|
|
353
|
+
.${V.FILL}{width:100%;height:100%;opacity:1}
|
|
354
|
+
.${V.ANDROID_HEIGHT}{height:calc(var(${B},1vh)*100)}
|
|
355
|
+
.${V.OVERFLOW_HIDDEN}{overflow:hidden}
|
|
356
|
+
`, document.head.appendChild(t);
|
|
357
|
+
}
|
|
358
|
+
this._executeMessage = this._executeMessage.bind(this);
|
|
359
|
+
let o = new t("website", window, null, this._executeMessage);
|
|
360
|
+
this.setMessageHandler(o), this._onResize = this._onResize.bind(this), b() && window.addEventListener("resize", this._onResize), this._container = n, this._initData = r, this._configuratorSettings = e;
|
|
361
|
+
let s = this._createIframe();
|
|
362
|
+
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(n, !0);
|
|
363
|
+
}
|
|
364
|
+
teardown() {
|
|
365
|
+
this._container && H.delete(this._container);
|
|
366
|
+
let e = this._container.querySelector("iframe");
|
|
367
|
+
e && this._container.removeChild(e), window.removeEventListener("resize", this._onResize);
|
|
368
|
+
}
|
|
369
|
+
_createIframe() {
|
|
370
|
+
let e = document.createElement("iframe"), t = this._configuratorSettings?.url || "https://www.roomle.com/t/cp/";
|
|
371
|
+
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;
|
|
372
|
+
}
|
|
373
|
+
_onResize() {
|
|
374
|
+
L(this._iframe);
|
|
375
|
+
}
|
|
376
|
+
_onUseFullPage() {
|
|
377
|
+
this._iframe.classList.add(V.POSITION), document.documentElement.classList.add(V.OVERFLOW_HIDDEN), window.document.body.classList.add(V.OVERFLOW_HIDDEN), b() && (L(this._iframe), this._iframe.classList.add(V.ANDROID_HEIGHT));
|
|
378
|
+
}
|
|
379
|
+
_onBackToWebsite() {
|
|
380
|
+
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);
|
|
381
|
+
}
|
|
382
|
+
_executeMessage({ message: e, args: t }, n) {
|
|
383
|
+
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(() => {
|
|
384
|
+
if (!this._messageHandler) {
|
|
385
|
+
console.error("MessageHandler not set");
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
this._messageHandler.sendMessage(O.WEBSITE_READY);
|
|
389
|
+
}, 0), Promise.resolve({ result: null })) : this.executeMessage({
|
|
390
|
+
message: e,
|
|
391
|
+
args: t
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
//#endregion
|
|
396
|
+
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 };
|