@veloceapps/sdk 6.0.0-4 → 6.0.0-40

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.
Files changed (221) hide show
  1. package/bundles/veloceapps-sdk-cms.umd.js +1409 -822
  2. package/bundles/veloceapps-sdk-cms.umd.js.map +1 -1
  3. package/bundles/veloceapps-sdk-core.umd.js +735 -610
  4. package/bundles/veloceapps-sdk-core.umd.js.map +1 -1
  5. package/bundles/veloceapps-sdk-runtime.umd.js +209 -142
  6. package/bundles/veloceapps-sdk-runtime.umd.js.map +1 -1
  7. package/bundles/veloceapps-sdk.umd.js +361 -298
  8. package/bundles/veloceapps-sdk.umd.js.map +1 -1
  9. package/cms/components/element-children/element-children.component.d.ts +13 -3
  10. package/cms/components/element-children/element-children.module.d.ts +4 -2
  11. package/cms/components/element-drop-handle/element-drop-handle.component.d.ts +12 -0
  12. package/cms/components/element-drop-handle/element-drop-handle.module.d.ts +9 -0
  13. package/cms/components/element-renderer/element-renderer.component.d.ts +3 -3
  14. package/cms/components/preview/index.d.ts +1 -0
  15. package/cms/components/preview/preview.component.d.ts +9 -8
  16. package/cms/components/preview/preview.module.d.ts +2 -1
  17. package/cms/components/preview/preview.types.d.ts +11 -0
  18. package/cms/index.d.ts +2 -0
  19. package/cms/launcher.module.d.ts +3 -1
  20. package/cms/modules/migrations/index.d.ts +2 -0
  21. package/cms/modules/migrations/migrations.d.ts +2 -0
  22. package/cms/modules/migrations/migrations.module.d.ts +6 -0
  23. package/cms/modules/migrations/services/migrations.service.d.ts +10 -0
  24. package/cms/modules/migrations/types/migrations.types.d.ts +2 -0
  25. package/cms/modules/runtime/index.d.ts +2 -0
  26. package/cms/modules/runtime/runtime.module.d.ts +8 -0
  27. package/cms/modules/runtime/services/compilation.service.d.ts +18 -0
  28. package/cms/modules/runtime/services/runtime-editor.service.d.ts +18 -0
  29. package/cms/modules/runtime/services/runtime.service.d.ts +27 -0
  30. package/cms/modules/runtime/tokens.d.ts +3 -0
  31. package/cms/{types → modules/runtime/types}/compilation.types.d.ts +1 -1
  32. package/cms/modules/runtime/types/runtime.actions.d.ts +9 -0
  33. package/cms/plugins/element-hover.plugin.d.ts +32 -0
  34. package/cms/services/index.d.ts +0 -1
  35. package/cms/services/io-provider.service.d.ts +3 -3
  36. package/cms/types/common.types.d.ts +1 -1
  37. package/cms/types/configuration.types.d.ts +1 -0
  38. package/cms/types/index.d.ts +1 -1
  39. package/cms/utils/elements-resolver.d.ts +3 -2
  40. package/cms/utils/index.d.ts +1 -0
  41. package/cms/utils/path.utils.d.ts +0 -1
  42. package/cms/utils/ui-definition.utils.d.ts +6 -0
  43. package/cms/vendor-map.d.ts +26 -14
  44. package/core/modules/configuration/services/configuration-runtime.service.d.ts +2 -4
  45. package/core/modules/configuration/services/configuration.service.d.ts +6 -4
  46. package/core/modules/configuration/types/configuration-runtime.types.d.ts +0 -2
  47. package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +6 -3
  48. package/core/services/metric-calculation/metric-calculation.service.d.ts +5 -1
  49. package/core/services/quote-draft.service.d.ts +2 -2
  50. package/core/types/index.d.ts +0 -1
  51. package/core/types/ui-definition.types.d.ts +19 -4
  52. package/core/utils/index.d.ts +1 -0
  53. package/core/utils/line-item.utils.d.ts +2 -0
  54. package/core/utils/ui-definition.utils.d.ts +2 -0
  55. package/esm2015/cms/cms.elements.js +17 -4
  56. package/esm2015/cms/components/element-children/element-children.component.js +24 -8
  57. package/esm2015/cms/components/element-children/element-children.module.js +8 -6
  58. package/esm2015/cms/components/element-drop-handle/element-drop-handle.component.js +32 -0
  59. package/esm2015/cms/components/element-drop-handle/element-drop-handle.module.js +19 -0
  60. package/esm2015/cms/components/element-renderer/element-renderer.component.js +9 -9
  61. package/esm2015/cms/components/element-renderer/element-renderer.module.js +4 -4
  62. package/esm2015/cms/components/plugin.component.js +3 -3
  63. package/esm2015/cms/components/preview/index.js +2 -1
  64. package/esm2015/cms/components/preview/preview.component.js +21 -36
  65. package/esm2015/cms/components/preview/preview.module.js +7 -6
  66. package/esm2015/cms/components/preview/preview.types.js +2 -0
  67. package/esm2015/cms/directives/custom-template.directive.js +3 -3
  68. package/esm2015/cms/index.js +3 -1
  69. package/esm2015/cms/launcher.module.js +10 -9
  70. package/esm2015/cms/modules/federated/federated.component.js +3 -3
  71. package/esm2015/cms/modules/federated/federated.module.js +4 -4
  72. package/esm2015/cms/modules/migrations/index.js +3 -0
  73. package/esm2015/cms/modules/migrations/migrations.js +11 -0
  74. package/esm2015/cms/modules/migrations/migrations.module.js +15 -0
  75. package/esm2015/cms/modules/migrations/services/migrations.service.js +43 -0
  76. package/esm2015/cms/modules/migrations/types/migrations.types.js +2 -0
  77. package/esm2015/cms/modules/runtime/index.js +3 -0
  78. package/esm2015/cms/modules/runtime/runtime.module.js +32 -0
  79. package/esm2015/cms/modules/runtime/services/compilation.service.js +84 -0
  80. package/esm2015/cms/modules/runtime/services/runtime-editor.service.js +27 -0
  81. package/esm2015/cms/modules/runtime/services/runtime.service.js +74 -0
  82. package/esm2015/cms/modules/runtime/tokens.js +3 -0
  83. package/esm2015/cms/modules/runtime/types/compilation.types.js +2 -0
  84. package/esm2015/cms/modules/runtime/types/runtime.actions.js +2 -0
  85. package/esm2015/cms/plugins/configuration.plugin.js +12 -4
  86. package/esm2015/cms/plugins/element-hover.plugin.js +157 -0
  87. package/esm2015/cms/plugins/io.plugin.js +3 -3
  88. package/esm2015/cms/plugins/script.plugin.js +3 -3
  89. package/esm2015/cms/services/element-context.service.js +3 -3
  90. package/esm2015/cms/services/index.js +1 -2
  91. package/esm2015/cms/services/integration.state.js +3 -3
  92. package/esm2015/cms/services/io-provider.service.js +9 -9
  93. package/esm2015/cms/services/templates.service.js +3 -3
  94. package/esm2015/cms/types/common.types.js +1 -1
  95. package/esm2015/cms/types/configuration.types.js +1 -1
  96. package/esm2015/cms/types/index.js +2 -2
  97. package/esm2015/cms/utils/elements-resolver.js +18 -8
  98. package/esm2015/cms/utils/index.js +2 -1
  99. package/esm2015/cms/utils/path.utils.js +2 -13
  100. package/esm2015/cms/utils/ui-definition.utils.js +82 -0
  101. package/esm2015/cms/vendor-map.js +11 -4
  102. package/esm2015/core/core.module.js +4 -4
  103. package/esm2015/core/modules/configuration/configuration.module.js +4 -4
  104. package/esm2015/core/modules/configuration/services/configuration-runtime.service.js +5 -10
  105. package/esm2015/core/modules/configuration/services/configuration.service.js +27 -24
  106. package/esm2015/core/modules/configuration/services/runtime-context.service.js +3 -3
  107. package/esm2015/core/modules/configuration/types/configuration-runtime.types.js +1 -1
  108. package/esm2015/core/modules/flow-configuration/flow-configuration.module.js +4 -4
  109. package/esm2015/core/modules/flow-configuration/services/flow-configuration.service.js +17 -9
  110. package/esm2015/core/modules/flow-configuration/services/flow-update.service.js +3 -3
  111. package/esm2015/core/services/context.service.js +3 -3
  112. package/esm2015/core/services/metric-calculation/metric-calculation.service.js +18 -9
  113. package/esm2015/core/services/product-images.service.js +3 -3
  114. package/esm2015/core/services/quote-draft.service.js +7 -7
  115. package/esm2015/core/types/index.js +1 -2
  116. package/esm2015/core/types/ui-definition.types.js +2 -2
  117. package/esm2015/core/utils/index.js +2 -1
  118. package/esm2015/core/utils/line-item.utils.js +27 -11
  119. package/esm2015/core/utils/ui-definition.utils.js +9 -0
  120. package/esm2015/runtime/components/component-preview/component-preview.component.js +4 -4
  121. package/esm2015/runtime/components/section-renderer/section-renderer.component.js +3 -3
  122. package/esm2015/runtime/components/ui-runtime/runtime.component.js +3 -3
  123. package/esm2015/runtime/components/ui-runtime-preview/runtime-preview.component.js +3 -3
  124. package/esm2015/runtime/execution/components/children-placeholder/children-placeholder.component.js +6 -6
  125. package/esm2015/runtime/execution/components/context-provider/context-provider.component.js +3 -3
  126. package/esm2015/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.js +3 -3
  127. package/esm2015/runtime/execution/components/federated/federated.component.js +3 -3
  128. package/esm2015/runtime/execution/components/velo-attribute/velo-attribute.component.js +3 -3
  129. package/esm2015/runtime/execution/components/velo-multiselect/velo-multiselect.component.js +3 -3
  130. package/esm2015/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.js +3 -3
  131. package/esm2015/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.js +3 -3
  132. package/esm2015/runtime/execution/components/velo-port-radio/velo-port-radio.component.js +3 -3
  133. package/esm2015/runtime/execution/components/velo-type/velo-type.component.js +3 -3
  134. package/esm2015/runtime/execution/directives/section-script.directive.js +3 -3
  135. package/esm2015/runtime/execution/directives/sf-query.directive.js +3 -3
  136. package/esm2015/runtime/execution/directives/velo-attribute.directive.js +3 -3
  137. package/esm2015/runtime/execution/directives/velo-port.directive.js +18 -18
  138. package/esm2015/runtime/execution/directives/vl-approval.directive.js +3 -3
  139. package/esm2015/runtime/execution/directives/vl-document-attachments.directive.js +3 -3
  140. package/esm2015/runtime/execution/directives/vl-document-templates.directive.js +3 -3
  141. package/esm2015/runtime/execution/directives/vl-quote.directive.js +4 -4
  142. package/esm2015/runtime/execution/directives/vl-ramp.directive.js +3 -3
  143. package/esm2015/runtime/execution/runtime-execution.module.js +4 -4
  144. package/esm2015/runtime/runtime.module.js +4 -4
  145. package/esm2015/runtime/services/cart.service.js +3 -3
  146. package/esm2015/runtime/services/collapsible-state.service.js +3 -3
  147. package/esm2015/runtime/services/configuration.service.js +4 -4
  148. package/esm2015/runtime/services/current-state.service.js +3 -3
  149. package/esm2015/runtime/services/form-scope.service.js +3 -3
  150. package/esm2015/runtime/services/product-model-cache.service.js +3 -3
  151. package/esm2015/runtime/services/runtime-context.service.js +3 -3
  152. package/esm2015/runtime/services/runtime-form.service.js +3 -3
  153. package/esm2015/runtime/services/runtime.service.js +4 -4
  154. package/esm2015/runtime/services/section-helper.service.js +3 -3
  155. package/esm2015/runtime/services/section-scope.service.js +3 -3
  156. package/esm2015/runtime/services/section-store.service.js +3 -3
  157. package/esm2015/runtime/services/section.service.js +6 -6
  158. package/esm2015/runtime/types/index.js +2 -1
  159. package/esm2015/runtime/types/quote-states.types.js +2 -0
  160. package/esm2015/src/components/dialog/dialog.component.js +3 -3
  161. package/esm2015/src/components/dialog/dialog.module.js +4 -4
  162. package/esm2015/src/components/doc-gen/doc-gen.component.js +3 -3
  163. package/esm2015/src/components/doc-gen/doc-gen.module.js +4 -4
  164. package/esm2015/src/components/header/cart-overlay/cart-preview.component.js +3 -3
  165. package/esm2015/src/components/header/cart-overlay/cart-preview.module.js +4 -4
  166. package/esm2015/src/components/header/header.component.js +8 -9
  167. package/esm2015/src/components/header/header.module.js +4 -4
  168. package/esm2015/src/components/header/metrics/metrics.component.js +79 -67
  169. package/esm2015/src/components/header/metrics/metrics.definitions.js +1 -8
  170. package/esm2015/src/components/header/metrics/metrics.module.js +4 -4
  171. package/esm2015/src/flow-routing.module.js +4 -4
  172. package/esm2015/src/flow.component.js +3 -3
  173. package/esm2015/src/flow.module.js +4 -4
  174. package/esm2015/src/guards/context.guard.js +3 -3
  175. package/esm2015/src/guards/product-unload.guard.js +3 -3
  176. package/esm2015/src/guards/root.guard.js +3 -3
  177. package/esm2015/src/pages/catalog/catalog.component.js +3 -3
  178. package/esm2015/src/pages/catalog/catalog.module.js +4 -4
  179. package/esm2015/src/pages/debug/debug.component.js +3 -3
  180. package/esm2015/src/pages/debug/debug.module.js +4 -4
  181. package/esm2015/src/pages/empty-account/empty-account.component.js +3 -3
  182. package/esm2015/src/pages/empty-account/empty-account.module.js +4 -4
  183. package/esm2015/src/pages/legacy-product/legacy-product.component.js +4 -4
  184. package/esm2015/src/pages/legacy-product/legacy-product.module.js +4 -4
  185. package/esm2015/src/pages/product/product.component.js +5 -12
  186. package/esm2015/src/pages/product/product.module.js +4 -4
  187. package/esm2015/src/pages/record-not-found/record-not-found.component.js +3 -3
  188. package/esm2015/src/pages/record-not-found/record-not-found.module.js +4 -4
  189. package/esm2015/src/pages/remote/remote.component.js +5 -8
  190. package/esm2015/src/pages/remote/remote.module.js +4 -4
  191. package/esm2015/src/pages/shopping-cart/shopping-cart.component.js +3 -3
  192. package/esm2015/src/pages/shopping-cart/shopping-cart.module.js +4 -4
  193. package/esm2015/src/resolvers/flow.resolver.js +3 -3
  194. package/esm2015/src/resolvers/quote.resolver.js +8 -8
  195. package/esm2015/src/services/doc-gen.service.js +3 -3
  196. package/esm2015/src/services/flow-dialog.service.js +3 -3
  197. package/esm2015/src/services/flow-router.service.js +3 -3
  198. package/esm2015/src/services/flow.service.js +3 -3
  199. package/esm2015/src/utils/flow.utils.js +3 -3
  200. package/fesm2015/veloceapps-sdk-cms.js +1181 -713
  201. package/fesm2015/veloceapps-sdk-cms.js.map +1 -1
  202. package/fesm2015/veloceapps-sdk-core.js +557 -517
  203. package/fesm2015/veloceapps-sdk-core.js.map +1 -1
  204. package/fesm2015/veloceapps-sdk-runtime.js +138 -138
  205. package/fesm2015/veloceapps-sdk-runtime.js.map +1 -1
  206. package/fesm2015/veloceapps-sdk.js +239 -244
  207. package/fesm2015/veloceapps-sdk.js.map +1 -1
  208. package/package.json +5 -3
  209. package/runtime/services/configuration.service.d.ts +2 -1
  210. package/runtime/services/runtime.service.d.ts +2 -1
  211. package/runtime/types/index.d.ts +1 -0
  212. package/src/components/header/metrics/metrics.component.d.ts +15 -6
  213. package/src/components/header/metrics/metrics.definitions.d.ts +0 -3
  214. package/src/pages/product/product.component.d.ts +0 -1
  215. package/cms/services/dynamic-module.service.d.ts +0 -15
  216. package/cms/services/launcher.service.d.ts +0 -18
  217. package/esm2015/cms/services/dynamic-module.service.js +0 -33
  218. package/esm2015/cms/services/launcher.service.js +0 -58
  219. package/esm2015/cms/types/compilation.types.js +0 -2
  220. package/esm2015/core/types/quote-states.types.js +0 -2
  221. /package/{core → runtime}/types/quote-states.types.d.ts +0 -0
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('lodash'), require('@angular/common'), require('@veloceapps/core'), require('@angular/cdk/drag-drop'), require('@angular/cdk/scrolling'), require('@angular/forms'), require('@veloceapps/sdk/core'), require('@veloceapps/components'), require('@babel/standalone'), require('@veloceapps/api'), require('rxjs/operators'), require('primeng/api'), require('primeng/dynamicdialog')) :
3
- typeof define === 'function' && define.amd ? define('@veloceapps/sdk/cms', ['exports', '@angular/core', 'rxjs', 'lodash', '@angular/common', '@veloceapps/core', '@angular/cdk/drag-drop', '@angular/cdk/scrolling', '@angular/forms', '@veloceapps/sdk/core', '@veloceapps/components', '@babel/standalone', '@veloceapps/api', 'rxjs/operators', 'primeng/api', 'primeng/dynamicdialog'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.veloceapps = global.veloceapps || {}, global.veloceapps.sdk = global.veloceapps.sdk || {}, global.veloceapps.sdk.cms = {}), global.ng.core, global.rxjs, global.lodash, global.ng.common, global["@veloceapps/core"], global.ng.cdk.dragDrop, global.ng.cdk.scrolling, global.ng.forms, global.veloceapps.sdk.core, global["@veloceapps/components"], global["@babel/standalone"], global["@veloceapps/api"], global.rxjs.operators, global["primeng/api"], global["primeng/dynamicdialog"]));
5
- })(this, (function (exports, i0, rxjs, lodash, i7, core, dragDrop, scrolling, angularForms, i2, i1, standalone, api, rxjsOperators, i3, dynamicdialog) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('lodash'), require('rfc6902'), require('@veloceapps/sdk/core'), require('primeng/api'), require('@veloceapps/components'), require('@veloceapps/core'), require('@angular/common'), require('ngx-drag-drop'), require('@veloceapps/api'), require('primeng/dynamicdialog'), require('@angular/cdk/drag-drop'), require('@angular/cdk/scrolling'), require('@angular/forms'), require('@babel/standalone'), require('rxjs/operators')) :
3
+ typeof define === 'function' && define.amd ? define('@veloceapps/sdk/cms', ['exports', '@angular/core', 'rxjs', 'lodash', 'rfc6902', '@veloceapps/sdk/core', 'primeng/api', '@veloceapps/components', '@veloceapps/core', '@angular/common', 'ngx-drag-drop', '@veloceapps/api', 'primeng/dynamicdialog', '@angular/cdk/drag-drop', '@angular/cdk/scrolling', '@angular/forms', '@babel/standalone', 'rxjs/operators'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.veloceapps = global.veloceapps || {}, global.veloceapps.sdk = global.veloceapps.sdk || {}, global.veloceapps.sdk.cms = {}), global.ng.core, global.rxjs, global.lodash, global.rfc6902, global.veloceapps.sdk.core, global["primeng/api"], global["@veloceapps/components"], global["@veloceapps/core"], global.ng.common, global["ngx-drag-drop"], global["@veloceapps/api"], global["primeng/dynamicdialog"], global.ng.cdk.dragDrop, global.ng.cdk.scrolling, global.ng.forms, global["@babel/standalone"], global.rxjs.operators));
5
+ })(this, (function (exports, i0, rxjs, lodash, rfc6902, i2, i3, i1, core, i7, i2$1, api, dynamicdialog, dragDrop, scrolling, angularForms, standalone, rxjsOperators) { 'use strict';
6
6
 
7
7
  function _interopNamespace(e) {
8
8
  if (e && e.__esModule) return e;
@@ -25,12 +25,13 @@
25
25
  var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
26
26
  var rxjs__namespace = /*#__PURE__*/_interopNamespace(rxjs);
27
27
  var lodash__namespace = /*#__PURE__*/_interopNamespace(lodash);
28
- var i7__namespace = /*#__PURE__*/_interopNamespace(i7);
29
- var angularForms__namespace = /*#__PURE__*/_interopNamespace(angularForms);
30
28
  var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
29
+ var i3__namespace = /*#__PURE__*/_interopNamespace(i3);
31
30
  var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
31
+ var i7__namespace = /*#__PURE__*/_interopNamespace(i7);
32
+ var i2__namespace$1 = /*#__PURE__*/_interopNamespace(i2$1);
33
+ var angularForms__namespace = /*#__PURE__*/_interopNamespace(angularForms);
32
34
  var rxjsOperators__namespace = /*#__PURE__*/_interopNamespace(rxjsOperators);
33
- var i3__namespace = /*#__PURE__*/_interopNamespace(i3);
34
35
 
35
36
  exports.FlowAction = void 0;
36
37
  (function (FlowAction) {
@@ -97,7 +98,7 @@
97
98
  SetDefaultMetrics: SetDefaultMetrics
98
99
  });
99
100
 
100
- /*! *****************************************************************************
101
+ /******************************************************************************
101
102
  Copyright (c) Microsoft Corporation.
102
103
 
103
104
  Permission to use, copy, modify, and/or distribute this software for any
@@ -164,6 +165,64 @@
164
165
  function __param(paramIndex, decorator) {
165
166
  return function (target, key) { decorator(target, key, paramIndex); };
166
167
  }
168
+ function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
169
+ function accept(f) { if (f !== void 0 && typeof f !== "function")
170
+ throw new TypeError("Function expected"); return f; }
171
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
172
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
173
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
174
+ var _, done = false;
175
+ for (var i = decorators.length - 1; i >= 0; i--) {
176
+ var context = {};
177
+ for (var p in contextIn)
178
+ context[p] = p === "access" ? {} : contextIn[p];
179
+ for (var p in contextIn.access)
180
+ context.access[p] = contextIn.access[p];
181
+ context.addInitializer = function (f) { if (done)
182
+ throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
183
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
184
+ if (kind === "accessor") {
185
+ if (result === void 0)
186
+ continue;
187
+ if (result === null || typeof result !== "object")
188
+ throw new TypeError("Object expected");
189
+ if (_ = accept(result.get))
190
+ descriptor.get = _;
191
+ if (_ = accept(result.set))
192
+ descriptor.set = _;
193
+ if (_ = accept(result.init))
194
+ initializers.push(_);
195
+ }
196
+ else if (_ = accept(result)) {
197
+ if (kind === "field")
198
+ initializers.push(_);
199
+ else
200
+ descriptor[key] = _;
201
+ }
202
+ }
203
+ if (target)
204
+ Object.defineProperty(target, contextIn.name, descriptor);
205
+ done = true;
206
+ }
207
+ ;
208
+ function __runInitializers(thisArg, initializers, value) {
209
+ var useValue = arguments.length > 2;
210
+ for (var i = 0; i < initializers.length; i++) {
211
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
212
+ }
213
+ return useValue ? value : void 0;
214
+ }
215
+ ;
216
+ function __propKey(x) {
217
+ return typeof x === "symbol" ? x : "".concat(x);
218
+ }
219
+ ;
220
+ function __setFunctionName(f, name, prefix) {
221
+ if (typeof name === "symbol")
222
+ name = name.description ? "[".concat(name.description, "]") : "";
223
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
224
+ }
225
+ ;
167
226
  function __metadata(metadataKey, metadataValue) {
168
227
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
169
228
  return Reflect.metadata(metadataKey, metadataValue);
@@ -195,7 +254,7 @@
195
254
  function step(op) {
196
255
  if (f)
197
256
  throw new TypeError("Generator is already executing.");
198
- while (_)
257
+ while (g && (g = 0, op[0] && (_ = 0)), _)
199
258
  try {
200
259
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
201
260
  return t;
@@ -259,7 +318,11 @@
259
318
  var __createBinding = Object.create ? (function (o, m, k, k2) {
260
319
  if (k2 === undefined)
261
320
  k2 = k;
262
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
321
+ var desc = Object.getOwnPropertyDescriptor(m, k);
322
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
323
+ desc = { enumerable: true, get: function () { return m[k]; } };
324
+ }
325
+ Object.defineProperty(o, k2, desc);
263
326
  }) : (function (o, m, k, k2) {
264
327
  if (k2 === undefined)
265
328
  k2 = k;
@@ -359,7 +422,7 @@
359
422
  function __asyncDelegator(o) {
360
423
  var i, p;
361
424
  return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
362
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
425
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
363
426
  }
364
427
  function __asyncValues(o) {
365
428
  if (!Symbol.asyncIterator)
@@ -414,6 +477,11 @@
414
477
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
415
478
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
416
479
  }
480
+ function __classPrivateFieldIn(state, receiver) {
481
+ if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
482
+ throw new TypeError("Cannot use 'in' operator on non-object");
483
+ return typeof state === "function" ? receiver === state : state.has(receiver);
484
+ }
417
485
 
418
486
  var DEFAULT_PLUGINS_TOKEN = new i0.InjectionToken('DEFAULT_PLUGINS_TOKEN');
419
487
  var UI_DEFINITION_METADATA = new i0.InjectionToken('UI_DEFINITION_METADATA_TOKEN');
@@ -492,6 +560,110 @@
492
560
  __param(0, i0.Inject(i0.Injector))
493
561
  ], exports.ElementComponent);
494
562
 
563
+ function getElementUniqueName(collection, name, comparator) {
564
+ var result = '';
565
+ var index = 0;
566
+ while (!result) {
567
+ var candidate = name + (index ? " (" + index + ")" : '');
568
+ var exists = collection.some(comparator(candidate));
569
+ if (!exists) {
570
+ result = candidate;
571
+ }
572
+ else {
573
+ index++;
574
+ }
575
+ }
576
+ return result;
577
+ }
578
+ var insertElementAt = function (source, target, parentPath, index) {
579
+ var result = __spreadArray([], __read(source));
580
+ var name = getElementUniqueName(result, target.name, function (name) { return function (el) { return el.name === name; }; });
581
+ var path = parentPath ? parentPath + "/" + name : name;
582
+ result.splice(index, 0, Object.assign(Object.assign({}, target), { path: path, name: name }));
583
+ return result;
584
+ };
585
+ var insertElement = function (source, target, path, index) {
586
+ if (!path) {
587
+ return insertElementAt(source, target, '', index);
588
+ }
589
+ return source.map(function (element) {
590
+ var _a;
591
+ if (element.path === path) {
592
+ return Object.assign(Object.assign({}, element), { children: insertElementAt(element.children, target, element.path, index) });
593
+ }
594
+ else if ((_a = element.path) === null || _a === void 0 ? void 0 : _a.startsWith(path)) {
595
+ return Object.assign(Object.assign({}, element), { children: insertElement(element.children, target, path, index) });
596
+ }
597
+ else {
598
+ return element;
599
+ }
600
+ });
601
+ };
602
+ var removeElement = function (source, path) {
603
+ return source.reduce(function (trunk, element) {
604
+ if (path === element.path) {
605
+ return trunk;
606
+ }
607
+ if (element.path) {
608
+ if (path.startsWith(element.path)) {
609
+ trunk.push(Object.assign(Object.assign({}, element), { children: removeElement(element.children, path) }));
610
+ }
611
+ else {
612
+ trunk.push(element);
613
+ }
614
+ }
615
+ return trunk;
616
+ }, []);
617
+ };
618
+ var findElementByPath = function (source, path) {
619
+ var e_1, _b;
620
+ try {
621
+ for (var source_1 = __values(source), source_1_1 = source_1.next(); !source_1_1.done; source_1_1 = source_1.next()) {
622
+ var el = source_1_1.value;
623
+ if (el.path === path) {
624
+ return el;
625
+ }
626
+ if (el.path && path.startsWith(el.path)) {
627
+ var found = findElementByPath(el.children, path);
628
+ if (found) {
629
+ return found;
630
+ }
631
+ }
632
+ }
633
+ }
634
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
635
+ finally {
636
+ try {
637
+ if (source_1_1 && !source_1_1.done && (_b = source_1.return)) _b.call(source_1);
638
+ }
639
+ finally { if (e_1) throw e_1.error; }
640
+ }
641
+ return;
642
+ };
643
+ var findElementByModule = function (elements, module, elementName) {
644
+ var e_2, _b;
645
+ try {
646
+ for (var elements_1 = __values(elements), elements_1_1 = elements_1.next(); !elements_1_1.done; elements_1_1 = elements_1.next()) {
647
+ var el = elements_1_1.value;
648
+ if (el.module === module && el.name === elementName) {
649
+ return el;
650
+ }
651
+ var child = findElementByModule(el.children, module, elementName);
652
+ if (child) {
653
+ return child;
654
+ }
655
+ }
656
+ }
657
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
658
+ finally {
659
+ try {
660
+ if (elements_1_1 && !elements_1_1.done && (_b = elements_1.return)) _b.call(elements_1);
661
+ }
662
+ finally { if (e_2) throw e_2.error; }
663
+ }
664
+ return;
665
+ };
666
+
495
667
  var parseBoundPath = function (path) {
496
668
  var _a, _b;
497
669
  var regexp = new RegExp("(?:\\/)(?:\\w+)(?:\\/)(?:ports|attributes)(?:\\/)(?:\\w+)|(?:\\/)(?:\\w+)", 'g');
@@ -524,29 +696,6 @@
524
696
  variable: variable,
525
697
  };
526
698
  };
527
- var findElementByModule = function (elements, module, elementName) {
528
- var e_1, _e;
529
- try {
530
- for (var elements_1 = __values(elements), elements_1_1 = elements_1.next(); !elements_1_1.done; elements_1_1 = elements_1.next()) {
531
- var el = elements_1_1.value;
532
- if (el.module === module && el.name === elementName) {
533
- return el;
534
- }
535
- var child = findElementByModule(el.children, module, elementName);
536
- if (child) {
537
- return child;
538
- }
539
- }
540
- }
541
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
542
- finally {
543
- try {
544
- if (elements_1_1 && !elements_1_1.done && (_e = elements_1.return)) _e.call(elements_1);
545
- }
546
- finally { if (e_1) throw e_1.error; }
547
- }
548
- return;
549
- };
550
699
  var getAbsolutePath = function (elements, subject, path) {
551
700
  var _a, _b, _c;
552
701
  if (path.module) {
@@ -569,49 +718,85 @@
569
718
  return subjectSegments.join('/');
570
719
  };
571
720
 
572
- var DynamicModuleService = /** @class */ (function () {
573
- function DynamicModuleService() {
574
- this._elementsTree = [];
575
- this._componentFactories = [];
721
+ var CMS_COMPILATION_SERVICE = new i0.InjectionToken('VENDOR_MAP');
722
+
723
+ var RuntimeService = /** @class */ (function () {
724
+ function RuntimeService(injector) {
725
+ this.injector = injector;
726
+ this.modules = [];
727
+ this.componentFactories = {};
728
+ this.applicationTree = [];
729
+ this.isInitialized$ = new rxjs.BehaviorSubject(false);
730
+ this.updated$ = new rxjs.Subject();
731
+ this.compilationService = this.injector.get(CMS_COMPILATION_SERVICE);
576
732
  }
577
- Object.defineProperty(DynamicModuleService.prototype, "componentFactories", {
578
- get: function () {
579
- return this._componentFactories;
580
- },
581
- set: function (data) {
582
- this._componentFactories = data;
583
- },
584
- enumerable: false,
585
- configurable: true
586
- });
587
- DynamicModuleService.prototype.getComponentFactory = function (element) {
588
- return this.componentFactories.find(function (f) { return f.componentType.path === element.path; });
733
+ RuntimeService.prototype.initialize$ = function (uiDefinition, config) {
734
+ var _this = this;
735
+ this.config = config;
736
+ if (!uiDefinition) {
737
+ return rxjs.of([]);
738
+ }
739
+ return this.compilationService.compileUIDefinition$(uiDefinition).pipe(rxjs.map(function (result) {
740
+ _this.applicationTree = result.elements;
741
+ _this.addComponentFactories(result.module.componentFactories);
742
+ return result.elements;
743
+ }), rxjs.tap(function () { return _this.isInitialized$.next(true); }));
589
744
  };
590
- Object.defineProperty(DynamicModuleService.prototype, "elementsTree", {
591
- get: function () {
592
- return this._elementsTree;
593
- },
594
- set: function (tree) {
595
- this._elementsTree = tree;
596
- },
597
- enumerable: false,
598
- configurable: true
599
- });
600
- DynamicModuleService.prototype.clear = function () {
601
- this._elementsTree = [];
602
- this.componentFactories = [];
745
+ RuntimeService.prototype.applyPatch$ = function (patch) {
746
+ var _this = this;
747
+ var observable$ = rxjs.of(undefined);
748
+ patch.forEach(function (operation) {
749
+ switch (operation.op) {
750
+ case 'add': {
751
+ observable$ = observable$.pipe(rxjs.switchMap(function () { return _this.addElement$(operation); }));
752
+ break;
753
+ }
754
+ case 'remove': {
755
+ observable$ = observable$.pipe(rxjs.map(function () { return _this.deleteElement(operation); }));
756
+ break;
757
+ }
758
+ default:
759
+ observable$ = rxjs.of();
760
+ }
761
+ });
762
+ return observable$.pipe(rxjs.tap(function () { return _this.updated$.next(); }));
763
+ };
764
+ RuntimeService.prototype.getCompiledElement$ = function (path) {
765
+ var _this = this;
766
+ return this.updated$.pipe(rxjs.startWith(undefined), rxjs.map(function () { return findElementByPath(_this.applicationTree, path); }), rxjs.distinctUntilChanged());
767
+ };
768
+ RuntimeService.prototype.clear = function () {
769
+ this.compilationService.clearModuleCache(this.modules);
770
+ this.modules = [];
771
+ this.applicationTree = [];
772
+ this.componentFactories = {};
773
+ this.isInitialized$.next(false);
774
+ };
775
+ RuntimeService.prototype.addElement$ = function (operation) {
776
+ var _this = this;
777
+ return this.compilationService.compileElement$(operation.value).pipe(rxjs.map(function (result) {
778
+ _this.addComponentFactories(result.module.componentFactories);
779
+ rfc6902.applyPatch(_this.applicationTree, [Object.assign(Object.assign({}, operation), { value: result.elements[0] })]);
780
+ }));
781
+ };
782
+ RuntimeService.prototype.deleteElement = function (operation) {
783
+ rfc6902.applyPatch(this.applicationTree, [operation]);
784
+ };
785
+ RuntimeService.prototype.addComponentFactories = function (list) {
786
+ var _this = this;
787
+ list.forEach(function (item) { return (_this.componentFactories[item.componentType.path] = item); });
603
788
  };
604
- return DynamicModuleService;
789
+ return RuntimeService;
605
790
  }());
606
- DynamicModuleService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DynamicModuleService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
607
- DynamicModuleService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DynamicModuleService });
608
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DynamicModuleService, decorators: [{
791
+ RuntimeService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RuntimeService, deps: [{ token: i0__namespace.Injector }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
792
+ RuntimeService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RuntimeService });
793
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RuntimeService, decorators: [{
609
794
  type: i0.Injectable
610
- }] });
795
+ }], ctorParameters: function () { return [{ type: i0__namespace.Injector }]; } });
611
796
 
612
797
  var IOProviderService = /** @class */ (function () {
613
- function IOProviderService(dynamicModuleService) {
614
- this.dynamicModuleService = dynamicModuleService;
798
+ function IOProviderService(runtimeService) {
799
+ this.runtimeService = runtimeService;
615
800
  this.inputs = {};
616
801
  }
617
802
  IOProviderService.prototype.connect = function (el, name, target) {
@@ -631,7 +816,7 @@
631
816
  var pathIsValue = elPath.segments.length === 1 && elPath.segments[0].startsWith('"') && elPath.segments[0].endsWith('"');
632
817
  var finalName = (_b = elPath.variable) !== null && _b !== void 0 ? _b : name;
633
818
  var value = pathIsValue ? new rxjs.BehaviorSubject(elPath.segments[0].slice(1, -1)) : undefined;
634
- var absolutePath = !pathIsValue ? getAbsolutePath(this.dynamicModuleService.elementsTree, el, elPath) : el.path;
819
+ var absolutePath = !pathIsValue ? getAbsolutePath(this.runtimeService.applicationTree, el, elPath) : el.path;
635
820
  return this.createSubjectSafe(absolutePath !== null && absolutePath !== void 0 ? absolutePath : '', finalName, value);
636
821
  };
637
822
  IOProviderService.prototype.createSubjectSafe = function (path, name, subject) {
@@ -651,11 +836,11 @@
651
836
  };
652
837
  return IOProviderService;
653
838
  }());
654
- IOProviderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: IOProviderService, deps: [{ token: DynamicModuleService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
655
- IOProviderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: IOProviderService });
656
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: IOProviderService, decorators: [{
839
+ IOProviderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: IOProviderService, deps: [{ token: RuntimeService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
840
+ IOProviderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: IOProviderService });
841
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: IOProviderService, decorators: [{
657
842
  type: i0.Injectable
658
- }], ctorParameters: function () { return [{ type: DynamicModuleService }]; } });
843
+ }], ctorParameters: function () { return [{ type: RuntimeService }]; } });
659
844
 
