@veloceapps/sdk 1.0.2 → 2.0.0
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/bundles/veloce-sdk-cms.umd.js +444 -309
- package/bundles/veloce-sdk-cms.umd.js.map +1 -1
- package/bundles/veloce-sdk-runtime.umd.js +146 -146
- package/bundles/veloce-sdk-runtime.umd.js.map +1 -1
- package/bundles/veloce-sdk.umd.js.map +1 -1
- package/cms/services/dynamic-module.service.d.ts +4 -0
- package/cms/services/io-provider.service.d.ts +3 -0
- package/cms/services/launcher.service.d.ts +0 -2
- package/cms/types/common.types.d.ts +31 -11
- package/cms/utils/elements-resolver.d.ts +16 -0
- package/cms/utils/path.utils.d.ts +4 -0
- package/esm2015/cms/cms.elements.js +6 -2
- package/esm2015/cms/components/element-children/element-children.component.js +3 -3
- package/esm2015/cms/components/element-children/element-children.module.js +4 -4
- package/esm2015/cms/components/element-renderer/element-renderer.component.js +5 -5
- 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/preview.component.js +3 -3
- package/esm2015/cms/components/preview/preview.module.js +4 -4
- package/esm2015/cms/directives/custom-template.directive.js +3 -3
- package/esm2015/cms/launcher.module.js +4 -4
- package/esm2015/cms/modules/configuration/configuration.module.js +4 -4
- package/esm2015/cms/modules/configuration/services/configuration.service.js +3 -3
- package/esm2015/cms/plugins/configuration.plugin.js +3 -3
- package/esm2015/cms/plugins/io.plugin.js +3 -3
- package/esm2015/cms/plugins/script.plugin.js +3 -3
- package/esm2015/cms/services/dynamic-module.service.js +15 -4
- package/esm2015/cms/services/element-context.service.js +3 -3
- package/esm2015/cms/services/io-provider.service.js +17 -17
- package/esm2015/cms/services/launcher.service.js +12 -49
- package/esm2015/cms/services/templates.service.js +3 -3
- package/esm2015/cms/types/common.types.js +1 -1
- package/esm2015/cms/utils/elements-resolver.js +81 -0
- package/esm2015/cms/utils/path.utils.js +52 -0
- package/esm2015/runtime/components/component-preview/component-preview.component.js +3 -3
- 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 +3 -3
- 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 +3 -3
- package/esm2015/runtime/services/context.service.js +3 -3
- package/esm2015/runtime/services/current-state.service.js +3 -3
- package/esm2015/runtime/services/flow.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/quote.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 +3 -3
- 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/fesm2015/veloce-sdk-cms.js +391 -284
- package/fesm2015/veloce-sdk-cms.js.map +1 -1
- package/fesm2015/veloce-sdk-runtime.js +146 -146
- package/fesm2015/veloce-sdk-runtime.js.map +1 -1
- package/fesm2015/veloce-sdk.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __decorate, __param, __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, Directive, NgModule } from '@angular/core';
|
|
4
4
|
import * as rxjs from 'rxjs';
|
|
5
5
|
import { BehaviorSubject, combineLatest, of, shareReplay, throwError, Subject, takeUntil, map as map$1, from, tap as tap$1, forkJoin, catchError as catchError$1 } from 'rxjs';
|
|
6
6
|
import { EntityUtil, UUID, ConfigurationMode, ConfigurationContextMode, RuntimeModel, CoreModule } from '@veloce/core';
|
|
@@ -9,7 +9,7 @@ import { RuntimeMode, RuntimeStep, ContextService } from '@veloce/sdk/runtime';
|
|
|
9
9
|
import * as rxjsOperators from 'rxjs/operators';
|
|
10
10
|
import { first, switchMap, catchError, map, tap } from 'rxjs/operators';
|
|
11
11
|
import * as lodash from 'lodash';
|
|
12
|
-
import { compact, sortBy, isArray, pull,
|
|
12
|
+
import { compact, sortBy, isArray, pull, flatten, set } from 'lodash';
|
|
13
13
|
import * as i1 from '@veloce/api';
|
|
14
14
|
import { ContextApiService, ProductModelApiService, ConfigurationApiService } from '@veloce/api';
|
|
15
15
|
import * as i3 from 'primeng/api';
|
|
@@ -313,14 +313,98 @@ class ConfigurationService {
|
|
|
313
313
|
};
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
|
-
ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
317
|
-
ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
|
318
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
316
|
+
ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ConfigurationService, deps: [{ token: i1.ConfigurationApiService }, { token: i2.ContextService }, { token: i1.ConfigurationApiService }, { token: i3.MessageService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
317
|
+
ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ConfigurationService });
|
|
318
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ConfigurationService, decorators: [{
|
|
319
319
|
type: Injectable
|
|
320
320
|
}], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: i2.ContextService }, { type: i1.ConfigurationApiService }, { type: i3.MessageService }]; } });
|
|
321
321
|
|
|
322
|
-
|
|
322
|
+
const parsePath = (path) => {
|
|
323
|
+
var _a, _b, _c, _d;
|
|
324
|
+
const segments = path.split('/');
|
|
325
|
+
let module;
|
|
326
|
+
let variable;
|
|
327
|
+
if ((_a = segments[0]) === null || _a === void 0 ? void 0 : _a.startsWith('@')) {
|
|
328
|
+
module = (_b = segments.shift()) === null || _b === void 0 ? void 0 : _b.substring(1);
|
|
329
|
+
}
|
|
330
|
+
if (((_c = segments[segments.length - 1]) === null || _c === void 0 ? void 0 : _c[0]) === ':') {
|
|
331
|
+
variable = (_d = segments.pop()) === null || _d === void 0 ? void 0 : _d.substring(1);
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
segments,
|
|
335
|
+
module,
|
|
336
|
+
variable,
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
const findElementByModule = (elements, module, elementName) => {
|
|
340
|
+
for (const el of elements) {
|
|
341
|
+
if (el.module === module && el.name === elementName) {
|
|
342
|
+
return el;
|
|
343
|
+
}
|
|
344
|
+
const child = findElementByModule(el.children, module, elementName);
|
|
345
|
+
if (child) {
|
|
346
|
+
return child;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return;
|
|
350
|
+
};
|
|
351
|
+
const getAbsolutePath = (elements, subject, path) => {
|
|
352
|
+
var _a, _b, _c, _d;
|
|
353
|
+
if (path.module) {
|
|
354
|
+
return (_a = findElementByModule(elements, path.module, path.segments[0])) === null || _a === void 0 ? void 0 : _a.path;
|
|
355
|
+
}
|
|
356
|
+
const subjectSegments = (_c = (_b = subject.path) === null || _b === void 0 ? void 0 : _b.split('/')) !== null && _c !== void 0 ? _c : [];
|
|
357
|
+
const isRelativePath = ((_d = path.segments[0]) === null || _d === void 0 ? void 0 : _d[0]) === '.';
|
|
358
|
+
if (!isRelativePath) {
|
|
359
|
+
return path.segments.join('/');
|
|
360
|
+
}
|
|
361
|
+
const segments = [...path.segments];
|
|
362
|
+
while (segments.length) {
|
|
363
|
+
const segment = segments.shift();
|
|
364
|
+
if (segment === '..') {
|
|
365
|
+
subjectSegments.pop();
|
|
366
|
+
}
|
|
367
|
+
else if (segment) {
|
|
368
|
+
subjectSegments.push(segment);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return subjectSegments.join('/');
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
class DynamicModuleService {
|
|
323
375
|
constructor() {
|
|
376
|
+
this._elementsTree = [];
|
|
377
|
+
this._componentFactories = [];
|
|
378
|
+
}
|
|
379
|
+
set componentFactories(data) {
|
|
380
|
+
this._componentFactories = data;
|
|
381
|
+
}
|
|
382
|
+
get componentFactories() {
|
|
383
|
+
return this._componentFactories;
|
|
384
|
+
}
|
|
385
|
+
getComponentFactory(element) {
|
|
386
|
+
return this.componentFactories.find(f => f.componentType.path === element.path);
|
|
387
|
+
}
|
|
388
|
+
get elementsTree() {
|
|
389
|
+
return this._elementsTree;
|
|
390
|
+
}
|
|
391
|
+
set elementsTree(tree) {
|
|
392
|
+
this._elementsTree = tree;
|
|
393
|
+
}
|
|
394
|
+
clear() {
|
|
395
|
+
this._elementsTree = [];
|
|
396
|
+
this.componentFactories = [];
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
DynamicModuleService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DynamicModuleService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
400
|
+
DynamicModuleService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DynamicModuleService });
|
|
401
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DynamicModuleService, decorators: [{
|
|
402
|
+
type: Injectable
|
|
403
|
+
}] });
|
|
404
|
+
|
|
405
|
+
class IOProviderService {
|
|
406
|
+
constructor(dynamicModuleService) {
|
|
407
|
+
this.dynamicModuleService = dynamicModuleService;
|
|
324
408
|
this.inputs = {};
|
|
325
409
|
}
|
|
326
410
|
connect(el, name, target) {
|
|
@@ -333,18 +417,15 @@ class IOProviderService {
|
|
|
333
417
|
resolveTarget(el, name, target) {
|
|
334
418
|
var _a, _b;
|
|
335
419
|
const isHost = !target;
|
|
336
|
-
if (
|
|
337
|
-
|
|
338
|
-
const finalName = optionalName !== null && optionalName !== void 0 ? optionalName : name;
|
|
339
|
-
return this.createSubjectSafe(path, finalName);
|
|
420
|
+
if (isHost) {
|
|
421
|
+
return this.createSubjectSafe((_a = el.path) !== null && _a !== void 0 ? _a : '', name);
|
|
340
422
|
}
|
|
341
|
-
const
|
|
342
|
-
const
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
return subject;
|
|
423
|
+
const elPath = parsePath(target);
|
|
424
|
+
const pathIsValue = elPath.segments.length === 1 && elPath.segments[0].startsWith('"') && elPath.segments[0].endsWith('"');
|
|
425
|
+
const finalName = (_b = elPath.variable) !== null && _b !== void 0 ? _b : name;
|
|
426
|
+
const value = pathIsValue ? new BehaviorSubject(elPath.segments[0].slice(1, -1)) : undefined;
|
|
427
|
+
const absolutePath = !pathIsValue ? getAbsolutePath(this.dynamicModuleService.elementsTree, el, elPath) : el.path;
|
|
428
|
+
return this.createSubjectSafe(absolutePath !== null && absolutePath !== void 0 ? absolutePath : '', finalName, value);
|
|
348
429
|
}
|
|
349
430
|
createSubjectSafe(path, name, subject) {
|
|
350
431
|
if (!this.inputs[path]) {
|
|
@@ -356,11 +437,11 @@ class IOProviderService {
|
|
|
356
437
|
return this.inputs[path][name];
|
|
357
438
|
}
|
|
358
439
|
}
|
|
359
|
-
IOProviderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
360
|
-
IOProviderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
|
361
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
440
|
+
IOProviderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IOProviderService, deps: [{ token: DynamicModuleService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
441
|
+
IOProviderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IOProviderService });
|
|
442
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IOProviderService, decorators: [{
|
|
362
443
|
type: Injectable
|
|
363
|
-
}] });
|
|
444
|
+
}], ctorParameters: function () { return [{ type: DynamicModuleService }]; } });
|
|
364
445
|
|
|
365
446
|
class TemplatesService {
|
|
366
447
|
constructor() {
|
|
@@ -373,9 +454,9 @@ class TemplatesService {
|
|
|
373
454
|
return this.templates[name];
|
|
374
455
|
}
|
|
375
456
|
}
|
|
376
|
-
TemplatesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
377
|
-
TemplatesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
|
378
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
457
|
+
TemplatesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: TemplatesService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
458
|
+
TemplatesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: TemplatesService });
|
|
459
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: TemplatesService, decorators: [{
|
|
379
460
|
type: Injectable
|
|
380
461
|
}] });
|
|
381
462
|
|
|
@@ -414,6 +495,187 @@ const extendElementMetadata = (script, extend) => {
|
|
|
414
495
|
return script.replace(metadataString, JSON.stringify(updated));
|
|
415
496
|
};
|
|
416
497
|
|
|
498
|
+
class ElementContextService {
|
|
499
|
+
}
|
|
500
|
+
ElementContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ElementContextService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
501
|
+
ElementContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ElementContextService });
|
|
502
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ElementContextService, decorators: [{
|
|
503
|
+
type: Injectable
|
|
504
|
+
}] });
|
|
505
|
+
|
|
506
|
+
class ElementRendererComponent {
|
|
507
|
+
constructor(parentInjector, dynamicModuleService, elementContext, ioProviderService, configurationService, elementRef, cdr) {
|
|
508
|
+
this.parentInjector = parentInjector;
|
|
509
|
+
this.dynamicModuleService = dynamicModuleService;
|
|
510
|
+
this.elementContext = elementContext;
|
|
511
|
+
this.ioProviderService = ioProviderService;
|
|
512
|
+
this.configurationService = configurationService;
|
|
513
|
+
this.elementRef = elementRef;
|
|
514
|
+
this.cdr = cdr;
|
|
515
|
+
this.refs = {};
|
|
516
|
+
this.destroy$ = new Subject();
|
|
517
|
+
}
|
|
518
|
+
ngOnInit() {
|
|
519
|
+
this.elementContext.metadata = this.meta;
|
|
520
|
+
this.factory = this.dynamicModuleService.getComponentFactory(this.meta);
|
|
521
|
+
this.createComponents();
|
|
522
|
+
}
|
|
523
|
+
ngOnDestroy() {
|
|
524
|
+
this.destroyComponents();
|
|
525
|
+
this.destroy$.next();
|
|
526
|
+
this.destroy$.complete();
|
|
527
|
+
}
|
|
528
|
+
createComponents() {
|
|
529
|
+
const modelMeta = this.meta.model;
|
|
530
|
+
if (!modelMeta) {
|
|
531
|
+
this.refs[UUID.UUID()] = this.createComponent();
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
if (modelMeta.lineItem) {
|
|
535
|
+
this.createFromLineItem(modelMeta.lineItem);
|
|
536
|
+
}
|
|
537
|
+
else if (modelMeta.path) {
|
|
538
|
+
this.createFromPath(modelMeta.path);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
createFromPath(path) {
|
|
542
|
+
const array$ = this.ioProviderService.connect(this.meta, 'children$', path);
|
|
543
|
+
array$ === null || array$ === void 0 ? void 0 : array$.pipe(takeUntil(this.destroy$)).subscribe(children => {
|
|
544
|
+
if (!isArray(children)) {
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
this.processChildren(children);
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
createFromLineItem(path) {
|
|
551
|
+
var _a, _b;
|
|
552
|
+
const parentComp = this.parentInjector.get(ElementRendererComponent, null);
|
|
553
|
+
const parentPath = (_a = parentComp === null || parentComp === void 0 ? void 0 : parentComp.meta.model) === null || _a === void 0 ? void 0 : _a.lineItem;
|
|
554
|
+
const pathBlocks = parseBoundPath(path).reverse();
|
|
555
|
+
const { property, name } = (_b = pathBlocks[1]) !== null && _b !== void 0 ? _b : {};
|
|
556
|
+
const finalPath = pathBlocks[0];
|
|
557
|
+
const children$ = this.getParentLineItem$(parentComp).pipe(map$1(model => {
|
|
558
|
+
var _a;
|
|
559
|
+
if (property === 'ports' && !finalPath.property && parentPath !== path) {
|
|
560
|
+
return (_a = model.lineItems.filter(({ port }) => port === name)) !== null && _a !== void 0 ? _a : [];
|
|
561
|
+
}
|
|
562
|
+
return [model];
|
|
563
|
+
}));
|
|
564
|
+
children$.pipe(takeUntil(this.destroy$)).subscribe(children => {
|
|
565
|
+
this.processChildren(children);
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
processChildren(children) {
|
|
569
|
+
const refs = children.reduce((acc, data) => {
|
|
570
|
+
var _a;
|
|
571
|
+
const key = String((_a = data === null || data === void 0 ? void 0 : data.id) !== null && _a !== void 0 ? _a : UUID.UUID());
|
|
572
|
+
const ref = this.refs[key] ? this.updateComponent(key, data) : this.createComponent(data);
|
|
573
|
+
return ref ? Object.assign(Object.assign({}, acc), { [key]: ref }) : acc;
|
|
574
|
+
}, {});
|
|
575
|
+
const existingKeys = Object.keys(this.refs);
|
|
576
|
+
const newKeys = Object.keys(refs);
|
|
577
|
+
pull(existingKeys, ...newKeys).forEach(key => {
|
|
578
|
+
this.destroyComponent(key);
|
|
579
|
+
});
|
|
580
|
+
this.refs = refs;
|
|
581
|
+
this.cdr.detectChanges();
|
|
582
|
+
}
|
|
583
|
+
getParentLineItem$(parentComp) {
|
|
584
|
+
var _a;
|
|
585
|
+
const parentRefs = Object.values((_a = parentComp === null || parentComp === void 0 ? void 0 : parentComp.refs) !== null && _a !== void 0 ? _a : {});
|
|
586
|
+
const parentRef = parentRefs.find(ref => { var _a; return (_a = ref === null || ref === void 0 ? void 0 : ref.location.nativeElement) === null || _a === void 0 ? void 0 : _a.contains(this.elementRef.nativeElement); });
|
|
587
|
+
const parentModel$ = parentRef === null || parentRef === void 0 ? void 0 : parentRef.instance.model$;
|
|
588
|
+
return parentModel$ !== null && parentModel$ !== void 0 ? parentModel$ : this.configurationService.get();
|
|
589
|
+
}
|
|
590
|
+
createComponent(data) {
|
|
591
|
+
var _a, _b;
|
|
592
|
+
if (!this.factory) {
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
const componentRef = (_a = this.el) === null || _a === void 0 ? void 0 : _a.createComponent(this.factory);
|
|
596
|
+
if (componentRef) {
|
|
597
|
+
componentRef.location.nativeElement.setAttribute('name', this.meta.name);
|
|
598
|
+
componentRef.location.nativeElement.setAttribute('path', this.meta.path);
|
|
599
|
+
(_b = componentRef.instance) === null || _b === void 0 ? void 0 : _b.model$.next(data);
|
|
600
|
+
}
|
|
601
|
+
return componentRef;
|
|
602
|
+
}
|
|
603
|
+
updateComponent(key, data) {
|
|
604
|
+
const ref = this.refs[key];
|
|
605
|
+
ref === null || ref === void 0 ? void 0 : ref.instance.model$.next(data);
|
|
606
|
+
return ref;
|
|
607
|
+
}
|
|
608
|
+
destroyComponent(key) {
|
|
609
|
+
var _a;
|
|
610
|
+
(_a = this.refs[key]) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
611
|
+
delete this.refs[key];
|
|
612
|
+
}
|
|
613
|
+
destroyComponents() {
|
|
614
|
+
Object.values(this.refs).forEach(ref => ref === null || ref === void 0 ? void 0 : ref.destroy());
|
|
615
|
+
this.refs = {};
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
ElementRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ElementRendererComponent, deps: [{ token: i0.Injector, skipSelf: true }, { token: DynamicModuleService }, { token: ElementContextService }, { token: IOProviderService }, { token: ConfigurationService }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
619
|
+
ElementRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", 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 });
|
|
620
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ElementRendererComponent, decorators: [{
|
|
621
|
+
type: Component,
|
|
622
|
+
args: [{
|
|
623
|
+
selector: 'vl-cms-element-renderer',
|
|
624
|
+
templateUrl: './element-renderer.component.html',
|
|
625
|
+
styleUrls: ['./element-renderer.component.scss'],
|
|
626
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
627
|
+
providers: [ElementContextService],
|
|
628
|
+
}]
|
|
629
|
+
}], ctorParameters: function () { return [{ type: i0.Injector, decorators: [{
|
|
630
|
+
type: SkipSelf
|
|
631
|
+
}] }, { type: DynamicModuleService }, { type: ElementContextService }, { type: IOProviderService }, { type: ConfigurationService }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { el: [{
|
|
632
|
+
type: ViewChild,
|
|
633
|
+
args: ['el', { read: ViewContainerRef, static: true }]
|
|
634
|
+
}], meta: [{
|
|
635
|
+
type: Input
|
|
636
|
+
}] } });
|
|
637
|
+
|
|
638
|
+
class ElementChildrenComponent {
|
|
639
|
+
constructor(elementContext) {
|
|
640
|
+
this.elementContext = elementContext;
|
|
641
|
+
this.metadata = this.elementContext.metadata;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
ElementChildrenComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ElementChildrenComponent, deps: [{ token: ElementContextService }], target: i0.ɵɵFactoryTarget.Component });
|
|
645
|
+
ElementChildrenComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: ElementChildrenComponent, selector: "element-children", ngImport: i0, template: "<ng-container *ngIf=\"metadata?.children.length\">\n <ng-container *ngFor=\"let child of metadata.children\">\n <vl-cms-element-renderer [meta]=\"child\"></vl-cms-element-renderer>\n </ng-container>\n</ng-container>\n", styles: [":host{display:contents}\n"], components: [{ type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: ["meta"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
646
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ElementChildrenComponent, decorators: [{
|
|
647
|
+
type: Component,
|
|
648
|
+
args: [{
|
|
649
|
+
// eslint-disable-next-line @angular-eslint/component-selector
|
|
650
|
+
selector: 'element-children',
|
|
651
|
+
templateUrl: 'element-children.component.html',
|
|
652
|
+
styleUrls: ['./element-children.component.scss'],
|
|
653
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
654
|
+
}]
|
|
655
|
+
}], ctorParameters: function () { return [{ type: ElementContextService }]; } });
|
|
656
|
+
|
|
657
|
+
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
658
|
+
class CustomTemplateDirective {
|
|
659
|
+
constructor(templateRef, templatesService) {
|
|
660
|
+
this.templateRef = templateRef;
|
|
661
|
+
this.templatesService = templatesService;
|
|
662
|
+
}
|
|
663
|
+
ngAfterViewInit() {
|
|
664
|
+
if (!this.customTemplate) {
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
this.templatesService.register(this.customTemplate, this.templateRef);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
CustomTemplateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: CustomTemplateDirective, deps: [{ token: i0.TemplateRef }, { token: TemplatesService }], target: i0.ɵɵFactoryTarget.Directive });
|
|
671
|
+
CustomTemplateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: CustomTemplateDirective, selector: "[customTemplate]", inputs: { customTemplate: "customTemplate" }, ngImport: i0 });
|
|
672
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: CustomTemplateDirective, decorators: [{
|
|
673
|
+
type: Directive,
|
|
674
|
+
args: [{ selector: '[customTemplate]' }]
|
|
675
|
+
}], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: TemplatesService }]; }, propDecorators: { customTemplate: [{
|
|
676
|
+
type: Input
|
|
677
|
+
}] } });
|
|
678
|
+
|
|
417
679
|
class ConfigurationPlugin {
|
|
418
680
|
constructor(host) {
|
|
419
681
|
this.host = host;
|
|
@@ -498,9 +760,9 @@ class ConfigurationPlugin {
|
|
|
498
760
|
return this.host;
|
|
499
761
|
}
|
|
500
762
|
}
|
|
501
|
-
ConfigurationPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
502
|
-
ConfigurationPlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.
|
|
503
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
763
|
+
ConfigurationPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ConfigurationPlugin, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
|
|
764
|
+
ConfigurationPlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: ConfigurationPlugin, ngImport: i0 });
|
|
765
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ConfigurationPlugin, decorators: [{
|
|
504
766
|
type: Directive
|
|
505
767
|
}], ctorParameters: function () { return [{ type: undefined }]; } });
|
|
506
768
|
|
|
@@ -570,9 +832,9 @@ class ScriptPlugin {
|
|
|
570
832
|
}
|
|
571
833
|
}
|
|
572
834
|
}
|
|
573
|
-
ScriptPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
574
|
-
ScriptPlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.
|
|
575
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
835
|
+
ScriptPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ScriptPlugin, deps: [{ token: ElementComponent }], target: i0.ɵɵFactoryTarget.Directive });
|
|
836
|
+
ScriptPlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: ScriptPlugin, ngImport: i0 });
|
|
837
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ScriptPlugin, decorators: [{
|
|
576
838
|
type: Directive
|
|
577
839
|
}], ctorParameters: function () { return [{ type: ElementComponent }]; } });
|
|
578
840
|
|
|
@@ -607,9 +869,9 @@ class IOPlugin {
|
|
|
607
869
|
});
|
|
608
870
|
}
|
|
609
871
|
}
|
|
610
|
-
IOPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
611
|
-
IOPlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.
|
|
612
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
872
|
+
IOPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IOPlugin, deps: [{ token: ElementComponent }], target: i0.ɵɵFactoryTarget.Directive });
|
|
873
|
+
IOPlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: IOPlugin, ngImport: i0 });
|
|
874
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IOPlugin, decorators: [{
|
|
613
875
|
type: Directive
|
|
614
876
|
}], ctorParameters: function () { return [{ type: ElementComponent }]; } });
|
|
615
877
|
|
|
@@ -621,214 +883,92 @@ const CONFIG = {
|
|
|
621
883
|
CONTAINER: {
|
|
622
884
|
component: ElementComponent,
|
|
623
885
|
template: '<element-children></element-children>',
|
|
624
|
-
plugins: [],
|
|
886
|
+
plugins: [IOPlugin],
|
|
625
887
|
},
|
|
626
888
|
SERVICE: {
|
|
627
889
|
component: ElementComponent,
|
|
628
890
|
plugins: [IOPlugin],
|
|
629
891
|
},
|
|
892
|
+
REFERENCE: {
|
|
893
|
+
component: ElementComponent,
|
|
894
|
+
plugins: [IOPlugin],
|
|
895
|
+
},
|
|
630
896
|
};
|
|
631
897
|
|
|
632
|
-
class
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
this._componentFactories = [];
|
|
643
|
-
}
|
|
644
|
-
set componentFactories(data) {
|
|
645
|
-
this._componentFactories = data;
|
|
646
|
-
}
|
|
647
|
-
get componentFactories() {
|
|
648
|
-
return this._componentFactories;
|
|
649
|
-
}
|
|
650
|
-
getComponentFactory(element) {
|
|
651
|
-
return this.componentFactories.find(f => f.componentType.path === element.path);
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
DynamicModuleService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DynamicModuleService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
655
|
-
DynamicModuleService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DynamicModuleService });
|
|
656
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DynamicModuleService, decorators: [{
|
|
657
|
-
type: Injectable
|
|
658
|
-
}] });
|
|
659
|
-
|
|
660
|
-
class ElementRendererComponent {
|
|
661
|
-
constructor(parentInjector, dynamicModuleService, elementContext, ioProviderService, configurationService, elementRef, cdr) {
|
|
662
|
-
this.parentInjector = parentInjector;
|
|
663
|
-
this.dynamicModuleService = dynamicModuleService;
|
|
664
|
-
this.elementContext = elementContext;
|
|
665
|
-
this.ioProviderService = ioProviderService;
|
|
666
|
-
this.configurationService = configurationService;
|
|
667
|
-
this.elementRef = elementRef;
|
|
668
|
-
this.cdr = cdr;
|
|
669
|
-
this.refs = {};
|
|
670
|
-
this.destroy$ = new Subject();
|
|
671
|
-
}
|
|
672
|
-
ngOnInit() {
|
|
673
|
-
this.elementContext.metadata = this.meta;
|
|
674
|
-
this.factory = this.dynamicModuleService.getComponentFactory(this.meta);
|
|
675
|
-
this.createComponents();
|
|
676
|
-
}
|
|
677
|
-
ngOnDestroy() {
|
|
678
|
-
this.destroyComponents();
|
|
679
|
-
this.destroy$.next();
|
|
680
|
-
this.destroy$.complete();
|
|
681
|
-
}
|
|
682
|
-
createComponents() {
|
|
683
|
-
const modelMeta = this.meta.model;
|
|
684
|
-
if (!modelMeta) {
|
|
685
|
-
this.refs[UUID.UUID()] = this.createComponent();
|
|
686
|
-
return;
|
|
687
|
-
}
|
|
688
|
-
if (modelMeta.lineItem) {
|
|
689
|
-
this.createFromLineItem(modelMeta.lineItem);
|
|
690
|
-
}
|
|
691
|
-
else if (modelMeta.path) {
|
|
692
|
-
this.createFromPath(modelMeta.path);
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
createFromPath(path) {
|
|
696
|
-
const array$ = this.ioProviderService.connect(this.meta, 'children$', path);
|
|
697
|
-
array$ === null || array$ === void 0 ? void 0 : array$.pipe(takeUntil(this.destroy$)).subscribe(children => {
|
|
698
|
-
if (!isArray(children)) {
|
|
699
|
-
return;
|
|
898
|
+
class ElementsResolver {
|
|
899
|
+
constructor(uiDef, elements) {
|
|
900
|
+
this.uiDef = uiDef;
|
|
901
|
+
this.renderableElements = [];
|
|
902
|
+
this.sharedElements = [];
|
|
903
|
+
this.elements = this.transpileScripts(elements);
|
|
904
|
+
const flatElements = this.flattenElements(this.elements);
|
|
905
|
+
for (const el of flatElements) {
|
|
906
|
+
if (this.isSharedElement(el)) {
|
|
907
|
+
this.sharedElements.push(el);
|
|
700
908
|
}
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
}
|
|
704
|
-
createFromLineItem(path) {
|
|
705
|
-
var _a, _b;
|
|
706
|
-
const parentComp = this.parentInjector.get(ElementRendererComponent, null);
|
|
707
|
-
const parentPath = (_a = parentComp === null || parentComp === void 0 ? void 0 : parentComp.meta.model) === null || _a === void 0 ? void 0 : _a.lineItem;
|
|
708
|
-
const pathBlocks = parseBoundPath(path).reverse();
|
|
709
|
-
const { property, name } = (_b = pathBlocks[1]) !== null && _b !== void 0 ? _b : {};
|
|
710
|
-
const finalPath = pathBlocks[0];
|
|
711
|
-
const children$ = this.getParentLineItem$(parentComp).pipe(map$1(model => {
|
|
712
|
-
var _a;
|
|
713
|
-
if (property === 'ports' && !finalPath.property && parentPath !== path) {
|
|
714
|
-
return (_a = model.lineItems.filter(({ port }) => port === name)) !== null && _a !== void 0 ? _a : [];
|
|
909
|
+
else {
|
|
910
|
+
this.renderableElements.push(el);
|
|
715
911
|
}
|
|
716
|
-
|
|
717
|
-
}));
|
|
718
|
-
children$.pipe(takeUntil(this.destroy$)).subscribe(children => {
|
|
719
|
-
this.processChildren(children);
|
|
720
|
-
});
|
|
721
|
-
}
|
|
722
|
-
processChildren(children) {
|
|
723
|
-
const refs = children.reduce((acc, data) => {
|
|
724
|
-
var _a;
|
|
725
|
-
const key = String((_a = data === null || data === void 0 ? void 0 : data.id) !== null && _a !== void 0 ? _a : UUID.UUID());
|
|
726
|
-
const ref = this.refs[key] ? this.updateComponent(key, data) : this.createComponent(data);
|
|
727
|
-
return ref ? Object.assign(Object.assign({}, acc), { [key]: ref }) : acc;
|
|
728
|
-
}, {});
|
|
729
|
-
const existingKeys = Object.keys(this.refs);
|
|
730
|
-
const newKeys = Object.keys(refs);
|
|
731
|
-
pull(existingKeys, ...newKeys).forEach(key => {
|
|
732
|
-
this.destroyComponent(key);
|
|
733
|
-
});
|
|
734
|
-
this.refs = refs;
|
|
735
|
-
this.cdr.markForCheck();
|
|
912
|
+
}
|
|
736
913
|
}
|
|
737
|
-
|
|
914
|
+
transpile(el) {
|
|
738
915
|
var _a;
|
|
739
|
-
|
|
740
|
-
const parentRef = parentRefs.find(ref => { var _a; return (_a = ref === null || ref === void 0 ? void 0 : ref.location.nativeElement) === null || _a === void 0 ? void 0 : _a.contains(this.elementRef.nativeElement); });
|
|
741
|
-
const parentModel$ = parentRef === null || parentRef === void 0 ? void 0 : parentRef.instance.model$;
|
|
742
|
-
return parentModel$ !== null && parentModel$ !== void 0 ? parentModel$ : this.configurationService.get();
|
|
743
|
-
}
|
|
744
|
-
createComponent(data) {
|
|
745
|
-
var _a, _b;
|
|
746
|
-
if (!this.factory) {
|
|
916
|
+
if (!el.script) {
|
|
747
917
|
return;
|
|
748
918
|
}
|
|
749
|
-
const
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
return componentRef;
|
|
756
|
-
}
|
|
757
|
-
updateComponent(key, data) {
|
|
758
|
-
const ref = this.refs[key];
|
|
759
|
-
ref === null || ref === void 0 ? void 0 : ref.instance.model$.next(data);
|
|
760
|
-
return ref;
|
|
919
|
+
const transformed = transform(el.script, {
|
|
920
|
+
filename: el.name + '.ts',
|
|
921
|
+
presets: ['typescript'],
|
|
922
|
+
sourceMaps: 'inline',
|
|
923
|
+
});
|
|
924
|
+
return (_a = transformed.code) !== null && _a !== void 0 ? _a : undefined;
|
|
761
925
|
}
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
(_a = this.refs[key]) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
765
|
-
delete this.refs[key];
|
|
926
|
+
transpileScripts(elements) {
|
|
927
|
+
return elements.map(el => (Object.assign(Object.assign({}, el), { script: this.transpile(el), children: this.transpileScripts(el.children) })));
|
|
766
928
|
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
this.refs = {};
|
|
929
|
+
flattenElements(elements) {
|
|
930
|
+
return flatten(elements.map(el => [el, ...this.flattenElements(el.children)]));
|
|
770
931
|
}
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
ElementRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", 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 });
|
|
774
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementRendererComponent, decorators: [{
|
|
775
|
-
type: Component,
|
|
776
|
-
args: [{
|
|
777
|
-
selector: 'vl-cms-element-renderer',
|
|
778
|
-
templateUrl: './element-renderer.component.html',
|
|
779
|
-
styleUrls: ['./element-renderer.component.scss'],
|
|
780
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
781
|
-
providers: [ElementContextService],
|
|
782
|
-
}]
|
|
783
|
-
}], ctorParameters: function () { return [{ type: i0.Injector, decorators: [{
|
|
784
|
-
type: SkipSelf
|
|
785
|
-
}] }, { type: DynamicModuleService }, { type: ElementContextService }, { type: IOProviderService }, { type: ConfigurationService }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { el: [{
|
|
786
|
-
type: ViewChild,
|
|
787
|
-
args: ['el', { read: ViewContainerRef, static: true }]
|
|
788
|
-
}], meta: [{
|
|
789
|
-
type: Input
|
|
790
|
-
}] } });
|
|
791
|
-
|
|
792
|
-
class ElementChildrenComponent {
|
|
793
|
-
constructor(elementContext) {
|
|
794
|
-
this.elementContext = elementContext;
|
|
795
|
-
this.metadata = this.elementContext.metadata;
|
|
932
|
+
isSharedElement(el) {
|
|
933
|
+
return Boolean(el.reference) && el.type !== 'REFERENCE';
|
|
796
934
|
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
808
|
-
}]
|
|
809
|
-
}], ctorParameters: function () { return [{ type: ElementContextService }]; } });
|
|
810
|
-
|
|
811
|
-
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
812
|
-
class CustomTemplateDirective {
|
|
813
|
-
constructor(templateRef, templatesService) {
|
|
814
|
-
this.templateRef = templateRef;
|
|
815
|
-
this.templatesService = templatesService;
|
|
935
|
+
processElementMetadata(element) {
|
|
936
|
+
if (element.type === 'REFERENCE') {
|
|
937
|
+
const sharedElement = this.sharedElements.find(el => element.reference === el.name);
|
|
938
|
+
if (!sharedElement) {
|
|
939
|
+
console.warn(`Shared element "${element.reference}" not found`);
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
return Object.assign(Object.assign({}, element), { type: sharedElement.type, template: sharedElement.template, script: sharedElement.script, styles: sharedElement.styles, inputs: Object.assign(Object.assign({}, sharedElement.inputs), element.inputs), outputs: Object.assign(Object.assign({}, sharedElement.outputs), element.outputs) });
|
|
943
|
+
}
|
|
944
|
+
return element;
|
|
816
945
|
}
|
|
817
|
-
|
|
818
|
-
|
|
946
|
+
resolveElement(sourceElement) {
|
|
947
|
+
const element = this.processElementMetadata(sourceElement);
|
|
948
|
+
if (!element) {
|
|
819
949
|
return;
|
|
820
950
|
}
|
|
821
|
-
|
|
951
|
+
const config = CONFIG[element.type];
|
|
952
|
+
const defaultPlugins = DEFAULT_PLUGINS[this.uiDef.type];
|
|
953
|
+
if (!config) {
|
|
954
|
+
console.warn(`Unknown element type "${element.type}"`);
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
957
|
+
const component = Object.assign(Object.assign({ selector: 'vl-element', template: element.template || config.template || '' }, (element.styles ? { styles: [element.styles] } : {})), { providers: [
|
|
958
|
+
{ provide: DEFAULT_PLUGINS_TOKEN, useValue: defaultPlugins },
|
|
959
|
+
{ provide: UI_DEFINITION_METADATA, useValue: this.uiDef },
|
|
960
|
+
{ provide: ELEMENT_METADATA, useValue: element },
|
|
961
|
+
{ provide: ELEMENT_CONFIG, useValue: config },
|
|
962
|
+
] });
|
|
963
|
+
const cmp = Component(component)(class C extends config.component {
|
|
964
|
+
});
|
|
965
|
+
set(cmp, 'path', element.path);
|
|
966
|
+
return cmp;
|
|
967
|
+
}
|
|
968
|
+
getNgComponents() {
|
|
969
|
+
return this.renderableElements.map(el => this.resolveElement(el)).filter(Boolean);
|
|
822
970
|
}
|
|
823
971
|
}
|
|
824
|
-
CustomTemplateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: CustomTemplateDirective, deps: [{ token: i0.TemplateRef }, { token: TemplatesService }], target: i0.ɵɵFactoryTarget.Directive });
|
|
825
|
-
CustomTemplateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: CustomTemplateDirective, selector: "[customTemplate]", inputs: { customTemplate: "customTemplate" }, ngImport: i0 });
|
|
826
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: CustomTemplateDirective, decorators: [{
|
|
827
|
-
type: Directive,
|
|
828
|
-
args: [{ selector: '[customTemplate]' }]
|
|
829
|
-
}], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: TemplatesService }]; }, propDecorators: { customTemplate: [{
|
|
830
|
-
type: Input
|
|
831
|
-
}] } });
|
|
832
972
|
|
|
833
973
|
class LauncherService {
|
|
834
974
|
constructor(compiler, dynamicModuleService) {
|
|
@@ -836,8 +976,7 @@ class LauncherService {
|
|
|
836
976
|
this.dynamicModuleService = dynamicModuleService;
|
|
837
977
|
}
|
|
838
978
|
compileModule(elements, uiDefs) {
|
|
839
|
-
|
|
840
|
-
this.module = this.getModule(transformedElements, uiDefs);
|
|
979
|
+
this.module = this.getModule(elements, uiDefs);
|
|
841
980
|
return from(this.compiler.compileModuleAndAllComponentsAsync(this.module)).pipe(tap$1(m => {
|
|
842
981
|
this.dynamicModuleService.componentFactories = m.componentFactories;
|
|
843
982
|
this.moduleInstance = m;
|
|
@@ -845,7 +984,7 @@ class LauncherService {
|
|
|
845
984
|
}
|
|
846
985
|
destroy() {
|
|
847
986
|
if (this.moduleInstance) {
|
|
848
|
-
this.dynamicModuleService.
|
|
987
|
+
this.dynamicModuleService.clear();
|
|
849
988
|
this.moduleInstance = undefined;
|
|
850
989
|
}
|
|
851
990
|
if (this.module) {
|
|
@@ -853,57 +992,25 @@ class LauncherService {
|
|
|
853
992
|
this.module = undefined;
|
|
854
993
|
}
|
|
855
994
|
}
|
|
856
|
-
|
|
857
|
-
const config = CONFIG[element.type];
|
|
858
|
-
const defaultPlugins = DEFAULT_PLUGINS[uiDefs.type];
|
|
859
|
-
if (!config) {
|
|
860
|
-
console.warn(`Unknown element type "${element.type}"`);
|
|
861
|
-
return;
|
|
862
|
-
}
|
|
863
|
-
const cmp = Component(Object.assign(Object.assign({ selector: 'vl-element', template: element.template || config.template || '' }, (element.styles ? { styles: [element.styles] } : {})), { providers: [
|
|
864
|
-
{ provide: DEFAULT_PLUGINS_TOKEN, useValue: defaultPlugins },
|
|
865
|
-
{ provide: UI_DEFINITION_METADATA, useValue: uiDefs },
|
|
866
|
-
{ provide: ELEMENT_METADATA, useValue: element },
|
|
867
|
-
{ provide: ELEMENT_CONFIG, useValue: config },
|
|
868
|
-
] }))(class C extends config.component {
|
|
869
|
-
});
|
|
870
|
-
set(cmp, 'path', element.path);
|
|
871
|
-
return cmp;
|
|
872
|
-
}
|
|
873
|
-
getModule(elements, uiDefs) {
|
|
995
|
+
getModule(elements, uiDef) {
|
|
874
996
|
const staticComponents = [ElementChildrenComponent, ElementRendererComponent, CustomTemplateDirective];
|
|
875
|
-
const
|
|
997
|
+
const elementsResolver = new ElementsResolver(uiDef, elements);
|
|
998
|
+
this.dynamicModuleService.elementsTree = elementsResolver.elements;
|
|
876
999
|
let DynamicModule = class DynamicModule {
|
|
877
1000
|
};
|
|
878
1001
|
DynamicModule = __decorate([
|
|
879
1002
|
NgModule({
|
|
880
1003
|
imports: [CommonModule, ReactiveFormsModule],
|
|
881
|
-
declarations: [...staticComponents, ...
|
|
1004
|
+
declarations: [...staticComponents, ...elementsResolver.getNgComponents()],
|
|
882
1005
|
jit: true,
|
|
883
1006
|
})
|
|
884
1007
|
], DynamicModule);
|
|
885
1008
|
return DynamicModule;
|
|
886
1009
|
}
|
|
887
|
-
transformElements(elements) {
|
|
888
|
-
return flatten(elements.map(el => {
|
|
889
|
-
var _a;
|
|
890
|
-
const children = this.transformElements(el.children);
|
|
891
|
-
if (!el.script) {
|
|
892
|
-
return [el, ...children];
|
|
893
|
-
}
|
|
894
|
-
const transformed = transform(el.script, {
|
|
895
|
-
filename: el.name + '.ts',
|
|
896
|
-
presets: ['typescript'],
|
|
897
|
-
sourceMaps: 'inline',
|
|
898
|
-
});
|
|
899
|
-
const script = (_a = transformed.code) !== null && _a !== void 0 ? _a : undefined;
|
|
900
|
-
return [Object.assign(Object.assign({}, el), { script }), ...children];
|
|
901
|
-
}));
|
|
902
|
-
}
|
|
903
1010
|
}
|
|
904
|
-
LauncherService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
905
|
-
LauncherService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
|
906
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
1011
|
+
LauncherService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LauncherService, deps: [{ token: i0.Compiler }, { token: DynamicModuleService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1012
|
+
LauncherService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LauncherService });
|
|
1013
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LauncherService, decorators: [{
|
|
907
1014
|
type: Injectable
|
|
908
1015
|
}], ctorParameters: function () { return [{ type: i0.Compiler }, { type: DynamicModuleService }]; } });
|
|
909
1016
|
|
|
@@ -951,9 +1058,9 @@ class PreviewComponent {
|
|
|
951
1058
|
.subscribe();
|
|
952
1059
|
}
|
|
953
1060
|
}
|
|
954
|
-
PreviewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
955
|
-
PreviewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.
|
|
956
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
1061
|
+
PreviewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PreviewComponent, deps: [{ token: LauncherService }, { token: ConfigurationService }, { token: i3.MessageService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1062
|
+
PreviewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: PreviewComponent, selector: "vl-cms-preview", inputs: { modelId: "modelId", uiDefinition: "uiDefinition" }, providers: [IOProviderService, ConfigurationService, 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%;all:unset}\n"], components: [{ type: i4.LoaderComponent, selector: "vl-loader", inputs: ["label"] }, { type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: ["meta"] }], directives: [{ type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i6.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1063
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PreviewComponent, decorators: [{
|
|
957
1064
|
type: Component,
|
|
958
1065
|
args: [{
|
|
959
1066
|
selector: 'vl-cms-preview',
|
|
@@ -970,10 +1077,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
|
970
1077
|
|
|
971
1078
|
class ElementRendererModule {
|
|
972
1079
|
}
|
|
973
|
-
ElementRendererModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
974
|
-
ElementRendererModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.
|
|
975
|
-
ElementRendererModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.
|
|
976
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
1080
|
+
ElementRendererModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ElementRendererModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1081
|
+
ElementRendererModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ElementRendererModule, declarations: [ElementRendererComponent], exports: [ElementRendererComponent] });
|
|
1082
|
+
ElementRendererModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ElementRendererModule });
|
|
1083
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ElementRendererModule, decorators: [{
|
|
977
1084
|
type: NgModule,
|
|
978
1085
|
args: [{
|
|
979
1086
|
declarations: [ElementRendererComponent],
|
|
@@ -983,10 +1090,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
|
983
1090
|
|
|
984
1091
|
class ElementChildrenModule {
|
|
985
1092
|
}
|
|
986
|
-
ElementChildrenModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
987
|
-
ElementChildrenModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.
|
|
988
|
-
ElementChildrenModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.
|
|
989
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
1093
|
+
ElementChildrenModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ElementChildrenModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1094
|
+
ElementChildrenModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ElementChildrenModule, declarations: [ElementChildrenComponent], imports: [ElementRendererModule], exports: [ElementChildrenComponent] });
|
|
1095
|
+
ElementChildrenModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ElementChildrenModule, imports: [[ElementRendererModule]] });
|
|
1096
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ElementChildrenModule, decorators: [{
|
|
990
1097
|
type: NgModule,
|
|
991
1098
|
args: [{
|
|
992
1099
|
declarations: [ElementChildrenComponent],
|
|
@@ -997,10 +1104,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
|
997
1104
|
|
|
998
1105
|
class PreviewModule {
|
|
999
1106
|
}
|
|
1000
|
-
PreviewModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
1001
|
-
PreviewModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.
|
|
1002
|
-
PreviewModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.
|
|
1003
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
1107
|
+
PreviewModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PreviewModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1108
|
+
PreviewModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PreviewModule, declarations: [PreviewComponent], imports: [CommonModule, LoaderModule, ElementRendererModule, ElementChildrenModule], exports: [PreviewComponent] });
|
|
1109
|
+
PreviewModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PreviewModule, imports: [[CommonModule, LoaderModule, ElementRendererModule, ElementChildrenModule]] });
|
|
1110
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PreviewModule, decorators: [{
|
|
1004
1111
|
type: NgModule,
|
|
1005
1112
|
args: [{
|
|
1006
1113
|
declarations: [PreviewComponent],
|
|
@@ -1017,10 +1124,10 @@ function ElementDefinition(definition) {
|
|
|
1017
1124
|
|
|
1018
1125
|
class ConfigurationModule {
|
|
1019
1126
|
}
|
|
1020
|
-
ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
1021
|
-
ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.
|
|
1022
|
-
ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.
|
|
1023
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
1127
|
+
ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1128
|
+
ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ConfigurationModule });
|
|
1129
|
+
ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ConfigurationModule, providers: [ContextService, ContextApiService, ProductModelApiService, ConfigurationApiService] });
|
|
1130
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ConfigurationModule, decorators: [{
|
|
1024
1131
|
type: NgModule,
|
|
1025
1132
|
args: [{
|
|
1026
1133
|
providers: [ContextService, ContextApiService, ProductModelApiService, ConfigurationApiService],
|
|
@@ -1029,10 +1136,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
|
1029
1136
|
|
|
1030
1137
|
class LauncherModule {
|
|
1031
1138
|
}
|
|
1032
|
-
LauncherModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
1033
|
-
LauncherModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.
|
|
1034
|
-
LauncherModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.
|
|
1035
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
1139
|
+
LauncherModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LauncherModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1140
|
+
LauncherModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LauncherModule, imports: [CommonModule, CoreModule, ConfigurationModule] });
|
|
1141
|
+
LauncherModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LauncherModule, providers: [LauncherService, DynamicModuleService], imports: [[CommonModule, CoreModule, ConfigurationModule]] });
|
|
1142
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LauncherModule, decorators: [{
|
|
1036
1143
|
type: NgModule,
|
|
1037
1144
|
args: [{
|
|
1038
1145
|
imports: [CommonModule, CoreModule, ConfigurationModule],
|