@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,26 +1,29 @@
1
1
  import { __decorate, __param, __awaiter, __rest } from 'tslib';
2
2
  import * as i0 from '@angular/core';
3
- import { InjectionToken, Component, ChangeDetectionStrategy, Inject, Injector, Injectable, Directive, ViewContainerRef, SkipSelf, ViewChild, Input, NgModule, ViewEncapsulation } from '@angular/core';
3
+ import { InjectionToken, Component, ChangeDetectionStrategy, Inject, Injector, Injectable, ViewContainerRef, SkipSelf, ViewChild, Input, ViewEncapsulation, NgModule, Directive, ElementRef } from '@angular/core';
4
4
  import * as rxjs from 'rxjs';
5
- import { BehaviorSubject, Subject, takeUntil, map, filter, from, tap, of, switchMap, forkJoin, catchError } from 'rxjs';
5
+ import { BehaviorSubject, Subject, of, map, tap, switchMap, startWith, distinctUntilChanged, filter, takeUntil, forkJoin, catchError, ReplaySubject, combineLatest, from } from 'rxjs';
6
6
  import * as lodash from 'lodash';
7
- import { compact, flatten, isArray, pull, set, kebabCase } from 'lodash';
7
+ import { compact, isArray, pull, merge, flatten, set, kebabCase, cloneDeep } from 'lodash';
8
+ import { applyPatch } from 'rfc6902';
9
+ import * as i2 from '@veloceapps/sdk/core';
10
+ import { ConfigurationService, LineItemWorker, generateLineItem, getAttributeValue, QuoteDraftService, FlowConfigurationService, ProductImagesService, ContextService, lineItemUtils, SdkCoreModule, UI_DEFINITION_VERSION } from '@veloceapps/sdk/core';
11
+ import * as i3 from 'primeng/api';
12
+ import * as i1 from '@veloceapps/components';
13
+ import { LetDirectiveModule, LoaderModule, ToastService, ToastType } from '@veloceapps/components';
14
+ import { UUID, isDefined, CoreModule } from '@veloceapps/core';
8
15
  import * as i7 from '@angular/common';
9
- import { DOCUMENT, CommonModule } from '@angular/common';
10
- import { UUID, CoreModule } from '@veloceapps/core';
16
+ import { CommonModule, DOCUMENT } from '@angular/common';
17
+ import * as i2$1 from 'ngx-drag-drop';
18
+ import { DndModule } from 'ngx-drag-drop';
19
+ import { SalesforceApiService, QuoteApiService, DocumentTemplatesApiService, DocumentAttachmentApiService, RampApiService, CatalogApiService, DeltaApiService, PicklistsApiService, PriceApiService, ShoppingCartSettingsApiService, ConfigurationSettingsApiService, ApiModule } from '@veloceapps/api';
20
+ import { DialogService } from 'primeng/dynamicdialog';
11
21
  import { DragDropModule } from '@angular/cdk/drag-drop';
12
22
  import { ScrollingModule } from '@angular/cdk/scrolling';
13
23
  import * as angularForms from '@angular/forms';
14
24
  import { FormsModule, ReactiveFormsModule } from '@angular/forms';
15
- import * as i2 from '@veloceapps/sdk/core';
16
- import { ConfigurationService, LineItemWorker, generateLineItem, getAttributeValue, QuoteDraftService, FlowConfigurationService, ProductImagesService, lineItemUtils, SdkCoreModule } from '@veloceapps/sdk/core';
17
- import * as i1 from '@veloceapps/components';
18
- import { LoaderModule } from '@veloceapps/components';
19
25
  import { transform } from '@babel/standalone';
20
- import { SalesforceApiService, QuoteApiService, DocumentTemplatesApiService, DocumentAttachmentApiService, RampApiService, CatalogApiService, DeltaApiService, PicklistsApiService, PriceApiService, ApiModule } from '@veloceapps/api';
21
26
  import * as rxjsOperators from 'rxjs/operators';
22
- import * as i3 from 'primeng/api';
23
- import { DialogService } from 'primeng/dynamicdialog';
24
27
 
25
28
  var FlowAction;
26
29
  (function (FlowAction) {
@@ -156,6 +159,88 @@ ElementComponent = __decorate([
156
159
  __param(0, Inject(Injector))
157
160
  ], ElementComponent);
158
161
 
162
+ function getElementUniqueName(collection, name, comparator) {
163
+ let result = '';
164
+ let index = 0;
165
+ while (!result) {
166
+ const candidate = name + (index ? ` (${index})` : '');
167
+ const exists = collection.some(comparator(candidate));
168
+ if (!exists) {
169
+ result = candidate;
170
+ }
171
+ else {
172
+ index++;
173
+ }
174
+ }
175
+ return result;
176
+ }
177
+ const insertElementAt = (source, target, parentPath, index) => {
178
+ const result = [...source];
179
+ const name = getElementUniqueName(result, target.name, (name) => (el) => el.name === name);
180
+ const path = parentPath ? `${parentPath}/${name}` : name;
181
+ result.splice(index, 0, Object.assign(Object.assign({}, target), { path, name }));
182
+ return result;
183
+ };
184
+ const insertElement = (source, target, path, index) => {
185
+ if (!path) {
186
+ return insertElementAt(source, target, '', index);
187
+ }
188
+ return source.map(element => {
189
+ var _a;
190
+ if (element.path === path) {
191
+ return Object.assign(Object.assign({}, element), { children: insertElementAt(element.children, target, element.path, index) });
192
+ }
193
+ else if ((_a = element.path) === null || _a === void 0 ? void 0 : _a.startsWith(path)) {
194
+ return Object.assign(Object.assign({}, element), { children: insertElement(element.children, target, path, index) });
195
+ }
196
+ else {
197
+ return element;
198
+ }
199
+ });
200
+ };
201
+ const removeElement = (source, path) => {
202
+ return source.reduce((trunk, element) => {
203
+ if (path === element.path) {
204
+ return trunk;
205
+ }
206
+ if (element.path) {
207
+ if (path.startsWith(element.path)) {
208
+ trunk.push(Object.assign(Object.assign({}, element), { children: removeElement(element.children, path) }));
209
+ }
210
+ else {
211
+ trunk.push(element);
212
+ }
213
+ }
214
+ return trunk;
215
+ }, []);
216
+ };
217
+ const findElementByPath = (source, path) => {
218
+ for (const el of source) {
219
+ if (el.path === path) {
220
+ return el;
221
+ }
222
+ if (el.path && path.startsWith(el.path)) {
223
+ const found = findElementByPath(el.children, path);
224
+ if (found) {
225
+ return found;
226
+ }
227
+ }
228
+ }
229
+ return;
230
+ };
231
+ const findElementByModule = (elements, module, elementName) => {
232
+ for (const el of elements) {
233
+ if (el.module === module && el.name === elementName) {
234
+ return el;
235
+ }
236
+ const child = findElementByModule(el.children, module, elementName);
237
+ if (child) {
238
+ return child;
239
+ }
240
+ }
241
+ return;
242
+ };
243
+
159
244
  const parseBoundPath = (path) => {
160
245
  var _a, _b;
161
246
  const regexp = new RegExp(`(?:\\/)(?:\\w+)(?:\\/)(?:ports|attributes)(?:\\/)(?:\\w+)|(?:\\/)(?:\\w+)`, 'g');
@@ -188,18 +273,6 @@ const parsePath = (path) => {
188
273
  variable,
189
274
  };
190
275
  };
191
- const findElementByModule = (elements, module, elementName) => {
192
- for (const el of elements) {
193
- if (el.module === module && el.name === elementName) {
194
- return el;
195
- }
196
- const child = findElementByModule(el.children, module, elementName);
197
- if (child) {
198
- return child;
199
- }
200
- }
201
- return;
202
- };
203
276
  const getAbsolutePath = (elements, subject, path) => {
204
277
  var _a, _b, _c;
205
278
  if (path.module) {
@@ -222,40 +295,79 @@ const getAbsolutePath = (elements, subject, path) => {
222
295
  return subjectSegments.join('/');
223
296
  };
224
297
 
225
- class DynamicModuleService {
226
- constructor() {
227
- this._elementsTree = [];
228
- this._componentFactories = [];
229
- }
230
- set componentFactories(data) {
231
- this._componentFactories = data;
232
- }
233
- get componentFactories() {
234
- return this._componentFactories;
298
+ const CMS_COMPILATION_SERVICE = new InjectionToken('VENDOR_MAP');
299
+
300
+ class RuntimeService {
301
+ constructor(injector) {
302
+ this.injector = injector;
303
+ this.modules = [];
304
+ this.componentFactories = {};
305
+ this.applicationTree = [];
306
+ this.isInitialized$ = new BehaviorSubject(false);
307
+ this.updated$ = new Subject();
308
+ this.compilationService = this.injector.get(CMS_COMPILATION_SERVICE);
309
+ }
310
+ initialize$(uiDefinition, config) {
311
+ this.config = config;
312
+ if (!uiDefinition) {
313
+ return of([]);
314
+ }
315
+ return this.compilationService.compileUIDefinition$(uiDefinition).pipe(map(result => {
316
+ this.applicationTree = result.elements;
317
+ this.addComponentFactories(result.module.componentFactories);
318
+ return result.elements;
319
+ }), tap(() => this.isInitialized$.next(true)));
320
+ }
321
+ applyPatch$(patch) {
322
+ let observable$ = of(undefined);
323
+ patch.forEach(operation => {
324
+ switch (operation.op) {
325
+ case 'add': {
326
+ observable$ = observable$.pipe(switchMap(() => this.addElement$(operation)));
327
+ break;
328
+ }
329
+ case 'remove': {
330
+ observable$ = observable$.pipe(map(() => this.deleteElement(operation)));
331
+ break;
332
+ }
333
+ default:
334
+ observable$ = of();
335
+ }
336
+ });
337
+ return observable$.pipe(tap(() => this.updated$.next()));
235
338
  }
236
- getComponentFactory(element) {
237
- return this.componentFactories.find(f => f.componentType.path === element.path);
339
+ getCompiledElement$(path) {
340
+ return this.updated$.pipe(startWith(undefined), map(() => findElementByPath(this.applicationTree, path)), distinctUntilChanged());
238
341
  }
239
- get elementsTree() {
240
- return this._elementsTree;
342
+ clear() {
343
+ this.compilationService.clearModuleCache(this.modules);
344
+ this.modules = [];
345
+ this.applicationTree = [];
346
+ this.componentFactories = {};
347
+ this.isInitialized$.next(false);
348
+ }
349
+ addElement$(operation) {
350
+ return this.compilationService.compileElement$(operation.value).pipe(map(result => {
351
+ this.addComponentFactories(result.module.componentFactories);
352
+ applyPatch(this.applicationTree, [Object.assign(Object.assign({}, operation), { value: result.elements[0] })]);
353
+ }));
241
354
  }
242
- set elementsTree(tree) {
243
- this._elementsTree = tree;
355
+ deleteElement(operation) {
356
+ applyPatch(this.applicationTree, [operation]);
244
357
  }
245
- clear() {
246
- this._elementsTree = [];
247
- this.componentFactories = [];
358
+ addComponentFactories(list) {
359
+ list.forEach(item => (this.componentFactories[item.componentType.path] = item));
248
360
  }
249
361
  }
250
- DynamicModuleService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DynamicModuleService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
251
- DynamicModuleService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DynamicModuleService });
252
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DynamicModuleService, decorators: [{
362
+ RuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeService, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
363
+ RuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeService });
364
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeService, decorators: [{
253
365
  type: Injectable
254
- }] });
366
+ }], ctorParameters: function () { return [{ type: i0.Injector }]; } });
255
367
 
256
368
  class IOProviderService {
257
- constructor(dynamicModuleService) {
258
- this.dynamicModuleService = dynamicModuleService;
369
+ constructor(runtimeService) {
370
+ this.runtimeService = runtimeService;
259
371
  this.inputs = {};
260
372
  }
261
373
  connect(el, name, target) {
@@ -275,7 +387,7 @@ class IOProviderService {
275
387
  const pathIsValue = elPath.segments.length === 1 && elPath.segments[0].startsWith('"') && elPath.segments[0].endsWith('"');
276
388
  const finalName = (_b = elPath.variable) !== null && _b !== void 0 ? _b : name;
277
389
  const value = pathIsValue ? new BehaviorSubject(elPath.segments[0].slice(1, -1)) : undefined;
278
- const absolutePath = !pathIsValue ? getAbsolutePath(this.dynamicModuleService.elementsTree, el, elPath) : el.path;
390
+ const absolutePath = !pathIsValue ? getAbsolutePath(this.runtimeService.applicationTree, el, elPath) : el.path;
279
391
  return this.createSubjectSafe(absolutePath !== null && absolutePath !== void 0 ? absolutePath : '', finalName, value);
280
392
  }
281
393
  createSubjectSafe(path, name, subject) {
@@ -293,11 +405,11 @@ class IOProviderService {
293
405
  return this.inputs[path][name];
294
406
  }
295
407
  }
296
- IOProviderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IOProviderService, deps: [{ token: DynamicModuleService }], target: i0.ɵɵFactoryTarget.Injectable });
297
- IOProviderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IOProviderService });
298
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IOProviderService, decorators: [{
408
+ IOProviderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IOProviderService, deps: [{ token: RuntimeService }], target: i0.ɵɵFactoryTarget.Injectable });
409
+ IOProviderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IOProviderService });
410
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IOProviderService, decorators: [{
299
411
  type: Injectable
300
- }], ctorParameters: function () { return [{ type: DynamicModuleService }]; } });
412
+ }], ctorParameters: function () { return [{ type: RuntimeService }]; } });
301
413
 
