@luzmo/embed 8.0.0 → 8.1.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/index.shared.cjs CHANGED
@@ -435,41 +435,46 @@ var createIframeUrl = (dashboardContent) => {
435
435
  // libs/embed-libs/embed/src/lib/shared/helpers/get-loader.ts
436
436
  var getLoader = (dashboardComponent) => {
437
437
  let errorMsg;
438
- if (dashboardComponent.params.error || dashboardComponent.browserNotSupported.length > 0) {
439
- dashboardComponent.params.error = true;
438
+ if (dashboardComponent.params?.error || (dashboardComponent.browserNotSupported?.length ?? 0) > 0) {
439
+ if (dashboardComponent.params) {
440
+ dashboardComponent.params.error = true;
441
+ }
440
442
  if (dashboardComponent.browserNotSupported) {
441
443
  errorMsg = "Browser is not supported.";
442
444
  }
443
445
  }
444
- const loadingMsg = translations_default.initializing[dashboardComponent.params.language] || translations_default.initializing.en;
445
- return dashboardComponent.browserNotSupported || dashboardComponent.params.error ? { loadingMsg, errorMsg } : { loadingMsg, errorMsg: "" };
446
+ const language = dashboardComponent.params?.language;
447
+ const loadingMsg = (language ? translations_default.initializing[language] : void 0) || translations_default.initializing.en;
448
+ return dashboardComponent.browserNotSupported || dashboardComponent.params?.error ? { loadingMsg, errorMsg } : { loadingMsg, errorMsg: "" };
446
449
  };
447
450
 
448
451
  // libs/embed-libs/embed/src/lib/shared/helpers/promise-dispatch.ts
449
452
  function resolvePromise(dashboardComponent, requestId, data) {
450
- if (dashboardComponent.promises[requestId]) {
451
- dashboardComponent.promises[requestId].resolve(data);
452
- delete dashboardComponent.promises[requestId];
453
+ const promises = dashboardComponent.promises;
454
+ if (promises?.[requestId]) {
455
+ promises[requestId].resolve(data);
456
+ delete promises[requestId];
453
457
  }
454
458
  }
455
459
  function rejectPromise(dashboardComponent, requestId, data) {
456
- if (dashboardComponent.promises[requestId]) {
457
- dashboardComponent.promises[requestId].reject(data);
458
- delete dashboardComponent.promises[requestId];
460
+ const promises = dashboardComponent.promises;
461
+ if (promises?.[requestId]) {
462
+ promises[requestId].reject(data);
463
+ delete promises[requestId];
459
464
  }
460
465
  }
461
466
 
462
467
  // libs/embed-libs/embed/src/lib/shared/helpers/styles.ts
463
468
  function containerStyles(dashboardComponent) {
464
469
  const styles = {};
465
- if (dashboardComponent.params.loaderBackground && !dashboardComponent.iframeLoaded) {
470
+ if (dashboardComponent.params?.loaderBackground && !dashboardComponent.iframeLoaded) {
466
471
  styles.background = dashboardComponent.params.loaderBackground;
467
472
  }
468
473
  return styles;
469
474
  }
470
475
  function containerLoaderStyles(dashboardComponent) {
471
- const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
472
- const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
476
+ const height = dashboardComponent.params?.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
477
+ const chartHeightDefined = dashboardComponent.params?.itemEmbedding && height !== "auto";
473
478
  const display = dashboardComponent.iframeLoaded ? "none" : "";
474
479
  return {
475
480
  display,
@@ -477,8 +482,8 @@ function containerLoaderStyles(dashboardComponent) {
477
482
  };
478
483
  }
479
484
  function loaderStyles(dashboardComponent) {
480
- const background = dashboardComponent.params.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
481
- if (dashboardComponent.params.itemEmbedding) {
485
+ const background = dashboardComponent.params?.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
486
+ if (dashboardComponent.params?.itemEmbedding) {
482
487
  dashboardComponent.loaderSize = 24;
483
488
  dashboardComponent.borderWidth = 4;
484
489
  dashboardComponent.minHeight = 200;
@@ -507,11 +512,11 @@ function plStyles(dashboardComponent) {
507
512
  } = DEFAULT_PARAMETERS;
508
513
  const spinnerColorBorder = generateBorderStyle(
509
514
  dashboardComponent.borderWidth,
510
- dashboardComponent.params.loaderSpinnerColor || defaultSpinnerColor
515
+ dashboardComponent.params?.loaderSpinnerColor || defaultSpinnerColor
511
516
  );
512
517
  const spinnerBackgroundBorder = generateBorderStyle(
513
518
  dashboardComponent.borderWidth,
514
- dashboardComponent.params.loaderSpinnerBackground || defaultSpinnerBackground
519
+ dashboardComponent.params?.loaderSpinnerBackground || defaultSpinnerBackground
515
520
  );
516
521
  const size = `${dashboardComponent.loaderSize}px`;
517
522
  return {
@@ -524,27 +529,28 @@ function plStyles(dashboardComponent) {
524
529
  };
525
530
  }
526
531
  function lcStyles(dashboardComponent) {
527
- const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
528
- const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
529
- const getPaddingStr = (value) => `${(value - dashboardComponent.loaderSize - 32) / 2}px`;
530
- const verticalPadding = dashboardComponent.params.itemId ? chartHeightDefined ? getPaddingStr(Number.parseInt(`${height}`, 10)) : getPaddingStr(dashboardComponent.minHeight) : "128px";
532
+ const height = dashboardComponent.params?.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
533
+ const chartHeightDefined = dashboardComponent.params?.itemEmbedding && height !== "auto";
534
+ const getPaddingStr = (value) => `${((value ?? Number.NaN) - (dashboardComponent.loaderSize ?? Number.NaN) - 32) / 2}px`;
535
+ const verticalPadding = dashboardComponent.params?.itemId ? chartHeightDefined ? getPaddingStr(Number.parseInt(`${height}`, 10)) : getPaddingStr(dashboardComponent.minHeight) : "128px";
531
536
  return {
532
537
  padding: `${verticalPadding} 16px`
533
538
  };
534
539
  }
535
540
  function calculateIframeStyles(dashboardComponent) {
536
- const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
537
- const width = dashboardComponent.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
538
- if (dashboardComponent.params.itemEmbedding && height !== "auto") {
541
+ const height = dashboardComponent.params?.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
542
+ const width = dashboardComponent.params?.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
543
+ const editMode = dashboardComponent.params?.editMode;
544
+ if (dashboardComponent.params?.itemEmbedding && height !== "auto") {
539
545
  dashboardComponent.iframeHeight = `${height}px`;
540
- } else if (dashboardComponent.params.itemEmbedding) {
546
+ } else if (dashboardComponent.params?.itemEmbedding) {
541
547
  dashboardComponent.iframeHeight = "200px";
542
- } else if (["editFull", "editLimited"].includes(dashboardComponent.params.editMode)) {
548
+ } else if (editMode != null && ["editFull", "editLimited"].includes(editMode)) {
543
549
  dashboardComponent.iframeHeight = "100%";
544
550
  } else {
545
551
  dashboardComponent.iframeHeight = "400px";
546
552
  }
547
- dashboardComponent.iframeWidth = dashboardComponent.params.itemEmbedding && width !== "auto" ? `${width}px` : "100%";
553
+ dashboardComponent.iframeWidth = dashboardComponent.params?.itemEmbedding && width !== "auto" ? `${width}px` : "100%";
548
554
  const styles = {
549
555
  height: dashboardComponent.iframeHeight,
550
556
  width: dashboardComponent.iframeWidth
@@ -563,7 +569,7 @@ function calculateIframeStyles(dashboardComponent) {
563
569
 
564
570
  // libs/embed-libs/embed/src/lib/shared/helpers/update-iframe-url.ts
565
571
  var updateIframeUrl = (iframe, iframeUrl) => {
566
- if (iframe?.contentWindow) {
572
+ if (iframe?.contentWindow && iframeUrl !== void 0) {
567
573
  iframe.contentWindow.location.replace(iframeUrl);
568
574
  }
569
575
  };
@@ -572,7 +578,7 @@ var updateIframeUrl = (iframe, iframeUrl) => {
572
578
  var selectedDataUtils = {
573
579
  merge(...filters) {
574
580
  return filters.reduce((acc, filter) => {
575
- acc.and.push(...filter.and);
581
+ (acc.and ??= []).push(...filter.and ?? []);
576
582
  return acc;
577
583
  }, {
578
584
  and: []
@@ -635,43 +641,46 @@ var selectedDataUtils = {
635
641
  // libs/embed-libs/embed/src/lib/shared/methods/export-dashboard.ts
636
642
  var exportDashboard = (dashboardComponent, iframe, format) => {
637
643
  const requestId = uuidv4();
638
- if (iframe?.contentWindow) {
639
- iframe.contentWindow.postMessage(
640
- {
641
- action: "exportDashboard",
642
- format: format || "png",
643
- _version: dashboardComponent.libVersion,
644
- requestId
645
- },
646
- "*"
647
- );
648
- return new Promise((resolve, reject) => {
649
- dashboardComponent.promises[requestId] = { resolve, reject };
650
- setTimeout(() => {
651
- if (dashboardComponent.promises[requestId]) {
652
- const errorMessage = "exportDashboard request timed out.";
653
- dashboardComponent.promises[requestId].reject(
654
- new Error(errorMessage)
655
- );
656
- delete dashboardComponent.promises[requestId];
657
- }
658
- }, 12e5);
659
- });
644
+ if (!iframe?.contentWindow) {
645
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
660
646
  }
661
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
647
+ const { promises } = dashboardComponent;
648
+ if (!promises) {
649
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
650
+ }
651
+ iframe.contentWindow.postMessage(
652
+ {
653
+ action: "exportDashboard",
654
+ format: format || "png",
655
+ _version: dashboardComponent.libVersion,
656
+ requestId
657
+ },
658
+ "*"
659
+ );
660
+ return new Promise((resolve, reject) => {
661
+ promises[requestId] = { resolve, reject };
662
+ setTimeout(() => {
663
+ if (promises[requestId]) {
664
+ const errorMessage = "exportDashboard request timed out.";
665
+ promises[requestId].reject(new Error(errorMessage));
666
+ delete promises[requestId];
667
+ }
668
+ }, 12e5);
669
+ });
662
670
  };
663
671
 
664
672
  // libs/embed-libs/embed/src/lib/shared/methods/get-accessible-dashboards.ts
665
673
  var getAccessibleDashboards = async (dashboardComponent) => {
666
674
  await dashboardComponent.updateComplete;
667
- if ((dashboardComponent.currentAuthKey ?? dashboardComponent.authKey) && (dashboardComponent.currentAuthToken ?? dashboardComponent.authToken)) {
675
+ if ((dashboardComponent.currentAuthKey ?? dashboardComponent.authKey) && (dashboardComponent.currentAuthToken ?? dashboardComponent.authToken) && dashboardComponent.params) {
676
+ const { params } = dashboardComponent;
668
677
  const fetchUser = new Promise((resolve, reject) => {
669
678
  void (() => {
670
679
  try {
671
680
  const responsePromise = window.fetch(
672
681
  // With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
673
682
  // Fixes incorrect url with embedMode="webComponent"
674
- `${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/authorization`,
683
+ `${addTrailingSlash(params.apiHost)}0.1.0/authorization`,
675
684
  {
676
685
  method: "POST",
677
686
  mode: "cors",
@@ -716,136 +725,144 @@ var getAccessibleDashboards = async (dashboardComponent) => {
716
725
  }
717
726
  })();
718
727
  });
719
- return new Promise((resolve, reject) => void (() => {
720
- try {
721
- fetchUser.then((authorizationData) => {
722
- const responsePromise = window.fetch(
723
- // With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
724
- // Fixes incorrect url with embedMode="webComponent"
725
- `${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/securable`,
726
- {
727
- method: "POST",
728
- mode: "cors",
729
- cache: "no-cache",
730
- headers: { "Content-Type": "application/json" },
731
- redirect: "follow",
732
- body: JSON.stringify({
733
- action: "get",
734
- version: "0.1.0",
735
- key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
736
- token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
737
- find: {
738
- where: { type: "dashboard", is_variant: false },
739
- attributes: ["id", "name", "modified_at"],
740
- order: [["modified_at", "desc"]],
741
- include: [
742
- { model: "Tag", attributes: ["tag"] },
743
- { model: "User", attributes: ["id", "name"] },
744
- {
745
- model: "Group",
746
- attributes: ["id", "name", "public"]
747
- },
748
- { model: "Integration", attributes: ["id", "name"] }
749
- ]
750
- }
751
- })
752
- }
753
- );
754
- responsePromise.then((response) => response.json()).then((data) => {
755
- const dashboardList = data.rows.length > 0 ? formatDashboardList(
756
- data.rows,
757
- authorizationData.integrationId,
758
- authorizationData.user,
759
- dashboardComponent
760
- ) : [];
761
- resolve(dashboardList);
728
+ return new Promise((resolve, reject) => {
729
+ void (() => {
730
+ try {
731
+ fetchUser.then((authorizationData) => {
732
+ const responsePromise = window.fetch(
733
+ // With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
734
+ // Fixes incorrect url with embedMode="webComponent"
735
+ `${addTrailingSlash(params.apiHost)}0.1.0/securable`,
736
+ {
737
+ method: "POST",
738
+ mode: "cors",
739
+ cache: "no-cache",
740
+ headers: { "Content-Type": "application/json" },
741
+ redirect: "follow",
742
+ body: JSON.stringify({
743
+ action: "get",
744
+ version: "0.1.0",
745
+ key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
746
+ token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
747
+ find: {
748
+ where: { type: "dashboard", is_variant: false },
749
+ attributes: ["id", "name", "modified_at"],
750
+ order: [["modified_at", "desc"]],
751
+ include: [
752
+ { model: "Tag", attributes: ["tag"] },
753
+ { model: "User", attributes: ["id", "name"] },
754
+ {
755
+ model: "Group",
756
+ attributes: ["id", "name", "public"]
757
+ },
758
+ { model: "Integration", attributes: ["id", "name"] }
759
+ ]
760
+ }
761
+ })
762
+ }
763
+ );
764
+ responsePromise.then((response) => response.json()).then((data) => {
765
+ const dashboardList = data.rows.length > 0 ? formatDashboardList(
766
+ data.rows,
767
+ authorizationData.integrationId,
768
+ authorizationData.user,
769
+ dashboardComponent
770
+ ) : [];
771
+ resolve(dashboardList);
772
+ });
773
+ }).catch((error) => {
774
+ reject(error);
762
775
  });
763
- }).catch((error) => {
776
+ } catch (error) {
764
777
  reject(error);
765
- });
766
- } catch (error) {
767
- reject(error);
768
- }
769
- })());
778
+ }
779
+ })();
780
+ });
770
781
  }
771
782
  throw new Error("No authKey or authToken found in the luzmo-dashboard component.");
772
783
  };
773
784
 
774
785
  // libs/embed-libs/embed/src/lib/shared/methods/get-dashboard-context.ts
775
786
  var getDashboardContext = (dashboardComponent, iframe) => {
776
- if (iframe?.contentWindow) {
777
- const requestId = uuidv4();
778
- iframe.contentWindow.postMessage(
779
- { action: "getDashboardContext", _version: dashboardComponent.libVersion, requestId },
780
- "*"
781
- );
782
- return new Promise((resolve, reject) => {
783
- dashboardComponent.promises[requestId] = { resolve, reject };
784
- setTimeout(() => {
785
- if (dashboardComponent.promises[requestId]) {
786
- const errorMessage = "getDashboardContext request timed out.";
787
- dashboardComponent.promises[requestId].reject(
788
- new Error(errorMessage)
789
- );
790
- delete dashboardComponent.promises[requestId];
791
- }
792
- }, 2e3);
793
- });
787
+ if (!iframe?.contentWindow) {
788
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
794
789
  }
795
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
790
+ const { promises } = dashboardComponent;
791
+ if (!promises) {
792
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
793
+ }
794
+ const requestId = uuidv4();
795
+ iframe.contentWindow.postMessage(
796
+ { action: "getDashboardContext", _version: dashboardComponent.libVersion, requestId },
797
+ "*"
798
+ );
799
+ return new Promise((resolve, reject) => {
800
+ promises[requestId] = { resolve, reject };
801
+ setTimeout(() => {
802
+ if (promises[requestId]) {
803
+ const errorMessage = "getDashboardContext request timed out.";
804
+ promises[requestId].reject(new Error(errorMessage));
805
+ delete promises[requestId];
806
+ }
807
+ }, 2e3);
808
+ });
796
809
  };
797
810
 
798
811
  // libs/embed-libs/embed/src/lib/shared/methods/get-data.ts
799
812
  var getData = (dashboardComponent, iframe, itemId) => {
800
- if (iframe?.contentWindow) {
801
- const requestId = uuidv4();
802
- iframe.contentWindow.postMessage(
803
- {
804
- action: "getData",
805
- id: itemId,
806
- _version: dashboardComponent.libVersion,
807
- requestId
808
- },
809
- "*"
810
- );
811
- return new Promise((resolve, reject) => {
812
- dashboardComponent.promises[requestId] = { resolve, reject };
813
- setTimeout(() => {
814
- if (dashboardComponent.promises[requestId]) {
815
- const errorMessage = "getData request timed out.";
816
- dashboardComponent.promises[requestId].reject(
817
- new Error(errorMessage)
818
- );
819
- delete dashboardComponent.promises[requestId];
820
- }
821
- }, 2e3);
822
- });
813
+ if (!iframe?.contentWindow) {
814
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
823
815
  }
824
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
816
+ const { promises } = dashboardComponent;
817
+ if (!promises) {
818
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
819
+ }
820
+ const requestId = uuidv4();
821
+ iframe.contentWindow.postMessage(
822
+ {
823
+ action: "getData",
824
+ id: itemId,
825
+ _version: dashboardComponent.libVersion,
826
+ requestId
827
+ },
828
+ "*"
829
+ );
830
+ return new Promise((resolve, reject) => {
831
+ promises[requestId] = { resolve, reject };
832
+ setTimeout(() => {
833
+ if (promises[requestId]) {
834
+ const errorMessage = "getData request timed out.";
835
+ promises[requestId].reject(new Error(errorMessage));
836
+ delete promises[requestId];
837
+ }
838
+ }, 2e3);
839
+ });
825
840
  };
826
841
 
827
842
  // libs/embed-libs/embed/src/lib/shared/methods/get-filters.ts
828
843
  var getFilters = (dashboardComponent, iframe) => {
829
- if (iframe?.contentWindow) {
830
- const requestId = uuidv4();
831
- iframe.contentWindow.postMessage(
832
- { action: "getFilters", _version: dashboardComponent.libVersion, requestId },
833
- "*"
834
- );
835
- return new Promise((resolve, reject) => {
836
- dashboardComponent.promises[requestId] = { resolve, reject };
837
- setTimeout(() => {
838
- if (dashboardComponent.promises[requestId]) {
839
- const errorMessage = "getFilters request timed out.";
840
- dashboardComponent.promises[requestId].reject(
841
- new Error(errorMessage)
842
- );
843
- delete dashboardComponent.promises[requestId];
844
- }
845
- }, 2e3);
846
- });
844
+ if (!iframe?.contentWindow) {
845
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
847
846
  }
848
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
847
+ const { promises } = dashboardComponent;
848
+ if (!promises) {
849
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
850
+ }
851
+ const requestId = uuidv4();
852
+ iframe.contentWindow.postMessage(
853
+ { action: "getFilters", _version: dashboardComponent.libVersion, requestId },
854
+ "*"
855
+ );
856
+ return new Promise((resolve, reject) => {
857
+ promises[requestId] = { resolve, reject };
858
+ setTimeout(() => {
859
+ if (promises[requestId]) {
860
+ const errorMessage = "getFilters request timed out.";
861
+ promises[requestId].reject(new Error(errorMessage));
862
+ delete promises[requestId];
863
+ }
864
+ }, 2e3);
865
+ });
849
866
  };
850
867
 
851
868
  // libs/embed-libs/embed/src/lib/shared/methods/get-insights.ts
@@ -853,6 +870,10 @@ var getInsights = (dashboardComponent, iframe, options = {}) => {
853
870
  if (!iframe?.contentWindow) {
854
871
  return Promise.reject(new Error("Cannot retrieve contentWindow."));
855
872
  }
873
+ const { promises } = dashboardComponent;
874
+ if (!promises) {
875
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
876
+ }
856
877
  const requestId = uuidv4();
857
878
  iframe.contentWindow.postMessage(
858
879
  {
@@ -864,11 +885,11 @@ var getInsights = (dashboardComponent, iframe, options = {}) => {
864
885
  "*"
865
886
  );
866
887
  return new Promise((resolve, reject) => {
867
- dashboardComponent.promises[requestId] = { resolve, reject };
888
+ promises[requestId] = { resolve, reject };
868
889
  setTimeout(() => {
869
- if (dashboardComponent.promises[requestId]) {
870
- dashboardComponent.promises[requestId].reject(new Error("getInsights request timed out."));
871
- delete dashboardComponent.promises[requestId];
890
+ if (promises[requestId]) {
891
+ promises[requestId].reject(new Error("getInsights request timed out."));
892
+ delete promises[requestId];
872
893
  }
873
894
  }, 6e4);
874
895
  });
@@ -876,7 +897,7 @@ var getInsights = (dashboardComponent, iframe, options = {}) => {
876
897
 
877
898
  // libs/embed-libs/embed/src/lib/shared/methods/refresh-data.ts
878
899
  var refreshData = (dashboardComponent, iframe, itemId) => {
879
- if (iframe) {
900
+ if (iframe?.contentWindow) {
880
901
  iframe.contentWindow.postMessage(
881
902
  {
882
903
  action: "refreshData",
@@ -892,7 +913,7 @@ var refreshData = (dashboardComponent, iframe, itemId) => {
892
913
 
893
914
  // libs/embed-libs/embed/src/lib/shared/methods/reload-dashboard.ts
894
915
  var reloadDashboard = (dashboardComponent, iframe) => {
895
- if (iframe) {
916
+ if (iframe?.contentWindow) {
896
917
  iframe.contentWindow.postMessage(
897
918
  { action: "reloadDashboard", _version: dashboardComponent.libVersion },
898
919
  "*"
@@ -904,7 +925,7 @@ var reloadDashboard = (dashboardComponent, iframe) => {
904
925
 
905
926
  // libs/embed-libs/embed/src/lib/shared/methods/send-export-email.ts
906
927
  var sendExportEmail = (dashboardComponent, iframe, type, subject, message) => {
907
- if (iframe) {
928
+ if (iframe?.contentWindow) {
908
929
  iframe.contentWindow.postMessage(
909
930
  {
910
931
  action: "sendExportEmail",
@@ -922,7 +943,7 @@ var sendExportEmail = (dashboardComponent, iframe, type, subject, message) => {
922
943
 
923
944
  // libs/embed-libs/embed/src/lib/shared/methods/set-authorization.ts
924
945
  var setAuthorization = (dashboardComponent, iframe, key, token) => {
925
- if (iframe) {
946
+ if (iframe?.contentWindow) {
926
947
  iframe.contentWindow.postMessage(
927
948
  {
928
949
  action: "setAuthorization",
@@ -939,92 +960,100 @@ var setAuthorization = (dashboardComponent, iframe, key, token) => {
939
960
 
940
961
  // libs/embed-libs/embed/src/lib/shared/methods/set-edit-mode.ts
941
962
  var setEditMode = (dashboardComponent, iframe, editMode) => {
942
- if (iframe && iframe.contentWindow) {
943
- const requestId = uuidv4();
944
- if (dashboardComponent.params.editMode === editMode) {
945
- return Promise.reject(
946
- new Error("editMode parameter is currently already set to " + editMode)
947
- );
948
- } else if (editMode !== "editFull" && editMode !== "editLimited" && editMode !== "view") {
949
- return Promise.reject(
950
- new Error(
951
- "The editMode parameter must be one of the following values: 'editFull', 'editLimited' or 'view'."
952
- )
953
- );
954
- }
955
- iframe.contentWindow.postMessage(
956
- {
957
- action: "setEditMode",
958
- editMode,
959
- _version: dashboardComponent.libVersion,
960
- requestId
961
- },
962
- "*"
963
+ if (!iframe?.contentWindow) {
964
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
965
+ }
966
+ const { params, promises } = dashboardComponent;
967
+ if (!params || !promises) {
968
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
969
+ }
970
+ const requestId = uuidv4();
971
+ if (params.editMode === editMode) {
972
+ return Promise.reject(
973
+ new Error("editMode parameter is currently already set to " + editMode)
974
+ );
975
+ } else if (editMode !== "editFull" && editMode !== "editLimited" && editMode !== "view") {
976
+ return Promise.reject(
977
+ new Error(
978
+ "The editMode parameter must be one of the following values: 'editFull', 'editLimited' or 'view'."
979
+ )
963
980
  );
964
- return new Promise((resolve, reject) => {
965
- dashboardComponent.promises[requestId] = { resolve, reject };
966
- });
967
981
  }
968
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
982
+ iframe.contentWindow.postMessage(
983
+ {
984
+ action: "setEditMode",
985
+ editMode,
986
+ _version: dashboardComponent.libVersion,
987
+ requestId
988
+ },
989
+ "*"
990
+ );
991
+ return new Promise((resolve, reject) => {
992
+ promises[requestId] = { resolve, reject };
993
+ });
969
994
  };
970
995
 
971
996
  // libs/embed-libs/embed/src/lib/shared/methods/set-preview.ts
972
997
  var setPreview = (dashboardComponent, iframe, preview) => {
973
- if (iframe) {
974
- const requestId = uuidv4();
975
- iframe.contentWindow.postMessage(
976
- {
977
- action: "setPreview",
978
- preview,
979
- requestId,
980
- _version: dashboardComponent.libVersion
981
- },
982
- "*"
983
- );
984
- return new Promise((resolve, reject) => {
985
- dashboardComponent.promises[requestId] = { resolve, reject };
986
- setTimeout(() => {
987
- if (dashboardComponent.promises[requestId]) {
988
- const errorMessage = "setPreview request timed out.";
989
- dashboardComponent.promises[requestId].reject(
990
- new Error(errorMessage)
991
- );
992
- delete dashboardComponent.promises[requestId];
993
- }
994
- }, 2e3);
995
- });
998
+ if (!iframe?.contentWindow) {
999
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
996
1000
  }
997
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
1001
+ const { promises } = dashboardComponent;
1002
+ if (!promises) {
1003
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
1004
+ }
1005
+ const requestId = uuidv4();
1006
+ iframe.contentWindow.postMessage(
1007
+ {
1008
+ action: "setPreview",
1009
+ preview,
1010
+ requestId,
1011
+ _version: dashboardComponent.libVersion
1012
+ },
1013
+ "*"
1014
+ );
1015
+ return new Promise((resolve, reject) => {
1016
+ promises[requestId] = { resolve, reject };
1017
+ setTimeout(() => {
1018
+ if (promises[requestId]) {
1019
+ const errorMessage = "setPreview request timed out.";
1020
+ promises[requestId].reject(new Error(errorMessage));
1021
+ delete promises[requestId];
1022
+ }
1023
+ }, 2e3);
1024
+ });
998
1025
  };
999
1026
 
1000
1027
  // libs/embed-libs/embed/src/lib/shared/methods/set-selected-data.ts
1001
1028
  var setSelectedData = (dashboardComponent, iframe, itemId, filters) => {
1002
- if (iframe) {
1003
- const requestId = uuidv4();
1004
- iframe.contentWindow.postMessage(
1005
- {
1006
- action: "setSelectedData",
1007
- itemId,
1008
- filters,
1009
- _version: dashboardComponent.libVersion,
1010
- requestId
1011
- },
1012
- "*"
1013
- );
1014
- return new Promise((resolve, reject) => {
1015
- dashboardComponent.promises[requestId] = { resolve, reject };
1016
- setTimeout(() => {
1017
- if (dashboardComponent.promises[requestId]) {
1018
- const errorMessage = "setSelectedData request timed out.";
1019
- dashboardComponent.promises[requestId].reject(
1020
- new Error(errorMessage)
1021
- );
1022
- delete dashboardComponent.promises[requestId];
1023
- }
1024
- }, 2e3);
1025
- });
1029
+ if (!iframe?.contentWindow) {
1030
+ return Promise.reject();
1031
+ }
1032
+ const { promises } = dashboardComponent;
1033
+ if (!promises) {
1034
+ return Promise.reject();
1026
1035
  }
1027
- return Promise.reject();
1036
+ const requestId = uuidv4();
1037
+ iframe.contentWindow.postMessage(
1038
+ {
1039
+ action: "setSelectedData",
1040
+ itemId,
1041
+ filters,
1042
+ _version: dashboardComponent.libVersion,
1043
+ requestId
1044
+ },
1045
+ "*"
1046
+ );
1047
+ return new Promise((resolve, reject) => {
1048
+ promises[requestId] = { resolve, reject };
1049
+ setTimeout(() => {
1050
+ if (promises[requestId]) {
1051
+ const errorMessage = "setSelectedData request timed out.";
1052
+ promises[requestId].reject(new Error(errorMessage));
1053
+ delete promises[requestId];
1054
+ }
1055
+ }, 2e3);
1056
+ });
1028
1057
  };
1029
1058
 
1030
1059
  // libs/embed-libs/embed/src/lib/shared/service/calculate-dimensions.ts
@@ -1070,6 +1099,9 @@ var _setCalculatedDimensions = (dashboardComponent) => {
1070
1099
  for (const key of dashboardDimensionKeys) {
1071
1100
  if (screenModes.includes(key)) {
1072
1101
  const screenMode = EXTENTS.find((extent) => extent.mode === key);
1102
+ if (!screenMode) {
1103
+ continue;
1104
+ }
1073
1105
  availableScreenModeExtents.push({
1074
1106
  ...screenMode,
1075
1107
  height: dashboardComponent.dimensions[key][1] || 50
@@ -1124,24 +1156,27 @@ var _setCalculatedDimensions = (dashboardComponent) => {
1124
1156
  ),
1125
1157
  screenModeExtentMinWidth
1126
1158
  );
1127
- currentHeight = screenModeExtent.height;
1159
+ currentHeight = screenModeExtent.height ?? 0;
1128
1160
  }
1129
1161
  }
1130
1162
  }
1131
1163
  }
1132
1164
  } else {
1133
- const {
1134
- height: chosenModeHeight,
1135
- width: [chosenModeMinWidth, chosenModeMaxWidth]
1136
- } = availableScreenModeExtents.find(
1165
+ const chosenModeExtent = availableScreenModeExtents.find(
1137
1166
  (d) => d.mode === dashboardComponent.params.screenMode
1138
1167
  );
1139
- currentMode = dashboardComponent.params.screenMode;
1140
- currentWidth = Math.max(
1141
- Math.min(chosenModeMaxWidth, dashboardComponent.containerWidth),
1142
- chosenModeMinWidth
1143
- );
1144
- currentHeight = chosenModeHeight;
1168
+ if (chosenModeExtent) {
1169
+ const {
1170
+ height: chosenModeHeight,
1171
+ width: [chosenModeMinWidth, chosenModeMaxWidth]
1172
+ } = chosenModeExtent;
1173
+ currentMode = dashboardComponent.params.screenMode;
1174
+ currentWidth = Math.max(
1175
+ Math.min(chosenModeMaxWidth, dashboardComponent.containerWidth),
1176
+ chosenModeMinWidth
1177
+ );
1178
+ currentHeight = chosenModeHeight ?? 0;
1179
+ }
1145
1180
  if (dashboardComponent.params.itemEmbedding) {
1146
1181
  if (dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto") {
1147
1182
  currentWidth = Number.parseInt(
@@ -1161,7 +1196,7 @@ var _setCalculatedDimensions = (dashboardComponent) => {
1161
1196
  const [lowestModeExtent] = availableScreenModeExtents;
1162
1197
  currentMode = lowestModeExtent.mode;
1163
1198
  currentWidth = lowestModeExtent.width[0];
1164
- currentHeight = lowestModeExtent.height;
1199
+ currentHeight = lowestModeExtent.height ?? 0;
1165
1200
  }
1166
1201
  }
1167
1202
  dashboardComponent.currentScreenMode = currentMode;
@@ -1223,6 +1258,9 @@ var _extendAndValidate = (dashboardContent) => {
1223
1258
  "fixed",
1224
1259
  "auto"
1225
1260
  ];
1261
+ if (!dashboardContent.params) {
1262
+ dashboardContent.params = {};
1263
+ }
1226
1264
  for (const key of defaultKeys) {
1227
1265
  if (dashboardContent.params[key] === null) {
1228
1266
  delete dashboardContent.params[key];
@@ -1290,17 +1328,20 @@ var _extendAndValidate = (dashboardContent) => {
1290
1328
  if (dashboardContent.params.screenMode && dashboardContent.params.screenMode !== "auto") {
1291
1329
  dashboardContent.params.switchScreenModeOnResize = false;
1292
1330
  }
1293
- if (dashboardContent.params.itemDimensions.width !== "auto") {
1294
- dashboardContent.params.itemDimensions.width = Number.parseInt(
1295
- `${dashboardContent.params.itemDimensions.width}`.replace("px", ""),
1296
- 10
1297
- ) || "auto";
1298
- }
1299
- if (dashboardContent.params.itemDimensions.height !== "auto") {
1300
- dashboardContent.params.itemDimensions.height = Number.parseInt(
1301
- `${dashboardContent.params.itemDimensions.height}`.replace("px", ""),
1302
- 10
1303
- ) || "auto";
1331
+ const itemDimensions = dashboardContent.params.itemDimensions;
1332
+ if (itemDimensions) {
1333
+ if (itemDimensions.width !== "auto") {
1334
+ itemDimensions.width = Number.parseInt(
1335
+ `${itemDimensions.width}`.replace("px", ""),
1336
+ 10
1337
+ ) || "auto";
1338
+ }
1339
+ if (itemDimensions.height !== "auto") {
1340
+ itemDimensions.height = Number.parseInt(
1341
+ `${itemDimensions.height}`.replace("px", ""),
1342
+ 10
1343
+ ) || "auto";
1344
+ }
1304
1345
  }
1305
1346
  dashboardContent.params.itemEmbedding = !!dashboardContent.params.itemId;
1306
1347
  if (dashboardContent.params.error || errorMessages.length > 0) {
@@ -1312,6 +1353,7 @@ var _extendAndValidate = (dashboardContent) => {
1312
1353
  var libraryTypeToWebComponentTypeMapping = {
1313
1354
  type: "type",
1314
1355
  slots: "slots",
1356
+ inlineData: "inline-data",
1315
1357
  options: "options",
1316
1358
  appServer: "app-server",
1317
1359
  apiHost: "api-host",
@@ -1326,7 +1368,23 @@ var libraryTypeToWebComponentTypeMapping = {
1326
1368
  dashboardContentsVersion: "dashboard-contents-version",
1327
1369
  libVersion: "lib-version"
1328
1370
  };
1329
- var libraryAcceptedParametersList = ["appServer", "apiHost", "options", "type", "authKey", "authToken", "slots", "filters", "canFilter", "contextId", "itemId", "dashboardId", "aiMessageAssetId", "libVersion"];
1371
+ var libraryAcceptedParametersList = [
1372
+ "appServer",
1373
+ "apiHost",
1374
+ "options",
1375
+ "type",
1376
+ "authKey",
1377
+ "authToken",
1378
+ "slots",
1379
+ "inlineData",
1380
+ "filters",
1381
+ "canFilter",
1382
+ "contextId",
1383
+ "itemId",
1384
+ "dashboardId",
1385
+ "aiMessageAssetId",
1386
+ "libVersion"
1387
+ ];
1330
1388
 
1331
1389
  // libs/embed-libs/embed/src/lib/shared/constants/class-constants.ts
1332
1390
  var luzmoEmbedContainerClass = "luzmo-embed-container";