@one-commerce/sdk-backoffice-vue3 1.12.0-alpha.0 → 1.14.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.
@@ -203,6 +203,18 @@ class BackofficeLayout extends BaseCallClass {
203
203
  _defineProperty$2(this, "isAsideOpened", void 0);
204
204
  }
205
205
 
206
+ }
207
+ class BackofficeAuthorization extends BaseCallClass {
208
+ constructor(...args) {
209
+ super(...args);
210
+
211
+ _defineProperty$2(this, "serviceName", 'authorization');
212
+ }
213
+
214
+ getAuthToken() {
215
+ return this.call('getAuthToken');
216
+ }
217
+
206
218
  }
207
219
 
208
220
  function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -280,6 +292,8 @@ class Sdk extends Events {
280
292
 
281
293
  _defineProperty(this, "autoheight", true);
282
294
 
295
+ _defineProperty(this, "heightMutationObserver", null);
296
+
283
297
  _defineProperty(this, "origin", void 0);
284
298
 
285
299
  _defineProperty(this, "isInitialized", false);
@@ -318,19 +332,50 @@ class Sdk extends Events {
318
332
  this.channel.subscribe(main.Message.FRAME_HEIGHT_REQUEST, payload => {
319
333
  if (this.autoheight) {
320
334
  Sdk.log('Request for iframe height');
321
- const body = document.body,
322
- html = document.documentElement;
323
- const height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
324
- this.channel.postMessage(main.Message.FRAME_HEIGHT_CHANGE, height);
335
+ this.sendFrameHeight();
325
336
  }
326
337
  });
327
338
  this.channel.connect().then(() => {
328
339
  Sdk.log('Connected with ONe SDK');
340
+
341
+ if (this.autoheight) {
342
+ this.initializeHeightObserver();
343
+ }
329
344
  });
330
345
  this.setupOptions(options);
331
346
  Sdk.log('Initialized.');
332
347
  }
333
348
 
349
+ sendFrameHeight() {
350
+ const body = document.body,
351
+ html = document.documentElement;
352
+ const height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
353
+ this.channel.postMessage(main.Message.FRAME_HEIGHT_CHANGE, height);
354
+ }
355
+
356
+ initializeHeightObserver() {
357
+ if ("MutationObserver" in window) {
358
+ const onMutationObserved = () => {
359
+ this.sendFrameHeight();
360
+ };
361
+
362
+ const target = document.querySelector('body'),
363
+ config = {
364
+ attributes: true,
365
+ attributeOldValue: false,
366
+ characterData: true,
367
+ characterDataOldValue: false,
368
+ childList: true,
369
+ subtree: true
370
+ };
371
+ this.heightMutationObserver = new MutationObserver(onMutationObserved);
372
+ Sdk.log('Create body MutationObserver');
373
+ this.heightMutationObserver.observe(target, config);
374
+ } else {
375
+ Sdk.warn('MutationObserver not available. Auto-height functionality disabled.');
376
+ }
377
+ }
378
+
334
379
  setupOptions(options) {
335
380
  if (options) {
336
381
  if (typeof options.debug !== 'undefined') {
@@ -391,7 +436,8 @@ class BackofficeSdk extends Sdk {
391
436
  catalog: new BackofficeCatalog(this.callFunction.bind(this)),
392
437
  user: new BackofficeUser(this.callFunction.bind(this)),
393
438
  tenant: new BackofficeTenant(this.callFunction.bind(this)),
394
- layout: new BackofficeLayout(this.callFunction.bind(this))
439
+ layout: new BackofficeLayout(this.callFunction.bind(this)),
440
+ authorization: new BackofficeAuthorization(this.callFunction.bind(this))
395
441
  });
396
442
  }
397
443
 
@@ -429,6 +475,7 @@ var index = {
429
475
  obj.layout.update(payload);
430
476
  obj.catalog.update(payload);
431
477
  obj.orderpath.update(payload);
478
+ obj.authorization.update(payload);
432
479
  };
433
480
 
434
481
  sdk.on(SdkEvents.INIT, function (payload) {