@veloceapps/sdk 6.0.0-6 → 6.0.0-60
Sign up to get free protection for your applications and to get access to all the features.
- package/bundles/veloceapps-sdk-cms.umd.js +1248 -823
- package/bundles/veloceapps-sdk-cms.umd.js.map +1 -1
- package/bundles/veloceapps-sdk-core.umd.js +803 -696
- package/bundles/veloceapps-sdk-core.umd.js.map +1 -1
- package/bundles/veloceapps-sdk-runtime.umd.js +209 -142
- package/bundles/veloceapps-sdk-runtime.umd.js.map +1 -1
- package/bundles/veloceapps-sdk.umd.js +371 -299
- package/bundles/veloceapps-sdk.umd.js.map +1 -1
- package/cms/components/element-children/element-children.component.d.ts +13 -3
- package/cms/components/element-children/element-children.module.d.ts +4 -2
- package/cms/components/element-drop-handle/element-drop-handle.component.d.ts +12 -0
- package/cms/components/element-drop-handle/element-drop-handle.module.d.ts +9 -0
- package/cms/components/element-renderer/element-renderer.component.d.ts +3 -3
- package/cms/components/preview/index.d.ts +1 -0
- package/cms/components/preview/preview.component.d.ts +9 -8
- package/cms/components/preview/preview.module.d.ts +2 -1
- package/cms/components/preview/preview.types.d.ts +11 -0
- package/cms/index.d.ts +2 -0
- package/cms/launcher.module.d.ts +3 -1
- package/cms/modules/migrations/index.d.ts +2 -0
- package/cms/modules/migrations/migrations.d.ts +2 -0
- package/cms/modules/migrations/migrations.module.d.ts +6 -0
- package/cms/modules/migrations/services/migrations.service.d.ts +10 -0
- package/cms/modules/migrations/types/migrations.types.d.ts +2 -0
- package/cms/modules/runtime/index.d.ts +2 -0
- package/cms/modules/runtime/runtime.module.d.ts +8 -0
- package/cms/modules/runtime/services/compilation.service.d.ts +18 -0
- package/cms/modules/runtime/services/runtime-editor.service.d.ts +18 -0
- package/cms/modules/runtime/services/runtime.service.d.ts +27 -0
- package/cms/modules/runtime/tokens.d.ts +3 -0
- package/cms/{types → modules/runtime/types}/compilation.types.d.ts +1 -1
- package/cms/modules/runtime/types/runtime.actions.d.ts +9 -0
- package/cms/services/index.d.ts +0 -1
- package/cms/services/io-provider.service.d.ts +3 -3
- package/cms/types/common.types.d.ts +1 -1
- package/cms/types/configuration.types.d.ts +1 -0
- package/cms/types/index.d.ts +1 -1
- package/cms/utils/elements-resolver.d.ts +3 -2
- package/cms/utils/index.d.ts +1 -0
- package/cms/utils/path.utils.d.ts +0 -1
- package/cms/utils/ui-definition.utils.d.ts +6 -0
- package/cms/vendor-map.d.ts +40 -25
- package/core/modules/configuration/services/configuration-runtime.service.d.ts +2 -4
- package/core/modules/configuration/services/configuration.service.d.ts +6 -4
- package/core/modules/configuration/types/configuration-runtime.types.d.ts +0 -2
- package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +3 -2
- package/core/services/metric-calculation/metric-calculation.service.d.ts +5 -1
- package/core/services/quote-draft.service.d.ts +2 -2
- package/core/types/index.d.ts +0 -1
- package/core/types/ui-definition.types.d.ts +19 -4
- package/core/utils/index.d.ts +1 -0
- package/core/utils/line-item.utils.d.ts +2 -0
- package/core/utils/ui-definition.utils.d.ts +2 -0
- package/esm2015/cms/components/element-children/element-children.component.js +24 -8
- package/esm2015/cms/components/element-children/element-children.module.js +8 -6
- package/esm2015/cms/components/element-drop-handle/element-drop-handle.component.js +32 -0
- package/esm2015/cms/components/element-drop-handle/element-drop-handle.module.js +19 -0
- package/esm2015/cms/components/element-renderer/element-renderer.component.js +9 -9
- package/esm2015/cms/components/element-renderer/element-renderer.module.js +4 -4
- package/esm2015/cms/components/plugin.component.js +3 -3
- package/esm2015/cms/components/preview/index.js +2 -1
- package/esm2015/cms/components/preview/preview.component.js +21 -36
- package/esm2015/cms/components/preview/preview.module.js +7 -6
- package/esm2015/cms/components/preview/preview.types.js +2 -0
- package/esm2015/cms/directives/custom-template.directive.js +3 -3
- package/esm2015/cms/index.js +3 -1
- package/esm2015/cms/launcher.module.js +10 -9
- package/esm2015/cms/modules/federated/federated.component.js +3 -3
- package/esm2015/cms/modules/federated/federated.module.js +4 -4
- package/esm2015/cms/modules/migrations/index.js +3 -0
- package/esm2015/cms/modules/migrations/migrations.js +11 -0
- package/esm2015/cms/modules/migrations/migrations.module.js +15 -0
- package/esm2015/cms/modules/migrations/services/migrations.service.js +43 -0
- package/esm2015/cms/modules/migrations/types/migrations.types.js +2 -0
- package/esm2015/cms/modules/runtime/index.js +3 -0
- package/esm2015/cms/modules/runtime/runtime.module.js +32 -0
- package/esm2015/cms/modules/runtime/services/compilation.service.js +84 -0
- package/esm2015/cms/modules/runtime/services/runtime-editor.service.js +27 -0
- package/esm2015/cms/modules/runtime/services/runtime.service.js +74 -0
- package/esm2015/cms/modules/runtime/tokens.js +3 -0
- package/esm2015/cms/modules/runtime/types/compilation.types.js +2 -0
- package/esm2015/cms/modules/runtime/types/runtime.actions.js +2 -0
- package/esm2015/cms/plugins/configuration.plugin.js +12 -4
- package/esm2015/cms/plugins/io.plugin.js +3 -3
- package/esm2015/cms/plugins/script.plugin.js +3 -3
- package/esm2015/cms/services/element-context.service.js +3 -3
- package/esm2015/cms/services/index.js +1 -2
- package/esm2015/cms/services/integration.state.js +3 -3
- package/esm2015/cms/services/io-provider.service.js +9 -9
- package/esm2015/cms/services/templates.service.js +3 -3
- package/esm2015/cms/types/common.types.js +1 -1
- package/esm2015/cms/types/configuration.types.js +1 -1
- package/esm2015/cms/types/index.js +2 -2
- package/esm2015/cms/utils/elements-resolver.js +18 -8
- package/esm2015/cms/utils/index.js +2 -1
- package/esm2015/cms/utils/path.utils.js +2 -13
- package/esm2015/cms/utils/ui-definition.utils.js +82 -0
- package/esm2015/cms/vendor-map.js +21 -10
- package/esm2015/core/core.module.js +4 -4
- package/esm2015/core/modules/configuration/configuration.module.js +4 -4
- package/esm2015/core/modules/configuration/services/configuration-runtime.service.js +5 -10
- package/esm2015/core/modules/configuration/services/configuration.service.js +27 -24
- package/esm2015/core/modules/configuration/services/runtime-context.service.js +3 -3
- package/esm2015/core/modules/configuration/types/configuration-runtime.types.js +1 -1
- package/esm2015/core/modules/flow-configuration/flow-configuration.module.js +4 -4
- package/esm2015/core/modules/flow-configuration/services/flow-configuration.service.js +10 -9
- package/esm2015/core/modules/flow-configuration/services/flow-update.service.js +3 -3
- package/esm2015/core/services/context.service.js +3 -3
- package/esm2015/core/services/metric-calculation/metric-calculation.service.js +18 -9
- package/esm2015/core/services/product-images.service.js +3 -3
- package/esm2015/core/services/quote-draft.service.js +7 -7
- package/esm2015/core/types/index.js +1 -2
- package/esm2015/core/types/ui-definition.types.js +2 -2
- package/esm2015/core/utils/index.js +2 -1
- package/esm2015/core/utils/line-item.utils.js +27 -11
- package/esm2015/core/utils/ui-definition.utils.js +9 -0
- package/esm2015/runtime/components/component-preview/component-preview.component.js +4 -4
- package/esm2015/runtime/components/section-renderer/section-renderer.component.js +3 -3
- package/esm2015/runtime/components/ui-runtime/runtime.component.js +3 -3
- package/esm2015/runtime/components/ui-runtime-preview/runtime-preview.component.js +3 -3
- package/esm2015/runtime/execution/components/children-placeholder/children-placeholder.component.js +6 -6
- package/esm2015/runtime/execution/components/context-provider/context-provider.component.js +3 -3
- package/esm2015/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.js +3 -3
- package/esm2015/runtime/execution/components/federated/federated.component.js +3 -3
- package/esm2015/runtime/execution/components/velo-attribute/velo-attribute.component.js +3 -3
- package/esm2015/runtime/execution/components/velo-multiselect/velo-multiselect.component.js +3 -3
- package/esm2015/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.js +3 -3
- package/esm2015/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.js +3 -3
- package/esm2015/runtime/execution/components/velo-port-radio/velo-port-radio.component.js +3 -3
- package/esm2015/runtime/execution/components/velo-type/velo-type.component.js +3 -3
- package/esm2015/runtime/execution/directives/section-script.directive.js +3 -3
- package/esm2015/runtime/execution/directives/sf-query.directive.js +3 -3
- package/esm2015/runtime/execution/directives/velo-attribute.directive.js +3 -3
- package/esm2015/runtime/execution/directives/velo-port.directive.js +18 -18
- package/esm2015/runtime/execution/directives/vl-approval.directive.js +3 -3
- package/esm2015/runtime/execution/directives/vl-document-attachments.directive.js +3 -3
- package/esm2015/runtime/execution/directives/vl-document-templates.directive.js +3 -3
- package/esm2015/runtime/execution/directives/vl-quote.directive.js +4 -4
- package/esm2015/runtime/execution/directives/vl-ramp.directive.js +3 -3
- package/esm2015/runtime/execution/runtime-execution.module.js +4 -4
- package/esm2015/runtime/runtime.module.js +4 -4
- package/esm2015/runtime/services/cart.service.js +3 -3
- package/esm2015/runtime/services/collapsible-state.service.js +3 -3
- package/esm2015/runtime/services/configuration.service.js +4 -4
- package/esm2015/runtime/services/current-state.service.js +3 -3
- package/esm2015/runtime/services/form-scope.service.js +3 -3
- package/esm2015/runtime/services/product-model-cache.service.js +3 -3
- package/esm2015/runtime/services/runtime-context.service.js +3 -3
- package/esm2015/runtime/services/runtime-form.service.js +3 -3
- package/esm2015/runtime/services/runtime.service.js +4 -4
- package/esm2015/runtime/services/section-helper.service.js +3 -3
- package/esm2015/runtime/services/section-scope.service.js +3 -3
- package/esm2015/runtime/services/section-store.service.js +3 -3
- package/esm2015/runtime/services/section.service.js +6 -6
- package/esm2015/runtime/types/index.js +2 -1
- package/esm2015/runtime/types/quote-states.types.js +2 -0
- package/esm2015/src/components/dialog/dialog.component.js +3 -3
- package/esm2015/src/components/dialog/dialog.module.js +4 -4
- package/esm2015/src/components/doc-gen/doc-gen.component.js +3 -3
- package/esm2015/src/components/doc-gen/doc-gen.module.js +4 -4
- package/esm2015/src/components/header/cart-overlay/cart-preview.component.js +3 -3
- package/esm2015/src/components/header/cart-overlay/cart-preview.module.js +4 -4
- package/esm2015/src/components/header/header.component.js +20 -12
- package/esm2015/src/components/header/header.module.js +4 -4
- package/esm2015/src/components/header/metrics/metrics.component.js +79 -67
- package/esm2015/src/components/header/metrics/metrics.definitions.js +1 -8
- package/esm2015/src/components/header/metrics/metrics.module.js +4 -4
- package/esm2015/src/flow-routing.module.js +4 -4
- package/esm2015/src/flow.component.js +3 -3
- package/esm2015/src/flow.module.js +4 -4
- package/esm2015/src/guards/context.guard.js +3 -3
- package/esm2015/src/guards/product-unload.guard.js +3 -3
- package/esm2015/src/guards/root.guard.js +3 -3
- package/esm2015/src/pages/catalog/catalog.component.js +3 -3
- package/esm2015/src/pages/catalog/catalog.module.js +4 -4
- package/esm2015/src/pages/debug/debug.component.js +3 -3
- package/esm2015/src/pages/debug/debug.module.js +4 -4
- package/esm2015/src/pages/empty-account/empty-account.component.js +3 -3
- package/esm2015/src/pages/empty-account/empty-account.module.js +4 -4
- package/esm2015/src/pages/legacy-product/legacy-product.component.js +4 -4
- package/esm2015/src/pages/legacy-product/legacy-product.module.js +4 -4
- package/esm2015/src/pages/product/product.component.js +5 -12
- package/esm2015/src/pages/product/product.module.js +4 -4
- package/esm2015/src/pages/record-not-found/record-not-found.component.js +3 -3
- package/esm2015/src/pages/record-not-found/record-not-found.module.js +4 -4
- package/esm2015/src/pages/remote/remote.component.js +5 -8
- package/esm2015/src/pages/remote/remote.module.js +4 -4
- package/esm2015/src/pages/shopping-cart/shopping-cart.component.js +3 -3
- package/esm2015/src/pages/shopping-cart/shopping-cart.module.js +4 -4
- package/esm2015/src/resolvers/flow.resolver.js +3 -3
- package/esm2015/src/resolvers/quote.resolver.js +8 -8
- package/esm2015/src/services/doc-gen.service.js +3 -3
- package/esm2015/src/services/flow-dialog.service.js +3 -3
- package/esm2015/src/services/flow-router.service.js +3 -3
- package/esm2015/src/services/flow.service.js +3 -3
- package/esm2015/src/utils/flow.utils.js +3 -3
- package/fesm2015/veloceapps-sdk-cms.js +1041 -731
- package/fesm2015/veloceapps-sdk-cms.js.map +1 -1
- package/fesm2015/veloceapps-sdk-core.js +554 -521
- package/fesm2015/veloceapps-sdk-core.js.map +1 -1
- package/fesm2015/veloceapps-sdk-runtime.js +138 -138
- package/fesm2015/veloceapps-sdk-runtime.js.map +1 -1
- package/fesm2015/veloceapps-sdk.js +256 -252
- package/fesm2015/veloceapps-sdk.js.map +1 -1
- package/package.json +5 -3
- package/runtime/services/configuration.service.d.ts +2 -1
- package/runtime/services/runtime.service.d.ts +2 -1
- package/runtime/types/index.d.ts +1 -0
- package/src/components/header/header.component.d.ts +4 -2
- package/src/components/header/metrics/metrics.component.d.ts +15 -6
- package/src/components/header/metrics/metrics.definitions.d.ts +0 -3
- package/src/pages/product/product.component.d.ts +0 -1
- package/cms/services/dynamic-module.service.d.ts +0 -15
- package/cms/services/launcher.service.d.ts +0 -18
- package/esm2015/cms/services/dynamic-module.service.js +0 -33
- package/esm2015/cms/services/launcher.service.js +0 -58
- package/esm2015/cms/types/compilation.types.js +0 -2
- package/esm2015/core/types/quote-states.types.js +0 -2
- /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,
|
3
|
+
import { InjectionToken, Component, ChangeDetectionStrategy, Inject, Injector, Injectable, ViewContainerRef, SkipSelf, ViewChild, Input, ViewEncapsulation, NgModule, Directive } from '@angular/core';
|
4
4
|
import * as rxjs from 'rxjs';
|
5
|
-
import { BehaviorSubject, Subject,
|
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,
|
7
|
+
import { compact, isArray, pull, 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 {
|
10
|
-
import
|
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
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
this.
|
232
|
-
|
233
|
-
|
234
|
-
|
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
|
-
|
237
|
-
return this.
|
339
|
+
getCompiledElement$(path) {
|
340
|
+
return this.updated$.pipe(startWith(undefined), map(() => findElementByPath(this.applicationTree, path)), distinctUntilChanged());
|
238
341
|
}
|
239
|
-
|
240
|
-
|
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
|
-
|
243
|
-
this.
|
355
|
+
deleteElement(operation) {
|
356
|
+
applyPatch(this.applicationTree, [operation]);
|
244
357
|
}
|
245
|
-
|
246
|
-
this.
|
247
|
-
this.componentFactories = [];
|
358
|
+
addComponentFactories(list) {
|
359
|
+
list.forEach(item => (this.componentFactories[item.componentType.path] = item));
|
248
360
|
}
|
249
361
|
}
|
250
|
-
|
251
|
-
|
252
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
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(
|
258
|
-
this.
|
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.
|
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.
|
297
|
-
IOProviderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
298
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
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:
|
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.
|
325
|
-
TemplatesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
326
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
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
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
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
|
-
|
357
|
-
|
358
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
359
|
-
type:
|
360
|
-
|
472
|
+
IntegrationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IntegrationState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
473
|
+
IntegrationState.ɵprov = 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
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
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
|
-
|
391
|
-
|
392
|
-
|
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
|
-
|
396
|
-
|
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
|
-
|
406
|
-
|
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
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
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.
|
753
|
-
ElementRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.
|
754
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
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,32 +635,238 @@ 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:
|
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
|
773
|
-
constructor(
|
774
|
-
this.
|
775
|
-
this.
|
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
|
-
|
779
|
-
|
780
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
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
|
-
|
784
|
-
|
785
|
-
|
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:
|
790
|
-
|
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
|
+
|
791
870
|
// eslint-disable-next-line @angular-eslint/directive-selector
|
792
871
|
class CustomTemplateDirective {
|
793
872
|
constructor(templateRef, templatesService) {
|
@@ -801,144 +880,290 @@ 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.
|
805
|
-
CustomTemplateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.
|
806
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
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
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
892
|
+
class IOPlugin {
|
893
|
+
constructor(host) {
|
894
|
+
var _a, _b;
|
895
|
+
this.host = host;
|
896
|
+
const elementMetadata = this.host.injector.get(ELEMENT_METADATA);
|
897
|
+
const inputProvider = this.host.injector.get(IOProviderService);
|
898
|
+
const inputs = Object.entries((_a = elementMetadata.inputs) !== null && _a !== void 0 ? _a : {});
|
899
|
+
const outputs = Object.entries((_b = elementMetadata.outputs) !== null && _b !== void 0 ? _b : {});
|
900
|
+
inputs.forEach(([key, path]) => {
|
901
|
+
var _a;
|
902
|
+
if (path && typeof path !== 'string') {
|
903
|
+
console.error(`The value of '${key}' input should be a string`);
|
904
|
+
}
|
905
|
+
if (((_a = elementMetadata.outputs) === null || _a === void 0 ? void 0 : _a[key]) !== undefined) {
|
906
|
+
console.warn(`'${key}' appears both in inputs and outputs. To prevent inconsistent behavior please keep them unique `);
|
907
|
+
}
|
908
|
+
this.host[key] = inputProvider.connect(elementMetadata, key, path);
|
909
|
+
});
|
910
|
+
outputs.forEach(([key, path]) => {
|
911
|
+
if (path && typeof path !== 'string') {
|
912
|
+
console.error(`The value of '${key}' output should be a string`);
|
913
|
+
}
|
914
|
+
this.host[key] = inputProvider.provide(elementMetadata, key, path);
|
915
|
+
});
|
916
|
+
}
|
917
|
+
}
|
918
|
+
IOPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IOPlugin, deps: [{ token: ElementComponent }], target: i0.ɵɵFactoryTarget.Directive });
|
919
|
+
IOPlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: IOPlugin, ngImport: i0 });
|
920
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IOPlugin, decorators: [{
|
921
|
+
type: Directive
|
922
|
+
}], ctorParameters: function () { return [{ type: ElementComponent }]; } });
|
817
923
|
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
924
|
+
class ScriptPlugin {
|
925
|
+
constructor(host) {
|
926
|
+
this.host = host;
|
927
|
+
this.normalizeImports = (script, elementPath) => {
|
928
|
+
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');
|
929
|
+
const result = script.replace(regexp, (match, g1, g2, src) => {
|
930
|
+
const imports = g1
|
931
|
+
.trim()
|
932
|
+
.slice(1, -1)
|
933
|
+
.split(',')
|
934
|
+
.map(item => item.trim());
|
935
|
+
imports.forEach(item => {
|
936
|
+
var _a;
|
937
|
+
if (!((_a = this.vendorMap[src]) === null || _a === void 0 ? void 0 : _a[item])) {
|
938
|
+
throw new Error(`Failed to import ${item} from '${src}' in ${elementPath}/script.ts`);
|
939
|
+
}
|
940
|
+
});
|
941
|
+
return `const ${g1} = vendor['${src}'];`;
|
942
|
+
});
|
943
|
+
return result;
|
944
|
+
};
|
945
|
+
this.document = this.host.injector.get(DOCUMENT);
|
946
|
+
this.vendorMap = this.host.injector.get(VENDOR_MAP);
|
947
|
+
const elementMetadata = this.host.injector.get(ELEMENT_METADATA);
|
948
|
+
const sharedElementMetadata = this.host.injector.get(SHARED_ELEMENT_METADATA);
|
949
|
+
this.addScript(sharedElementMetadata);
|
950
|
+
this.addScript(elementMetadata);
|
951
|
+
}
|
952
|
+
addScript(metadata) {
|
953
|
+
var _a;
|
954
|
+
if (!(metadata === null || metadata === void 0 ? void 0 : metadata.script)) {
|
823
955
|
return;
|
824
956
|
}
|
825
|
-
const
|
826
|
-
script
|
827
|
-
script.
|
828
|
-
script
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
957
|
+
const id = btoa(UUID.UUID());
|
958
|
+
const script = this.document.createElement('script');
|
959
|
+
script.type = `text/javascript`;
|
960
|
+
let scriptContent = this.normalizeImports(metadata.script, (_a = metadata.path) !== null && _a !== void 0 ? _a : metadata.name);
|
961
|
+
const classMatch = /export class (\S+)/.exec(scriptContent);
|
962
|
+
const className = classMatch === null || classMatch === void 0 ? void 0 : classMatch[1];
|
963
|
+
if (!classMatch || !className) {
|
964
|
+
console.error("Script doesn't have exported class");
|
965
|
+
return;
|
966
|
+
}
|
967
|
+
scriptContent = scriptContent.replace(classMatch[0], `class ${className}`);
|
968
|
+
script.text = `var ${id} = function(vendor) {${scriptContent}
|
969
|
+
return ${className}; };`;
|
970
|
+
this.document.body.appendChild(script);
|
971
|
+
const ScriptClass = window[id](this.vendorMap);
|
972
|
+
if (ScriptClass instanceof Object) {
|
973
|
+
this.host.registerPlugin(new ScriptClass(this.host));
|
974
|
+
}
|
975
|
+
this.document.body.removeChild(script);
|
976
|
+
}
|
834
977
|
}
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
978
|
+
ScriptPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ScriptPlugin, deps: [{ token: ElementComponent }], target: i0.ɵɵFactoryTarget.Directive });
|
979
|
+
ScriptPlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: ScriptPlugin, ngImport: i0 });
|
980
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ScriptPlugin, decorators: [{
|
981
|
+
type: Directive
|
982
|
+
}], ctorParameters: function () { return [{ type: ElementComponent }]; } });
|
983
|
+
|
984
|
+
/*
|
985
|
+
* ScriptPlugin must always be the last plugin in the list to make sure user code is running after all pre-initializers.
|
986
|
+
*/
|
987
|
+
const CONFIG = {
|
988
|
+
CUSTOM: {
|
989
|
+
component: ElementComponent,
|
990
|
+
plugins: [IOPlugin, ScriptPlugin],
|
991
|
+
},
|
992
|
+
CONTAINER: {
|
993
|
+
component: ElementComponent,
|
994
|
+
defaultTemplate: '<element-children></element-children>',
|
995
|
+
plugins: [ScriptPlugin],
|
996
|
+
},
|
997
|
+
SERVICE: {
|
998
|
+
component: ElementComponent,
|
999
|
+
plugins: [IOPlugin, ScriptPlugin],
|
1000
|
+
suppressTemplate: true,
|
1001
|
+
suppressStyles: true,
|
1002
|
+
},
|
1003
|
+
REFERENCE: {
|
1004
|
+
component: ElementComponent,
|
1005
|
+
plugins: [IOPlugin, ScriptPlugin],
|
1006
|
+
suppressTemplate: true,
|
1007
|
+
},
|
1008
|
+
};
|
1009
|
+
|
1010
|
+
const EXPORTED_CLASS_REGEX = /export class (\S+)/;
|
1011
|
+
const METADATA_DECORATOR_REGEX = /@ElementDefinition\(([\s\S]+)\)(\n|\r\n|.)*export class/g;
|
1012
|
+
class UiBuildError extends Error {
|
1013
|
+
constructor(message, affectedMetadata) {
|
1014
|
+
super(message);
|
1015
|
+
this.name = this.constructor.name;
|
1016
|
+
this.affectedMetadata = affectedMetadata;
|
1017
|
+
}
|
846
1018
|
}
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
1019
|
+
const elementToMetadata = (el, parentPath) => {
|
1020
|
+
var _a;
|
1021
|
+
const script = el.script && window.atob(el.script);
|
1022
|
+
const template = el.template && window.atob(el.template);
|
1023
|
+
const styles = el.styles && window.atob(el.styles);
|
1024
|
+
const exportedClassName = script && ((_a = EXPORTED_CLASS_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
|
1025
|
+
if (!exportedClassName) {
|
1026
|
+
throw new Error("Script doesn't have exported class");
|
1027
|
+
}
|
1028
|
+
const elementMetadata = extractElementMetadata(script || '');
|
1029
|
+
const path = (parentPath ? parentPath + '/' : '') + elementMetadata.name;
|
1030
|
+
return Object.assign(Object.assign({}, elementMetadata), { path, script: script === null || script === void 0 ? void 0 : script.replace(METADATA_DECORATOR_REGEX, 'export class'), template,
|
1031
|
+
styles, children: el.children.map(child => elementToMetadata(child, path)) });
|
1032
|
+
};
|
1033
|
+
const metadataToElement = (metadata, recursive = true) => {
|
1034
|
+
const elMetadata = {
|
1035
|
+
name: metadata.name,
|
1036
|
+
isShared: metadata.isShared,
|
1037
|
+
type: metadata.type,
|
1038
|
+
model: metadata.model,
|
1039
|
+
module: metadata.module,
|
1040
|
+
reference: metadata.reference,
|
1041
|
+
inputs: metadata.inputs,
|
1042
|
+
outputs: metadata.outputs,
|
1043
|
+
children: metadata.children.map(({ name }) => name),
|
1044
|
+
configuredStyles: metadata.configuredStyles,
|
1045
|
+
};
|
1046
|
+
const normalizedElMetadata = normalizeElementMetadata(elMetadata);
|
1047
|
+
if (!metadata.script || !EXPORTED_CLASS_REGEX.test(metadata.script)) {
|
1048
|
+
throw new UiBuildError(`'${metadata.name}' component script is missing an exported class`, metadata);
|
1049
|
+
}
|
1050
|
+
const script = metadata.script &&
|
1051
|
+
window.btoa(metadata.script.replace(EXPORTED_CLASS_REGEX, `@ElementDefinition(${stringifyElementMetadata(normalizedElMetadata)})\nexport class Script`));
|
1052
|
+
const template = metadata.template && window.btoa(metadata.template);
|
1053
|
+
const styles = metadata.styles && window.btoa(metadata.styles);
|
1054
|
+
return {
|
1055
|
+
script,
|
1056
|
+
template,
|
1057
|
+
styles,
|
1058
|
+
children: recursive ? metadata.children.map(meta => metadataToElement(meta)) : [],
|
1059
|
+
};
|
1060
|
+
};
|
1061
|
+
const normalizeElementMetadata = (elementMetadata) => {
|
1062
|
+
var _a, _b, _c, _d;
|
1063
|
+
const metadata = Object.assign({}, elementMetadata);
|
1064
|
+
// model
|
1065
|
+
const { lineItem, path } = (_a = metadata.model) !== null && _a !== void 0 ? _a : {};
|
1066
|
+
const model = lineItem ? { lineItem } : path ? { path } : undefined;
|
1067
|
+
if (model) {
|
1068
|
+
metadata.model = model;
|
1069
|
+
}
|
1070
|
+
else {
|
1071
|
+
delete metadata.model;
|
1072
|
+
}
|
1073
|
+
// module
|
1074
|
+
if (!metadata.module) {
|
1075
|
+
delete metadata.module;
|
1076
|
+
}
|
1077
|
+
// reference
|
1078
|
+
if (!metadata.reference) {
|
1079
|
+
delete metadata.reference;
|
1080
|
+
}
|
1081
|
+
// inputs
|
1082
|
+
const inputs = Object.entries((_b = metadata.inputs) !== null && _b !== void 0 ? _b : {}).reduce((acc, [key, value]) => {
|
1083
|
+
return Object.assign(Object.assign({}, acc), { [key]: value || null });
|
1084
|
+
}, {});
|
1085
|
+
if (inputs && Object.keys(inputs).length > 0) {
|
1086
|
+
metadata.inputs = inputs;
|
1087
|
+
}
|
1088
|
+
else {
|
1089
|
+
delete metadata.inputs;
|
1090
|
+
}
|
1091
|
+
// outputs
|
1092
|
+
const outputs = Object.entries((_c = metadata.outputs) !== null && _c !== void 0 ? _c : {}).reduce((acc, [key, value]) => {
|
1093
|
+
return Object.assign(Object.assign({}, acc), { [key]: value || null });
|
1094
|
+
}, {});
|
1095
|
+
if (outputs && Object.keys(outputs).length > 0) {
|
1096
|
+
metadata.outputs = outputs;
|
1097
|
+
}
|
1098
|
+
else {
|
1099
|
+
delete metadata.outputs;
|
1100
|
+
}
|
1101
|
+
// children
|
1102
|
+
if (!((_d = metadata.children) === null || _d === void 0 ? void 0 : _d.length)) {
|
1103
|
+
delete metadata.children;
|
1104
|
+
}
|
1105
|
+
// isShared
|
1106
|
+
if (!metadata.isShared) {
|
1107
|
+
delete metadata.isShared;
|
1108
|
+
}
|
1109
|
+
// configuredStyles
|
1110
|
+
if (!metadata.configuredStyles) {
|
1111
|
+
delete metadata.configuredStyles;
|
1112
|
+
}
|
1113
|
+
return metadata;
|
1114
|
+
};
|
1115
|
+
const extractElementMetadata = (script) => {
|
1116
|
+
var _a;
|
1117
|
+
const metadataString = ((_a = METADATA_DECORATOR_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
|
1118
|
+
// need to reset regex last index to prevent null result for next execution
|
1119
|
+
METADATA_DECORATOR_REGEX.lastIndex = 0;
|
1120
|
+
return new Function(`return ${metadataString}`)();
|
1121
|
+
};
|
1122
|
+
const extendElementMetadata = (script, extend) => {
|
1123
|
+
var _a;
|
1124
|
+
const metadataString = ((_a = METADATA_DECORATOR_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
|
1125
|
+
// need to reset regex last index to prevent null result for next execution
|
1126
|
+
METADATA_DECORATOR_REGEX.lastIndex = 0;
|
1127
|
+
if (!metadataString) {
|
1128
|
+
return script;
|
1129
|
+
}
|
1130
|
+
const updated = Object.assign(Object.assign({}, new Function(`return ${metadataString}`)()), extend);
|
1131
|
+
return script.replace(metadataString, stringifyElementMetadata(updated));
|
1132
|
+
};
|
1133
|
+
const getElementConfig = (type) => {
|
1134
|
+
return CONFIG[type];
|
1135
|
+
};
|
1136
|
+
const doesElementSupportIO = (type) => {
|
1137
|
+
var _a, _b;
|
1138
|
+
return (_b = (_a = getElementConfig(type).plugins) === null || _a === void 0 ? void 0 : _a.includes(IOPlugin)) !== null && _b !== void 0 ? _b : false;
|
1139
|
+
};
|
1140
|
+
function stringifyElementMetadata(elementMetadata) {
|
1141
|
+
const cleaned = JSON.stringify(elementMetadata, null, 2);
|
1142
|
+
return cleaned.replace(/^[\t ]*"[^:\n\r]+(?<!\\)":/gm, function (match) {
|
1143
|
+
return match.replace(/"/g, '');
|
851
1144
|
});
|
852
1145
|
}
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
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;
|
864
|
-
}
|
865
|
-
ngOnChanges(changes) {
|
866
|
-
var _a, _b, _c, _d;
|
867
|
-
if (changes.data && this.instance) {
|
868
|
-
this.instance.data = this.data;
|
869
|
-
}
|
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;
|
873
|
-
}
|
1146
|
+
const isValidScript = (script) => {
|
1147
|
+
var _a;
|
1148
|
+
if (!script) {
|
1149
|
+
return false;
|
874
1150
|
}
|
875
|
-
|
876
|
-
|
1151
|
+
const exportedClassName = script && ((_a = EXPORTED_CLASS_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
|
1152
|
+
if (!exportedClassName) {
|
1153
|
+
return false;
|
877
1154
|
}
|
878
|
-
|
879
|
-
|
880
|
-
|
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) {
|
884
|
-
return;
|
885
|
-
}
|
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
|
-
});
|
1155
|
+
const meta = extractElementMetadata(script);
|
1156
|
+
if (!meta.name || !meta.type) {
|
1157
|
+
return false;
|
901
1158
|
}
|
1159
|
+
return true;
|
1160
|
+
};
|
1161
|
+
function flattenElements(elements) {
|
1162
|
+
return flatten(elements.map(el => [el, ...flattenElements(el.children)]));
|
902
1163
|
}
|
903
|
-
|
904
|
-
|
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
|
-
}] } });
|
928
|
-
|
929
|
-
class FederatedModule {
|
1164
|
+
function isSharedElement(el) {
|
1165
|
+
return Boolean(el.isShared) && el.type !== 'REFERENCE';
|
930
1166
|
}
|
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
1167
|
|
943
1168
|
class ConfigurationPlugin {
|
944
1169
|
constructor(host) {
|
@@ -981,7 +1206,15 @@ class ConfigurationPlugin {
|
|
981
1206
|
}
|
982
1207
|
this.configurationService.patch(new LineItemWorker(rootLineItem).remove(this.modelSnapshot.id).li);
|
983
1208
|
};
|
1209
|
+
const updateQty = (qty) => {
|
1210
|
+
const rootLineItem = this.configurationService.getSnapshot();
|
1211
|
+
if (!rootLineItem || !this.modelSnapshot) {
|
1212
|
+
return;
|
1213
|
+
}
|
1214
|
+
this.configurationService.patch(new LineItemWorker(rootLineItem).replace(Object.assign(Object.assign({}, this.modelSnapshot), { qty })).li);
|
1215
|
+
};
|
984
1216
|
this.typeHost.remove = remove;
|
1217
|
+
this.typeHost.updateQty = updateQty;
|
985
1218
|
}
|
986
1219
|
registerPort(name) {
|
987
1220
|
const model$ = this.host.model$;
|
@@ -1016,72 +1249,34 @@ class ConfigurationPlugin {
|
|
1016
1249
|
this.attributeHost.value$ = value$;
|
1017
1250
|
this.attributeHost.patch = patch;
|
1018
1251
|
}
|
1019
|
-
get attributeHost() {
|
1020
|
-
return this.host;
|
1021
|
-
}
|
1022
|
-
get typeHost() {
|
1023
|
-
return this.host;
|
1024
|
-
}
|
1025
|
-
get portHost() {
|
1026
|
-
return this.host;
|
1027
|
-
}
|
1028
|
-
}
|
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: [{
|
1032
|
-
type: Directive
|
1033
|
-
}], ctorParameters: function () { return [{ type: undefined }]; } });
|
1034
|
-
|
1035
|
-
const DEFAULT_PLUGINS = {
|
1036
|
-
CONFIGURATION: [ConfigurationPlugin],
|
1037
|
-
DEFAULT: [],
|
1038
|
-
};
|
1039
|
-
|
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));
|
1252
|
+
get attributeHost() {
|
1253
|
+
return this.host;
|
1061
1254
|
}
|
1062
|
-
|
1063
|
-
return this.
|
1255
|
+
get typeHost() {
|
1256
|
+
return this.host;
|
1064
1257
|
}
|
1065
|
-
|
1066
|
-
this.
|
1067
|
-
this.action$.next(ClearAction);
|
1258
|
+
get portHost() {
|
1259
|
+
return this.host;
|
1068
1260
|
}
|
1069
1261
|
}
|
1070
|
-
|
1071
|
-
|
1072
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1073
|
-
type:
|
1074
|
-
|
1075
|
-
|
1262
|
+
ConfigurationPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ConfigurationPlugin, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
|
1263
|
+
ConfigurationPlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: ConfigurationPlugin, ngImport: i0 });
|
1264
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ConfigurationPlugin, decorators: [{
|
1265
|
+
type: Directive
|
1266
|
+
}], ctorParameters: function () { return [{ type: undefined }]; } });
|
1267
|
+
|
1268
|
+
const DEFAULT_PLUGINS = {
|
1269
|
+
CONFIGURATION: [ConfigurationPlugin],
|
1270
|
+
DEFAULT: [],
|
1271
|
+
};
|
1076
1272
|
|
1077
1273
|
const VELOCE_LIBS = {
|
1078
|
-
'@veloceapps/
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
IntegrationState }),
|
1274
|
+
'@veloceapps/core': {
|
1275
|
+
isDefined,
|
1276
|
+
},
|
1277
|
+
'@veloceapps/components': {
|
1278
|
+
ToastService,
|
1279
|
+
},
|
1085
1280
|
'@veloceapps/api': {
|
1086
1281
|
SalesforceApiService,
|
1087
1282
|
QuoteApiService,
|
@@ -1092,23 +1287,44 @@ const VELOCE_LIBS = {
|
|
1092
1287
|
DeltaApiService,
|
1093
1288
|
PicklistsApiService,
|
1094
1289
|
PriceApiService,
|
1290
|
+
ShoppingCartSettingsApiService,
|
1291
|
+
ConfigurationSettingsApiService,
|
1095
1292
|
},
|
1293
|
+
'@veloceapps/sdk/core': Object.assign({ ConfigurationService,
|
1294
|
+
QuoteDraftService,
|
1295
|
+
FlowConfigurationService,
|
1296
|
+
LineItemWorker,
|
1297
|
+
ProductImagesService,
|
1298
|
+
ContextService }, lineItemUtils),
|
1299
|
+
'@veloceapps/sdk/cms': Object.assign(Object.assign(Object.assign({}, cmsInjectionTokens), cmsActions), { TemplatesService,
|
1300
|
+
IntegrationState }),
|
1096
1301
|
};
|
1097
1302
|
const VELOCE_LIBS_BACKWARDS_COMPATIBLE = Object.entries(VELOCE_LIBS).reduce((trunk, [key, value]) => (Object.assign(Object.assign({}, trunk), { [key.replace('@veloceapps/', '@veloce/')]: value })), {});
|
1098
1303
|
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
1304
|
|
1100
1305
|
class ElementsResolver {
|
1101
|
-
constructor(uiDef, elements) {
|
1306
|
+
constructor(uiDef, elements, sharedElements = []) {
|
1102
1307
|
this.uiDef = uiDef;
|
1103
1308
|
this.renderableElements = [];
|
1104
1309
|
this.sharedElements = [];
|
1105
1310
|
const transpiledElements = this.transpileScripts(elements);
|
1106
|
-
|
1107
|
-
this.
|
1311
|
+
const transpiledSharedElements = this.transpileScripts(sharedElements);
|
1312
|
+
this.sharedElements = this.flattenElements(transpiledElements)
|
1313
|
+
.filter(el => this.isSharedElement(el))
|
1314
|
+
.concat(transpiledSharedElements);
|
1315
|
+
this.elements = transpiledElements.map(el => this.processElementMetadata(el)).filter(isDefined);
|
1316
|
+
this.renderableElements = this.getRenderableElements(this.elements);
|
1317
|
+
}
|
1318
|
+
addElement(element) {
|
1319
|
+
if (element.isShared) {
|
1320
|
+
return;
|
1321
|
+
}
|
1322
|
+
const transpiledElements = this.transpileScripts([element]);
|
1323
|
+
this.elements = transpiledElements.map(el => this.processElementMetadata(el)).filter(isDefined);
|
1108
1324
|
this.renderableElements = this.getRenderableElements(this.elements);
|
1109
1325
|
}
|
1110
1326
|
getNgComponents() {
|
1111
|
-
return this.renderableElements.map(el => this.resolveElement(el)).filter(
|
1327
|
+
return this.renderableElements.map(el => this.resolveElement(el)).filter(isDefined);
|
1112
1328
|
}
|
1113
1329
|
transpile(el) {
|
1114
1330
|
var _a;
|
@@ -1175,9 +1391,7 @@ class ElementsResolver {
|
|
1175
1391
|
}
|
1176
1392
|
finalElement.template = this.resolveElementTemplate(finalElement);
|
1177
1393
|
finalElement.styles = this.resolveElementStyles(finalElement);
|
1178
|
-
return Object.assign(Object.assign({}, finalElement), { children: finalElement.children
|
1179
|
-
.map(child => this.processElementMetadata(child))
|
1180
|
-
.filter(Boolean) });
|
1394
|
+
return Object.assign(Object.assign({}, finalElement), { children: finalElement.children.map(child => this.processElementMetadata(child)).filter(isDefined) });
|
1181
1395
|
}
|
1182
1396
|
getSharedChildren(children, parentPath) {
|
1183
1397
|
return children.map(c => {
|
@@ -1237,202 +1451,298 @@ class ElementsResolver {
|
|
1237
1451
|
}
|
1238
1452
|
}
|
1239
1453
|
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
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;
|
1454
|
+
const defaultOptions = {
|
1455
|
+
suppressLoading: false,
|
1456
|
+
loadingLabel: 'LOADING',
|
1457
|
+
};
|
1458
|
+
|
1459
|
+
const moduleMap = {};
|
1460
|
+
function loadRemoteEntry(remoteEntry) {
|
1461
|
+
return new Promise((resolve, reject) => {
|
1462
|
+
if (moduleMap[remoteEntry]) {
|
1463
|
+
resolve();
|
1464
|
+
return;
|
1262
1465
|
}
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1466
|
+
const script = document.createElement('script');
|
1467
|
+
script.src = remoteEntry;
|
1468
|
+
script.onerror = reject;
|
1469
|
+
script.onload = () => {
|
1470
|
+
moduleMap[remoteEntry] = true;
|
1471
|
+
resolve(); // window is the global namespace
|
1267
1472
|
};
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1473
|
+
document.body.append(script);
|
1474
|
+
});
|
1475
|
+
}
|
1476
|
+
function lookupExposedModule(remoteName, exposedModule) {
|
1477
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1478
|
+
// Initializes the share scope. This fills it with known provided modules from this build and all remotes
|
1479
|
+
yield __webpack_init_sharing__('default');
|
1480
|
+
const container = window[remoteName]; // or get the container somewhere else
|
1481
|
+
// Initialize the container, it may provide shared modules
|
1482
|
+
yield container.init(__webpack_share_scopes__.default);
|
1483
|
+
const factory = yield container.get(exposedModule);
|
1484
|
+
const Module = factory();
|
1485
|
+
return Module;
|
1486
|
+
});
|
1487
|
+
}
|
1488
|
+
function loadRemoteModule(remoteEntry, remoteName, exposedModule) {
|
1489
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1490
|
+
yield loadRemoteEntry(remoteEntry);
|
1491
|
+
return yield lookupExposedModule(remoteName, exposedModule);
|
1492
|
+
});
|
1277
1493
|
}
|
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
1494
|
|
1284
|
-
class
|
1285
|
-
constructor(
|
1286
|
-
this.
|
1287
|
-
this.
|
1288
|
-
this.
|
1289
|
-
this.
|
1290
|
-
this.
|
1291
|
-
|
1292
|
-
this.
|
1293
|
-
this.
|
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();
|
1495
|
+
class FederatedComponent {
|
1496
|
+
constructor(injector, compiler, appRef, renderer) {
|
1497
|
+
this.injector = injector;
|
1498
|
+
this.compiler = compiler;
|
1499
|
+
this.appRef = appRef;
|
1500
|
+
this.renderer = renderer;
|
1501
|
+
this.isLoading$ = new BehaviorSubject(false);
|
1502
|
+
// configs
|
1503
|
+
this.suppressLoading = defaultOptions.suppressLoading;
|
1504
|
+
this.loadingLabel = defaultOptions.loadingLabel;
|
1306
1505
|
}
|
1307
|
-
|
1308
|
-
|
1309
|
-
if (
|
1310
|
-
|
1506
|
+
ngOnChanges(changes) {
|
1507
|
+
var _a, _b, _c, _d;
|
1508
|
+
if (changes.data && this.instance) {
|
1509
|
+
this.instance.data = this.data;
|
1311
1510
|
}
|
1312
|
-
if (
|
1313
|
-
|
1314
|
-
|
1511
|
+
if (changes.options) {
|
1512
|
+
this.suppressLoading = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.suppressLoading) !== null && _b !== void 0 ? _b : defaultOptions.suppressLoading;
|
1513
|
+
this.loadingLabel = (_d = (_c = this.options) === null || _c === void 0 ? void 0 : _c.loadingLabel) !== null && _d !== void 0 ? _d : defaultOptions.loadingLabel;
|
1315
1514
|
}
|
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
1515
|
}
|
1321
|
-
|
1322
|
-
|
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
|
-
}
|
1516
|
+
ngOnInit() {
|
1517
|
+
this.isLoading$.next(true);
|
1333
1518
|
}
|
1334
|
-
|
1335
|
-
|
1519
|
+
ngAfterViewInit() {
|
1520
|
+
var _a, _b, _c, _d, _e, _f;
|
1521
|
+
const remoteEntry = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.remoteEntry) !== null && _b !== void 0 ? _b : this.remoteEntry;
|
1522
|
+
const remoteName = (_d = (_c = this.options) === null || _c === void 0 ? void 0 : _c.remoteName) !== null && _d !== void 0 ? _d : this.remoteName;
|
1523
|
+
const exposedModule = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.exposedModule) !== null && _f !== void 0 ? _f : this.exposedModule;
|
1524
|
+
if (!remoteEntry || !remoteName || !exposedModule) {
|
1336
1525
|
return;
|
1337
1526
|
}
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
this.
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
}), takeUntil(this.destroy$))
|
1354
|
-
.subscribe();
|
1527
|
+
loadRemoteModule(remoteEntry, remoteName, exposedModule).then(federated => {
|
1528
|
+
this.compiler.compileModuleAsync(federated[exposedModule]).then(moduleFactory => {
|
1529
|
+
var _a, _b, _c;
|
1530
|
+
const rootModuleRef = moduleFactory.create(this.injector);
|
1531
|
+
const rootComponentFactory = rootModuleRef.componentFactoryResolver.resolveComponentFactory(federated[exposedModule].rootComponent);
|
1532
|
+
const node = document.createElement('div');
|
1533
|
+
const { instance, hostView } = rootComponentFactory.create(this.injector, [], node);
|
1534
|
+
this.instance = instance;
|
1535
|
+
this.instance.data = this.data;
|
1536
|
+
this.renderer.appendChild((_a = this.moduleHostRef) === null || _a === void 0 ? void 0 : _a.nativeElement, node);
|
1537
|
+
this.appRef.attachView(hostView);
|
1538
|
+
(_c = (_b = this.options) === null || _b === void 0 ? void 0 : _b.onReady) === null || _c === void 0 ? void 0 : _c.call(_b);
|
1539
|
+
this.isLoading$.next(false);
|
1540
|
+
});
|
1541
|
+
});
|
1355
1542
|
}
|
1356
1543
|
}
|
1357
|
-
|
1358
|
-
|
1359
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1544
|
+
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 });
|
1545
|
+
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 });
|
1546
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FederatedComponent, decorators: [{
|
1360
1547
|
type: Component,
|
1361
1548
|
args: [{
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1549
|
+
// eslint-disable-next-line @angular-eslint/component-selector
|
1550
|
+
selector: 'veloce-host-federated',
|
1551
|
+
templateUrl: './federated.component.html',
|
1552
|
+
styleUrls: ['./federated.component.scss'],
|
1365
1553
|
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
1554
|
}]
|
1370
|
-
}], ctorParameters: function () { return [{ type:
|
1555
|
+
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.Compiler }, { type: i0.ApplicationRef }, { type: i0.Renderer2 }]; }, propDecorators: { moduleHostRef: [{
|
1556
|
+
type: ViewChild,
|
1557
|
+
args: ['moduleHost', { static: false }]
|
1558
|
+
}], remoteEntry: [{
|
1371
1559
|
type: Input
|
1372
|
-
}],
|
1560
|
+
}], remoteName: [{
|
1561
|
+
type: Input
|
1562
|
+
}], exposedModule: [{
|
1563
|
+
type: Input
|
1564
|
+
}], data: [{
|
1373
1565
|
type: Input
|
1374
|
-
}],
|
1566
|
+
}], options: [{
|
1375
1567
|
type: Input
|
1376
1568
|
}] } });
|
1377
1569
|
|
1378
|
-
class
|
1570
|
+
class FederatedModule {
|
1379
1571
|
}
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1572
|
+
FederatedModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FederatedModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1573
|
+
FederatedModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FederatedModule, declarations: [FederatedComponent], imports: [CommonModule, LoaderModule], exports: [FederatedComponent] });
|
1574
|
+
FederatedModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FederatedModule, imports: [[CommonModule, LoaderModule]] });
|
1575
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FederatedModule, decorators: [{
|
1384
1576
|
type: NgModule,
|
1385
1577
|
args: [{
|
1386
|
-
declarations: [
|
1387
|
-
|
1578
|
+
declarations: [FederatedComponent],
|
1579
|
+
imports: [CommonModule, LoaderModule],
|
1580
|
+
exports: [FederatedComponent],
|
1388
1581
|
}]
|
1389
1582
|
}] });
|
1390
1583
|
|
1391
|
-
class
|
1584
|
+
class CompilationService {
|
1585
|
+
constructor(compiler) {
|
1586
|
+
this.compiler = compiler;
|
1587
|
+
}
|
1588
|
+
compileUIDefinition$(uiDefinition) {
|
1589
|
+
return of([]).pipe(switchMap(() => {
|
1590
|
+
const { children, pages, components } = uiDefinition, uiDefinitionMeta = __rest(uiDefinition, ["children", "pages", "components"]);
|
1591
|
+
this.uiDefinitionMeta = uiDefinitionMeta;
|
1592
|
+
const elements = [...(children !== null && children !== void 0 ? children : []), ...(pages !== null && pages !== void 0 ? pages : [])];
|
1593
|
+
const sharedElements = components !== null && components !== void 0 ? components : [];
|
1594
|
+
const metadata = elements.map(element => elementToMetadata(element));
|
1595
|
+
const sharedMetadata = sharedElements.map(element => elementToMetadata(element));
|
1596
|
+
this.elementsResolver = new ElementsResolver(uiDefinition, metadata, sharedMetadata);
|
1597
|
+
const module = this.getModule(this.elementsResolver.getNgComponents());
|
1598
|
+
return combineLatest([
|
1599
|
+
from(this.compiler.compileModuleAndAllComponentsAsync(module)),
|
1600
|
+
of(this.elementsResolver),
|
1601
|
+
]);
|
1602
|
+
}), map(([module, elementsResolver]) => ({ module, elements: elementsResolver.elements })));
|
1603
|
+
}
|
1604
|
+
compileElement$(element) {
|
1605
|
+
if (!this.uiDefinitionMeta) {
|
1606
|
+
throw 'No UI Definition context';
|
1607
|
+
}
|
1608
|
+
return of(this.uiDefinitionMeta).pipe(switchMap(uiDefinition => {
|
1609
|
+
var _a;
|
1610
|
+
const elementsResolver = (_a = this.elementsResolver) !== null && _a !== void 0 ? _a : new ElementsResolver(uiDefinition, []);
|
1611
|
+
elementsResolver.addElement(element);
|
1612
|
+
const module = this.getModule(elementsResolver.getNgComponents());
|
1613
|
+
return combineLatest([from(this.compiler.compileModuleAndAllComponentsAsync(module)), of(elementsResolver)]);
|
1614
|
+
}), map(([module, elementsResolver]) => ({ module, elements: elementsResolver.elements })));
|
1615
|
+
}
|
1616
|
+
clearModuleCache(modules) {
|
1617
|
+
modules.forEach(module => this.compiler.clearCacheFor(module));
|
1618
|
+
this.uiDefinitionMeta = undefined;
|
1619
|
+
}
|
1620
|
+
getModule(components) {
|
1621
|
+
const staticComponents = [
|
1622
|
+
ElementChildrenComponent,
|
1623
|
+
ElementRendererComponent,
|
1624
|
+
ElementDropHandleComponent,
|
1625
|
+
CustomTemplateDirective,
|
1626
|
+
];
|
1627
|
+
let DynamicModule = class DynamicModule {
|
1628
|
+
};
|
1629
|
+
DynamicModule = __decorate([
|
1630
|
+
NgModule({
|
1631
|
+
imports: [
|
1632
|
+
CommonModule,
|
1633
|
+
FormsModule,
|
1634
|
+
ReactiveFormsModule,
|
1635
|
+
FederatedModule,
|
1636
|
+
DragDropModule,
|
1637
|
+
DndModule,
|
1638
|
+
ScrollingModule,
|
1639
|
+
],
|
1640
|
+
declarations: [...staticComponents, ...components],
|
1641
|
+
jit: true,
|
1642
|
+
})
|
1643
|
+
], DynamicModule);
|
1644
|
+
return DynamicModule;
|
1645
|
+
}
|
1646
|
+
}
|
1647
|
+
CompilationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: CompilationService, deps: [{ token: i0.Compiler }], target: i0.ɵɵFactoryTarget.Injectable });
|
1648
|
+
CompilationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: CompilationService });
|
1649
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: CompilationService, decorators: [{
|
1650
|
+
type: Injectable
|
1651
|
+
}], ctorParameters: function () { return [{ type: i0.Compiler }]; } });
|
1652
|
+
|
1653
|
+
class RuntimeModule {
|
1392
1654
|
}
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1655
|
+
RuntimeModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1656
|
+
RuntimeModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeModule, imports: [CommonModule, CoreModule] });
|
1657
|
+
RuntimeModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeModule, providers: [
|
1658
|
+
DialogService,
|
1659
|
+
RuntimeService,
|
1660
|
+
RuntimeEditorService,
|
1661
|
+
{ provide: CMS_COMPILATION_SERVICE, useClass: CompilationService },
|
1662
|
+
], imports: [[CommonModule, CoreModule]] });
|
1663
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeModule, decorators: [{
|
1397
1664
|
type: NgModule,
|
1398
1665
|
args: [{
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1666
|
+
imports: [CommonModule, CoreModule],
|
1667
|
+
providers: [
|
1668
|
+
DialogService,
|
1669
|
+
RuntimeService,
|
1670
|
+
RuntimeEditorService,
|
1671
|
+
{ provide: CMS_COMPILATION_SERVICE, useClass: CompilationService },
|
1672
|
+
],
|
1402
1673
|
}]
|
1403
1674
|
}] });
|
1404
1675
|
|
1405
|
-
class
|
1676
|
+
class LauncherModule {
|
1406
1677
|
}
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1678
|
+
LauncherModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LauncherModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1679
|
+
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] });
|
1680
|
+
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] });
|
1681
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LauncherModule, decorators: [{
|
1411
1682
|
type: NgModule,
|
1412
1683
|
args: [{
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
exports: [PreviewComponent],
|
1684
|
+
imports: [CommonModule, CoreModule, ApiModule, SdkCoreModule, RuntimeModule, PreviewModule],
|
1685
|
+
providers: [IntegrationState, DialogService],
|
1686
|
+
exports: [PreviewModule],
|
1417
1687
|
}]
|
1418
1688
|
}] });
|
1419
1689
|
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
}
|
1690
|
+
const migrations = {
|
1691
|
+
2: () => {
|
1692
|
+
throw 'Migration from Legacy UI definition is not possible';
|
1693
|
+
},
|
1694
|
+
3: uiDef => {
|
1695
|
+
var _a;
|
1696
|
+
const children = (_a = uiDef.children) !== null && _a !== void 0 ? _a : [];
|
1697
|
+
return Object.assign(Object.assign({}, uiDef), { children: undefined, pages: children, version: 3 });
|
1698
|
+
},
|
1699
|
+
};
|
1700
|
+
|
1701
|
+
class MigrationsService {
|
1702
|
+
constructor(toastService) {
|
1703
|
+
this.toastService = toastService;
|
1704
|
+
}
|
1705
|
+
migrateUIDefinition(uiDef) {
|
1706
|
+
const currentVersion = uiDef.version;
|
1707
|
+
const targetVersion = UI_DEFINITION_VERSION;
|
1708
|
+
const migrateVersions = Object.keys(migrations)
|
1709
|
+
.reduce((acc, version) => {
|
1710
|
+
const v = Number(version);
|
1711
|
+
if (v > currentVersion && v <= targetVersion) {
|
1712
|
+
acc.push(v);
|
1713
|
+
}
|
1714
|
+
return acc;
|
1715
|
+
}, [])
|
1716
|
+
.sort();
|
1717
|
+
try {
|
1718
|
+
let result = cloneDeep(uiDef);
|
1719
|
+
for (const version of migrateVersions) {
|
1720
|
+
result = migrations[version](result);
|
1721
|
+
}
|
1722
|
+
return result;
|
1723
|
+
}
|
1724
|
+
catch (e) {
|
1725
|
+
this.toastService.add({ summary: String(e), severity: ToastType.error });
|
1726
|
+
return;
|
1727
|
+
}
|
1728
|
+
}
|
1424
1729
|
}
|
1730
|
+
MigrationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsService, deps: [{ token: i1.ToastService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1731
|
+
MigrationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsService, providedIn: 'root' });
|
1732
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsService, decorators: [{
|
1733
|
+
type: Injectable,
|
1734
|
+
args: [{ providedIn: 'root' }]
|
1735
|
+
}], ctorParameters: function () { return [{ type: i1.ToastService }]; } });
|
1425
1736
|
|
1426
|
-
class
|
1737
|
+
class MigrationsModule {
|
1427
1738
|
}
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1739
|
+
MigrationsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1740
|
+
MigrationsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsModule });
|
1741
|
+
MigrationsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsModule, providers: [MigrationsService] });
|
1742
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsModule, decorators: [{
|
1432
1743
|
type: NgModule,
|
1433
1744
|
args: [{
|
1434
|
-
|
1435
|
-
providers: [LauncherService, IntegrationState, DynamicModuleService, DialogService],
|
1745
|
+
providers: [MigrationsService],
|
1436
1746
|
}]
|
1437
1747
|
}] });
|
1438
1748
|
|
@@ -1440,5 +1750,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
1440
1750
|
* Generated bundle index. Do not edit.
|
1441
1751
|
*/
|
1442
1752
|
|
1443
|
-
export { ApplyProductConfigurationAction, CloseDocGenAction, ConfigureProductAction, DEFAULT_PLUGINS_TOKEN, ELEMENT_CONFIG, ELEMENT_METADATA, ElementComponent, ElementDefinition, ElementsResolver, FlowAction, IntegrationState, LauncherModule,
|
1753
|
+
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
1754
|
//# sourceMappingURL=veloceapps-sdk-cms.js.map
|