660
845
  var TemplatesService = /** @class */ (function () {
661
846
  function TemplatesService() {
@@ -680,318 +865,73 @@
680
865
  };
681
866
  return TemplatesService;
682
867
  }());
683
- TemplatesService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TemplatesService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
684
- TemplatesService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TemplatesService });
685
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TemplatesService, decorators: [{
868
+ TemplatesService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TemplatesService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
869
+ TemplatesService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TemplatesService });
870
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TemplatesService, decorators: [{
686
871
  type: i0.Injectable
687
872
  }] });
688
873
 
689
- var IOPlugin = /** @class */ (function () {
690
- function IOPlugin(host) {
691
- var _this = this;
692
- var _a, _b;
693
- this.host = host;
694
- var elementMetadata = this.host.injector.get(ELEMENT_METADATA);
695
- var inputProvider = this.host.injector.get(IOProviderService);
696
- var inputs = Object.entries((_a = elementMetadata.inputs) !== null && _a !== void 0 ? _a : {});
697
- var outputs = Object.entries((_b = elementMetadata.outputs) !== null && _b !== void 0 ? _b : {});
698
- inputs.forEach(function (_c) {
699
- var _d = __read(_c, 2), key = _d[0], path = _d[1];
700
- var _a;
701
- if (path && typeof path !== 'string') {
702
- console.error("The value of '" + key + "' input should be a string");
703
- }
704
- if (((_a = elementMetadata.outputs) === null || _a === void 0 ? void 0 : _a[key]) !== undefined) {
705
- console.warn("'" + key + "' appears both in inputs and outputs. To prevent inconsistent behavior please keep them unique ");
706
- }
707
- _this.host[key] = inputProvider.connect(elementMetadata, key, path);
708
- });
709
- outputs.forEach(function (_c) {
710
- var _d = __read(_c, 2), key = _d[0], path = _d[1];
711
- if (path && typeof path !== 'string') {
712
- console.error("The value of '" + key + "' output should be a string");
713
- }
714
- _this.host[key] = inputProvider.provide(elementMetadata, key, path);
715
- });
874
+ var InitAction = { type: 'INIT' };
875
+ var ClearAction = { type: 'CLEAR' };
876
+ var IntegrationState = /** @class */ (function () {
877
+ function IntegrationState() {
878
+ this.stateSubj$ = new rxjs.BehaviorSubject({});
879
+ this.action$ = new rxjs.BehaviorSubject(InitAction);
716
880
  }
717
- return IOPlugin;
881
+ Object.defineProperty(IntegrationState.prototype, "state$", {
882
+ get: function () {
883
+ return this.stateSubj$.asObservable();
884
+ },
885
+ enumerable: false,
886
+ configurable: true
887
+ });
888
+ Object.defineProperty(IntegrationState.prototype, "state", {
889
+ get: function () {
890
+ return this.stateSubj$.getValue();
891
+ },
892
+ enumerable: false,
893
+ configurable: true
894
+ });
895
+ IntegrationState.prototype.patchState = function (update) {
896
+ this.stateSubj$.next(Object.assign(Object.assign({}, this.stateSubj$.getValue()), update));
897
+ };
898
+ IntegrationState.prototype.dispatch = function (action) {
899
+ this.action$.next(action);
900
+ };
901
+ IntegrationState.prototype.listen$ = function (actionType) {
902
+ return this.action$.pipe(rxjs.filter(function (action) { return action.type === actionType; }), rxjs.map(function (action) { return action.payload; }));
903
+ };
904
+ IntegrationState.prototype.listenAll$ = function () {
905
+ return this.action$.asObservable();
906
+ };
907
+ IntegrationState.prototype.clear = function () {
908
+ this.stateSubj$.next({});
909
+ this.action$.next(ClearAction);
910
+ };
911
+ return IntegrationState;
718
912
  }());
719
- IOPlugin.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: IOPlugin, deps: [{ token: exports.ElementComponent }], target: i0__namespace.ɵɵFactoryTarget.Directive });
720
- IOPlugindir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: IOPlugin, ngImport: i0__namespace });
721
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: IOPlugin, decorators: [{
722
- type: i0.Directive
723
- }], ctorParameters: function () { return [{ type: exports.ElementComponent }]; } });
913
+ IntegrationState.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: IntegrationState, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
914
+ IntegrationStateprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: IntegrationState, providedIn: 'root' });
915
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: IntegrationState, decorators: [{
916
+ type: i0.Injectable,
917
+ args: [{ providedIn: 'root' }]
918
+ }] });
724
919
 
