@veloceapps/sdk 5.0.9 → 5.0.10

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.
@@ -1519,30 +1519,14 @@
1519
1519
 
1520
1520
  var ElementsResolver = /** @class */ (function () {
1521
1521
  function ElementsResolver(uiDef, elements) {
1522
- var e_1, _c;
1522
+ var _this = this;
1523
1523
  this.uiDef = uiDef;
1524
1524
  this.renderableElements = [];
1525
1525
  this.sharedElements = [];
1526
- this.elements = this.transpileScripts(elements);
1527
- var flatElements = this.flattenElements(this.elements);
1528
- try {
1529
- for (var flatElements_1 = __values(flatElements), flatElements_1_1 = flatElements_1.next(); !flatElements_1_1.done; flatElements_1_1 = flatElements_1.next()) {
1530
- var el = flatElements_1_1.value;
1531
- if (this.isSharedElement(el)) {
1532
- this.sharedElements.push(el);
1533
- }
1534
- else {
1535
- this.renderableElements.push(el);
1536
- }
1537
- }
1538
- }
1539
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1540
- finally {
1541
- try {
1542
- if (flatElements_1_1 && !flatElements_1_1.done && (_c = flatElements_1.return)) _c.call(flatElements_1);
1543
- }
1544
- finally { if (e_1) throw e_1.error; }
1545
- }
1526
+ var transpiledElements = this.transpileScripts(elements);
1527
+ this.sharedElements = this.flattenElements(transpiledElements).filter(function (el) { return _this.isSharedElement(el); });
1528
+ this.elements = transpiledElements.map(function (el) { return _this.processElementMetadata(el); }).filter(Boolean);
1529
+ this.renderableElements = this.getRenderableElements(this.elements);
1546
1530
  }
1547
1531
  ElementsResolver.prototype.getNgComponents = function () {
1548
1532
  var _this = this;
@@ -1571,8 +1555,31 @@
1571
1555
  ElementsResolver.prototype.isSharedElement = function (el) {
1572
1556
  return Boolean(el.isShared) && el.type !== 'REFERENCE';
1573
1557
  };
1558
+ ElementsResolver.prototype.getRenderableElements = function (elements) {
1559
+ var e_1, _c;
1560
+ var _this = this;
1561
+ var renderable = [];
1562
+ try {
1563
+ for (var elements_1 = __values(elements), elements_1_1 = elements_1.next(); !elements_1_1.done; elements_1_1 = elements_1.next()) {
1564
+ var el = elements_1_1.value;
1565
+ if (!this.isSharedElement(el)) {
1566
+ var children = el.children.filter(function (child) { return !_this.isSharedElement(child); });
1567
+ var renderableChildren = this.getRenderableElements(children);
1568
+ renderable.push.apply(renderable, __spreadArray([Object.assign(Object.assign({}, el), { children: children })], __read(renderableChildren)));
1569
+ }
1570
+ }
1571
+ }
1572
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1573
+ finally {
1574
+ try {
1575
+ if (elements_1_1 && !elements_1_1.done && (_c = elements_1.return)) _c.call(elements_1);
1576
+ }
1577
+ finally { if (e_1) throw e_1.error; }
1578
+ }
1579
+ return renderable;
1580
+ };
1574
1581
  ElementsResolver.prototype.getSharedElement = function (element) {
1575
- if (element.type !== 'REFERENCE') {
1582
+ if (!element.reference) {
1576
1583
  return;
1577
1584
  }
1578
1585
  return this.sharedElements.find(function (el) { return element.reference === el.name; });
@@ -1588,29 +1595,40 @@
1588
1595
  return !config.suppressStyles ? (_a = element.styles) !== null && _a !== void 0 ? _a : '' : '';
1589
1596
  };
1590
1597
  ElementsResolver.prototype.processElementMetadata = function (sourceElement) {
1598
+ var _this = this;
1591
1599
  var _a, _b;
1592
- var sharedElement = this.getSharedElement(sourceElement);
1593
1600
  var finalElement;
1594
1601
  if (sourceElement.type === 'REFERENCE') {
1602
+ var sharedElement = this.getSharedElement(sourceElement);
1595
1603
  if (!sharedElement) {
1596
1604
  console.warn("Shared element \"" + sourceElement.reference + "\" not found");
1597
1605
  return;
1598
1606
  }
1599
- finalElement = Object.assign(Object.assign({}, sourceElement), { type: sharedElement.type, template: sharedElement.template, styles: ((_a = sharedElement.styles) !== null && _a !== void 0 ? _a : '') + '\n' + ((_b = sourceElement.styles) !== null && _b !== void 0 ? _b : ''), inputs: Object.assign(Object.assign({}, sharedElement.inputs), sourceElement.inputs), outputs: Object.assign(Object.assign({}, sharedElement.outputs), sourceElement.outputs) });
1607
+ finalElement = Object.assign(Object.assign({}, sourceElement), { children: this.getSharedChildren(sharedElement.children, sourceElement.path), type: sharedElement.type, template: sharedElement.template, styles: ((_a = sharedElement.styles) !== null && _a !== void 0 ? _a : '') + '\n' + ((_b = sourceElement.styles) !== null && _b !== void 0 ? _b : ''), inputs: Object.assign(Object.assign({}, sharedElement.inputs), sourceElement.inputs), outputs: Object.assign(Object.assign({}, sharedElement.outputs), sourceElement.outputs) });
1600
1608
  }
1601
1609
  else {
1602
1610
  finalElement = sourceElement;
1611
+ delete sourceElement.reference;
1603
1612
  }
1604
1613
  finalElement.template = this.resolveElementTemplate(finalElement);
1605
1614
  finalElement.styles = this.resolveElementStyles(finalElement);
1606
- return finalElement;
1615
+ return Object.assign(Object.assign({}, finalElement), { children: finalElement.children
1616
+ .map(function (child) { return _this.processElementMetadata(child); })
1617
+ .filter(Boolean) });
1607
1618
  };
1608
- ElementsResolver.prototype.resolveElement = function (sourceElement) {
1619
+ ElementsResolver.prototype.getSharedChildren = function (children, parentPath) {
1620
+ var _this = this;
1621
+ return children.map(function (c) {
1622
+ if (!c.path) {
1623
+ return c;
1624
+ }
1625
+ var _c = __read(c.path.split('/').reverse(), 1), elName = _c[0];
1626
+ var path = parentPath + '/' + elName;
1627
+ return Object.assign(Object.assign({}, c), { path: path, children: _this.getSharedChildren(c.children, path) });
1628
+ });
1629
+ };
1630
+ ElementsResolver.prototype.resolveElement = function (element) {
1609
1631
  var _a;
1610
- var element = this.processElementMetadata(sourceElement);
1611
- if (!element) {
1612
- return;
1613
- }
1614
1632
  var config = CONFIG[element.type];
1615
1633
  var defaultPlugins = (_a = DEFAULT_PLUGINS[this.uiDef.type]) !== null && _a !== void 0 ? _a : [];
1616
1634
  if (!config) {
@@ -1626,7 +1644,7 @@
1626
1644
  { provide: DEFAULT_PLUGINS_TOKEN, useValue: defaultPlugins },
1627
1645
  { provide: UI_DEFINITION_METADATA, useValue: this.uiDef },
1628
1646
  { provide: ELEMENT_METADATA, useValue: element },
1629
- { provide: SHARED_ELEMENT_METADATA, useValue: this.getSharedElement(sourceElement) },
1647
+ { provide: SHARED_ELEMENT_METADATA, useValue: this.getSharedElement(element) },
1630
1648
  { provide: ELEMENT_CONFIG, useValue: config },
1631
1649
  { provide: VENDOR_MAP, useValue: vendorMap },
1632
1650
  ] });
@@ -1661,13 +1679,15 @@
1661
1679
  this.compiler = compiler;
1662
1680
  this.dynamicModuleService = dynamicModuleService;
1663
1681
  }
1664
- LauncherService.prototype.compileModule = function (elements, uiDefs) {
1682
+ LauncherService.prototype.compileModule = function (uiDef, elements) {
1665
1683
  var _this = this;
1666
- this.module = this.getModule(elements, uiDefs);
1684
+ var elementsResolver = new ElementsResolver(uiDef, elements);
1685
+ this.dynamicModuleService.elementsTree = elementsResolver.elements;
1686
+ this.module = this.getModule(elementsResolver.getNgComponents());
1667
1687
  return rxjs.from(this.compiler.compileModuleAndAllComponentsAsync(this.module)).pipe(rxjs.tap(function (m) {
1668
1688
  _this.dynamicModuleService.componentFactories = m.componentFactories;
1669
1689
  _this.moduleInstance = m;
1670
- }));
1690
+ }), rxjs.map(function (m) { return ({ module: m, elements: elementsResolver.elements }); }));
1671
1691
  };
1672
1692
  LauncherService.prototype.destroy = function () {
1673
1693
  if (this.moduleInstance) {
@@ -1679,10 +1699,8 @@
1679
1699
  this.module = undefined;
1680
1700
  }
1681
1701
  };
1682
- LauncherService.prototype.getModule = function (elements, uiDef) {
1702
+ LauncherService.prototype.getModule = function (components) {
1683
1703
  var staticComponents = [ElementChildrenComponent, ElementRendererComponent, CustomTemplateDirective];
1684
- var elementsResolver = new ElementsResolver(uiDef, elements);
1685
- this.dynamicModuleService.elementsTree = elementsResolver.elements;
1686
1704
  var DynamicModule = /** @class */ (function () {
1687
1705
  function DynamicModule() {
1688
1706
  }
@@ -1691,7 +1709,7 @@
1691
1709
  DynamicModule = __decorate([
1692
1710
  i0.NgModule({
1693
1711
  imports: [i7.CommonModule, angularForms.FormsModule, angularForms.ReactiveFormsModule, FederatedModule, dragDrop.DragDropModule],
1694
- declarations: __spreadArray(__spreadArray([], __read(staticComponents)), __read(elementsResolver.getNgComponents())),
1712
+ declarations: __spreadArray(__spreadArray([], __read(staticComponents)), __read(components)),
1695
1713
  jit: true,
1696
1714
  })
1697
1715
  ], DynamicModule);
@@ -1762,10 +1780,14 @@
1762
1780
  return;
1763
1781
  }
1764
1782
  var _a = this.uiDefinition, children = _a.children, uiDefinitionMeta = __rest(_a, ["children"]);
1765
- this.elements = this.elementToMetadataSafe(children);
1766
- var compilation$ = this.launcherService.compileModule(this.elements, uiDefinitionMeta);
1783
+ var elements = this.elementToMetadataSafe(children);
1784
+ var compilation$ = this.launcherService.compileModule(uiDefinitionMeta, elements);
1767
1785
  rxjs.forkJoin([compilation$, this.initializeConfiguration$()])
1768
- .pipe(rxjs.tap(function () { return _this.state$.next({ loading: false, failure: false }); }), rxjs.catchError(function (error) {
1786
+ .pipe(rxjs.tap(function (_c) {
1787
+ var _d = __read(_c, 1), result = _d[0];
1788
+ _this.elements = result.elements;
1789
+ _this.state$.next({ loading: false, failure: false });
1790
+ }), rxjs.catchError(function (error) {
1769
1791
  var _a, _b;
1770
1792
  console.error(error);
1771
1793
  if (!((_b = (_a = _this.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.suppressToastMessages)) {