@veloceapps/sdk 7.0.2-16 → 7.0.2-18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. package/cms/cms.actions.d.ts +7 -1
  2. package/cms/components/element-children/element-children.component.d.ts +3 -1
  3. package/cms/components/preview/preview.types.d.ts +4 -0
  4. package/cms/injection-tokens.d.ts +1 -3
  5. package/cms/modules/runtime/services/compilation.service.d.ts +2 -1
  6. package/cms/plugins/element-hover.plugin.d.ts +2 -0
  7. package/cms/plugins/script.plugin.d.ts +0 -3
  8. package/cms/types/common.types.d.ts +2 -2
  9. package/cms/utils/elements-resolver.d.ts +5 -1
  10. package/cms/utils/script.utils.d.ts +2 -0
  11. package/cms/vendor-map.d.ts +1 -2
  12. package/core/types/ui-definition.types.d.ts +7 -2
  13. package/esm2020/cms/cms.actions.mjs +11 -2
  14. package/esm2020/cms/cms.elements.mjs +5 -5
  15. package/esm2020/cms/components/element-children/element-children.component.mjs +11 -6
  16. package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +2 -2
  17. package/esm2020/cms/components/preview/preview.types.mjs +1 -1
  18. package/esm2020/cms/injection-tokens.mjs +1 -2
  19. package/esm2020/cms/modules/runtime/services/compilation.service.mjs +3 -3
  20. package/esm2020/cms/modules/runtime/services/runtime.service.mjs +2 -2
  21. package/esm2020/cms/plugins/element-hover.plugin.mjs +9 -1
  22. package/esm2020/cms/plugins/script.plugin.mjs +6 -40
  23. package/esm2020/cms/services/integration.state.mjs +3 -6
  24. package/esm2020/cms/types/common.types.mjs +1 -1
  25. package/esm2020/cms/utils/elements-resolver.mjs +22 -8
  26. package/esm2020/cms/utils/script.utils.mjs +42 -0
  27. package/esm2020/core/types/ui-definition.types.mjs +1 -1
  28. package/esm2020/src/flow-routing.module.mjs +1 -2
  29. package/fesm2015/veloceapps-sdk-cms.mjs +142 -105
  30. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  31. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  32. package/fesm2015/veloceapps-sdk.mjs +0 -1
  33. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  34. package/fesm2020/veloceapps-sdk-cms.mjs +155 -117
  35. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  36. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  37. package/fesm2020/veloceapps-sdk.mjs +0 -1
  38. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  39. package/package.json +1 -1