725
- var ScriptPlugin = /** @class */ (function () {
726
- function ScriptPlugin(host) {
727
- var _this = this;
728
- this.host = host;
729
- this.normalizeImports = function (script, elementPath) {
730
- var regexp = new RegExp("import([ \\n\\t]*(?:[^ \\n\\t\\{\\}]+[ \\n\\t]*,?)?(?:[ \\n\\t]*\\{(?:[ \\n\\t]*[^ \\n\\t\"'\\{\\}]+[ \\n\\t]*,?)+\\})?[ \\n\\t]*)from[ \\n\\t]*(['\"])([^'\"\\n]+)(?:['\"]);", 'g');
731
- var result = script.replace(regexp, function (match, g1, g2, src) {
732
- var imports = g1
733
- .trim()
734
- .slice(1, -1)
735
- .split(',')
736
- .map(function (item) { return item.trim(); });
737
- imports.forEach(function (item) {
738
- var _a;
739
- if (!((_a = _this.vendorMap[src]) === null || _a === void 0 ? void 0 : _a[item])) {
740
- throw new Error("Failed to import " + item + " from '" + src + "' in " + elementPath + "/script.ts");
741
- }
742
- });
743
- return "const " + g1 + " = vendor['" + src + "'];";
744
- });
745
- return result;
746
- };
747
- this.document = this.host.injector.get(i7.DOCUMENT);
748
- this.vendorMap = this.host.injector.get(VENDOR_MAP);
749
- var elementMetadata = this.host.injector.get(ELEMENT_METADATA);
750
- var sharedElementMetadata = this.host.injector.get(SHARED_ELEMENT_METADATA);
751
- this.addScript(sharedElementMetadata);
752
- this.addScript(elementMetadata);
920
+ var ElementContextService = /** @class */ (function () {
921
+ function ElementContextService() {
753
922
  }
754
- ScriptPlugin.prototype.addScript = function (metadata) {
755
- var _a;
756
- if (!(metadata === null || metadata === void 0 ? void 0 : metadata.script)) {
757
- return;
758
- }
759
- var id = btoa(core.UUID.UUID());
760
- var script = this.document.createElement('script');
761
- script.type = "text/javascript";
762
- var scriptContent = this.normalizeImports(metadata.script, (_a = metadata.path) !== null && _a !== void 0 ? _a : metadata.name);
763
- var classMatch = /export class (\S+)/.exec(scriptContent);
764
- var className = classMatch === null || classMatch === void 0 ? void 0 : classMatch[1];
765
- if (!classMatch || !className) {
766
- console.error("Script doesn't have exported class");
767
- return;
768
- }
769
- scriptContent = scriptContent.replace(classMatch[0], "class " + className);
770
- script.text = "var " + id + " = function(vendor) {" + scriptContent + "\n return " + className + "; };";
771
- this.document.body.appendChild(script);
772
- var ScriptClass = window[id](this.vendorMap);
773
- if (ScriptClass instanceof Object) {
774
- this.host.registerPlugin(new ScriptClass(this.host));
775
- }
776
- this.document.body.removeChild(script);
777
- };
778
- return ScriptPlugin;
923
+ return ElementContextService;
779
924
  }());
780
- ScriptPlugin.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ScriptPlugin, deps: [{ token: exports.ElementComponent }], target: i0__namespace.ɵɵFactoryTarget.Directive });
781
- ScriptPlugindir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: ScriptPlugin, ngImport: i0__namespace });
782
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ScriptPlugin, decorators: [{
783
- type: i0.Directive
784
- }], ctorParameters: function () { return [{ type: exports.ElementComponent }]; } });
785
-
786
- /*
787
- * ScriptPlugin must always be the last plugin in the list to make sure user code is running after all pre-initializers.
788
- */
789
- var CONFIG = {
790
- CUSTOM: {
791
- component: exports.ElementComponent,
792
- plugins: [IOPlugin, ScriptPlugin],
793
- },
794
- CONTAINER: {
795
- component: exports.ElementComponent,
796
- defaultTemplate: '<element-children></element-children>',
797
- plugins: [ScriptPlugin],
798
- },
799
- SERVICE: {
800
- component: exports.ElementComponent,
801
- plugins: [IOPlugin, ScriptPlugin],
802
- suppressTemplate: true,
803
- suppressStyles: true,
804
- },
805
- REFERENCE: {
806
- component: exports.ElementComponent,
807
- plugins: [IOPlugin, ScriptPlugin],
808
- suppressTemplate: true,
809
- },
810
- };
811
-
812
- var EXPORTED_CLASS_REGEX = /export class (\S+)/;
813
- var METADATA_DECORATOR_REGEX = /@ElementDefinition\(([\s\S]+)\)(\n|\r\n|.)*export class/g;
814
- var UiBuildError = /** @class */ (function (_super) {
815
- __extends(UiBuildError, _super);
816
- function UiBuildError(message, affectedMetadata) {
817
- var _this = _super.call(this, message) || this;
818
- _this.name = _this.constructor.name;
819
- _this.affectedMetadata = affectedMetadata;
820
- return _this;
821
- }
822
- return UiBuildError;
823
- }(Error));
824
- var elementToMetadata = function (el, parentPath) {
825
- var _a;
826
- var script = el.script && window.atob(el.script);
827
- var template = el.template && window.atob(el.template);
828
- var styles = el.styles && window.atob(el.styles);
829
- var exportedClassName = script && ((_a = EXPORTED_CLASS_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
830
- if (!exportedClassName) {
831
- throw new Error("Script doesn't have exported class");
832
- }
833
- var elementMetadata = extractElementMetadata(script || '');
834
- var path = (parentPath ? parentPath + '/' : '') + elementMetadata.name;
835
- return Object.assign(Object.assign({}, elementMetadata), { path: path, script: script === null || script === void 0 ? void 0 : script.replace(METADATA_DECORATOR_REGEX, 'export class'), template: template, styles: styles, children: el.children.map(function (child) { return elementToMetadata(child, path); }) });
836
- };
837
- var metadataToElement = function (metadata, recursive) {
838
- if (recursive === void 0) { recursive = true; }
839
- var elMetadata = {
840
- name: metadata.name,
841
- isShared: metadata.isShared,
842
- type: metadata.type,
843
- model: metadata.model,
844
- module: metadata.module,
845
- reference: metadata.reference,
846
- inputs: metadata.inputs,
847
- outputs: metadata.outputs,
848
- children: metadata.children.map(function (_e) {
849
- var name = _e.name;
850
- return name;
851
- }),
852
- configuredStyles: metadata.configuredStyles,
853
- };
854
- var normalizedElMetadata = normalizeElementMetadata(elMetadata);
855
- if (!metadata.script || !EXPORTED_CLASS_REGEX.test(metadata.script)) {
856
- throw new UiBuildError("'" + metadata.name + "' component script is missing an exported class", metadata);
857
- }
858
- var script = metadata.script &&
859
- window.btoa(metadata.script.replace(EXPORTED_CLASS_REGEX, "@ElementDefinition(" + stringifyElementMetadata(normalizedElMetadata) + ")\nexport class Script"));
860
- var template = metadata.template && window.btoa(metadata.template);
861
- var styles = metadata.styles && window.btoa(metadata.styles);
862
- return {
863
- script: script,
864
- template: template,
865
- styles: styles,
866
- children: recursive ? metadata.children.map(function (meta) { return metadataToElement(meta); }) : [],
867
- };
868
- };
869
- var normalizeElementMetadata = function (elementMetadata) {
870
- var _a, _b, _c, _d;
871
- var metadata = Object.assign({}, elementMetadata);
872
- // model
873
- var _e = (_a = metadata.model) !== null && _a !== void 0 ? _a : {}, lineItem = _e.lineItem, path = _e.path;
874
- var model = lineItem ? { lineItem: lineItem } : path ? { path: path } : undefined;
875
- if (model) {
876
- metadata.model = model;
877
- }
878
- else {
879
- delete metadata.model;
880
- }
881
- // module
882
- if (!metadata.module) {
883
- delete metadata.module;
884
- }
885
- // reference
886
- if (!metadata.reference) {
887
- delete metadata.reference;
888
- }
889
- // inputs
890
- var inputs = Object.entries((_b = metadata.inputs) !== null && _b !== void 0 ? _b : {}).reduce(function (acc, _e) {
891
- var _f;
892
- var _g = __read(_e, 2), key = _g[0], value = _g[1];
893
- return Object.assign(Object.assign({}, acc), (_f = {}, _f[key] = value || null, _f));
894
- }, {});
895
- if (inputs && Object.keys(inputs).length > 0) {
896
- metadata.inputs = inputs;
897
- }
898
- else {
899
- delete metadata.inputs;
900
- }
901
- // outputs
902
- var outputs = Object.entries((_c = metadata.outputs) !== null && _c !== void 0 ? _c : {}).reduce(function (acc, _e) {
903
- var _f;
904
- var _g = __read(_e, 2), key = _g[0], value = _g[1];
905
- return Object.assign(Object.assign({}, acc), (_f = {}, _f[key] = value || null, _f));
906
- }, {});
907
- if (outputs && Object.keys(outputs).length > 0) {
908
- metadata.outputs = outputs;
909
- }
910
- else {
911
- delete metadata.outputs;
912
- }
913
- // children
914
- if (!((_d = metadata.children) === null || _d === void 0 ? void 0 : _d.length)) {
915
- delete metadata.children;
916
- }
917
- // isShared
918
- if (!metadata.isShared) {
919
- delete metadata.isShared;
920
- }
921
- // configuredStyles
922
- if (!metadata.configuredStyles) {
923
- delete metadata.configuredStyles;
924
- }
925
- return metadata;
926
- };
927
- var extractElementMetadata = function (script) {
928
- var _a;
929
- var metadataString = ((_a = METADATA_DECORATOR_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
930
- // need to reset regex last index to prevent null result for next execution
931
- METADATA_DECORATOR_REGEX.lastIndex = 0;
932
- return new Function("return " + metadataString)();
933
- };
934
- var extendElementMetadata = function (script, extend) {
935
- var _a;
936
- var metadataString = ((_a = METADATA_DECORATOR_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
937
- // need to reset regex last index to prevent null result for next execution
938
- METADATA_DECORATOR_REGEX.lastIndex = 0;
939
- if (!metadataString) {
940
- return script;
941
- }
942
- var updated = Object.assign(Object.assign({}, new Function("return " + metadataString)()), extend);
943
- return script.replace(metadataString, stringifyElementMetadata(updated));
944
- };
945
- var getElementConfig = function (type) {
946
- return CONFIG[type];
947
- };
948
- var doesElementSupportIO = function (type) {
949
- var _a, _b;
950
- return (_b = (_a = getElementConfig(type).plugins) === null || _a === void 0 ? void 0 : _a.includes(IOPlugin)) !== null && _b !== void 0 ? _b : false;
951
- };
952
- function stringifyElementMetadata(elementMetadata) {
953
- var cleaned = JSON.stringify(elementMetadata, null, 2);
954
- return cleaned.replace(/^[\t ]*"[^:\n\r]+(?<!\\)":/gm, function (match) {
955
- return match.replace(/"/g, '');
956
- });
957
- }
958
- var isValidScript = function (script) {
959
- var _a;
960
- if (!script) {
961
- return false;
962
- }
963
- var exportedClassName = script && ((_a = EXPORTED_CLASS_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
964
- if (!exportedClassName) {
965
- return false;
966
- }
967
- var meta = extractElementMetadata(script);
968
- if (!meta.name || !meta.type) {
969
- return false;
970
- }
971
- return true;
972
- };
973
- function flattenElements(elements) {
974
- return lodash.flatten(elements.map(function (el) { return __spreadArray([el], __read(flattenElements(el.children))); }));
975
- }
976
- function isSharedElement(el) {
977
- return Boolean(el.isShared) && el.type !== 'REFERENCE';
978
- }
979
-
980
- var ElementContextService = /** @class */ (function () {
981
- function ElementContextService() {
982
- }
983
- return ElementContextService;
984
- }());
985
- ElementContextService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ElementContextService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
986
- ElementContextService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ElementContextService });
987
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ElementContextService, decorators: [{
925
+ ElementContextService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementContextService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
926
+ ElementContextServiceprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementContextService });
927
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementContextService, decorators: [{
988
928
  type: i0.Injectable
989
929
  }] });
990
930
 
991
931
  var ElementRendererComponent = /** @class */ (function () {
992
- function ElementRendererComponent(parentInjector, dynamicModuleService, elementContext, ioProviderService, configurationService, elementRef, cdr) {
932
+ function ElementRendererComponent(parentInjector, runtimeService, elementContext, ioProviderService, configurationService, elementRef, cdr) {
993
933
  this.parentInjector = parentInjector;
994
- this.dynamicModuleService = dynamicModuleService;
934
+ this.runtimeService = runtimeService;
995
935
  this.elementContext = elementContext;
996
936
  this.ioProviderService = ioProviderService;
997
937
  this.configurationService = configurationService;
@@ -1002,7 +942,7 @@
1002
942
  }
1003
943
  ElementRendererComponent.prototype.ngOnInit = function () {
1004
944
  this.elementContext.metadata = this.meta;
1005
- this.factory = this.dynamicModuleService.getComponentFactory(this.meta);
945
+ this.factory = this.meta.path ? this.runtimeService.componentFactories[this.meta.path] : undefined;
1006
946
  this.createComponents();
1007
947
  };
1008
948
  ElementRendererComponent.prototype.ngOnDestroy = function () {
@@ -1135,9 +1075,9 @@
1135
1075
  };
1136
1076
  return ElementRendererComponent;
1137
1077
  }());
1138
- ElementRendererComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ElementRendererComponent, deps: [{ token: i0__namespace.Injector, skipSelf: true }, { token: DynamicModuleService }, { token: ElementContextService }, { token: IOProviderService }, { token: i2__namespace.ConfigurationService }, { token: i0__namespace.ElementRef }, { token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
1139
- ElementRendererComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: { meta: "meta" }, providers: [ElementContextService], viewQueries: [{ propertyName: "el", first: true, predicate: ["el"], descendants: true, read: i0.ViewContainerRef, static: true }], ngImport: i0__namespace, template: "<ng-template #el></ng-template>\n", styles: [":host{display:contents}\n"], changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
1140
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ElementRendererComponent, decorators: [{
1078
+ ElementRendererComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementRendererComponent, deps: [{ token: i0__namespace.Injector, skipSelf: true }, { token: RuntimeService }, { token: ElementContextService }, { token: IOProviderService }, { token: i2__namespace.ConfigurationService }, { token: i0__namespace.ElementRef }, { token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
1079
+ ElementRendererComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: { meta: "meta" }, providers: [ElementContextService], viewQueries: [{ propertyName: "el", first: true, predicate: ["el"], descendants: true, read: i0.ViewContainerRef, static: true }], ngImport: i0__namespace, template: "<ng-template #el></ng-template>\n", styles: [":host{display:contents}\n"], changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
1080
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementRendererComponent, decorators: [{
1141
1081
  type: i0.Component,
1142
1082
  args: [{
1143
1083
  selector: 'vl-cms-element-renderer',
@@ -1149,7 +1089,7 @@
1149
1089
  }], ctorParameters: function () {
1150
1090
  return [{ type: i0__namespace.Injector, decorators: [{
1151
1091
  type: i0.SkipSelf
1152
- }] }, { type: DynamicModuleService }, { type: ElementContextService }, { type: IOProviderService }, { type: i2__namespace.ConfigurationService }, { type: i0__namespace.ElementRef }, { type: i0__namespace.ChangeDetectorRef }];
1092
+ }] }, { type: RuntimeService }, { type: ElementContextService }, { type: IOProviderService }, { type: i2__namespace.ConfigurationService }, { type: i0__namespace.ElementRef }, { type: i0__namespace.ChangeDetectorRef }];
1153
1093
  }, propDecorators: { el: [{
1154
1094
  type: i0.ViewChild,
1155
1095
  args: ['el', { read: i0.ViewContainerRef, static: true }]
@@ -1157,204 +1097,731 @@
1157
1097
  type: i0.Input
1158
1098
  }] } });
1159
1099
 
1160
- var ElementChildrenComponent = /** @class */ (function () {
1161
- function ElementChildrenComponent(elementContext) {
1162
- this.elementContext = elementContext;
1163
- this.metadata = this.elementContext.metadata;
1164
- }
1165
- return ElementChildrenComponent;
1166
- }());
1167
- ElementChildrenComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ElementChildrenComponent, deps: [{ token: ElementContextService }], target: i0__namespace.ɵɵFactoryTarget.Component });
1168
- ElementChildrenComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: ElementChildrenComponent, selector: "element-children", ngImport: i0__namespace, template: "<ng-container *ngIf=\"metadata?.children.length\">\n <ng-container *ngFor=\"let child of metadata.children\">\n <vl-cms-element-renderer [meta]=\"child\"></vl-cms-element-renderer>\n </ng-container>\n</ng-container>\n", styles: [":host{display:contents}\n"], components: [{ type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: ["meta"] }], changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
1169
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ElementChildrenComponent, decorators: [{
1170
- type: i0.Component,
1171
- args: [{
1172
- // eslint-disable-next-line @angular-eslint/component-selector
1173
- selector: 'element-children',
1174
- templateUrl: 'element-children.component.html',
1175
- styleUrls: ['./element-children.component.scss'],
1176
- changeDetection: i0.ChangeDetectionStrategy.OnPush,
1177
- }]
1178
- }], ctorParameters: function () { return [{ type: ElementContextService }]; } });
1179
-
1180
- // eslint-disable-next-line @angular-eslint/directive-selector
1181
- var CustomTemplateDirective = /** @class */ (function () {
1182
- function CustomTemplateDirective(templateRef, templatesService) {
1183
- this.templateRef = templateRef;
1184
- this.templatesService = templatesService;
1100
+ var PreviewComponent = /** @class */ (function () {
1101
+ function PreviewComponent(runtimeService, configurationService, messageService, configurationRuntimeService, integrationState, cdr) {
1102
+ var _this = this;
1103
+ this.runtimeService = runtimeService;
1104
+ this.configurationService = configurationService;
1105
+ this.messageService = messageService;
1106
+ this.configurationRuntimeService = configurationRuntimeService;
1107
+ this.integrationState = integrationState;
1108
+ this.cdr = cdr;
1109
+ this.state$ = new rxjs.BehaviorSubject({ loading: true, failure: false });
1110
+ this.elements = [];
1111
+ this.destroy$ = new rxjs.Subject();
1112
+ this.runtimeService.updated$.pipe(rxjs.takeUntil(this.destroy$)).subscribe(function () { return _this.cdr.detectChanges(); });
1185
1113
  }
1186
- CustomTemplateDirective.prototype.ngAfterViewInit = function () {
1187
- if (!this.customTemplate) {
1188
- return;
1114
+ PreviewComponent.prototype.ngOnInit = function () {
1115
+ var _a;
1116
+ if (!((_a = this.config) === null || _a === void 0 ? void 0 : _a.suppressClearState)) {
1117
+ this.integrationState.clear();
1189
1118
  }
1190
- this.templatesService.register(this.customTemplate, this.templateRef);
1119
+ this.startPreview();
1191
1120
  };
1192
- return CustomTemplateDirective;
1193
- }());
1194
- CustomTemplateDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: CustomTemplateDirective, deps: [{ token: i0__namespace.TemplateRef }, { token: TemplatesService }], target: i0__namespace.ɵɵFactoryTarget.Directive });
1195
- CustomTemplateDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: CustomTemplateDirective, selector: "[customTemplate]", inputs: { customTemplate: "customTemplate" }, ngImport: i0__namespace });
1196
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: CustomTemplateDirective, decorators: [{
1197
- type: i0.Directive,
1198
- args: [{ selector: '[customTemplate]' }]
1199
- }], ctorParameters: function () { return [{ type: i0__namespace.TemplateRef }, { type: TemplatesService }]; }, propDecorators: { customTemplate: [{
1200
- type: i0.Input
1201
- }] } });
1202
-
1203
- var defaultOptions = {
1204
- suppressLoading: false,
1205
- loadingLabel: 'LOADING',
1206
- };
1207
-
1208
- var moduleMap = {};
1209
- function loadRemoteEntry(remoteEntry) {
1210
- return new Promise(function (resolve, reject) {
1211
- if (moduleMap[remoteEntry]) {
1212
- resolve();
1121
+ PreviewComponent.prototype.ngOnDestroy = function () {
1122
+ this.destroy$.next();
1123
+ this.destroy$.complete();
1124
+ this.configurationService.reset();
1125
+ this.runtimeService.clear();
1126
+ };
1127
+ PreviewComponent.prototype.initializeConfiguration$ = function () {
1128
+ var _this = this;
1129
+ var isAlreadyInitialized = this.configurationRuntimeService.isInitialized;
1130
+ if (!this.uiDefinition || this.uiDefinition.type !== 'CONFIGURATION' || isAlreadyInitialized) {
1131
+ return rxjs.of({});
1132
+ }
1133
+ if (!this.modelId) {
1134
+ console.warn("No modelId is given for uiDefinition with '" + this.uiDefinition.type + "' type");
1135
+ return rxjs.of({});
1136
+ }
1137
+ // If still not initialized - init configuration in Test mode
1138
+ return this.configurationRuntimeService
1139
+ .initTestMode(this.modelId, this.uiDefinition)
1140
+ .pipe(rxjs.switchMap(function () { return _this.configurationService.configure(); }));
1141
+ };
1142
+ PreviewComponent.prototype.startPreview = function () {
1143
+ var _this = this;
1144
+ if (!this.uiDefinition) {
1213
1145
  return;
1214
1146
  }
1215
- var script = document.createElement('script');
1216
- script.src = remoteEntry;
1217
- script.onerror = reject;
1218
- script.onload = function () {
1219
- moduleMap[remoteEntry] = true;
1220
- resolve(); // window is the global namespace
1221
- };
1222
- document.body.append(script);
1223
- });
1224
- }
1225
- function lookupExposedModule(remoteName, exposedModule) {
1226
- return __awaiter(this, void 0, void 0, function () {
1227
- var container, factory, Module;
1228
- return __generator(this, function (_a) {
1229
- switch (_a.label) {
1230
- case 0:
1231
- // Initializes the share scope. This fills it with known provided modules from this build and all remotes
1232
- return [4 /*yield*/, __webpack_init_sharing__('default')];
1233
- case 1:
1234
- // Initializes the share scope. This fills it with known provided modules from this build and all remotes
1235
- _a.sent();
1236
- container = window[remoteName];
1237
- // Initialize the container, it may provide shared modules
1238
- return [4 /*yield*/, container.init(__webpack_share_scopes__.default)];
1239
- case 2:
1240
- // Initialize the container, it may provide shared modules
1241
- _a.sent();
1242
- return [4 /*yield*/, container.get(exposedModule)];
1243
- case 3:
1244
- factory = _a.sent();
1245
- Module = factory();
1246
- return [2 /*return*/, Module];
1147
+ rxjs.forkJoin([this.runtimeService.initialize$(this.uiDefinition, this.config), this.initializeConfiguration$()])
1148
+ .pipe(rxjs.tap(function (_c) {
1149
+ var _d = __read(_c, 1), elements = _d[0];
1150
+ _this.elements = elements;
1151
+ _this.state$.next({ loading: false, failure: false });
1152
+ }), rxjs.catchError(function (error) {
1153
+ var _a, _b;
1154
+ console.error(error);
1155
+ if (!((_b = (_a = _this.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.suppressToastMessages)) {
1156
+ _this.messageService.add({ severity: 'error', summary: error });
1247
1157
  }
1158
+ _this.state$.next({ loading: false, failure: true });
1159
+ return rxjs.of();
1160
+ }), rxjs.takeUntil(this.destroy$))
1161
+ .subscribe();
1162
+ };
1163
+ return PreviewComponent;
1164
+ }());
1165
+ PreviewComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: PreviewComponent, deps: [{ token: RuntimeService }, { token: i2__namespace.ConfigurationService }, { token: i3__namespace.MessageService }, { token: i2__namespace.ConfigurationRuntimeService }, { token: IntegrationState }, { token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
1166
+ PreviewComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: PreviewComponent, selector: "vl-cms-preview", inputs: { modelId: "modelId", uiDefinition: "uiDefinition", config: "config" }, providers: [IOProviderService, TemplatesService], ngImport: i0__namespace, template: "<ng-container *ngIf=\"state$ | async as state\">\n <vl-loader *ngIf=\"state.loading; else content\" [label]=\"'Loading UI'\"></vl-loader>\n\n <ng-template #content>\n <ng-container *ngIf=\"!state.failure\">\n <vl-cms-element-renderer *ngFor=\"let el of elements\" [meta]=\"el\"></vl-cms-element-renderer>\n </ng-container>\n </ng-template>\n</ng-container>\n", styles: [":host{flex-grow:1;display:flex;flex-direction:column;height:100%}\n"], components: [{ type: i1__namespace.LoaderComponent, selector: "vl-loader", inputs: ["label", "overlayVisible"] }, { type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: ["meta"] }], directives: [{ type: i7__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i7__namespace.AsyncPipe }, changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush, encapsulation: i0__namespace.ViewEncapsulation.ShadowDom });
1167
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: PreviewComponent, decorators: [{
1168
+ type: i0.Component,
1169
+ args: [{
1170
+ selector: 'vl-cms-preview',
1171
+ templateUrl: './preview.component.html',
1172
+ styleUrls: ['./preview.component.scss'],
1173
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
1174
+ providers: [IOProviderService, TemplatesService],
1175
+ // use shadow DOM to prevent UI from being affected by global styles
1176
+ encapsulation: i0.ViewEncapsulation.ShadowDom,
1177
+ }]
1178
+ }], ctorParameters: function () { return [{ type: RuntimeService }, { type: i2__namespace.ConfigurationService }, { type: i3__namespace.MessageService }, { type: i2__namespace.ConfigurationRuntimeService }, { type: IntegrationState }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { modelId: [{
1179
+ type: i0.Input
1180
+ }], uiDefinition: [{
1181
+ type: i0.Input
1182
+ }], config: [{
1183
+ type: i0.Input
1184
+ }] } });
1185
+
1186
+ var RuntimeEditorService = /** @class */ (function () {
1187
+ function RuntimeEditorService(runtimeService) {
1188
+ var _this = this;
1189
+ this.runtimeService = runtimeService;
1190
+ this.editorModeSubj$ = new rxjs.BehaviorSubject(false);
1191
+ this.dragMode$ = new rxjs.BehaviorSubject(false);
1192
+ this.elementDropped$ = new rxjs.ReplaySubject();
1193
+ this.elementDeleted$ = new rxjs.ReplaySubject();
1194
+ this.editorMode$ = this.editorModeSubj$.asObservable();
1195
+ this.runtimeService.isInitialized$.subscribe(function () { var _a; return _this.editorModeSubj$.next(Boolean((_a = _this.runtimeService.config) === null || _a === void 0 ? void 0 : _a.uiBuilderMode)); });
1196
+ }
1197
+ RuntimeEditorService.prototype.applyPatch$ = function (patch) {
1198
+ return this.runtimeService.applyPatch$(patch);
1199
+ };
1200
+ RuntimeEditorService.prototype.toggleEditorMode = function () {
1201
+ this.editorModeSubj$.next(!this.editorModeSubj$.value);
1202
+ };
1203
+ return RuntimeEditorService;
1204
+ }());
1205
+ RuntimeEditorService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RuntimeEditorService, deps: [{ token: RuntimeService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1206
+ RuntimeEditorService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RuntimeEditorService });
1207
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RuntimeEditorService, decorators: [{
1208
+ type: i0.Injectable
1209
+ }], ctorParameters: function () { return [{ type: RuntimeService }]; } });
1210
+
1211
+ var ElementDropHandleComponent = /** @class */ (function () {
1212
+ function ElementDropHandleComponent(runtimeService) {
1213
+ this.runtimeService = runtimeService;
1214
+ }
1215
+ ElementDropHandleComponent.prototype.handleDrop = function (e) {
1216
+ this.runtimeService.elementDropped$.next({
1217
+ element: e.data,
1218
+ index: this.index,
1219
+ path: this.parentPath,
1248
1220
  });
1249
- });
1221
+ };
1222
+ return ElementDropHandleComponent;
1223
+ }());
1224
+ ElementDropHandleComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementDropHandleComponent, deps: [{ token: RuntimeEditorService }], target: i0__namespace.ɵɵFactoryTarget.Component });
1225
+ ElementDropHandleComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: ElementDropHandleComponent, selector: "vl-element-drop-handle", inputs: { index: "index", parentPath: "parentPath" }, ngImport: i0__namespace, template: "<div class=\"container\" dndDropzone (dndDrop)=\"handleDrop($event)\">\n <div class=\"handle\"></div>\n</div>\n", styles: [":host{width:0;position:relative}.container{width:40px;height:100%;position:absolute;transform:translate(-50%);display:flex;justify-content:center;align-items:center}.handle{display:none;background:red;height:calc(100% - 10px);width:2px;pointer-events:none}.container.dndDragover .handle{display:block}\n"], directives: [{ type: i2__namespace$1.DndDropzoneDirective, selector: "[dndDropzone]", inputs: ["dndDropzone", "dndEffectAllowed", "dndAllowExternal", "dndHorizontal", "dndDragoverClass", "dndDropzoneDisabledClass", "dndDisableIf", "dndDisableDropIf"], outputs: ["dndDragover", "dndDrop"] }], changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
1226
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementDropHandleComponent, decorators: [{
1227
+ type: i0.Component,
1228
+ args: [{
1229
+ selector: 'vl-element-drop-handle',
1230
+ templateUrl: './element-drop-handle.component.html',
1231
+ styleUrls: ['./element-drop-handle.component.scss'],
1232
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
1233
+ }]
1234
+ }], ctorParameters: function () { return [{ type: RuntimeEditorService }]; }, propDecorators: { index: [{
1235
+ type: i0.Input
1236
+ }], parentPath: [{
1237
+ type: i0.Input
1238
+ }] } });
1239
+
1240
+ var ElementDropHandleModule = /** @class */ (function () {
1241
+ function ElementDropHandleModule() {
1242
+ }
1243
+ return ElementDropHandleModule;
1244
+ }());
1245
+ ElementDropHandleModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementDropHandleModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1246
+ ElementDropHandleModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementDropHandleModule, declarations: [ElementDropHandleComponent], imports: [i7.CommonModule, i2$1.DndModule], exports: [ElementDropHandleComponent] });
1247
+ ElementDropHandleModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementDropHandleModule, imports: [[i7.CommonModule, i2$1.DndModule]] });
1248
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementDropHandleModule, decorators: [{
1249
+ type: i0.NgModule,
1250
+ args: [{
1251
+ declarations: [ElementDropHandleComponent],
1252
+ imports: [i7.CommonModule, i2$1.DndModule],
1253
+ exports: [ElementDropHandleComponent],
1254
+ }]
1255
+ }] });
1256
+
1257
+ var ElementRendererModule = /** @class */ (function () {
1258
+ function ElementRendererModule() {
1259
+ }
1260
+ return ElementRendererModule;
1261
+ }());
1262
+ ElementRendererModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementRendererModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1263
+ ElementRendererModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementRendererModule, declarations: [ElementRendererComponent], exports: [ElementRendererComponent] });
1264
+ ElementRendererModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementRendererModule });
1265
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementRendererModule, decorators: [{
1266
+ type: i0.NgModule,
1267
+ args: [{
1268
+ declarations: [ElementRendererComponent],
1269
+ exports: [ElementRendererComponent],
1270
+ }]
1271
+ }] });
1272
+
1273
+ var ElementChildrenComponent = /** @class */ (function () {
1274
+ function ElementChildrenComponent(elementContext, runtimeService, runtimeEditorService, cdr) {
1275
+ var _this = this;
1276
+ var _a, _b;
1277
+ this.elementContext = elementContext;
1278
+ this.runtimeService = runtimeService;
1279
+ this.runtimeEditorService = runtimeEditorService;
1280
+ this.cdr = cdr;
1281
+ this.destroyed$ = new rxjs.Subject();
1282
+ var path = (_b = (_a = this.elementContext) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.path;
1283
+ this.metadata$ = path ? this.runtimeService.getCompiledElement$(path) : rxjs.of(undefined);
1284
+ this.dragMode$ = rxjs.combineLatest([this.runtimeEditorService.editorMode$, this.runtimeEditorService.dragMode$]).pipe(rxjs.map(function (flags) { return flags.every(Boolean); }));
1285
+ this.runtimeService.updated$.pipe(rxjs.takeUntil(this.destroyed$)).subscribe(function () { return _this.cdr.detectChanges(); });
1286
+ }
1287
+ ElementChildrenComponent.prototype.ngOnDestroy = function () {
1288
+ this.destroyed$.next();
1289
+ this.destroyed$.complete();
1290
+ };
1291
+ return ElementChildrenComponent;
1292
+ }());
1293
+ ElementChildrenComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementChildrenComponent, deps: [{ token: ElementContextService }, { token: RuntimeService }, { token: RuntimeEditorService }, { token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
1294
+ ElementChildrenComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: ElementChildrenComponent, selector: "element-children", ngImport: i0__namespace, template: "<ng-container *ngIf=\"metadata$ | async as metadata\">\n <vl-element-drop-handle *ngIf=\"dragMode$ | async\" [index]=\"0\" [parentPath]=\"metadata.path\"></vl-element-drop-handle>\n <ng-container *ngFor=\"let child of metadata.children; let i = index\">\n <vl-cms-element-renderer [meta]=\"child\"></vl-cms-element-renderer>\n <vl-element-drop-handle\n *ngIf=\"dragMode$ | async\"\n [index]=\"i + 1\"\n [parentPath]=\"metadata.path\"\n ></vl-element-drop-handle>\n </ng-container>\n</ng-container>\n", styles: [":host{display:contents}\n"], components: [{ type: ElementDropHandleComponent, selector: "vl-element-drop-handle", inputs: ["index", "parentPath"] }, { type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: ["meta"] }], changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
1295
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementChildrenComponent, decorators: [{
1296
+ type: i0.Component,
1297
+ args: [{
1298
+ // eslint-disable-next-line @angular-eslint/component-selector
1299
+ selector: 'element-children',
1300
+ templateUrl: 'element-children.component.html',
1301
+ styleUrls: ['./element-children.component.scss'],
1302
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
1303
+ }]
1304
+ }], ctorParameters: function () { return [{ type: ElementContextService }, { type: RuntimeService }, { type: RuntimeEditorService }, { type: i0__namespace.ChangeDetectorRef }]; } });
1305
+
1306
+ var ElementChildrenModule = /** @class */ (function () {
1307
+ function ElementChildrenModule() {
1308
+ }
1309
+ return ElementChildrenModule;
1310
+ }());
1311
+ ElementChildrenModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementChildrenModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1312
+ ElementChildrenModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementChildrenModule, declarations: [ElementChildrenComponent], imports: [i1.LetDirectiveModule, ElementRendererModule, ElementDropHandleModule], exports: [ElementChildrenComponent] });
1313
+ ElementChildrenModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementChildrenModule, imports: [[i1.LetDirectiveModule, ElementRendererModule, ElementDropHandleModule]] });
1314
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementChildrenModule, decorators: [{
1315
+ type: i0.NgModule,
1316
+ args: [{
1317
+ declarations: [ElementChildrenComponent],
1318
+ imports: [i1.LetDirectiveModule, ElementRendererModule, ElementDropHandleModule],
1319
+ exports: [ElementChildrenComponent],
1320
+ }]
1321
+ }] });
1322
+
1323
+ var PreviewModule = /** @class */ (function () {
1324
+ function PreviewModule() {
1325
+ }
1326
+ return PreviewModule;
1327
+ }());
1328
+ PreviewModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: PreviewModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1329
+ PreviewModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: PreviewModule, declarations: [PreviewComponent], imports: [i7.CommonModule, i1.LoaderModule, ElementRendererModule, ElementChildrenModule, ElementDropHandleModule], exports: [PreviewComponent] });
1330
+ PreviewModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: PreviewModule, providers: [IntegrationState], imports: [[i7.CommonModule, i1.LoaderModule, ElementRendererModule, ElementChildrenModule, ElementDropHandleModule]] });
1331
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: PreviewModule, decorators: [{
1332
+ type: i0.NgModule,
1333
+ args: [{
1334
+ declarations: [PreviewComponent],
1335
+ imports: [i7.CommonModule, i1.LoaderModule, ElementRendererModule, ElementChildrenModule, ElementDropHandleModule],
1336
+ providers: [IntegrationState],
1337
+ exports: [PreviewComponent],
1338
+ }]
1339
+ }] });
1340
+
1341
+ function ElementDefinition(definition) {
1342
+ return function (constructor) {
1343
+ return constructor;
1344
+ };
1250
1345
  }