302
414
  class TemplatesService {
303
415
  constructor() {
@@ -321,339 +433,100 @@ class TemplatesService {
321
433
  }
322
434
  }
323
435
  }
324
- TemplatesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TemplatesService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
325
- TemplatesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TemplatesService });
326
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TemplatesService, decorators: [{
436
+ TemplatesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: TemplatesService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
437
+ TemplatesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: TemplatesService });
438
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: TemplatesService, decorators: [{
327
439
  type: Injectable
328
440
  }] });
329
441
 
330
- class IOPlugin {
331
- constructor(host) {
332
- var _a, _b;
333
- this.host = host;
334
- const elementMetadata = this.host.injector.get(ELEMENT_METADATA);
335
- const inputProvider = this.host.injector.get(IOProviderService);
336
- const inputs = Object.entries((_a = elementMetadata.inputs) !== null && _a !== void 0 ? _a : {});
337
- const outputs = Object.entries((_b = elementMetadata.outputs) !== null && _b !== void 0 ? _b : {});
338
- inputs.forEach(([key, path]) => {
339
- var _a;
340
- if (path && typeof path !== 'string') {
341
- console.error(`The value of '${key}' input should be a string`);
342
- }
343
- if (((_a = elementMetadata.outputs) === null || _a === void 0 ? void 0 : _a[key]) !== undefined) {
344
- console.warn(`'${key}' appears both in inputs and outputs. To prevent inconsistent behavior please keep them unique `);
345
- }
346
- this.host[key] = inputProvider.connect(elementMetadata, key, path);
347
- });
348
- outputs.forEach(([key, path]) => {
349
- if (path && typeof path !== 'string') {
350
- console.error(`The value of '${key}' output should be a string`);
351
- }
352
- this.host[key] = inputProvider.provide(elementMetadata, key, path);
353
- });
442
+ const InitAction = { type: 'INIT' };
443
+ const ClearAction = { type: 'CLEAR' };
444
+ class IntegrationState {
445
+ constructor() {
446
+ this.stateSubj$ = new BehaviorSubject({});
447
+ this.action$ = new BehaviorSubject(InitAction);
448
+ }
449
+ get state$() {
450
+ return this.stateSubj$.asObservable();
451
+ }
452
+ get state() {
453
+ return this.stateSubj$.getValue();
454
+ }
455
+ patchState(update) {
456
+ this.stateSubj$.next(Object.assign(Object.assign({}, this.stateSubj$.getValue()), update));
457
+ }
458
+ dispatch(action) {
459
+ this.action$.next(action);
460
+ }
461
+ listen$(actionType) {
462
+ return this.action$.pipe(filter(action => action.type === actionType), map(action => action.payload));
463
+ }
464
+ listenAll$() {
465
+ return this.action$.asObservable();
466
+ }
467
+ clear() {
468
+ this.stateSubj$.next({});
469
+ this.action$.next(ClearAction);
354
470
  }
355
471
  }
356
- IOPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IOPlugin, deps: [{ token: ElementComponent }], target: i0.ɵɵFactoryTarget.Directive });
357
- IOPlugindir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: IOPlugin, ngImport: i0 });
358
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IOPlugin, decorators: [{
359
- type: Directive
360
- }], ctorParameters: function () { return [{ type: ElementComponent }]; } });
472
+ IntegrationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IntegrationState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
473
+ IntegrationStateprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IntegrationState, providedIn: 'root' });
474
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IntegrationState, decorators: [{
475
+ type: Injectable,
476
+ args: [{ providedIn: 'root' }]
477
+ }] });
361
478
 
