@veloceapps/sdk 6.0.0-1 → 6.0.0-100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -2
- package/bundles/veloceapps-sdk-cms.umd.js +1270 -798
- package/bundles/veloceapps-sdk-cms.umd.js.map +1 -1
- package/bundles/veloceapps-sdk-core.umd.js +783 -650
- package/bundles/veloceapps-sdk-core.umd.js.map +1 -1
- package/bundles/veloceapps-sdk-runtime.umd.js +216 -150
- package/bundles/veloceapps-sdk-runtime.umd.js.map +1 -1
- package/bundles/veloceapps-sdk.umd.js +574 -309
- package/bundles/veloceapps-sdk.umd.js.map +1 -1
- package/cms/cms.actions.d.ts +2 -4
- 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 +1 -1
- package/cms/services/integration.state.d.ts +2 -3
- package/cms/services/io-provider.service.d.ts +3 -3
- package/cms/services/resources.service.d.ts +10 -0
- 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/types/integration.types.d.ts +5 -0
- 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 +51 -30
- 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 +6 -3
- package/core/modules/flow-configuration/services/flow-update.service.d.ts +3 -2
- package/core/services/context.service.d.ts +1 -0
- 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/cms.actions.js +1 -6
- 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 +11 -10
- 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 +2 -2
- package/esm2015/cms/services/integration.state.js +4 -4
- package/esm2015/cms/services/io-provider.service.js +9 -9
- package/esm2015/cms/services/resources.service.js +50 -0
- 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/types/integration.types.js +1 -1
- 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 +27 -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 +38 -34
- 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 +18 -10
- package/esm2015/core/modules/flow-configuration/services/flow-update.service.js +9 -9
- package/esm2015/core/services/context.service.js +7 -4
- 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 +11 -12
- 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 +16 -6
- package/esm2015/src/components/dialog/dialog.module.js +4 -4
- package/esm2015/src/components/dialog/dialog.types.js +1 -1
- 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 +39 -13
- 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 +18 -5
- 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 +5 -5
- package/esm2015/src/guards/root.guard.js +3 -3
- package/esm2015/src/pages/assets/assets.component.js +117 -0
- package/esm2015/src/pages/assets/assets.module.js +20 -0
- package/esm2015/src/pages/catalog/catalog.component.js +6 -6
- 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 +6 -6
- 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 +17 -12
- package/esm2015/src/services/doc-gen.service.js +3 -3
- package/esm2015/src/services/flow-dialog.service.js +5 -4
- package/esm2015/src/services/flow-router.service.js +12 -4
- package/esm2015/src/services/flow.service.js +12 -5
- package/esm2015/src/types/flow-customization.types.js +1 -1
- package/esm2015/src/utils/flow.utils.js +3 -3
- package/fesm2015/veloceapps-sdk-cms.js +1075 -718
- package/fesm2015/veloceapps-sdk-cms.js.map +1 -1
- package/fesm2015/veloceapps-sdk-core.js +573 -529
- package/fesm2015/veloceapps-sdk-core.js.map +1 -1
- package/fesm2015/veloceapps-sdk-runtime.js +145 -146
- package/fesm2015/veloceapps-sdk-runtime.js.map +1 -1
- package/fesm2015/veloceapps-sdk.js +446 -262
- 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/dialog/dialog.types.d.ts +1 -0
- package/src/components/header/header.component.d.ts +10 -3
- package/src/components/header/metrics/metrics.component.d.ts +15 -6
- package/src/components/header/metrics/metrics.definitions.d.ts +0 -3
- package/src/flow-routing.module.d.ts +4 -3
- package/src/pages/assets/assets.component.d.ts +32 -0
- package/src/pages/assets/assets.module.d.ts +10 -0
- package/src/pages/product/product.component.d.ts +0 -1
- package/src/resolvers/quote.resolver.d.ts +1 -0
- package/src/services/flow-router.service.d.ts +2 -0
- package/src/services/flow.service.d.ts +1 -0
- package/src/types/flow-customization.types.d.ts +1 -0
- 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 -57
- 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,25 +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, ReplaySubject, noop, take, Observable, takeUntil, forkJoin, catchError, 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, Operator, Predicate, parseJsonSafely, 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, GuidedSellingApiService, ApiModule } from '@veloceapps/api';
|
20
|
+
import { DialogService } from 'primeng/dynamicdialog';
|
11
21
|
import { DragDropModule } from '@angular/cdk/drag-drop';
|
22
|
+
import { ScrollingModule } from '@angular/cdk/scrolling';
|
12
23
|
import * as angularForms from '@angular/forms';
|
13
24
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
14
|
-
import * as i2 from '@veloceapps/sdk/core';
|
15
|
-
import { ConfigurationService, LineItemWorker, generateLineItem, getAttributeValue, QuoteDraftService, FlowConfigurationService, ProductImagesService, lineItemUtils, SdkCoreModule } from '@veloceapps/sdk/core';
|
16
|
-
import * as i1 from '@veloceapps/components';
|
17
|
-
import { LoaderModule } from '@veloceapps/components';
|
18
25
|
import { transform } from '@babel/standalone';
|
19
|
-
import { SalesforceApiService, QuoteApiService, DocumentTemplatesApiService, DocumentAttachmentApiService, RampApiService, CatalogApiService, DeltaApiService, PicklistsApiService, PriceApiService, ApiModule } from '@veloceapps/api';
|
20
26
|
import * as rxjsOperators from 'rxjs/operators';
|
21
|
-
import * as i3 from 'primeng/api';
|
22
|
-
import { DialogService } from 'primeng/dynamicdialog';
|
23
27
|
|
24
28
|
var FlowAction;
|
25
29
|
(function (FlowAction) {
|
@@ -32,7 +36,6 @@ var FlowAction;
|
|
32
36
|
FlowAction["FLOW_SWITCH_OBJECT"] = "FLOW_SWITCH_OBJECT";
|
33
37
|
FlowAction["REMOTE_APPLY"] = "REMOTE_APPLY";
|
34
38
|
FlowAction["REMOTE_CANCEL"] = "REMOTE_CANCEL";
|
35
|
-
FlowAction["SET_DEFAULT_METRICS"] = "SET_DEFAULT_METRICS";
|
36
39
|
})(FlowAction || (FlowAction = {}));
|
37
40
|
const ConfigureProductAction = ({ lineItemId, productId, }) => ({
|
38
41
|
type: FlowAction.FLOW_CONFIGURE_PRODUCT,
|
@@ -63,10 +66,6 @@ const SwitchObjectAction = (payload) => ({
|
|
63
66
|
type: FlowAction.FLOW_SWITCH_OBJECT,
|
64
67
|
payload,
|
65
68
|
});
|
66
|
-
const SetDefaultMetrics = (metrics) => ({
|
67
|
-
type: FlowAction.SET_DEFAULT_METRICS,
|
68
|
-
payload: { metrics },
|
69
|
-
});
|
70
69
|
|
71
70
|
var cmsActions = /*#__PURE__*/Object.freeze({
|
72
71
|
__proto__: null,
|
@@ -79,8 +78,7 @@ var cmsActions = /*#__PURE__*/Object.freeze({
|
|
79
78
|
CloseDocGenAction: CloseDocGenAction,
|
80
79
|
RemoteApplyAction: RemoteApplyAction,
|
81
80
|
RemoteCancelAction: RemoteCancelAction,
|
82
|
-
SwitchObjectAction: SwitchObjectAction
|
83
|
-
SetDefaultMetrics: SetDefaultMetrics
|
81
|
+
SwitchObjectAction: SwitchObjectAction
|
84
82
|
});
|
85
83
|
|
86
84
|
const DEFAULT_PLUGINS_TOKEN = new InjectionToken('DEFAULT_PLUGINS_TOKEN');
|
@@ -155,6 +153,88 @@ ElementComponent = __decorate([
|
|
155
153
|
__param(0, Inject(Injector))
|
156
154
|
], ElementComponent);
|
157
155
|
|
156
|
+
function getElementUniqueName(collection, name, comparator) {
|
157
|
+
let result = '';
|
158
|
+
let index = 0;
|
159
|
+
while (!result) {
|
160
|
+
const candidate = name + (index ? ` (${index})` : '');
|
161
|
+
const exists = collection.some(comparator(candidate));
|
162
|
+
if (!exists) {
|
163
|
+
result = candidate;
|
164
|
+
}
|
165
|
+
else {
|
166
|
+
index++;
|
167
|
+
}
|
168
|
+
}
|
169
|
+
return result;
|
170
|
+
}
|
171
|
+
const insertElementAt = (source, target, parentPath, index) => {
|
172
|
+
const result = [...source];
|
173
|
+
const name = getElementUniqueName(result, target.name, (name) => (el) => el.name === name);
|
174
|
+
const path = parentPath ? `${parentPath}/${name}` : name;
|
175
|
+
result.splice(index, 0, Object.assign(Object.assign({}, target), { path, name }));
|
176
|
+
return result;
|
177
|
+
};
|
178
|
+
const insertElement = (source, target, path, index) => {
|
179
|
+
if (!path) {
|
180
|
+
return insertElementAt(source, target, '', index);
|
181
|
+
}
|
182
|
+
return source.map(element => {
|
183
|
+
var _a;
|
184
|
+
if (element.path === path) {
|
185
|
+
return Object.assign(Object.assign({}, element), { children: insertElementAt(element.children, target, element.path, index) });
|
186
|
+
}
|
187
|
+
else if ((_a = element.path) === null || _a === void 0 ? void 0 : _a.startsWith(path)) {
|
188
|
+
return Object.assign(Object.assign({}, element), { children: insertElement(element.children, target, path, index) });
|
189
|
+
}
|
190
|
+
else {
|
191
|
+
return element;
|
192
|
+
}
|
193
|
+
});
|
194
|
+
};
|
195
|
+
const removeElement = (source, path) => {
|
196
|
+
return source.reduce((trunk, element) => {
|
197
|
+
if (path === element.path) {
|
198
|
+
return trunk;
|
199
|
+
}
|
200
|
+
if (element.path) {
|
201
|
+
if (path.startsWith(element.path)) {
|
202
|
+
trunk.push(Object.assign(Object.assign({}, element), { children: removeElement(element.children, path) }));
|
203
|
+
}
|
204
|
+
else {
|
205
|
+
trunk.push(element);
|
206
|
+
}
|
207
|
+
}
|
208
|
+
return trunk;
|
209
|
+
}, []);
|
210
|
+
};
|
211
|
+
const findElementByPath = (source, path) => {
|
212
|
+
for (const el of source) {
|
213
|
+
if (el.path === path) {
|
214
|
+
return el;
|
215
|
+
}
|
216
|
+
if (el.path && path.startsWith(el.path)) {
|
217
|
+
const found = findElementByPath(el.children, path);
|
218
|
+
if (found) {
|
219
|
+
return found;
|
220
|
+
}
|
221
|
+
}
|
222
|
+
}
|
223
|
+
return;
|
224
|
+
};
|
225
|
+
const findElementByModule = (elements, module, elementName) => {
|
226
|
+
for (const el of elements) {
|
227
|
+
if (el.module === module && el.name === elementName) {
|
228
|
+
return el;
|
229
|
+
}
|
230
|
+
const child = findElementByModule(el.children, module, elementName);
|
231
|
+
if (child) {
|
232
|
+
return child;
|
233
|
+
}
|
234
|
+
}
|
235
|
+
return;
|
236
|
+
};
|
237
|
+
|
158
238
|
const parseBoundPath = (path) => {
|
159
239
|
var _a, _b;
|
160
240
|
const regexp = new RegExp(`(?:\\/)(?:\\w+)(?:\\/)(?:ports|attributes)(?:\\/)(?:\\w+)|(?:\\/)(?:\\w+)`, 'g');
|
@@ -187,18 +267,6 @@ const parsePath = (path) => {
|
|
187
267
|
variable,
|
188
268
|
};
|
189
269
|
};
|
190
|
-
const findElementByModule = (elements, module, elementName) => {
|
191
|
-
for (const el of elements) {
|
192
|
-
if (el.module === module && el.name === elementName) {
|
193
|
-
return el;
|
194
|
-
}
|
195
|
-
const child = findElementByModule(el.children, module, elementName);
|
196
|
-
if (child) {
|
197
|
-
return child;
|
198
|
-
}
|
199
|
-
}
|
200
|
-
return;
|
201
|
-
};
|
202
270
|
const getAbsolutePath = (elements, subject, path) => {
|
203
271
|
var _a, _b, _c;
|
204
272
|
if (path.module) {
|
@@ -221,40 +289,79 @@ const getAbsolutePath = (elements, subject, path) => {
|
|
221
289
|
return subjectSegments.join('/');
|
222
290
|
};
|
223
291
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
this.
|
231
|
-
|
232
|
-
|
233
|
-
|
292
|
+
const CMS_COMPILATION_SERVICE = new InjectionToken('VENDOR_MAP');
|
293
|
+
|
294
|
+
class RuntimeService {
|
295
|
+
constructor(injector) {
|
296
|
+
this.injector = injector;
|
297
|
+
this.modules = [];
|
298
|
+
this.componentFactories = {};
|
299
|
+
this.applicationTree = [];
|
300
|
+
this.isInitialized$ = new BehaviorSubject(false);
|
301
|
+
this.updated$ = new Subject();
|
302
|
+
this.compilationService = this.injector.get(CMS_COMPILATION_SERVICE);
|
303
|
+
}
|
304
|
+
initialize$(uiDefinition, config) {
|
305
|
+
this.config = config;
|
306
|
+
if (!uiDefinition) {
|
307
|
+
return of([]);
|
308
|
+
}
|
309
|
+
return this.compilationService.compileUIDefinition$(uiDefinition).pipe(map(result => {
|
310
|
+
this.applicationTree = result.elements;
|
311
|
+
this.addComponentFactories(result.module.componentFactories);
|
312
|
+
return result.elements;
|
313
|
+
}), tap(() => this.isInitialized$.next(true)));
|
314
|
+
}
|
315
|
+
applyPatch$(patch) {
|
316
|
+
let observable$ = of(undefined);
|
317
|
+
patch.forEach(operation => {
|
318
|
+
switch (operation.op) {
|
319
|
+
case 'add': {
|
320
|
+
observable$ = observable$.pipe(switchMap(() => this.addElement$(operation)));
|
321
|
+
break;
|
322
|
+
}
|
323
|
+
case 'remove': {
|
324
|
+
observable$ = observable$.pipe(map(() => this.deleteElement(operation)));
|
325
|
+
break;
|
326
|
+
}
|
327
|
+
default:
|
328
|
+
observable$ = of();
|
329
|
+
}
|
330
|
+
});
|
331
|
+
return observable$.pipe(tap(() => this.updated$.next()));
|
234
332
|
}
|
235
|
-
|
236
|
-
return this.
|
333
|
+
getCompiledElement$(path) {
|
334
|
+
return this.updated$.pipe(startWith(undefined), map(() => findElementByPath(this.applicationTree, path)), distinctUntilChanged());
|
237
335
|
}
|
238
|
-
|
239
|
-
|
336
|
+
clear() {
|
337
|
+
this.compilationService.clearModuleCache(this.modules);
|
338
|
+
this.modules = [];
|
339
|
+
this.applicationTree = [];
|
340
|
+
this.componentFactories = {};
|
341
|
+
this.isInitialized$.next(false);
|
342
|
+
}
|
343
|
+
addElement$(operation) {
|
344
|
+
return this.compilationService.compileElement$(operation.value).pipe(map(result => {
|
345
|
+
this.addComponentFactories(result.module.componentFactories);
|
346
|
+
applyPatch(this.applicationTree, [Object.assign(Object.assign({}, operation), { value: result.elements[0] })]);
|
347
|
+
}));
|
240
348
|
}
|
241
|
-
|
242
|
-
this.
|
349
|
+
deleteElement(operation) {
|
350
|
+
applyPatch(this.applicationTree, [operation]);
|
243
351
|
}
|
244
|
-
|
245
|
-
this.
|
246
|
-
this.componentFactories = [];
|
352
|
+
addComponentFactories(list) {
|
353
|
+
list.forEach(item => (this.componentFactories[item.componentType.path] = item));
|
247
354
|
}
|
248
355
|
}
|
249
|
-
|
250
|
-
|
251
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
356
|
+
RuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeService, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
357
|
+
RuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeService });
|
358
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeService, decorators: [{
|
252
359
|
type: Injectable
|
253
|
-
}] });
|
360
|
+
}], ctorParameters: function () { return [{ type: i0.Injector }]; } });
|
254
361
|
|
255
362
|
class IOProviderService {
|
256
|
-
constructor(
|
257
|
-
this.
|
363
|
+
constructor(runtimeService) {
|
364
|
+
this.runtimeService = runtimeService;
|
258
365
|
this.inputs = {};
|
259
366
|
}
|
260
367
|
connect(el, name, target) {
|
@@ -274,7 +381,7 @@ class IOProviderService {
|
|
274
381
|
const pathIsValue = elPath.segments.length === 1 && elPath.segments[0].startsWith('"') && elPath.segments[0].endsWith('"');
|
275
382
|
const finalName = (_b = elPath.variable) !== null && _b !== void 0 ? _b : name;
|
276
383
|
const value = pathIsValue ? new BehaviorSubject(elPath.segments[0].slice(1, -1)) : undefined;
|
277
|
-
const absolutePath = !pathIsValue ? getAbsolutePath(this.
|
384
|
+
const absolutePath = !pathIsValue ? getAbsolutePath(this.runtimeService.applicationTree, el, elPath) : el.path;
|
278
385
|
return this.createSubjectSafe(absolutePath !== null && absolutePath !== void 0 ? absolutePath : '', finalName, value);
|
279
386
|
}
|
280
387
|
createSubjectSafe(path, name, subject) {
|
@@ -292,11 +399,11 @@ class IOProviderService {
|
|
292
399
|
return this.inputs[path][name];
|
293
400
|
}
|
294
401
|
}
|
295
|
-
IOProviderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
296
|
-
IOProviderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
297
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
402
|
+
IOProviderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IOProviderService, deps: [{ token: RuntimeService }], target: i0.ɵɵFactoryTarget.Injectable });
|
403
|
+
IOProviderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IOProviderService });
|
404
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IOProviderService, decorators: [{
|
298
405
|
type: Injectable
|
299
|
-
}], ctorParameters: function () { return [{ type:
|
406
|
+
}], ctorParameters: function () { return [{ type: RuntimeService }]; } });
|
300
407
|
|
301
408
|
class TemplatesService {
|
302
409
|
constructor() {
|
@@ -320,312 +427,120 @@ class TemplatesService {
|
|
320
427
|
}
|
321
428
|
}
|
322
429
|
}
|
323
|
-
TemplatesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
324
|
-
TemplatesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
325
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
430
|
+
TemplatesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: TemplatesService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
431
|
+
TemplatesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: TemplatesService });
|
432
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: TemplatesService, decorators: [{
|
326
433
|
type: Injectable
|
327
434
|
}] });
|
328
435
|
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
436
|
+
const InitAction = { type: 'INIT' };
|
437
|
+
const ClearAction = { type: 'CLEAR' };
|
438
|
+
class IntegrationState {
|
439
|
+
constructor() {
|
440
|
+
this.stateSubj$ = new BehaviorSubject({});
|
441
|
+
this.action$ = new BehaviorSubject(InitAction);
|
442
|
+
}
|
443
|
+
get state$() {
|
444
|
+
return this.stateSubj$.asObservable();
|
445
|
+
}
|
446
|
+
get state() {
|
447
|
+
return this.stateSubj$.getValue();
|
448
|
+
}
|
449
|
+
patchState(update) {
|
450
|
+
this.stateSubj$.next(Object.assign(Object.assign({}, this.stateSubj$.getValue()), update));
|
451
|
+
}
|
452
|
+
dispatch(action) {
|
453
|
+
this.action$.next(action);
|
454
|
+
}
|
455
|
+
listen$(actionType) {
|
456
|
+
return this.action$.pipe(filter(action => action.type === actionType), map(action => action.payload));
|
457
|
+
}
|
458
|
+
listenAll$() {
|
459
|
+
return this.action$.asObservable();
|
460
|
+
}
|
461
|
+
clear() {
|
462
|
+
this.stateSubj$.next({});
|
463
|
+
this.action$.next(ClearAction);
|
353
464
|
}
|
354
465
|
}
|
355
|
-
|
356
|
-
|
357
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
358
|
-
type:
|
359
|
-
|
466
|
+
IntegrationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IntegrationState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
467
|
+
IntegrationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IntegrationState, providedIn: 'root' });
|
468
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IntegrationState, decorators: [{
|
469
|
+
type: Injectable,
|
470
|
+
args: [{ providedIn: 'root' }]
|
471
|
+
}] });
|
360
472
|
|
361
|
-
class
|
362
|
-
constructor(
|
363
|
-
this.
|
364
|
-
this.
|
365
|
-
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');
|
366
|
-
const result = script.replace(regexp, (match, g1, g2, src) => {
|
367
|
-
const imports = g1
|
368
|
-
.trim()
|
369
|
-
.slice(1, -1)
|
370
|
-
.split(',')
|
371
|
-
.map(item => item.trim());
|
372
|
-
imports.forEach(item => {
|
373
|
-
var _a;
|
374
|
-
if (!((_a = this.vendorMap[src]) === null || _a === void 0 ? void 0 : _a[item])) {
|
375
|
-
throw new Error(`Failed to import ${item} from '${src}' in ${elementPath}/script.ts`);
|
376
|
-
}
|
377
|
-
});
|
378
|
-
return `const ${g1} = vendor['${src}'];`;
|
379
|
-
});
|
380
|
-
return result;
|
381
|
-
};
|
382
|
-
this.document = this.host.injector.get(DOCUMENT);
|
383
|
-
this.vendorMap = this.host.injector.get(VENDOR_MAP);
|
384
|
-
const elementMetadata = this.host.injector.get(ELEMENT_METADATA);
|
385
|
-
const sharedElementMetadata = this.host.injector.get(SHARED_ELEMENT_METADATA);
|
386
|
-
this.addScript(sharedElementMetadata);
|
387
|
-
this.addScript(elementMetadata);
|
473
|
+
class ResourcesService {
|
474
|
+
constructor() {
|
475
|
+
this.scripts = new Map();
|
476
|
+
this.loaded$ = new ReplaySubject();
|
388
477
|
}
|
389
|
-
|
390
|
-
|
391
|
-
if (
|
392
|
-
return;
|
393
|
-
}
|
394
|
-
const id = btoa(UUID.UUID());
|
395
|
-
const script = this.document.createElement('script');
|
396
|
-
script.type = `text/javascript`;
|
397
|
-
let scriptContent = this.normalizeImports(metadata.script, (_a = metadata.path) !== null && _a !== void 0 ? _a : metadata.name);
|
398
|
-
const classMatch = /export class (\S+)/.exec(scriptContent);
|
399
|
-
const className = classMatch === null || classMatch === void 0 ? void 0 : classMatch[1];
|
400
|
-
if (!classMatch || !className) {
|
401
|
-
console.error("Script doesn't have exported class");
|
402
|
-
return;
|
478
|
+
loadScript(url) {
|
479
|
+
const loaded = this.scripts.get(url);
|
480
|
+
if (loaded === true) {
|
481
|
+
return of(noop());
|
403
482
|
}
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
483
|
+
if (loaded == null) {
|
484
|
+
this.scripts.set(url, false);
|
485
|
+
const script = document.createElement('script');
|
486
|
+
script.src = url;
|
487
|
+
script.onload = () => {
|
488
|
+
this.scripts.set(url, true);
|
489
|
+
this.loaded$.next();
|
490
|
+
};
|
491
|
+
document.body.appendChild(script);
|
411
492
|
}
|
412
|
-
this.
|
493
|
+
return this.loaded$.pipe(filter(() => this.scripts.get(url) === true), take(1));
|
494
|
+
}
|
495
|
+
loadStyles(url) {
|
496
|
+
var _a, _b;
|
497
|
+
const previewEl = document.querySelector('vl-cms-preview');
|
498
|
+
const rootEl = (_b = (_a = previewEl === null || previewEl === void 0 ? void 0 : previewEl.shadowRoot) !== null && _a !== void 0 ? _a : previewEl) !== null && _b !== void 0 ? _b : document.body;
|
499
|
+
return new Observable(subscriber => {
|
500
|
+
const link = document.createElement('link');
|
501
|
+
link.rel = 'stylesheet';
|
502
|
+
link.type = 'text/css';
|
503
|
+
link.href = url;
|
504
|
+
link.media = 'all';
|
505
|
+
link.onload = () => {
|
506
|
+
subscriber.next();
|
507
|
+
subscriber.complete();
|
508
|
+
};
|
509
|
+
rootEl.appendChild(link);
|
510
|
+
});
|
413
511
|
}
|
414
512
|
}
|
415
|
-
|
416
|
-
|
417
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
418
|
-
type:
|
419
|
-
|
513
|
+
ResourcesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ResourcesService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
514
|
+
ResourcesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ResourcesService, providedIn: 'root' });
|
515
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ResourcesService, decorators: [{
|
516
|
+
type: Injectable,
|
517
|
+
args: [{ providedIn: 'root' }]
|
518
|
+
}] });
|
420
519
|
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
},
|
429
|
-
CONTAINER: {
|
430
|
-
component: ElementComponent,
|
431
|
-
defaultTemplate: '<element-children></element-children>',
|
432
|
-
plugins: [ScriptPlugin],
|
433
|
-
},
|
434
|
-
SERVICE: {
|
435
|
-
component: ElementComponent,
|
436
|
-
plugins: [IOPlugin, ScriptPlugin],
|
437
|
-
suppressTemplate: true,
|
438
|
-
suppressStyles: true,
|
439
|
-
},
|
440
|
-
REFERENCE: {
|
441
|
-
component: ElementComponent,
|
442
|
-
plugins: [IOPlugin, ScriptPlugin],
|
443
|
-
suppressTemplate: true,
|
444
|
-
},
|
445
|
-
};
|
520
|
+
class ElementContextService {
|
521
|
+
}
|
522
|
+
ElementContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementContextService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
523
|
+
ElementContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementContextService });
|
524
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementContextService, decorators: [{
|
525
|
+
type: Injectable
|
526
|
+
}] });
|
446
527
|
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
this.
|
453
|
-
this.
|
528
|
+
class ElementRendererComponent {
|
529
|
+
constructor(parentInjector, runtimeService, elementContext, ioProviderService, configurationService, elementRef, cdr) {
|
530
|
+
this.parentInjector = parentInjector;
|
531
|
+
this.runtimeService = runtimeService;
|
532
|
+
this.elementContext = elementContext;
|
533
|
+
this.ioProviderService = ioProviderService;
|
534
|
+
this.configurationService = configurationService;
|
535
|
+
this.elementRef = elementRef;
|
536
|
+
this.cdr = cdr;
|
537
|
+
this.refs = {};
|
538
|
+
this.destroy$ = new Subject();
|
454
539
|
}
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
const template = el.template && window.atob(el.template);
|
460
|
-
const styles = el.styles && window.atob(el.styles);
|
461
|
-
const exportedClassName = script && ((_a = EXPORTED_CLASS_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
|
462
|
-
if (!exportedClassName) {
|
463
|
-
throw new Error("Script doesn't have exported class");
|
464
|
-
}
|
465
|
-
const elementMetadata = extractElementMetadata(script || '');
|
466
|
-
const path = (parentPath ? parentPath + '/' : '') + elementMetadata.name;
|
467
|
-
return Object.assign(Object.assign({}, elementMetadata), { path, script: script === null || script === void 0 ? void 0 : script.replace(METADATA_DECORATOR_REGEX, 'export class'), template,
|
468
|
-
styles, children: el.children.map(child => elementToMetadata(child, path)) });
|
469
|
-
};
|
470
|
-
const metadataToElement = (metadata, recursive = true) => {
|
471
|
-
const elMetadata = {
|
472
|
-
name: metadata.name,
|
473
|
-
isShared: metadata.isShared,
|
474
|
-
type: metadata.type,
|
475
|
-
model: metadata.model,
|
476
|
-
module: metadata.module,
|
477
|
-
reference: metadata.reference,
|
478
|
-
inputs: metadata.inputs,
|
479
|
-
outputs: metadata.outputs,
|
480
|
-
children: metadata.children.map(({ name }) => name),
|
481
|
-
configuredStyles: metadata.configuredStyles,
|
482
|
-
};
|
483
|
-
const normalizedElMetadata = normalizeElementMetadata(elMetadata);
|
484
|
-
if (!metadata.script || !EXPORTED_CLASS_REGEX.test(metadata.script)) {
|
485
|
-
throw new UiBuildError(`'${metadata.name}' component script is missing an exported class`, metadata);
|
486
|
-
}
|
487
|
-
const script = metadata.script &&
|
488
|
-
window.btoa(metadata.script.replace(EXPORTED_CLASS_REGEX, `@ElementDefinition(${stringifyElementMetadata(normalizedElMetadata)})\nexport class Script`));
|
489
|
-
const template = metadata.template && window.btoa(metadata.template);
|
490
|
-
const styles = metadata.styles && window.btoa(metadata.styles);
|
491
|
-
return {
|
492
|
-
script,
|
493
|
-
template,
|
494
|
-
styles,
|
495
|
-
children: recursive ? metadata.children.map(meta => metadataToElement(meta)) : [],
|
496
|
-
};
|
497
|
-
};
|
498
|
-
const normalizeElementMetadata = (elementMetadata) => {
|
499
|
-
var _a, _b, _c, _d;
|
500
|
-
const metadata = Object.assign({}, elementMetadata);
|
501
|
-
// model
|
502
|
-
const { lineItem, path } = (_a = metadata.model) !== null && _a !== void 0 ? _a : {};
|
503
|
-
const model = lineItem ? { lineItem } : path ? { path } : undefined;
|
504
|
-
if (model) {
|
505
|
-
metadata.model = model;
|
506
|
-
}
|
507
|
-
else {
|
508
|
-
delete metadata.model;
|
509
|
-
}
|
510
|
-
// module
|
511
|
-
if (!metadata.module) {
|
512
|
-
delete metadata.module;
|
513
|
-
}
|
514
|
-
// reference
|
515
|
-
if (!metadata.reference) {
|
516
|
-
delete metadata.reference;
|
517
|
-
}
|
518
|
-
// inputs
|
519
|
-
const inputs = Object.entries((_b = metadata.inputs) !== null && _b !== void 0 ? _b : {}).reduce((acc, [key, value]) => {
|
520
|
-
return Object.assign(Object.assign({}, acc), { [key]: value || null });
|
521
|
-
}, {});
|
522
|
-
if (inputs && Object.keys(inputs).length > 0) {
|
523
|
-
metadata.inputs = inputs;
|
524
|
-
}
|
525
|
-
else {
|
526
|
-
delete metadata.inputs;
|
527
|
-
}
|
528
|
-
// outputs
|
529
|
-
const outputs = Object.entries((_c = metadata.outputs) !== null && _c !== void 0 ? _c : {}).reduce((acc, [key, value]) => {
|
530
|
-
return Object.assign(Object.assign({}, acc), { [key]: value || null });
|
531
|
-
}, {});
|
532
|
-
if (outputs && Object.keys(outputs).length > 0) {
|
533
|
-
metadata.outputs = outputs;
|
534
|
-
}
|
535
|
-
else {
|
536
|
-
delete metadata.outputs;
|
537
|
-
}
|
538
|
-
// children
|
539
|
-
if (!((_d = metadata.children) === null || _d === void 0 ? void 0 : _d.length)) {
|
540
|
-
delete metadata.children;
|
541
|
-
}
|
542
|
-
// isShared
|
543
|
-
if (!metadata.isShared) {
|
544
|
-
delete metadata.isShared;
|
545
|
-
}
|
546
|
-
// configuredStyles
|
547
|
-
if (!metadata.configuredStyles) {
|
548
|
-
delete metadata.configuredStyles;
|
549
|
-
}
|
550
|
-
return metadata;
|
551
|
-
};
|
552
|
-
const extractElementMetadata = (script) => {
|
553
|
-
var _a;
|
554
|
-
const metadataString = ((_a = METADATA_DECORATOR_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
|
555
|
-
// need to reset regex last index to prevent null result for next execution
|
556
|
-
METADATA_DECORATOR_REGEX.lastIndex = 0;
|
557
|
-
return new Function(`return ${metadataString}`)();
|
558
|
-
};
|
559
|
-
const extendElementMetadata = (script, extend) => {
|
560
|
-
var _a;
|
561
|
-
const metadataString = ((_a = METADATA_DECORATOR_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
|
562
|
-
// need to reset regex last index to prevent null result for next execution
|
563
|
-
METADATA_DECORATOR_REGEX.lastIndex = 0;
|
564
|
-
if (!metadataString) {
|
565
|
-
return script;
|
566
|
-
}
|
567
|
-
const updated = Object.assign(Object.assign({}, new Function(`return ${metadataString}`)()), extend);
|
568
|
-
return script.replace(metadataString, stringifyElementMetadata(updated));
|
569
|
-
};
|
570
|
-
const getElementConfig = (type) => {
|
571
|
-
return CONFIG[type];
|
572
|
-
};
|
573
|
-
const doesElementSupportIO = (type) => {
|
574
|
-
var _a, _b;
|
575
|
-
return (_b = (_a = getElementConfig(type).plugins) === null || _a === void 0 ? void 0 : _a.includes(IOPlugin)) !== null && _b !== void 0 ? _b : false;
|
576
|
-
};
|
577
|
-
function stringifyElementMetadata(elementMetadata) {
|
578
|
-
const cleaned = JSON.stringify(elementMetadata, null, 2);
|
579
|
-
return cleaned.replace(/^[\t ]*"[^:\n\r]+(?<!\\)":/gm, function (match) {
|
580
|
-
return match.replace(/"/g, '');
|
581
|
-
});
|
582
|
-
}
|
583
|
-
const isValidScript = (script) => {
|
584
|
-
var _a;
|
585
|
-
if (!script) {
|
586
|
-
return false;
|
587
|
-
}
|
588
|
-
const exportedClassName = script && ((_a = EXPORTED_CLASS_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
|
589
|
-
if (!exportedClassName) {
|
590
|
-
return false;
|
591
|
-
}
|
592
|
-
const meta = extractElementMetadata(script);
|
593
|
-
if (!meta.name || !meta.type) {
|
594
|
-
return false;
|
595
|
-
}
|
596
|
-
return true;
|
597
|
-
};
|
598
|
-
function flattenElements(elements) {
|
599
|
-
return flatten(elements.map(el => [el, ...flattenElements(el.children)]));
|
600
|
-
}
|
601
|
-
function isSharedElement(el) {
|
602
|
-
return Boolean(el.isShared) && el.type !== 'REFERENCE';
|
603
|
-
}
|
604
|
-
|
605
|
-
class ElementContextService {
|
606
|
-
}
|
607
|
-
ElementContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementContextService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
608
|
-
ElementContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementContextService });
|
609
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementContextService, decorators: [{
|
610
|
-
type: Injectable
|
611
|
-
}] });
|
612
|
-
|
613
|
-
class ElementRendererComponent {
|
614
|
-
constructor(parentInjector, dynamicModuleService, elementContext, ioProviderService, configurationService, elementRef, cdr) {
|
615
|
-
this.parentInjector = parentInjector;
|
616
|
-
this.dynamicModuleService = dynamicModuleService;
|
617
|
-
this.elementContext = elementContext;
|
618
|
-
this.ioProviderService = ioProviderService;
|
619
|
-
this.configurationService = configurationService;
|
620
|
-
this.elementRef = elementRef;
|
621
|
-
this.cdr = cdr;
|
622
|
-
this.refs = {};
|
623
|
-
this.destroy$ = new Subject();
|
624
|
-
}
|
625
|
-
ngOnInit() {
|
626
|
-
this.elementContext.metadata = this.meta;
|
627
|
-
this.factory = this.dynamicModuleService.getComponentFactory(this.meta);
|
628
|
-
this.createComponents();
|
540
|
+
ngOnInit() {
|
541
|
+
this.elementContext.metadata = this.meta;
|
542
|
+
this.factory = this.meta.path ? this.runtimeService.componentFactories[this.meta.path] : undefined;
|
543
|
+
this.createComponents();
|
629
544
|
}
|
630
545
|
ngOnDestroy() {
|
631
546
|
this.destroyComponents();
|
@@ -748,9 +663,9 @@ class ElementRendererComponent {
|
|
748
663
|
this.refs = {};
|
749
664
|
}
|
750
665
|
}
|
751
|
-
ElementRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
752
|
-
ElementRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.
|
753
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
666
|
+
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 });
|
667
|
+
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 });
|
668
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementRendererComponent, decorators: [{
|
754
669
|
type: Component,
|
755
670
|
args: [{
|
756
671
|
selector: 'vl-cms-element-renderer',
|
@@ -761,184 +676,536 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
761
676
|
}]
|
762
677
|
}], ctorParameters: function () { return [{ type: i0.Injector, decorators: [{
|
763
678
|
type: SkipSelf
|
764
|
-
}] }, { type:
|
679
|
+
}] }, { type: RuntimeService }, { type: ElementContextService }, { type: IOProviderService }, { type: i2.ConfigurationService }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { el: [{
|
765
680
|
type: ViewChild,
|
766
681
|
args: ['el', { read: ViewContainerRef, static: true }]
|
767
682
|
}], meta: [{
|
768
683
|
type: Input
|
769
684
|
}] } });
|
770
685
|
|
771
|
-
class
|
772
|
-
constructor(
|
773
|
-
this.
|
774
|
-
this.
|
686
|
+
class PreviewComponent {
|
687
|
+
constructor(runtimeService, configurationService, messageService, configurationRuntimeService, integrationState, cdr) {
|
688
|
+
this.runtimeService = runtimeService;
|
689
|
+
this.configurationService = configurationService;
|
690
|
+
this.messageService = messageService;
|
691
|
+
this.configurationRuntimeService = configurationRuntimeService;
|
692
|
+
this.integrationState = integrationState;
|
693
|
+
this.cdr = cdr;
|
694
|
+
this.state$ = new BehaviorSubject({ loading: true, failure: false });
|
695
|
+
this.elements = [];
|
696
|
+
this.destroy$ = new Subject();
|
697
|
+
this.runtimeService.updated$.pipe(takeUntil(this.destroy$)).subscribe(() => this.cdr.detectChanges());
|
698
|
+
}
|
699
|
+
ngOnInit() {
|
700
|
+
var _a;
|
701
|
+
if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.clearStateOnInit) {
|
702
|
+
this.integrationState.clear();
|
703
|
+
}
|
704
|
+
this.startPreview();
|
705
|
+
}
|
706
|
+
ngOnDestroy() {
|
707
|
+
this.destroy$.next();
|
708
|
+
this.destroy$.complete();
|
709
|
+
this.configurationService.reset();
|
710
|
+
this.runtimeService.clear();
|
711
|
+
}
|
712
|
+
initializeConfiguration$() {
|
713
|
+
const isAlreadyInitialized = this.configurationRuntimeService.isInitialized;
|
714
|
+
if (!this.uiDefinition || this.uiDefinition.type !== 'CONFIGURATION' || isAlreadyInitialized) {
|
715
|
+
return of({});
|
716
|
+
}
|
717
|
+
if (!this.modelId) {
|
718
|
+
console.warn(`No modelId is given for uiDefinition with '${this.uiDefinition.type}' type`);
|
719
|
+
return of({});
|
720
|
+
}
|
721
|
+
// If still not initialized - init configuration in Test mode
|
722
|
+
return this.configurationRuntimeService
|
723
|
+
.initTestMode(this.modelId, this.uiDefinition)
|
724
|
+
.pipe(switchMap(() => this.configurationService.configure()));
|
725
|
+
}
|
726
|
+
startPreview() {
|
727
|
+
if (!this.uiDefinition) {
|
728
|
+
return;
|
729
|
+
}
|
730
|
+
forkJoin([this.runtimeService.initialize$(this.uiDefinition, this.config), this.initializeConfiguration$()])
|
731
|
+
.pipe(tap(([elements]) => {
|
732
|
+
this.elements = elements;
|
733
|
+
this.state$.next({ loading: false, failure: false });
|
734
|
+
}), catchError(error => {
|
735
|
+
var _a, _b;
|
736
|
+
console.error(error);
|
737
|
+
if (!((_b = (_a = this.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.suppressToastMessages)) {
|
738
|
+
this.messageService.add({ severity: 'error', summary: error });
|
739
|
+
}
|
740
|
+
this.state$.next({ loading: false, failure: true });
|
741
|
+
return of();
|
742
|
+
}), takeUntil(this.destroy$))
|
743
|
+
.subscribe();
|
775
744
|
}
|
776
745
|
}
|
777
|
-
|
778
|
-
|
779
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
746
|
+
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 });
|
747
|
+
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 });
|
748
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PreviewComponent, decorators: [{
|
780
749
|
type: Component,
|
781
750
|
args: [{
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
styleUrls: ['./element-children.component.scss'],
|
751
|
+
selector: 'vl-cms-preview',
|
752
|
+
templateUrl: './preview.component.html',
|
753
|
+
styleUrls: ['./preview.component.scss'],
|
786
754
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
755
|
+
providers: [IOProviderService, TemplatesService],
|
756
|
+
// use shadow DOM to prevent UI from being affected by global styles
|
757
|
+
encapsulation: ViewEncapsulation.ShadowDom,
|
787
758
|
}]
|
788
|
-
}], ctorParameters: function () { return [{ type:
|
759
|
+
}], ctorParameters: function () { return [{ type: RuntimeService }, { type: i2.ConfigurationService }, { type: i3.MessageService }, { type: i2.ConfigurationRuntimeService }, { type: IntegrationState }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { modelId: [{
|
760
|
+
type: Input
|
761
|
+
}], uiDefinition: [{
|
762
|
+
type: Input
|
763
|
+
}], config: [{
|
764
|
+
type: Input
|
765
|
+
}] } });
|
789
766
|
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
this.
|
794
|
-
this.
|
767
|
+
class RuntimeEditorService {
|
768
|
+
constructor(runtimeService) {
|
769
|
+
this.runtimeService = runtimeService;
|
770
|
+
this.editorModeSubj$ = new BehaviorSubject(false);
|
771
|
+
this.dragMode$ = new BehaviorSubject(false);
|
772
|
+
this.elementDropped$ = new ReplaySubject();
|
773
|
+
this.elementDeleted$ = new ReplaySubject();
|
774
|
+
this.editorMode$ = this.editorModeSubj$.asObservable();
|
775
|
+
this.runtimeService.isInitialized$.subscribe(() => { var _a; return this.editorModeSubj$.next(Boolean((_a = this.runtimeService.config) === null || _a === void 0 ? void 0 : _a.uiBuilderMode)); });
|
795
776
|
}
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
this.
|
777
|
+
applyPatch$(patch) {
|
778
|
+
return this.runtimeService.applyPatch$(patch);
|
779
|
+
}
|
780
|
+
toggleEditorMode() {
|
781
|
+
this.editorModeSubj$.next(!this.editorModeSubj$.value);
|
801
782
|
}
|
802
783
|
}
|
803
|
-
|
804
|
-
|
805
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
806
|
-
type:
|
807
|
-
|
808
|
-
|
784
|
+
RuntimeEditorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeEditorService, deps: [{ token: RuntimeService }], target: i0.ɵɵFactoryTarget.Injectable });
|
785
|
+
RuntimeEditorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeEditorService });
|
786
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeEditorService, decorators: [{
|
787
|
+
type: Injectable
|
788
|
+
}], ctorParameters: function () { return [{ type: RuntimeService }]; } });
|
789
|
+
|
790
|
+
class ElementDropHandleComponent {
|
791
|
+
constructor(runtimeService) {
|
792
|
+
this.runtimeService = runtimeService;
|
793
|
+
}
|
794
|
+
handleDrop(e) {
|
795
|
+
this.runtimeService.elementDropped$.next({
|
796
|
+
element: e.data,
|
797
|
+
index: this.index,
|
798
|
+
path: this.parentPath,
|
799
|
+
});
|
800
|
+
}
|
801
|
+
}
|
802
|
+
ElementDropHandleComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementDropHandleComponent, deps: [{ token: RuntimeEditorService }], target: i0.ɵɵFactoryTarget.Component });
|
803
|
+
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 });
|
804
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementDropHandleComponent, decorators: [{
|
805
|
+
type: Component,
|
806
|
+
args: [{
|
807
|
+
selector: 'vl-element-drop-handle',
|
808
|
+
templateUrl: './element-drop-handle.component.html',
|
809
|
+
styleUrls: ['./element-drop-handle.component.scss'],
|
810
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
811
|
+
}]
|
812
|
+
}], ctorParameters: function () { return [{ type: RuntimeEditorService }]; }, propDecorators: { index: [{
|
813
|
+
type: Input
|
814
|
+
}], parentPath: [{
|
809
815
|
type: Input
|
810
816
|
}] } });
|
811
817
|
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
};
|
818
|
+
class ElementDropHandleModule {
|
819
|
+
}
|
820
|
+
ElementDropHandleModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementDropHandleModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
821
|
+
ElementDropHandleModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementDropHandleModule, declarations: [ElementDropHandleComponent], imports: [CommonModule, DndModule], exports: [ElementDropHandleComponent] });
|
822
|
+
ElementDropHandleModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementDropHandleModule, imports: [[CommonModule, DndModule]] });
|
823
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementDropHandleModule, decorators: [{
|
824
|
+
type: NgModule,
|
825
|
+
args: [{
|
826
|
+
declarations: [ElementDropHandleComponent],
|
827
|
+
imports: [CommonModule, DndModule],
|
828
|
+
exports: [ElementDropHandleComponent],
|
829
|
+
}]
|
830
|
+
}] });
|
816
831
|
|
817
|
-
|
818
|
-
function loadRemoteEntry(remoteEntry) {
|
819
|
-
return new Promise((resolve, reject) => {
|
820
|
-
if (moduleMap[remoteEntry]) {
|
821
|
-
resolve();
|
822
|
-
return;
|
823
|
-
}
|
824
|
-
const script = document.createElement('script');
|
825
|
-
script.src = remoteEntry;
|
826
|
-
script.onerror = reject;
|
827
|
-
script.onload = () => {
|
828
|
-
moduleMap[remoteEntry] = true;
|
829
|
-
resolve(); // window is the global namespace
|
830
|
-
};
|
831
|
-
document.body.append(script);
|
832
|
-
});
|
833
|
-
}
|
834
|
-
function lookupExposedModule(remoteName, exposedModule) {
|
835
|
-
return __awaiter(this, void 0, void 0, function* () {
|
836
|
-
// Initializes the share scope. This fills it with known provided modules from this build and all remotes
|
837
|
-
yield __webpack_init_sharing__('default');
|
838
|
-
const container = window[remoteName]; // or get the container somewhere else
|
839
|
-
// Initialize the container, it may provide shared modules
|
840
|
-
yield container.init(__webpack_share_scopes__.default);
|
841
|
-
const factory = yield container.get(exposedModule);
|
842
|
-
const Module = factory();
|
843
|
-
return Module;
|
844
|
-
});
|
845
|
-
}
|
846
|
-
function loadRemoteModule(remoteEntry, remoteName, exposedModule) {
|
847
|
-
return __awaiter(this, void 0, void 0, function* () {
|
848
|
-
yield loadRemoteEntry(remoteEntry);
|
849
|
-
return yield lookupExposedModule(remoteName, exposedModule);
|
850
|
-
});
|
832
|
+
class ElementRendererModule {
|
851
833
|
}
|
834
|
+
ElementRendererModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementRendererModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
835
|
+
ElementRendererModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementRendererModule, declarations: [ElementRendererComponent], exports: [ElementRendererComponent] });
|
836
|
+
ElementRendererModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementRendererModule });
|
837
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementRendererModule, decorators: [{
|
838
|
+
type: NgModule,
|
839
|
+
args: [{
|
840
|
+
declarations: [ElementRendererComponent],
|
841
|
+
exports: [ElementRendererComponent],
|
842
|
+
}]
|
843
|
+
}] });
|
852
844
|
|
853
|
-
class
|
854
|
-
constructor(
|
855
|
-
|
856
|
-
this.
|
857
|
-
this.
|
858
|
-
this.
|
859
|
-
this.
|
860
|
-
|
861
|
-
this.
|
862
|
-
this.
|
863
|
-
|
864
|
-
|
865
|
-
var _a, _b, _c, _d;
|
866
|
-
if (changes.data && this.instance) {
|
867
|
-
this.instance.data = this.data;
|
868
|
-
}
|
869
|
-
if (changes.options) {
|
870
|
-
this.suppressLoading = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.suppressLoading) !== null && _b !== void 0 ? _b : defaultOptions.suppressLoading;
|
871
|
-
this.loadingLabel = (_d = (_c = this.options) === null || _c === void 0 ? void 0 : _c.loadingLabel) !== null && _d !== void 0 ? _d : defaultOptions.loadingLabel;
|
872
|
-
}
|
873
|
-
}
|
874
|
-
ngOnInit() {
|
875
|
-
this.isLoading$.next(true);
|
845
|
+
class ElementChildrenComponent {
|
846
|
+
constructor(elementContext, runtimeService, runtimeEditorService, cdr) {
|
847
|
+
var _a, _b;
|
848
|
+
this.elementContext = elementContext;
|
849
|
+
this.runtimeService = runtimeService;
|
850
|
+
this.runtimeEditorService = runtimeEditorService;
|
851
|
+
this.cdr = cdr;
|
852
|
+
this.destroyed$ = new Subject();
|
853
|
+
const path = (_b = (_a = this.elementContext) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.path;
|
854
|
+
this.metadata$ = path ? this.runtimeService.getCompiledElement$(path) : of(undefined);
|
855
|
+
this.dragMode$ = combineLatest([this.runtimeEditorService.editorMode$, this.runtimeEditorService.dragMode$]).pipe(map(flags => flags.every(Boolean)));
|
856
|
+
this.runtimeService.updated$.pipe(takeUntil(this.destroyed$)).subscribe(() => this.cdr.detectChanges());
|
876
857
|
}
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
const remoteName = (_d = (_c = this.options) === null || _c === void 0 ? void 0 : _c.remoteName) !== null && _d !== void 0 ? _d : this.remoteName;
|
881
|
-
const exposedModule = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.exposedModule) !== null && _f !== void 0 ? _f : this.exposedModule;
|
882
|
-
if (!remoteEntry || !remoteName || !exposedModule) {
|
883
|
-
return;
|
884
|
-
}
|
885
|
-
loadRemoteModule(remoteEntry, remoteName, exposedModule).then(federated => {
|
886
|
-
this.compiler.compileModuleAsync(federated[exposedModule]).then(moduleFactory => {
|
887
|
-
var _a, _b, _c;
|
888
|
-
const rootModuleRef = moduleFactory.create(this.injector);
|
889
|
-
const rootComponentFactory = rootModuleRef.componentFactoryResolver.resolveComponentFactory(federated[exposedModule].rootComponent);
|
890
|
-
const node = document.createElement('div');
|
891
|
-
const { instance, hostView } = rootComponentFactory.create(this.injector, [], node);
|
892
|
-
this.instance = instance;
|
893
|
-
this.instance.data = this.data;
|
894
|
-
this.renderer.appendChild((_a = this.moduleHostRef) === null || _a === void 0 ? void 0 : _a.nativeElement, node);
|
895
|
-
this.appRef.attachView(hostView);
|
896
|
-
(_c = (_b = this.options) === null || _b === void 0 ? void 0 : _b.onReady) === null || _c === void 0 ? void 0 : _c.call(_b);
|
897
|
-
this.isLoading$.next(false);
|
898
|
-
});
|
899
|
-
});
|
858
|
+
ngOnDestroy() {
|
859
|
+
this.destroyed$.next();
|
860
|
+
this.destroyed$.complete();
|
900
861
|
}
|
901
862
|
}
|
902
|
-
|
903
|
-
|
904
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
863
|
+
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 });
|
864
|
+
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 });
|
865
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementChildrenComponent, decorators: [{
|
905
866
|
type: Component,
|
906
867
|
args: [{
|
907
868
|
// eslint-disable-next-line @angular-eslint/component-selector
|
908
|
-
selector: '
|
909
|
-
templateUrl: '
|
910
|
-
styleUrls: ['./
|
869
|
+
selector: 'element-children',
|
870
|
+
templateUrl: 'element-children.component.html',
|
871
|
+
styleUrls: ['./element-children.component.scss'],
|
911
872
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
912
873
|
}]
|
913
|
-
}], ctorParameters: function () { return [{ type:
|
914
|
-
type: ViewChild,
|
915
|
-
args: ['moduleHost', { static: false }]
|
916
|
-
}], remoteEntry: [{
|
917
|
-
type: Input
|
918
|
-
}], remoteName: [{
|
919
|
-
type: Input
|
920
|
-
}], exposedModule: [{
|
921
|
-
type: Input
|
922
|
-
}], data: [{
|
923
|
-
type: Input
|
924
|
-
}], options: [{
|
925
|
-
type: Input
|
926
|
-
}] } });
|
874
|
+
}], ctorParameters: function () { return [{ type: ElementContextService }, { type: RuntimeService }, { type: RuntimeEditorService }, { type: i0.ChangeDetectorRef }]; } });
|
927
875
|
|
928
|
-
class
|
876
|
+
class ElementChildrenModule {
|
929
877
|
}
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
878
|
+
ElementChildrenModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementChildrenModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
879
|
+
ElementChildrenModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementChildrenModule, declarations: [ElementChildrenComponent], imports: [LetDirectiveModule, ElementRendererModule, ElementDropHandleModule], exports: [ElementChildrenComponent] });
|
880
|
+
ElementChildrenModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementChildrenModule, imports: [[LetDirectiveModule, ElementRendererModule, ElementDropHandleModule]] });
|
881
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ElementChildrenModule, decorators: [{
|
934
882
|
type: NgModule,
|
935
883
|
args: [{
|
936
|
-
declarations: [
|
937
|
-
imports: [
|
938
|
-
exports: [
|
884
|
+
declarations: [ElementChildrenComponent],
|
885
|
+
imports: [LetDirectiveModule, ElementRendererModule, ElementDropHandleModule],
|
886
|
+
exports: [ElementChildrenComponent],
|
939
887
|
}]
|
940
888
|
}] });
|
941
889
|
|
890
|
+
class PreviewModule {
|
891
|
+
}
|
892
|
+
PreviewModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PreviewModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
893
|
+
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] });
|
894
|
+
PreviewModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PreviewModule, providers: [IntegrationState], imports: [[CommonModule, LoaderModule, ElementRendererModule, ElementChildrenModule, ElementDropHandleModule]] });
|
895
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PreviewModule, decorators: [{
|
896
|
+
type: NgModule,
|
897
|
+
args: [{
|
898
|
+
declarations: [PreviewComponent],
|
899
|
+
imports: [CommonModule, LoaderModule, ElementRendererModule, ElementChildrenModule, ElementDropHandleModule],
|
900
|
+
providers: [IntegrationState],
|
901
|
+
exports: [PreviewComponent],
|
902
|
+
}]
|
903
|
+
}] });
|
904
|
+
|
905
|
+
function ElementDefinition(definition) {
|
906
|
+
return function (constructor) {
|
907
|
+
return constructor;
|
908
|
+
};
|
909
|
+
}
|
910
|
+
|
911
|
+
// eslint-disable-next-line @angular-eslint/directive-selector
|
912
|
+
class CustomTemplateDirective {
|
913
|
+
constructor(templateRef, templatesService) {
|
914
|
+
this.templateRef = templateRef;
|
915
|
+
this.templatesService = templatesService;
|
916
|
+
}
|
917
|
+
ngAfterViewInit() {
|
918
|
+
if (!this.customTemplate) {
|
919
|
+
return;
|
920
|
+
}
|
921
|
+
this.templatesService.register(this.customTemplate, this.templateRef);
|
922
|
+
}
|
923
|
+
}
|
924
|
+
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 });
|
925
|
+
CustomTemplateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: CustomTemplateDirective, selector: "[customTemplate]", inputs: { customTemplate: "customTemplate" }, ngImport: i0 });
|
926
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: CustomTemplateDirective, decorators: [{
|
927
|
+
type: Directive,
|
928
|
+
args: [{ selector: '[customTemplate]' }]
|
929
|
+
}], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: TemplatesService }]; }, propDecorators: { customTemplate: [{
|
930
|
+
type: Input
|
931
|
+
}] } });
|
932
|
+
|
933
|
+
class IOPlugin {
|
934
|
+
constructor(host) {
|
935
|
+
var _a, _b;
|
936
|
+
this.host = host;
|
937
|
+
const elementMetadata = this.host.injector.get(ELEMENT_METADATA);
|
938
|
+
const inputProvider = this.host.injector.get(IOProviderService);
|
939
|
+
const inputs = Object.entries((_a = elementMetadata.inputs) !== null && _a !== void 0 ? _a : {});
|
940
|
+
const outputs = Object.entries((_b = elementMetadata.outputs) !== null && _b !== void 0 ? _b : {});
|
941
|
+
inputs.forEach(([key, path]) => {
|
942
|
+
var _a;
|
943
|
+
if (path && typeof path !== 'string') {
|
944
|
+
console.error(`The value of '${key}' input should be a string`);
|
945
|
+
}
|
946
|
+
if (((_a = elementMetadata.outputs) === null || _a === void 0 ? void 0 : _a[key]) !== undefined) {
|
947
|
+
console.warn(`'${key}' appears both in inputs and outputs. To prevent inconsistent behavior please keep them unique `);
|
948
|
+
}
|
949
|
+
this.host[key] = inputProvider.connect(elementMetadata, key, path);
|
950
|
+
});
|
951
|
+
outputs.forEach(([key, path]) => {
|
952
|
+
if (path && typeof path !== 'string') {
|
953
|
+
console.error(`The value of '${key}' output should be a string`);
|
954
|
+
}
|
955
|
+
this.host[key] = inputProvider.provide(elementMetadata, key, path);
|
956
|
+
});
|
957
|
+
}
|
958
|
+
}
|
959
|
+
IOPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IOPlugin, deps: [{ token: ElementComponent }], target: i0.ɵɵFactoryTarget.Directive });
|
960
|
+
IOPlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: IOPlugin, ngImport: i0 });
|
961
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IOPlugin, decorators: [{
|
962
|
+
type: Directive
|
963
|
+
}], ctorParameters: function () { return [{ type: ElementComponent }]; } });
|
964
|
+
|
965
|
+
class ScriptPlugin {
|
966
|
+
constructor(host) {
|
967
|
+
this.host = host;
|
968
|
+
this.normalizeImports = (script, elementPath) => {
|
969
|
+
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');
|
970
|
+
const result = script.replace(regexp, (match, g1, g2, src) => {
|
971
|
+
const imports = g1
|
972
|
+
.trim()
|
973
|
+
.slice(1, -1)
|
974
|
+
.split(',')
|
975
|
+
.map(item => item.trim());
|
976
|
+
imports.forEach(item => {
|
977
|
+
var _a;
|
978
|
+
if (!((_a = this.vendorMap[src]) === null || _a === void 0 ? void 0 : _a[item])) {
|
979
|
+
throw new Error(`Failed to import ${item} from '${src}' in ${elementPath}/script.ts`);
|
980
|
+
}
|
981
|
+
});
|
982
|
+
return `const ${g1} = vendor['${src}'];`;
|
983
|
+
});
|
984
|
+
return result;
|
985
|
+
};
|
986
|
+
this.document = this.host.injector.get(DOCUMENT);
|
987
|
+
this.vendorMap = this.host.injector.get(VENDOR_MAP);
|
988
|
+
const elementMetadata = this.host.injector.get(ELEMENT_METADATA);
|
989
|
+
const sharedElementMetadata = this.host.injector.get(SHARED_ELEMENT_METADATA);
|
990
|
+
this.addScript(sharedElementMetadata);
|
991
|
+
this.addScript(elementMetadata);
|
992
|
+
}
|
993
|
+
addScript(metadata) {
|
994
|
+
var _a;
|
995
|
+
if (!(metadata === null || metadata === void 0 ? void 0 : metadata.script)) {
|
996
|
+
return;
|
997
|
+
}
|
998
|
+
const id = btoa(UUID.UUID());
|
999
|
+
const script = this.document.createElement('script');
|
1000
|
+
script.type = `text/javascript`;
|
1001
|
+
let scriptContent = this.normalizeImports(metadata.script, (_a = metadata.path) !== null && _a !== void 0 ? _a : metadata.name);
|
1002
|
+
const classMatch = /export class (\S+)/.exec(scriptContent);
|
1003
|
+
const className = classMatch === null || classMatch === void 0 ? void 0 : classMatch[1];
|
1004
|
+
if (!classMatch || !className) {
|
1005
|
+
console.error("Script doesn't have exported class");
|
1006
|
+
return;
|
1007
|
+
}
|
1008
|
+
scriptContent = scriptContent.replace(classMatch[0], `class ${className}`);
|
1009
|
+
script.text = `var ${id} = function(vendor) {${scriptContent}
|
1010
|
+
return ${className}; };`;
|
1011
|
+
this.document.body.appendChild(script);
|
1012
|
+
const ScriptClass = window[id](this.vendorMap);
|
1013
|
+
if (ScriptClass instanceof Object) {
|
1014
|
+
this.host.registerPlugin(new ScriptClass(this.host));
|
1015
|
+
}
|
1016
|
+
this.document.body.removeChild(script);
|
1017
|
+
}
|
1018
|
+
}
|
1019
|
+
ScriptPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ScriptPlugin, deps: [{ token: ElementComponent }], target: i0.ɵɵFactoryTarget.Directive });
|
1020
|
+
ScriptPlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: ScriptPlugin, ngImport: i0 });
|
1021
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ScriptPlugin, decorators: [{
|
1022
|
+
type: Directive
|
1023
|
+
}], ctorParameters: function () { return [{ type: ElementComponent }]; } });
|
1024
|
+
|
1025
|
+
/*
|
1026
|
+
* ScriptPlugin must always be the last plugin in the list to make sure user code is running after all pre-initializers.
|
1027
|
+
*/
|
1028
|
+
const CONFIG = {
|
1029
|
+
CUSTOM: {
|
1030
|
+
component: ElementComponent,
|
1031
|
+
plugins: [IOPlugin, ScriptPlugin],
|
1032
|
+
},
|
1033
|
+
CONTAINER: {
|
1034
|
+
component: ElementComponent,
|
1035
|
+
defaultTemplate: '<element-children></element-children>',
|
1036
|
+
plugins: [ScriptPlugin],
|
1037
|
+
},
|
1038
|
+
SERVICE: {
|
1039
|
+
component: ElementComponent,
|
1040
|
+
plugins: [IOPlugin, ScriptPlugin],
|
1041
|
+
suppressTemplate: true,
|
1042
|
+
suppressStyles: true,
|
1043
|
+
},
|
1044
|
+
REFERENCE: {
|
1045
|
+
component: ElementComponent,
|
1046
|
+
plugins: [IOPlugin, ScriptPlugin],
|
1047
|
+
suppressTemplate: true,
|
1048
|
+
},
|
1049
|
+
};
|
1050
|
+
|
1051
|
+
const EXPORTED_CLASS_REGEX = /export class (\S+)/;
|
1052
|
+
const METADATA_DECORATOR_REGEX = /@ElementDefinition\(([\s\S]+)\)(\n|\r\n|.)*export class/g;
|
1053
|
+
class UiBuildError extends Error {
|
1054
|
+
constructor(message, affectedMetadata) {
|
1055
|
+
super(message);
|
1056
|
+
this.name = this.constructor.name;
|
1057
|
+
this.affectedMetadata = affectedMetadata;
|
1058
|
+
}
|
1059
|
+
}
|
1060
|
+
const elementToMetadata = (el, parentPath) => {
|
1061
|
+
var _a;
|
1062
|
+
const script = el.script && window.atob(el.script);
|
1063
|
+
const template = el.template && window.atob(el.template);
|
1064
|
+
const styles = el.styles && window.atob(el.styles);
|
1065
|
+
const exportedClassName = script && ((_a = EXPORTED_CLASS_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
|
1066
|
+
if (!exportedClassName) {
|
1067
|
+
throw new Error("Script doesn't have exported class");
|
1068
|
+
}
|
1069
|
+
const elementMetadata = extractElementMetadata(script || '');
|
1070
|
+
const path = (parentPath ? parentPath + '/' : '') + elementMetadata.name;
|
1071
|
+
return Object.assign(Object.assign({}, elementMetadata), { path, script: script === null || script === void 0 ? void 0 : script.replace(METADATA_DECORATOR_REGEX, 'export class'), template,
|
1072
|
+
styles, children: el.children.map(child => elementToMetadata(child, path)) });
|
1073
|
+
};
|
1074
|
+
const metadataToElement = (metadata, recursive = true) => {
|
1075
|
+
const elMetadata = {
|
1076
|
+
name: metadata.name,
|
1077
|
+
isShared: metadata.isShared,
|
1078
|
+
type: metadata.type,
|
1079
|
+
model: metadata.model,
|
1080
|
+
module: metadata.module,
|
1081
|
+
reference: metadata.reference,
|
1082
|
+
inputs: metadata.inputs,
|
1083
|
+
outputs: metadata.outputs,
|
1084
|
+
children: metadata.children.map(({ name }) => name),
|
1085
|
+
configuredStyles: metadata.configuredStyles,
|
1086
|
+
};
|
1087
|
+
const normalizedElMetadata = normalizeElementMetadata(elMetadata);
|
1088
|
+
if (!metadata.script || !EXPORTED_CLASS_REGEX.test(metadata.script)) {
|
1089
|
+
throw new UiBuildError(`'${metadata.name}' component script is missing an exported class`, metadata);
|
1090
|
+
}
|
1091
|
+
const script = metadata.script &&
|
1092
|
+
window.btoa(metadata.script.replace(EXPORTED_CLASS_REGEX, `@ElementDefinition(${stringifyElementMetadata(normalizedElMetadata)})\nexport class Script`));
|
1093
|
+
const template = metadata.template && window.btoa(metadata.template);
|
1094
|
+
const styles = metadata.styles && window.btoa(metadata.styles);
|
1095
|
+
return {
|
1096
|
+
script,
|
1097
|
+
template,
|
1098
|
+
styles,
|
1099
|
+
children: recursive ? metadata.children.map(meta => metadataToElement(meta)) : [],
|
1100
|
+
};
|
1101
|
+
};
|
1102
|
+
const normalizeElementMetadata = (elementMetadata) => {
|
1103
|
+
var _a, _b, _c, _d;
|
1104
|
+
const metadata = Object.assign({}, elementMetadata);
|
1105
|
+
// model
|
1106
|
+
const { lineItem, path } = (_a = metadata.model) !== null && _a !== void 0 ? _a : {};
|
1107
|
+
const model = lineItem ? { lineItem } : path ? { path } : undefined;
|
1108
|
+
if (model) {
|
1109
|
+
metadata.model = model;
|
1110
|
+
}
|
1111
|
+
else {
|
1112
|
+
delete metadata.model;
|
1113
|
+
}
|
1114
|
+
// module
|
1115
|
+
if (!metadata.module) {
|
1116
|
+
delete metadata.module;
|
1117
|
+
}
|
1118
|
+
// reference
|
1119
|
+
if (!metadata.reference) {
|
1120
|
+
delete metadata.reference;
|
1121
|
+
}
|
1122
|
+
// inputs
|
1123
|
+
const inputs = Object.entries((_b = metadata.inputs) !== null && _b !== void 0 ? _b : {}).reduce((acc, [key, value]) => {
|
1124
|
+
return Object.assign(Object.assign({}, acc), { [key]: value || null });
|
1125
|
+
}, {});
|
1126
|
+
if (inputs && Object.keys(inputs).length > 0) {
|
1127
|
+
metadata.inputs = inputs;
|
1128
|
+
}
|
1129
|
+
else {
|
1130
|
+
delete metadata.inputs;
|
1131
|
+
}
|
1132
|
+
// outputs
|
1133
|
+
const outputs = Object.entries((_c = metadata.outputs) !== null && _c !== void 0 ? _c : {}).reduce((acc, [key, value]) => {
|
1134
|
+
return Object.assign(Object.assign({}, acc), { [key]: value || null });
|
1135
|
+
}, {});
|
1136
|
+
if (outputs && Object.keys(outputs).length > 0) {
|
1137
|
+
metadata.outputs = outputs;
|
1138
|
+
}
|
1139
|
+
else {
|
1140
|
+
delete metadata.outputs;
|
1141
|
+
}
|
1142
|
+
// children
|
1143
|
+
if (!((_d = metadata.children) === null || _d === void 0 ? void 0 : _d.length)) {
|
1144
|
+
delete metadata.children;
|
1145
|
+
}
|
1146
|
+
// isShared
|
1147
|
+
if (!metadata.isShared) {
|
1148
|
+
delete metadata.isShared;
|
1149
|
+
}
|
1150
|
+
// configuredStyles
|
1151
|
+
if (!metadata.configuredStyles) {
|
1152
|
+
delete metadata.configuredStyles;
|
1153
|
+
}
|
1154
|
+
return metadata;
|
1155
|
+
};
|
1156
|
+
const extractElementMetadata = (script) => {
|
1157
|
+
var _a;
|
1158
|
+
const metadataString = ((_a = METADATA_DECORATOR_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
|
1159
|
+
// need to reset regex last index to prevent null result for next execution
|
1160
|
+
METADATA_DECORATOR_REGEX.lastIndex = 0;
|
1161
|
+
return new Function(`return ${metadataString}`)();
|
1162
|
+
};
|
1163
|
+
const extendElementMetadata = (script, extend) => {
|
1164
|
+
var _a;
|
1165
|
+
const metadataString = ((_a = METADATA_DECORATOR_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
|
1166
|
+
// need to reset regex last index to prevent null result for next execution
|
1167
|
+
METADATA_DECORATOR_REGEX.lastIndex = 0;
|
1168
|
+
if (!metadataString) {
|
1169
|
+
return script;
|
1170
|
+
}
|
1171
|
+
const updated = Object.assign(Object.assign({}, new Function(`return ${metadataString}`)()), extend);
|
1172
|
+
return script.replace(metadataString, stringifyElementMetadata(updated));
|
1173
|
+
};
|
1174
|
+
const getElementConfig = (type) => {
|
1175
|
+
return CONFIG[type];
|
1176
|
+
};
|
1177
|
+
const doesElementSupportIO = (type) => {
|
1178
|
+
var _a, _b;
|
1179
|
+
return (_b = (_a = getElementConfig(type).plugins) === null || _a === void 0 ? void 0 : _a.includes(IOPlugin)) !== null && _b !== void 0 ? _b : false;
|
1180
|
+
};
|
1181
|
+
function stringifyElementMetadata(elementMetadata) {
|
1182
|
+
const cleaned = JSON.stringify(elementMetadata, null, 2);
|
1183
|
+
return cleaned.replace(/^[\t ]*"[^:\n\r]+(?<!\\)":/gm, function (match) {
|
1184
|
+
return match.replace(/"/g, '');
|
1185
|
+
});
|
1186
|
+
}
|
1187
|
+
const isValidScript = (script) => {
|
1188
|
+
var _a;
|
1189
|
+
if (!script) {
|
1190
|
+
return false;
|
1191
|
+
}
|
1192
|
+
const exportedClassName = script && ((_a = EXPORTED_CLASS_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
|
1193
|
+
if (!exportedClassName) {
|
1194
|
+
return false;
|
1195
|
+
}
|
1196
|
+
const meta = extractElementMetadata(script);
|
1197
|
+
if (!meta.name || !meta.type) {
|
1198
|
+
return false;
|
1199
|
+
}
|
1200
|
+
return true;
|
1201
|
+
};
|
1202
|
+
function flattenElements(elements) {
|
1203
|
+
return flatten(elements.map(el => [el, ...flattenElements(el.children)]));
|
1204
|
+
}
|
1205
|
+
function isSharedElement(el) {
|
1206
|
+
return Boolean(el.isShared) && el.type !== 'REFERENCE';
|
1207
|
+
}
|
1208
|
+
|
942
1209
|
class ConfigurationPlugin {
|
943
1210
|
constructor(host) {
|
944
1211
|
var _a, _b;
|
@@ -980,7 +1247,15 @@ class ConfigurationPlugin {
|
|
980
1247
|
}
|
981
1248
|
this.configurationService.patch(new LineItemWorker(rootLineItem).remove(this.modelSnapshot.id).li);
|
982
1249
|
};
|
1250
|
+
const updateQty = (qty) => {
|
1251
|
+
const rootLineItem = this.configurationService.getSnapshot();
|
1252
|
+
if (!rootLineItem || !this.modelSnapshot) {
|
1253
|
+
return;
|
1254
|
+
}
|
1255
|
+
this.configurationService.patch(new LineItemWorker(rootLineItem).replace(Object.assign(Object.assign({}, this.modelSnapshot), { qty })).li);
|
1256
|
+
};
|
983
1257
|
this.typeHost.remove = remove;
|
1258
|
+
this.typeHost.updateQty = updateQty;
|
984
1259
|
}
|
985
1260
|
registerPort(name) {
|
986
1261
|
const model$ = this.host.model$;
|
@@ -1012,75 +1287,40 @@ class ConfigurationPlugin {
|
|
1012
1287
|
}
|
1013
1288
|
this.configurationService.patch(new LineItemWorker(this.modelSnapshot).patchAttribute([{ name, value }]).li);
|
1014
1289
|
};
|
1015
|
-
this.attributeHost.value$ = value$;
|
1016
|
-
this.attributeHost.patch = patch;
|
1017
|
-
}
|
1018
|
-
get attributeHost() {
|
1019
|
-
return this.host;
|
1020
|
-
}
|
1021
|
-
get typeHost() {
|
1022
|
-
return this.host;
|
1023
|
-
}
|
1024
|
-
get portHost() {
|
1025
|
-
return this.host;
|
1026
|
-
}
|
1027
|
-
}
|
1028
|
-
ConfigurationPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationPlugin, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
|
1029
|
-
ConfigurationPlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: ConfigurationPlugin, ngImport: i0 });
|
1030
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationPlugin, decorators: [{
|
1031
|
-
type: Directive
|
1032
|
-
}], ctorParameters: function () { return [{ type: undefined }]; } });
|
1033
|
-
|
1034
|
-
const DEFAULT_PLUGINS = {
|
1035
|
-
CONFIGURATION: [ConfigurationPlugin],
|
1036
|
-
DEFAULT: [],
|
1037
|
-
};
|
1038
|
-
|
1039
|
-
const InitAction = { type: 'INIT' };
|
1040
|
-
const ClearAction = { type: 'CLEAR' };
|
1041
|
-
class IntegrationState {
|
1042
|
-
constructor() {
|
1043
|
-
this.stateSubj$ = new BehaviorSubject({});
|
1044
|
-
this.action$ = new BehaviorSubject(InitAction);
|
1045
|
-
}
|
1046
|
-
get state$() {
|
1047
|
-
return this.stateSubj$.asObservable();
|
1048
|
-
}
|
1049
|
-
get state() {
|
1050
|
-
return this.stateSubj$.getValue();
|
1051
|
-
}
|
1052
|
-
patchState(update) {
|
1053
|
-
this.stateSubj$.next(Object.assign(Object.assign({}, this.stateSubj$.getValue()), update));
|
1054
|
-
}
|
1055
|
-
dispatch(action) {
|
1056
|
-
this.action$.next(action);
|
1290
|
+
this.attributeHost.value$ = value$;
|
1291
|
+
this.attributeHost.patch = patch;
|
1057
1292
|
}
|
1058
|
-
|
1059
|
-
return this.
|
1293
|
+
get attributeHost() {
|
1294
|
+
return this.host;
|
1060
1295
|
}
|
1061
|
-
|
1062
|
-
return this.
|
1296
|
+
get typeHost() {
|
1297
|
+
return this.host;
|
1063
1298
|
}
|
1064
|
-
|
1065
|
-
this.
|
1066
|
-
this.action$.next(ClearAction);
|
1299
|
+
get portHost() {
|
1300
|
+
return this.host;
|
1067
1301
|
}
|
1068
1302
|
}
|
1069
|
-
|
1070
|
-
|
1071
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1072
|
-
type:
|
1073
|
-
|
1074
|
-
|
1303
|
+
ConfigurationPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ConfigurationPlugin, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
|
1304
|
+
ConfigurationPlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: ConfigurationPlugin, ngImport: i0 });
|
1305
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ConfigurationPlugin, decorators: [{
|
1306
|
+
type: Directive
|
1307
|
+
}], ctorParameters: function () { return [{ type: undefined }]; } });
|
1308
|
+
|
1309
|
+
const DEFAULT_PLUGINS = {
|
1310
|
+
CONFIGURATION: [ConfigurationPlugin],
|
1311
|
+
DEFAULT: [],
|
1312
|
+
};
|
1075
1313
|
|
1076
1314
|
const VELOCE_LIBS = {
|
1077
|
-
'@veloceapps/
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1315
|
+
'@veloceapps/core': {
|
1316
|
+
isDefined,
|
1317
|
+
Operator,
|
1318
|
+
Predicate,
|
1319
|
+
parseJsonSafely,
|
1320
|
+
},
|
1321
|
+
'@veloceapps/components': {
|
1322
|
+
ToastService,
|
1323
|
+
},
|
1084
1324
|
'@veloceapps/api': {
|
1085
1325
|
SalesforceApiService,
|
1086
1326
|
QuoteApiService,
|
@@ -1091,23 +1331,46 @@ const VELOCE_LIBS = {
|
|
1091
1331
|
DeltaApiService,
|
1092
1332
|
PicklistsApiService,
|
1093
1333
|
PriceApiService,
|
1334
|
+
ShoppingCartSettingsApiService,
|
1335
|
+
ConfigurationSettingsApiService,
|
1336
|
+
GuidedSellingApiService,
|
1094
1337
|
},
|
1338
|
+
'@veloceapps/sdk/core': Object.assign({ ConfigurationService,
|
1339
|
+
QuoteDraftService,
|
1340
|
+
FlowConfigurationService,
|
1341
|
+
LineItemWorker,
|
1342
|
+
ProductImagesService,
|
1343
|
+
ContextService }, lineItemUtils),
|
1344
|
+
'@veloceapps/sdk/cms': Object.assign(Object.assign(Object.assign({}, cmsInjectionTokens), cmsActions), { TemplatesService,
|
1345
|
+
IntegrationState,
|
1346
|
+
ResourcesService }),
|
1095
1347
|
};
|
1096
1348
|
const VELOCE_LIBS_BACKWARDS_COMPATIBLE = Object.entries(VELOCE_LIBS).reduce((trunk, [key, value]) => (Object.assign(Object.assign({}, trunk), { [key.replace('@veloceapps/', '@veloce/')]: value })), {});
|
1097
1349
|
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 });
|
1098
1350
|
|
1099
1351
|
class ElementsResolver {
|
1100
|
-
constructor(uiDef, elements) {
|
1352
|
+
constructor(uiDef, elements, sharedElements = []) {
|
1101
1353
|
this.uiDef = uiDef;
|
1102
1354
|
this.renderableElements = [];
|
1103
1355
|
this.sharedElements = [];
|
1104
1356
|
const transpiledElements = this.transpileScripts(elements);
|
1105
|
-
|
1106
|
-
this.
|
1357
|
+
const transpiledSharedElements = this.transpileScripts(sharedElements);
|
1358
|
+
this.sharedElements = this.flattenElements(transpiledElements)
|
1359
|
+
.filter(el => this.isSharedElement(el))
|
1360
|
+
.concat(transpiledSharedElements);
|
1361
|
+
this.elements = transpiledElements.map(el => this.processElementMetadata(el)).filter(isDefined);
|
1362
|
+
this.renderableElements = this.getRenderableElements(this.elements);
|
1363
|
+
}
|
1364
|
+
addElement(element) {
|
1365
|
+
if (element.isShared) {
|
1366
|
+
return;
|
1367
|
+
}
|
1368
|
+
const transpiledElements = this.transpileScripts([element]);
|
1369
|
+
this.elements = transpiledElements.map(el => this.processElementMetadata(el)).filter(isDefined);
|
1107
1370
|
this.renderableElements = this.getRenderableElements(this.elements);
|
1108
1371
|
}
|
1109
1372
|
getNgComponents() {
|
1110
|
-
return this.renderableElements.map(el => this.resolveElement(el)).filter(
|
1373
|
+
return this.renderableElements.map(el => this.resolveElement(el)).filter(isDefined);
|
1111
1374
|
}
|
1112
1375
|
transpile(el) {
|
1113
1376
|
var _a;
|
@@ -1174,9 +1437,7 @@ class ElementsResolver {
|
|
1174
1437
|
}
|
1175
1438
|
finalElement.template = this.resolveElementTemplate(finalElement);
|
1176
1439
|
finalElement.styles = this.resolveElementStyles(finalElement);
|
1177
|
-
return Object.assign(Object.assign({}, finalElement), { children: finalElement.children
|
1178
|
-
.map(child => this.processElementMetadata(child))
|
1179
|
-
.filter(Boolean) });
|
1440
|
+
return Object.assign(Object.assign({}, finalElement), { children: finalElement.children.map(child => this.processElementMetadata(child)).filter(isDefined) });
|
1180
1441
|
}
|
1181
1442
|
getSharedChildren(children, parentPath) {
|
1182
1443
|
return children.map(c => {
|
@@ -1236,202 +1497,298 @@ class ElementsResolver {
|
|
1236
1497
|
}
|
1237
1498
|
}
|
1238
1499
|
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
this.moduleInstance = m;
|
1251
|
-
}), map(m => ({ module: m, elements: elementsResolver.elements })));
|
1252
|
-
}
|
1253
|
-
destroy() {
|
1254
|
-
if (this.moduleInstance) {
|
1255
|
-
this.dynamicModuleService.clear();
|
1256
|
-
this.moduleInstance = undefined;
|
1257
|
-
}
|
1258
|
-
if (this.module) {
|
1259
|
-
this.compiler.clearCacheFor(this.module);
|
1260
|
-
this.module = undefined;
|
1500
|
+
const defaultOptions = {
|
1501
|
+
suppressLoading: false,
|
1502
|
+
loadingLabel: 'LOADING',
|
1503
|
+
};
|
1504
|
+
|
1505
|
+
const moduleMap = {};
|
1506
|
+
function loadRemoteEntry(remoteEntry) {
|
1507
|
+
return new Promise((resolve, reject) => {
|
1508
|
+
if (moduleMap[remoteEntry]) {
|
1509
|
+
resolve();
|
1510
|
+
return;
|
1261
1511
|
}
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1512
|
+
const script = document.createElement('script');
|
1513
|
+
script.src = remoteEntry;
|
1514
|
+
script.onerror = reject;
|
1515
|
+
script.onload = () => {
|
1516
|
+
moduleMap[remoteEntry] = true;
|
1517
|
+
resolve(); // window is the global namespace
|
1266
1518
|
};
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1519
|
+
document.body.append(script);
|
1520
|
+
});
|
1521
|
+
}
|
1522
|
+
function lookupExposedModule(remoteName, exposedModule) {
|
1523
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1524
|
+
// Initializes the share scope. This fills it with known provided modules from this build and all remotes
|
1525
|
+
yield __webpack_init_sharing__('default');
|
1526
|
+
const container = window[remoteName]; // or get the container somewhere else
|
1527
|
+
// Initialize the container, it may provide shared modules
|
1528
|
+
yield container.init(__webpack_share_scopes__.default);
|
1529
|
+
const factory = yield container.get(exposedModule);
|
1530
|
+
const Module = factory();
|
1531
|
+
return Module;
|
1532
|
+
});
|
1533
|
+
}
|
1534
|
+
function loadRemoteModule(remoteEntry, remoteName, exposedModule) {
|
1535
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1536
|
+
yield loadRemoteEntry(remoteEntry);
|
1537
|
+
return yield lookupExposedModule(remoteName, exposedModule);
|
1538
|
+
});
|
1276
1539
|
}
|
1277
|
-
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 });
|
1278
|
-
LauncherService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LauncherService });
|
1279
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LauncherService, decorators: [{
|
1280
|
-
type: Injectable
|
1281
|
-
}], ctorParameters: function () { return [{ type: i0.Compiler }, { type: DynamicModuleService }]; } });
|
1282
1540
|
|
1283
|
-
class
|
1284
|
-
constructor(
|
1285
|
-
this.
|
1286
|
-
this.
|
1287
|
-
this.
|
1288
|
-
this.
|
1289
|
-
this.
|
1290
|
-
|
1291
|
-
this.
|
1292
|
-
this.
|
1293
|
-
this.destroy$ = new Subject();
|
1294
|
-
}
|
1295
|
-
ngOnInit() {
|
1296
|
-
if (this.clearState) {
|
1297
|
-
this.integrationState.clear();
|
1298
|
-
}
|
1299
|
-
this.startPreview();
|
1300
|
-
}
|
1301
|
-
ngOnDestroy() {
|
1302
|
-
this.destroy$.next();
|
1303
|
-
this.destroy$.complete();
|
1304
|
-
this.configurationService.reset();
|
1541
|
+
class FederatedComponent {
|
1542
|
+
constructor(injector, compiler, appRef, renderer) {
|
1543
|
+
this.injector = injector;
|
1544
|
+
this.compiler = compiler;
|
1545
|
+
this.appRef = appRef;
|
1546
|
+
this.renderer = renderer;
|
1547
|
+
this.isLoading$ = new BehaviorSubject(false);
|
1548
|
+
// configs
|
1549
|
+
this.suppressLoading = defaultOptions.suppressLoading;
|
1550
|
+
this.loadingLabel = defaultOptions.loadingLabel;
|
1305
1551
|
}
|
1306
|
-
|
1307
|
-
|
1308
|
-
if (
|
1309
|
-
|
1552
|
+
ngOnChanges(changes) {
|
1553
|
+
var _a, _b, _c, _d;
|
1554
|
+
if (changes.data && this.instance) {
|
1555
|
+
this.instance.data = this.data;
|
1310
1556
|
}
|
1311
|
-
if (
|
1312
|
-
|
1313
|
-
|
1557
|
+
if (changes.options) {
|
1558
|
+
this.suppressLoading = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.suppressLoading) !== null && _b !== void 0 ? _b : defaultOptions.suppressLoading;
|
1559
|
+
this.loadingLabel = (_d = (_c = this.options) === null || _c === void 0 ? void 0 : _c.loadingLabel) !== null && _d !== void 0 ? _d : defaultOptions.loadingLabel;
|
1314
1560
|
}
|
1315
|
-
// If still not initialized - init configuration in Test mode
|
1316
|
-
return this.runtimeService
|
1317
|
-
.initTestMode(this.modelId, this.uiDefinition)
|
1318
|
-
.pipe(switchMap(() => this.configurationService.configure()));
|
1319
1561
|
}
|
1320
|
-
|
1321
|
-
|
1322
|
-
try {
|
1323
|
-
return elements.map(element => elementToMetadata(element));
|
1324
|
-
}
|
1325
|
-
catch (e) {
|
1326
|
-
console.error(e);
|
1327
|
-
if (!((_b = (_a = this.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.suppressToastMessages)) {
|
1328
|
-
this.messageService.add({ severity: 'error', summary: String(e) });
|
1329
|
-
}
|
1330
|
-
return [];
|
1331
|
-
}
|
1562
|
+
ngOnInit() {
|
1563
|
+
this.isLoading$.next(true);
|
1332
1564
|
}
|
1333
|
-
|
1334
|
-
|
1565
|
+
ngAfterViewInit() {
|
1566
|
+
var _a, _b, _c, _d, _e, _f;
|
1567
|
+
const remoteEntry = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.remoteEntry) !== null && _b !== void 0 ? _b : this.remoteEntry;
|
1568
|
+
const remoteName = (_d = (_c = this.options) === null || _c === void 0 ? void 0 : _c.remoteName) !== null && _d !== void 0 ? _d : this.remoteName;
|
1569
|
+
const exposedModule = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.exposedModule) !== null && _f !== void 0 ? _f : this.exposedModule;
|
1570
|
+
if (!remoteEntry || !remoteName || !exposedModule) {
|
1335
1571
|
return;
|
1336
1572
|
}
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
this.
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
}), takeUntil(this.destroy$))
|
1353
|
-
.subscribe();
|
1573
|
+
loadRemoteModule(remoteEntry, remoteName, exposedModule).then(federated => {
|
1574
|
+
this.compiler.compileModuleAsync(federated[exposedModule]).then(moduleFactory => {
|
1575
|
+
var _a, _b, _c;
|
1576
|
+
const rootModuleRef = moduleFactory.create(this.injector);
|
1577
|
+
const rootComponentFactory = rootModuleRef.componentFactoryResolver.resolveComponentFactory(federated[exposedModule].rootComponent);
|
1578
|
+
const node = document.createElement('div');
|
1579
|
+
const { instance, hostView } = rootComponentFactory.create(this.injector, [], node);
|
1580
|
+
this.instance = instance;
|
1581
|
+
this.instance.data = this.data;
|
1582
|
+
this.renderer.appendChild((_a = this.moduleHostRef) === null || _a === void 0 ? void 0 : _a.nativeElement, node);
|
1583
|
+
this.appRef.attachView(hostView);
|
1584
|
+
(_c = (_b = this.options) === null || _b === void 0 ? void 0 : _b.onReady) === null || _c === void 0 ? void 0 : _c.call(_b);
|
1585
|
+
this.isLoading$.next(false);
|
1586
|
+
});
|
1587
|
+
});
|
1354
1588
|
}
|
1355
1589
|
}
|
1356
|
-
|
1357
|
-
|
1358
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1590
|
+
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 });
|
1591
|
+
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 });
|
1592
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FederatedComponent, decorators: [{
|
1359
1593
|
type: Component,
|
1360
1594
|
args: [{
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1595
|
+
// eslint-disable-next-line @angular-eslint/component-selector
|
1596
|
+
selector: 'veloce-host-federated',
|
1597
|
+
templateUrl: './federated.component.html',
|
1598
|
+
styleUrls: ['./federated.component.scss'],
|
1364
1599
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
1365
|
-
providers: [IOProviderService, TemplatesService],
|
1366
|
-
// use shadow DOM to prevent UI from being affected by global styles
|
1367
|
-
encapsulation: ViewEncapsulation.ShadowDom,
|
1368
1600
|
}]
|
1369
|
-
}], ctorParameters: function () { return [{ type:
|
1601
|
+
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.Compiler }, { type: i0.ApplicationRef }, { type: i0.Renderer2 }]; }, propDecorators: { moduleHostRef: [{
|
1602
|
+
type: ViewChild,
|
1603
|
+
args: ['moduleHost', { static: false }]
|
1604
|
+
}], remoteEntry: [{
|
1370
1605
|
type: Input
|
1371
|
-
}],
|
1606
|
+
}], remoteName: [{
|
1607
|
+
type: Input
|
1608
|
+
}], exposedModule: [{
|
1609
|
+
type: Input
|
1610
|
+
}], data: [{
|
1372
1611
|
type: Input
|
1373
|
-
}],
|
1612
|
+
}], options: [{
|
1374
1613
|
type: Input
|
1375
1614
|
}] } });
|
1376
1615
|
|
1377
|
-
class
|
1616
|
+
class FederatedModule {
|
1378
1617
|
}
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1618
|
+
FederatedModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FederatedModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1619
|
+
FederatedModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FederatedModule, declarations: [FederatedComponent], imports: [CommonModule, LoaderModule], exports: [FederatedComponent] });
|
1620
|
+
FederatedModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FederatedModule, imports: [[CommonModule, LoaderModule]] });
|
1621
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FederatedModule, decorators: [{
|
1383
1622
|
type: NgModule,
|
1384
1623
|
args: [{
|
1385
|
-
declarations: [
|
1386
|
-
|
1624
|
+
declarations: [FederatedComponent],
|
1625
|
+
imports: [CommonModule, LoaderModule],
|
1626
|
+
exports: [FederatedComponent],
|
1387
1627
|
}]
|
1388
1628
|
}] });
|
1389
1629
|
|
1390
|
-
class
|
1630
|
+
class CompilationService {
|
1631
|
+
constructor(compiler) {
|
1632
|
+
this.compiler = compiler;
|
1633
|
+
}
|
1634
|
+
compileUIDefinition$(uiDefinition) {
|
1635
|
+
return of([]).pipe(switchMap(() => {
|
1636
|
+
const { children, pages, components } = uiDefinition, uiDefinitionMeta = __rest(uiDefinition, ["children", "pages", "components"]);
|
1637
|
+
this.uiDefinitionMeta = uiDefinitionMeta;
|
1638
|
+
const elements = [...(children !== null && children !== void 0 ? children : []), ...(pages !== null && pages !== void 0 ? pages : [])];
|
1639
|
+
const sharedElements = components !== null && components !== void 0 ? components : [];
|
1640
|
+
const metadata = elements.map(element => elementToMetadata(element));
|
1641
|
+
const sharedMetadata = sharedElements.map(element => elementToMetadata(element));
|
1642
|
+
this.elementsResolver = new ElementsResolver(uiDefinition, metadata, sharedMetadata);
|
1643
|
+
const module = this.getModule(this.elementsResolver.getNgComponents());
|
1644
|
+
return combineLatest([
|
1645
|
+
from(this.compiler.compileModuleAndAllComponentsAsync(module)),
|
1646
|
+
of(this.elementsResolver),
|
1647
|
+
]);
|
1648
|
+
}), map(([module, elementsResolver]) => ({ module, elements: elementsResolver.elements })));
|
1649
|
+
}
|
1650
|
+
compileElement$(element) {
|
1651
|
+
if (!this.uiDefinitionMeta) {
|
1652
|
+
throw 'No UI Definition context';
|
1653
|
+
}
|
1654
|
+
return of(this.uiDefinitionMeta).pipe(switchMap(uiDefinition => {
|
1655
|
+
var _a;
|
1656
|
+
const elementsResolver = (_a = this.elementsResolver) !== null && _a !== void 0 ? _a : new ElementsResolver(uiDefinition, []);
|
1657
|
+
elementsResolver.addElement(element);
|
1658
|
+
const module = this.getModule(elementsResolver.getNgComponents());
|
1659
|
+
return combineLatest([from(this.compiler.compileModuleAndAllComponentsAsync(module)), of(elementsResolver)]);
|
1660
|
+
}), map(([module, elementsResolver]) => ({ module, elements: elementsResolver.elements })));
|
1661
|
+
}
|
1662
|
+
clearModuleCache(modules) {
|
1663
|
+
modules.forEach(module => this.compiler.clearCacheFor(module));
|
1664
|
+
this.uiDefinitionMeta = undefined;
|
1665
|
+
}
|
1666
|
+
getModule(components) {
|
1667
|
+
const staticComponents = [
|
1668
|
+
ElementChildrenComponent,
|
1669
|
+
ElementRendererComponent,
|
1670
|
+
ElementDropHandleComponent,
|
1671
|
+
CustomTemplateDirective,
|
1672
|
+
];
|
1673
|
+
let DynamicModule = class DynamicModule {
|
1674
|
+
};
|
1675
|
+
DynamicModule = __decorate([
|
1676
|
+
NgModule({
|
1677
|
+
imports: [
|
1678
|
+
CommonModule,
|
1679
|
+
FormsModule,
|
1680
|
+
ReactiveFormsModule,
|
1681
|
+
FederatedModule,
|
1682
|
+
DragDropModule,
|
1683
|
+
DndModule,
|
1684
|
+
ScrollingModule,
|
1685
|
+
],
|
1686
|
+
declarations: [...staticComponents, ...components],
|
1687
|
+
jit: true,
|
1688
|
+
})
|
1689
|
+
], DynamicModule);
|
1690
|
+
return DynamicModule;
|
1691
|
+
}
|
1692
|
+
}
|
1693
|
+
CompilationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: CompilationService, deps: [{ token: i0.Compiler }], target: i0.ɵɵFactoryTarget.Injectable });
|
1694
|
+
CompilationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: CompilationService });
|
1695
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: CompilationService, decorators: [{
|
1696
|
+
type: Injectable
|
1697
|
+
}], ctorParameters: function () { return [{ type: i0.Compiler }]; } });
|
1698
|
+
|
1699
|
+
class RuntimeModule {
|
1391
1700
|
}
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1701
|
+
RuntimeModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1702
|
+
RuntimeModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeModule, imports: [CommonModule, CoreModule] });
|
1703
|
+
RuntimeModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeModule, providers: [
|
1704
|
+
DialogService,
|
1705
|
+
RuntimeService,
|
1706
|
+
RuntimeEditorService,
|
1707
|
+
{ provide: CMS_COMPILATION_SERVICE, useClass: CompilationService },
|
1708
|
+
], imports: [[CommonModule, CoreModule]] });
|
1709
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeModule, decorators: [{
|
1396
1710
|
type: NgModule,
|
1397
1711
|
args: [{
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1712
|
+
imports: [CommonModule, CoreModule],
|
1713
|
+
providers: [
|
1714
|
+
DialogService,
|
1715
|
+
RuntimeService,
|
1716
|
+
RuntimeEditorService,
|
1717
|
+
{ provide: CMS_COMPILATION_SERVICE, useClass: CompilationService },
|
1718
|
+
],
|
1401
1719
|
}]
|
1402
1720
|
}] });
|
1403
1721
|
|
1404
|
-
class
|
1722
|
+
class LauncherModule {
|
1405
1723
|
}
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1724
|
+
LauncherModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LauncherModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1725
|
+
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] });
|
1726
|
+
LauncherModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LauncherModule, providers: [IntegrationState, DialogService, ResourcesService], imports: [[CommonModule, CoreModule, ApiModule, SdkCoreModule, RuntimeModule, PreviewModule], PreviewModule] });
|
1727
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: LauncherModule, decorators: [{
|
1410
1728
|
type: NgModule,
|
1411
1729
|
args: [{
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
exports: [PreviewComponent],
|
1730
|
+
imports: [CommonModule, CoreModule, ApiModule, SdkCoreModule, RuntimeModule, PreviewModule],
|
1731
|
+
providers: [IntegrationState, DialogService, ResourcesService],
|
1732
|
+
exports: [PreviewModule],
|
1416
1733
|
}]
|
1417
1734
|
}] });
|
1418
1735
|
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
}
|
1736
|
+
const migrations = {
|
1737
|
+
2: () => {
|
1738
|
+
throw 'Migration from Legacy UI definition is not possible';
|
1739
|
+
},
|
1740
|
+
3: uiDef => {
|
1741
|
+
var _a;
|
1742
|
+
const children = (_a = uiDef.children) !== null && _a !== void 0 ? _a : [];
|
1743
|
+
return Object.assign(Object.assign({}, uiDef), { children: undefined, pages: children, version: 3 });
|
1744
|
+
},
|
1745
|
+
};
|
1746
|
+
|
1747
|
+
class MigrationsService {
|
1748
|
+
constructor(toastService) {
|
1749
|
+
this.toastService = toastService;
|
1750
|
+
}
|
1751
|
+
migrateUIDefinition(uiDef) {
|
1752
|
+
const currentVersion = uiDef.version;
|
1753
|
+
const targetVersion = UI_DEFINITION_VERSION;
|
1754
|
+
const migrateVersions = Object.keys(migrations)
|
1755
|
+
.reduce((acc, version) => {
|
1756
|
+
const v = Number(version);
|
1757
|
+
if (v > currentVersion && v <= targetVersion) {
|
1758
|
+
acc.push(v);
|
1759
|
+
}
|
1760
|
+
return acc;
|
1761
|
+
}, [])
|
1762
|
+
.sort();
|
1763
|
+
try {
|
1764
|
+
let result = cloneDeep(uiDef);
|
1765
|
+
for (const version of migrateVersions) {
|
1766
|
+
result = migrations[version](result);
|
1767
|
+
}
|
1768
|
+
return result;
|
1769
|
+
}
|
1770
|
+
catch (e) {
|
1771
|
+
this.toastService.add({ summary: String(e), severity: ToastType.error });
|
1772
|
+
return;
|
1773
|
+
}
|
1774
|
+
}
|
1423
1775
|
}
|
1776
|
+
MigrationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsService, deps: [{ token: i1.ToastService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1777
|
+
MigrationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsService, providedIn: 'root' });
|
1778
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsService, decorators: [{
|
1779
|
+
type: Injectable,
|
1780
|
+
args: [{ providedIn: 'root' }]
|
1781
|
+
}], ctorParameters: function () { return [{ type: i1.ToastService }]; } });
|
1424
1782
|
|
1425
|
-
class
|
1783
|
+
class MigrationsModule {
|
1426
1784
|
}
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1785
|
+
MigrationsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1786
|
+
MigrationsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsModule });
|
1787
|
+
MigrationsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsModule, providers: [MigrationsService] });
|
1788
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MigrationsModule, decorators: [{
|
1431
1789
|
type: NgModule,
|
1432
1790
|
args: [{
|
1433
|
-
|
1434
|
-
providers: [LauncherService, IntegrationState, DynamicModuleService, DialogService],
|
1791
|
+
providers: [MigrationsService],
|
1435
1792
|
}]
|
1436
1793
|
}] });
|
1437
1794
|
|
@@ -1439,5 +1796,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
1439
1796
|
* Generated bundle index. Do not edit.
|
1440
1797
|
*/
|
1441
1798
|
|
1442
|
-
export { ApplyProductConfigurationAction, CloseDocGenAction, ConfigureProductAction, DEFAULT_PLUGINS_TOKEN, ELEMENT_CONFIG, ELEMENT_METADATA, ElementComponent, ElementDefinition, ElementsResolver, FlowAction, IntegrationState, LauncherModule,
|
1799
|
+
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, ResourcesService, RuntimeEditorService, RuntimeModule, SHARED_ELEMENT_METADATA, 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 };
|
1443
1800
|
//# sourceMappingURL=veloceapps-sdk-cms.js.map
|