1251
- function loadRemoteModule(remoteEntry, remoteName, exposedModule) {
1252
- return __awaiter(this, void 0, void 0, function () {
1253
- return __generator(this, function (_a) {
1254
- switch (_a.label) {
1255
- case 0: return [4 /*yield*/, loadRemoteEntry(remoteEntry)];
1256
- case 1:
1257
- _a.sent();
1258
- return [4 /*yield*/, lookupExposedModule(remoteName, exposedModule)];
1259
- case 2: return [2 /*return*/, _a.sent()];
1346
+
1347
+ // eslint-disable-next-line @angular-eslint/directive-selector
1348
+ var CustomTemplateDirective = /** @class */ (function () {
1349
+ function CustomTemplateDirective(templateRef, templatesService) {
1350
+ this.templateRef = templateRef;
1351
+ this.templatesService = templatesService;
1352
+ }
1353
+ CustomTemplateDirective.prototype.ngAfterViewInit = function () {
1354
+ if (!this.customTemplate) {
1355
+ return;
1356
+ }
1357
+ this.templatesService.register(this.customTemplate, this.templateRef);
1358
+ };
1359
+ return CustomTemplateDirective;
1360
+ }());
1361
+ CustomTemplateDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: CustomTemplateDirective, deps: [{ token: i0__namespace.TemplateRef }, { token: TemplatesService }], target: i0__namespace.ɵɵFactoryTarget.Directive });
1362
+ CustomTemplateDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: CustomTemplateDirective, selector: "[customTemplate]", inputs: { customTemplate: "customTemplate" }, ngImport: i0__namespace });
1363
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: CustomTemplateDirective, decorators: [{
1364
+ type: i0.Directive,
1365
+ args: [{ selector: '[customTemplate]' }]
1366
+ }], ctorParameters: function () { return [{ type: i0__namespace.TemplateRef }, { type: TemplatesService }]; }, propDecorators: { customTemplate: [{
1367
+ type: i0.Input
1368
+ }] } });
1369
+
1370
+ var ElementHoverPlugin = /** @class */ (function () {
1371
+ function ElementHoverPlugin(host) {
1372
+ var _this = this;
1373
+ this.host = host;
1374
+ this.hoverClassName = 'element-hover';
1375
+ this.color = 'red';
1376
+ this.highlighted = false;
1377
+ this.destroyed$ = new rxjs.Subject();
1378
+ this.el = this.host.injector.get(i0.ElementRef);
1379
+ this.metadata = this.host.injector.get(ELEMENT_METADATA);
1380
+ this.document = this.host.injector.get(i7.DOCUMENT);
1381
+ this.runtimeEditorService = this.host.injector.get(RuntimeEditorService);
1382
+ this.mouseOverListenerBound = this.mouseOverListener.bind(this);
1383
+ this.mouseLeaveListenerBound = this.mouseLeaveListener.bind(this);
1384
+ this.runtimeEditorService.editorMode$.pipe(rxjs.takeUntil(this.destroyed$)).subscribe(function (editorMode) {
1385
+ if (editorMode) {
1386
+ _this.attachListeners();
1387
+ }
1388
+ else {
1389
+ _this.detachListeners();
1390
+ }
1391
+ });
1392
+ }
1393
+ ElementHoverPlugin.prototype.ngOnDestroy = function () {
1394
+ this.destroyed$.next();
1395
+ this.destroyed$.complete();
1396
+ this.detachListeners();
1397
+ };
1398
+ ElementHoverPlugin.prototype.attachListeners = function () {
1399
+ this.el.nativeElement.addEventListener('mouseover', this.mouseOverListenerBound);
1400
+ this.el.nativeElement.addEventListener('mouseleave', this.mouseLeaveListenerBound);
1401
+ };
1402
+ ElementHoverPlugin.prototype.detachListeners = function () {
1403
+ this.el.nativeElement.removeEventListener('mouseover', this.mouseOverListenerBound);
1404
+ this.el.nativeElement.removeEventListener('mouseleave', this.mouseLeaveListenerBound);
1405
+ };
1406
+ ElementHoverPlugin.prototype.mouseOverListener = function (e) {
1407
+ var _this = this;
1408
+ var path = e.composedPath();
1409
+ var innerPath = path.slice(0, path.indexOf(this.el.nativeElement));
1410
+ var hasChildHovered = innerPath.some(function (target) {
1411
+ var t = target;
1412
+ return t.tagName === 'VL-ELEMENT' && t.classList.contains(_this.hoverClassName);
1413
+ });
1414
+ if (hasChildHovered) {
1415
+ this.removeHighlight();
1416
+ }
1417
+ else {
1418
+ this.addHighlight();
1419
+ }
1420
+ };
1421
+ ElementHoverPlugin.prototype.mouseLeaveListener = function () {
1422
+ this.removeHighlight();
1423
+ };
1424
+ ElementHoverPlugin.prototype.addHighlight = function () {
1425
+ if (this.highlighted) {
1426
+ return;
1427
+ }
1428
+ this.highlighted = true;
1429
+ this.el.nativeElement.classList.add(this.hoverClassName);
1430
+ var overlay = this.createContainer();
1431
+ this.addRemoveButton(overlay);
1432
+ this.addElementName(overlay);
1433
+ this.el.nativeElement.appendChild(overlay);
1434
+ this.overlayEl = overlay;
1435
+ };
1436
+ ElementHoverPlugin.prototype.removeHighlight = function () {
1437
+ if (!this.highlighted) {
1438
+ return;
1439
+ }
1440
+ this.highlighted = false;
1441
+ this.el.nativeElement.style.boxShadow = '';
1442
+ this.el.nativeElement.classList.remove(this.hoverClassName);
1443
+ this.deleteRemoveButton();
1444
+ };
1445
+ ElementHoverPlugin.prototype.createContainer = function () {
1446
+ var hostRect = this.el.nativeElement.getBoundingClientRect();
1447
+ var div = this.document.createElement('div');
1448
+ lodash.merge(div.style, {
1449
+ position: 'fixed',
1450
+ display: 'block',
1451
+ pointerEvents: 'none',
1452
+ left: '0',
1453
+ top: '0',
1454
+ fontSize: '10px',
1455
+ lineHeight: "12px",
1456
+ fontWeight: '400',
1457
+ color: '#fff',
1458
+ width: hostRect.width + "px",
1459
+ height: hostRect.height + "px",
1460
+ transform: "translate(" + hostRect.left + "px, " + hostRect.top + "px)",
1461
+ boxSizing: 'border-box',
1462
+ boxShadow: "inset 0 0 0 1px " + this.color,
1463
+ });
1464
+ return div;
1465
+ };
1466
+ ElementHoverPlugin.prototype.addRemoveButton = function (container) {
1467
+ var _this = this;
1468
+ if (this.metadata.type === 'LAYOUT_REGION') {
1469
+ return;
1470
+ }
1471
+ var buttonEl = this.document.createElement('div');
1472
+ var buttonSize = 12;
1473
+ lodash.merge(buttonEl.style, {
1474
+ bottom: '100%',
1475
+ right: '0',
1476
+ width: buttonSize + "px",
1477
+ height: buttonSize + "px",
1478
+ padding: '1px',
1479
+ textAlign: 'center',
1480
+ backgroundColor: this.color,
1481
+ position: 'absolute',
1482
+ cursor: 'pointer',
1483
+ display: 'block',
1484
+ pointerEvents: 'all',
1485
+ });
1486
+ buttonEl.innerHTML = '&#10005;';
1487
+ buttonEl.addEventListener('click', function () {
1488
+ if (_this.metadata.path) {
1489
+ _this.runtimeEditorService.elementDeleted$.next({ path: _this.metadata.path });
1260
1490
  }
1261
1491
  });
1492
+ container.appendChild(buttonEl);
1493
+ };
1494
+ ElementHoverPlugin.prototype.addElementName = function (container) {
1495
+ var nameEl = this.document.createElement('div');
1496
+ lodash.merge(nameEl.style, {
1497
+ bottom: '100%',
1498
+ left: '0',
1499
+ height: "12px",
1500
+ backgroundColor: this.color,
1501
+ position: 'absolute',
1502
+ padding: '1px 2px',
1503
+ display: 'block',
1504
+ pointerEvents: 'all',
1505
+ });
1506
+ nameEl.innerHTML = this.metadata.name;
1507
+ container.appendChild(nameEl);
1508
+ };
1509
+ ElementHoverPlugin.prototype.deleteRemoveButton = function () {
1510
+ if (this.overlayEl) {
1511
+ this.el.nativeElement.removeChild(this.overlayEl);
1512
+ this.overlayEl = undefined;
1513
+ }
1514
+ };
1515
+ return ElementHoverPlugin;
1516
+ }());
1517
+ ElementHoverPlugin.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementHoverPlugin, deps: [{ token: exports.ElementComponent }], target: i0__namespace.ɵɵFactoryTarget.Directive });
1518
+ ElementHoverPlugin.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: ElementHoverPlugin, ngImport: i0__namespace });
1519
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ElementHoverPlugin, decorators: [{
1520
+ type: i0.Directive
1521
+ }], ctorParameters: function () { return [{ type: exports.ElementComponent }]; } });
1522
+
1523
+ var IOPlugin = /** @class */ (function () {
1524
+ function IOPlugin(host) {
1525
+ var _this = this;
1526
+ var _a, _b;
1527
+ this.host = host;
1528
+ var elementMetadata = this.host.injector.get(ELEMENT_METADATA);
1529
+ var inputProvider = this.host.injector.get(IOProviderService);
1530
+ var inputs = Object.entries((_a = elementMetadata.inputs) !== null && _a !== void 0 ? _a : {});
1531
+ var outputs = Object.entries((_b = elementMetadata.outputs) !== null && _b !== void 0 ? _b : {});
1532
+ inputs.forEach(function (_c) {
1533
+ var _d = __read(_c, 2), key = _d[0], path = _d[1];
1534
+ var _a;
1535
+ if (path && typeof path !== 'string') {
1536
+ console.error("The value of '" + key + "' input should be a string");
1537
+ }
1538
+ if (((_a = elementMetadata.outputs) === null || _a === void 0 ? void 0 : _a[key]) !== undefined) {
1539
+ console.warn("'" + key + "' appears both in inputs and outputs. To prevent inconsistent behavior please keep them unique ");
1540
+ }
1541
+ _this.host[key] = inputProvider.connect(elementMetadata, key, path);
1542
+ });
1543
+ outputs.forEach(function (_c) {
1544
+ var _d = __read(_c, 2), key = _d[0], path = _d[1];
1545
+ if (path && typeof path !== 'string') {
1546
+ console.error("The value of '" + key + "' output should be a string");
1547
+ }
1548
+ _this.host[key] = inputProvider.provide(elementMetadata, key, path);
1549
+ });
1550
+ }
1551
+ return IOPlugin;
1552
+ }());
1553
+ IOPlugin.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: IOPlugin, deps: [{ token: exports.ElementComponent }], target: i0__namespace.ɵɵFactoryTarget.Directive });
1554
+ IOPlugin.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: IOPlugin, ngImport: i0__namespace });
1555
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: IOPlugin, decorators: [{
1556
+ type: i0.Directive
1557
+ }], ctorParameters: function () { return [{ type: exports.ElementComponent }]; } });
1558
+
1559
+ var ScriptPlugin = /** @class */ (function () {
1560
+ function ScriptPlugin(host) {
1561
+ var _this = this;
1562
+ this.host = host;
1563
+ this.normalizeImports = function (script, elementPath) {
1564
+ var regexp = new RegExp("import([ \\n\\t]*(?:[^ \\n\\t\\{\\}]+[ \\n\\t]*,?)?(?:[ \\n\\t]*\\{(?:[ \\n\\t]*[^ \\n\\t\"'\\{\\}]+[ \\n\\t]*,?)+\\})?[ \\n\\t]*)from[ \\n\\t]*(['\"])([^'\"\\n]+)(?:['\"]);", 'g');
1565
+ var result = script.replace(regexp, function (match, g1, g2, src) {
1566
+ var imports = g1
1567
+ .trim()
1568
+ .slice(1, -1)
1569
+ .split(',')
1570
+ .map(function (item) { return item.trim(); });
1571
+ imports.forEach(function (item) {
1572
+ var _a;
1573
+ if (!((_a = _this.vendorMap[src]) === null || _a === void 0 ? void 0 : _a[item])) {
1574
+ throw new Error("Failed to import " + item + " from '" + src + "' in " + elementPath + "/script.ts");
1575
+ }
1576
+ });
1577
+ return "const " + g1 + " = vendor['" + src + "'];";
1578
+ });
1579
+ return result;
1580
+ };
1581
+ this.document = this.host.injector.get(i7.DOCUMENT);
1582
+ this.vendorMap = this.host.injector.get(VENDOR_MAP);
1583
+ var elementMetadata = this.host.injector.get(ELEMENT_METADATA);
1584
+ var sharedElementMetadata = this.host.injector.get(SHARED_ELEMENT_METADATA);
1585
+ this.addScript(sharedElementMetadata);
1586
+ this.addScript(elementMetadata);
1587
+ }
1588
+ ScriptPlugin.prototype.addScript = function (metadata) {
1589
+ var _a;
1590
+ if (!(metadata === null || metadata === void 0 ? void 0 : metadata.script)) {
1591
+ return;
1592
+ }
1593
+ var id = btoa(core.UUID.UUID());
1594
+ var script = this.document.createElement('script');
1595
+ script.type = "text/javascript";
1596
+ var scriptContent = this.normalizeImports(metadata.script, (_a = metadata.path) !== null && _a !== void 0 ? _a : metadata.name);
1597
+ var classMatch = /export class (\S+)/.exec(scriptContent);
1598
+ var className = classMatch === null || classMatch === void 0 ? void 0 : classMatch[1];
1599
+ if (!classMatch || !className) {
1600
+ console.error("Script doesn't have exported class");
1601
+ return;
1602
+ }
1603
+ scriptContent = scriptContent.replace(classMatch[0], "class " + className);
1604
+ script.text = "var " + id + " = function(vendor) {" + scriptContent + "\n return " + className + "; };";
1605
+ this.document.body.appendChild(script);
1606
+ var ScriptClass = window[id](this.vendorMap);
1607
+ if (ScriptClass instanceof Object) {
1608
+ this.host.registerPlugin(new ScriptClass(this.host));
1609
+ }
1610
+ this.document.body.removeChild(script);
1611
+ };
1612
+ return ScriptPlugin;
1613
+ }());
1614
+ ScriptPlugin.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ScriptPlugin, deps: [{ token: exports.ElementComponent }], target: i0__namespace.ɵɵFactoryTarget.Directive });
1615
+ ScriptPlugin.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: ScriptPlugin, ngImport: i0__namespace });
1616
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ScriptPlugin, decorators: [{
1617
+ type: i0.Directive
1618
+ }], ctorParameters: function () { return [{ type: exports.ElementComponent }]; } });
1619
+
1620
+ /*
1621
+ * ScriptPlugin must always be the last plugin in the list to make sure user code is running after all pre-initializers.
1622
+ */
1623
+ var CONFIG = {
1624
+ CUSTOM: {
1625
+ component: exports.ElementComponent,
1626
+ plugins: [ElementHoverPlugin, IOPlugin, ScriptPlugin],
1627
+ },
1628
+ CONTAINER: {
1629
+ component: exports.ElementComponent,
1630
+ defaultTemplate: '<element-children></element-children>',
1631
+ plugins: [ElementHoverPlugin, ScriptPlugin],
1632
+ },
1633
+ SERVICE: {
1634
+ component: exports.ElementComponent,
1635
+ plugins: [IOPlugin, ScriptPlugin],
1636
+ suppressTemplate: true,
1637
+ suppressStyles: true,
1638
+ },
1639
+ REFERENCE: {
1640
+ component: exports.ElementComponent,
1641
+ plugins: [ElementHoverPlugin, IOPlugin, ScriptPlugin],
1642
+ suppressTemplate: true,
1643
+ },
1644
+ PAGE: {
1645
+ component: exports.ElementComponent,
1646
+ plugins: [ElementHoverPlugin, IOPlugin, ScriptPlugin],
1647
+ },
1648
+ PAGE_LAYOUT: {
1649
+ component: exports.ElementComponent,
1650
+ plugins: [ElementHoverPlugin, IOPlugin, ScriptPlugin],
1651
+ },
1652
+ LAYOUT_REGION: {
1653
+ component: exports.ElementComponent,
1654
+ plugins: [ElementHoverPlugin, IOPlugin, ScriptPlugin],
1655
+ },
1656
+ };
1657
+
1658
+ var EXPORTED_CLASS_REGEX = /export class (\S+)/;
1659
+ var METADATA_DECORATOR_REGEX = /@ElementDefinition\(([\s\S]+)\)(\n|\r\n|.)*export class/g;
1660
+ var UiBuildError = /** @class */ (function (_super) {
1661
+ __extends(UiBuildError, _super);
1662
+ function UiBuildError(message, affectedMetadata) {
1663
+ var _this = _super.call(this, message) || this;
1664
+ _this.name = _this.constructor.name;
1665
+ _this.affectedMetadata = affectedMetadata;
1666
+ return _this;
1667
+ }
1668
+ return UiBuildError;
1669
+ }(Error));
1670
+ var elementToMetadata = function (el, parentPath) {
1671
+ var _a;
1672
+ var script = el.script && window.atob(el.script);
1673
+ var template = el.template && window.atob(el.template);
1674
+ var styles = el.styles && window.atob(el.styles);
1675
+ var exportedClassName = script && ((_a = EXPORTED_CLASS_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
1676
+ if (!exportedClassName) {
1677
+ throw new Error("Script doesn't have exported class");
1678
+ }
1679
+ var elementMetadata = extractElementMetadata(script || '');
1680
+ var path = (parentPath ? parentPath + '/' : '') + elementMetadata.name;
1681
+ return Object.assign(Object.assign({}, elementMetadata), { path: path, script: script === null || script === void 0 ? void 0 : script.replace(METADATA_DECORATOR_REGEX, 'export class'), template: template, styles: styles, children: el.children.map(function (child) { return elementToMetadata(child, path); }) });
1682
+ };
1683
+ var metadataToElement = function (metadata, recursive) {
1684
+ if (recursive === void 0) { recursive = true; }
1685
+ var elMetadata = {
1686
+ name: metadata.name,
1687
+ isShared: metadata.isShared,
1688
+ type: metadata.type,
1689
+ model: metadata.model,
1690
+ module: metadata.module,
1691
+ reference: metadata.reference,
1692
+ inputs: metadata.inputs,
1693
+ outputs: metadata.outputs,
1694
+ children: metadata.children.map(function (_e) {
1695
+ var name = _e.name;
1696
+ return name;
1697
+ }),
1698
+ configuredStyles: metadata.configuredStyles,
1699
+ };
1700
+ var normalizedElMetadata = normalizeElementMetadata(elMetadata);
1701
+ if (!metadata.script || !EXPORTED_CLASS_REGEX.test(metadata.script)) {
1702
+ throw new UiBuildError("'" + metadata.name + "' component script is missing an exported class", metadata);
1703
+ }
1704
+ var script = metadata.script &&
1705
+ window.btoa(metadata.script.replace(EXPORTED_CLASS_REGEX, "@ElementDefinition(" + stringifyElementMetadata(normalizedElMetadata) + ")\nexport class Script"));
1706
+ var template = metadata.template && window.btoa(metadata.template);
1707
+ var styles = metadata.styles && window.btoa(metadata.styles);
1708
+ return {
1709
+ script: script,
1710
+ template: template,
1711
+ styles: styles,
1712
+ children: recursive ? metadata.children.map(function (meta) { return metadataToElement(meta); }) : [],
1713
+ };
1714
+ };
1715
+ var normalizeElementMetadata = function (elementMetadata) {
1716
+ var _a, _b, _c, _d;
1717
+ var metadata = Object.assign({}, elementMetadata);
1718
+ // model
1719
+ var _e = (_a = metadata.model) !== null && _a !== void 0 ? _a : {}, lineItem = _e.lineItem, path = _e.path;
1720
+ var model = lineItem ? { lineItem: lineItem } : path ? { path: path } : undefined;
1721
+ if (model) {
1722
+ metadata.model = model;
1723
+ }
1724
+ else {
1725
+ delete metadata.model;
1726
+ }
1727
+ // module
1728
+ if (!metadata.module) {
1729
+ delete metadata.module;
1730
+ }
1731
+ // reference
1732
+ if (!metadata.reference) {
1733
+ delete metadata.reference;
1734
+ }
1735
+ // inputs
1736
+ var inputs = Object.entries((_b = metadata.inputs) !== null && _b !== void 0 ? _b : {}).reduce(function (acc, _e) {
1737
+ var _f;
1738
+ var _g = __read(_e, 2), key = _g[0], value = _g[1];
1739
+ return Object.assign(Object.assign({}, acc), (_f = {}, _f[key] = value || null, _f));
1740
+ }, {});
1741
+ if (inputs && Object.keys(inputs).length > 0) {
1742
+ metadata.inputs = inputs;
1743
+ }
1744
+ else {
1745
+ delete metadata.inputs;
1746
+ }
1747
+ // outputs
1748
+ var outputs = Object.entries((_c = metadata.outputs) !== null && _c !== void 0 ? _c : {}).reduce(function (acc, _e) {
1749
+ var _f;
1750
+ var _g = __read(_e, 2), key = _g[0], value = _g[1];
1751
+ return Object.assign(Object.assign({}, acc), (_f = {}, _f[key] = value || null, _f));
1752
+ }, {});
1753
+ if (outputs && Object.keys(outputs).length > 0) {
1754
+ metadata.outputs = outputs;
1755
+ }
1756
+ else {
1757
+ delete metadata.outputs;
1758
+ }
1759
+ // children
1760
+ if (!((_d = metadata.children) === null || _d === void 0 ? void 0 : _d.length)) {
1761
+ delete metadata.children;
1762
+ }
1763
+ // isShared
1764
+ if (!metadata.isShared) {
1765
+ delete metadata.isShared;
1766
+ }
1767
+ // configuredStyles
1768
+ if (!metadata.configuredStyles) {
1769
+ delete metadata.configuredStyles;
1770
+ }
1771
+ return metadata;
1772
+ };
1773
+ var extractElementMetadata = function (script) {
1774
+ var _a;
1775
+ var metadataString = ((_a = METADATA_DECORATOR_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
1776
+ // need to reset regex last index to prevent null result for next execution
1777
+ METADATA_DECORATOR_REGEX.lastIndex = 0;
1778
+ return new Function("return " + metadataString)();
1779
+ };
1780
+ var extendElementMetadata = function (script, extend) {
1781
+ var _a;
1782
+ var metadataString = ((_a = METADATA_DECORATOR_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
1783
+ // need to reset regex last index to prevent null result for next execution
1784
+ METADATA_DECORATOR_REGEX.lastIndex = 0;
1785
+ if (!metadataString) {
1786
+ return script;
1787
+ }
1788
+ var updated = Object.assign(Object.assign({}, new Function("return " + metadataString)()), extend);
1789
+ return script.replace(metadataString, stringifyElementMetadata(updated));
1790
+ };
1791
+ var getElementConfig = function (type) {
1792
+ return CONFIG[type];
1793
+ };
1794
+ var doesElementSupportIO = function (type) {
1795
+ var _a, _b;
1796
+ return (_b = (_a = getElementConfig(type).plugins) === null || _a === void 0 ? void 0 : _a.includes(IOPlugin)) !== null && _b !== void 0 ? _b : false;
1797
+ };
1798
+ function stringifyElementMetadata(elementMetadata) {
1799
+ var cleaned = JSON.stringify(elementMetadata, null, 2);
1800
+ return cleaned.replace(/^[\t ]*"[^:\n\r]+(?<!\\)":/gm, function (match) {
1801
+ return match.replace(/"/g, '');
1262
1802
  });
1263
1803
  }
1264
-
1265
- var FederatedComponent = /** @class */ (function () {
1266
- function FederatedComponent(injector, compiler, appRef, renderer) {
1267
- this.injector = injector;
1268
- this.compiler = compiler;
1269
- this.appRef = appRef;
1270
- this.renderer = renderer;
1271
- this.isLoading$ = new rxjs.BehaviorSubject(false);
1272
- // configs
1273
- this.suppressLoading = defaultOptions.suppressLoading;
1274
- this.loadingLabel = defaultOptions.loadingLabel;
1804
+ var isValidScript = function (script) {
1805
+ var _a;
1806
+ if (!script) {
1807
+ return false;
1275
1808
  }
1276
- FederatedComponent.prototype.ngOnChanges = function (changes) {
1277
- var _a, _b, _c, _d;
1278
- if (changes.data && this.instance) {
1279
- this.instance.data = this.data;
1280
- }
1281
- if (changes.options) {
1282
- this.suppressLoading = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.suppressLoading) !== null && _b !== void 0 ? _b : defaultOptions.suppressLoading;
1283
- this.loadingLabel = (_d = (_c = this.options) === null || _c === void 0 ? void 0 : _c.loadingLabel) !== null && _d !== void 0 ? _d : defaultOptions.loadingLabel;
1284
- }
1285
- };
1286
- FederatedComponent.prototype.ngOnInit = function () {
1287
- this.isLoading$.next(true);
1288
- };
1289
- FederatedComponent.prototype.ngAfterViewInit = function () {
1290
- var _this = this;
1291
- var _a, _b, _c, _d, _e, _f;
1292
- var remoteEntry = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.remoteEntry) !== null && _b !== void 0 ? _b : this.remoteEntry;
1293
- var remoteName = (_d = (_c = this.options) === null || _c === void 0 ? void 0 : _c.remoteName) !== null && _d !== void 0 ? _d : this.remoteName;
1294
- var exposedModule = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.exposedModule) !== null && _f !== void 0 ? _f : this.exposedModule;
1295
- if (!remoteEntry || !remoteName || !exposedModule) {
1296
- return;
1297
- }
1298
- loadRemoteModule(remoteEntry, remoteName, exposedModule).then(function (federated) {
1299
- _this.compiler.compileModuleAsync(federated[exposedModule]).then(function (moduleFactory) {
1300
- var _a, _b, _c;
1301
- var rootModuleRef = moduleFactory.create(_this.injector);
1302
- var rootComponentFactory = rootModuleRef.componentFactoryResolver.resolveComponentFactory(federated[exposedModule].rootComponent);
1303
- var node = document.createElement('div');
1304
- var _g = rootComponentFactory.create(_this.injector, [], node), instance = _g.instance, hostView = _g.hostView;
1305
- _this.instance = instance;
1306
- _this.instance.data = _this.data;
1307
- _this.renderer.appendChild((_a = _this.moduleHostRef) === null || _a === void 0 ? void 0 : _a.nativeElement, node);
1308
- _this.appRef.attachView(hostView);
1309
- (_c = (_b = _this.options) === null || _b === void 0 ? void 0 : _b.onReady) === null || _c === void 0 ? void 0 : _c.call(_b);
1310
- _this.isLoading$.next(false);
1311
- });
1312
- });
1313
- };
1314
- return FederatedComponent;
1315
- }());
1316
- FederatedComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FederatedComponent, deps: [{ token: i0__namespace.Injector }, { token: i0__namespace.Compiler }, { token: i0__namespace.ApplicationRef }, { token: i0__namespace.Renderer2 }], target: i0__namespace.ɵɵFactoryTarget.Component });
1317
- FederatedComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: FederatedComponent, selector: "veloce-host-federated", inputs: { remoteEntry: "remoteEntry", remoteName: "remoteName", exposedModule: "exposedModule", data: "data", options: "options" }, viewQueries: [{ propertyName: "moduleHostRef", first: true, predicate: ["moduleHost"], descendants: true }], usesOnChanges: true, ngImport: i0__namespace, template: "<div #moduleHost></div>\n\n<vl-loader *ngIf=\"!suppressLoading && (isLoading$ | async)\" [label]=\"loadingLabel\"></vl-loader>\n", styles: [":host{display:block}div{height:100%}\n"], components: [{ type: i1__namespace.LoaderComponent, selector: "vl-loader", inputs: ["label", "overlayVisible"] }], directives: [{ type: i7__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i7__namespace.AsyncPipe }, changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
1318
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FederatedComponent, decorators: [{
1319
- type: i0.Component,
1320
- args: [{
1321
- // eslint-disable-next-line @angular-eslint/component-selector
1322
- selector: 'veloce-host-federated',
1323
- templateUrl: './federated.component.html',
1324
- styleUrls: ['./federated.component.scss'],
1325
- changeDetection: i0.ChangeDetectionStrategy.OnPush,
1326
- }]
1327
- }], ctorParameters: function () { return [{ type: i0__namespace.Injector }, { type: i0__namespace.Compiler }, { type: i0__namespace.ApplicationRef }, { type: i0__namespace.Renderer2 }]; }, propDecorators: { moduleHostRef: [{
1328
- type: i0.ViewChild,
1329
- args: ['moduleHost', { static: false }]
1330
- }], remoteEntry: [{
1331
- type: i0.Input
1332
- }], remoteName: [{
1333
- type: i0.Input
1334
- }], exposedModule: [{
1335
- type: i0.Input
1336
- }], data: [{
1337
- type: i0.Input
1338
- }], options: [{
1339
- type: i0.Input
1340
- }] } });
1341
-
1342
- var FederatedModule = /** @class */ (function () {
1343
- function FederatedModule() {
1809
+ var exportedClassName = script && ((_a = EXPORTED_CLASS_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
1810
+ if (!exportedClassName) {
1811
+ return false;
1344
1812
  }
1345
- return FederatedModule;
1346
- }());
1347
- FederatedModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FederatedModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1348
- FederatedModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FederatedModule, declarations: [FederatedComponent], imports: [i7.CommonModule, i1.LoaderModule], exports: [FederatedComponent] });
1349
- FederatedModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FederatedModule, imports: [[i7.CommonModule, i1.LoaderModule]] });
1350
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FederatedModule, decorators: [{
1351
- type: i0.NgModule,
1352
- args: [{
1353
- declarations: [FederatedComponent],
1354
- imports: [i7.CommonModule, i1.LoaderModule],
1355
- exports: [FederatedComponent],
1356
- }]
1357
- }] });
1813
+ var meta = extractElementMetadata(script);
1814
+ if (!meta.name || !meta.type) {
1815
+ return false;
1816
+ }
1817
+ return true;
1818
+ };
1819
+ function flattenElements(elements) {
1820
+ return lodash.flatten(elements.map(function (el) { return __spreadArray([el], __read(flattenElements(el.children))); }));
1821
+ }
1822
+ function isSharedElement(el) {
1823
+ return Boolean(el.isShared) && el.type !== 'REFERENCE';
1824
+ }
1358
1825
 
