@luzmo/embed 6.0.0-beta.7 → 6.0.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/CHANGELOG.md +9 -1
- package/MIGRATIONS.md +1 -1
- package/README.md +14 -120
- package/index.cjs +37 -223
- package/index.d.ts +1 -3
- package/index.js +39 -222
- package/lib/dashboard-component/dashboard-base.d.ts +2 -1
- package/luzmo-embed.min.js +1372 -5918
- package/package.json +2 -3
- package/src/index.d.ts +1 -3
- package/src/lib/dashboard-component/dashboard-base.d.ts +2 -1
- package/lib/viz-item/viz-item-component.d.ts +0 -3
- package/lib/viz-item/viz-item.base.d.ts +0 -41
- package/src/lib/viz-item/viz-item-component.d.ts +0 -3
- package/src/lib/viz-item/viz-item.base.d.ts +0 -41
package/index.js
CHANGED
|
@@ -10,9 +10,6 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
10
10
|
return result;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
// libs/embed-libs/embed/src/index.ts
|
|
14
|
-
import { filterUtils } from "@luzmo/shared-embed";
|
|
15
|
-
|
|
16
13
|
// libs/embed-libs/embed/src/lib/dashboard-component/dashboard-component.ts
|
|
17
14
|
import {
|
|
18
15
|
customElement
|
|
@@ -33,11 +30,14 @@ import {
|
|
|
33
30
|
styleMap
|
|
34
31
|
} from "lit/directives/style-map.js";
|
|
35
32
|
import {
|
|
33
|
+
__federationMethodGetRemote,
|
|
34
|
+
__federationMethodWrapDefault,
|
|
35
|
+
remotesMap,
|
|
36
36
|
luzmoEmbedContainerClass
|
|
37
37
|
} from "@luzmo/shared-embed";
|
|
38
38
|
|
|
39
39
|
// libs/embed-libs/embed/package.json
|
|
40
|
-
var version = "6.0.0
|
|
40
|
+
var version = "6.0.0";
|
|
41
41
|
|
|
42
42
|
// libs/embed-libs/embed/src/lib/luzmo-service.ts
|
|
43
43
|
var LuzmoService = class {
|
|
@@ -342,7 +342,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
342
342
|
this.browserErrorMsg = "";
|
|
343
343
|
this.dashboardError = false;
|
|
344
344
|
this.browserNotSupported = [];
|
|
345
|
-
this.
|
|
345
|
+
this.VERSION = version + "-wc-luzmo";
|
|
346
346
|
this.isLibraryLoaded = false;
|
|
347
347
|
this.currentAuthKey = null;
|
|
348
348
|
this.currentAuthToken = null;
|
|
@@ -406,6 +406,22 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
406
406
|
});
|
|
407
407
|
});
|
|
408
408
|
}
|
|
409
|
+
loadLibrary(appServer) {
|
|
410
|
+
if (remotesMap[appServer]) {
|
|
411
|
+
return Promise.resolve(remotesMap[appServer].module);
|
|
412
|
+
}
|
|
413
|
+
remotesMap[appServer] = {
|
|
414
|
+
url: appServer?.startsWith("http://localhost") ? `${SharedLib2.removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${SharedLib2.removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`,
|
|
415
|
+
format: "esm",
|
|
416
|
+
from: "vite",
|
|
417
|
+
module: void 0
|
|
418
|
+
};
|
|
419
|
+
return __federationMethodGetRemote(appServer, "./DashboardApp").then((module) => {
|
|
420
|
+
const wrappedModule = __federationMethodWrapDefault(module, true);
|
|
421
|
+
remotesMap[appServer].module = wrappedModule;
|
|
422
|
+
return wrappedModule;
|
|
423
|
+
});
|
|
424
|
+
}
|
|
409
425
|
// Set resize event listener
|
|
410
426
|
connectedCallback() {
|
|
411
427
|
super.connectedCallback();
|
|
@@ -431,7 +447,9 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
431
447
|
initComponent() {
|
|
432
448
|
this.params = this._setOptions();
|
|
433
449
|
if (this.getIsViewMode()) {
|
|
434
|
-
|
|
450
|
+
this._setupLoader();
|
|
451
|
+
this._loaderStyles();
|
|
452
|
+
this.loadLibrary(this.params.appServer).then(async () => {
|
|
435
453
|
this.isLibraryLoaded = true;
|
|
436
454
|
await this.updateComplete;
|
|
437
455
|
const oldReference = this.renderRoot.querySelector("dashboard-component");
|
|
@@ -471,18 +489,18 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
471
489
|
if (!["authKey", "authToken", "apiHost", "itemDimensions"].includes(key) && this.params[key]) {
|
|
472
490
|
this.dashboardReference.setAttribute(this.attributesMap[key], this.params[key]);
|
|
473
491
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
492
|
+
}
|
|
493
|
+
if (this.params.itemDimensions) {
|
|
494
|
+
this.dashboardReference.setAttribute("item-dimensions", JSON.stringify(this.params.itemDimensions));
|
|
495
|
+
}
|
|
496
|
+
if (this.params.apiHost) {
|
|
497
|
+
this.dashboardReference.setAttribute("api-host", SharedLib2.removeTrailingSlash(this.params.apiHost));
|
|
498
|
+
}
|
|
499
|
+
if (this.params.key) {
|
|
500
|
+
this.dashboardReference.setAttribute("auth-key", this.params.key);
|
|
501
|
+
}
|
|
502
|
+
if (this.params.token) {
|
|
503
|
+
this.dashboardReference.setAttribute("auth-token", this.params.token);
|
|
486
504
|
}
|
|
487
505
|
}
|
|
488
506
|
}
|
|
@@ -517,7 +535,7 @@ var LuzmoDashboard = class extends LitElement {
|
|
|
517
535
|
if (this.dashboardReference) {
|
|
518
536
|
for (const [propertyName] of changedProperties.entries()) {
|
|
519
537
|
if (propertyName === "appSever") {
|
|
520
|
-
|
|
538
|
+
this.loadLibrary(changedProperties[propertyName]).then(async () => {
|
|
521
539
|
this.isLibraryLoaded = true;
|
|
522
540
|
await this.updateComplete;
|
|
523
541
|
this.dashboardReference = this.renderRoot.querySelector("dashboard-component");
|
|
@@ -1016,7 +1034,7 @@ __decorateClass([
|
|
|
1016
1034
|
], LuzmoDashboard.prototype, "browserNotSupported", 2);
|
|
1017
1035
|
__decorateClass([
|
|
1018
1036
|
property()
|
|
1019
|
-
], LuzmoDashboard.prototype, "
|
|
1037
|
+
], LuzmoDashboard.prototype, "VERSION", 2);
|
|
1020
1038
|
__decorateClass([
|
|
1021
1039
|
state()
|
|
1022
1040
|
], LuzmoDashboard.prototype, "isLibraryLoaded", 2);
|
|
@@ -1039,207 +1057,6 @@ var LuzmoEmbedDashboard = class extends LuzmoDashboard {
|
|
|
1039
1057
|
LuzmoEmbedDashboard = __decorateClass([
|
|
1040
1058
|
customElement("luzmo-embed-dashboard")
|
|
1041
1059
|
], LuzmoEmbedDashboard);
|
|
1042
|
-
|
|
1043
|
-
// libs/embed-libs/embed/src/lib/viz-item/viz-item-component.ts
|
|
1044
|
-
import { customElement as customElement2 } from "lit/decorators.js";
|
|
1045
|
-
|
|
1046
|
-
// libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
|
|
1047
|
-
import { property as property2 } from "lit/decorators.js";
|
|
1048
|
-
import { LitElement as LitElement2, html as html2, css as css2 } from "lit";
|
|
1049
|
-
import * as SharedLib3 from "@luzmo/shared-embed";
|
|
1050
|
-
import { fromError } from "zod-validation-error";
|
|
1051
|
-
var LuzmoBaseVizItem = class extends LitElement2 {
|
|
1052
|
-
constructor() {
|
|
1053
|
-
super();
|
|
1054
|
-
this.appServer = "https://app.luzmo.com";
|
|
1055
|
-
this.apiHost = "https://api.luzmo.com";
|
|
1056
|
-
this.slots = [];
|
|
1057
|
-
this.version = version + "-wc-luzmo";
|
|
1058
|
-
this.libVersion = version + "-wc-luzmo";
|
|
1059
|
-
this.postInitCallQueue = [];
|
|
1060
|
-
}
|
|
1061
|
-
static {
|
|
1062
|
-
// Static styles to set host display to block, else it is not shown at all for some reason.
|
|
1063
|
-
this.styles = css2`
|
|
1064
|
-
:host {
|
|
1065
|
-
display: block;
|
|
1066
|
-
width: 100%;
|
|
1067
|
-
height: 100%;
|
|
1068
|
-
}
|
|
1069
|
-
`;
|
|
1070
|
-
}
|
|
1071
|
-
canInitializeVizItem() {
|
|
1072
|
-
return !!(this.type || this.dashboardId && this.itemId);
|
|
1073
|
-
}
|
|
1074
|
-
getFilters() {
|
|
1075
|
-
return this.chartElement.getFilters();
|
|
1076
|
-
}
|
|
1077
|
-
export() {
|
|
1078
|
-
return this.chartElement.export();
|
|
1079
|
-
}
|
|
1080
|
-
getData() {
|
|
1081
|
-
return this.chartElement.getData();
|
|
1082
|
-
}
|
|
1083
|
-
refreshData() {
|
|
1084
|
-
return this.chartElement.refreshData();
|
|
1085
|
-
}
|
|
1086
|
-
setFilters(filterInput) {
|
|
1087
|
-
return this.chartElement.setFilters(void 0, filterInput);
|
|
1088
|
-
}
|
|
1089
|
-
setAuthorization(key, token) {
|
|
1090
|
-
return this.chartElement.setAuthorization(key, token);
|
|
1091
|
-
}
|
|
1092
|
-
attributeChangedCallback(name, _old, value) {
|
|
1093
|
-
super.attributeChangedCallback(name, _old, value);
|
|
1094
|
-
if (name === "selecteddata") {
|
|
1095
|
-
if (this.chartElement) {
|
|
1096
|
-
this.setFilters(JSON.parse(value ?? "{}"));
|
|
1097
|
-
} else {
|
|
1098
|
-
this.postInitCallQueue.push([this.setFilters, [JSON.parse(value ?? "{}")]]);
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
async firstUpdated(_changedProperties) {
|
|
1103
|
-
super.firstUpdated(_changedProperties);
|
|
1104
|
-
if (this.canInitializeVizItem()) {
|
|
1105
|
-
await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
|
|
1106
|
-
this.createAndAppendElement();
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
createAndAppendElement() {
|
|
1110
|
-
if (!this.chartElement) {
|
|
1111
|
-
this.chartElement = document.createElement("chart-component");
|
|
1112
|
-
this.chartElement.setAttribute("embedding-mode", "chart");
|
|
1113
|
-
this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
|
|
1114
|
-
this.chartElement.addEventListener("rendered", (payload) => {
|
|
1115
|
-
for (const functionToCall of this.postInitCallQueue) {
|
|
1116
|
-
functionToCall[0].bind(this)(...functionToCall[1]);
|
|
1117
|
-
}
|
|
1118
|
-
this.dispatchEvent(new CustomEvent("rendered", payload));
|
|
1119
|
-
});
|
|
1120
|
-
this.chartElement.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
|
|
1121
|
-
this.chartElement.addEventListener("exported", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
|
|
1122
|
-
this.chartElement.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
|
|
1123
|
-
this.updateVizItemProperties();
|
|
1124
|
-
this.renderRoot.append(this.chartElement);
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
updateVizItemProperties() {
|
|
1128
|
-
if (this.chartElement) {
|
|
1129
|
-
for (const key in SharedLib3.libraryTypeToWebComponentTypeMapping) {
|
|
1130
|
-
const value = this[key];
|
|
1131
|
-
if (value) {
|
|
1132
|
-
this.parseAndValidate(key);
|
|
1133
|
-
const attributeValue = ["appServer", "apiHost"].includes(key) ? SharedLib3.removeTrailingSlash(value) : value;
|
|
1134
|
-
this.chartElement.setAttribute(
|
|
1135
|
-
SharedLib3.libraryTypeToWebComponentTypeMapping[key],
|
|
1136
|
-
typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
|
|
1137
|
-
);
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
async updated(changedProperties) {
|
|
1143
|
-
if (this.chartElement) {
|
|
1144
|
-
for (const [propertyName] of changedProperties.entries()) {
|
|
1145
|
-
const mappedAttributeName = SharedLib3.libraryTypeToWebComponentTypeMapping[propertyName] ?? propertyName;
|
|
1146
|
-
this.parseAndValidate(propertyName);
|
|
1147
|
-
const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
|
|
1148
|
-
this.chartElement.setAttribute(mappedAttributeName, attributeValue);
|
|
1149
|
-
}
|
|
1150
|
-
} else {
|
|
1151
|
-
if (this.canInitializeVizItem()) {
|
|
1152
|
-
if (this.type) {
|
|
1153
|
-
this.parseAndValidate("type");
|
|
1154
|
-
}
|
|
1155
|
-
await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
|
|
1156
|
-
this.createAndAppendElement();
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
parseAndValidate(key) {
|
|
1161
|
-
try {
|
|
1162
|
-
if (key === "slots") {
|
|
1163
|
-
SharedLib3.slotsParser.parse(this.slots);
|
|
1164
|
-
} else if (key === "options") {
|
|
1165
|
-
SharedLib3.vizItemOptionsParser.parse(this.options);
|
|
1166
|
-
} else if (key === "canFilter") {
|
|
1167
|
-
SharedLib3.canFilterParser.parse(this.canFilter);
|
|
1168
|
-
} else if (key === "type") {
|
|
1169
|
-
SharedLib3.itemTypeParser.parse(this.type);
|
|
1170
|
-
}
|
|
1171
|
-
} catch (err) {
|
|
1172
|
-
const validationError = fromError(err);
|
|
1173
|
-
console.warn(err);
|
|
1174
|
-
console.warn(validationError.toString());
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
render() {
|
|
1178
|
-
return html2` `;
|
|
1179
|
-
}
|
|
1180
|
-
};
|
|
1181
|
-
__decorateClass([
|
|
1182
|
-
property2()
|
|
1183
|
-
], LuzmoBaseVizItem.prototype, "appServer", 2);
|
|
1184
|
-
__decorateClass([
|
|
1185
|
-
property2()
|
|
1186
|
-
], LuzmoBaseVizItem.prototype, "apiHost", 2);
|
|
1187
|
-
__decorateClass([
|
|
1188
|
-
property2({ type: Array })
|
|
1189
|
-
], LuzmoBaseVizItem.prototype, "slots", 2);
|
|
1190
|
-
__decorateClass([
|
|
1191
|
-
property2({ type: Object })
|
|
1192
|
-
], LuzmoBaseVizItem.prototype, "options", 2);
|
|
1193
|
-
__decorateClass([
|
|
1194
|
-
property2()
|
|
1195
|
-
], LuzmoBaseVizItem.prototype, "type", 2);
|
|
1196
|
-
__decorateClass([
|
|
1197
|
-
property2()
|
|
1198
|
-
], LuzmoBaseVizItem.prototype, "authKey", 2);
|
|
1199
|
-
__decorateClass([
|
|
1200
|
-
property2()
|
|
1201
|
-
], LuzmoBaseVizItem.prototype, "authToken", 2);
|
|
1202
|
-
__decorateClass([
|
|
1203
|
-
property2()
|
|
1204
|
-
], LuzmoBaseVizItem.prototype, "version", 2);
|
|
1205
|
-
__decorateClass([
|
|
1206
|
-
property2()
|
|
1207
|
-
], LuzmoBaseVizItem.prototype, "contextId", 2);
|
|
1208
|
-
__decorateClass([
|
|
1209
|
-
property2({
|
|
1210
|
-
converter: (value) => {
|
|
1211
|
-
try {
|
|
1212
|
-
return JSON.parse(value);
|
|
1213
|
-
} catch (exc) {
|
|
1214
|
-
return value;
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
})
|
|
1218
|
-
], LuzmoBaseVizItem.prototype, "canFilter", 2);
|
|
1219
|
-
__decorateClass([
|
|
1220
|
-
property2({ type: Array })
|
|
1221
|
-
], LuzmoBaseVizItem.prototype, "filters", 2);
|
|
1222
|
-
__decorateClass([
|
|
1223
|
-
property2()
|
|
1224
|
-
], LuzmoBaseVizItem.prototype, "dashboardId", 2);
|
|
1225
|
-
__decorateClass([
|
|
1226
|
-
property2()
|
|
1227
|
-
], LuzmoBaseVizItem.prototype, "itemId", 2);
|
|
1228
|
-
__decorateClass([
|
|
1229
|
-
property2({ type: Object })
|
|
1230
|
-
], LuzmoBaseVizItem.prototype, "selectedData", 2);
|
|
1231
|
-
__decorateClass([
|
|
1232
|
-
property2()
|
|
1233
|
-
], LuzmoBaseVizItem.prototype, "libVersion", 2);
|
|
1234
|
-
|
|
1235
|
-
// libs/embed-libs/embed/src/lib/viz-item/viz-item-component.ts
|
|
1236
|
-
var LuzmoEmbedVizItem = class extends LuzmoBaseVizItem {
|
|
1237
|
-
};
|
|
1238
|
-
LuzmoEmbedVizItem = __decorateClass([
|
|
1239
|
-
customElement2("luzmo-embed-viz-item")
|
|
1240
|
-
], LuzmoEmbedVizItem);
|
|
1241
1060
|
export {
|
|
1242
|
-
LuzmoEmbedDashboard
|
|
1243
|
-
LuzmoEmbedVizItem,
|
|
1244
|
-
filterUtils
|
|
1061
|
+
LuzmoEmbedDashboard
|
|
1245
1062
|
};
|
|
@@ -51,7 +51,7 @@ export declare class LuzmoDashboard extends LitElement implements SharedLib.ES6L
|
|
|
51
51
|
browserErrorMsg: string;
|
|
52
52
|
dashboardError: boolean;
|
|
53
53
|
browserNotSupported: any[];
|
|
54
|
-
|
|
54
|
+
VERSION: string;
|
|
55
55
|
protected isLibraryLoaded: boolean;
|
|
56
56
|
protected dashboardReference: SharedLib.LuzmoElement;
|
|
57
57
|
currentAuthKey: string;
|
|
@@ -67,6 +67,7 @@ export declare class LuzmoDashboard extends LitElement implements SharedLib.ES6L
|
|
|
67
67
|
iframeWidth?: string;
|
|
68
68
|
_resizeObserver: ResizeObserver;
|
|
69
69
|
constructor();
|
|
70
|
+
private loadLibrary;
|
|
70
71
|
connectedCallback(): void;
|
|
71
72
|
disconnectedCallback(): void;
|
|
72
73
|
firstUpdated(): void;
|