@luzmo/embed 5.1.3-beta.3 → 5.1.4

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.libs.js CHANGED
@@ -28,11 +28,14 @@ import {
28
28
  styleMap
29
29
  } from "lit/directives/style-map.js";
30
30
  import {
31
+ __federationMethodGetRemote,
32
+ __federationMethodWrapDefault,
33
+ remotesMap,
31
34
  luzmoEmbedContainerClass
32
35
  } from "@luzmo/shared-embed";
33
36
 
34
37
  // libs/embed-libs/embed/package.json
35
- var version = "5.1.3-beta.3";
38
+ var version = "5.1.4";
36
39
 
37
40
  // libs/embed-libs/embed/src/lib/luzmo-service.ts
38
41
  var LuzmoService = class {
@@ -204,6 +207,7 @@ import { css } from "lit";
204
207
  var dashboardStyles = css`
205
208
  :host {
206
209
  display: block;
210
+ height: 100%;
207
211
  }
208
212
 
209
213
  @-webkit-keyframes spin {
@@ -238,6 +242,9 @@ var dashboardStyles = css`
238
242
  border: 0;
239
243
  }
240
244
 
245
+ .luzmo-embed-dashboard-ede {
246
+ }
247
+
241
248
  .luzmo-embed-container-ede {
242
249
  width: 100%;
243
250
  height: 100%;
@@ -314,7 +321,7 @@ var dashboardStyles = css`
314
321
 
315
322
  // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-base.ts
316
323
  var LuzmoDashboard = class extends LitElement {
317
- constructor() {
324
+ constructor(inputParameters) {
318
325
  super();
319
326
  this.language = "auto";
320
327
  this.screenMode = "auto";
@@ -333,11 +340,10 @@ var LuzmoDashboard = class extends LitElement {
333
340
  this.browserErrorMsg = "";
334
341
  this.dashboardError = false;
335
342
  this.browserNotSupported = [];
336
- this.libVersion = version + "-wc-luzmo";
343
+ this.VERSION = version + "-wc-luzmo";
337
344
  this.isLibraryLoaded = false;
338
345
  this.currentAuthKey = null;
339
346
  this.currentAuthToken = null;
340
- this.isInitCalled = false;
341
347
  this.attributesMap = {
342
348
  dashboardId: "dashboard-id",
343
349
  dashboardSlug: "dashboard-slug",
@@ -367,6 +373,7 @@ var LuzmoDashboard = class extends LitElement {
367
373
  this._iframeId = `luzmo-dashboard-${this._containerId}`;
368
374
  this.iframeLoaded = false;
369
375
  this.promises = {};
376
+ this.setInputParameters(inputParameters);
370
377
  this.params = this._setOptions();
371
378
  this._onResize = () => {
372
379
  if (this.shadowRoot?.querySelector(".dashboard-container")) {
@@ -397,6 +404,60 @@ var LuzmoDashboard = class extends LitElement {
397
404
  });
398
405
  });
399
406
  }
407
+ loadLibrary(appServer) {
408
+ if (remotesMap[appServer]) {
409
+ return Promise.resolve(remotesMap[appServer].module);
410
+ }
411
+ remotesMap[appServer] = {
412
+ url: appServer?.startsWith("http://localhost") ? `${SharedLib2.removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${SharedLib2.removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`,
413
+ format: "esm",
414
+ from: "vite",
415
+ module: void 0
416
+ };
417
+ return __federationMethodGetRemote(appServer, "./DashboardApp").then((module) => {
418
+ const wrappedModule = __federationMethodWrapDefault(module, true);
419
+ remotesMap[appServer].module = wrappedModule;
420
+ return wrappedModule;
421
+ });
422
+ }
423
+ setInputParameters(inputParameters) {
424
+ if (!inputParameters) {
425
+ return;
426
+ }
427
+ const params = [
428
+ "dashboardId",
429
+ "dashboardSlug",
430
+ "itemId",
431
+ "language",
432
+ "qeVersion",
433
+ "screenMode",
434
+ "switchScreenModeOnResize",
435
+ "accentColor",
436
+ "mainColor",
437
+ "authToken",
438
+ "authKey",
439
+ "editMode",
440
+ "loaderBackground",
441
+ "loaderFontColor",
442
+ "loaderSpinnerColor",
443
+ "loaderSpinnerBackground",
444
+ "timezoneId",
445
+ "itemDimensions",
446
+ "apiHost"
447
+ ];
448
+ for (const key of params) {
449
+ const value = inputParameters[key];
450
+ if (value) {
451
+ this[key] = value;
452
+ }
453
+ }
454
+ if (inputParameters.experimental) {
455
+ this.experimental = inputParameters.experimental;
456
+ }
457
+ if (inputParameters.appServer) {
458
+ this.appServer = SharedLib2.addTrailingSlash(inputParameters.appServer);
459
+ }
460
+ }
400
461
  // Set resize event listener
401
462
  connectedCallback() {
402
463
  super.connectedCallback();
@@ -415,6 +476,7 @@ var LuzmoDashboard = class extends LitElement {
415
476
  this._loaderMsg = SharedLib2.getLoader(this)?.loadingMsg;
416
477
  this._loaderStyles();
417
478
  luzmo_service_default._components.push(this);
479
+ this.initComponent();
418
480
  if (this.luzmoEmbedContainer) {
419
481
  this._resizeObserver.observe(this.luzmoEmbedContainer);
420
482
  }
@@ -422,7 +484,7 @@ var LuzmoDashboard = class extends LitElement {
422
484
  initComponent() {
423
485
  this.params = this._setOptions();
424
486
  if (this.getIsViewMode()) {
425
- SharedLib2.loadLibrary(this.params.appServer).then(async () => {
487
+ this.loadLibrary(this.params.appServer).then(async () => {
426
488
  this.isLibraryLoaded = true;
427
489
  await this.updateComplete;
428
490
  const oldReference = this.renderRoot.querySelector("dashboard-component");
@@ -494,21 +556,11 @@ var LuzmoDashboard = class extends LitElement {
494
556
  "timezoneId",
495
557
  "itemDimensions"
496
558
  ]);
497
- const conditionsToCheck = ["dashboardId", "dashboardSlug", "itemId"];
498
- let callInitComponent = false;
499
- for (const condition of conditionsToCheck) {
500
- callInitComponent = callInitComponent || changedProperties.get(condition) === void 0 && this[condition];
501
- }
502
- if (callInitComponent && !this.isInitCalled) {
503
- this.initComponent();
504
- this.isInitCalled = true;
505
- return;
506
- }
507
559
  if (this.getIsViewMode()) {
508
560
  if (this.dashboardReference) {
509
561
  for (const [propertyName] of changedProperties.entries()) {
510
562
  if (propertyName === "appSever") {
511
- SharedLib2.loadLibrary(changedProperties[propertyName]).then(async () => {
563
+ this.loadLibrary(changedProperties[propertyName]).then(async () => {
512
564
  this.isLibraryLoaded = true;
513
565
  await this.updateComplete;
514
566
  this.dashboardReference = this.renderRoot.querySelector("dashboard-component");
@@ -716,7 +768,7 @@ var LuzmoDashboard = class extends LitElement {
716
768
  ${this.dashboardId || this.dashboardSlug ? html`
717
769
  ${loader}
718
770
  <iframe
719
- class="luzmo-embed-dashboard"
771
+ class="luzmo-embed-dashboard ${!this.getIsViewMode() ? `luzmo-embed-dashboard-ede` : ""}"
720
772
  id="${this._iframeId}"
721
773
  name="${this._iframeId}"
722
774
  style=${styleMap(this.iframeStyle)}
@@ -1007,7 +1059,7 @@ __decorateClass([
1007
1059
  ], LuzmoDashboard.prototype, "browserNotSupported", 2);
1008
1060
  __decorateClass([
1009
1061
  property()
1010
- ], LuzmoDashboard.prototype, "libVersion", 2);
1062
+ ], LuzmoDashboard.prototype, "VERSION", 2);
1011
1063
  __decorateClass([
1012
1064
  state()
1013
1065
  ], LuzmoDashboard.prototype, "isLibraryLoaded", 2);
@@ -1020,9 +1072,6 @@ __decorateClass([
1020
1072
  __decorateClass([
1021
1073
  state()
1022
1074
  ], LuzmoDashboard.prototype, "currentAuthToken", 2);
1023
- __decorateClass([
1024
- state()
1025
- ], LuzmoDashboard.prototype, "isInitCalled", 2);
1026
1075
 
1027
1076
  // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-web-component.ts
1028
1077
  var LuzmoDashboardWebComponent = class extends LuzmoDashboard {
@@ -1030,155 +1079,6 @@ var LuzmoDashboardWebComponent = class extends LuzmoDashboard {
1030
1079
  LuzmoDashboardWebComponent = __decorateClass([
1031
1080
  customElement("luzmo-dashboard-web-component")
1032
1081
  ], LuzmoDashboardWebComponent);
1033
-
1034
- // libs/embed-libs/embed/src/lib/viz-item/viz-item-web-component.ts
1035
- import { customElement as customElement2 } from "lit/decorators.js";
1036
-
1037
- // libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
1038
- import { property as property2 } from "lit/decorators.js";
1039
- import { LitElement as LitElement2, html as html2, css as css2 } from "lit";
1040
- import * as SharedLib3 from "@luzmo/shared-embed";
1041
- import { fromError } from "zod-validation-error";
1042
- var LuzmoBaseVizItem = class extends LitElement2 {
1043
- constructor() {
1044
- super();
1045
- this.appServer = "https://app.luzmo.com";
1046
- this.apiHost = "https://api.luzmo.com";
1047
- this.slots = [];
1048
- this.options = {
1049
- title: {
1050
- en: ""
1051
- },
1052
- theme: "default"
1053
- };
1054
- this.version = version + "-wc-luzmo";
1055
- }
1056
- static {
1057
- // Static styles to set host display to block, else it is not shown at all for some reason.
1058
- this.styles = css2`
1059
- :host {
1060
- display: block;
1061
- width: 100%;
1062
- height: 100%;
1063
- }
1064
- `;
1065
- }
1066
- async firstUpdated(_changedProperties) {
1067
- super.firstUpdated(_changedProperties);
1068
- if (this.type) {
1069
- await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
1070
- this.createAndAppendElement();
1071
- }
1072
- }
1073
- createAndAppendElement() {
1074
- if (!this.chartElement) {
1075
- this.chartElement = document.createElement("chart-component");
1076
- this.chartElement.setAttribute("embedding-mode", "chart");
1077
- this.updateVizItemProperties();
1078
- this.renderRoot.append(this.chartElement);
1079
- }
1080
- }
1081
- updateVizItemProperties() {
1082
- if (this.chartElement) {
1083
- for (const key in SharedLib3.libraryTypeToWebComponentTypeMapping) {
1084
- const value = this[key];
1085
- if (value) {
1086
- this.parseAndValidate(key);
1087
- const attributeValue = ["appServer", "apiHost"].includes(key) ? SharedLib3.removeTrailingSlash(value) : value;
1088
- this.chartElement.setAttribute(
1089
- SharedLib3.libraryTypeToWebComponentTypeMapping[key],
1090
- typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
1091
- );
1092
- }
1093
- }
1094
- }
1095
- }
1096
- async updated(changedProperties) {
1097
- if (this.chartElement) {
1098
- for (const [propertyName] of changedProperties.entries()) {
1099
- const mappedAttributeName = SharedLib3.libraryTypeToWebComponentTypeMapping[propertyName] ?? propertyName;
1100
- this.parseAndValidate(propertyName);
1101
- const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
1102
- this.chartElement.setAttribute(mappedAttributeName, attributeValue);
1103
- }
1104
- } else {
1105
- if (this.type) {
1106
- this.parseAndValidate("type");
1107
- await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
1108
- this.createAndAppendElement();
1109
- }
1110
- }
1111
- }
1112
- parseAndValidate(key) {
1113
- try {
1114
- if (key === "slots") {
1115
- SharedLib3.slotsParser.parse(this.slots);
1116
- } else if (key === "options") {
1117
- SharedLib3.vizItemOptionsParser.parse(this.options);
1118
- } else if (key === "canFilter") {
1119
- SharedLib3.canFilterParser.parse(this.canFilter);
1120
- } else if (key === "type") {
1121
- SharedLib3.itemTypeParser.parse(this.type);
1122
- }
1123
- } catch (err) {
1124
- const validationError = fromError(err);
1125
- console.error(err);
1126
- console.error(validationError.toString());
1127
- }
1128
- }
1129
- render() {
1130
- return html2` `;
1131
- }
1132
- };
1133
- __decorateClass([
1134
- property2()
1135
- ], LuzmoBaseVizItem.prototype, "appServer", 2);
1136
- __decorateClass([
1137
- property2()
1138
- ], LuzmoBaseVizItem.prototype, "apiHost", 2);
1139
- __decorateClass([
1140
- property2({ type: Array })
1141
- ], LuzmoBaseVizItem.prototype, "slots", 2);
1142
- __decorateClass([
1143
- property2({ type: Object })
1144
- ], LuzmoBaseVizItem.prototype, "options", 2);
1145
- __decorateClass([
1146
- property2()
1147
- ], LuzmoBaseVizItem.prototype, "type", 2);
1148
- __decorateClass([
1149
- property2()
1150
- ], LuzmoBaseVizItem.prototype, "authKey", 2);
1151
- __decorateClass([
1152
- property2()
1153
- ], LuzmoBaseVizItem.prototype, "authToken", 2);
1154
- __decorateClass([
1155
- property2()
1156
- ], LuzmoBaseVizItem.prototype, "version", 2);
1157
- __decorateClass([
1158
- property2()
1159
- ], LuzmoBaseVizItem.prototype, "contextId", 2);
1160
- __decorateClass([
1161
- property2({
1162
- converter: (value) => {
1163
- try {
1164
- return JSON.parse(value);
1165
- } catch (exc) {
1166
- return value;
1167
- }
1168
- }
1169
- })
1170
- ], LuzmoBaseVizItem.prototype, "canFilter", 2);
1171
- __decorateClass([
1172
- property2({ type: Array })
1173
- ], LuzmoBaseVizItem.prototype, "filters", 2);
1174
-
1175
- // libs/embed-libs/embed/src/lib/viz-item/viz-item-web-component.ts
1176
- var LuzmoVizItemWebComponent = class extends LuzmoBaseVizItem {
1177
- };
1178
- LuzmoVizItemWebComponent = __decorateClass([
1179
- customElement2("luzmo-viz-item-web-component")
1180
- ], LuzmoVizItemWebComponent);
1181
1082
  export {
1182
- LuzmoDashboardWebComponent,
1183
- LuzmoVizItemWebComponent
1083
+ LuzmoDashboardWebComponent
1184
1084
  };
@@ -51,12 +51,11 @@ export declare class LuzmoDashboard extends LitElement implements SharedLib.ES6L
51
51
  browserErrorMsg: string;
52
52
  dashboardError: boolean;
53
53
  browserNotSupported: any[];
54
- libVersion: string;
54
+ VERSION: string;
55
55
  protected isLibraryLoaded: boolean;
56
56
  protected dashboardReference: SharedLib.LuzmoElement;
57
57
  currentAuthKey: string;
58
58
  currentAuthToken: string;
59
- isInitCalled: boolean;
60
59
  private attributesMap;
61
60
  _loadTimeoutHandle?: number;
62
61
  _onResize: () => void;
@@ -66,7 +65,9 @@ export declare class LuzmoDashboard extends LitElement implements SharedLib.ES6L
66
65
  iframeHeight?: string;
67
66
  iframeWidth?: string;
68
67
  _resizeObserver: ResizeObserver;
69
- constructor();
68
+ constructor(inputParameters?: Record<keyof LuzmoDashboard, any>);
69
+ private loadLibrary;
70
+ private setInputParameters;
70
71
  connectedCallback(): void;
71
72
  disconnectedCallback(): void;
72
73
  firstUpdated(): void;