1359
1826
  var ConfigurationPlugin = /** @class */ (function () {
1360
1827
  function ConfigurationPlugin(host) {
@@ -1399,7 +1866,15 @@
1399
1866
  }
1400
1867
  _this.configurationService.patch(new i2.LineItemWorker(rootLineItem).remove(_this.modelSnapshot.id).li);
1401
1868
  };
1869
+ var updateQty = function (qty) {
1870
+ var rootLineItem = _this.configurationService.getSnapshot();
1871
+ if (!rootLineItem || !_this.modelSnapshot) {
1872
+ return;
1873
+ }
1874
+ _this.configurationService.patch(new i2.LineItemWorker(rootLineItem).replace(Object.assign(Object.assign({}, _this.modelSnapshot), { qty: qty })).li);
1875
+ };
1402
1876
  this.typeHost.remove = remove;
1877
+ this.typeHost.updateQty = updateQty;
1403
1878
  };
1404
1879
  ConfigurationPlugin.prototype.registerPort = function (name) {
1405
1880
  var _this = this;
@@ -1460,9 +1935,9 @@
1460
1935
  });
1461
1936
  return ConfigurationPlugin;
1462
1937
  }());
1463
- ConfigurationPlugin.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationPlugin, deps: "invalid", target: i0__namespace.ɵɵFactoryTarget.Directive });
1464
- ConfigurationPlugin.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: ConfigurationPlugin, ngImport: i0__namespace });
1465
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationPlugin, decorators: [{
1938
+ ConfigurationPlugin.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationPlugin, deps: "invalid", target: i0__namespace.ɵɵFactoryTarget.Directive });
1939
+ ConfigurationPlugin.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: ConfigurationPlugin, ngImport: i0__namespace });
1940
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationPlugin, decorators: [{
1466
1941
  type: i0.Directive
1467
1942
  }], ctorParameters: function () { return [{ type: undefined }]; } });