362
- class ScriptPlugin {
363
- constructor(host) {
364
- this.host = host;
365
- this.normalizeImports = (script, elementPath) => {
366
- const 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');
367
- const result = script.replace(regexp, (match, g1, g2, src) => {
368
- const imports = g1
369
- .trim()
370
- .slice(1, -1)
371
- .split(',')
372
- .map(item => item.trim());
373
- imports.forEach(item => {
374
- var _a;
375
- if (!((_a = this.vendorMap[src]) === null || _a === void 0 ? void 0 : _a[item])) {
376
- throw new Error(`Failed to import ${item} from '${src}' in ${elementPath}/script.ts`);
377
- }
378
- });
379
- return `const ${g1} = vendor['${src}'];`;
380
- });
381
- return result;
382
- };
383
- this.document = this.host.injector.get(DOCUMENT);
384
- this.vendorMap = this.host.injector.get(VENDOR_MAP);
385
- const elementMetadata = this.host.injector.get(ELEMENT_METADATA);
386
- const sharedElementMetadata = this.host.injector.get(SHARED_ELEMENT_METADATA);
387
- this.addScript(sharedElementMetadata);
388
- this.addScript(elementMetadata);
479
+ class ElementContextService {
480
+ }
481
+ ElementContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementContextService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
482
+ ElementContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementContextService });
483
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementContextService, decorators: [{
484
+ type: Injectable
485
+ }] });
486
+
487
+ class ElementRendererComponent {
488
+ constructor(parentInjector, runtimeService, elementContext, ioProviderService, configurationService, elementRef, cdr) {
489
+ this.parentInjector = parentInjector;
490
+ this.runtimeService = runtimeService;
491
+ this.elementContext = elementContext;
492
+ this.ioProviderService = ioProviderService;
493
+ this.configurationService = configurationService;
494
+ this.elementRef = elementRef;
495
+ this.cdr = cdr;
496
+ this.refs = {};
497
+ this.destroy$ = new Subject();
389
498
  }
390
- addScript(metadata) {
391
- var _a;
392
- if (!(metadata === null || metadata === void 0 ? void 0 : metadata.script)) {
499
+ ngOnInit() {
500
+ this.elementContext.metadata = this.meta;
501
+ this.factory = this.meta.path ? this.runtimeService.componentFactories[this.meta.path] : undefined;
502
+ this.createComponents();
503
+ }
504
+ ngOnDestroy() {
505
+ this.destroyComponents();
506
+ this.destroy$.next();
507
+ this.destroy$.complete();
508
+ }
509
+ createComponents() {
510
+ const modelMeta = this.meta.model;
511
+ if (!modelMeta) {
512
+ this.refs[UUID.UUID()] = this.createComponent();
393
513
  return;
394
514
  }
395
- const id = btoa(UUID.UUID());
396
- const script = this.document.createElement('script');
397
- script.type = `text/javascript`;
398
- let scriptContent = this.normalizeImports(metadata.script, (_a = metadata.path) !== null && _a !== void 0 ? _a : metadata.name);
399
- const classMatch = /export class (\S+)/.exec(scriptContent);
400
- const className = classMatch === null || classMatch === void 0 ? void 0 : classMatch[1];
401
- if (!classMatch || !className) {
402
- console.error("Script doesn't have exported class");
403
- return;
515
+ if (modelMeta.lineItem) {
516
+ this.createFromLineItem(modelMeta.lineItem);
404
517
  }
405
- scriptContent = scriptContent.replace(classMatch[0], `class ${className}`);
406
- script.text = `var ${id} = function(vendor) {${scriptContent}
407
- return ${className}; };`;
408
- this.document.body.appendChild(script);
409
- const ScriptClass = window[id](this.vendorMap);
410
- if (ScriptClass instanceof Object) {
411
- this.host.registerPlugin(new ScriptClass(this.host));
518
+ else if (modelMeta.path) {
519
+ this.createFromPath(modelMeta.path);
412
520
  }
413
- this.document.body.removeChild(script);
414
521
  }
415
- }
416
- ScriptPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ScriptPlugin, deps: [{ token: ElementComponent }], target: i0.ɵɵFactoryTarget.Directive });
417
- ScriptPlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: ScriptPlugin, ngImport: i0 });
418
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ScriptPlugin, decorators: [{
419
- type: Directive
420
- }], ctorParameters: function () { return [{ type: ElementComponent }]; } });
421
-
422
- /*
423
- * ScriptPlugin must always be the last plugin in the list to make sure user code is running after all pre-initializers.
424
- */
425
- const CONFIG = {
426
- CUSTOM: {
427
- component: ElementComponent,
428
- plugins: [IOPlugin, ScriptPlugin],
429
- },
430
- CONTAINER: {
431
- component: ElementComponent,
432
- defaultTemplate: '<element-children></element-children>',
433
- plugins: [ScriptPlugin],
434
- },
435
- SERVICE: {
436
- component: ElementComponent,
437
- plugins: [IOPlugin, ScriptPlugin],
438
- suppressTemplate: true,
439
- suppressStyles: true,
440
- },
441
- REFERENCE: {
442
- component: ElementComponent,
443
- plugins: [IOPlugin, ScriptPlugin],
444
- suppressTemplate: true,
445
- },
446
- };
447
-
448
- const EXPORTED_CLASS_REGEX = /export class (\S+)/;
449
- const METADATA_DECORATOR_REGEX = /@ElementDefinition\(([\s\S]+)\)(\n|\r\n|.)*export class/g;
450
- class UiBuildError extends Error {
451
- constructor(message, affectedMetadata) {
452
- super(message);
453
- this.name = this.constructor.name;
454
- this.affectedMetadata = affectedMetadata;
455
- }
456
- }
457
- const elementToMetadata = (el, parentPath) => {
458
- var _a;
459
- const script = el.script && window.atob(el.script);
460
- const template = el.template && window.atob(el.template);
461
- const styles = el.styles && window.atob(el.styles);
462
- const exportedClassName = script && ((_a = EXPORTED_CLASS_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
463
- if (!exportedClassName) {
464
- throw new Error("Script doesn't have exported class");
465
- }
466
- const elementMetadata = extractElementMetadata(script || '');
467
- const path = (parentPath ? parentPath + '/' : '') + elementMetadata.name;
468
- return Object.assign(Object.assign({}, elementMetadata), { path, script: script === null || script === void 0 ? void 0 : script.replace(METADATA_DECORATOR_REGEX, 'export class'), template,
469
- styles, children: el.children.map(child => elementToMetadata(child, path)) });
470
- };
471
- const metadataToElement = (metadata, recursive = true) => {
472
- const elMetadata = {
473
- name: metadata.name,
474
- isShared: metadata.isShared,
475
- type: metadata.type,
476
- model: metadata.model,
477
- module: metadata.module,
478
- reference: metadata.reference,
479
- inputs: metadata.inputs,
480
- outputs: metadata.outputs,
481
- children: metadata.children.map(({ name }) => name),
482
- configuredStyles: metadata.configuredStyles,
483
- };
484
- const normalizedElMetadata = normalizeElementMetadata(elMetadata);
485
- if (!metadata.script || !EXPORTED_CLASS_REGEX.test(metadata.script)) {
486
- throw new UiBuildError(`'${metadata.name}' component script is missing an exported class`, metadata);
487
- }
488
- const script = metadata.script &&
489
- window.btoa(metadata.script.replace(EXPORTED_CLASS_REGEX, `@ElementDefinition(${stringifyElementMetadata(normalizedElMetadata)})\nexport class Script`));
490
- const template = metadata.template && window.btoa(metadata.template);
491
- const styles = metadata.styles && window.btoa(metadata.styles);
492
- return {
493
- script,
494
- template,
495
- styles,
496
- children: recursive ? metadata.children.map(meta => metadataToElement(meta)) : [],
497
- };
498
- };
499
- const normalizeElementMetadata = (elementMetadata) => {
500
- var _a, _b, _c, _d;
501
- const metadata = Object.assign({}, elementMetadata);
502
- // model
503
- const { lineItem, path } = (_a = metadata.model) !== null && _a !== void 0 ? _a : {};
504
- const model = lineItem ? { lineItem } : path ? { path } : undefined;
505
- if (model) {
506
- metadata.model = model;
507
- }
508
- else {
509
- delete metadata.model;
510
- }
511
- // module
512
- if (!metadata.module) {
513
- delete metadata.module;
514
- }
515
- // reference
516
- if (!metadata.reference) {
517
- delete metadata.reference;
518
- }
519
- // inputs
520
- const inputs = Object.entries((_b = metadata.inputs) !== null && _b !== void 0 ? _b : {}).reduce((acc, [key, value]) => {
521
- return Object.assign(Object.assign({}, acc), { [key]: value || null });
522
- }, {});
523
- if (inputs && Object.keys(inputs).length > 0) {
524
- metadata.inputs = inputs;
525
- }
526
- else {
527
- delete metadata.inputs;
528
- }
529
- // outputs
530
- const outputs = Object.entries((_c = metadata.outputs) !== null && _c !== void 0 ? _c : {}).reduce((acc, [key, value]) => {
531
- return Object.assign(Object.assign({}, acc), { [key]: value || null });
532
- }, {});
533
- if (outputs && Object.keys(outputs).length > 0) {
534
- metadata.outputs = outputs;
535
- }
536
- else {
537
- delete metadata.outputs;
538
- }
539
- // children
540
- if (!((_d = metadata.children) === null || _d === void 0 ? void 0 : _d.length)) {
541
- delete metadata.children;
542
- }
543
- // isShared
544
- if (!metadata.isShared) {
545
- delete metadata.isShared;
546
- }
547
- // configuredStyles
548
- if (!metadata.configuredStyles) {
549
- delete metadata.configuredStyles;
550
- }
551
- return metadata;
552
- };
553
- const extractElementMetadata = (script) => {
554
- var _a;
555
- const metadataString = ((_a = METADATA_DECORATOR_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
556
- // need to reset regex last index to prevent null result for next execution
557
- METADATA_DECORATOR_REGEX.lastIndex = 0;
558
- return new Function(`return ${metadataString}`)();
559
- };
560
- const extendElementMetadata = (script, extend) => {
561
- var _a;
562
- const metadataString = ((_a = METADATA_DECORATOR_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
563
- // need to reset regex last index to prevent null result for next execution
564
- METADATA_DECORATOR_REGEX.lastIndex = 0;
565
- if (!metadataString) {
566
- return script;
567
- }
568
- const updated = Object.assign(Object.assign({}, new Function(`return ${metadataString}`)()), extend);
569
- return script.replace(metadataString, stringifyElementMetadata(updated));
570
- };
571
- const getElementConfig = (type) => {
572
- return CONFIG[type];
573
- };
574
- const doesElementSupportIO = (type) => {
575
- var _a, _b;
576
- return (_b = (_a = getElementConfig(type).plugins) === null || _a === void 0 ? void 0 : _a.includes(IOPlugin)) !== null && _b !== void 0 ? _b : false;
577
- };
578
- function stringifyElementMetadata(elementMetadata) {
579
- const cleaned = JSON.stringify(elementMetadata, null, 2);
580
- return cleaned.replace(/^[\t ]*"[^:\n\r]+(?<!\\)":/gm, function (match) {
581
- return match.replace(/"/g, '');
582
- });
583
- }
584
- const isValidScript = (script) => {
585
- var _a;
586
- if (!script) {
587
- return false;
588
- }
589
- const exportedClassName = script && ((_a = EXPORTED_CLASS_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
590
- if (!exportedClassName) {
591
- return false;
592
- }
593
- const meta = extractElementMetadata(script);
594
- if (!meta.name || !meta.type) {
595
- return false;
596
- }
597
- return true;
598
- };
599
- function flattenElements(elements) {
600
- return flatten(elements.map(el => [el, ...flattenElements(el.children)]));
601
- }
602
- function isSharedElement(el) {
603
- return Boolean(el.isShared) && el.type !== 'REFERENCE';
604
- }
605
-
606
- class ElementContextService {
607
- }
608
- ElementContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementContextService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
609
- ElementContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementContextService });
610
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementContextService, decorators: [{
611
- type: Injectable
612
- }] });
613
-
614
- class ElementRendererComponent {
615
- constructor(parentInjector, dynamicModuleService, elementContext, ioProviderService, configurationService, elementRef, cdr) {
616
- this.parentInjector = parentInjector;
617
- this.dynamicModuleService = dynamicModuleService;
618
- this.elementContext = elementContext;
619
- this.ioProviderService = ioProviderService;
620
- this.configurationService = configurationService;
621
- this.elementRef = elementRef;
622
- this.cdr = cdr;
623
- this.refs = {};
624
- this.destroy$ = new Subject();
625
- }
626
- ngOnInit() {
627
- this.elementContext.metadata = this.meta;
628
- this.factory = this.dynamicModuleService.getComponentFactory(this.meta);
629
- this.createComponents();
630
- }
631
- ngOnDestroy() {
632
- this.destroyComponents();
633
- this.destroy$.next();
634
- this.destroy$.complete();
635
- }
636
- createComponents() {
637
- const modelMeta = this.meta.model;
638
- if (!modelMeta) {
639
- this.refs[UUID.UUID()] = this.createComponent();
640
- return;
641
- }
642
- if (modelMeta.lineItem) {
643
- this.createFromLineItem(modelMeta.lineItem);
644
- }
645
- else if (modelMeta.path) {
646
- this.createFromPath(modelMeta.path);
647
- }
648
- }
649
- createFromPath(path) {
650
- const array$ = this.ioProviderService.connect(this.meta, 'children$', path);
651
- array$ === null || array$ === void 0 ? void 0 : array$.pipe(takeUntil(this.destroy$)).subscribe(children => {
652
- if (!isArray(children)) {
653
- return;
654
- }
655
- this.processChildren(children);
656
- });
522
+ createFromPath(path) {
523
+ const array$ = this.ioProviderService.connect(this.meta, 'children$', path);
524
+ array$ === null || array$ === void 0 ? void 0 : array$.pipe(takeUntil(this.destroy$)).subscribe(children => {
525
+ if (!isArray(children)) {
526
+ return;
527
+ }
528
+ this.processChildren(children);
529
+ });
657
530
  }
658
531
  getModelComponent() {
659
532
  let component = null;
@@ -749,9 +622,9 @@ class ElementRendererComponent {
749
622
  this.refs = {};
750
623
  }
751
624
  }
752
- ElementRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementRendererComponent, deps: [{ token: i0.Injector, skipSelf: true }, { token: DynamicModuleService }, { token: ElementContextService }, { token: IOProviderService }, { token: i2.ConfigurationService }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
753
- ElementRendererComponent.ɵcmp = i0.ɵɵ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: ViewContainerRef, static: true }], ngImport: i0, template: "<ng-template #el></ng-template>\n", styles: [":host{display:contents}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
754
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementRendererComponent, decorators: [{
625
+ ElementRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementRendererComponent, deps: [{ token: i0.Injector, skipSelf: true }, { token: RuntimeService }, { token: ElementContextService }, { token: IOProviderService }, { token: i2.ConfigurationService }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
626
+ ElementRendererComponent.ɵcmp = i0.ɵɵ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: ViewContainerRef, static: true }], ngImport: i0, template: "<ng-template #el></ng-template>\n", styles: [":host{display:contents}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
627
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementRendererComponent, decorators: [{
755
628
  type: Component,
756
629
  args: [{
757
630
  selector: 'vl-cms-element-renderer',
@@ -762,33 +635,239 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
762
635
  }]
763
636
  }], ctorParameters: function () { return [{ type: i0.Injector, decorators: [{
764
637
  type: SkipSelf
765
- }] }, { type: DynamicModuleService }, { type: ElementContextService }, { type: IOProviderService }, { type: i2.ConfigurationService }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { el: [{
638
+ }] }, { type: RuntimeService }, { type: ElementContextService }, { type: IOProviderService }, { type: i2.ConfigurationService }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { el: [{
766
639
  type: ViewChild,
767
640
  args: ['el', { read: ViewContainerRef, static: true }]
768
641
  }], meta: [{
769
642
  type: Input
770
643
  }] } });
771
644
 
772
- class ElementChildrenComponent {
773
- constructor(elementContext) {
774
- this.elementContext = elementContext;
775
- this.metadata = this.elementContext.metadata;
645
+ class PreviewComponent {
646
+ constructor(runtimeService, configurationService, messageService, configurationRuntimeService, integrationState, cdr) {
647
+ this.runtimeService = runtimeService;
648
+ this.configurationService = configurationService;
649
+ this.messageService = messageService;
650
+ this.configurationRuntimeService = configurationRuntimeService;
651
+ this.integrationState = integrationState;
652
+ this.cdr = cdr;
653
+ this.state$ = new BehaviorSubject({ loading: true, failure: false });
654
+ this.elements = [];
655
+ this.destroy$ = new Subject();
656
+ this.runtimeService.updated$.pipe(takeUntil(this.destroy$)).subscribe(() => this.cdr.detectChanges());
657
+ }
658
+ ngOnInit() {
659
+ var _a;
660
+ if (!((_a = this.config) === null || _a === void 0 ? void 0 : _a.suppressClearState)) {
661
+ this.integrationState.clear();
662
+ }
663
+ this.startPreview();
664
+ }
665
+ ngOnDestroy() {
666
+ this.destroy$.next();
667
+ this.destroy$.complete();
668
+ this.configurationService.reset();
669
+ this.runtimeService.clear();
670
+ }
671
+ initializeConfiguration$() {
672
+ const isAlreadyInitialized = this.configurationRuntimeService.isInitialized;
673
+ if (!this.uiDefinition || this.uiDefinition.type !== 'CONFIGURATION' || isAlreadyInitialized) {
674
+ return of({});
675
+ }
676
+ if (!this.modelId) {
677
+ console.warn(`No modelId is given for uiDefinition with '${this.uiDefinition.type}' type`);
678
+ return of({});
679
+ }
680
+ // If still not initialized - init configuration in Test mode
681
+ return this.configurationRuntimeService
682
+ .initTestMode(this.modelId, this.uiDefinition)
683
+ .pipe(switchMap(() => this.configurationService.configure()));
684
+ }
685
+ startPreview() {
686
+ if (!this.uiDefinition) {
687
+ return;
688
+ }
689
+ forkJoin([this.runtimeService.initialize$(this.uiDefinition, this.config), this.initializeConfiguration$()])
690
+ .pipe(tap(([elements]) => {
691
+ this.elements = elements;
692
+ this.state$.next({ loading: false, failure: false });
693
+ }), catchError(error => {
694
+ var _a, _b;
695
+ console.error(error);
696
+ if (!((_b = (_a = this.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.suppressToastMessages)) {
697
+ this.messageService.add({ severity: 'error', summary: error });
698
+ }
699
+ this.state$.next({ loading: false, failure: true });
700
+ return of();
701
+ }), takeUntil(this.destroy$))
702
+ .subscribe();
776
703
  }
777
704
  }
778
- ElementChildrenComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementChildrenComponent, deps: [{ token: ElementContextService }], target: i0.ɵɵFactoryTarget.Component });
779
- ElementChildrenComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: ElementChildrenComponent, selector: "element-children", ngImport: i0, 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.ChangeDetectionStrategy.OnPush });
780
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementChildrenComponent, decorators: [{
705
+ PreviewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PreviewComponent, deps: [{ token: RuntimeService }, { token: i2.ConfigurationService }, { token: i3.MessageService }, { token: i2.ConfigurationRuntimeService }, { token: IntegrationState }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
706
+ PreviewComponent.ɵcmp = i0.ɵɵ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, 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.LoaderComponent, selector: "vl-loader", inputs: ["label", "overlayVisible"] }, { type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: ["meta"] }], directives: [{ type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i7.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.ShadowDom });
707
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PreviewComponent, decorators: [{
781
708
  type: Component,
782
709
  args: [{
783
- // eslint-disable-next-line @angular-eslint/component-selector
784
- selector: 'element-children',
785
- templateUrl: 'element-children.component.html',
786
- styleUrls: ['./element-children.component.scss'],
710
+ selector: 'vl-cms-preview',
711
+ templateUrl: './preview.component.html',
712
+ styleUrls: ['./preview.component.scss'],
787
713
  changeDetection: ChangeDetectionStrategy.OnPush,
714
+ providers: [IOProviderService, TemplatesService],
715
+ // use shadow DOM to prevent UI from being affected by global styles
716
+ encapsulation: ViewEncapsulation.ShadowDom,
788
717
  }]
789
- }], ctorParameters: function () { return [{ type: ElementContextService }]; } });
790
-
791
- // eslint-disable-next-line @angular-eslint/directive-selector
718
+ }], ctorParameters: function () { return [{ type: RuntimeService }, { type: i2.ConfigurationService }, { type: i3.MessageService }, { type: i2.ConfigurationRuntimeService }, { type: IntegrationState }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { modelId: [{
719
+ type: Input
720
+ }], uiDefinition: [{
721
+ type: Input
722
+ }], config: [{
723
+ type: Input
724
+ }] } });
725
+
726
+ class RuntimeEditorService {
727
+ constructor(runtimeService) {
728
+ this.runtimeService = runtimeService;
729
+ this.editorModeSubj$ = new BehaviorSubject(false);
730
+ this.dragMode$ = new BehaviorSubject(false);
731
+ this.elementDropped$ = new ReplaySubject();
732
+ this.elementDeleted$ = new ReplaySubject();
733
+ this.editorMode$ = this.editorModeSubj$.asObservable();
734
+ this.runtimeService.isInitialized$.subscribe(() => { var _a; return this.editorModeSubj$.next(Boolean((_a = this.runtimeService.config) === null || _a === void 0 ? void 0 : _a.uiBuilderMode)); });
735
+ }
736
+ applyPatch$(patch) {
737
+ return this.runtimeService.applyPatch$(patch);
738
+ }
739
+ toggleEditorMode() {
740
+ this.editorModeSubj$.next(!this.editorModeSubj$.value);
741
+ }
742
+ }
743
+ RuntimeEditorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeEditorService, deps: [{ token: RuntimeService }], target: i0.ɵɵFactoryTarget.Injectable });
744
+ RuntimeEditorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeEditorService });
745
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeEditorService, decorators: [{
746
+ type: Injectable
747
+ }], ctorParameters: function () { return [{ type: RuntimeService }]; } });
748
+
749
+ class ElementDropHandleComponent {
750
+ constructor(runtimeService) {
751
+ this.runtimeService = runtimeService;
752
+ }
753
+ handleDrop(e) {
754
+ this.runtimeService.elementDropped$.next({
755
+ element: e.data,
756
+ index: this.index,
757
+ path: this.parentPath,
758
+ });
759
+ }
760
+ }
761
+ ElementDropHandleComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementDropHandleComponent, deps: [{ token: RuntimeEditorService }], target: i0.ɵɵFactoryTarget.Component });
762
+ ElementDropHandleComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: ElementDropHandleComponent, selector: "vl-element-drop-handle", inputs: { index: "index", parentPath: "parentPath" }, ngImport: i0, 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$1.DndDropzoneDirective, selector: "[dndDropzone]", inputs: ["dndDropzone", "dndEffectAllowed", "dndAllowExternal", "dndHorizontal", "dndDragoverClass", "dndDropzoneDisabledClass", "dndDisableIf", "dndDisableDropIf"], outputs: ["dndDragover", "dndDrop"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
763
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementDropHandleComponent, decorators: [{
764
+ type: Component,
765
+ args: [{
766
+ selector: 'vl-element-drop-handle',
767
+ templateUrl: './element-drop-handle.component.html',
768
+ styleUrls: ['./element-drop-handle.component.scss'],
769
+ changeDetection: ChangeDetectionStrategy.OnPush,
770
+ }]
771
+ }], ctorParameters: function () { return [{ type: RuntimeEditorService }]; }, propDecorators: { index: [{
772
+ type: Input
773
+ }], parentPath: [{
774
+ type: Input
775
+ }] } });
776
+
777
+ class ElementDropHandleModule {
778
+ }
779
+ ElementDropHandleModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementDropHandleModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
780
+ ElementDropHandleModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementDropHandleModule, declarations: [ElementDropHandleComponent], imports: [CommonModule, DndModule], exports: [ElementDropHandleComponent] });
781
+ ElementDropHandleModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementDropHandleModule, imports: [[CommonModule, DndModule]] });
782
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementDropHandleModule, decorators: [{
783
+ type: NgModule,
784
+ args: [{
785
+ declarations: [ElementDropHandleComponent],
786
+ imports: [CommonModule, DndModule],
787
+ exports: [ElementDropHandleComponent],
788
+ }]
789
+ }] });
790
+
791
+ class ElementRendererModule {
792
+ }
793
+ ElementRendererModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementRendererModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
794
+ ElementRendererModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementRendererModule, declarations: [ElementRendererComponent], exports: [ElementRendererComponent] });
795
+ ElementRendererModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementRendererModule });
796
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementRendererModule, decorators: [{
797
+ type: NgModule,
798
+ args: [{
799
+ declarations: [ElementRendererComponent],
800
+ exports: [ElementRendererComponent],
801
+ }]
802
+ }] });
803
+
804
+ class ElementChildrenComponent {
805
+ constructor(elementContext, runtimeService, runtimeEditorService, cdr) {
806
+ var _a, _b;
807
+ this.elementContext = elementContext;
808
+ this.runtimeService = runtimeService;
809
+ this.runtimeEditorService = runtimeEditorService;
810
+ this.cdr = cdr;
811
+ this.destroyed$ = new Subject();
812
+ const path = (_b = (_a = this.elementContext) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.path;
813
+ this.metadata$ = path ? this.runtimeService.getCompiledElement$(path) : of(undefined);
814
+ this.dragMode$ = combineLatest([this.runtimeEditorService.editorMode$, this.runtimeEditorService.dragMode$]).pipe(map(flags => flags.every(Boolean)));
815
+ this.runtimeService.updated$.pipe(takeUntil(this.destroyed$)).subscribe(() => this.cdr.detectChanges());
816
+ }
817
+ ngOnDestroy() {
818
+ this.destroyed$.next();
819
+ this.destroyed$.complete();
820
+ }
821
+ }
822
+ ElementChildrenComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementChildrenComponent, deps: [{ token: ElementContextService }, { token: RuntimeService }, { token: RuntimeEditorService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
823
+ ElementChildrenComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: ElementChildrenComponent, selector: "element-children", ngImport: i0, 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.ChangeDetectionStrategy.OnPush });
824
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementChildrenComponent, decorators: [{
825
+ type: Component,
826
+ args: [{
827
+ // eslint-disable-next-line @angular-eslint/component-selector
828
+ selector: 'element-children',
829
+ templateUrl: 'element-children.component.html',
830
+ styleUrls: ['./element-children.component.scss'],
831
+ changeDetection: ChangeDetectionStrategy.OnPush,
832
+ }]
833
+ }], ctorParameters: function () { return [{ type: ElementContextService }, { type: RuntimeService }, { type: RuntimeEditorService }, { type: i0.ChangeDetectorRef }]; } });
834
+
835
+ class ElementChildrenModule {
836
+ }
837
+ ElementChildrenModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementChildrenModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
838
+ ElementChildrenModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementChildrenModule, declarations: [ElementChildrenComponent], imports: [LetDirectiveModule, ElementRendererModule, ElementDropHandleModule], exports: [ElementChildrenComponent] });
839
+ ElementChildrenModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementChildrenModule, imports: [[LetDirectiveModule, ElementRendererModule, ElementDropHandleModule]] });
840
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementChildrenModule, decorators: [{
841
+ type: NgModule,
842
+ args: [{
843
+ declarations: [ElementChildrenComponent],
844
+ imports: [LetDirectiveModule, ElementRendererModule, ElementDropHandleModule],
845
+ exports: [ElementChildrenComponent],
846
+ }]
847
+ }] });
848
+
849
+ class PreviewModule {
850
+ }
851
+ PreviewModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PreviewModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
852
+ PreviewModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PreviewModule, declarations: [PreviewComponent], imports: [CommonModule, LoaderModule, ElementRendererModule, ElementChildrenModule, ElementDropHandleModule], exports: [PreviewComponent] });
853
+ PreviewModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PreviewModule, providers: [IntegrationState], imports: [[CommonModule, LoaderModule, ElementRendererModule, ElementChildrenModule, ElementDropHandleModule]] });
854
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PreviewModule, decorators: [{
855
+ type: NgModule,
856
+ args: [{
857
+ declarations: [PreviewComponent],
858
+ imports: [CommonModule, LoaderModule, ElementRendererModule, ElementChildrenModule, ElementDropHandleModule],
859
+ providers: [IntegrationState],
860
+ exports: [PreviewComponent],
861
+ }]
862
+ }] });
863
+
864
+ function ElementDefinition(definition) {
865
+ return function (constructor) {
866
+ return constructor;
867
+ };
868
+ }
869
+
870
+ // eslint-disable-next-line @angular-eslint/directive-selector
792
871
  class CustomTemplateDirective {
793
872
  constructor(templateRef, templatesService) {
794
873
  this.templateRef = templateRef;
@@ -801,144 +880,451 @@ class CustomTemplateDirective {
801
880
  this.templatesService.register(this.customTemplate, this.templateRef);
802
881
  }
803
882
  }
804
- CustomTemplateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: CustomTemplateDirective, deps: [{ token: i0.TemplateRef }, { token: TemplatesService }], target: i0.ɵɵFactoryTarget.Directive });
805
- CustomTemplateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: CustomTemplateDirective, selector: "[customTemplate]", inputs: { customTemplate: "customTemplate" }, ngImport: i0 });
806
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: CustomTemplateDirective, decorators: [{
883
+ CustomTemplateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: CustomTemplateDirective, deps: [{ token: i0.TemplateRef }, { token: TemplatesService }], target: i0.ɵɵFactoryTarget.Directive });
884
+ CustomTemplateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: CustomTemplateDirective, selector: "[customTemplate]", inputs: { customTemplate: "customTemplate" }, ngImport: i0 });
885
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: CustomTemplateDirective, decorators: [{
807
886
  type: Directive,
808
887
  args: [{ selector: '[customTemplate]' }]
809
888
  }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: TemplatesService }]; }, propDecorators: { customTemplate: [{
810
889
  type: Input
811
890
  }] } });
