@luzmo/embed 8.0.0-es2021 → 8.1.0-es2021

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/index.rn.js CHANGED
@@ -362,41 +362,46 @@ var createIframeUrl = (dashboardContent) => {
362
362
  // libs/embed-libs/embed/src/lib/shared/helpers/get-loader.ts
363
363
  var getLoader = (dashboardComponent) => {
364
364
  let errorMsg;
365
- if (dashboardComponent.params.error || dashboardComponent.browserNotSupported.length > 0) {
366
- dashboardComponent.params.error = true;
365
+ if (dashboardComponent.params?.error || (dashboardComponent.browserNotSupported?.length ?? 0) > 0) {
366
+ if (dashboardComponent.params) {
367
+ dashboardComponent.params.error = true;
368
+ }
367
369
  if (dashboardComponent.browserNotSupported) {
368
370
  errorMsg = "Browser is not supported.";
369
371
  }
370
372
  }
371
- const loadingMsg = translations_default.initializing[dashboardComponent.params.language] || translations_default.initializing.en;
372
- return dashboardComponent.browserNotSupported || dashboardComponent.params.error ? { loadingMsg, errorMsg } : { loadingMsg, errorMsg: "" };
373
+ const language = dashboardComponent.params?.language;
374
+ const loadingMsg = (language ? translations_default.initializing[language] : void 0) || translations_default.initializing.en;
375
+ return dashboardComponent.browserNotSupported || dashboardComponent.params?.error ? { loadingMsg, errorMsg } : { loadingMsg, errorMsg: "" };
373
376
  };
374
377
 
375
378
  // libs/embed-libs/embed/src/lib/shared/helpers/promise-dispatch.ts
376
379
  function resolvePromise(dashboardComponent, requestId, data) {
377
- if (dashboardComponent.promises[requestId]) {
378
- dashboardComponent.promises[requestId].resolve(data);
379
- delete dashboardComponent.promises[requestId];
380
+ const promises = dashboardComponent.promises;
381
+ if (promises?.[requestId]) {
382
+ promises[requestId].resolve(data);
383
+ delete promises[requestId];
380
384
  }
381
385
  }
382
386
  function rejectPromise(dashboardComponent, requestId, data) {
383
- if (dashboardComponent.promises[requestId]) {
384
- dashboardComponent.promises[requestId].reject(data);
385
- delete dashboardComponent.promises[requestId];
387
+ const promises = dashboardComponent.promises;
388
+ if (promises?.[requestId]) {
389
+ promises[requestId].reject(data);
390
+ delete promises[requestId];
386
391
  }
387
392
  }
388
393
 
389
394
  // libs/embed-libs/embed/src/lib/shared/helpers/styles.ts
390
395
  function containerStyles(dashboardComponent) {
391
396
  const styles = {};
392
- if (dashboardComponent.params.loaderBackground && !dashboardComponent.iframeLoaded) {
397
+ if (dashboardComponent.params?.loaderBackground && !dashboardComponent.iframeLoaded) {
393
398
  styles.background = dashboardComponent.params.loaderBackground;
394
399
  }
395
400
  return styles;
396
401
  }
397
402
  function containerLoaderStyles(dashboardComponent) {
398
- const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
399
- const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
403
+ const height = dashboardComponent.params?.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
404
+ const chartHeightDefined = dashboardComponent.params?.itemEmbedding && height !== "auto";
400
405
  const display = dashboardComponent.iframeLoaded ? "none" : "";
401
406
  return {
402
407
  display,
@@ -404,8 +409,8 @@ function containerLoaderStyles(dashboardComponent) {
404
409
  };
405
410
  }
406
411
  function loaderStyles(dashboardComponent) {
407
- const background = dashboardComponent.params.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
408
- if (dashboardComponent.params.itemEmbedding) {
412
+ const background = dashboardComponent.params?.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
413
+ if (dashboardComponent.params?.itemEmbedding) {
409
414
  dashboardComponent.loaderSize = 24;
410
415
  dashboardComponent.borderWidth = 4;
411
416
  dashboardComponent.minHeight = 200;
@@ -434,11 +439,11 @@ function plStyles(dashboardComponent) {
434
439
  } = DEFAULT_PARAMETERS;
435
440
  const spinnerColorBorder = generateBorderStyle(
436
441
  dashboardComponent.borderWidth,
437
- dashboardComponent.params.loaderSpinnerColor || defaultSpinnerColor
442
+ dashboardComponent.params?.loaderSpinnerColor || defaultSpinnerColor
438
443
  );
439
444
  const spinnerBackgroundBorder = generateBorderStyle(
440
445
  dashboardComponent.borderWidth,
441
- dashboardComponent.params.loaderSpinnerBackground || defaultSpinnerBackground
446
+ dashboardComponent.params?.loaderSpinnerBackground || defaultSpinnerBackground
442
447
  );
443
448
  const size = `${dashboardComponent.loaderSize}px`;
444
449
  return {
@@ -451,27 +456,28 @@ function plStyles(dashboardComponent) {
451
456
  };
452
457
  }
453
458
  function lcStyles(dashboardComponent) {
454
- const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
455
- const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
456
- const getPaddingStr = (value) => `${(value - dashboardComponent.loaderSize - 32) / 2}px`;
457
- const verticalPadding = dashboardComponent.params.itemId ? chartHeightDefined ? getPaddingStr(Number.parseInt(`${height}`, 10)) : getPaddingStr(dashboardComponent.minHeight) : "128px";
459
+ const height = dashboardComponent.params?.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
460
+ const chartHeightDefined = dashboardComponent.params?.itemEmbedding && height !== "auto";
461
+ const getPaddingStr = (value) => `${((value ?? Number.NaN) - (dashboardComponent.loaderSize ?? Number.NaN) - 32) / 2}px`;
462
+ const verticalPadding = dashboardComponent.params?.itemId ? chartHeightDefined ? getPaddingStr(Number.parseInt(`${height}`, 10)) : getPaddingStr(dashboardComponent.minHeight) : "128px";
458
463
  return {
459
464
  padding: `${verticalPadding} 16px`
460
465
  };
461
466
  }
462
467
  function calculateIframeStyles(dashboardComponent) {
463
- const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
464
- const width = dashboardComponent.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
465
- if (dashboardComponent.params.itemEmbedding && height !== "auto") {
468
+ const height = dashboardComponent.params?.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
469
+ const width = dashboardComponent.params?.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
470
+ const editMode = dashboardComponent.params?.editMode;
471
+ if (dashboardComponent.params?.itemEmbedding && height !== "auto") {
466
472
  dashboardComponent.iframeHeight = `${height}px`;
467
- } else if (dashboardComponent.params.itemEmbedding) {
473
+ } else if (dashboardComponent.params?.itemEmbedding) {
468
474
  dashboardComponent.iframeHeight = "200px";
469
- } else if (["editFull", "editLimited"].includes(dashboardComponent.params.editMode)) {
475
+ } else if (editMode != null && ["editFull", "editLimited"].includes(editMode)) {
470
476
  dashboardComponent.iframeHeight = "100%";
471
477
  } else {
472
478
  dashboardComponent.iframeHeight = "400px";
473
479
  }
474
- dashboardComponent.iframeWidth = dashboardComponent.params.itemEmbedding && width !== "auto" ? `${width}px` : "100%";
480
+ dashboardComponent.iframeWidth = dashboardComponent.params?.itemEmbedding && width !== "auto" ? `${width}px` : "100%";
475
481
  const styles = {
476
482
  height: dashboardComponent.iframeHeight,
477
483
  width: dashboardComponent.iframeWidth
@@ -490,7 +496,7 @@ function calculateIframeStyles(dashboardComponent) {
490
496
 
491
497
  // libs/embed-libs/embed/src/lib/shared/helpers/update-iframe-url.ts
492
498
  var updateIframeUrl = (iframe, iframeUrl) => {
493
- if (iframe?.contentWindow) {
499
+ if (iframe?.contentWindow && iframeUrl !== void 0) {
494
500
  iframe.contentWindow.location.replace(iframeUrl);
495
501
  }
496
502
  };
@@ -499,7 +505,7 @@ var updateIframeUrl = (iframe, iframeUrl) => {
499
505
  var selectedDataUtils = {
500
506
  merge(...filters) {
501
507
  return filters.reduce((acc, filter) => {
502
- acc.and.push(...filter.and);
508
+ (acc.and ??= []).push(...filter.and ?? []);
503
509
  return acc;
504
510
  }, {
505
511
  and: []
@@ -562,43 +568,46 @@ var selectedDataUtils = {
562
568
  // libs/embed-libs/embed/src/lib/shared/methods/export-dashboard.ts
563
569
  var exportDashboard = (dashboardComponent, iframe, format) => {
564
570
  const requestId = uuidv4();
565
- if (iframe?.contentWindow) {
566
- iframe.contentWindow.postMessage(
567
- {
568
- action: "exportDashboard",
569
- format: format || "png",
570
- _version: dashboardComponent.libVersion,
571
- requestId
572
- },
573
- "*"
574
- );
575
- return new Promise((resolve, reject) => {
576
- dashboardComponent.promises[requestId] = { resolve, reject };
577
- setTimeout(() => {
578
- if (dashboardComponent.promises[requestId]) {
579
- const errorMessage = "exportDashboard request timed out.";
580
- dashboardComponent.promises[requestId].reject(
581
- new Error(errorMessage)
582
- );
583
- delete dashboardComponent.promises[requestId];
584
- }
585
- }, 12e5);
586
- });
571
+ if (!iframe?.contentWindow) {
572
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
587
573
  }
588
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
574
+ const { promises } = dashboardComponent;
575
+ if (!promises) {
576
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
577
+ }
578
+ iframe.contentWindow.postMessage(
579
+ {
580
+ action: "exportDashboard",
581
+ format: format || "png",
582
+ _version: dashboardComponent.libVersion,
583
+ requestId
584
+ },
585
+ "*"
586
+ );
587
+ return new Promise((resolve, reject) => {
588
+ promises[requestId] = { resolve, reject };
589
+ setTimeout(() => {
590
+ if (promises[requestId]) {
591
+ const errorMessage = "exportDashboard request timed out.";
592
+ promises[requestId].reject(new Error(errorMessage));
593
+ delete promises[requestId];
594
+ }
595
+ }, 12e5);
596
+ });
589
597
  };
590
598
 
591
599
  // libs/embed-libs/embed/src/lib/shared/methods/get-accessible-dashboards.ts
592
600
  var getAccessibleDashboards = async (dashboardComponent) => {
593
601
  await dashboardComponent.updateComplete;
594
- if ((dashboardComponent.currentAuthKey ?? dashboardComponent.authKey) && (dashboardComponent.currentAuthToken ?? dashboardComponent.authToken)) {
602
+ if ((dashboardComponent.currentAuthKey ?? dashboardComponent.authKey) && (dashboardComponent.currentAuthToken ?? dashboardComponent.authToken) && dashboardComponent.params) {
603
+ const { params } = dashboardComponent;
595
604
  const fetchUser = new Promise((resolve, reject) => {
596
605
  void (() => {
597
606
  try {
598
607
  const responsePromise = window.fetch(
599
608
  // With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
600
609
  // Fixes incorrect url with embedMode="webComponent"
601
- `${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/authorization`,
610
+ `${addTrailingSlash(params.apiHost)}0.1.0/authorization`,
602
611
  {
603
612
  method: "POST",
604
613
  mode: "cors",
@@ -643,136 +652,144 @@ var getAccessibleDashboards = async (dashboardComponent) => {
643
652
  }
644
653
  })();
645
654
  });
646
- return new Promise((resolve, reject) => void (() => {
647
- try {
648
- fetchUser.then((authorizationData) => {
649
- const responsePromise = window.fetch(
650
- // With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
651
- // Fixes incorrect url with embedMode="webComponent"
652
- `${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/securable`,
653
- {
654
- method: "POST",
655
- mode: "cors",
656
- cache: "no-cache",
657
- headers: { "Content-Type": "application/json" },
658
- redirect: "follow",
659
- body: JSON.stringify({
660
- action: "get",
661
- version: "0.1.0",
662
- key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
663
- token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
664
- find: {
665
- where: { type: "dashboard", is_variant: false },
666
- attributes: ["id", "name", "modified_at"],
667
- order: [["modified_at", "desc"]],
668
- include: [
669
- { model: "Tag", attributes: ["tag"] },
670
- { model: "User", attributes: ["id", "name"] },
671
- {
672
- model: "Group",
673
- attributes: ["id", "name", "public"]
674
- },
675
- { model: "Integration", attributes: ["id", "name"] }
676
- ]
677
- }
678
- })
679
- }
680
- );
681
- responsePromise.then((response) => response.json()).then((data) => {
682
- const dashboardList = data.rows.length > 0 ? formatDashboardList(
683
- data.rows,
684
- authorizationData.integrationId,
685
- authorizationData.user,
686
- dashboardComponent
687
- ) : [];
688
- resolve(dashboardList);
655
+ return new Promise((resolve, reject) => {
656
+ void (() => {
657
+ try {
658
+ fetchUser.then((authorizationData) => {
659
+ const responsePromise = window.fetch(
660
+ // With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
661
+ // Fixes incorrect url with embedMode="webComponent"
662
+ `${addTrailingSlash(params.apiHost)}0.1.0/securable`,
663
+ {
664
+ method: "POST",
665
+ mode: "cors",
666
+ cache: "no-cache",
667
+ headers: { "Content-Type": "application/json" },
668
+ redirect: "follow",
669
+ body: JSON.stringify({
670
+ action: "get",
671
+ version: "0.1.0",
672
+ key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
673
+ token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
674
+ find: {
675
+ where: { type: "dashboard", is_variant: false },
676
+ attributes: ["id", "name", "modified_at"],
677
+ order: [["modified_at", "desc"]],
678
+ include: [
679
+ { model: "Tag", attributes: ["tag"] },
680
+ { model: "User", attributes: ["id", "name"] },
681
+ {
682
+ model: "Group",
683
+ attributes: ["id", "name", "public"]
684
+ },
685
+ { model: "Integration", attributes: ["id", "name"] }
686
+ ]
687
+ }
688
+ })
689
+ }
690
+ );
691
+ responsePromise.then((response) => response.json()).then((data) => {
692
+ const dashboardList = data.rows.length > 0 ? formatDashboardList(
693
+ data.rows,
694
+ authorizationData.integrationId,
695
+ authorizationData.user,
696
+ dashboardComponent
697
+ ) : [];
698
+ resolve(dashboardList);
699
+ });
700
+ }).catch((error) => {
701
+ reject(error);
689
702
  });
690
- }).catch((error) => {
703
+ } catch (error) {
691
704
  reject(error);
692
- });
693
- } catch (error) {
694
- reject(error);
695
- }
696
- })());
705
+ }
706
+ })();
707
+ });
697
708
  }
698
709
  throw new Error("No authKey or authToken found in the luzmo-dashboard component.");
699
710
  };
700
711
 
701
712
  // libs/embed-libs/embed/src/lib/shared/methods/get-dashboard-context.ts
702
713
  var getDashboardContext = (dashboardComponent, iframe) => {
703
- if (iframe?.contentWindow) {
704
- const requestId = uuidv4();
705
- iframe.contentWindow.postMessage(
706
- { action: "getDashboardContext", _version: dashboardComponent.libVersion, requestId },
707
- "*"
708
- );
709
- return new Promise((resolve, reject) => {
710
- dashboardComponent.promises[requestId] = { resolve, reject };
711
- setTimeout(() => {
712
- if (dashboardComponent.promises[requestId]) {
713
- const errorMessage = "getDashboardContext request timed out.";
714
- dashboardComponent.promises[requestId].reject(
715
- new Error(errorMessage)
716
- );
717
- delete dashboardComponent.promises[requestId];
718
- }
719
- }, 2e3);
720
- });
714
+ if (!iframe?.contentWindow) {
715
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
721
716
  }
722
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
717
+ const { promises } = dashboardComponent;
718
+ if (!promises) {
719
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
720
+ }
721
+ const requestId = uuidv4();
722
+ iframe.contentWindow.postMessage(
723
+ { action: "getDashboardContext", _version: dashboardComponent.libVersion, requestId },
724
+ "*"
725
+ );
726
+ return new Promise((resolve, reject) => {
727
+ promises[requestId] = { resolve, reject };
728
+ setTimeout(() => {
729
+ if (promises[requestId]) {
730
+ const errorMessage = "getDashboardContext request timed out.";
731
+ promises[requestId].reject(new Error(errorMessage));
732
+ delete promises[requestId];
733
+ }
734
+ }, 2e3);
735
+ });
723
736
  };
724
737
 
725
738
  // libs/embed-libs/embed/src/lib/shared/methods/get-data.ts
726
739
  var getData = (dashboardComponent, iframe, itemId) => {
727
- if (iframe?.contentWindow) {
728
- const requestId = uuidv4();
729
- iframe.contentWindow.postMessage(
730
- {
731
- action: "getData",
732
- id: itemId,
733
- _version: dashboardComponent.libVersion,
734
- requestId
735
- },
736
- "*"
737
- );
738
- return new Promise((resolve, reject) => {
739
- dashboardComponent.promises[requestId] = { resolve, reject };
740
- setTimeout(() => {
741
- if (dashboardComponent.promises[requestId]) {
742
- const errorMessage = "getData request timed out.";
743
- dashboardComponent.promises[requestId].reject(
744
- new Error(errorMessage)
745
- );
746
- delete dashboardComponent.promises[requestId];
747
- }
748
- }, 2e3);
749
- });
740
+ if (!iframe?.contentWindow) {
741
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
750
742
  }
751
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
743
+ const { promises } = dashboardComponent;
744
+ if (!promises) {
745
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
746
+ }
747
+ const requestId = uuidv4();
748
+ iframe.contentWindow.postMessage(
749
+ {
750
+ action: "getData",
751
+ id: itemId,
752
+ _version: dashboardComponent.libVersion,
753
+ requestId
754
+ },
755
+ "*"
756
+ );
757
+ return new Promise((resolve, reject) => {
758
+ promises[requestId] = { resolve, reject };
759
+ setTimeout(() => {
760
+ if (promises[requestId]) {
761
+ const errorMessage = "getData request timed out.";
762
+ promises[requestId].reject(new Error(errorMessage));
763
+ delete promises[requestId];
764
+ }
765
+ }, 2e3);
766
+ });
752
767
  };
753
768
 
754
769
  // libs/embed-libs/embed/src/lib/shared/methods/get-filters.ts
755
770
  var getFilters = (dashboardComponent, iframe) => {
756
- if (iframe?.contentWindow) {
757
- const requestId = uuidv4();
758
- iframe.contentWindow.postMessage(
759
- { action: "getFilters", _version: dashboardComponent.libVersion, requestId },
760
- "*"
761
- );
762
- return new Promise((resolve, reject) => {
763
- dashboardComponent.promises[requestId] = { resolve, reject };
764
- setTimeout(() => {
765
- if (dashboardComponent.promises[requestId]) {
766
- const errorMessage = "getFilters request timed out.";
767
- dashboardComponent.promises[requestId].reject(
768
- new Error(errorMessage)
769
- );
770
- delete dashboardComponent.promises[requestId];
771
- }
772
- }, 2e3);
773
- });
771
+ if (!iframe?.contentWindow) {
772
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
774
773
  }
775
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
774
+ const { promises } = dashboardComponent;
775
+ if (!promises) {
776
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
777
+ }
778
+ const requestId = uuidv4();
779
+ iframe.contentWindow.postMessage(
780
+ { action: "getFilters", _version: dashboardComponent.libVersion, requestId },
781
+ "*"
782
+ );
783
+ return new Promise((resolve, reject) => {
784
+ promises[requestId] = { resolve, reject };
785
+ setTimeout(() => {
786
+ if (promises[requestId]) {
787
+ const errorMessage = "getFilters request timed out.";
788
+ promises[requestId].reject(new Error(errorMessage));
789
+ delete promises[requestId];
790
+ }
791
+ }, 2e3);
792
+ });
776
793
  };
777
794
 
778
795
  // libs/embed-libs/embed/src/lib/shared/methods/get-insights.ts
@@ -780,6 +797,10 @@ var getInsights = (dashboardComponent, iframe, options = {}) => {
780
797
  if (!iframe?.contentWindow) {
781
798
  return Promise.reject(new Error("Cannot retrieve contentWindow."));
782
799
  }
800
+ const { promises } = dashboardComponent;
801
+ if (!promises) {
802
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
803
+ }
783
804
  const requestId = uuidv4();
784
805
  iframe.contentWindow.postMessage(
785
806
  {
@@ -791,11 +812,11 @@ var getInsights = (dashboardComponent, iframe, options = {}) => {
791
812
  "*"
792
813
  );
793
814
  return new Promise((resolve, reject) => {
794
- dashboardComponent.promises[requestId] = { resolve, reject };
815
+ promises[requestId] = { resolve, reject };
795
816
  setTimeout(() => {
796
- if (dashboardComponent.promises[requestId]) {
797
- dashboardComponent.promises[requestId].reject(new Error("getInsights request timed out."));
798
- delete dashboardComponent.promises[requestId];
817
+ if (promises[requestId]) {
818
+ promises[requestId].reject(new Error("getInsights request timed out."));
819
+ delete promises[requestId];
799
820
  }
800
821
  }, 6e4);
801
822
  });
@@ -803,7 +824,7 @@ var getInsights = (dashboardComponent, iframe, options = {}) => {
803
824
 
804
825
  // libs/embed-libs/embed/src/lib/shared/methods/refresh-data.ts
805
826
  var refreshData = (dashboardComponent, iframe, itemId) => {
806
- if (iframe) {
827
+ if (iframe?.contentWindow) {
807
828
  iframe.contentWindow.postMessage(
808
829
  {
809
830
  action: "refreshData",
@@ -819,7 +840,7 @@ var refreshData = (dashboardComponent, iframe, itemId) => {
819
840
 
820
841
  // libs/embed-libs/embed/src/lib/shared/methods/reload-dashboard.ts
821
842
  var reloadDashboard = (dashboardComponent, iframe) => {
822
- if (iframe) {
843
+ if (iframe?.contentWindow) {
823
844
  iframe.contentWindow.postMessage(
824
845
  { action: "reloadDashboard", _version: dashboardComponent.libVersion },
825
846
  "*"
@@ -831,7 +852,7 @@ var reloadDashboard = (dashboardComponent, iframe) => {
831
852
 
832
853
  // libs/embed-libs/embed/src/lib/shared/methods/send-export-email.ts
833
854
  var sendExportEmail = (dashboardComponent, iframe, type, subject, message) => {
834
- if (iframe) {
855
+ if (iframe?.contentWindow) {
835
856
  iframe.contentWindow.postMessage(
836
857
  {
837
858
  action: "sendExportEmail",
@@ -849,7 +870,7 @@ var sendExportEmail = (dashboardComponent, iframe, type, subject, message) => {
849
870
 
850
871
  // libs/embed-libs/embed/src/lib/shared/methods/set-authorization.ts
851
872
  var setAuthorization = (dashboardComponent, iframe, key, token) => {
852
- if (iframe) {
873
+ if (iframe?.contentWindow) {
853
874
  iframe.contentWindow.postMessage(
854
875
  {
855
876
  action: "setAuthorization",
@@ -866,92 +887,100 @@ var setAuthorization = (dashboardComponent, iframe, key, token) => {
866
887
 
867
888
  // libs/embed-libs/embed/src/lib/shared/methods/set-edit-mode.ts
868
889
  var setEditMode = (dashboardComponent, iframe, editMode) => {
869
- if (iframe && iframe.contentWindow) {
870
- const requestId = uuidv4();
871
- if (dashboardComponent.params.editMode === editMode) {
872
- return Promise.reject(
873
- new Error("editMode parameter is currently already set to " + editMode)
874
- );
875
- } else if (editMode !== "editFull" && editMode !== "editLimited" && editMode !== "view") {
876
- return Promise.reject(
877
- new Error(
878
- "The editMode parameter must be one of the following values: 'editFull', 'editLimited' or 'view'."
879
- )
880
- );
881
- }
882
- iframe.contentWindow.postMessage(
883
- {
884
- action: "setEditMode",
885
- editMode,
886
- _version: dashboardComponent.libVersion,
887
- requestId
888
- },
889
- "*"
890
+ if (!iframe?.contentWindow) {
891
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
892
+ }
893
+ const { params, promises } = dashboardComponent;
894
+ if (!params || !promises) {
895
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
896
+ }
897
+ const requestId = uuidv4();
898
+ if (params.editMode === editMode) {
899
+ return Promise.reject(
900
+ new Error("editMode parameter is currently already set to " + editMode)
901
+ );
902
+ } else if (editMode !== "editFull" && editMode !== "editLimited" && editMode !== "view") {
903
+ return Promise.reject(
904
+ new Error(
905
+ "The editMode parameter must be one of the following values: 'editFull', 'editLimited' or 'view'."
906
+ )
890
907
  );
891
- return new Promise((resolve, reject) => {
892
- dashboardComponent.promises[requestId] = { resolve, reject };
893
- });
894
908
  }
895
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
909
+ iframe.contentWindow.postMessage(
910
+ {
911
+ action: "setEditMode",
912
+ editMode,
913
+ _version: dashboardComponent.libVersion,
914
+ requestId
915
+ },
916
+ "*"
917
+ );
918
+ return new Promise((resolve, reject) => {
919
+ promises[requestId] = { resolve, reject };
920
+ });
896
921
  };
897
922
 
898
923
  // libs/embed-libs/embed/src/lib/shared/methods/set-preview.ts
899
924
  var setPreview = (dashboardComponent, iframe, preview) => {
900
- if (iframe) {
901
- const requestId = uuidv4();
902
- iframe.contentWindow.postMessage(
903
- {
904
- action: "setPreview",
905
- preview,
906
- requestId,
907
- _version: dashboardComponent.libVersion
908
- },
909
- "*"
910
- );
911
- return new Promise((resolve, reject) => {
912
- dashboardComponent.promises[requestId] = { resolve, reject };
913
- setTimeout(() => {
914
- if (dashboardComponent.promises[requestId]) {
915
- const errorMessage = "setPreview request timed out.";
916
- dashboardComponent.promises[requestId].reject(
917
- new Error(errorMessage)
918
- );
919
- delete dashboardComponent.promises[requestId];
920
- }
921
- }, 2e3);
922
- });
925
+ if (!iframe?.contentWindow) {
926
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
923
927
  }
924
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
928
+ const { promises } = dashboardComponent;
929
+ if (!promises) {
930
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
931
+ }
932
+ const requestId = uuidv4();
933
+ iframe.contentWindow.postMessage(
934
+ {
935
+ action: "setPreview",
936
+ preview,
937
+ requestId,
938
+ _version: dashboardComponent.libVersion
939
+ },
940
+ "*"
941
+ );
942
+ return new Promise((resolve, reject) => {
943
+ promises[requestId] = { resolve, reject };
944
+ setTimeout(() => {
945
+ if (promises[requestId]) {
946
+ const errorMessage = "setPreview request timed out.";
947
+ promises[requestId].reject(new Error(errorMessage));
948
+ delete promises[requestId];
949
+ }
950
+ }, 2e3);
951
+ });
925
952
  };
926
953
 
927
954
  // libs/embed-libs/embed/src/lib/shared/methods/set-selected-data.ts
928
955
  var setSelectedData = (dashboardComponent, iframe, itemId, filters) => {
929
- if (iframe) {
930
- const requestId = uuidv4();
931
- iframe.contentWindow.postMessage(
932
- {
933
- action: "setSelectedData",
934
- itemId,
935
- filters,
936
- _version: dashboardComponent.libVersion,
937
- requestId
938
- },
939
- "*"
940
- );
941
- return new Promise((resolve, reject) => {
942
- dashboardComponent.promises[requestId] = { resolve, reject };
943
- setTimeout(() => {
944
- if (dashboardComponent.promises[requestId]) {
945
- const errorMessage = "setSelectedData request timed out.";
946
- dashboardComponent.promises[requestId].reject(
947
- new Error(errorMessage)
948
- );
949
- delete dashboardComponent.promises[requestId];
950
- }
951
- }, 2e3);
952
- });
956
+ if (!iframe?.contentWindow) {
957
+ return Promise.reject();
958
+ }
959
+ const { promises } = dashboardComponent;
960
+ if (!promises) {
961
+ return Promise.reject();
953
962
  }
954
- return Promise.reject();
963
+ const requestId = uuidv4();
964
+ iframe.contentWindow.postMessage(
965
+ {
966
+ action: "setSelectedData",
967
+ itemId,
968
+ filters,
969
+ _version: dashboardComponent.libVersion,
970
+ requestId
971
+ },
972
+ "*"
973
+ );
974
+ return new Promise((resolve, reject) => {
975
+ promises[requestId] = { resolve, reject };
976
+ setTimeout(() => {
977
+ if (promises[requestId]) {
978
+ const errorMessage = "setSelectedData request timed out.";
979
+ promises[requestId].reject(new Error(errorMessage));
980
+ delete promises[requestId];
981
+ }
982
+ }, 2e3);
983
+ });
955
984
  };
956
985
 
957
986
  // libs/embed-libs/embed/src/lib/shared/service/calculate-dimensions.ts
@@ -997,6 +1026,9 @@ var _setCalculatedDimensions = (dashboardComponent) => {
997
1026
  for (const key of dashboardDimensionKeys) {
998
1027
  if (screenModes.includes(key)) {
999
1028
  const screenMode = EXTENTS.find((extent) => extent.mode === key);
1029
+ if (!screenMode) {
1030
+ continue;
1031
+ }
1000
1032
  availableScreenModeExtents.push({
1001
1033
  ...screenMode,
1002
1034
  height: dashboardComponent.dimensions[key][1] || 50
@@ -1051,24 +1083,27 @@ var _setCalculatedDimensions = (dashboardComponent) => {
1051
1083
  ),
1052
1084
  screenModeExtentMinWidth
1053
1085
  );
1054
- currentHeight = screenModeExtent.height;
1086
+ currentHeight = screenModeExtent.height ?? 0;
1055
1087
  }
1056
1088
  }
1057
1089
  }
1058
1090
  }
1059
1091
  } else {
1060
- const {
1061
- height: chosenModeHeight,
1062
- width: [chosenModeMinWidth, chosenModeMaxWidth]
1063
- } = availableScreenModeExtents.find(
1092
+ const chosenModeExtent = availableScreenModeExtents.find(
1064
1093
  (d) => d.mode === dashboardComponent.params.screenMode
1065
1094
  );
1066
- currentMode = dashboardComponent.params.screenMode;
1067
- currentWidth = Math.max(
1068
- Math.min(chosenModeMaxWidth, dashboardComponent.containerWidth),
1069
- chosenModeMinWidth
1070
- );
1071
- currentHeight = chosenModeHeight;
1095
+ if (chosenModeExtent) {
1096
+ const {
1097
+ height: chosenModeHeight,
1098
+ width: [chosenModeMinWidth, chosenModeMaxWidth]
1099
+ } = chosenModeExtent;
1100
+ currentMode = dashboardComponent.params.screenMode;
1101
+ currentWidth = Math.max(
1102
+ Math.min(chosenModeMaxWidth, dashboardComponent.containerWidth),
1103
+ chosenModeMinWidth
1104
+ );
1105
+ currentHeight = chosenModeHeight ?? 0;
1106
+ }
1072
1107
  if (dashboardComponent.params.itemEmbedding) {
1073
1108
  if (dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto") {
1074
1109
  currentWidth = Number.parseInt(
@@ -1088,7 +1123,7 @@ var _setCalculatedDimensions = (dashboardComponent) => {
1088
1123
  const [lowestModeExtent] = availableScreenModeExtents;
1089
1124
  currentMode = lowestModeExtent.mode;
1090
1125
  currentWidth = lowestModeExtent.width[0];
1091
- currentHeight = lowestModeExtent.height;
1126
+ currentHeight = lowestModeExtent.height ?? 0;
1092
1127
  }
1093
1128
  }
1094
1129
  dashboardComponent.currentScreenMode = currentMode;
@@ -1150,6 +1185,9 @@ var _extendAndValidate = (dashboardContent) => {
1150
1185
  "fixed",
1151
1186
  "auto"
1152
1187
  ];
1188
+ if (!dashboardContent.params) {
1189
+ dashboardContent.params = {};
1190
+ }
1153
1191
  for (const key of defaultKeys) {
1154
1192
  if (dashboardContent.params[key] === null) {
1155
1193
  delete dashboardContent.params[key];
@@ -1217,17 +1255,20 @@ var _extendAndValidate = (dashboardContent) => {
1217
1255
  if (dashboardContent.params.screenMode && dashboardContent.params.screenMode !== "auto") {
1218
1256
  dashboardContent.params.switchScreenModeOnResize = false;
1219
1257
  }
1220
- if (dashboardContent.params.itemDimensions.width !== "auto") {
1221
- dashboardContent.params.itemDimensions.width = Number.parseInt(
1222
- `${dashboardContent.params.itemDimensions.width}`.replace("px", ""),
1223
- 10
1224
- ) || "auto";
1225
- }
1226
- if (dashboardContent.params.itemDimensions.height !== "auto") {
1227
- dashboardContent.params.itemDimensions.height = Number.parseInt(
1228
- `${dashboardContent.params.itemDimensions.height}`.replace("px", ""),
1229
- 10
1230
- ) || "auto";
1258
+ const itemDimensions = dashboardContent.params.itemDimensions;
1259
+ if (itemDimensions) {
1260
+ if (itemDimensions.width !== "auto") {
1261
+ itemDimensions.width = Number.parseInt(
1262
+ `${itemDimensions.width}`.replace("px", ""),
1263
+ 10
1264
+ ) || "auto";
1265
+ }
1266
+ if (itemDimensions.height !== "auto") {
1267
+ itemDimensions.height = Number.parseInt(
1268
+ `${itemDimensions.height}`.replace("px", ""),
1269
+ 10
1270
+ ) || "auto";
1271
+ }
1231
1272
  }
1232
1273
  dashboardContent.params.itemEmbedding = !!dashboardContent.params.itemId;
1233
1274
  if (dashboardContent.params.error || errorMessages.length > 0) {
@@ -1239,6 +1280,7 @@ var _extendAndValidate = (dashboardContent) => {
1239
1280
  var libraryTypeToWebComponentTypeMapping = {
1240
1281
  type: "type",
1241
1282
  slots: "slots",
1283
+ inlineData: "inline-data",
1242
1284
  options: "options",
1243
1285
  appServer: "app-server",
1244
1286
  apiHost: "api-host",
@@ -1253,7 +1295,23 @@ var libraryTypeToWebComponentTypeMapping = {
1253
1295
  dashboardContentsVersion: "dashboard-contents-version",
1254
1296
  libVersion: "lib-version"
1255
1297
  };
1256
- var libraryAcceptedParametersList = ["appServer", "apiHost", "options", "type", "authKey", "authToken", "slots", "filters", "canFilter", "contextId", "itemId", "dashboardId", "aiMessageAssetId", "libVersion"];
1298
+ var libraryAcceptedParametersList = [
1299
+ "appServer",
1300
+ "apiHost",
1301
+ "options",
1302
+ "type",
1303
+ "authKey",
1304
+ "authToken",
1305
+ "slots",
1306
+ "inlineData",
1307
+ "filters",
1308
+ "canFilter",
1309
+ "contextId",
1310
+ "itemId",
1311
+ "dashboardId",
1312
+ "aiMessageAssetId",
1313
+ "libVersion"
1314
+ ];
1257
1315
 
1258
1316
  // libs/embed-libs/embed/src/lib/shared/constants/class-constants.ts
1259
1317
  var luzmoEmbedContainerClass = "luzmo-embed-container";