1468
1943
 
@@ -1471,54 +1946,8 @@
1471
1946
  DEFAULT: [],
1472
1947
  };
1473
1948
 
1474
- var InitAction = { type: 'INIT' };
1475
- var ClearAction = { type: 'CLEAR' };
1476
- var IntegrationState = /** @class */ (function () {
1477
- function IntegrationState() {
1478
- this.stateSubj$ = new rxjs.BehaviorSubject({});
1479
- this.action$ = new rxjs.BehaviorSubject(InitAction);
1480
- }
1481
- Object.defineProperty(IntegrationState.prototype, "state$", {
1482
- get: function () {
1483
- return this.stateSubj$.asObservable();
1484
- },
1485
- enumerable: false,
1486
- configurable: true
1487
- });
1488
- Object.defineProperty(IntegrationState.prototype, "state", {
1489
- get: function () {
1490
- return this.stateSubj$.getValue();
1491
- },
1492
- enumerable: false,
1493
- configurable: true
1494
- });
1495
- IntegrationState.prototype.patchState = function (update) {
1496
- this.stateSubj$.next(Object.assign(Object.assign({}, this.stateSubj$.getValue()), update));
1497
- };
1498
- IntegrationState.prototype.dispatch = function (action) {
1499
- this.action$.next(action);
1500
- };
1501
- IntegrationState.prototype.listen$ = function (actionType) {
1502
- return this.action$.pipe(rxjs.filter(function (action) { return action.type === actionType; }), rxjs.map(function (action) { return action.payload; }));
1503
- };
1504
- IntegrationState.prototype.listenAll$ = function () {
1505
- return this.action$.asObservable();
1506
- };
1507
- IntegrationState.prototype.clear = function () {
1508
- this.stateSubj$.next({});
1509
- this.action$.next(ClearAction);
1510
- };
1511
- return IntegrationState;
1512
- }());
1513
- IntegrationState.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: IntegrationState, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1514
- IntegrationState.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: IntegrationState, providedIn: 'root' });
1515
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: IntegrationState, decorators: [{
1516
- type: i0.Injectable,
1517
- args: [{ providedIn: 'root' }]
1518
- }] });
1519
-
1520
1949
  var VELOCE_LIBS = {
1521
- '@veloceapps/sdk/core': Object.assign({ ConfigurationService: i2.ConfigurationService, QuoteDraftService: i2.QuoteDraftService, FlowConfigurationService: i2.FlowConfigurationService, LineItemWorker: i2.LineItemWorker, ProductImagesService: i2.ProductImagesService }, i2.lineItemUtils),
1950
+ '@veloceapps/sdk/core': Object.assign({ ConfigurationService: i2.ConfigurationService, QuoteDraftService: i2.QuoteDraftService, FlowConfigurationService: i2.FlowConfigurationService, LineItemWorker: i2.LineItemWorker, ProductImagesService: i2.ProductImagesService, ContextService: i2.ContextService }, i2.lineItemUtils),
1522
1951
  '@veloceapps/sdk/cms': Object.assign(Object.assign(Object.assign({}, cmsInjectionTokens), cmsActions), { TemplatesService: TemplatesService, IntegrationState: IntegrationState }),
1523
1952
  '@veloceapps/api': {
1524
1953
  SalesforceApiService: api.SalesforceApiService,
@@ -1530,6 +1959,11 @@
1530
1959
  DeltaApiService: api.DeltaApiService,
1531
1960
  PicklistsApiService: api.PicklistsApiService,
1532
1961
  PriceApiService: api.PriceApiService,
1962
+ ShoppingCartSettingsApiService: api.ShoppingCartSettingsApiService,
1963
+ ConfigurationSettingsApiService: api.ConfigurationSettingsApiService,
1964
+ },
1965
+ '@veloceapps/components': {
1966
+ ToastService: i1.ToastService,
1533
1967
  },
1534
1968
  };