812
891
 
813
- const defaultOptions = {
814
- suppressLoading: false,
815
- loadingLabel: 'LOADING',
816
- };
817
-
818
- const moduleMap = {};
819
- function loadRemoteEntry(remoteEntry) {
820
- return new Promise((resolve, reject) => {
821
- if (moduleMap[remoteEntry]) {
822
- resolve();
892
+ class ElementHoverPlugin {
893
+ constructor(host) {
894
+ this.host = host;
895
+ this.hoverClassName = 'element-hover';
896
+ this.color = 'red';
897
+ this.highlighted = false;
898
+ this.destroyed$ = new Subject();
899
+ this.el = this.host.injector.get(ElementRef);
900
+ this.metadata = this.host.injector.get(ELEMENT_METADATA);
901
+ this.document = this.host.injector.get(DOCUMENT);
902
+ this.runtimeEditorService = this.host.injector.get(RuntimeEditorService);
903
+ this.mouseOverListenerBound = this.mouseOverListener.bind(this);
904
+ this.mouseLeaveListenerBound = this.mouseLeaveListener.bind(this);
905
+ this.runtimeEditorService.editorMode$.pipe(takeUntil(this.destroyed$)).subscribe(editorMode => {
906
+ if (editorMode) {
907
+ this.attachListeners();
908
+ }
909
+ else {
910
+ this.detachListeners();
911
+ }
912
+ });
913
+ }
914
+ ngOnDestroy() {
915
+ this.destroyed$.next();
916
+ this.destroyed$.complete();
917
+ this.detachListeners();
918
+ }
919
+ attachListeners() {
920
+ this.el.nativeElement.addEventListener('mouseover', this.mouseOverListenerBound);
921
+ this.el.nativeElement.addEventListener('mouseleave', this.mouseLeaveListenerBound);
922
+ }
923
+ detachListeners() {
924
+ this.el.nativeElement.removeEventListener('mouseover', this.mouseOverListenerBound);
925
+ this.el.nativeElement.removeEventListener('mouseleave', this.mouseLeaveListenerBound);
926
+ }
927
+ mouseOverListener(e) {
928
+ const path = e.composedPath();
929
+ const innerPath = path.slice(0, path.indexOf(this.el.nativeElement));
930
+ const hasChildHovered = innerPath.some(target => {
931
+ const t = target;
932
+ return t.tagName === 'VL-ELEMENT' && t.classList.contains(this.hoverClassName);
933
+ });
934
+ if (hasChildHovered) {
935
+ this.removeHighlight();
936
+ }
937
+ else {
938
+ this.addHighlight();
939
+ }
940
+ }
941
+ mouseLeaveListener() {
942
+ this.removeHighlight();
943
+ }
944
+ addHighlight() {
945
+ if (this.highlighted) {
823
946
  return;
824
947
  }
825
- const script = document.createElement('script');
826
- script.src = remoteEntry;
827
- script.onerror = reject;
828
- script.onload = () => {
829
- moduleMap[remoteEntry] = true;
830
- resolve(); // window is the global namespace
831
- };
832
- document.body.append(script);
833
- });
834
- }
835
- function lookupExposedModule(remoteName, exposedModule) {
836
- return __awaiter(this, void 0, void 0, function* () {
837
- // Initializes the share scope. This fills it with known provided modules from this build and all remotes
838
- yield __webpack_init_sharing__('default');
839
- const container = window[remoteName]; // or get the container somewhere else
840
- // Initialize the container, it may provide shared modules
841
- yield container.init(__webpack_share_scopes__.default);
842
- const factory = yield container.get(exposedModule);
843
- const Module = factory();
844
- return Module;
845
- });
846
- }
847
- function loadRemoteModule(remoteEntry, remoteName, exposedModule) {
848
- return __awaiter(this, void 0, void 0, function* () {
849
- yield loadRemoteEntry(remoteEntry);
850
- return yield lookupExposedModule(remoteName, exposedModule);
851
- });
852
- }
853
-
854
- class FederatedComponent {
855
- constructor(injector, compiler, appRef, renderer) {
856
- this.injector = injector;
857
- this.compiler = compiler;
858
- this.appRef = appRef;
859
- this.renderer = renderer;
860
- this.isLoading$ = new BehaviorSubject(false);
861
- // configs
862
- this.suppressLoading = defaultOptions.suppressLoading;
863
- this.loadingLabel = defaultOptions.loadingLabel;
948
+ this.highlighted = true;
949
+ this.el.nativeElement.classList.add(this.hoverClassName);
950
+ const overlay = this.createContainer();
951
+ this.addRemoveButton(overlay);
952
+ this.addElementName(overlay);
953
+ this.el.nativeElement.appendChild(overlay);
954
+ this.overlayEl = overlay;
955
+ }
956
+ removeHighlight() {
957
+ if (!this.highlighted) {
958
+ return;
959
+ }
960
+ this.highlighted = false;
961
+ this.el.nativeElement.style.boxShadow = '';
962
+ this.el.nativeElement.classList.remove(this.hoverClassName);
963
+ this.deleteRemoveButton();
964
+ }
965
+ createContainer() {
966
+ const hostRect = this.el.nativeElement.getBoundingClientRect();
967
+ const div = this.document.createElement('div');
968
+ merge(div.style, {
969
+ position: 'fixed',
970
+ display: 'block',
971
+ pointerEvents: 'none',
972
+ left: '0',
973
+ top: '0',
974
+ fontSize: '10px',
975
+ lineHeight: `12px`,
976
+ fontWeight: '400',
977
+ color: '#fff',
978
+ width: `${hostRect.width}px`,
979
+ height: `${hostRect.height}px`,
980
+ transform: `translate(${hostRect.left}px, ${hostRect.top}px)`,
981
+ boxSizing: 'border-box',
982
+ boxShadow: `inset 0 0 0 1px ${this.color}`,
983
+ });
984
+ return div;
864
985
  }
865
- ngOnChanges(changes) {
866
- var _a, _b, _c, _d;
867
- if (changes.data && this.instance) {
868
- this.instance.data = this.data;
986
+ addRemoveButton(container) {
987
+ if (this.metadata.type === 'LAYOUT_REGION') {
988
+ return;
869
989
  }
870
- if (changes.options) {
871
- this.suppressLoading = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.suppressLoading) !== null && _b !== void 0 ? _b : defaultOptions.suppressLoading;
872
- this.loadingLabel = (_d = (_c = this.options) === null || _c === void 0 ? void 0 : _c.loadingLabel) !== null && _d !== void 0 ? _d : defaultOptions.loadingLabel;
990
+ const buttonEl = this.document.createElement('div');
991
+ const buttonSize = 12;
992
+ merge(buttonEl.style, {
993
+ bottom: '100%',
994
+ right: '0',
995
+ width: `${buttonSize}px`,
996
+ height: `${buttonSize}px`,
997
+ padding: '1px',
998
+ textAlign: 'center',
999
+ backgroundColor: this.color,
1000
+ position: 'absolute',
1001
+ cursor: 'pointer',
1002
+ display: 'block',
1003
+ pointerEvents: 'all',
1004
+ });
1005
+ buttonEl.innerHTML = '&#10005;';
1006
+ buttonEl.addEventListener('click', () => {
1007
+ if (this.metadata.path) {
1008
+ this.runtimeEditorService.elementDeleted$.next({ path: this.metadata.path });
1009
+ }
1010
+ });
1011
+ container.appendChild(buttonEl);
1012
+ }
1013
+ addElementName(container) {
1014
+ const nameEl = this.document.createElement('div');
1015
+ merge(nameEl.style, {
1016
+ bottom: '100%',
1017
+ left: '0',
1018
+ height: `12px`,
1019
+ backgroundColor: this.color,
1020
+ position: 'absolute',
1021
+ padding: '1px 2px',
1022
+ display: 'block',
1023
+ pointerEvents: 'all',
1024
+ });
1025
+ nameEl.innerHTML = this.metadata.name;
1026
+ container.appendChild(nameEl);
1027
+ }
1028
+ deleteRemoveButton() {
1029
+ if (this.overlayEl) {
1030
+ this.el.nativeElement.removeChild(this.overlayEl);
1031
+ this.overlayEl = undefined;
873
1032
  }
874
1033
  }
875
- ngOnInit() {
876
- this.isLoading$.next(true);
1034
+ }
1035
+ ElementHoverPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementHoverPlugin, deps: [{ token: ElementComponent }], target: i0.ɵɵFactoryTarget.Directive });
1036
+ ElementHoverPlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: ElementHoverPlugin, ngImport: i0 });
1037
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementHoverPlugin, decorators: [{
1038
+ type: Directive
1039
+ }], ctorParameters: function () { return [{ type: ElementComponent }]; } });
1040
+
1041
+ class IOPlugin {
1042
+ constructor(host) {
1043
+ var _a, _b;
1044
+ this.host = host;
1045
+ const elementMetadata = this.host.injector.get(ELEMENT_METADATA);
1046
+ const inputProvider = this.host.injector.get(IOProviderService);
1047
+ const inputs = Object.entries((_a = elementMetadata.inputs) !== null && _a !== void 0 ? _a : {});
1048
+ const outputs = Object.entries((_b = elementMetadata.outputs) !== null && _b !== void 0 ? _b : {});
1049
+ inputs.forEach(([key, path]) => {
1050
+ var _a;
1051
+ if (path && typeof path !== 'string') {
1052
+ console.error(`The value of '${key}' input should be a string`);
1053
+ }
1054
+ if (((_a = elementMetadata.outputs) === null || _a === void 0 ? void 0 : _a[key]) !== undefined) {
1055
+ console.warn(`'${key}' appears both in inputs and outputs. To prevent inconsistent behavior please keep them unique `);
1056
+ }
1057
+ this.host[key] = inputProvider.connect(elementMetadata, key, path);
1058
+ });
1059
+ outputs.forEach(([key, path]) => {
1060
+ if (path && typeof path !== 'string') {
1061
+ console.error(`The value of '${key}' output should be a string`);
1062
+ }
1063
+ this.host[key] = inputProvider.provide(elementMetadata, key, path);
1064
+ });
877
1065
  }
878
- ngAfterViewInit() {
879
- var _a, _b, _c, _d, _e, _f;
880
- const remoteEntry = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.remoteEntry) !== null && _b !== void 0 ? _b : this.remoteEntry;
881
- const remoteName = (_d = (_c = this.options) === null || _c === void 0 ? void 0 : _c.remoteName) !== null && _d !== void 0 ? _d : this.remoteName;
882
- const exposedModule = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.exposedModule) !== null && _f !== void 0 ? _f : this.exposedModule;
883
- if (!remoteEntry || !remoteName || !exposedModule) {
1066
+ }
1067
+ IOPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IOPlugin, deps: [{ token: ElementComponent }], target: i0.ɵɵFactoryTarget.Directive });
1068
+ IOPlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: IOPlugin, ngImport: i0 });
1069
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IOPlugin, decorators: [{
1070
+ type: Directive
1071
+ }], ctorParameters: function () { return [{ type: ElementComponent }]; } });
1072
+
1073
+ class ScriptPlugin {
1074
+ constructor(host) {
1075
+ this.host = host;
1076
+ this.normalizeImports = (script, elementPath) => {
1077
+ const 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');
1078
+ const result = script.replace(regexp, (match, g1, g2, src) => {
1079
+ const imports = g1
1080
+ .trim()
1081
+ .slice(1, -1)
1082
+ .split(',')
1083
+ .map(item => item.trim());
1084
+ imports.forEach(item => {
1085
+ var _a;
1086
+ if (!((_a = this.vendorMap[src]) === null || _a === void 0 ? void 0 : _a[item])) {
1087
+ throw new Error(`Failed to import ${item} from '${src}' in ${elementPath}/script.ts`);
1088
+ }
1089
+ });
1090
+ return `const ${g1} = vendor['${src}'];`;
1091
+ });
1092
+ return result;
1093
+ };
1094
+ this.document = this.host.injector.get(DOCUMENT);
1095
+ this.vendorMap = this.host.injector.get(VENDOR_MAP);
1096
+ const elementMetadata = this.host.injector.get(ELEMENT_METADATA);
1097
+ const sharedElementMetadata = this.host.injector.get(SHARED_ELEMENT_METADATA);
1098
+ this.addScript(sharedElementMetadata);
1099
+ this.addScript(elementMetadata);
1100
+ }
1101
+ addScript(metadata) {
1102
+ var _a;
1103
+ if (!(metadata === null || metadata === void 0 ? void 0 : metadata.script)) {
884
1104
  return;
885
1105
  }
886
- loadRemoteModule(remoteEntry, remoteName, exposedModule).then(federated => {
887
- this.compiler.compileModuleAsync(federated[exposedModule]).then(moduleFactory => {
888
- var _a, _b, _c;
889
- const rootModuleRef = moduleFactory.create(this.injector);
890
- const rootComponentFactory = rootModuleRef.componentFactoryResolver.resolveComponentFactory(federated[exposedModule].rootComponent);
891
- const node = document.createElement('div');
892
- const { instance, hostView } = rootComponentFactory.create(this.injector, [], node);
893
- this.instance = instance;
894
- this.instance.data = this.data;
895
- this.renderer.appendChild((_a = this.moduleHostRef) === null || _a === void 0 ? void 0 : _a.nativeElement, node);
896
- this.appRef.attachView(hostView);
897
- (_c = (_b = this.options) === null || _b === void 0 ? void 0 : _b.onReady) === null || _c === void 0 ? void 0 : _c.call(_b);
898
- this.isLoading$.next(false);
899
- });
900
- });
1106
+ const id = btoa(UUID.UUID());
1107
+ const script = this.document.createElement('script');
1108
+ script.type = `text/javascript`;
1109
+ let scriptContent = this.normalizeImports(metadata.script, (_a = metadata.path) !== null && _a !== void 0 ? _a : metadata.name);
1110
+ const classMatch = /export class (\S+)/.exec(scriptContent);
1111
+ const className = classMatch === null || classMatch === void 0 ? void 0 : classMatch[1];
1112
+ if (!classMatch || !className) {
1113
+ console.error("Script doesn't have exported class");
1114
+ return;
1115
+ }
1116
+ scriptContent = scriptContent.replace(classMatch[0], `class ${className}`);
1117
+ script.text = `var ${id} = function(vendor) {${scriptContent}
1118
+ return ${className}; };`;
1119
+ this.document.body.appendChild(script);
1120
+ const ScriptClass = window[id](this.vendorMap);
1121
+ if (ScriptClass instanceof Object) {
1122
+ this.host.registerPlugin(new ScriptClass(this.host));
1123
+ }
1124
+ this.document.body.removeChild(script);
901
1125
  }
902
1126
  }
