@veloceapps/sdk 2.0.7 → 2.0.8

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.
@@ -632,6 +632,7 @@
632
632
  REFERENCE: {
633
633
  component: exports.ElementComponent,
634
634
  plugins: [IOPlugin],
635
+ suppressTemplate: true,
635
636
  },
636
637
  };
637
638
 
@@ -644,7 +645,7 @@
644
645
  var styles = el.styles && window.atob(el.styles);
645
646
  var exportedClassName = script && ((_a = EXPORTED_CLASS_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
646
647
  if (!exportedClassName) {
647
- console.error("Script doesn't have exported class");
648
+ throw new Error("Script doesn't have exported class");
648
649
  }
649
650
  var elementMetadata = extractElementMetadata(script || '');
650
651
  var path = (parentPath ? parentPath + '/' : '') + elementMetadata.name;
@@ -653,6 +654,7 @@
653
654
  var metadataToElement = function (metadata) {
654
655
  var elMetadata = {
655
656
  name: metadata.name,
657
+ isShared: metadata.isShared,
656
658
  type: metadata.type,
657
659
  model: metadata.model,
658
660
  module: metadata.module,
@@ -664,6 +666,9 @@
664
666
  return name;
665
667
  }),
666
668
  };
669
+ if (!metadata.script || !EXPORTED_CLASS_REGEX.test(metadata.script)) {
670
+ throw new Error("'" + metadata.name + "' element script doesn't have exported class");
671
+ }
667
672
  var script = metadata.script &&
668
673
  window.btoa(metadata.script.replace(EXPORTED_CLASS_REGEX, "@ElementDefinition(" + JSON.stringify(elMetadata) + ") export class Script"));
669
674
  var template = metadata.template && window.btoa(metadata.template);
@@ -1570,13 +1575,13 @@
1570
1575
  return lodash.flatten(elements.map(function (el) { return __spreadArray([el], __read(_this.flattenElements(el.children))); }));
1571
1576
  };
1572
1577
  ElementsResolver.prototype.isSharedElement = function (el) {
1573
- return Boolean(el.reference) && el.type !== 'REFERENCE';
1578
+ return Boolean(el.isShared) && el.type !== 'REFERENCE';
1574
1579
  };
1575
1580
  ElementsResolver.prototype.getSharedElement = function (element) {
1576
1581
  if (element.type !== 'REFERENCE') {
1577
1582
  return;
1578
1583
  }
1579
- return this.sharedElements.find(function (el) { return element.reference === el.reference; });
1584
+ return this.sharedElements.find(function (el) { return element.reference === el.name; });
1580
1585
  };
1581
1586
  ElementsResolver.prototype.resolveElementTemplate = function (element) {
1582
1587
  var config = CONFIG[element.type];
@@ -1878,13 +1883,23 @@
1878
1883
  .initTestMode(this.modelId, uiDefinitionProps)
1879
1884
  .pipe(rxjs.switchMap(function () { return _this.configurationService.configure(); }));
1880
1885
  };
1886
+ PreviewComponent.prototype.elementToMetadataSafe = function (elements) {
1887
+ try {
1888
+ return elements.map(function (element) { return elementToMetadata(element); });
1889
+ }
1890
+ catch (e) {
1891
+ console.error(e);
1892
+ this.messageService.add({ severity: 'error', summary: String(e) });
1893
+ return [];
1894
+ }
1895
+ };
1881
1896
  PreviewComponent.prototype.startPreview = function () {
1882
1897
  var _this = this;
1883
1898
  if (!this.uiDefinition) {
1884
1899
  return;
1885
1900
  }
1886
1901
  var _a = this.uiDefinition, children = _a.children, uiDefinitionMeta = __rest(_a, ["children"]);
1887
- this.elements = children.map(function (child) { return elementToMetadata(child); });
1902
+ this.elements = this.elementToMetadataSafe(children);
1888
1903
  var compilation$ = this.launcherService.compileModule(this.elements, uiDefinitionMeta);
1889
1904
  rxjs.forkJoin([compilation$, this.initializeConfiguration$()])
1890
1905
  .pipe(rxjs.tap(function () { return _this.state$.next({ loading: false, failure: false }); }), rxjs.catchError(function (error) {