1535
1969
  var VELOCE_LIBS_BACKWARDS_COMPATIBLE = Object.entries(VELOCE_LIBS).reduce(function (trunk, _a) {
@@ -1540,19 +1974,32 @@
1540
1974
  var vendorMap = Object.assign(Object.assign(Object.assign({}, VELOCE_LIBS), VELOCE_LIBS_BACKWARDS_COMPATIBLE), { '@angular/core': i0__namespace, '@angular/forms': angularForms__namespace, rxjs: rxjs__namespace, 'rxjs/operators': rxjsOperators__namespace, lodash: lodash__namespace });
1541
1975
 
1542
1976
  var ElementsResolver = /** @class */ (function () {
1543
- function ElementsResolver(uiDef, elements) {
1977
+ function ElementsResolver(uiDef, elements, sharedElements) {
1544
1978
  var _this = this;
1979
+ if (sharedElements === void 0) { sharedElements = []; }
1545
1980
  this.uiDef = uiDef;
1546
1981
  this.renderableElements = [];
1547
1982
  this.sharedElements = [];
1548
1983
  var transpiledElements = this.transpileScripts(elements);
1549
- this.sharedElements = this.flattenElements(transpiledElements).filter(function (el) { return _this.isSharedElement(el); });
1550
- this.elements = transpiledElements.map(function (el) { return _this.processElementMetadata(el); }).filter(Boolean);
1984
+ var transpiledSharedElements = this.transpileScripts(sharedElements);
1985
+ this.sharedElements = this.flattenElements(transpiledElements)
1986
+ .filter(function (el) { return _this.isSharedElement(el); })
1987
+ .concat(transpiledSharedElements);
1988
+ this.elements = transpiledElements.map(function (el) { return _this.processElementMetadata(el); }).filter(core.isDefined);
1551
1989
  this.renderableElements = this.getRenderableElements(this.elements);
1552
1990
  }
1991
+ ElementsResolver.prototype.addElement = function (element) {
1992
+ var _this = this;
1993
+ if (element.isShared) {
1994
+ return;
1995
+ }
1996
+ var transpiledElements = this.transpileScripts([element]);
1997
+ this.elements = transpiledElements.map(function (el) { return _this.processElementMetadata(el); }).filter(core.isDefined);
1998
+ this.renderableElements = this.getRenderableElements(this.elements);
1999
+ };
1553
2000
  ElementsResolver.prototype.getNgComponents = function () {
1554
2001
  var _this = this;
1555
- return this.renderableElements.map(function (el) { return _this.resolveElement(el); }).filter(Boolean);
2002
+ return this.renderableElements.map(function (el) { return _this.resolveElement(el); }).filter(core.isDefined);
1556
2003
  };
1557
2004
  ElementsResolver.prototype.transpile = function (el) {
1558
2005
  var _a;
@@ -1634,9 +2081,7 @@
1634
2081
  }
1635
2082
  finalElement.template = this.resolveElementTemplate(finalElement);
1636
2083
  finalElement.styles = this.resolveElementStyles(finalElement);
1637
- return Object.assign(Object.assign({}, finalElement), { children: finalElement.children
1638
- .map(function (child) { return _this.processElementMetadata(child); })
1639
- .filter(Boolean) });
2084
+ return Object.assign(Object.assign({}, finalElement), { children: finalElement.children.map(function (child) { return _this.processElementMetadata(child); }).filter(core.isDefined) });
1640
2085
  };
1641
2086
  ElementsResolver.prototype.getSharedChildren = function (children, parentPath) {
1642
2087
  var _this = this;
@@ -1671,256 +2116,391 @@
1671
2116
  function C() {
1672
2117
  return _super !== null && _super.apply(this, arguments) || this;
1673
2118
  }
1674
- return C;
1675
- }(config.component)));
1676
- lodash.set(cmp, 'path', element.path);
1677
- return cmp;
1678
- };
1679
- ElementsResolver.prototype.getElementStyles = function (element) {
1680
- var result = '';
1681
- var configuredStyles = this.convertInlineStylesToCSS(element.configuredStyles);
1682
- if (configuredStyles) {
1683
- // order is important: styles written by user in CSS code should has higher priority
1684
- result += configuredStyles;
1685
- }
1686
- if (element.styles) {
1687
- result += element.styles;
1688
- }
1689
- return result || undefined;
1690
- };
1691
- ElementsResolver.prototype.convertInlineStylesToCSS = function (styles) {
1692
- if (!styles) {
1693
- return '';
1694
- }
1695
- var entries = Object.entries(styles);
1696
- var result = ':host {\n';
1697
- entries.forEach(function (_c) {
1698
- var _d = __read(_c, 2), style = _d[0], value = _d[1];
1699
- result += " " + lodash.kebabCase(style) + ":" + value + ";\n";
2119
+ return C;
2120
+ }(config.component)));
2121
+ lodash.set(cmp, 'path', element.path);
2122
+ return cmp;
2123
+ };
2124
+ ElementsResolver.prototype.getElementStyles = function (element) {
2125
+ var result = '';
2126
+ var configuredStyles = this.convertInlineStylesToCSS(element.configuredStyles);
2127
+ if (configuredStyles) {
2128
+ // order is important: styles written by user in CSS code should has higher priority
2129
+ result += configuredStyles;
2130
+ }
2131
+ if (element.styles) {
2132
+ result += element.styles;
2133
+ }
2134
+ return result || undefined;
2135
+ };
2136
+ ElementsResolver.prototype.convertInlineStylesToCSS = function (styles) {
2137
+ if (!styles) {
2138
+ return '';
2139
+ }
2140
+ var entries = Object.entries(styles);
2141
+ var result = ':host {\n';
2142
+ entries.forEach(function (_c) {
2143
+ var _d = __read(_c, 2), style = _d[0], value = _d[1];
2144
+ result += " " + lodash.kebabCase(style) + ":" + value + ";\n";
2145
+ });
2146
+ result += '}\n';
2147
+ return result;
2148
+ };
2149
+ return ElementsResolver;
2150
+ }());
2151
+
2152
+ var defaultOptions = {
2153
+ suppressLoading: false,
2154
+ loadingLabel: 'LOADING',
2155
+ };
2156
+
2157
+ var moduleMap = {};
2158
+ function loadRemoteEntry(remoteEntry) {
2159
+ return new Promise(function (resolve, reject) {
2160
+ if (moduleMap[remoteEntry]) {
2161
+ resolve();
2162
+ return;
2163
+ }
2164
+ var script = document.createElement('script');
2165
+ script.src = remoteEntry;
2166
+ script.onerror = reject;
2167
+ script.onload = function () {
2168
+ moduleMap[remoteEntry] = true;
2169
+ resolve(); // window is the global namespace
2170
+ };
2171
+ document.body.append(script);
2172
+ });
2173
+ }
2174
+ function lookupExposedModule(remoteName, exposedModule) {
2175
+ return __awaiter(this, void 0, void 0, function () {
2176
+ var container, factory, Module;
2177
+ return __generator(this, function (_a) {
2178
+ switch (_a.label) {
2179
+ case 0:
2180
+ // Initializes the share scope. This fills it with known provided modules from this build and all remotes
2181
+ return [4 /*yield*/, __webpack_init_sharing__('default')];
2182
+ case 1:
2183
+ // Initializes the share scope. This fills it with known provided modules from this build and all remotes
2184
+ _a.sent();
2185
+ container = window[remoteName];
2186
+ // Initialize the container, it may provide shared modules
2187
+ return [4 /*yield*/, container.init(__webpack_share_scopes__.default)];
2188
+ case 2:
2189
+ // Initialize the container, it may provide shared modules
2190
+ _a.sent();
2191
+ return [4 /*yield*/, container.get(exposedModule)];
2192
+ case 3:
2193
+ factory = _a.sent();
2194
+ Module = factory();
2195
+ return [2 /*return*/, Module];
2196
+ }
1700
2197
  });
1701
- result += '}\n';
1702
- return result;
1703
- };
1704
- return ElementsResolver;
1705
- }());
1706
-
1707
- var LauncherService = /** @class */ (function () {
1708
- function LauncherService(compiler, dynamicModuleService) {
1709
- this.compiler = compiler;
1710
- this.dynamicModuleService = dynamicModuleService;
1711
- }
1712
- LauncherService.prototype.compileModule = function (uiDef, elements) {
1713
- var _this = this;
1714
- var elementsResolver = new ElementsResolver(uiDef, elements);
1715
- this.dynamicModuleService.elementsTree = elementsResolver.elements;
1716
- this.module = this.getModule(elementsResolver.getNgComponents());
1717
- return rxjs.from(this.compiler.compileModuleAndAllComponentsAsync(this.module)).pipe(rxjs.tap(function (m) {
1718
- _this.dynamicModuleService.componentFactories = m.componentFactories;
1719
- _this.moduleInstance = m;
1720
- }), rxjs.map(function (m) { return ({ module: m, elements: elementsResolver.elements }); }));
1721
- };
1722
- LauncherService.prototype.destroy = function () {
1723
- if (this.moduleInstance) {
1724
- this.dynamicModuleService.clear();
1725
- this.moduleInstance = undefined;
1726
- }
1727
- if (this.module) {
1728
- this.compiler.clearCacheFor(this.module);
1729
- this.module = undefined;
1730
- }
1731
- };
1732
- LauncherService.prototype.getModule = function (components) {
1733
- var staticComponents = [ElementChildrenComponent, ElementRendererComponent, CustomTemplateDirective];
1734
- var DynamicModule = /** @class */ (function () {
1735
- function DynamicModule() {
2198
+ });
2199
+ }
2200
+ function loadRemoteModule(remoteEntry, remoteName, exposedModule) {
2201
+ return __awaiter(this, void 0, void 0, function () {
2202
+ return __generator(this, function (_a) {
2203
+ switch (_a.label) {
2204
+ case 0: return [4 /*yield*/, loadRemoteEntry(remoteEntry)];
2205
+ case 1:
2206
+ _a.sent();
2207
+ return [4 /*yield*/, lookupExposedModule(remoteName, exposedModule)];
2208
+ case 2: return [2 /*return*/, _a.sent()];
1736
2209
  }
1737
- return DynamicModule;
1738
- }());
1739
- DynamicModule = __decorate([
1740
- i0.NgModule({
1741
- imports: [i7.CommonModule, angularForms.FormsModule, angularForms.ReactiveFormsModule, FederatedModule, dragDrop.DragDropModule, scrolling.ScrollingModule],
1742
- declarations: __spreadArray(__spreadArray([], __read(staticComponents)), __read(components)),
1743
- jit: true,
1744
- })
1745
- ], DynamicModule);
1746
- return DynamicModule;
1747
- };
1748
- return LauncherService;
1749
- }());
1750
- LauncherService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: LauncherService, deps: [{ token: i0__namespace.Compiler }, { token: DynamicModuleService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1751
- LauncherService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: LauncherService });
1752
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: LauncherService, decorators: [{
1753
- type: i0.Injectable
1754
- }], ctorParameters: function () { return [{ type: i0__namespace.Compiler }, { type: DynamicModuleService }]; } });
2210
+ });
2211
+ });
2212
+ }
1755
2213
 