903
- FederatedComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FederatedComponent, deps: [{ token: i0.Injector }, { token: i0.Compiler }, { token: i0.ApplicationRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
904
- FederatedComponentcmp = i0.ɵɵ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, 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.LoaderComponent, selector: "vl-loader", inputs: ["label", "overlayVisible"] }], directives: [{ type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i7.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
905
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FederatedComponent, decorators: [{
906
- type: Component,
907
- args: [{
908
- // eslint-disable-next-line @angular-eslint/component-selector
909
- selector: 'veloce-host-federated',
910
- templateUrl: './federated.component.html',
911
- styleUrls: ['./federated.component.scss'],
912
- changeDetection: ChangeDetectionStrategy.OnPush,
913
- }]
914
- }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.Compiler }, { type: i0.ApplicationRef }, { type: i0.Renderer2 }]; }, propDecorators: { moduleHostRef: [{
915
- type: ViewChild,
916
- args: ['moduleHost', { static: false }]
917
- }], remoteEntry: [{
918
- type: Input
919
- }], remoteName: [{
920
- type: Input
921
- }], exposedModule: [{
922
- type: Input
923
- }], data: [{
924
- type: Input
925
- }], options: [{
926
- type: Input
927
- }] } });
1127
+ ScriptPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ScriptPlugin, deps: [{ token: ElementComponent }], target: i0.ɵɵFactoryTarget.Directive });
1128
+ ScriptPlugindir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: ScriptPlugin, ngImport: i0 });
1129
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ScriptPlugin, decorators: [{
1130
+ type: Directive
1131
+ }], ctorParameters: function () { return [{ type: ElementComponent }]; } });
928
1132
 
