@veloceapps/sdk 8.0.0-108 → 8.0.0-109
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cms/components/preview/preview.types.d.ts +4 -0
- package/cms/utils/element-metadata-worker.d.ts +11 -0
- package/cms/utils/elements-resolver.d.ts +0 -2
- package/cms/utils/index.d.ts +2 -0
- package/cms/utils/transpilation-worker.d.ts +13 -0
- package/esm2020/cms/components/preview/preview.component.mjs +5 -3
- package/esm2020/cms/components/preview/preview.types.mjs +1 -1
- package/esm2020/cms/modules/runtime/services/compilation.service.mjs +6 -6
- package/esm2020/cms/utils/element-metadata-worker.mjs +31 -0
- package/esm2020/cms/utils/elements-resolver.mjs +7 -27
- package/esm2020/cms/utils/index.mjs +3 -1
- package/esm2020/cms/utils/transpilation-worker.mjs +52 -0
- package/fesm2015/veloceapps-sdk-cms.mjs +99 -29
- package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-cms.mjs +91 -30
- package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as i2 from '@veloceapps/sdk/core';
|
|
2
2
|
import { IntegrationState, ConfigurationService, ConfigurationState, QuoteDraftService, FlowConfigurationService, FlowStateService, LineItemWorker, ProductImagesService, ContextService, RuntimeSettingsService, MetricsCalculationService, ActionCodePipe, DatePipe, NumberPipe, PricePipe, lineItemUtils, generateLineItem, getAttributeValue, SdkPipesModule, SdkCoreModule, UI_DEFINITION_VERSION } from '@veloceapps/sdk/core';
|
|
3
3
|
export { IntegrationState } from '@veloceapps/sdk/core';
|
|
4
|
-
import { __decorate, __param, __metadata, __rest } from 'tslib';
|
|
4
|
+
import { __decorate, __param, __metadata, __awaiter, __rest } from 'tslib';
|
|
5
5
|
import * as i0 from '@angular/core';
|
|
6
6
|
import { InjectionToken, Component, ChangeDetectionStrategy, Inject, Injector, Injectable, ViewContainerRef, SkipSelf, ViewChild, Input, ViewEncapsulation, NgModule, inject, ElementRef, Directive, ApplicationRef, createComponent, EventEmitter, createNgModule } from '@angular/core';
|
|
7
7
|
import * as rxjs from 'rxjs';
|
|
8
|
-
import { BehaviorSubject, Subject, map, distinctUntilChanged, of, tap, switchMap, startWith, takeUntil, combineLatest, catchError, ReplaySubject, noop, filter, take, Observable } from 'rxjs';
|
|
8
|
+
import { BehaviorSubject, Subject, map, distinctUntilChanged, of, tap, switchMap, startWith, takeUntil, combineLatest, catchError, ReplaySubject, noop, filter, take, Observable, from } from 'rxjs';
|
|
9
9
|
import * as i3 from '@veloceapps/components';
|
|
10
10
|
import { ToastType, LetDirectiveModule, LoaderModule, ToastService, HiddenTextTooltipModule, ErrorTooltipModule } from '@veloceapps/components';
|
|
11
11
|
import lodash, { compact, cloneDeep, isArray, pull, merge, omit, flatten, kebabCase, set } from 'lodash';
|
|
@@ -22,8 +22,8 @@ import { ScrollingModule } from '@angular/cdk/scrolling';
|
|
|
22
22
|
import * as angularForms from '@angular/forms';
|
|
23
23
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
24
24
|
import * as rxjsOperators from 'rxjs/operators';
|
|
25
|
-
import { transform } from '@babel/standalone';
|
|
26
25
|
import * as sass from 'sass';
|
|
26
|
+
import { transform } from '@babel/standalone';
|
|
27
27
|
import { loadRemoteModule } from '@angular-architects/module-federation';
|
|
28
28
|
|
|
29
29
|
var FlowAction;
|
|
@@ -1022,9 +1022,12 @@ class PreviewComponent {
|
|
|
1022
1022
|
this.startPreview();
|
|
1023
1023
|
}
|
|
1024
1024
|
ngOnDestroy() {
|
|
1025
|
+
var _a;
|
|
1025
1026
|
this.destroy$.next();
|
|
1026
1027
|
this.destroy$.complete();
|
|
1027
|
-
this.
|
|
1028
|
+
if (!((_a = this.config) === null || _a === void 0 ? void 0 : _a.persistConfigurationState)) {
|
|
1029
|
+
this.configurationState.cleanup();
|
|
1030
|
+
}
|
|
1028
1031
|
this.runtimeService.clear();
|
|
1029
1032
|
}
|
|
1030
1033
|
trackBy(_, el) {
|
|
@@ -1974,6 +1977,39 @@ function getElementAngularIOs(names) {
|
|
|
1974
1977
|
}, []);
|
|
1975
1978
|
}
|
|
1976
1979
|
|
|
1980
|
+
class ElementMetadataWorker {
|
|
1981
|
+
constructor(elements) {
|
|
1982
|
+
this.elements = elements;
|
|
1983
|
+
}
|
|
1984
|
+
get$() {
|
|
1985
|
+
return from((() => __awaiter(this, void 0, void 0, function* () { return this.processAsync(this.elements); }))());
|
|
1986
|
+
}
|
|
1987
|
+
processAsync(elements) {
|
|
1988
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1989
|
+
const result = [];
|
|
1990
|
+
yield this.processLevelAsync(elements, result);
|
|
1991
|
+
return result;
|
|
1992
|
+
});
|
|
1993
|
+
}
|
|
1994
|
+
processLevelAsync(elements, metadata, parentPath) {
|
|
1995
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1996
|
+
for (const el of elements) {
|
|
1997
|
+
const elMetadata = yield this.elementToMetadataAsync(el, parentPath);
|
|
1998
|
+
metadata.push(elMetadata);
|
|
1999
|
+
yield this.processLevelAsync(el.children, elMetadata.children, elMetadata.path);
|
|
2000
|
+
}
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
2003
|
+
elementToMetadataAsync(el, parentPath) {
|
|
2004
|
+
return new Promise(resolve => {
|
|
2005
|
+
setTimeout(() => {
|
|
2006
|
+
const metadata = elementToMetadata({ script: el.script, template: el.template, styles: el.styles, children: [] }, parentPath);
|
|
2007
|
+
resolve(metadata);
|
|
2008
|
+
});
|
|
2009
|
+
});
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
|
|
1977
2013
|
class ConfigurationPlugin {
|
|
1978
2014
|
constructor(host) {
|
|
1979
2015
|
var _a, _b;
|
|
@@ -2079,6 +2115,57 @@ const DEFAULT_PLUGINS = {
|
|
|
2079
2115
|
DEFAULT: [],
|
|
2080
2116
|
};
|
|
2081
2117
|
|
|
2118
|
+
class TranspilationWorker {
|
|
2119
|
+
constructor(elements) {
|
|
2120
|
+
this.elements = elements;
|
|
2121
|
+
}
|
|
2122
|
+
get$() {
|
|
2123
|
+
return from((() => __awaiter(this, void 0, void 0, function* () { return this.transpileScriptsAsync(this.elements); }))());
|
|
2124
|
+
}
|
|
2125
|
+
get() {
|
|
2126
|
+
return this.transpileScripts(this.elements);
|
|
2127
|
+
}
|
|
2128
|
+
transpileScripts(elements) {
|
|
2129
|
+
return elements.map(el => (Object.assign(Object.assign({}, el), { script: this.transpile(el), children: this.transpileScripts(el.children) })));
|
|
2130
|
+
}
|
|
2131
|
+
transpileScriptsAsync(elements) {
|
|
2132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2133
|
+
const result = [];
|
|
2134
|
+
yield this.processLevelAsync(elements, result);
|
|
2135
|
+
return result;
|
|
2136
|
+
});
|
|
2137
|
+
}
|
|
2138
|
+
processLevelAsync(elements, result) {
|
|
2139
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2140
|
+
for (const el of elements) {
|
|
2141
|
+
const elMetadata = yield this.transpileMetadataAsync(el);
|
|
2142
|
+
result.push(elMetadata);
|
|
2143
|
+
yield this.processLevelAsync(el.children, elMetadata.children);
|
|
2144
|
+
}
|
|
2145
|
+
});
|
|
2146
|
+
}
|
|
2147
|
+
transpileMetadataAsync(el) {
|
|
2148
|
+
return new Promise(resolve => {
|
|
2149
|
+
setTimeout(() => {
|
|
2150
|
+
const result = Object.assign(Object.assign({}, el), { script: this.transpile(el), children: [] });
|
|
2151
|
+
resolve(result);
|
|
2152
|
+
});
|
|
2153
|
+
});
|
|
2154
|
+
}
|
|
2155
|
+
transpile(el) {
|
|
2156
|
+
var _a;
|
|
2157
|
+
if (!el.script) {
|
|
2158
|
+
return;
|
|
2159
|
+
}
|
|
2160
|
+
const transformed = transform(el.script, {
|
|
2161
|
+
filename: el.name + '.ts',
|
|
2162
|
+
presets: ['typescript'],
|
|
2163
|
+
sourceMaps: 'inline',
|
|
2164
|
+
});
|
|
2165
|
+
return (_a = transformed.code) !== null && _a !== void 0 ? _a : undefined;
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2082
2169
|
class ElementsResolver {
|
|
2083
2170
|
constructor(uiDef, elements, sharedElements = [], config) {
|
|
2084
2171
|
var _a;
|
|
@@ -2086,12 +2173,10 @@ class ElementsResolver {
|
|
|
2086
2173
|
this.config = config;
|
|
2087
2174
|
this.renderableElements = [];
|
|
2088
2175
|
this.sharedElements = [];
|
|
2089
|
-
|
|
2090
|
-
const transpiledSharedElements = this.transpileScripts(sharedElements);
|
|
2091
|
-
this.sharedElements = this.flattenElements(transpiledElements)
|
|
2176
|
+
this.sharedElements = this.flattenElements(elements)
|
|
2092
2177
|
.filter(el => this.isSharedElement(el))
|
|
2093
|
-
.concat(
|
|
2094
|
-
this.elements =
|
|
2178
|
+
.concat(sharedElements);
|
|
2179
|
+
this.elements = elements.map(el => this.processElementMetadata(el)).filter(isDefined);
|
|
2095
2180
|
this.renderableElements = this.getRenderableElements(this.elements);
|
|
2096
2181
|
this.uiDefMetadata = Object.assign(Object.assign({}, this.uiDef), { customization: (_a = this.uiDef.customization) !== null && _a !== void 0 ? _a : this.getDefaultCustomizationState() });
|
|
2097
2182
|
}
|
|
@@ -2099,28 +2184,13 @@ class ElementsResolver {
|
|
|
2099
2184
|
if (element.isShared) {
|
|
2100
2185
|
return;
|
|
2101
2186
|
}
|
|
2102
|
-
const transpiledElements =
|
|
2187
|
+
const transpiledElements = new TranspilationWorker([element]).get();
|
|
2103
2188
|
this.elements = transpiledElements.map(el => this.processElementMetadata(el)).filter(isDefined);
|
|
2104
2189
|
this.renderableElements = this.getRenderableElements(this.elements);
|
|
2105
2190
|
}
|
|
2106
2191
|
getNgComponents() {
|
|
2107
2192
|
return [...this.renderableElements, ...this.sharedElements].filter(isDefined).reduce((trunk, el) => (Object.assign(Object.assign({}, trunk), { [el.path]: this.resolveElement(el) })), {});
|
|
2108
2193
|
}
|
|
2109
|
-
transpile(el) {
|
|
2110
|
-
var _a;
|
|
2111
|
-
if (!el.script) {
|
|
2112
|
-
return;
|
|
2113
|
-
}
|
|
2114
|
-
const transformed = transform(el.script, {
|
|
2115
|
-
filename: el.name + '.ts',
|
|
2116
|
-
presets: ['typescript'],
|
|
2117
|
-
sourceMaps: 'inline',
|
|
2118
|
-
});
|
|
2119
|
-
return (_a = transformed.code) !== null && _a !== void 0 ? _a : undefined;
|
|
2120
|
-
}
|
|
2121
|
-
transpileScripts(elements) {
|
|
2122
|
-
return elements.map(el => (Object.assign(Object.assign({}, el), { script: this.transpile(el), children: this.transpileScripts(el.children) })));
|
|
2123
|
-
}
|
|
2124
2194
|
flattenElements(elements) {
|
|
2125
2195
|
return flatten(elements.map(el => [el, ...this.flattenElements(el.children)]));
|
|
2126
2196
|
}
|
|
@@ -2390,13 +2460,13 @@ class CompilationService {
|
|
|
2390
2460
|
}
|
|
2391
2461
|
compileUIDefinition$(uiDefinition, config) {
|
|
2392
2462
|
return of([]).pipe(map(() => {
|
|
2393
|
-
var _a, _b;
|
|
2394
2463
|
const { children, pages, components } = uiDefinition, uiDefinitionMeta = __rest(uiDefinition, ["children", "pages", "components"]);
|
|
2395
2464
|
this.uiDefinitionMeta = uiDefinitionMeta;
|
|
2396
2465
|
const elements = [...(children !== null && children !== void 0 ? children : []), ...(pages !== null && pages !== void 0 ? pages : [])];
|
|
2397
2466
|
const sharedElements = components !== null && components !== void 0 ? components : [];
|
|
2398
|
-
|
|
2399
|
-
|
|
2467
|
+
return [elements, sharedElements];
|
|
2468
|
+
}), switchMap(elementsChunks => combineLatest(elementsChunks.map(chunk => new ElementMetadataWorker(chunk).get$()))), switchMap(dataChunks => combineLatest(dataChunks.map(chunk => new TranspilationWorker(chunk).get$()))), map(([metadata, sharedMetadata]) => {
|
|
2469
|
+
var _a, _b;
|
|
2400
2470
|
this.elementsResolver = new ElementsResolver(uiDefinition, metadata, sharedMetadata, config);
|
|
2401
2471
|
const componentTypes = this.elementsResolver.getNgComponents();
|
|
2402
2472
|
const module = this.getModule(componentTypes);
|
|
@@ -2566,5 +2636,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
2566
2636
|
* Generated bundle index. Do not edit.
|
|
2567
2637
|
*/
|
|
2568
2638
|
|
|
2569
|
-
export { ApplyProductConfigurationAction, CloseDocGenAction, CmsAction, ConfigureProductAction, DEFAULT_ELEMENT, DEFAULT_PLUGINS_TOKEN, ELEMENT_CONFIG, ELEMENT_METADATA, ElementComponent, ElementDefinition, ElementsResolver, FlowAction, LAYOUT, LauncherModule, MigrationsModule, MigrationsService, NavigateBackAction, NavigateToCatalogAction, OpenDocGenAction, PreviewComponent, PreviewModule, RemoteApplyAction, RemoteCancelAction, ResourcesService, RuntimeEditorService, RuntimeModule, RuntimeService, SHARED_ELEMENT_METADATA, STARTING_PAGE_LAYOUT, STARTING_PAGE_NAME, STARTING_PAGE_STYLES, STARTING_PAGE_TYPE, SwitchObjectAction, TemplatesService, UI_DEFINITION_METADATA, UiBuildError, atobSafe, btoaSafe, constructPage, constructPageChildren, constructRegion, doesElementSupportIO, elementToMetadata, extendElementMetadata, extractElementMetadata, findElementByModule, findElementByPath, flattenElements, getAbsolutePath, getElementAngularIOs, getElementConfig, insertElement, isElementAngularIO, isSharedElement, isValidScript, metadataToElement, normalizeElementMetadata, parseBoundPath, parsePath, removeElement, stringifyElementMetadata, toElementAngularIO };
|
|
2639
|
+
export { ApplyProductConfigurationAction, CloseDocGenAction, CmsAction, ConfigureProductAction, DEFAULT_ELEMENT, DEFAULT_PLUGINS_TOKEN, ELEMENT_CONFIG, ELEMENT_METADATA, ElementComponent, ElementDefinition, ElementMetadataWorker, ElementsResolver, FlowAction, LAYOUT, LauncherModule, MigrationsModule, MigrationsService, NavigateBackAction, NavigateToCatalogAction, OpenDocGenAction, PreviewComponent, PreviewModule, RemoteApplyAction, RemoteCancelAction, ResourcesService, RuntimeEditorService, RuntimeModule, RuntimeService, SHARED_ELEMENT_METADATA, STARTING_PAGE_LAYOUT, STARTING_PAGE_NAME, STARTING_PAGE_STYLES, STARTING_PAGE_TYPE, SwitchObjectAction, TemplatesService, TranspilationWorker, UI_DEFINITION_METADATA, UiBuildError, atobSafe, btoaSafe, constructPage, constructPageChildren, constructRegion, doesElementSupportIO, elementToMetadata, extendElementMetadata, extractElementMetadata, findElementByModule, findElementByPath, flattenElements, getAbsolutePath, getElementAngularIOs, getElementConfig, insertElement, isElementAngularIO, isSharedElement, isValidScript, metadataToElement, normalizeElementMetadata, parseBoundPath, parsePath, removeElement, stringifyElementMetadata, toElementAngularIO };
|
|
2570
2640
|
//# sourceMappingURL=veloceapps-sdk-cms.mjs.map
|