@sap-ux/preview-middleware 1.0.24 → 1.0.26

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/dist/base/flp.js CHANGED
@@ -341,7 +341,6 @@ export class FlpSandbox {
341
341
  await this.setApplicationDependencies();
342
342
  // get filepath from request. Use dummy url to extract it from originalUrl if needed
343
343
  const filePath = 'query' in req ? req.path : new URL('http://dummyHost' + req.originalUrl).pathname; //NOSONAR
344
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
345
344
  const file = await this.project.byPath(filePath);
346
345
  if (file) {
347
346
  this.logger.info(`HTML file returned at ${filePath} is loaded from the file system.`);
@@ -734,7 +733,6 @@ export class FlpSandbox {
734
733
  */
735
734
  async testRunnerHtmlGetHandler(res, next, config, htmlTemplate, id) {
736
735
  this.logger.debug(`Serving test route: ${config.path}`);
737
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
738
736
  const file = await this.project.byPath(config.path);
739
737
  if (file) {
740
738
  this.logger.warn(`HTML file returned at ${config.path} is loaded from the file system.`);
@@ -1,8 +1,25 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["sap/ui/rta/command/CommandFactory", "open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common", "./validator", "../../utils/fe-v4"], function (CommandFactory, ___sap_ux_private_control_property_editor_common, ___validatorjs, ____utils_fe_v4js) {
3
+ sap.ui.define(["open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common", "./validator", "../../utils/fe-v4"], function (___sap_ux_private_control_property_editor_common, ___validatorjs, ____utils_fe_v4js) {
4
4
  "use strict";
5
5
 
6
+ function __ui5_require_async(path) {
7
+ return new Promise(function (resolve, reject) {
8
+ sap.ui.require([path], function (module) {
9
+ if (!(module && module.__esModule)) {
10
+ module = module === null || !(typeof module === "object" && path.endsWith("/library")) ? {
11
+ default: module
12
+ } : module;
13
+ Object.defineProperty(module, "__esModule", {
14
+ value: true
15
+ });
16
+ }
17
+ resolve(module);
18
+ }, function (err) {
19
+ reject(err);
20
+ });
21
+ });
22
+ }
6
23
  const PropertyType = ___sap_ux_private_control_property_editor_common["PropertyType"];
7
24
  const validateBindingModel = ___validatorjs["validateBindingModel"];
8
25
  const createManifestPropertyChange = ____utils_fe_v4js["createManifestPropertyChange"];
@@ -44,6 +61,7 @@ sap.ui.define(["sap/ui/rta/command/CommandFactory", "open/ux/preview/client/thir
44
61
  propertyName: change.propertyName,
45
62
  [property]: change.value
46
63
  };
64
+ const CommandFactory = (await __ui5_require_async('sap/ui/rta/command/CommandFactory')).default;
47
65
  const command = await CommandFactory.getCommandFor(modifiedControl, changeType, modifiedValue, null, flexSettings);
48
66
  await rta.getCommandStack().pushAndExecute(command);
49
67
  } else if (change.propertyType === PropertyType.Configuration) {
@@ -1,5 +1,4 @@
1
1
  import type FlexCommand from 'sap/ui/rta/command/FlexCommand';
2
- import CommandFactory from 'sap/ui/rta/command/CommandFactory';
3
2
  import { PropertyType, type PropertyChange } from '@sap-ux-private/control-property-editor-common';
4
3
  import type { UI5AdaptationOptions } from '../types.js';
5
4
  import { validateBindingModel } from './validator.js';
@@ -45,6 +44,7 @@ export async function applyChange(options: UI5AdaptationOptions, change: Propert
45
44
  [property]: change.value
46
45
  };
47
46
 
47
+ const CommandFactory = (await import('sap/ui/rta/command/CommandFactory')).default;
48
48
  const command = await CommandFactory.getCommandFor<FlexCommand>(
49
49
  modifiedControl,
50
50
  changeType,
@@ -5,8 +5,8 @@ import {
5
5
  requestControlContextMenu
6
6
  } from '@sap-ux-private/control-property-editor-common';
7
7
  import { ActionSenderFunction, SubscribeFunction } from './types.js';
8
- import RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
9
- import { ActionService } from 'sap/ui/rta/service/Action';
8
+ import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
9
+ import type { ActionService } from 'sap/ui/rta/service/Action';
10
10
  import { DialogFactory } from '../adp/dialog-factory.js';
11
11
  import { getTextBundle } from '../i18n.js';
12
12
  import Log from 'sap/base/Log';
@@ -89,10 +89,10 @@ sap.ui.define(["sap/base/Log", "../../utils/core", "../../utils/error", "../util
89
89
  controlIndex[node.controlType] = [node];
90
90
  }
91
91
  }
92
- function addToPropertyIdMap(node, propertyIdMap) {
92
+ async function addToPropertyIdMap(node, propertyIdMap) {
93
93
  const control = getControlById(node.controlId);
94
94
  if (control) {
95
- const overlay = getOverlay(control);
95
+ const overlay = await getOverlay(control);
96
96
  const overlayData = overlay?.getDesignTimeMetadata().getData();
97
97
  if (!overlayData?.manifestPropertyPath) {
98
98
  return;
@@ -146,7 +146,7 @@ sap.ui.define(["sap/base/Log", "../../utils/core", "../../utils/error", "../util
146
146
  children: transformedChildren
147
147
  };
148
148
  indexNode(controlIndex, node);
149
- addToPropertyIdMap(node, propertyIdMap);
149
+ await addToPropertyIdMap(node, propertyIdMap);
150
150
  items.push(node);
151
151
  }
152
152
  if (isAdp && isExtPoint) {
@@ -101,10 +101,10 @@ function indexNode(controlIndex: ControlTreeIndex, node: OutlineNode): void {
101
101
  }
102
102
  }
103
103
 
104
- function addToPropertyIdMap(node: OutlineNode, propertyIdMap: Map<string, string[]>): void {
104
+ async function addToPropertyIdMap(node: OutlineNode, propertyIdMap: Map<string, string[]>): Promise<void> {
105
105
  const control = getControlById(node.controlId);
106
106
  if (control) {
107
- const overlay = getOverlay(control);
107
+ const overlay = await getOverlay(control);
108
108
  const overlayData = overlay?.getDesignTimeMetadata().getData();
109
109
  if (!overlayData?.manifestPropertyPath) {
110
110
  return;
@@ -170,7 +170,7 @@ export async function transformNodes(
170
170
  };
171
171
 
172
172
  indexNode(controlIndex, node);
173
- addToPropertyIdMap(node, propertyIdMap);
173
+ await addToPropertyIdMap(node, propertyIdMap);
174
174
 
175
175
  items.push(node);
176
176
  }
@@ -134,7 +134,7 @@ sap.ui.define(["open/ux/preview/client/thirdparty/@sap-ux-private/control-proper
134
134
  this.changeService.onStackChange(async event => {
135
135
  const control = event.detail.controls.find(ctrl => ctrl === this.currentSelection);
136
136
  if (control) {
137
- const overlay = getOverlay(control);
137
+ const overlay = await getOverlay(control);
138
138
  await this.buildProperties(control, sendAction, overlay);
139
139
  }
140
140
  });
@@ -157,7 +157,7 @@ export class SelectionService implements Service {
157
157
  this.changeService.onStackChange(async (event) => {
158
158
  const control = event.detail.controls.find((ctrl) => ctrl === this.currentSelection);
159
159
  if (control) {
160
- const overlay = getOverlay(control);
160
+ const overlay = await getOverlay(control);
161
161
  await this.buildProperties(control, sendAction, overlay);
162
162
  }
163
163
  });
@@ -1,8 +1,25 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["sap/ui/core/mvc/XMLView", "sap/ui/core/UIComponent", "../utils/core", "sap/ui/dt/OverlayRegistry", "sap/ui/dt/OverlayUtil"], function (XMLView, UIComponent, ___utils_corejs, OverlayRegistry, OverlayUtil) {
3
+ sap.ui.define(["sap/ui/core/mvc/XMLView", "sap/ui/core/UIComponent", "../utils/core"], function (XMLView, UIComponent, ___utils_corejs) {
4
4
  "use strict";
5
5
 
6
+ function __ui5_require_async(path) {
7
+ return new Promise(function (resolve, reject) {
8
+ sap.ui.require([path], function (module) {
9
+ if (!(module && module.__esModule)) {
10
+ module = module === null || !(typeof module === "object" && path.endsWith("/library")) ? {
11
+ default: module
12
+ } : module;
13
+ Object.defineProperty(module, "__esModule", {
14
+ value: true
15
+ });
16
+ }
17
+ resolve(module);
18
+ }, function (err) {
19
+ reject(err);
20
+ });
21
+ });
22
+ }
6
23
  const getComponent = ___utils_corejs["getComponent"];
7
24
  /**
8
25
  * Get runtime control.
@@ -92,7 +109,32 @@ sap.ui.define(["sap/ui/core/mvc/XMLView", "sap/ui/core/UIComponent", "../utils/c
92
109
  }, {});
93
110
  return manifestProperties;
94
111
  }
95
- const getOverlay = control => {
112
+
113
+ // eslint-disable-next-line @sap-ux/fiori-tools/sap-no-global-variable
114
+ let overlayModulesPromise;
115
+
116
+ /**
117
+ * Lazily loads and caches the OverlayRegistry and OverlayUtil modules.
118
+ * The dynamic imports are executed only once; subsequent calls return the same resolved promise.
119
+ *
120
+ * @returns Promise resolving to an object containing the OverlayRegistry and OverlayUtil modules.
121
+ */
122
+ function getOverlayModules() {
123
+ overlayModulesPromise ??= Promise.all([__ui5_require_async('sap/ui/dt/OverlayRegistry'), __ui5_require_async('sap/ui/dt/OverlayUtil')]).then(([{
124
+ default: OverlayRegistry
125
+ }, {
126
+ default: OverlayUtil
127
+ }]) => ({
128
+ OverlayRegistry,
129
+ OverlayUtil
130
+ }));
131
+ return overlayModulesPromise;
132
+ }
133
+ const getOverlay = async control => {
134
+ const {
135
+ OverlayRegistry,
136
+ OverlayUtil
137
+ } = await getOverlayModules();
96
138
  let controlOverlay = OverlayRegistry.getOverlay(control);
97
139
  if (!controlOverlay?.getDomRef()) {
98
140
  //look for closest control
@@ -1,18 +1,16 @@
1
1
  import type ManagedObject from 'sap/ui/base/ManagedObject';
2
2
  import type Control from 'sap/ui/core/Control';
3
3
  import type ElementOverlay from 'sap/ui/dt/ElementOverlay';
4
+ import type OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
5
+ import type OverlayUtil from 'sap/ui/dt/OverlayUtil';
4
6
  import DataType from 'sap/ui/base/DataType';
5
7
  import ComponentContainer from 'sap/ui/core/ComponentContainer';
6
8
  import XMLView from 'sap/ui/core/mvc/XMLView';
7
9
  import UIComponent from 'sap/ui/core/UIComponent';
8
-
9
10
  import { getComponent } from '../utils/core.js';
10
11
  import { DesigntimeSetting } from 'sap/ui/dt/DesignTimeMetadata';
11
12
  import { ChangeService } from './changes/index.js';
12
13
  import UI5Element from 'sap/ui/core/Element';
13
- import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
14
- import OverlayUtil from 'sap/ui/dt/OverlayUtil';
15
-
16
14
 
17
15
  export interface PropertiesInfo {
18
16
  defaultValue: string;
@@ -151,7 +149,28 @@ export function getManifestProperties(
151
149
  return manifestProperties;
152
150
  }
153
151
 
154
- export const getOverlay = (control: UI5Element): ElementOverlay | undefined => {
152
+ // eslint-disable-next-line @sap-ux/fiori-tools/sap-no-global-variable
153
+ let overlayModulesPromise: Promise<{
154
+ OverlayRegistry: typeof OverlayRegistry;
155
+ OverlayUtil: typeof OverlayUtil;
156
+ }> | undefined;
157
+
158
+ /**
159
+ * Lazily loads and caches the OverlayRegistry and OverlayUtil modules.
160
+ * The dynamic imports are executed only once; subsequent calls return the same resolved promise.
161
+ *
162
+ * @returns Promise resolving to an object containing the OverlayRegistry and OverlayUtil modules.
163
+ */
164
+ function getOverlayModules() {
165
+ overlayModulesPromise ??= Promise.all([
166
+ import('sap/ui/dt/OverlayRegistry'),
167
+ import('sap/ui/dt/OverlayUtil')
168
+ ]).then(([{ default: OverlayRegistry }, { default: OverlayUtil }]) => ({ OverlayRegistry, OverlayUtil }));
169
+ return overlayModulesPromise;
170
+ }
171
+
172
+ export const getOverlay = async (control: UI5Element): Promise<ElementOverlay | undefined> => {
173
+ const { OverlayRegistry, OverlayUtil } = await getOverlayModules();
155
174
  let controlOverlay = OverlayRegistry.getOverlay(control);
156
175
  if (!controlOverlay?.getDomRef()) {
157
176
  //look for closest control
@@ -107,7 +107,7 @@ sap.ui.define(["sap/ui/core/Component", "./core", "../cpe/utils"], function (Com
107
107
  * @returns A Promise resolving to an array of FlexCommand objects.
108
108
  */
109
109
  async function createManifestPropertyChange(modifiedControl, flexSettings, propertyChanges, propertyPathExtraSegments) {
110
- const overlay = getOverlay(modifiedControl);
110
+ const overlay = await getOverlay(modifiedControl);
111
111
  if (!overlay) {
112
112
  return undefined;
113
113
  }
@@ -108,7 +108,7 @@ export async function createManifestPropertyChange(
108
108
  propertyChanges: Record<string, string | string[] | boolean | number | object | undefined>,
109
109
  propertyPathExtraSegments?: string[]
110
110
  ): Promise<FlexCommand | undefined> {
111
- const overlay = getOverlay(modifiedControl);
111
+ const overlay = await getOverlay(modifiedControl);
112
112
  if (!overlay) {
113
113
  return undefined;
114
114
  }
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "bugs": {
11
11
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apreview-middleware"
12
12
  },
13
- "version": "1.0.24",
13
+ "version": "1.0.26",
14
14
  "license": "Apache-2.0",
15
15
  "author": "@SAP/ux-tools-team",
16
16
  "main": "dist/index.js",
@@ -28,7 +28,7 @@
28
28
  "mem-fs-editor": "9.4.0",
29
29
  "qrcode": "1.5.4",
30
30
  "@sap/bas-sdk": "3.13.7",
31
- "@sap-ux/adp-tooling": "1.0.17",
31
+ "@sap-ux/adp-tooling": "1.0.18",
32
32
  "@sap-ux/btp-utils": "2.0.2",
33
33
  "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@1.0.5",
34
34
  "@sap-ux/feature-toggle": "1.0.2",
@@ -54,7 +54,7 @@
54
54
  "nock": "14.0.11",
55
55
  "npm-run-all2": "8.0.4",
56
56
  "supertest": "7.2.2",
57
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@1.0.24",
57
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@1.0.26",
58
58
  "@sap-ux-private/playwright": "1.0.2",
59
59
  "@sap-ux/axios-extension": "2.0.3",
60
60
  "@sap-ux/store": "2.0.1",