929
- class FederatedModule {
1133
+ /*
1134
+ * ScriptPlugin must always be the last plugin in the list to make sure user code is running after all pre-initializers.
1135
+ */
1136
+ const CONFIG = {
1137
+ CUSTOM: {
1138
+ component: ElementComponent,
1139
+ plugins: [ElementHoverPlugin, IOPlugin, ScriptPlugin],
1140
+ },
1141
+ CONTAINER: {
1142
+ component: ElementComponent,
1143
+ defaultTemplate: '<element-children></element-children>',
1144
+ plugins: [ElementHoverPlugin, ScriptPlugin],
1145
+ },
1146
+ SERVICE: {
1147
+ component: ElementComponent,
1148
+ plugins: [IOPlugin, ScriptPlugin],
1149
+ suppressTemplate: true,
1150
+ suppressStyles: true,
1151
+ },
1152
+ REFERENCE: {
1153
+ component: ElementComponent,
1154
+ plugins: [ElementHoverPlugin, IOPlugin, ScriptPlugin],
1155
+ suppressTemplate: true,
1156
+ },
1157
+ PAGE: {
1158
+ component: ElementComponent,
1159
+ plugins: [ElementHoverPlugin, IOPlugin, ScriptPlugin],
1160
+ },
1161
+ PAGE_LAYOUT: {
1162
+ component: ElementComponent,
1163
+ plugins: [ElementHoverPlugin, IOPlugin, ScriptPlugin],
1164
+ },
1165
+ LAYOUT_REGION: {
1166
+ component: ElementComponent,
1167
+ plugins: [ElementHoverPlugin, IOPlugin, ScriptPlugin],
1168
+ },
1169
+ };
1170
+
1171
+ const EXPORTED_CLASS_REGEX = /export class (\S+)/;
1172
+ const METADATA_DECORATOR_REGEX = /@ElementDefinition\(([\s\S]+)\)(\n|\r\n|.)*export class/g;
1173
+ class UiBuildError extends Error {
1174
+ constructor(message, affectedMetadata) {
1175
+ super(message);
1176
+ this.name = this.constructor.name;
1177
+ this.affectedMetadata = affectedMetadata;
1178
+ }
1179
+ }
1180
+ const elementToMetadata = (el, parentPath) => {
1181
+ var _a;
1182
+ const script = el.script && window.atob(el.script);
1183
+ const template = el.template && window.atob(el.template);
1184
+ const styles = el.styles && window.atob(el.styles);
1185
+ const exportedClassName = script && ((_a = EXPORTED_CLASS_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
1186
+ if (!exportedClassName) {
1187
+ throw new Error("Script doesn't have exported class");
1188
+ }
1189
+ const elementMetadata = extractElementMetadata(script || '');
1190
+ const path = (parentPath ? parentPath + '/' : '') + elementMetadata.name;
1191
+ return Object.assign(Object.assign({}, elementMetadata), { path, script: script === null || script === void 0 ? void 0 : script.replace(METADATA_DECORATOR_REGEX, 'export class'), template,
1192
+ styles, children: el.children.map(child => elementToMetadata(child, path)) });
1193
+ };
1194
+ const metadataToElement = (metadata, recursive = true) => {
1195
+ const elMetadata = {
1196
+ name: metadata.name,
1197
+ isShared: metadata.isShared,
1198
+ type: metadata.type,
1199
+ model: metadata.model,
1200
+ module: metadata.module,
1201
+ reference: metadata.reference,
1202
+ inputs: metadata.inputs,
1203
+ outputs: metadata.outputs,
1204
+ children: metadata.children.map(({ name }) => name),
1205
+ configuredStyles: metadata.configuredStyles,
1206
+ };
1207
+ const normalizedElMetadata = normalizeElementMetadata(elMetadata);
1208
+ if (!metadata.script || !EXPORTED_CLASS_REGEX.test(metadata.script)) {
1209
+ throw new UiBuildError(`'${metadata.name}' component script is missing an exported class`, metadata);
1210
+ }
1211
+ const script = metadata.script &&
1212
+ window.btoa(metadata.script.replace(EXPORTED_CLASS_REGEX, `@ElementDefinition(${stringifyElementMetadata(normalizedElMetadata)})\nexport class Script`));
1213
+ const template = metadata.template && window.btoa(metadata.template);
1214
+ const styles = metadata.styles && window.btoa(metadata.styles);
1215
+ return {
1216
+ script,
1217
+ template,
1218
+ styles,
1219
+ children: recursive ? metadata.children.map(meta => metadataToElement(meta)) : [],
1220
+ };
1221
+ };
1222
+ const normalizeElementMetadata = (elementMetadata) => {
1223
+ var _a, _b, _c, _d;
1224
+ const metadata = Object.assign({}, elementMetadata);
1225
+ // model
1226
+ const { lineItem, path } = (_a = metadata.model) !== null && _a !== void 0 ? _a : {};
1227
+ const model = lineItem ? { lineItem } : path ? { path } : undefined;
1228
+ if (model) {
1229
+ metadata.model = model;
1230
+ }
1231
+ else {
1232
+ delete metadata.model;
1233
+ }
1234
+ // module
1235
+ if (!metadata.module) {
1236
+ delete metadata.module;
1237
+ }
1238
+ // reference
1239
+ if (!metadata.reference) {
1240
+ delete metadata.reference;
1241
+ }
1242
+ // inputs
1243
+ const inputs = Object.entries((_b = metadata.inputs) !== null && _b !== void 0 ? _b : {}).reduce((acc, [key, value]) => {
1244
+ return Object.assign(Object.assign({}, acc), { [key]: value || null });
1245
+ }, {});
1246
+ if (inputs && Object.keys(inputs).length > 0) {
1247
+ metadata.inputs = inputs;
1248
+ }
1249
+ else {
1250
+ delete metadata.inputs;
1251
+ }
1252
+ // outputs
1253
+ const outputs = Object.entries((_c = metadata.outputs) !== null && _c !== void 0 ? _c : {}).reduce((acc, [key, value]) => {
1254
+ return Object.assign(Object.assign({}, acc), { [key]: value || null });
1255
+ }, {});
1256
+ if (outputs && Object.keys(outputs).length > 0) {
1257
+ metadata.outputs = outputs;
1258
+ }
1259
+ else {
1260
+ delete metadata.outputs;
1261
+ }
1262
+ // children
1263
+ if (!((_d = metadata.children) === null || _d === void 0 ? void 0 : _d.length)) {
1264
+ delete metadata.children;
1265
+ }
1266
+ // isShared
1267
+ if (!metadata.isShared) {
1268
+ delete metadata.isShared;
1269
+ }
1270
+ // configuredStyles
1271
+ if (!metadata.configuredStyles) {
1272
+ delete metadata.configuredStyles;
1273
+ }
1274
+ return metadata;
1275
+ };
1276
+ const extractElementMetadata = (script) => {
1277
+ var _a;
1278
+ const metadataString = ((_a = METADATA_DECORATOR_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
1279
+ // need to reset regex last index to prevent null result for next execution
1280
+ METADATA_DECORATOR_REGEX.lastIndex = 0;
1281
+ return new Function(`return ${metadataString}`)();
1282
+ };
1283
+ const extendElementMetadata = (script, extend) => {
1284
+ var _a;
1285
+ const metadataString = ((_a = METADATA_DECORATOR_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
1286
+ // need to reset regex last index to prevent null result for next execution
1287
+ METADATA_DECORATOR_REGEX.lastIndex = 0;
1288
+ if (!metadataString) {
1289
+ return script;
1290
+ }
1291
+ const updated = Object.assign(Object.assign({}, new Function(`return ${metadataString}`)()), extend);
1292
+ return script.replace(metadataString, stringifyElementMetadata(updated));
1293
+ };
1294
+ const getElementConfig = (type) => {
1295
+ return CONFIG[type];
1296
+ };
1297
+ const doesElementSupportIO = (type) => {
1298
+ var _a, _b;
1299
+ return (_b = (_a = getElementConfig(type).plugins) === null || _a === void 0 ? void 0 : _a.includes(IOPlugin)) !== null && _b !== void 0 ? _b : false;
1300
+ };
1301
+ function stringifyElementMetadata(elementMetadata) {
1302
+ const cleaned = JSON.stringify(elementMetadata, null, 2);
1303
+ return cleaned.replace(/^[\t ]*"[^:\n\r]+(?<!\\)":/gm, function (match) {
1304
+ return match.replace(/"/g, '');
1305
+ });
1306
+ }
1307
+ const isValidScript = (script) => {
1308
+ var _a;
1309
+ if (!script) {
1310
+ return false;
1311
+ }
1312
+ const exportedClassName = script && ((_a = EXPORTED_CLASS_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
1313
+ if (!exportedClassName) {
1314
+ return false;
1315
+ }
1316
+ const meta = extractElementMetadata(script);
1317
+ if (!meta.name || !meta.type) {
1318
+ return false;
1319
+ }
1320
+ return true;
1321
+ };
1322
+ function flattenElements(elements) {
1323
+ return flatten(elements.map(el => [el, ...flattenElements(el.children)]));
1324
+ }
1325
+ function isSharedElement(el) {
1326
+ return Boolean(el.isShared) && el.type !== 'REFERENCE';
930
1327
  }
931
- FederatedModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FederatedModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
932
- FederatedModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FederatedModule, declarations: [FederatedComponent], imports: [CommonModule, LoaderModule], exports: [FederatedComponent] });
933
- FederatedModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FederatedModule, imports: [[CommonModule, LoaderModule]] });
934
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FederatedModule, decorators: [{
935
- type: NgModule,
936
- args: [{
937
- declarations: [FederatedComponent],
938
- imports: [CommonModule, LoaderModule],
939
- exports: [FederatedComponent],
940
- }]
941
- }] });
942
1328
 
943
1329
  class ConfigurationPlugin {
944
1330
  constructor(host) {
@@ -979,9 +1365,17 @@ class ConfigurationPlugin {
979
1365
  if (!rootLineItem || !this.modelSnapshot) {
980
1366
  return;
981
1367
  }
982
- this.configurationService.patch(new LineItemWorker(rootLineItem).remove(this.modelSnapshot.id).li);
1368
+ this.configurationService.patch(new LineItemWorker(rootLineItem).remove(this.modelSnapshot.id).li);
1369
+ };
1370
+ const updateQty = (qty) => {
1371
+ const rootLineItem = this.configurationService.getSnapshot();
1372
+ if (!rootLineItem || !this.modelSnapshot) {
1373
+ return;
1374
+ }
1375
+ this.configurationService.patch(new LineItemWorker(rootLineItem).replace(Object.assign(Object.assign({}, this.modelSnapshot), { qty })).li);
983
1376
  };
984
1377
  this.typeHost.remove = remove;
1378
+ this.typeHost.updateQty = updateQty;
985
1379
  }
986
1380
  registerPort(name) {
987
1381
  const model$ = this.host.model$;
@@ -1026,9 +1420,9 @@ class ConfigurationPlugin {
1026
1420
  return this.host;
1027
1421
  }
1028
1422
  }
1029
- ConfigurationPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationPlugin, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
1030
- ConfigurationPlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: ConfigurationPlugin, ngImport: i0 });
1031
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationPlugin, decorators: [{
1423
+ ConfigurationPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ConfigurationPlugin, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
1424
+ ConfigurationPlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: ConfigurationPlugin, ngImport: i0 });
1425
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ConfigurationPlugin, decorators: [{
1032
1426
  type: Directive
1033
1427
  }], ctorParameters: function () { return [{ type: undefined }]; } });
1034
1428
 
@@ -1037,49 +1431,13 @@ const DEFAULT_PLUGINS = {
1037
1431
  DEFAULT: [],
1038
1432
  };
1039
1433
 
1040
- const InitAction = { type: 'INIT' };
1041
- const ClearAction = { type: 'CLEAR' };
1042
- class IntegrationState {
1043
- constructor() {
1044
- this.stateSubj$ = new BehaviorSubject({});
1045
- this.action$ = new BehaviorSubject(InitAction);
1046
- }
1047
- get state$() {
1048
- return this.stateSubj$.asObservable();
1049
- }
1050
- get state() {
1051
- return this.stateSubj$.getValue();
1052
- }
1053
- patchState(update) {
1054
- this.stateSubj$.next(Object.assign(Object.assign({}, this.stateSubj$.getValue()), update));
1055
- }
1056
- dispatch(action) {
1057
- this.action$.next(action);
1058
- }
1059
- listen$(actionType) {
1060
- return this.action$.pipe(filter(action => action.type === actionType), map(action => action.payload));
1061
- }
1062
- listenAll$() {
1063
- return this.action$.asObservable();
1064
- }
1065
- clear() {
1066
- this.stateSubj$.next({});
1067
- this.action$.next(ClearAction);
1068
- }
1069
- }
1070
- IntegrationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IntegrationState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1071
- IntegrationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IntegrationState, providedIn: 'root' });
1072
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: IntegrationState, decorators: [{
1073
- type: Injectable,
1074
- args: [{ providedIn: 'root' }]
1075
- }] });
1076
-
1077
1434
  const VELOCE_LIBS = {
1078
1435
  '@veloceapps/sdk/core': Object.assign({ ConfigurationService,
1079
1436
  QuoteDraftService,
1080
1437
  FlowConfigurationService,
1081
1438
  LineItemWorker,
1082
- ProductImagesService }, lineItemUtils),
1439
+ ProductImagesService,
1440
+ ContextService }, lineItemUtils),
1083
1441
  '@veloceapps/sdk/cms': Object.assign(Object.assign(Object.assign({}, cmsInjectionTokens), cmsActions), { TemplatesService,
1084
1442
  IntegrationState }),
1085
1443
  '@veloceapps/api': {
@@ -1092,23 +1450,39 @@ const VELOCE_LIBS = {
1092
1450
  DeltaApiService,
1093
1451
  PicklistsApiService,
1094
1452
  PriceApiService,
1453
+ ShoppingCartSettingsApiService,
1454
+ ConfigurationSettingsApiService,
1455
+ },
1456
+ '@veloceapps/components': {
1457
+ ToastService,
1095
1458
  },
1096
1459
  };
1097
1460
  const VELOCE_LIBS_BACKWARDS_COMPATIBLE = Object.entries(VELOCE_LIBS).reduce((trunk, [key, value]) => (Object.assign(Object.assign({}, trunk), { [key.replace('@veloceapps/', '@veloce/')]: value })), {});
1098
1461
  const vendorMap = Object.assign(Object.assign(Object.assign({}, VELOCE_LIBS), VELOCE_LIBS_BACKWARDS_COMPATIBLE), { '@angular/core': i0, '@angular/forms': angularForms, rxjs: rxjs, 'rxjs/operators': rxjsOperators, lodash: lodash });
1099
1462
 
