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