@veloceapps/sdk 8.0.0-107 → 8.0.0-109

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ import { __decorate, __param, __metadata } 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, { cloneDeep, compact, 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;
@@ -1019,7 +1019,9 @@ class PreviewComponent {
1019
1019
  ngOnDestroy() {
1020
1020
  this.destroy$.next();
1021
1021
  this.destroy$.complete();
1022
- this.configurationState.cleanup();
1022
+ if (!this.config?.persistConfigurationState) {
1023
+ this.configurationState.cleanup();
1024
+ }
1023
1025
  this.runtimeService.clear();
1024
1026
  }
1025
1027
  trackBy(_, el) {
@@ -1973,6 +1975,35 @@ function getElementAngularIOs(names) {
1973
1975
  }, []);
1974
1976
  }
1975
1977
 
1978
+ class ElementMetadataWorker {
1979
+ constructor(elements) {
1980
+ this.elements = elements;
1981
+ }
1982
+ get$() {
1983
+ return from((async () => this.processAsync(this.elements))());
1984
+ }
1985
+ async processAsync(elements) {
1986
+ const result = [];
1987
+ await this.processLevelAsync(elements, result);
1988
+ return result;
1989
+ }
1990
+ async processLevelAsync(elements, metadata, parentPath) {
1991
+ for (const el of elements) {
1992
+ const elMetadata = await this.elementToMetadataAsync(el, parentPath);
1993
+ metadata.push(elMetadata);
1994
+ await this.processLevelAsync(el.children, elMetadata.children, elMetadata.path);
1995
+ }
1996
+ }
1997
+ elementToMetadataAsync(el, parentPath) {
1998
+ return new Promise(resolve => {
1999
+ setTimeout(() => {
2000
+ const metadata = elementToMetadata({ script: el.script, template: el.template, styles: el.styles, children: [] }, parentPath);
2001
+ resolve(metadata);
2002
+ });
2003
+ });
2004
+ }
2005
+ }
2006
+
1976
2007
  class ConfigurationPlugin {
1977
2008
  constructor(host) {
1978
2009
  this.host = host;
@@ -2077,18 +2108,66 @@ const DEFAULT_PLUGINS = {
2077
2108
  DEFAULT: [],
2078
2109
  };
2079
2110
 
2111
+ class TranspilationWorker {
2112
+ constructor(elements) {
2113
+ this.elements = elements;
2114
+ }
2115
+ get$() {
2116
+ return from((async () => this.transpileScriptsAsync(this.elements))());
2117
+ }
2118
+ get() {
2119
+ return this.transpileScripts(this.elements);
2120
+ }
2121
+ transpileScripts(elements) {
2122
+ return elements.map(el => ({
2123
+ ...el,
2124
+ script: this.transpile(el),
2125
+ children: this.transpileScripts(el.children),
2126
+ }));
2127
+ }
2128
+ async transpileScriptsAsync(elements) {
2129
+ const result = [];
2130
+ await this.processLevelAsync(elements, result);
2131
+ return result;
2132
+ }
2133
+ async processLevelAsync(elements, result) {
2134
+ for (const el of elements) {
2135
+ const elMetadata = await this.transpileMetadataAsync(el);
2136
+ result.push(elMetadata);
2137
+ await this.processLevelAsync(el.children, elMetadata.children);
2138
+ }
2139
+ }
2140
+ transpileMetadataAsync(el) {
2141
+ return new Promise(resolve => {
2142
+ setTimeout(() => {
2143
+ const result = { ...el, script: this.transpile(el), children: [] };
2144
+ resolve(result);
2145
+ });
2146
+ });
2147
+ }
2148
+ transpile(el) {
2149
+ if (!el.script) {
2150
+ return;
2151
+ }
2152
+ const transformed = transform(el.script, {
2153
+ filename: el.name + '.ts',
2154
+ presets: ['typescript'],
2155
+ sourceMaps: 'inline',
2156
+ });
2157
+ return transformed.code ?? undefined;
2158
+ }
2159
+ }
2160
+
2080
2161
  class ElementsResolver {
2081
2162
  constructor(uiDef, elements, sharedElements = [], config) {
2082
2163
  this.uiDef = uiDef;
2083
2164
  this.config = config;
2084
2165
  this.renderableElements = [];
2085
2166
  this.sharedElements = [];
2086
- const transpiledElements = this.transpileScripts(elements);
2087
- const transpiledSharedElements = this.transpileScripts(sharedElements);
2088
- this.sharedElements = this.flattenElements(transpiledElements)
2167
+ this.sharedElements = this.flattenElements(elements)
2089
2168
  .filter(el => this.isSharedElement(el))
2090
- .concat(transpiledSharedElements);
2091
- this.elements = transpiledElements.map(el => this.processElementMetadata(el)).filter(isDefined);
2169
+ .concat(sharedElements);
2170
+ this.elements = elements.map(el => this.processElementMetadata(el)).filter(isDefined);
2092
2171
  this.renderableElements = this.getRenderableElements(this.elements);
2093
2172
  this.uiDefMetadata = {
2094
2173
  ...this.uiDef,
@@ -2099,7 +2178,7 @@ class ElementsResolver {
2099
2178
  if (element.isShared) {
2100
2179
  return;
2101
2180
  }
2102
- const transpiledElements = this.transpileScripts([element]);
2181
+ const transpiledElements = new TranspilationWorker([element]).get();
2103
2182
  this.elements = transpiledElements.map(el => this.processElementMetadata(el)).filter(isDefined);
2104
2183
  this.renderableElements = this.getRenderableElements(this.elements);
2105
2184
  }
@@ -2109,24 +2188,6 @@ class ElementsResolver {
2109
2188
  [el.path]: this.resolveElement(el),
2110
2189
  }), {});
2111
2190
  }
2112
- transpile(el) {
2113
- if (!el.script) {
2114
- return;
2115
- }
2116
- const transformed = transform(el.script, {
2117
- filename: el.name + '.ts',
2118
- presets: ['typescript'],
2119
- sourceMaps: 'inline',
2120
- });
2121
- return transformed.code ?? undefined;
2122
- }
2123
- transpileScripts(elements) {
2124
- return elements.map(el => ({
2125
- ...el,
2126
- script: this.transpile(el),
2127
- children: this.transpileScripts(el.children),
2128
- }));
2129
- }
2130
2191
  flattenElements(elements) {
2131
2192
  return flatten(elements.map(el => [el, ...this.flattenElements(el.children)]));
2132
2193
  }
@@ -2434,8 +2495,8 @@ class CompilationService {
2434
2495
  this.uiDefinitionMeta = uiDefinitionMeta;
2435
2496
  const elements = [...(children ?? []), ...(pages ?? [])];
2436
2497
  const sharedElements = components ?? [];
2437
- const metadata = elements.map(element => elementToMetadata(element));
2438
- const sharedMetadata = sharedElements.map(element => elementToMetadata(element));
2498
+ return [elements, sharedElements];
2499
+ }), switchMap(elementsChunks => combineLatest(elementsChunks.map(chunk => new ElementMetadataWorker(chunk).get$()))), switchMap(dataChunks => combineLatest(dataChunks.map(chunk => new TranspilationWorker(chunk).get$()))), map(([metadata, sharedMetadata]) => {
2439
2500
  this.elementsResolver = new ElementsResolver(uiDefinition, metadata, sharedMetadata, config);
2440
2501
  const componentTypes = this.elementsResolver.getNgComponents();
2441
2502
  const module = this.getModule(componentTypes);
@@ -2679,5 +2740,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
2679
2740
  * Generated bundle index. Do not edit.
2680
2741
  */
2681
2742
 
2682
- 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 };
2743
+ 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 };
2683
2744
  //# sourceMappingURL=veloceapps-sdk-cms.mjs.map