1100
1463
  class ElementsResolver {
1101
- constructor(uiDef, elements) {
1464
+ constructor(uiDef, elements, sharedElements = []) {
1102
1465
  this.uiDef = uiDef;
1103
1466
  this.renderableElements = [];
1104
1467
  this.sharedElements = [];
1105
1468
  const transpiledElements = this.transpileScripts(elements);
1106
- this.sharedElements = this.flattenElements(transpiledElements).filter(el => this.isSharedElement(el));
1107
- this.elements = transpiledElements.map(el => this.processElementMetadata(el)).filter(Boolean);
1469
+ const transpiledSharedElements = this.transpileScripts(sharedElements);
1470
+ this.sharedElements = this.flattenElements(transpiledElements)
1471
+ .filter(el => this.isSharedElement(el))
1472
+ .concat(transpiledSharedElements);
1473
+ this.elements = transpiledElements.map(el => this.processElementMetadata(el)).filter(isDefined);
1474
+ this.renderableElements = this.getRenderableElements(this.elements);
1475
+ }
1476
+ addElement(element) {
1477
+ if (element.isShared) {
1478
+ return;
1479
+ }
1480
+ const transpiledElements = this.transpileScripts([element]);
1481
+ this.elements = transpiledElements.map(el => this.processElementMetadata(el)).filter(isDefined);
1108
1482
  this.renderableElements = this.getRenderableElements(this.elements);
1109
1483
  }
1110
1484
  getNgComponents() {
1111
- return this.renderableElements.map(el => this.resolveElement(el)).filter(Boolean);
1485
+ return this.renderableElements.map(el => this.resolveElement(el)).filter(isDefined);
1112
1486
  }
1113
1487
  transpile(el) {
1114
1488
  var _a;
@@ -1175,9 +1549,7 @@ class ElementsResolver {
1175
1549
  }
1176
1550
  finalElement.template = this.resolveElementTemplate(finalElement);
1177
1551
  finalElement.styles = this.resolveElementStyles(finalElement);
1178
- return Object.assign(Object.assign({}, finalElement), { children: finalElement.children
1179
- .map(child => this.processElementMetadata(child))
1180
- .filter(Boolean) });
1552
+ return Object.assign(Object.assign({}, finalElement), { children: finalElement.children.map(child => this.processElementMetadata(child)).filter(isDefined) });
1181
1553
  }
1182
1554
  getSharedChildren(children, parentPath) {
1183
1555
  return children.map(c => {
@@ -1237,202 +1609,298 @@ class ElementsResolver {
1237
1609
  }
1238
1610
  }
1239
1611
 
1240
- class LauncherService {
1241
- constructor(compiler, dynamicModuleService) {
1242
- this.compiler = compiler;
1243
- this.dynamicModuleService = dynamicModuleService;
1244
- }
1245
- compileModule(uiDef, elements) {
1246
- const elementsResolver = new ElementsResolver(uiDef, elements);
1247
- this.dynamicModuleService.elementsTree = elementsResolver.elements;
1248
- this.module = this.getModule(elementsResolver.getNgComponents());
1249
- return from(this.compiler.compileModuleAndAllComponentsAsync(this.module)).pipe(tap(m => {
1250
- this.dynamicModuleService.componentFactories = m.componentFactories;
1251
- this.moduleInstance = m;
1252
- }), map(m => ({ module: m, elements: elementsResolver.elements })));
1253
- }
1254
- destroy() {
1255
- if (this.moduleInstance) {
1256
- this.dynamicModuleService.clear();
1257
- this.moduleInstance = undefined;
1258
- }
1259
- if (this.module) {
1260
- this.compiler.clearCacheFor(this.module);
1261
- this.module = undefined;
1612
+ const defaultOptions = {
1613
+ suppressLoading: false,
1614
+ loadingLabel: 'LOADING',
1615
+ };
1616
+
1617
+ const moduleMap = {};
1618
+ function loadRemoteEntry(remoteEntry) {
1619
+ return new Promise((resolve, reject) => {
1620
+ if (moduleMap[remoteEntry]) {
1621
+ resolve();
1622
+ return;
1262
1623
  }
1263
- }
1264
- getModule(components) {
1265
- const staticComponents = [ElementChildrenComponent, ElementRendererComponent, CustomTemplateDirective];
1266
- let DynamicModule = class DynamicModule {
1624
+ const script = document.createElement('script');
1625
+ script.src = remoteEntry;
1626
+ script.onerror = reject;
1627
+ script.onload = () => {
1628
+ moduleMap[remoteEntry] = true;
1629
+ resolve(); // window is the global namespace
1267
1630
  };
1268
- DynamicModule = __decorate([
1269
- NgModule({
1270
- imports: [CommonModule, FormsModule, ReactiveFormsModule, FederatedModule, DragDropModule, ScrollingModule],
1271
- declarations: [...staticComponents, ...components],
1272
- jit: true,
1273
- })
1274
- ], DynamicModule);
1275
- return DynamicModule;
1276
- }
1631
+ document.body.append(script);
1632
+ });
1633
+ }
1634
+ function lookupExposedModule(remoteName, exposedModule) {
1635
+ return __awaiter(this, void 0, void 0, function* () {
1636
+ // Initializes the share scope. This fills it with known provided modules from this build and all remotes
1637
+ yield __webpack_init_sharing__('default');
1638
+ const container = window[remoteName]; // or get the container somewhere else
1639
+ // Initialize the container, it may provide shared modules
1640
+ yield container.init(__webpack_share_scopes__.default);
1641
+ const factory = yield container.get(exposedModule);
1642
+ const Module = factory();
1643
+ return Module;
1644
+ });
1645
+ }
1646
+ function loadRemoteModule(remoteEntry, remoteName, exposedModule) {
1647
+ return __awaiter(this, void 0, void 0, function* () {
1648
+ yield loadRemoteEntry(remoteEntry);
1649
+ return yield lookupExposedModule(remoteName, exposedModule);
1650
+ });
1277
1651
  }
1278
- LauncherService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LauncherService, deps: [{ token: i0.Compiler }, { token: DynamicModuleService }], target: i0.ɵɵFactoryTarget.Injectable });
1279
- LauncherService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LauncherService });
1280
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LauncherService, decorators: [{
1281
- type: Injectable
1282
- }], ctorParameters: function () { return [{ type: i0.Compiler }, { type: DynamicModuleService }]; } });
1283
1652
 
1284
- class PreviewComponent {
1285
- constructor(launcherService, configurationService, messageService, runtimeService, integrationState) {
1286
- this.launcherService = launcherService;
1287
- this.configurationService = configurationService;
1288
- this.messageService = messageService;
1289
- this.runtimeService = runtimeService;
1290
- this.integrationState = integrationState;
1291
- this.clearState = false;
1292
- this.state$ = new BehaviorSubject({ loading: true, failure: false });
1293
- this.elements = [];
1294
- this.destroy$ = new Subject();
1295
- }
1296
- ngOnInit() {
1297
- if (this.clearState) {
1298
- this.integrationState.clear();
1299
- }
1300
- this.startPreview();
1301
- }
1302
- ngOnDestroy() {
1303
- this.destroy$.next();
1304
- this.destroy$.complete();
1305
- this.configurationService.reset();
1653
+ class FederatedComponent {
1654
+ constructor(injector, compiler, appRef, renderer) {
1655
+ this.injector = injector;
1656
+ this.compiler = compiler;
1657
+ this.appRef = appRef;
1658
+ this.renderer = renderer;
1659
+ this.isLoading$ = new BehaviorSubject(false);
1660
+ // configs
1661
+ this.suppressLoading = defaultOptions.suppressLoading;
1662
+ this.loadingLabel = defaultOptions.loadingLabel;
1306
1663
  }
1307
- initializeConfiguration$() {
1308
- const isAlreadyInitialized = this.runtimeService.isInitialized;
1309
- if (!this.uiDefinition || this.uiDefinition.type !== 'CONFIGURATION' || isAlreadyInitialized) {
1310
- return of({});
1664
+ ngOnChanges(changes) {
1665
+ var _a, _b, _c, _d;
1666
+ if (changes.data && this.instance) {
1667
+ this.instance.data = this.data;
1311
1668
  }
1312
- if (!this.modelId) {
1313
- console.warn(`No modelId is given for uiDefinition with '${this.uiDefinition.type}' type`);
1314
- return of({});
1669
+ if (changes.options) {
1670
+ this.suppressLoading = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.suppressLoading) !== null && _b !== void 0 ? _b : defaultOptions.suppressLoading;
1671
+ this.loadingLabel = (_d = (_c = this.options) === null || _c === void 0 ? void 0 : _c.loadingLabel) !== null && _d !== void 0 ? _d : defaultOptions.loadingLabel;
1315
1672
  }
1316
- // If still not initialized - init configuration in Test mode
1317
- return this.runtimeService
1318
- .initTestMode(this.modelId, this.uiDefinition)
1319
- .pipe(switchMap(() => this.configurationService.configure()));
1320
1673
  }
1321
- elementToMetadataSafe(elements) {
1322
- var _a, _b;
1323
- try {
1324
- return elements.map(element => elementToMetadata(element));
1325
- }
1326
- catch (e) {
1327
- console.error(e);
1328
- if (!((_b = (_a = this.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.suppressToastMessages)) {
1329
- this.messageService.add({ severity: 'error', summary: String(e) });
1330
- }
1331
- return [];
1332
- }
1674
+ ngOnInit() {
1675
+ this.isLoading$.next(true);
1333
1676
  }
1334
- startPreview() {
1335
- if (!this.uiDefinition) {
1677
+ ngAfterViewInit() {
1678
+ var _a, _b, _c, _d, _e, _f;
1679
+ const remoteEntry = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.remoteEntry) !== null && _b !== void 0 ? _b : this.remoteEntry;
1680
+ const remoteName = (_d = (_c = this.options) === null || _c === void 0 ? void 0 : _c.remoteName) !== null && _d !== void 0 ? _d : this.remoteName;
1681
+ const exposedModule = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.exposedModule) !== null && _f !== void 0 ? _f : this.exposedModule;
1682
+ if (!remoteEntry || !remoteName || !exposedModule) {
1336
1683
  return;
1337
1684
  }
1338
- const _a = this.uiDefinition, { children } = _a, uiDefinitionMeta = __rest(_a, ["children"]);
1339
- const elements = this.elementToMetadataSafe(children);
1340
- const compilation$ = this.launcherService.compileModule(uiDefinitionMeta, elements);
1341
- forkJoin([compilation$, this.initializeConfiguration$()])
1342
- .pipe(tap(([result]) => {
1343
- this.elements = result.elements;
1344
- this.state$.next({ loading: false, failure: false });
1345
- }), catchError(error => {
1346
- var _a, _b;
1347
- console.error(error);
1348
- if (!((_b = (_a = this.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.suppressToastMessages)) {
1349
- this.messageService.add({ severity: 'error', summary: error });
1350
- }
1351
- this.state$.next({ loading: false, failure: true });
1352
- return of();
1353
- }), takeUntil(this.destroy$))
1354
- .subscribe();
1685
+ loadRemoteModule(remoteEntry, remoteName, exposedModule).then(federated => {
1686
+ this.compiler.compileModuleAsync(federated[exposedModule]).then(moduleFactory => {
1687
+ var _a, _b, _c;
1688
+ const rootModuleRef = moduleFactory.create(this.injector);
1689
+ const rootComponentFactory = rootModuleRef.componentFactoryResolver.resolveComponentFactory(federated[exposedModule].rootComponent);
1690
+ const node = document.createElement('div');
1691
+ const { instance, hostView } = rootComponentFactory.create(this.injector, [], node);
1692
+ this.instance = instance;
1693
+ this.instance.data = this.data;
1694
+ this.renderer.appendChild((_a = this.moduleHostRef) === null || _a === void 0 ? void 0 : _a.nativeElement, node);
1695
+ this.appRef.attachView(hostView);
1696
+ (_c = (_b = this.options) === null || _b === void 0 ? void 0 : _b.onReady) === null || _c === void 0 ? void 0 : _c.call(_b);
1697
+ this.isLoading$.next(false);
1698
+ });
1699
+ });
1355
1700
  }
1356
1701
  }
1357
- PreviewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreviewComponent, deps: [{ token: LauncherService }, { token: i2.ConfigurationService }, { token: i3.MessageService }, { token: i2.ConfigurationRuntimeService }, { token: IntegrationState }], target: i0.ɵɵFactoryTarget.Component });
1358
- PreviewComponent.ɵcmp = i0.ɵɵ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, 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.LoaderComponent, selector: "vl-loader", inputs: ["label", "overlayVisible"] }, { type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: ["meta"] }], directives: [{ type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i7.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.ShadowDom });
1359
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreviewComponent, decorators: [{
1702
+ FederatedComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FederatedComponent, deps: [{ token: i0.Injector }, { token: i0.Compiler }, { token: i0.ApplicationRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
1703
+ FederatedComponent.ɵcmp = i0.ɵɵ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, 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.LoaderComponent, selector: "vl-loader", inputs: ["label", "overlayVisible"] }], directives: [{ type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i7.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
1704
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FederatedComponent, decorators: [{
1360
1705
  type: Component,
1361
1706
  args: [{
1362
- selector: 'vl-cms-preview',
1363
- templateUrl: './preview.component.html',
1364
- styleUrls: ['./preview.component.scss'],
1707
+ // eslint-disable-next-line @angular-eslint/component-selector
1708
+ selector: 'veloce-host-federated',
1709
+ templateUrl: './federated.component.html',
1710
+ styleUrls: ['./federated.component.scss'],
1365
1711
  changeDetection: ChangeDetectionStrategy.OnPush,
1366
- providers: [IOProviderService, TemplatesService],
1367
- // use shadow DOM to prevent UI from being affected by global styles
1368
- encapsulation: ViewEncapsulation.ShadowDom,
1369
1712
  }]
1370
- }], ctorParameters: function () { return [{ type: LauncherService }, { type: i2.ConfigurationService }, { type: i3.MessageService }, { type: i2.ConfigurationRuntimeService }, { type: IntegrationState }]; }, propDecorators: { modelId: [{
1713
+ }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.Compiler }, { type: i0.ApplicationRef }, { type: i0.Renderer2 }]; }, propDecorators: { moduleHostRef: [{
1714
+ type: ViewChild,
1715
+ args: ['moduleHost', { static: false }]
1716
+ }], remoteEntry: [{
1371
1717
  type: Input
1372
- }], uiDefinition: [{
1718
+ }], remoteName: [{
1719
+ type: Input
1720
+ }], exposedModule: [{
1721
+ type: Input
1722
+ }], data: [{
1373
1723
  type: Input
1374
- }], clearState: [{
1724
+ }], options: [{
1375
1725
  type: Input
1376
1726
  }] } });
1377
1727
 
1378
- class ElementRendererModule {
1728
+ class FederatedModule {
1379
1729
  }
1380
- ElementRendererModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementRendererModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1381
- ElementRendererModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementRendererModule, declarations: [ElementRendererComponent], exports: [ElementRendererComponent] });
1382
- ElementRendererModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementRendererModule });
1383
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementRendererModule, decorators: [{
1730
+ FederatedModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FederatedModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1731
+ FederatedModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FederatedModule, declarations: [FederatedComponent], imports: [CommonModule, LoaderModule], exports: [FederatedComponent] });
1732
+ FederatedModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FederatedModule, imports: [[CommonModule, LoaderModule]] });
1733
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FederatedModule, decorators: [{
1384
1734
  type: NgModule,
1385
1735
  args: [{
1386
- declarations: [ElementRendererComponent],
1387
- exports: [ElementRendererComponent],
1736
+ declarations: [FederatedComponent],
1737
+ imports: [CommonModule, LoaderModule],
1738
+ exports: [FederatedComponent],
1388
1739
  }]
1389
1740
  }] });