@@ -4,7 +4,7 @@ import { InjectionToken, Component, ChangeDetectionStrategy, Inject, Injector, I
4
4
  import * as rxjs from 'rxjs';
5
5
  import { BehaviorSubject, Subject, of, map, tap, switchMap, startWith, distinctUntilChanged, filter, ReplaySubject, noop, take, Observable, takeUntil, forkJoin, catchError, combineLatest } from 'rxjs';
6
6
  import * as i2 from '@veloceapps/sdk/core';
7
- import { ConfigurationService, LineItemWorker, generateLineItem, getAttributeValue, QuoteDraftService, FlowConfigurationService, ProductImagesService, ContextService, lineItemUtils, SdkCoreModule, UI_DEFINITION_VERSION } from '@veloceapps/sdk/core';
7
+ import { ConfigurationService, QuoteDraftService, FlowConfigurationService, LineItemWorker, ProductImagesService, ContextService, lineItemUtils, generateLineItem, getAttributeValue, SdkCoreModule, UI_DEFINITION_VERSION } from '@veloceapps/sdk/core';
8
8
  import * as i3 from 'primeng/api';
9
9
  import { applyPatch } from 'rfc6902';
10
10
  import { getCollectionUniqueName, UUID, isDefined, Operator, Predicate, parseJsonSafely, CoreModule } from '@veloceapps/core';
@@ -21,8 +21,8 @@ import { DragDropModule } from '@angular/cdk/drag-drop';
21
21
  import { ScrollingModule } from '@angular/cdk/scrolling';
22
22
  import * as angularForms from '@angular/forms';
23
23
  import { FormsModule, ReactiveFormsModule } from '@angular/forms';
24
- import { transform } from '@babel/standalone';
25
24
  import * as rxjsOperators from 'rxjs/operators';
25
+ import { transform } from '@babel/standalone';
26
26
  import { loadRemoteModule } from '@angular-architects/module-federation';
27
27
 
28
28
  var FlowAction;
@@ -69,16 +69,25 @@ const SwitchObjectAction = (payload) => ({
69
69
  var CmsAction;
70
70
  (function (CmsAction) {
71
71
  CmsAction.GO_TO_PAGE = '[CMS]_GO_TO_PAGE';
72
+ CmsAction.UPDATE_CUSTOMIZATION = '[CMS]_UPDATE_CUSTOMIZATION';
72
73
  /**
73
74
  * Navigate UI definition to a specific page
74
75
  *
75
76
  * @param pageName name of the page
76
- * @returns void
77
77
  */
78
78
  CmsAction.GoToPage = (pageName) => ({
79
79
  type: CmsAction.GO_TO_PAGE,
80
80
  payload: { pageName },
81
81
  });
82
+ /**
83
+ * Update UI definition customization state
84
+ *
85
+ * @param pageName name of the page
86
+ */
87
+ CmsAction.UpdateCustomization = (value) => ({
88
+ type: CmsAction.UPDATE_CUSTOMIZATION,
89
+ payload: { value },
90
+ });
82
91
  })(CmsAction || (CmsAction = {}));
83
92
 
84
93
  var cmsActions = /*#__PURE__*/Object.freeze({
@@ -101,7 +110,6 @@ const UI_DEFINITION_METADATA = new InjectionToken('UI_DEFINITION_METADATA_TOKEN'
101
110
  const ELEMENT_METADATA = new InjectionToken('ELEMENT_METADATA_TOKEN');
102
111
  const SHARED_ELEMENT_METADATA = new InjectionToken('SHARED_ELEMENT_METADATA_TOKEN');
103
112
  const ELEMENT_CONFIG = new InjectionToken('ELEMENT_CONFIG_TOKEN');
104
- const VENDOR_MAP = new InjectionToken('VENDOR_MAP');
105
113
 
106
114
  var cmsInjectionTokens = /*#__PURE__*/Object.freeze({
107
115
  __proto__: null,
@@ -109,8 +117,7 @@ var cmsInjectionTokens = /*#__PURE__*/Object.freeze({
109
117
  ELEMENT_CONFIG: ELEMENT_CONFIG,
110
118
  ELEMENT_METADATA: ELEMENT_METADATA,
111
119
  SHARED_ELEMENT_METADATA: SHARED_ELEMENT_METADATA,
112
- UI_DEFINITION_METADATA: UI_DEFINITION_METADATA,
113
- VENDOR_MAP: VENDOR_MAP
120
+ UI_DEFINITION_METADATA: UI_DEFINITION_METADATA
114
121
  });
115
122
 
116
123
  class Entity {
@@ -257,7 +264,7 @@ class RuntimeService {
257
264
  if (!uiDefinition) {
258
265
  return of([]);
259
266
  }
260
- return this.compilationService.compileUIDefinition$(uiDefinition).pipe(map(result => {
267
+ return this.compilationService.compileUIDefinition$(uiDefinition, config).pipe(map(result => {
261
268
  this.applicationTree = result.elements;
262
269
  this.componentTypes = {
263
270
  ...this.componentTypes,
@@ -316,12 +323,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
316
323
  type: Injectable
317
324
  }], ctorParameters: function () { return [{ type: i0.Injector }]; } });
318
325
 
319
- const InitAction = { type: 'INIT' };
320
- const ClearAction = { type: 'CLEAR' };
321
326
  class IntegrationState {
322
327
  constructor() {
323
328
  this.stateSubj$ = new BehaviorSubject({});
324
- this.action$ = new BehaviorSubject(InitAction);
329
+ this.action$ = new Subject();
325
330
  }
326
331
  get state$() {
327
332
  return this.stateSubj$.asObservable();
@@ -343,7 +348,6 @@ class IntegrationState {
343
348
  }
344
349
  clear() {
345
350
  this.stateSubj$.next({});
346
- this.action$.next(ClearAction);
347
351
  }
348
352
  }
349
353
  IntegrationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: IntegrationState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
@@ -864,13 +868,18 @@ class ElementChildrenComponent {
864
868
  this.destroyed$.next();
865
869
  this.destroyed$.complete();
866
870
  }
871
+ getFilteredChildren(elements) {
872
+ return this.filter ? this.filter(elements) : elements;
873
+ }
867
874
  }
868
875
  ElementChildrenComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ElementChildrenComponent, deps: [{ token: ElementContextService }, { token: RuntimeService }, { token: RuntimeEditorService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
869
- ElementChildrenComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.8", 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"], dependencies: [{ kind: "directive", type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: ["meta"] }, { kind: "component", type: ElementDropHandleComponent, selector: "vl-element-drop-handle", inputs: ["index", "parentPath"] }, { kind: "pipe", type: i5.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
876
+ ElementChildrenComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.8", type: ElementChildrenComponent, selector: "element-children", inputs: { filter: "filter" }, 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 getFilteredChildren(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"], dependencies: [{ kind: "directive", type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: ["meta"] }, { kind: "component", type: ElementDropHandleComponent, selector: "vl-element-drop-handle", inputs: ["index", "parentPath"] }, { kind: "pipe", type: i5.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
870
877
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ElementChildrenComponent, decorators: [{
871
878
  type: Component,
872
- args: [{ selector: 'element-children', changeDetection: ChangeDetectionStrategy.OnPush, 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"] }]
873
- }], ctorParameters: function () { return [{ type: ElementContextService }, { type: RuntimeService }, { type: RuntimeEditorService }, { type: i0.ChangeDetectorRef }]; } });
879
+ args: [{ selector: 'element-children', changeDetection: ChangeDetectionStrategy.OnPush, 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 getFilteredChildren(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"] }]
880
+ }], ctorParameters: function () { return [{ type: ElementContextService }, { type: RuntimeService }, { type: RuntimeEditorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { filter: [{
881
+ type: Input
882
+ }] } });
874
883
 
875
884
  class ElementChildrenModule {
876
885
  }
@@ -891,7 +900,7 @@ class ElementToolsPanelComponent {
891
900
  this.metadata = inject(ELEMENT_METADATA);
892
901
  this.config = inject(ELEMENT_CONFIG);
893
902
  this.elementRef = inject(ElementRef);
894
- this.showDeleteButton = !this.config.builder.suppressRemovable;
903
+ this.showDeleteButton = !this.config.builder?.suppressRemovable;
895
904
  const hostRect = this.elementRef.nativeElement.parentElement?.getBoundingClientRect();
896
905
  if (hostRect) {
897
906
  merge(this.elementRef.nativeElement.style, {
@@ -1001,6 +1010,7 @@ class ElementHoverPlugin {
1001
1010
  this.destroyed$ = new Subject();
1002
1011
  this.mouseOverListenerBound = this.mouseOverListener.bind(this);
1003
1012
  this.mouseLeaveListenerBound = this.mouseLeaveListener.bind(this);
1013
+ this.clickListenerBound = this.clickListener.bind(this);
1004
1014
  combineLatest([this.runtimeEditorService.editorMode$, this.isHovered$, this.isSelected$])
1005
1015
  .pipe(takeUntil(this.destroyed$))
1006
1016
  .subscribe(([editorMode]) => {
@@ -1027,10 +1037,12 @@ class ElementHoverPlugin {
1027
1037
  attachListeners() {
1028
1038
  this.el.nativeElement.addEventListener('mouseover', this.mouseOverListenerBound);
1029
1039
  this.el.nativeElement.addEventListener('mouseleave', this.mouseLeaveListenerBound);
1040
+ this.el.nativeElement.addEventListener('click', this.clickListenerBound);
1030
1041
  }
1031
1042
  detachListeners() {
1032
1043
  this.el.nativeElement.removeEventListener('mouseover', this.mouseOverListenerBound);
1033
1044
  this.el.nativeElement.removeEventListener('mouseleave', this.mouseLeaveListenerBound);
1045
+ this.el.nativeElement.removeEventListener('click', this.clickListenerBound);
1034
1046
  }
1035
1047
  mouseOverListener(e) {
1036
1048
  const path = e.composedPath();
@@ -1044,6 +1056,11 @@ class ElementHoverPlugin {
1044
1056
  this.isHovered$.next(isHovered);
1045
1057
  }
1046
1058
  }
1059
+ clickListener(e) {
1060
+ if (this.el.nativeElement === e.target) {
1061
+ this.runtimeEditorService.selectedElementPath$.next(this.metadata.path);
1062
+ }
1063
+ }
1047
1064
  mouseLeaveListener() {
1048
1065
  this.isHovered$.next(false);
1049
1066
  }
@@ -1161,28 +1178,103 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1161
1178
  type: Directive
1162
1179
  }], ctorParameters: function () { return [{ type: ElementComponent }]; } });
1163
1180
 
1181
+ const VELOCE_LIBS = {
1182
+ '@veloceapps/core': {
1183
+ isDefined,
1184
+ Operator,
1185
+ Predicate,
1186
+ parseJsonSafely,
1187
+ },
1188
+ '@veloceapps/components': {
1189
+ ToastService,
1190
+ ToastType,
1191
+ },
1192
+ '@veloceapps/api': {
1193
+ SalesforceApiService,
1194
+ QuoteApiService,
1195
+ DocumentTemplatesApiService,
1196
+ DocumentAttachmentApiService,
1197
+ RampApiService,
1198
+ CatalogApiService,
1199
+ DeltaApiService,
1200
+ PicklistsApiService,
1201
+ PriceApiService,
1202
+ ShoppingCartSettingsApiService,
1203
+ ConfigurationSettingsApiService,
1204
+ GuidedSellingApiService,
1205
+ },
1206
+ '@veloceapps/sdk/core': {
1207
+ ConfigurationService,
1208
+ QuoteDraftService,
1209
+ FlowConfigurationService,
1210
+ LineItemWorker,
1211
+ ProductImagesService,
1212
+ ContextService,
1213
+ ...lineItemUtils,
1214
+ },
1215
+ '@veloceapps/sdk/cms': {
1216
+ ...cmsInjectionTokens,
1217
+ ...cmsActions,
1218
+ TemplatesService,
1219
+ IntegrationState,
1220
+ ResourcesService,
1221
+ },
1222
+ };
1223
+ const VELOCE_LIBS_BACKWARDS_COMPATIBLE = Object.entries(VELOCE_LIBS).reduce((trunk, [key, value]) => ({ ...trunk, [key.replace('@veloceapps/', '@veloce/')]: value }), {});
1224
+ const vendorMap = {
1225
+ ...VELOCE_LIBS,
1226
+ // TODO: remove when projects/demos are migrated to @veloceapps organization libraries
1227
+ ...VELOCE_LIBS_BACKWARDS_COMPATIBLE,
1228
+ '@angular/core': i0,
1229
+ '@angular/forms': angularForms,
1230
+ rxjs: rxjs,
1231
+ 'rxjs/operators': rxjsOperators,
1232
+ lodash: lodash,
1233
+ };
1234
+
1235
+ const importRegexp = new RegExp(`import([ \\n\\t]*(?:[^ \\n\\t\\{\\}]+[ \\n\\t]*,?)?(?:[ \\n\\t]*\\{(?:[ \\n\\t]*[^ \\n\\t"'\\{\\}]+[ \\n\\t]*,?)+\\})?[ \\n\\t]*)from[ \\n\\t]*(['"])([^'"\\n]+)(?:['"]);`, 'g');
1236
+ const normalizeImports = (script, elementPath) => {
1237
+ const result = script.replace(importRegexp, (match, g1, g2, src) => {
1238
+ const imports = g1
1239
+ .trim()
1240
+ .slice(1, -1)
1241
+ .split(',')
1242
+ .map(item => item.trim());
1243
+ imports.forEach(item => {
1244
+ if (!vendorMap[src]?.[item]) {
1245
+ throw new Error(`Failed to import ${item} from '${src}' in ${elementPath}/script.ts`);
1246
+ }
1247
+ });
1248
+ return `const ${g1} = vendor['${src}'];`;
1249
+ });
1250
+ return result;
1251
+ };
1252
+ const getScriptClass = (metadata) => {
1253
+ if (!metadata?.script) {
1254
+ return;
1255
+ }
1256
+ const id = btoa(UUID.UUID());
1257
+ const script = document.createElement('script');
1258
+ script.type = `text/javascript`;
1259
+ let scriptContent = normalizeImports(metadata.script, metadata.path);
1260
+ const classMatch = /export class (\S+)/.exec(scriptContent);
1261
+ const className = classMatch?.[1];
1262
+ if (!classMatch || !className) {
1263
+ console.error("Script doesn't have exported class");
1264
+ return;
1265
+ }
1266
+ scriptContent = scriptContent.replace(classMatch[0], `class ${className}`);
1267
+ script.text = `var ${id} = function(vendor) {${scriptContent}
1268
+ return ${className}; };`;
1269
+ document.body.appendChild(script);
1270
+ const ScriptClass = window?.[id]?.(vendorMap);
1271
+ document.body.removeChild(script);
1272
+ return ScriptClass;
1273
+ };
1274
+
1164
1275
  class ScriptPlugin {
1165
1276
  constructor(host) {
1166
1277
  this.host = host;
1167
- this.normalizeImports = (script, elementPath) => {
1168
- 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');
1169
- const result = script.replace(regexp, (match, g1, g2, src) => {
1170
- const imports = g1
1171
- .trim()
1172
- .slice(1, -1)
1173
- .split(',')
1174
- .map(item => item.trim());
1175
- imports.forEach(item => {
1176
- if (!this.vendorMap[src]?.[item]) {
1177
- throw new Error(`Failed to import ${item} from '${src}' in ${elementPath}/script.ts`);
1178
- }
1179
- });
1180
- return `const ${g1} = vendor['${src}'];`;
1181
- });
1182
- return result;
1183
- };
1184
- this.document = this.host.injector.get(DOCUMENT);
1185
- this.vendorMap = this.host.injector.get(VENDOR_MAP);
1186
1278
  const elementMetadata = this.host.injector.get(ELEMENT_METADATA);
1187
1279
  const sharedElementMetadata = this.host.injector.get(SHARED_ELEMENT_METADATA);
1188
1280
  this.addScript(sharedElementMetadata);
@@ -1192,25 +1284,11 @@ class ScriptPlugin {
1192
1284
  if (!metadata?.script) {
1193
1285
  return;
1194
1286
  }
1195
- const id = btoa(UUID.UUID());
1196
- const script = this.document.createElement('script');
1197
- script.type = `text/javascript`;
1198
- let scriptContent = this.normalizeImports(metadata.script, metadata.path ?? metadata.name);
1199
- const classMatch = /export class (\S+)/.exec(scriptContent);
1200
- const className = classMatch?.[1];
1201
- if (!classMatch || !className) {
1202
- console.error("Script doesn't have exported class");
1203
- return;
1204
- }
1205
- scriptContent = scriptContent.replace(classMatch[0], `class ${className}`);
1206
- script.text = `var ${id} = function(vendor) {${scriptContent}
1207
- return ${className}; };`;
1208
- this.document.body.appendChild(script);
1209
- const ScriptClass = window[id](this.vendorMap);
1287
+ const ScriptClass = getScriptClass(metadata);
1210
1288
  if (ScriptClass instanceof Object) {
1211
- this.host.registerPlugin(new ScriptClass(this.host));
1289
+ const instance = new ScriptClass(this.host);
1290
+ this.host.registerPlugin(instance);
1212
1291
  }
1213
- this.document.body.removeChild(script);
1214
1292
  }
1215
1293
  }
1216
1294
  ScriptPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ScriptPlugin, deps: [{ token: ElementComponent }], target: i0.ɵɵFactoryTarget.Directive });
@@ -1223,29 +1301,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1223
1301
  * ScriptPlugin must always be the last plugin in the list to make sure user code is running after all pre-initializers.
1224
1302
  */
1225
1303
  const CONFIG = {
1304
+ CUSTOMIZATION_PAGE: {
1305
+ component: ElementComponent,
1306
+ plugins: [IOPlugin, ScriptPlugin],
1307
+ },
1226
1308
  CUSTOM: {
1227
1309
  component: ElementComponent,
1228
1310
  plugins: [IOPlugin, ElementHoverPlugin, ScriptPlugin],
1229
- builder: {},
1230
1311
  },
1231
1312
  CONTAINER: {
1232
1313
  component: ElementComponent,
1233
1314
  defaultTemplate: '<element-children></element-children>',
1234
1315
  plugins: [ScriptPlugin],
1235
- builder: {},
1236
1316
  },
1237
1317
  SERVICE: {
1238
1318
  component: ElementComponent,
1239
1319
  plugins: [IOPlugin, ScriptPlugin],
1240
1320
  suppressTemplate: true,
1241
1321
  suppressStyles: true,
1242
- builder: {},
1243
1322
  },
1244
1323
  REFERENCE: {
1245
1324
  component: ElementComponent,
1246
1325
  plugins: [IOPlugin, ScriptPlugin],
1247
1326
  suppressTemplate: true,
1248
- builder: {},
1249
1327
  },
1250
1328
  PAGE: {
1251
1329
  component: ElementComponent,
@@ -1743,63 +1821,10 @@ const LAYOUT = {
1743
1821
  },
1744
1822
  };
1745
1823
 
1746
- const VELOCE_LIBS = {
1747
- '@veloceapps/core': {
1748
- isDefined,
1749
- Operator,
1750
- Predicate,
1751
- parseJsonSafely,
1752
- },
1753
- '@veloceapps/components': {
1754
- ToastService,
1755
- ToastType,
1756
- },
1757
- '@veloceapps/api': {
1758
- SalesforceApiService,
1759
- QuoteApiService,
1760
- DocumentTemplatesApiService,
1761
- DocumentAttachmentApiService,
1762
- RampApiService,
1763
- CatalogApiService,
1764
- DeltaApiService,
1765
- PicklistsApiService,
1766
- PriceApiService,
1767
- ShoppingCartSettingsApiService,
1768
- ConfigurationSettingsApiService,
1769
- GuidedSellingApiService,
1770
- },
1771
- '@veloceapps/sdk/core': {
1772
- ConfigurationService,
1773
- QuoteDraftService,
1774
- FlowConfigurationService,
1775
- LineItemWorker,
1776
- ProductImagesService,
1777
- ContextService,
1778
- ...lineItemUtils,
1779
- },
1780
- '@veloceapps/sdk/cms': {
1781
- ...cmsInjectionTokens,
1782
- ...cmsActions,
1783
- TemplatesService,
1784
- IntegrationState,
1785
- ResourcesService,
1786
- },
1787
- };
1788
- const VELOCE_LIBS_BACKWARDS_COMPATIBLE = Object.entries(VELOCE_LIBS).reduce((trunk, [key, value]) => ({ ...trunk, [key.replace('@veloceapps/', '@veloce/')]: value }), {});
1789
- const vendorMap = {
1790
- ...VELOCE_LIBS,
1791
- // TODO: remove when projects/demos are migrated to @veloceapps organization libraries
1792
- ...VELOCE_LIBS_BACKWARDS_COMPATIBLE,
1793
- '@angular/core': i0,
1794
- '@angular/forms': angularForms,
1795
- rxjs: rxjs,
1796
- 'rxjs/operators': rxjsOperators,
1797
- lodash: lodash,
1798
- };
1799
-
1800
1824
  class ElementsResolver {
1801
- constructor(uiDef, elements, sharedElements = []) {
1825
+ constructor(uiDef, elements, sharedElements = [], config) {
1802
1826
  this.uiDef = uiDef;
1827
+ this.config = config;
1803
1828
  this.renderableElements = [];
1804
1829
  this.sharedElements = [];
1805
1830
  const transpiledElements = this.transpileScripts(elements);
@@ -1809,6 +1834,10 @@ class ElementsResolver {
1809
1834
  .concat(transpiledSharedElements);
1810
1835
  this.elements = transpiledElements.map(el => this.processElementMetadata(el)).filter(isDefined);
1811
1836
  this.renderableElements = this.getRenderableElements(this.elements);
1837
+ this.uiDefMetadata = {
1838
+ ...this.uiDef,
1839
+ customization: this.uiDef.customization ?? this.getDefaultCustomizationState(),
1840
+ };
1812
1841
  }
1813
1842
  addElement(element) {
1814
1843
  if (element.isShared) {
@@ -1851,7 +1880,9 @@ class ElementsResolver {
1851
1880
  getRenderableElements(elements) {
1852
1881
  const renderable = [];
1853
1882
  for (const el of elements) {
1854
- if (!this.isSharedElement(el)) {
1883
+ // In `customizationMode` render only element with CUSTOMIZATION_PAGE type
1884
+ const typePerMode = Boolean(this.config?.customizationMode) === (el.type === 'CUSTOMIZATION_PAGE');
1885
+ if (!this.isSharedElement(el) && typePerMode) {
1855
1886
  const children = el.children.filter(child => !this.isSharedElement(child));
1856
1887
  const renderableChildren = this.getRenderableElements(children);
1857
1888
  renderable.push({ ...el, children }, ...renderableChildren);
@@ -1930,7 +1961,7 @@ class ElementsResolver {
1930
1961
  }
1931
1962
  resolveElement(element) {
1932
1963
  const config = CONFIG[element.type];
1933
- const defaultPlugins = DEFAULT_PLUGINS[this.uiDef.type] ?? [];
1964
+ const defaultPlugins = DEFAULT_PLUGINS[this.uiDefMetadata.type] ?? [];
1934
1965
  if (!config) {
1935
1966
  console.warn(`Unknown element type "${element.type}"`);
1936
1967
  return;
@@ -1942,11 +1973,10 @@ class ElementsResolver {
1942
1973
  ...(styles ? { styles: [styles] } : {}),
1943
1974
  providers: [
1944
1975
  { provide: DEFAULT_PLUGINS_TOKEN, useValue: defaultPlugins },
1945
- { provide: UI_DEFINITION_METADATA, useValue: this.uiDef },
1976
+ { provide: UI_DEFINITION_METADATA, useValue: this.uiDefMetadata },
1946
1977
  { provide: ELEMENT_METADATA, useValue: element },
1947
1978
  { provide: SHARED_ELEMENT_METADATA, useValue: this.getSharedElement(element) },
1948
1979
  { provide: ELEMENT_CONFIG, useValue: config },
1949
- { provide: VENDOR_MAP, useValue: vendorMap },
1950
1980
  ],
1951
1981
  };
1952
1982
  const cmp = Component(component)(class C extends config.component {
@@ -1978,6 +2008,14 @@ class ElementsResolver {
1978
2008
  result += '}\n';
1979
2009
  return result;
1980
2010
  }
2011
+ getDefaultCustomizationState() {
2012
+ const customizationPage = this.elements.find(el => el.type === 'CUSTOMIZATION_PAGE');
2013
+ if (!customizationPage?.script) {
2014
+ return;
2015
+ }
2016
+ const c = getScriptClass(customizationPage);
2017
+ return c && 'default' in c ? c.default : undefined;
2018
+ }
1981
2019
  }
1982
2020
 
1983
2021
  class FederatedHostDirective {
@@ -2082,7 +2120,7 @@ class CompilationService {
2082
2120
  constructor(injector) {
2083
2121
  this.injector = injector;
2084
2122
  }
2085
- compileUIDefinition$(uiDefinition) {
2123
+ compileUIDefinition$(uiDefinition, config) {
2086
2124
  return of([]).pipe(map(() => {
2087
2125
  const { children, pages, components, ...uiDefinitionMeta } = uiDefinition;
2088
2126
  this.uiDefinitionMeta = uiDefinitionMeta;
@@ -2090,7 +2128,7 @@ class CompilationService {
2090
2128
  const sharedElements = components ?? [];
2091
2129
  const metadata = elements.map(element => elementToMetadata(element));
2092
2130
  const sharedMetadata = sharedElements.map(element => elementToMetadata(element));
2093
- this.elementsResolver = new ElementsResolver(uiDefinition, metadata, sharedMetadata);
2131
+ this.elementsResolver = new ElementsResolver(uiDefinition, metadata, sharedMetadata, config);
2094
2132
  const componentTypes = this.elementsResolver.getNgComponents();
2095
2133
  const module = this.getModule(componentTypes);
2096
2134
  return {
@@ -2324,5 +2362,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
2324
2362
  * Generated bundle index. Do not edit.
2325
2363
  */
2326
2364
 
2327
- export { ApplyProductConfigurationAction, CloseDocGenAction, CmsAction, 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, insertElement, isSharedElement, isValidScript, metadataToElement, normalizeElementMetadata, parseBoundPath, parsePath, removeElement, stringifyElementMetadata };
2365
+ export { ApplyProductConfigurationAction, CloseDocGenAction, CmsAction, 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, doesElementSupportIO, elementToMetadata, extendElementMetadata, extractElementMetadata, findElementByModule, findElementByPath, flattenElements, getAbsolutePath, getElementConfig, insertElement, isSharedElement, isValidScript, metadataToElement, normalizeElementMetadata, parseBoundPath, parsePath, removeElement, stringifyElementMetadata };
2328
2366
  //# sourceMappingURL=veloceapps-sdk-cms.mjs.map