@roomle/embedding-lib 4.38.0 → 4.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/api/classes/exposed_analytics_callbacks.ExposedAnalyticsCallbacks.md +1 -1
- package/docs/api/classes/exposed_api.ExposedApi.md +11 -11
- package/docs/api/classes/exposed_callbacks.ExposedCallbacks.md +8 -8
- package/docs/api/classes/roomle_configurator_api.default.md +9 -9
- package/docs/api/enums/types.UI_BUTTON.md +22 -22
- package/docs/api/interfaces/exposed_callbacks.Labels.md +2 -2
- package/docs/api/interfaces/exposed_callbacks.Price.md +2 -2
- package/docs/api/interfaces/roomle_configurator_api.RoomleEmbeddingApiKeys.md +4 -4
- package/docs/api/interfaces/types.ConfiguratorSettings.md +5 -5
- package/docs/api/interfaces/types.EmbeddingSkin.md +5 -5
- package/docs/api/interfaces/types.UiInitData.md +16 -16
- package/docs/api/modules/roomle_configurator_api.md +3 -3
- package/docs/examples/11_light_settings.html +89 -62
- package/docs/examples/roomle-configurator-api.es.min.js +254 -58
- package/docs/md/web/ui/EMBEDDING-CHANGELOG.md +21 -37
- package/package.json +2 -2
- package/types/index.d.ts +7 -3
- package/types/src/common/store/collection-view-state.d.ts +7 -3
- package/types/tests/helpers/mocks/sdk-connector.d.ts +1 -0
|
@@ -50,10 +50,10 @@ class MessageHandler {
|
|
|
50
50
|
};
|
|
51
51
|
let command = '';
|
|
52
52
|
try {
|
|
53
|
-
command = JSON.stringify({message, args});
|
|
53
|
+
command = JSON.stringify({ message, args });
|
|
54
54
|
}
|
|
55
55
|
catch (e) {
|
|
56
|
-
return reject(new Error(this._side + ': can not create command
|
|
56
|
+
return reject(new Error(this._side + ': can not create command because it is not JSON.stringify able'));
|
|
57
57
|
}
|
|
58
58
|
if (!this._outgoingMessageBus) {
|
|
59
59
|
return reject(new Error(this._side + ': outgoing bus not set yet'));
|
|
@@ -68,7 +68,7 @@ class MessageHandler {
|
|
|
68
68
|
try {
|
|
69
69
|
const command = JSON.parse(event.data);
|
|
70
70
|
if (!this._execMessage) {
|
|
71
|
-
return receiver.postMessage(JSON.stringify({error: this._side + ' is not ready to handle messages'}));
|
|
71
|
+
return receiver.postMessage(JSON.stringify({ error: this._side + ' is not ready to handle messages' }));
|
|
72
72
|
}
|
|
73
73
|
if (!Array.isArray(command.args)) {
|
|
74
74
|
command.args = [command.args];
|
|
@@ -87,19 +87,20 @@ class MessageHandler {
|
|
|
87
87
|
result = data.result;
|
|
88
88
|
}
|
|
89
89
|
if (error) {
|
|
90
|
-
receiver.postMessage(JSON.stringify({error}));
|
|
91
|
-
}
|
|
92
|
-
|
|
90
|
+
receiver.postMessage(JSON.stringify({ error }));
|
|
91
|
+
}
|
|
92
|
+
else if (result !== undefined) {
|
|
93
|
+
receiver.postMessage(JSON.stringify({ result }));
|
|
93
94
|
}
|
|
94
95
|
else {
|
|
95
|
-
receiver.postMessage(JSON.stringify({result: data}));
|
|
96
|
+
receiver.postMessage(JSON.stringify({ result: data }));
|
|
96
97
|
}
|
|
97
98
|
}, (error) => {
|
|
98
|
-
receiver.postMessage(JSON.stringify({error: this._prepareError(error)}));
|
|
99
|
+
receiver.postMessage(JSON.stringify({ error: this._prepareError(error) }));
|
|
99
100
|
});
|
|
100
101
|
}
|
|
101
102
|
catch (error) {
|
|
102
|
-
receiver.postMessage(JSON.stringify({error: this._prepareError(error)}));
|
|
103
|
+
receiver.postMessage(JSON.stringify({ error: this._prepareError(error) }));
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
}
|
|
@@ -115,49 +116,25 @@ class MessageHandler {
|
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
/**
|
|
119
|
-
* Recursively merge properties of two objects.
|
|
120
|
-
* If a property exists in both it, property of obj2 is used
|
|
121
|
-
* @param obj1
|
|
122
|
-
* @param obj2
|
|
123
|
-
*/
|
|
124
|
-
const deepMerge = (obj1, obj2) => {
|
|
125
|
-
// tslint:disable-next-line
|
|
126
|
-
for (const p in obj2) {
|
|
127
|
-
try {
|
|
128
|
-
// Property in destination object set; update its value.
|
|
129
|
-
if (obj2[p].constructor === Object) {
|
|
130
|
-
obj1[p] = deepMerge(obj1[p], obj2[p]);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
obj1[p] = obj2[p];
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
catch (e) {
|
|
137
|
-
// Property in destination object not set; create it and set its value.
|
|
138
|
-
obj1[p] = obj2[p];
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return obj1;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
119
|
const NAMESPACE_SEPARATOR = '.';
|
|
145
120
|
const HANDSHAKE_MESSAGES = {
|
|
146
121
|
REQUEST_BOOT: 'requestBoot',
|
|
147
122
|
SETUP: 'setup',
|
|
148
123
|
WEBSITE_READY: 'websiteReady',
|
|
149
124
|
};
|
|
150
|
-
const getConfiguratorSettings = async (configuratorId) => {
|
|
125
|
+
const getConfiguratorSettings = async (configuratorId, initData) => {
|
|
151
126
|
if (typeof configuratorId !== 'string') {
|
|
152
127
|
throw new Error('Configurator ID is not a string type: "' + (typeof configuratorId) + '"');
|
|
153
128
|
}
|
|
154
|
-
const
|
|
129
|
+
const server = initData.customApiUrl ? initData.customApiUrl : 'https://api.roomle.com/v2';
|
|
130
|
+
const currentTenant = initData.overrideTenant || 9;
|
|
131
|
+
const url = server + '/configurators/' + configuratorId;
|
|
155
132
|
const apiKey = 'roomle_portal_v2';
|
|
156
133
|
const token = '03-' + window.btoa((new Date()).toISOString() + ';anonymous;' + apiKey);
|
|
157
134
|
const createHeaders = () => {
|
|
158
135
|
const headers = {
|
|
159
136
|
apiKey,
|
|
160
|
-
currentTenant
|
|
137
|
+
currentTenant,
|
|
161
138
|
locale: 'en',
|
|
162
139
|
language: 'en',
|
|
163
140
|
device: 1,
|
|
@@ -173,16 +150,173 @@ const getConfiguratorSettings = async (configuratorId) => {
|
|
|
173
150
|
cache: 'default',
|
|
174
151
|
});
|
|
175
152
|
const response = await fetch(request);
|
|
176
|
-
const {configurator} = await response.json();
|
|
153
|
+
const { configurator } = await response.json();
|
|
177
154
|
return configurator;
|
|
178
155
|
};
|
|
156
|
+
|
|
157
|
+
const isInIframe = () => {
|
|
158
|
+
try {
|
|
159
|
+
return window.self !== window.top;
|
|
160
|
+
}
|
|
161
|
+
catch (e) {
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const NAMES_FOR_LOCALHOST = [
|
|
167
|
+
'127.0.0.1',
|
|
168
|
+
'localhost',
|
|
169
|
+
'0.0.0.0',
|
|
170
|
+
];
|
|
171
|
+
const getHostname = () => {
|
|
172
|
+
const isIframe = isInIframe();
|
|
173
|
+
let url = window.location.href;
|
|
174
|
+
if (isIframe) {
|
|
175
|
+
if (!document.referrer) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
url = document.referrer;
|
|
179
|
+
}
|
|
180
|
+
const { hostname } = new URL(url);
|
|
181
|
+
return hostname;
|
|
182
|
+
};
|
|
183
|
+
const isDemoHostname = (hostname) => {
|
|
184
|
+
if (NAMES_FOR_LOCALHOST.includes(hostname)) {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
if (hostname.endsWith('roomle.com')) {
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
// exception for CI builds
|
|
191
|
+
if (hostname.endsWith('gitlab.io') || hostname.endsWith('gitlab.com')) {
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
return false;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Recursively merge properties of two objects.
|
|
199
|
+
* If a property exists in both it, property of obj2 is used.
|
|
200
|
+
* Returns a new object (copy)
|
|
201
|
+
* @param obj1
|
|
202
|
+
* @param obj2
|
|
203
|
+
*/
|
|
204
|
+
const deepMergeCopy = (obj1, obj2) => {
|
|
205
|
+
const result = JSON.parse(JSON.stringify(obj1));
|
|
206
|
+
return deepMerge(result, obj2);
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Recursively merge properties of two objects.
|
|
210
|
+
* If a property exists in both it, property of obj2 is used.
|
|
211
|
+
* Warning: This returns obj1 and not a copy!
|
|
212
|
+
* @param obj1
|
|
213
|
+
* @param obj2
|
|
214
|
+
*/
|
|
215
|
+
const deepMerge = (obj1, obj2) => {
|
|
216
|
+
// tslint:disable-next-line
|
|
217
|
+
for (const p in obj2) {
|
|
218
|
+
try {
|
|
219
|
+
// Property in destination object set; update its value.
|
|
220
|
+
if (obj2[p].constructor === Object) {
|
|
221
|
+
obj1[p] = deepMerge(obj1[p], obj2[p]);
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
obj1[p] = obj2[p];
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
catch (e) {
|
|
228
|
+
// Property in destination object not set; create it and set its value.
|
|
229
|
+
obj1[p] = obj2[p];
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return obj1;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const BROWSER_LANGUAGE_PROPERTY_KEYS_KNOWN = ['language', 'browserLanguage', 'userLanguage', 'systemLanguage'];
|
|
236
|
+
const getLanguage = (lang = null) => {
|
|
237
|
+
const navigator = window.navigator;
|
|
238
|
+
if (lang) {
|
|
239
|
+
return lang.substr(0, 2);
|
|
240
|
+
}
|
|
241
|
+
if (Array.isArray(navigator.languages) && navigator.languages.length > 0) {
|
|
242
|
+
return navigator.languages[0].substr(0, 2);
|
|
243
|
+
}
|
|
244
|
+
for (let i = 0, length = BROWSER_LANGUAGE_PROPERTY_KEYS_KNOWN.length; i < length; i++) {
|
|
245
|
+
const language = navigator[BROWSER_LANGUAGE_PROPERTY_KEYS_KNOWN[i]];
|
|
246
|
+
if (language) {
|
|
247
|
+
return language.substr(0, 2);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return 'en';
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
const CONFIGURATOR_IDLE = '(idle)';
|
|
254
|
+
const castAndFixInitData = (initData) => {
|
|
255
|
+
castInitData(initData);
|
|
256
|
+
if (initData === null || initData === void 0 ? void 0 : initData.customApiUrl) {
|
|
257
|
+
initData.customApiUrl = decodeURIComponent(initData.customApiUrl);
|
|
258
|
+
}
|
|
259
|
+
if (initData.shareUrl) {
|
|
260
|
+
initData.deeplink = initData.shareUrl.replace(LEGACY_SHARE_PLACEHOLDER, SHARE_PLACEHOLDER);
|
|
261
|
+
}
|
|
262
|
+
return initData;
|
|
263
|
+
};
|
|
264
|
+
const castInitData = (obj) => {
|
|
265
|
+
if (!obj) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const keys = Object.keys(obj);
|
|
269
|
+
for (const key of keys) {
|
|
270
|
+
const value = obj[key];
|
|
271
|
+
// need to type-check for null because typeof null evaluates to object
|
|
272
|
+
// see here why this is like it is: https://2ality.com/2013/10/typeof-null.html
|
|
273
|
+
if (!Array.isArray(value) && typeof value === 'object' && value !== null) {
|
|
274
|
+
return castInitData(value);
|
|
275
|
+
}
|
|
276
|
+
if (Array.isArray(value)) {
|
|
277
|
+
for (const entry of value) {
|
|
278
|
+
castInitData(entry);
|
|
279
|
+
}
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
if (value === 'true' || value === 'false') {
|
|
283
|
+
obj[key] = value === 'true';
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
};
|
|
179
287
|
const mergeInitData = (configuratorSettings, currentInitData) => {
|
|
180
288
|
currentInitData.configuratorId = configuratorSettings.id;
|
|
181
289
|
const remoteInitData = configuratorSettings.settings || {};
|
|
182
|
-
|
|
290
|
+
// This is a performance optimization so we do not need to fetch
|
|
291
|
+
// configurator settings twice
|
|
292
|
+
if (!currentInitData.overrideTenant && configuratorSettings.tenant) {
|
|
293
|
+
// use as any because we send tenant id as string but SDK requires to send a number
|
|
294
|
+
// casting to number could become a problem when we change tenant IDs to something
|
|
295
|
+
// random instead of a integer which is incremented
|
|
296
|
+
currentInitData.overrideTenant = configuratorSettings.tenant;
|
|
297
|
+
}
|
|
298
|
+
return deepMergeCopy(remoteInitData, currentInitData);
|
|
299
|
+
};
|
|
300
|
+
const getFallbackInitData = () => {
|
|
301
|
+
const fallbackInitData = {};
|
|
302
|
+
if (!fallbackInitData.locale) {
|
|
303
|
+
fallbackInitData.locale = getLanguage();
|
|
304
|
+
}
|
|
305
|
+
if (fallbackInitData.id === CONFIGURATOR_IDLE) {
|
|
306
|
+
delete fallbackInitData.id;
|
|
307
|
+
}
|
|
308
|
+
const hostname = getHostname();
|
|
309
|
+
if (hostname && isDemoHostname(hostname)) {
|
|
310
|
+
fallbackInitData.configuratorId = 'demoConfigurator';
|
|
311
|
+
}
|
|
312
|
+
fallbackInitData.customApiUrl = 'https://www.roomle.com/api/v2';
|
|
313
|
+
fallbackInitData.emails = false;
|
|
314
|
+
return fallbackInitData;
|
|
183
315
|
};
|
|
316
|
+
const LEGACY_SHARE_PLACEHOLDER = '<CONF_ID>';
|
|
317
|
+
const SHARE_PLACEHOLDER = '#CONFIGURATIONID#';
|
|
184
318
|
|
|
185
|
-
// see why:
|
|
319
|
+
// see why: so#/58065241/10800831
|
|
186
320
|
const isAndroid = () => /(android)/i.test(navigator.userAgent);
|
|
187
321
|
|
|
188
322
|
const setDefaultBehaviour = (object, callbackName, defaultBehaviour) => {
|
|
@@ -222,7 +356,8 @@ const RML_CSS_CLASSES = {
|
|
|
222
356
|
ANDROID_HEIGHT: 'rml-android-height',
|
|
223
357
|
OVERFLOW_HIDDEN: 'rml-overflow-hidden',
|
|
224
358
|
};
|
|
225
|
-
|
|
359
|
+
const globalSetupDone = new Map();
|
|
360
|
+
class RoomleEmbeddingApi {
|
|
226
361
|
constructor(settings, container, initData, waitForIframe) {
|
|
227
362
|
this.ui = {
|
|
228
363
|
callbacks: null,
|
|
@@ -233,10 +368,16 @@ class RoomleConfiguratorApi {
|
|
|
233
368
|
this.analytics = {
|
|
234
369
|
callbacks: {},
|
|
235
370
|
};
|
|
371
|
+
this.global = {
|
|
372
|
+
callbacks: {},
|
|
373
|
+
};
|
|
236
374
|
this._initData = {};
|
|
237
375
|
if (!settings || typeof settings.id !== 'string') {
|
|
238
376
|
throw new Error('Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person');
|
|
239
377
|
}
|
|
378
|
+
if (globalSetupDone.has(container)) {
|
|
379
|
+
throw new Error('There is already an instance on this DOM element');
|
|
380
|
+
}
|
|
240
381
|
const stylesAlreadyAdded = !!document.getElementById(RML_STYLES_ID);
|
|
241
382
|
if (!stylesAlreadyAdded) {
|
|
242
383
|
const zIndex = initData.zIndex || 9999999;
|
|
@@ -247,13 +388,13 @@ class RoomleConfiguratorApi {
|
|
|
247
388
|
const cssTransitionForAllBrowsers = ['-webkit-', '-o-'].reduce((acc, browser) => acc += browser + cssTransition, '') + cssTransition;
|
|
248
389
|
const vh = calcVh();
|
|
249
390
|
styles.innerHTML = `
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
391
|
+
.${RML_CSS_CLASSES.CONTAINER}{${RML_CUSTOM_PROPERTY_HEIGHT}:${vh};}
|
|
392
|
+
.${RML_CSS_CLASSES.POSITION}{position:fixed;top:0;left:0;z-index:${zIndex};opacity:0}
|
|
393
|
+
.${RML_CSS_CLASSES.TRANSITION}{${cssTransitionForAllBrowsers}}
|
|
394
|
+
.${RML_CSS_CLASSES.FILL}{width:100%;height:100%;opacity:1}
|
|
395
|
+
.${RML_CSS_CLASSES.ANDROID_HEIGHT}{height:calc(var(${RML_CUSTOM_PROPERTY_HEIGHT},1vh)*100)}
|
|
396
|
+
.${RML_CSS_CLASSES.OVERFLOW_HIDDEN}{overflow:hidden}
|
|
397
|
+
`;
|
|
257
398
|
document.head.appendChild(styles);
|
|
258
399
|
}
|
|
259
400
|
this._onResize = this._onResize.bind(this);
|
|
@@ -271,6 +412,10 @@ class RoomleConfiguratorApi {
|
|
|
271
412
|
this._waitForIframe = waitForIframe;
|
|
272
413
|
this._container.appendChild(iframe);
|
|
273
414
|
this._iframe = iframe;
|
|
415
|
+
globalSetupDone.set(container, true);
|
|
416
|
+
}
|
|
417
|
+
static createPlanner(configuratorId, container, initData) {
|
|
418
|
+
return this._create(configuratorId, container, initData);
|
|
274
419
|
}
|
|
275
420
|
/**
|
|
276
421
|
* Method to create a new instance of a Roomle Configurator
|
|
@@ -278,11 +423,43 @@ class RoomleConfiguratorApi {
|
|
|
278
423
|
* @param container DOM container in which the configurator should be placed
|
|
279
424
|
* @param initData settings with which the configurator should be started
|
|
280
425
|
*/
|
|
426
|
+
static createConfigurator(configuratorId, container, initData) {
|
|
427
|
+
return this._create(configuratorId, container, initData);
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Method to create a new instance of a Roomle Configurator
|
|
431
|
+
* @deprecated please use "createConfigurator"
|
|
432
|
+
* @param configuratorId the id which identifies your configurator, you will get this ID from your Roomle Contact Person
|
|
433
|
+
* @param container DOM container in which the configurator should be placed
|
|
434
|
+
* @param initData settings with which the configurator should be started
|
|
435
|
+
*/
|
|
281
436
|
static create(configuratorId, container, initData) {
|
|
437
|
+
return this._create(configuratorId, container, initData);
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Method to create a new instance of a Roomle Viewer
|
|
441
|
+
* @param configuratorId the id which identifies your configurator, you will get this ID from your Roomle Contact Person
|
|
442
|
+
* @param container DOM container in which the configurator should be placed
|
|
443
|
+
* @param initData settings with which the configurator should be started
|
|
444
|
+
*/
|
|
445
|
+
static createViewer(configuratorId, container, initData) {
|
|
446
|
+
return this._create(configuratorId, container, initData);
|
|
447
|
+
}
|
|
448
|
+
static _create(configuratorId, container, initData) {
|
|
282
449
|
return new Promise(async (resolve, reject) => {
|
|
283
450
|
try {
|
|
284
|
-
const
|
|
285
|
-
|
|
451
|
+
const fallbackInitData = deepMerge(getFallbackInitData(), castAndFixInitData(initData));
|
|
452
|
+
if (!fallbackInitData.featureFlags) {
|
|
453
|
+
fallbackInitData.featureFlags = {};
|
|
454
|
+
}
|
|
455
|
+
if (typeof fallbackInitData.featureFlags.realPartList !== 'boolean') {
|
|
456
|
+
fallbackInitData.featureFlags.realPartList = true;
|
|
457
|
+
}
|
|
458
|
+
if (typeof fallbackInitData.featureFlags.globalCallbacks !== 'boolean') {
|
|
459
|
+
fallbackInitData.featureFlags.globalCallbacks = true;
|
|
460
|
+
}
|
|
461
|
+
const configuratorSettings = await getConfiguratorSettings(configuratorId, fallbackInitData);
|
|
462
|
+
initData = mergeInitData(configuratorSettings, fallbackInitData);
|
|
286
463
|
return new this(configuratorSettings, container, initData, resolve);
|
|
287
464
|
}
|
|
288
465
|
catch (e) {
|
|
@@ -291,6 +468,13 @@ class RoomleConfiguratorApi {
|
|
|
291
468
|
});
|
|
292
469
|
}
|
|
293
470
|
teardown() {
|
|
471
|
+
if (this._container) {
|
|
472
|
+
globalSetupDone.delete(this._container);
|
|
473
|
+
}
|
|
474
|
+
const iframe = this._container.querySelector('iframe');
|
|
475
|
+
if (iframe) {
|
|
476
|
+
this._container.removeChild(iframe);
|
|
477
|
+
}
|
|
294
478
|
window.removeEventListener('resize', this._onResize);
|
|
295
479
|
}
|
|
296
480
|
_createIframe() {
|
|
@@ -329,7 +513,7 @@ class RoomleConfiguratorApi {
|
|
|
329
513
|
document.documentElement.classList.remove(RML_CSS_CLASSES.OVERFLOW_HIDDEN);
|
|
330
514
|
window.document.body.classList.remove(RML_CSS_CLASSES.OVERFLOW_HIDDEN);
|
|
331
515
|
}
|
|
332
|
-
_executeMessage({message, args}, event) {
|
|
516
|
+
_executeMessage({ message, args }, event) {
|
|
333
517
|
var _a;
|
|
334
518
|
if (!event.source) {
|
|
335
519
|
// @ts-ignore
|
|
@@ -341,14 +525,17 @@ class RoomleConfiguratorApi {
|
|
|
341
525
|
}
|
|
342
526
|
if (message === HANDSHAKE_MESSAGES.REQUEST_BOOT) {
|
|
343
527
|
this._messageHandler.setOutgoingMessageBus(event.source);
|
|
344
|
-
return Promise.resolve({result: this._initData});
|
|
528
|
+
return Promise.resolve({ result: this._initData });
|
|
345
529
|
}
|
|
346
530
|
if (message === HANDSHAKE_MESSAGES.SETUP) {
|
|
347
|
-
const {methods, callbacks} = args[0];
|
|
531
|
+
const { methods, callbacks } = args[0];
|
|
348
532
|
methods.forEach((method) => {
|
|
349
533
|
const namespaces = method.split(NAMESPACE_SEPARATOR);
|
|
350
534
|
const object = namespaces[0];
|
|
351
535
|
const methodName = namespaces[1];
|
|
536
|
+
if (!this[object]) {
|
|
537
|
+
this[object] = {};
|
|
538
|
+
}
|
|
352
539
|
this[object][methodName] = function () {
|
|
353
540
|
// @todo -- this was the fix that values are passed to caller, e.g.: interface.extended.getParametersOfRootComponent
|
|
354
541
|
// most of the things we need for a meaningful test are not available in JEST (since it runs in node). We should
|
|
@@ -361,6 +548,9 @@ class RoomleConfiguratorApi {
|
|
|
361
548
|
const object = namespaces[0];
|
|
362
549
|
const callbacksName = namespaces[1];
|
|
363
550
|
const eventName = namespaces[2];
|
|
551
|
+
if (!this[object]) {
|
|
552
|
+
this[object] = {};
|
|
553
|
+
}
|
|
364
554
|
if (!this[object][callbacksName]) {
|
|
365
555
|
this[object][callbacksName] = {};
|
|
366
556
|
}
|
|
@@ -371,7 +561,7 @@ class RoomleConfiguratorApi {
|
|
|
371
561
|
setDefaultBehaviour(this.ui.callbacks, 'onBackToWebsite', this._onBackToWebsite);
|
|
372
562
|
this._waitForIframe(this);
|
|
373
563
|
setTimeout(() => this._messageHandler.sendMessage(HANDSHAKE_MESSAGES.WEBSITE_READY), 0); // Run it after the promise is resolved so everyone can subscribe
|
|
374
|
-
return Promise.resolve({result: null});
|
|
564
|
+
return Promise.resolve({ result: null });
|
|
375
565
|
}
|
|
376
566
|
const messageNamespaces = message.split(NAMESPACE_SEPARATOR);
|
|
377
567
|
const namespace = messageNamespaces[0];
|
|
@@ -379,12 +569,18 @@ class RoomleConfiguratorApi {
|
|
|
379
569
|
const methodOfAction = (messageNamespaces.length === 3) ? messageNamespaces[2] : null;
|
|
380
570
|
if (methodOfAction) {
|
|
381
571
|
if (this[namespace][objectOfAction][methodOfAction]) {
|
|
382
|
-
this[namespace][objectOfAction][methodOfAction](...args);
|
|
383
|
-
|
|
572
|
+
const result = this[namespace][objectOfAction][methodOfAction](...args);
|
|
573
|
+
if (result instanceof Promise) {
|
|
574
|
+
return result.then((data) => ({ result: data }));
|
|
575
|
+
}
|
|
576
|
+
else if (result !== undefined) {
|
|
577
|
+
return Promise.resolve({ result });
|
|
578
|
+
}
|
|
579
|
+
return Promise.resolve({ result: null });
|
|
384
580
|
}
|
|
385
581
|
}
|
|
386
582
|
return Promise.reject('Message "' + message + '" is unkown');
|
|
387
583
|
}
|
|
388
584
|
}
|
|
389
585
|
|
|
390
|
-
export default
|
|
586
|
+
export { RoomleEmbeddingApi as default };
|
|
@@ -1,45 +1,29 @@
|
|
|
1
|
-
## [4.
|
|
1
|
+
## [4.39.0](https://gitlab.com/roomle/web/roomle-ui/compare/embedding-v4.38.0...embedding-v4.39.0) (2022-07-19)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Features
|
|
5
5
|
|
|
6
|
-
* add
|
|
7
|
-
* add
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* **SDK:** upgrade
|
|
11
|
-
* **SDK:** upgrade
|
|
12
|
-
* **SDK:** upgrade
|
|
13
|
-
* **SDK:** upgrade SDK to version 2.35.0-alpha.6 ([b2a6fb9](https://gitlab.com/roomle/web/roomle-ui/commit/b2a6fb9ddbb63866bc086f7661fe3d4af717409e))
|
|
14
|
-
* **SDK:** upgrade SDK to version 2.35.0-alpha.9 ([d635fd8](https://gitlab.com/roomle/web/roomle-ui/commit/d635fd86161c24bbe5bb8d24787ad10f43493e3c))
|
|
15
|
-
* **SDK:** upgrade to version 2.34.0 ([040fff7](https://gitlab.com/roomle/web/roomle-ui/commit/040fff75928768578a6ce5e7d5fcdef71d103a42))
|
|
16
|
-
* **SDK:** upgrade to version 2.35.0-alpha.1 ([c13174a](https://gitlab.com/roomle/web/roomle-ui/commit/c13174afd3c6df810aa2fda8f9c79df5fa14d40b))
|
|
17
|
-
* **SDK:** upgrade to version 2.35.0-alpha.2 ([bb7cd51](https://gitlab.com/roomle/web/roomle-ui/commit/bb7cd5198956026c646d2fbafbd96f9c33e3b6e1))
|
|
18
|
-
* **SDK:** upgrade to version 2.35.0-alpha.2 ([ee0cfe3](https://gitlab.com/roomle/web/roomle-ui/commit/ee0cfe3630858e8a2eeeff0a9d29afd2646d1e41))
|
|
19
|
-
* **SDK:** upgrade to version 2.35.0-alpha.3 ([ca28a34](https://gitlab.com/roomle/web/roomle-ui/commit/ca28a34fcc1614ef007d2d53328f0210c94345e6))
|
|
20
|
-
* **SDK:** upgrade to version 2.35.0-alpha.3 ([1a293b0](https://gitlab.com/roomle/web/roomle-ui/commit/1a293b03b9e6c0d624ab2fc35bdba49bc682263f))
|
|
21
|
-
* **SDK:** upgrade to version 2.35.0-alpha.5 ([c90d419](https://gitlab.com/roomle/web/roomle-ui/commit/c90d41949df8af6e959ff52ffed8d0a3dda161a6))
|
|
6
|
+
* add bigger thumbnail design ([fb0e917](https://gitlab.com/roomle/web/roomle-ui/commit/fb0e917dd99c6bf55cb69067b7cbc80c1084cf6c))
|
|
7
|
+
* add correct styling of thumbnails in mobile ([bf3fd0f](https://gitlab.com/roomle/web/roomle-ui/commit/bf3fd0f28309c292e470f47fafaef458b9b6632b))
|
|
8
|
+
* **SDK:** upgrade to version 2.35.1-alpha.1 ([d864df7](https://gitlab.com/roomle/web/roomle-ui/commit/d864df7261fd7ba8dccc86f206bbe03620e38c11))
|
|
9
|
+
* **SDK:** upgrade to version 2.35.1-alpha.1 ([bfd3d24](https://gitlab.com/roomle/web/roomle-ui/commit/bfd3d24c3d2d66b0d9270bb8625fb1b5e68e92c2))
|
|
10
|
+
* **SDK:** upgrade to version 2.36.0-alpha.1 ([6d5fae3](https://gitlab.com/roomle/web/roomle-ui/commit/6d5fae3851988aa6f77d0f46dc3a3f364c1df292))
|
|
11
|
+
* **SDK:** upgrade to version 2.36.0-alpha.2 ([66197b1](https://gitlab.com/roomle/web/roomle-ui/commit/66197b1699f22229614c753948c233d30456c6e4))
|
|
12
|
+
* **SDK:** upgrade to version 2.36.0-alpha.3 ([92c3065](https://gitlab.com/roomle/web/roomle-ui/commit/92c30653eb3e625d5c69e748f3fb447547573d8d))
|
|
22
13
|
|
|
23
14
|
|
|
24
15
|
### Bug Fixes
|
|
25
16
|
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* failing
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* remove NSDB symbol ([bc8136b](https://gitlab.com/roomle/web/roomle-ui/commit/bc8136b0601fdd2a38b014b5337ac8ad7295d9a9))
|
|
40
|
-
* remove ts error ([bfd5b02](https://gitlab.com/roomle/web/roomle-ui/commit/bfd5b02d7cadd81079ca3b21c62b7bce712dcd49))
|
|
41
|
-
* should not close sidebar if change selection ([027fd9f](https://gitlab.com/roomle/web/roomle-ui/commit/027fd9fa9a6b1e10b8196153649d82e536ea9daf))
|
|
42
|
-
* sidebar should also close if i deselect a item ([d07a00e](https://gitlab.com/roomle/web/roomle-ui/commit/d07a00e971ccf95a3fbf6bcd8053fff8a571a366))
|
|
43
|
-
* sidebar should be opened again after dragged in a object ([ba06ddc](https://gitlab.com/roomle/web/roomle-ui/commit/ba06ddc10bdfef45bd525168fa1a5459ade3795f))
|
|
44
|
-
* touch drag should be only triggered if there is not too much x movement ([5a1261e](https://gitlab.com/roomle/web/roomle-ui/commit/5a1261e2680e4c36137005baee8fa699f9d0584e))
|
|
45
|
-
* type check on interface RoomlePlanner ([a749571](https://gitlab.com/roomle/web/roomle-ui/commit/a749571339b04599659f9950526d1db323f39a2c))
|
|
17
|
+
* Add addons icon on mobile need some right padding ([63fd194](https://gitlab.com/roomle/web/roomle-ui/commit/63fd1947e955e2415f49c0b32b88a21d0cec00a0))
|
|
18
|
+
* big thumbnails should have the same padding left and right ([a5a4ea6](https://gitlab.com/roomle/web/roomle-ui/commit/a5a4ea6de717b69e306d74f423e65ad5765cc93f))
|
|
19
|
+
* disable undo and redo in configurator when in MOC ([63c322c](https://gitlab.com/roomle/web/roomle-ui/commit/63c322cc53c3fe0af698cfdaf87b0b9a69fd1273))
|
|
20
|
+
* elements label should only be displayed if there are no group labels ([81d71a4](https://gitlab.com/roomle/web/roomle-ui/commit/81d71a4ac4336ebc361945b18d75cd8a49588785))
|
|
21
|
+
* failing tests and lint errors ([db8491a](https://gitlab.com/roomle/web/roomle-ui/commit/db8491ad5130cd50fe09f8584eea688b27e9c698))
|
|
22
|
+
* function not defined error ([535d3b8](https://gitlab.com/roomle/web/roomle-ui/commit/535d3b8d5e095bfd05b8e315d4a7d4f8b9ea6cf2))
|
|
23
|
+
* Group label of materials are missing ([d99727a](https://gitlab.com/roomle/web/roomle-ui/commit/d99727ab3d3bb58bb50a3ade8eb6cda4dc3e4a75))
|
|
24
|
+
* hide archived items in MOC ([fd8a57b](https://gitlab.com/roomle/web/roomle-ui/commit/fd8a57ba849fd2acc706669ebebb17ca5319cfd0))
|
|
25
|
+
* Partlist container doesn't have close icon on Rubens ([a010523](https://gitlab.com/roomle/web/roomle-ui/commit/a010523edc027a70140457af9ddd2bead213bda2))
|
|
26
|
+
* Partlist is not shown when the interaction container is collapsed ([de8a985](https://gitlab.com/roomle/web/roomle-ui/commit/de8a985e95840a162f4d90ecbc54bb866af151a0))
|
|
27
|
+
* set correct callback to enable undo and redo in MOC ([22b66ba](https://gitlab.com/roomle/web/roomle-ui/commit/22b66ba30f65925d5fde68db032762e72ad11286))
|
|
28
|
+
* show the correct bottom bar label for both, moc and configurator ([ffa6c33](https://gitlab.com/roomle/web/roomle-ui/commit/ffa6c33d69f860a828f5685ad8ab4754d9265245))
|
|
29
|
+
* update roomle-configurator-api for getting "createConfigurator" ([b725966](https://gitlab.com/roomle/web/roomle-ui/commit/b725966fefb8e04cee81b0a4f09332d3e8e03c5b))
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roomle/embedding-lib",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.39.0",
|
|
4
4
|
"main": "roomle-configurator-api.es.min.js",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
6
|
"author": "Roomle Development",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@roomle/web-sdk": "2.
|
|
8
|
+
"@roomle/web-sdk": "2.36.0-alpha.3"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@semantic-release/changelog": "^5.0.1",
|
package/types/index.d.ts
CHANGED
|
@@ -534,11 +534,13 @@ declare module "common/store/collection-view-state" {
|
|
|
534
534
|
import { Nullable } from "common/utils/types";
|
|
535
535
|
import { CollectionViewElement } from "common/components/collection-view/-utils/types";
|
|
536
536
|
import { StoreState } from "common/store/index";
|
|
537
|
+
export type ViewTypeState = 'listView' | 'gridViewSmall' | 'gridViewBig';
|
|
537
538
|
export interface GridViewUiState {
|
|
538
539
|
filter: string[];
|
|
539
|
-
showAllAsList: boolean;
|
|
540
540
|
search: Nullable<string>;
|
|
541
541
|
userInitiatedSearch: boolean;
|
|
542
|
+
viewType: ViewTypeState;
|
|
543
|
+
hasGroupLabel: boolean;
|
|
542
544
|
}
|
|
543
545
|
export interface CollectionViewUiState {
|
|
544
546
|
selected: Nullable<CollectionViewElement>;
|
|
@@ -546,6 +548,7 @@ declare module "common/store/collection-view-state" {
|
|
|
546
548
|
gridView: GridViewUiState;
|
|
547
549
|
}
|
|
548
550
|
export const getInitialCollectionViewState: () => CollectionViewUiState;
|
|
551
|
+
export const getInitialViewType: () => ViewTypeState;
|
|
549
552
|
export enum COLLECTION_VIEW_STATE_MUTATIONS {
|
|
550
553
|
ELEMENT_EXPANDED = "CV_ELEMENT_EXPANDED",
|
|
551
554
|
SET_SELECTED_ELEMENT = "CV_SET_SELECTED_ELEMENT",
|
|
@@ -553,9 +556,10 @@ declare module "common/store/collection-view-state" {
|
|
|
553
556
|
}
|
|
554
557
|
export enum GRID_VIEW_STATE_MUTATIONS {
|
|
555
558
|
SET_SEARCH = "GV_SET_SEARCH",
|
|
556
|
-
TOGGLE_LIST_DISPLAY_TYPE = "GV_TOGGLE_LIST_DISPLAY_TYPE",
|
|
557
559
|
TOGGLE_FILTER = "GV_TOGGLE_FILTER",
|
|
558
|
-
SET_USER_INITIATED_SEARCH = "GV_SET_USER_INITIATED_SEARCH"
|
|
560
|
+
SET_USER_INITIATED_SEARCH = "GV_SET_USER_INITIATED_SEARCH",
|
|
561
|
+
SET_VIEW_TYPE = "SET_VIEW_TYPE",
|
|
562
|
+
SET_HAS_GROUP_LABEL = "SET_HAS_GROUP_LABEL"
|
|
559
563
|
}
|
|
560
564
|
interface MuationPayload<T, V> {
|
|
561
565
|
state: T;
|
|
@@ -2,11 +2,13 @@ import { Module } from 'vuex';
|
|
|
2
2
|
import { Nullable } from '@/common/utils/types';
|
|
3
3
|
import { CollectionViewElement } from '@/common/components/collection-view/-utils/types';
|
|
4
4
|
import { StoreState } from '@/common/store';
|
|
5
|
+
export declare type ViewTypeState = 'listView' | 'gridViewSmall' | 'gridViewBig';
|
|
5
6
|
export interface GridViewUiState {
|
|
6
7
|
filter: string[];
|
|
7
|
-
showAllAsList: boolean;
|
|
8
8
|
search: Nullable<string>;
|
|
9
9
|
userInitiatedSearch: boolean;
|
|
10
|
+
viewType: ViewTypeState;
|
|
11
|
+
hasGroupLabel: boolean;
|
|
10
12
|
}
|
|
11
13
|
export interface CollectionViewUiState {
|
|
12
14
|
selected: Nullable<CollectionViewElement>;
|
|
@@ -14,6 +16,7 @@ export interface CollectionViewUiState {
|
|
|
14
16
|
gridView: GridViewUiState;
|
|
15
17
|
}
|
|
16
18
|
export declare const getInitialCollectionViewState: () => CollectionViewUiState;
|
|
19
|
+
export declare const getInitialViewType: () => ViewTypeState;
|
|
17
20
|
export declare enum COLLECTION_VIEW_STATE_MUTATIONS {
|
|
18
21
|
ELEMENT_EXPANDED = "CV_ELEMENT_EXPANDED",
|
|
19
22
|
SET_SELECTED_ELEMENT = "CV_SET_SELECTED_ELEMENT",
|
|
@@ -21,9 +24,10 @@ export declare enum COLLECTION_VIEW_STATE_MUTATIONS {
|
|
|
21
24
|
}
|
|
22
25
|
export declare enum GRID_VIEW_STATE_MUTATIONS {
|
|
23
26
|
SET_SEARCH = "GV_SET_SEARCH",
|
|
24
|
-
TOGGLE_LIST_DISPLAY_TYPE = "GV_TOGGLE_LIST_DISPLAY_TYPE",
|
|
25
27
|
TOGGLE_FILTER = "GV_TOGGLE_FILTER",
|
|
26
|
-
SET_USER_INITIATED_SEARCH = "GV_SET_USER_INITIATED_SEARCH"
|
|
28
|
+
SET_USER_INITIATED_SEARCH = "GV_SET_USER_INITIATED_SEARCH",
|
|
29
|
+
SET_VIEW_TYPE = "SET_VIEW_TYPE",
|
|
30
|
+
SET_HAS_GROUP_LABEL = "SET_HAS_GROUP_LABEL"
|
|
27
31
|
}
|
|
28
32
|
interface MuationPayload<T, V> {
|
|
29
33
|
state: T;
|