1390
1741
 
1391
- class ElementChildrenModule {
1742
+ class CompilationService {
1743
+ constructor(compiler) {
1744
+ this.compiler = compiler;
1745
+ }
1746
+ compileUIDefinition$(uiDefinition) {
1747
+ return of([]).pipe(switchMap(() => {
1748
+ const { children, pages, components } = uiDefinition, uiDefinitionMeta = __rest(uiDefinition, ["children", "pages", "components"]);
1749
+ this.uiDefinitionMeta = uiDefinitionMeta;
1750
+ const elements = [...(children !== null && children !== void 0 ? children : []), ...(pages !== null && pages !== void 0 ? pages : [])];
1751
+ const sharedElements = components !== null && components !== void 0 ? components : [];
1752
+ const metadata = elements.map(element => elementToMetadata(element));
1753
+ const sharedMetadata = sharedElements.map(element => elementToMetadata(element));
1754
+ this.elementsResolver = new ElementsResolver(uiDefinition, metadata, sharedMetadata);
1755
+ const module = this.getModule(this.elementsResolver.getNgComponents());
1756
+ return combineLatest([
1757
+ from(this.compiler.compileModuleAndAllComponentsAsync(module)),
1758
+ of(this.elementsResolver),
1759
+ ]);
1760
+ }), map(([module, elementsResolver]) => ({ module, elements: elementsResolver.elements })));
1761
+ }
1762
+ compileElement$(element) {
1763
+ if (!this.uiDefinitionMeta) {
1764
+ throw 'No UI Definition context';
1765
+ }
1766
+ return of(this.uiDefinitionMeta).pipe(switchMap(uiDefinition => {
1767
+ var _a;
1768
+ const elementsResolver = (_a = this.elementsResolver) !== null && _a !== void 0 ? _a : new ElementsResolver(uiDefinition, []);
1769
+ elementsResolver.addElement(element);
1770
+ const module = this.getModule(elementsResolver.getNgComponents());
1771
+ return combineLatest([from(this.compiler.compileModuleAndAllComponentsAsync(module)), of(elementsResolver)]);
1772
+ }), map(([module, elementsResolver]) => ({ module, elements: elementsResolver.elements })));
1773
+ }
1774
+ clearModuleCache(modules) {
1775
+ modules.forEach(module => this.compiler.clearCacheFor(module));
1776
+ this.uiDefinitionMeta = undefined;
1777
+ }
1778
+ getModule(components) {
1779
+ const staticComponents = [
1780
+ ElementChildrenComponent,
1781
+ ElementRendererComponent,
1782
+ ElementDropHandleComponent,
1783
+ CustomTemplateDirective,
1784
+ ];
1785
+ let DynamicModule = class DynamicModule {
1786
+ };
1787
+ DynamicModule = __decorate([
1788
+ NgModule({
1789
+ imports: [
1790
+ CommonModule,
1791
+ FormsModule,
1792
+ ReactiveFormsModule,
1793
+ FederatedModule,
1794
+ DragDropModule,
1795
+ DndModule,
1796
+ ScrollingModule,
1797
+ ],
1798
+ declarations: [...staticComponents, ...components],
1799
+ jit: true,
1800
+ })
1801
+ ], DynamicModule);
1802
+ return DynamicModule;
1803
+ }
1804
+ }
1805
+ CompilationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: CompilationService, deps: [{ token: i0.Compiler }], target: i0.ɵɵFactoryTarget.Injectable });
1806
+ CompilationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: CompilationService });
1807
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: CompilationService, decorators: [{
1808
+ type: Injectable
1809
+ }], ctorParameters: function () { return [{ type: i0.Compiler }]; } });
1810
+
1811
+ class RuntimeModule {
1392
1812
  }
1393
- ElementChildrenModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementChildrenModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1394
- ElementChildrenModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementChildrenModule, declarations: [ElementChildrenComponent], imports: [ElementRendererModule], exports: [ElementChildrenComponent] });
1395
- ElementChildrenModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementChildrenModule, imports: [[ElementRendererModule]] });
1396
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementChildrenModule, decorators: [{
1813
+ RuntimeModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1814
+ RuntimeModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeModule, imports: [CommonModule, CoreModule] });
1815
+ RuntimeModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeModule, providers: [
1816
+ DialogService,
1817
+ RuntimeService,
1818
+ RuntimeEditorService,
1819
+ { provide: CMS_COMPILATION_SERVICE, useClass: CompilationService },
1820
+ ], imports: [[CommonModule, CoreModule]] });
1821
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeModule, decorators: [{
1397
1822
  type: NgModule,
1398
1823
  args: [{
1399
- declarations: [ElementChildrenComponent],
1400
- imports: [ElementRendererModule],
1401
- exports: [ElementChildrenComponent],
1824
+ imports: [CommonModule, CoreModule],
1825
+ providers: [
1826
+ DialogService,
1827
+ RuntimeService,
1828
+ RuntimeEditorService,
1829
+ { provide: CMS_COMPILATION_SERVICE, useClass: CompilationService },
1830
+ ],
1402
1831
  }]
1403
1832
  }] });
1404
1833
 
1405
- class PreviewModule {
1834
+ class LauncherModule {
1406
1835
  }
1407
- PreviewModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreviewModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1408
- PreviewModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreviewModule, declarations: [PreviewComponent], imports: [CommonModule, LoaderModule, ElementRendererModule, ElementChildrenModule], exports: [PreviewComponent] });
1409
- PreviewModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreviewModule, providers: [IntegrationState], imports: [[CommonModule, LoaderModule, ElementRendererModule, ElementChildrenModule]] });
1410
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreviewModule, decorators: [{
1836
+ LauncherModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LauncherModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1837
+ LauncherModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LauncherModule, imports: [CommonModule, CoreModule, ApiModule, SdkCoreModule, RuntimeModule, PreviewModule], exports: [PreviewModule] });
1838
+ LauncherModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LauncherModule, providers: [IntegrationState, DialogService], imports: [[CommonModule, CoreModule, ApiModule, SdkCoreModule, RuntimeModule, PreviewModule], PreviewModule] });
1839
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LauncherModule, decorators: [{
1411
1840
  type: NgModule,
1412
1841
  args: [{
1413
- declarations: [PreviewComponent],
1414
- imports: [CommonModule, LoaderModule, ElementRendererModule, ElementChildrenModule],
1415
- providers: [IntegrationState],
1416
- exports: [PreviewComponent],
1842
+ imports: [CommonModule, CoreModule, ApiModule, SdkCoreModule, RuntimeModule, PreviewModule],
1843
+ providers: [IntegrationState, DialogService],
1844
+ exports: [PreviewModule],
1417
1845
  }]
1418
1846
  }] });
1419
1847
 
1420
- function ElementDefinition(definition) {
1421
- return function (constructor) {
1422
- return constructor;
1423
- };
1848
+ const migrations = {
1849
+ 2: () => {
1850
+ throw 'Migration from Legacy UI definition is not possible';
1851
+ },
1852
+ 3: uiDef => {
1853
+ var _a;
1854
+ const children = (_a = uiDef.children) !== null && _a !== void 0 ? _a : [];
1855
+ return Object.assign(Object.assign({}, uiDef), { children: undefined, pages: children, version: 3 });
1856
+ },
1857
+ };
1858
+
1859
+ class MigrationsService {
1860
+ constructor(toastService) {
1861
+ this.toastService = toastService;
1862
+ }
1863
+ migrateUIDefinition(uiDef) {
1864
+ const currentVersion = uiDef.version;
1865
+ const targetVersion = UI_DEFINITION_VERSION;
1866
+ const migrateVersions = Object.keys(migrations)
1867
+ .reduce((acc, version) => {
1868
+ const v = Number(version);
1869
+ if (v > currentVersion && v <= targetVersion) {
1870
+ acc.push(v);
1871
+ }
1872
+ return acc;
1873
+ }, [])
1874
+ .sort();
1875
+ try {
1876
+ let result = cloneDeep(uiDef);
1877
+ for (const version of migrateVersions) {
1878
+ result = migrations[version](result);
1879
+ }
1880
+ return result;
1881
+ }
1882
+ catch (e) {
1883
+ this.toastService.add({ summary: String(e), severity: ToastType.error });
1884
+ return;
1885
+ }
1886
+ }
1424
1887
  }
1888
+ MigrationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsService, deps: [{ token: i1.ToastService }], target: i0.ɵɵFactoryTarget.Injectable });
1889
+ MigrationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsService, providedIn: 'root' });
1890
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsService, decorators: [{
1891
+ type: Injectable,
1892
+ args: [{ providedIn: 'root' }]
1893
+ }], ctorParameters: function () { return [{ type: i1.ToastService }]; } });
1425
1894
 
1426
- class LauncherModule {
1895
+ class MigrationsModule {
1427
1896
  }
1428
- LauncherModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LauncherModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1429
- LauncherModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LauncherModule, imports: [CommonModule, CoreModule, ApiModule, SdkCoreModule] });
1430
- LauncherModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LauncherModule, providers: [LauncherService, IntegrationState, DynamicModuleService, DialogService], imports: [[CommonModule, CoreModule, ApiModule, SdkCoreModule]] });
1431
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LauncherModule, decorators: [{
1897
+ MigrationsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1898
+ MigrationsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsModule });
1899
+ MigrationsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsModule, providers: [MigrationsService] });
1900
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsModule, decorators: [{
1432
1901
  type: NgModule,
1433
1902
  args: [{
1434
- imports: [CommonModule, CoreModule, ApiModule, SdkCoreModule],
1435
- providers: [LauncherService, IntegrationState, DynamicModuleService, DialogService],
1903
+ providers: [MigrationsService],
1436
1904
  }]
1437
1905
  }] });
1438
1906
 
@@ -1440,5 +1908,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
1440
1908
  * Generated bundle index. Do not edit.
1441
1909
  */
1442
1910
 
1443
- export { ApplyProductConfigurationAction, CloseDocGenAction, ConfigureProductAction, DEFAULT_PLUGINS_TOKEN, ELEMENT_CONFIG, ELEMENT_METADATA, ElementComponent, ElementDefinition, ElementsResolver, FlowAction, IntegrationState, LauncherModule, LauncherService, NavigateBackAction, NavigateToCatalogAction, OpenDocGenAction, PreviewComponent, PreviewModule, RemoteApplyAction, RemoteCancelAction, SHARED_ELEMENT_METADATA, SetDefaultMetrics, SwitchObjectAction, TemplatesService, UI_DEFINITION_METADATA, UiBuildError, VENDOR_MAP, doesElementSupportIO, elementToMetadata, extendElementMetadata, extractElementMetadata, findElementByModule, flattenElements, getAbsolutePath, getElementConfig, isSharedElement, isValidScript, metadataToElement, normalizeElementMetadata, parseBoundPath, parsePath, stringifyElementMetadata };
1911
+ export { ApplyProductConfigurationAction, CloseDocGenAction, ConfigureProductAction, DEFAULT_PLUGINS_TOKEN, ELEMENT_CONFIG, ELEMENT_METADATA, ElementComponent, ElementDefinition, ElementsResolver, FlowAction, IntegrationState, LauncherModule, MigrationsModule, MigrationsService, NavigateBackAction, NavigateToCatalogAction, OpenDocGenAction, PreviewComponent, PreviewModule, RemoteApplyAction, RemoteCancelAction, RuntimeEditorService, RuntimeModule, SHARED_ELEMENT_METADATA, SetDefaultMetrics, SwitchObjectAction, TemplatesService, UI_DEFINITION_METADATA, UiBuildError, VENDOR_MAP, doesElementSupportIO, elementToMetadata, extendElementMetadata, extractElementMetadata, findElementByModule, findElementByPath, flattenElements, getAbsolutePath, getElementConfig, getElementUniqueName, insertElement, isSharedElement, isValidScript, metadataToElement, normalizeElementMetadata, parseBoundPath, parsePath, removeElement, stringifyElementMetadata };
1444
1912
  //# sourceMappingURL=veloceapps-sdk-cms.js.map