1756
- var PreviewComponent = /** @class */ (function () {
1757
- function PreviewComponent(launcherService, configurationService, messageService, runtimeService, integrationState) {
1758
- this.launcherService = launcherService;
1759
- this.configurationService = configurationService;
1760
- this.messageService = messageService;
1761
- this.runtimeService = runtimeService;
1762
- this.integrationState = integrationState;
1763
- this.clearState = false;
1764
- this.state$ = new rxjs.BehaviorSubject({ loading: true, failure: false });
1765
- this.elements = [];
1766
- this.destroy$ = new rxjs.Subject();
2214
+ var FederatedComponent = /** @class */ (function () {
2215
+ function FederatedComponent(injector, compiler, appRef, renderer) {
2216
+ this.injector = injector;
2217
+ this.compiler = compiler;
2218
+ this.appRef = appRef;
2219
+ this.renderer = renderer;
2220
+ this.isLoading$ = new rxjs.BehaviorSubject(false);
2221
+ // configs
2222
+ this.suppressLoading = defaultOptions.suppressLoading;
2223
+ this.loadingLabel = defaultOptions.loadingLabel;
1767
2224
  }
1768
- PreviewComponent.prototype.ngOnInit = function () {
1769
- if (this.clearState) {
1770
- this.integrationState.clear();
1771
- }
1772
- this.startPreview();
1773
- };
1774
- PreviewComponent.prototype.ngOnDestroy = function () {
1775
- this.destroy$.next();
1776
- this.destroy$.complete();
1777
- this.configurationService.reset();
1778
- };
1779
- PreviewComponent.prototype.initializeConfiguration$ = function () {
1780
- var _this = this;
1781
- var isAlreadyInitialized = this.runtimeService.isInitialized;
1782
- if (!this.uiDefinition || this.uiDefinition.type !== 'CONFIGURATION' || isAlreadyInitialized) {
1783
- return rxjs.of({});
2225
+ FederatedComponent.prototype.ngOnChanges = function (changes) {
2226
+ var _a, _b, _c, _d;
2227
+ if (changes.data && this.instance) {
2228
+ this.instance.data = this.data;
1784
2229
  }
1785
- if (!this.modelId) {
1786
- console.warn("No modelId is given for uiDefinition with '" + this.uiDefinition.type + "' type");
1787
- return rxjs.of({});
2230
+ if (changes.options) {
2231
+ this.suppressLoading = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.suppressLoading) !== null && _b !== void 0 ? _b : defaultOptions.suppressLoading;
2232
+ this.loadingLabel = (_d = (_c = this.options) === null || _c === void 0 ? void 0 : _c.loadingLabel) !== null && _d !== void 0 ? _d : defaultOptions.loadingLabel;
1788
2233
  }
1789
- // If still not initialized - init configuration in Test mode
1790
- return this.runtimeService
1791
- .initTestMode(this.modelId, this.uiDefinition)
1792
- .pipe(rxjs.switchMap(function () { return _this.configurationService.configure(); }));
1793
2234
  };
1794
- PreviewComponent.prototype.elementToMetadataSafe = function (elements) {
1795
- var _a, _b;
1796
- try {
1797
- return elements.map(function (element) { return elementToMetadata(element); });
1798
- }
1799
- catch (e) {
1800
- console.error(e);
1801
- if (!((_b = (_a = this.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.suppressToastMessages)) {
1802
- this.messageService.add({ severity: 'error', summary: String(e) });
1803
- }
1804
- return [];
1805
- }
2235
+ FederatedComponent.prototype.ngOnInit = function () {
2236
+ this.isLoading$.next(true);
1806
2237
  };
1807
- PreviewComponent.prototype.startPreview = function () {
2238
+ FederatedComponent.prototype.ngAfterViewInit = function () {
1808
2239
  var _this = this;
1809
- if (!this.uiDefinition) {
2240
+ var _a, _b, _c, _d, _e, _f;
2241
+ var remoteEntry = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.remoteEntry) !== null && _b !== void 0 ? _b : this.remoteEntry;
2242
+ var remoteName = (_d = (_c = this.options) === null || _c === void 0 ? void 0 : _c.remoteName) !== null && _d !== void 0 ? _d : this.remoteName;
2243
+ var exposedModule = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.exposedModule) !== null && _f !== void 0 ? _f : this.exposedModule;
2244
+ if (!remoteEntry || !remoteName || !exposedModule) {
1810
2245
  return;
1811
2246
  }
1812
- var _a = this.uiDefinition, children = _a.children, uiDefinitionMeta = __rest(_a, ["children"]);
1813
- var elements = this.elementToMetadataSafe(children);
1814
- var compilation$ = this.launcherService.compileModule(uiDefinitionMeta, elements);
1815
- rxjs.forkJoin([compilation$, this.initializeConfiguration$()])
1816
- .pipe(rxjs.tap(function (_c) {
1817
- var _d = __read(_c, 1), result = _d[0];
1818
- _this.elements = result.elements;
1819
- _this.state$.next({ loading: false, failure: false });
1820
- }), rxjs.catchError(function (error) {
1821
- var _a, _b;
1822
- console.error(error);
1823
- if (!((_b = (_a = _this.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.suppressToastMessages)) {
1824
- _this.messageService.add({ severity: 'error', summary: error });
1825
- }
1826
- _this.state$.next({ loading: false, failure: true });
1827
- return rxjs.of();
1828
- }), rxjs.takeUntil(this.destroy$))
1829
- .subscribe();
2247
+ loadRemoteModule(remoteEntry, remoteName, exposedModule).then(function (federated) {
2248
+ _this.compiler.compileModuleAsync(federated[exposedModule]).then(function (moduleFactory) {
2249
+ var _a, _b, _c;
2250
+ var rootModuleRef = moduleFactory.create(_this.injector);
2251
+ var rootComponentFactory = rootModuleRef.componentFactoryResolver.resolveComponentFactory(federated[exposedModule].rootComponent);
2252
+ var node = document.createElement('div');
2253
+ var _g = rootComponentFactory.create(_this.injector, [], node), instance = _g.instance, hostView = _g.hostView;
2254
+ _this.instance = instance;
2255
+ _this.instance.data = _this.data;
2256
+ _this.renderer.appendChild((_a = _this.moduleHostRef) === null || _a === void 0 ? void 0 : _a.nativeElement, node);
2257
+ _this.appRef.attachView(hostView);
2258
+ (_c = (_b = _this.options) === null || _b === void 0 ? void 0 : _b.onReady) === null || _c === void 0 ? void 0 : _c.call(_b);
2259
+ _this.isLoading$.next(false);
2260
+ });
2261
+ });
1830
2262
  };
1831
- return PreviewComponent;
2263
+ return FederatedComponent;
1832
2264
  }());
1833
- PreviewComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PreviewComponent, deps: [{ token: LauncherService }, { token: i2__namespace.ConfigurationService }, { token: i3__namespace.MessageService }, { token: i2__namespace.ConfigurationRuntimeService }, { token: IntegrationState }], target: i0__namespace.ɵɵFactoryTarget.Component });
1834
- PreviewComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: PreviewComponent, selector: "vl-cms-preview", inputs: { modelId: "modelId", uiDefinition: "uiDefinition", clearState: "clearState" }, providers: [IOProviderService, TemplatesService], ngImport: i0__namespace, template: "<ng-container *ngIf=\"state$ | async as state\">\n <vl-loader *ngIf=\"state.loading; else content\" [label]=\"'Loading UI'\"></vl-loader>\n\n <ng-template #content>\n <ng-container *ngIf=\"!state.failure\">\n <vl-cms-element-renderer *ngFor=\"let el of elements\" [meta]=\"el\"></vl-cms-element-renderer>\n </ng-container>\n </ng-template>\n</ng-container>\n", styles: [":host{flex-grow:1;display:flex;flex-direction:column;height:100%}\n"], components: [{ type: i1__namespace.LoaderComponent, selector: "vl-loader", inputs: ["label", "overlayVisible"] }, { type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: ["meta"] }], directives: [{ type: i7__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i7__namespace.AsyncPipe }, changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush, encapsulation: i0__namespace.ViewEncapsulation.ShadowDom });
1835
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PreviewComponent, decorators: [{
2265
+ FederatedComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FederatedComponent, deps: [{ token: i0__namespace.Injector }, { token: i0__namespace.Compiler }, { token: i0__namespace.ApplicationRef }, { token: i0__namespace.Renderer2 }], target: i0__namespace.ɵɵFactoryTarget.Component });
2266
+ FederatedComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: FederatedComponent, selector: "veloce-host-federated", inputs: { remoteEntry: "remoteEntry", remoteName: "remoteName", exposedModule: "exposedModule", data: "data", options: "options" }, viewQueries: [{ propertyName: "moduleHostRef", first: true, predicate: ["moduleHost"], descendants: true }], usesOnChanges: true, ngImport: i0__namespace, template: "<div #moduleHost></div>\n\n<vl-loader *ngIf=\"!suppressLoading && (isLoading$ | async)\" [label]=\"loadingLabel\"></vl-loader>\n", styles: [":host{display:block}div{height:100%}\n"], components: [{ type: i1__namespace.LoaderComponent, selector: "vl-loader", inputs: ["label", "overlayVisible"] }], directives: [{ type: i7__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i7__namespace.AsyncPipe }, changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
2267
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FederatedComponent, decorators: [{
1836
2268
  type: i0.Component,
1837
2269
  args: [{
1838
- selector: 'vl-cms-preview',
1839
- templateUrl: './preview.component.html',
1840
- styleUrls: ['./preview.component.scss'],
2270
+ // eslint-disable-next-line @angular-eslint/component-selector
2271
+ selector: 'veloce-host-federated',
2272
+ templateUrl: './federated.component.html',
2273
+ styleUrls: ['./federated.component.scss'],
1841
2274
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1842
- providers: [IOProviderService, TemplatesService],
1843
- // use shadow DOM to prevent UI from being affected by global styles
1844
- encapsulation: i0.ViewEncapsulation.ShadowDom,
1845
2275
  }]
1846
- }], ctorParameters: function () { return [{ type: LauncherService }, { type: i2__namespace.ConfigurationService }, { type: i3__namespace.MessageService }, { type: i2__namespace.ConfigurationRuntimeService }, { type: IntegrationState }]; }, propDecorators: { modelId: [{
2276
+ }], ctorParameters: function () { return [{ type: i0__namespace.Injector }, { type: i0__namespace.Compiler }, { type: i0__namespace.ApplicationRef }, { type: i0__namespace.Renderer2 }]; }, propDecorators: { moduleHostRef: [{
2277
+ type: i0.ViewChild,
2278
+ args: ['moduleHost', { static: false }]
2279
+ }], remoteEntry: [{
1847
2280
  type: i0.Input
1848
- }], uiDefinition: [{
2281
+ }], remoteName: [{
2282
+ type: i0.Input
2283
+ }], exposedModule: [{
1849
2284
  type: i0.Input
1850
- }], clearState: [{
2285
+ }], data: [{
2286
+ type: i0.Input
2287
+ }], options: [{
1851
2288
  type: i0.Input
1852
2289
  }] } });
1853
2290
 
1854
- var ElementRendererModule = /** @class */ (function () {
1855
- function ElementRendererModule() {
2291
+ var FederatedModule = /** @class */ (function () {
2292
+ function FederatedModule() {
1856
2293
  }
1857
- return ElementRendererModule;
2294
+ return FederatedModule;
1858
2295
  }());
1859
- ElementRendererModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ElementRendererModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1860
- ElementRendererModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ElementRendererModule, declarations: [ElementRendererComponent], exports: [ElementRendererComponent] });
1861
- ElementRendererModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ElementRendererModule });
1862
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ElementRendererModule, decorators: [{
2296
+ FederatedModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FederatedModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
2297
+ FederatedModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FederatedModule, declarations: [FederatedComponent], imports: [i7.CommonModule, i1.LoaderModule], exports: [FederatedComponent] });
2298
+ FederatedModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FederatedModule, imports: [[i7.CommonModule, i1.LoaderModule]] });
2299
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FederatedModule, decorators: [{
1863
2300
  type: i0.NgModule,
1864
2301
  args: [{
1865
- declarations: [ElementRendererComponent],
1866
- exports: [ElementRendererComponent],
2302
+ declarations: [FederatedComponent],
2303
+ imports: [i7.CommonModule, i1.LoaderModule],
2304
+ exports: [FederatedComponent],
1867
2305
  }]
1868
2306
  }] });
1869
2307
 
1870
- var ElementChildrenModule = /** @class */ (function () {
1871
- function ElementChildrenModule() {
2308
+ var CompilationService = /** @class */ (function () {
2309
+ function CompilationService(compiler) {
2310
+ this.compiler = compiler;
1872
2311
  }
1873
- return ElementChildrenModule;
2312
+ CompilationService.prototype.compileUIDefinition$ = function (uiDefinition) {
2313
+ var _this = this;
2314
+ return rxjs.of([]).pipe(rxjs.switchMap(function () {
2315
+ var children = uiDefinition.children, pages = uiDefinition.pages, components = uiDefinition.components, uiDefinitionMeta = __rest(uiDefinition, ["children", "pages", "components"]);
2316
+ _this.uiDefinitionMeta = uiDefinitionMeta;
2317
+ var elements = __spreadArray(__spreadArray([], __read((children !== null && children !== void 0 ? children : []))), __read((pages !== null && pages !== void 0 ? pages : [])));
2318
+ var sharedElements = components !== null && components !== void 0 ? components : [];
2319
+ var metadata = elements.map(function (element) { return elementToMetadata(element); });
2320
+ var sharedMetadata = sharedElements.map(function (element) { return elementToMetadata(element); });
2321
+ _this.elementsResolver = new ElementsResolver(uiDefinition, metadata, sharedMetadata);
2322
+ var module = _this.getModule(_this.elementsResolver.getNgComponents());
2323
+ return rxjs.combineLatest([
2324
+ rxjs.from(_this.compiler.compileModuleAndAllComponentsAsync(module)),
2325
+ rxjs.of(_this.elementsResolver),
2326
+ ]);
2327
+ }), rxjs.map(function (_b) {
2328
+ var _c = __read(_b, 2), module = _c[0], elementsResolver = _c[1];
2329
+ return ({ module: module, elements: elementsResolver.elements });
2330
+ }));
2331
+ };
2332
+ CompilationService.prototype.compileElement$ = function (element) {
2333
+ var _this = this;
2334
+ if (!this.uiDefinitionMeta) {
2335
+ throw 'No UI Definition context';
2336
+ }
2337
+ return rxjs.of(this.uiDefinitionMeta).pipe(rxjs.switchMap(function (uiDefinition) {
2338
+ var _a;
2339
+ var elementsResolver = (_a = _this.elementsResolver) !== null && _a !== void 0 ? _a : new ElementsResolver(uiDefinition, []);
2340
+ elementsResolver.addElement(element);
2341
+ var module = _this.getModule(elementsResolver.getNgComponents());
2342
+ return rxjs.combineLatest([rxjs.from(_this.compiler.compileModuleAndAllComponentsAsync(module)), rxjs.of(elementsResolver)]);
2343
+ }), rxjs.map(function (_b) {
2344
+ var _c = __read(_b, 2), module = _c[0], elementsResolver = _c[1];
2345
+ return ({ module: module, elements: elementsResolver.elements });
2346
+ }));
2347
+ };
2348
+ CompilationService.prototype.clearModuleCache = function (modules) {
2349
+ var _this = this;
2350
+ modules.forEach(function (module) { return _this.compiler.clearCacheFor(module); });
2351
+ this.uiDefinitionMeta = undefined;
2352
+ };
2353
+ CompilationService.prototype.getModule = function (components) {
2354
+ var staticComponents = [
2355
+ ElementChildrenComponent,
2356
+ ElementRendererComponent,
2357
+ ElementDropHandleComponent,
2358
+ CustomTemplateDirective,
2359
+ ];
2360
+ var DynamicModule = /** @class */ (function () {
2361
+ function DynamicModule() {
2362
+ }
2363
+ return DynamicModule;
2364
+ }());
2365
+ DynamicModule = __decorate([
2366
+ i0.NgModule({
2367
+ imports: [
2368
+ i7.CommonModule,
2369
+ angularForms.FormsModule,
2370
+ angularForms.ReactiveFormsModule,
2371
+ FederatedModule,
2372
+ dragDrop.DragDropModule,
2373
+ i2$1.DndModule,
2374
+ scrolling.ScrollingModule,
2375
+ ],
2376
+ declarations: __spreadArray(__spreadArray([], __read(staticComponents)), __read(components)),
2377
+ jit: true,
2378
+ })
2379
+ ], DynamicModule);
2380
+ return DynamicModule;
2381
+ };
2382
+ return CompilationService;
2383
+ }());
2384
+ CompilationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: CompilationService, deps: [{ token: i0__namespace.Compiler }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2385
+ CompilationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: CompilationService });
2386
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: CompilationService, decorators: [{
2387
+ type: i0.Injectable
2388
+ }], ctorParameters: function () { return [{ type: i0__namespace.Compiler }]; } });
2389
+
2390
+ var RuntimeModule = /** @class */ (function () {
2391
+ function RuntimeModule() {
2392
+ }
2393
+ return RuntimeModule;
1874
2394
  }());
1875
- ElementChildrenModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ElementChildrenModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1876
- ElementChildrenModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ElementChildrenModule, declarations: [ElementChildrenComponent], imports: [ElementRendererModule], exports: [ElementChildrenComponent] });
1877
- ElementChildrenModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ElementChildrenModule, imports: [[ElementRendererModule]] });
1878
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ElementChildrenModule, decorators: [{
2395
+ RuntimeModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RuntimeModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
2396
+ RuntimeModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RuntimeModule, imports: [i7.CommonModule, core.CoreModule] });
2397
+ RuntimeModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RuntimeModule, providers: [
2398
+ dynamicdialog.DialogService,
2399
+ RuntimeService,
2400
+ RuntimeEditorService,
2401
+ { provide: CMS_COMPILATION_SERVICE, useClass: CompilationService },
2402
+ ], imports: [[i7.CommonModule, core.CoreModule]] });
2403
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RuntimeModule, decorators: [{
1879
2404
  type: i0.NgModule,
1880
2405
  args: [{
1881
- declarations: [ElementChildrenComponent],
1882
- imports: [ElementRendererModule],
1883
- exports: [ElementChildrenComponent],
2406
+ imports: [i7.CommonModule, core.CoreModule],
2407
+ providers: [
2408
+ dynamicdialog.DialogService,
2409
+ RuntimeService,
2410
+ RuntimeEditorService,
2411
+ { provide: CMS_COMPILATION_SERVICE, useClass: CompilationService },
2412
+ ],
1884
2413
  }]
1885
2414
  }] });
1886
2415
 
1887
- var PreviewModule = /** @class */ (function () {
1888
- function PreviewModule() {
2416
+ var LauncherModule = /** @class */ (function () {
2417
+ function LauncherModule() {
1889
2418
  }
1890
- return PreviewModule;
2419
+ return LauncherModule;
1891
2420
  }());
1892
- PreviewModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PreviewModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1893
- PreviewModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PreviewModule, declarations: [PreviewComponent], imports: [i7.CommonModule, i1.LoaderModule, ElementRendererModule, ElementChildrenModule], exports: [PreviewComponent] });
1894
- PreviewModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PreviewModule, providers: [IntegrationState], imports: [[i7.CommonModule, i1.LoaderModule, ElementRendererModule, ElementChildrenModule]] });
1895
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PreviewModule, decorators: [{
2421
+ LauncherModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: LauncherModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
2422
+ LauncherModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: LauncherModule, imports: [i7.CommonModule, core.CoreModule, api.ApiModule, i2.SdkCoreModule, RuntimeModule, PreviewModule], exports: [PreviewModule] });
2423
+ LauncherModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: LauncherModule, providers: [IntegrationState, dynamicdialog.DialogService], imports: [[i7.CommonModule, core.CoreModule, api.ApiModule, i2.SdkCoreModule, RuntimeModule, PreviewModule], PreviewModule] });
2424
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: LauncherModule, decorators: [{
1896
2425
  type: i0.NgModule,
1897
2426
  args: [{
1898
- declarations: [PreviewComponent],
1899
- imports: [i7.CommonModule, i1.LoaderModule, ElementRendererModule, ElementChildrenModule],
1900
- providers: [IntegrationState],
1901
- exports: [PreviewComponent],
2427
+ imports: [i7.CommonModule, core.CoreModule, api.ApiModule, i2.SdkCoreModule, RuntimeModule, PreviewModule],
2428
+ providers: [IntegrationState, dynamicdialog.DialogService],
2429
+ exports: [PreviewModule],
1902
2430
  }]
1903
2431
  }] });
1904
2432
 
1905
- function ElementDefinition(definition) {
1906
- return function (constructor) {
1907
- return constructor;
2433
+ var migrations = {
2434
+ 2: function () {
2435
+ throw 'Migration from Legacy UI definition is not possible';
2436
+ },
2437
+ 3: function (uiDef) {
2438
+ var _a;
2439
+ var children = (_a = uiDef.children) !== null && _a !== void 0 ? _a : [];
2440
+ return Object.assign(Object.assign({}, uiDef), { children: undefined, pages: children, version: 3 });
2441
+ },
2442
+ };
2443
+
2444
+ var MigrationsService = /** @class */ (function () {
2445
+ function MigrationsService(toastService) {
2446
+ this.toastService = toastService;
2447
+ }
2448
+ MigrationsService.prototype.migrateUIDefinition = function (uiDef) {
2449
+ var e_1, _a;
2450
+ var currentVersion = uiDef.version;
2451
+ var targetVersion = i2.UI_DEFINITION_VERSION;
2452
+ var migrateVersions = Object.keys(migrations)
2453
+ .reduce(function (acc, version) {
2454
+ var v = Number(version);
2455
+ if (v > currentVersion && v <= targetVersion) {
2456
+ acc.push(v);
2457
+ }
2458
+ return acc;
2459
+ }, [])
2460
+ .sort();
2461
+ try {
2462
+ var result = lodash.cloneDeep(uiDef);
2463
+ try {
2464
+ for (var migrateVersions_1 = __values(migrateVersions), migrateVersions_1_1 = migrateVersions_1.next(); !migrateVersions_1_1.done; migrateVersions_1_1 = migrateVersions_1.next()) {
2465
+ var version = migrateVersions_1_1.value;
2466
+ result = migrations[version](result);
2467
+ }
2468
+ }
2469
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2470
+ finally {
2471
+ try {
2472
+ if (migrateVersions_1_1 && !migrateVersions_1_1.done && (_a = migrateVersions_1.return)) _a.call(migrateVersions_1);
2473
+ }
2474
+ finally { if (e_1) throw e_1.error; }
2475
+ }
2476
+ return result;
2477
+ }
2478
+ catch (e) {
2479
+ this.toastService.add({ summary: String(e), severity: i1.ToastType.error });
2480
+ return;
2481
+ }
1908
2482
  };
1909
- }
2483
+ return MigrationsService;
2484
+ }());
2485
+ MigrationsService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MigrationsService, deps: [{ token: i1__namespace.ToastService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2486
+ MigrationsService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MigrationsService, providedIn: 'root' });
2487
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MigrationsService, decorators: [{
2488
+ type: i0.Injectable,
2489
+ args: [{ providedIn: 'root' }]
2490
+ }], ctorParameters: function () { return [{ type: i1__namespace.ToastService }]; } });
1910
2491
 
1911
- var LauncherModule = /** @class */ (function () {
1912
- function LauncherModule() {
2492
+ var MigrationsModule = /** @class */ (function () {
2493
+ function MigrationsModule() {
1913
2494
  }
1914
- return LauncherModule;
2495
+ return MigrationsModule;
1915
2496
  }());
1916
- LauncherModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: LauncherModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1917
- LauncherModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: LauncherModule, imports: [i7.CommonModule, core.CoreModule, api.ApiModule, i2.SdkCoreModule] });
1918
- LauncherModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: LauncherModule, providers: [LauncherService, IntegrationState, DynamicModuleService, dynamicdialog.DialogService], imports: [[i7.CommonModule, core.CoreModule, api.ApiModule, i2.SdkCoreModule]] });
1919
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: LauncherModule, decorators: [{
2497
+ MigrationsModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MigrationsModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
2498
+ MigrationsModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MigrationsModule });
2499
+ MigrationsModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MigrationsModule, providers: [MigrationsService] });
2500
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MigrationsModule, decorators: [{
1920
2501
  type: i0.NgModule,
1921
2502
  args: [{
1922
- imports: [i7.CommonModule, core.CoreModule, api.ApiModule, i2.SdkCoreModule],
1923
- providers: [LauncherService, IntegrationState, DynamicModuleService, dynamicdialog.DialogService],
2503
+ providers: [MigrationsService],
1924
2504
  }]
1925
2505
  }] });
1926
2506
 
@@ -1938,7 +2518,8 @@
1938
2518
  exports.ElementsResolver = ElementsResolver;
1939
2519
  exports.IntegrationState = IntegrationState;
1940
2520
  exports.LauncherModule = LauncherModule;
1941
- exports.LauncherService = LauncherService;
2521
+ exports.MigrationsModule = MigrationsModule;
2522
+ exports.MigrationsService = MigrationsService;
1942
2523
  exports.NavigateBackAction = NavigateBackAction;
1943
2524
  exports.NavigateToCatalogAction = NavigateToCatalogAction;
1944
2525
  exports.OpenDocGenAction = OpenDocGenAction;
@@ -1946,6 +2527,8 @@
1946
2527
  exports.PreviewModule = PreviewModule;
1947
2528
  exports.RemoteApplyAction = RemoteApplyAction;
1948
2529
  exports.RemoteCancelAction = RemoteCancelAction;
2530
+ exports.RuntimeEditorService = RuntimeEditorService;
2531
+ exports.RuntimeModule = RuntimeModule;
1949
2532
  exports.SHARED_ELEMENT_METADATA = SHARED_ELEMENT_METADATA;
1950
2533
  exports.SetDefaultMetrics = SetDefaultMetrics;
1951
2534
  exports.SwitchObjectAction = SwitchObjectAction;
@@ -1958,15 +2541,19 @@
1958
2541
  exports.extendElementMetadata = extendElementMetadata;
1959
2542
  exports.extractElementMetadata = extractElementMetadata;
1960
2543
  exports.findElementByModule = findElementByModule;
2544
+ exports.findElementByPath = findElementByPath;
1961
2545
  exports.flattenElements = flattenElements;
1962
2546
  exports.getAbsolutePath = getAbsolutePath;
1963
2547
  exports.getElementConfig = getElementConfig;
2548
+ exports.getElementUniqueName = getElementUniqueName;
2549
+ exports.insertElement = insertElement;
1964
2550
  exports.isSharedElement = isSharedElement;
1965
2551
  exports.isValidScript = isValidScript;
1966
2552
  exports.metadataToElement = metadataToElement;
1967
2553
  exports.normalizeElementMetadata = normalizeElementMetadata;
1968
2554
  exports.parseBoundPath = parseBoundPath;
1969
2555
  exports.parsePath = parsePath;
2556
+ exports.removeElement = removeElement;
1970
2557
  exports.stringifyElementMetadata = stringifyElementMetadata;
1971
2558
 
1972
2559
  Object.defineProperty(exports, '__esModule', { value: true });