@sap-ux/preview-middleware 0.16.35 → 0.16.37

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.
@@ -61,7 +61,7 @@ sap.ui.define(["sap/ui/core/library", "sap/ui/core/mvc/Controller", "sap/m/Messa
61
61
  checkForExistingChange: function _checkForExistingChange(fragmentName) {
62
62
  const allCommands = this.rta.getCommandStack().getCommands();
63
63
  return allCommands.some(command => {
64
- if (command?.getProperty('name') === 'composite') {
64
+ if (typeof command.getCommands === 'function') {
65
65
  const addXmlCommand = command.getCommands().find(c => c?.getProperty('name') === 'addXMLAtExtensionPoint');
66
66
  return addXmlCommand && matchesFragmentName(addXmlCommand, fragmentName);
67
67
  } else {
@@ -126,7 +126,7 @@ export default abstract class BaseDialog<T extends BaseDialogModel = BaseDialogM
126
126
  const allCommands = this.rta.getCommandStack().getCommands();
127
127
 
128
128
  return allCommands.some((command: FlexCommand) => {
129
- if (command?.getProperty('name') === 'composite') {
129
+ if (typeof command.getCommands === 'function') {
130
130
  const addXmlCommand = command
131
131
  .getCommands()
132
132
  .find((c: FlexCommand) => c?.getProperty('name') === 'addXMLAtExtensionPoint');
@@ -4,10 +4,10 @@ sap.ui.define([
4
4
  '../cpe/init',
5
5
  './init-dialogs',
6
6
  'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
7
- 'sap/ui/VersionInfo',
8
7
  './ui5-version-utils',
9
- '../cpe/error-utils'
10
- ], function (log, __init, ___init_dialogs, ___sap_ux_private_control_property_editor_common, VersionInfo, ___ui5_version_utils, ___cpe_error_utils) {
8
+ '../cpe/error-utils',
9
+ '../utils/version'
10
+ ], function (log, __init, ___init_dialogs, ___sap_ux_private_control_property_editor_common, ___ui5_version_utils, ___cpe_error_utils, ___utils_version) {
11
11
  'use strict';
12
12
  function _interopRequireDefault(obj) {
13
13
  return obj && obj.__esModule && typeof obj.default !== 'undefined' ? obj.default : obj;
@@ -32,8 +32,9 @@ sap.ui.define([
32
32
  const enableTelemetry = ___sap_ux_private_control_property_editor_common['enableTelemetry'];
33
33
  const getUI5VersionValidationMessage = ___ui5_version_utils['getUI5VersionValidationMessage'];
34
34
  const getError = ___cpe_error_utils['getError'];
35
+ const getUi5Version = ___utils_version['getUi5Version'];
35
36
  var __exports = async function (rta) {
36
- const version = (await VersionInfo.load({ library: 'sap.ui.core' }))?.version;
37
+ const version = await getUi5Version();
37
38
  const versionParts = version.split('.');
38
39
  const minor = parseInt(versionParts[1], 10);
39
40
  const flexSettings = rta.getFlexSettings();
@@ -8,16 +8,14 @@ import {
8
8
  startPostMessageCommunication,
9
9
  enableTelemetry
10
10
  } from '@sap-ux-private/control-property-editor-common';
11
-
12
11
  import { ActionHandler } from '../cpe/types';
13
- import VersionInfo from 'sap/ui/VersionInfo';
14
12
  import { getUI5VersionValidationMessage } from './ui5-version-utils';
15
13
  import UI5Element from 'sap/ui/dt/Element';
16
14
  import { getError } from '../cpe/error-utils';
17
- import type {SingleVersionInfo} from '../../types/global';
15
+ import { getUi5Version } from '../utils/version';
18
16
 
19
17
  export default async function (rta: RuntimeAuthoring) {
20
- const version = (await VersionInfo.load({library:'sap.ui.core'}) as SingleVersionInfo)?.version;
18
+ const version = await getUi5Version();
21
19
  const versionParts = version.split('.');
22
20
  const minor = parseInt(versionParts[1], 10);
23
21
  const flexSettings = rta.getFlexSettings();
@@ -36,6 +36,9 @@ sap.ui.define(["sap/m/MessageToast"], function (MessageToast) {
36
36
  * the specified fragment name; otherwise, returns false.
37
37
  */
38
38
  function matchesFragmentName(command, fragmentName) {
39
+ if (typeof command.getPreparedChange !== 'function') {
40
+ return false;
41
+ }
39
42
  const change = command.getPreparedChange().getDefinition();
40
43
  return change.content?.fragmentPath?.includes(`${fragmentName}.fragment.xml`) || false;
41
44
  }
@@ -45,6 +45,9 @@ export function createDeferred<T>(): Deferred<T> {
45
45
  * the specified fragment name; otherwise, returns false.
46
46
  */
47
47
  export function matchesFragmentName(command: FlexCommand, fragmentName: string): boolean {
48
+ if (typeof command.getPreparedChange !== 'function') {
49
+ return false;
50
+ }
48
51
  const change = command.getPreparedChange().getDefinition() as unknown as FragmentChange;
49
52
  return change.content?.fragmentPath?.includes(`${fragmentName}.fragment.xml`) || false;
50
53
  }
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
  sap.ui.define([
3
3
  'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
4
- 'sap/ui/VersionInfo'
5
- ], function (___sap_ux_private_control_property_editor_common, VersionInfo) {
4
+ '../utils/version'
5
+ ], function (___sap_ux_private_control_property_editor_common, ___utils_version) {
6
6
  'use strict';
7
7
  function __ui5_require_async(path) {
8
8
  return new Promise(function (resolve, reject) {
@@ -18,9 +18,10 @@ sap.ui.define([
18
18
  });
19
19
  }
20
20
  const storageFileChanged = ___sap_ux_private_control_property_editor_common['storageFileChanged'];
21
+ const getUi5Version = ___utils_version['getUi5Version'];
21
22
  class WorkspaceConnectorService {
22
23
  async init(sendAction) {
23
- const version = (await VersionInfo.load({ library: 'sap.ui.core' }))?.version;
24
+ const version = await getUi5Version();
24
25
  const versionParts = version.split('.');
25
26
  const minor = parseInt(versionParts[1], 10);
26
27
  if (minor > 72) {
@@ -1,7 +1,6 @@
1
1
  import { ExternalAction, storageFileChanged } from '@sap-ux-private/control-property-editor-common';
2
2
  import { ActionSenderFunction } from './types';
3
- import VersionInfo from 'sap/ui/VersionInfo';
4
- import type {SingleVersionInfo} from '../../types/global';
3
+ import { getUi5Version } from '../utils/version';
5
4
 
6
5
  /**
7
6
  * A Class of WorkspaceConnectorService
@@ -13,7 +12,7 @@ export class WorkspaceConnectorService {
13
12
  * @param sendAction action sender function
14
13
  */
15
14
  public async init(sendAction: ActionSenderFunction): Promise<void> {
16
- const version = (await VersionInfo.load({library:'sap.ui.core'}) as SingleVersionInfo)?.version;
15
+ const version = await getUi5Version();
17
16
  const versionParts = version.split('.');
18
17
  const minor = parseInt(versionParts[1], 10);
19
18
  if (minor > 72) {
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["./utils", "sap/ui/VersionInfo"], function (___utils, VersionInfo) {
3
+ sap.ui.define(["./utils", "../../utils/version"], function (___utils, ____utils_version) {
4
4
  "use strict";
5
5
 
6
6
  const isEditable = ___utils["isEditable"];
7
7
  const isReuseComponent = ___utils["isReuseComponent"];
8
+ const getUi5Version = ____utils_version["getUi5Version"];
8
9
  /**
9
10
  * Retrieves additional data for a given control ID.
10
11
  *
@@ -75,9 +76,7 @@ sap.ui.define(["./utils", "sap/ui/VersionInfo"], function (___utils, VersionInfo
75
76
  async function transformNodes(input, scenario, reuseComponentsIds) {
76
77
  const stack = [...input];
77
78
  const items = [];
78
- const version = (await VersionInfo.load({
79
- library: 'sap.ui.core'
80
- }))?.version;
79
+ const version = await getUi5Version();
81
80
  const versionParts = version.split('.');
82
81
  const minor = parseInt(versionParts[1], 10);
83
82
  while (stack.length) {
@@ -2,8 +2,7 @@ import type { OutlineNode } from '@sap-ux-private/control-property-editor-common
2
2
  import type { OutlineViewNode } from 'sap/ui/rta/command/OutlineService';
3
3
  import type { Scenario } from 'sap/ui/fl/Scenario';
4
4
  import { isEditable, isReuseComponent } from './utils';
5
- import VersionInfo from 'sap/ui/VersionInfo';
6
- import type {SingleVersionInfo} from '../../../types/global';
5
+ import { getUi5Version } from '../../utils/version';
7
6
 
8
7
  interface AdditionalData {
9
8
  text?: string;
@@ -88,7 +87,7 @@ export async function transformNodes(
88
87
  ): Promise<OutlineNode[]> {
89
88
  const stack = [...input];
90
89
  const items: OutlineNode[] = [];
91
- const version = (await VersionInfo.load({library:'sap.ui.core'}) as SingleVersionInfo)?.version;
90
+ const version = await getUi5Version();
92
91
  const versionParts = version.split('.');
93
92
  const minor = parseInt(versionParts[1], 10);
94
93
  while (stack.length) {
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["sap/base/util/merge", "sap/ui/fl/write/api/connectors/ObjectStorageConnector", "sap/ui/fl/Layer", "sap/ui/VersionInfo", "./common"], function (merge, ObjectStorageConnector, Layer, VersionInfo, ___common) {
3
+ sap.ui.define(["sap/base/util/merge", "sap/ui/fl/write/api/connectors/ObjectStorageConnector", "sap/ui/fl/Layer", "./common", "../utils/version"], function (merge, ObjectStorageConnector, Layer, ___common, ___utils_version) {
4
4
  "use strict";
5
5
 
6
6
  const CHANGES_API_PATH = ___common["CHANGES_API_PATH"];
7
7
  const getFlexSettings = ___common["getFlexSettings"];
8
+ const getUi5Version = ___utils_version["getUi5Version"];
8
9
  const connector = merge({}, ObjectStorageConnector, {
9
10
  layers: [Layer.VENDOR, Layer.CUSTOMER_BASE],
10
11
  storage: {
@@ -68,9 +69,7 @@ sap.ui.define(["sap/base/util/merge", "sap/ui/fl/write/api/connectors/ObjectStor
68
69
  },
69
70
  loadFeatures: async function () {
70
71
  const features = await ObjectStorageConnector.loadFeatures();
71
- const version = (await VersionInfo.load({
72
- library: 'sap.ui.core'
73
- }))?.version;
72
+ const version = await getUi5Version();
74
73
  const [majorVersion, minorVersion] = version.split('.').map(v => parseInt(v, 10));
75
74
  features.isVariantAdaptationEnabled = majorVersion >= 1 && minorVersion >= 90;
76
75
  const settings = getFlexSettings();
@@ -1,9 +1,8 @@
1
1
  import merge from 'sap/base/util/merge';
2
2
  import ObjectStorageConnector from 'sap/ui/fl/write/api/connectors/ObjectStorageConnector';
3
3
  import Layer from 'sap/ui/fl/Layer';
4
- import VersionInfo from 'sap/ui/VersionInfo';
5
- import type {SingleVersionInfo} from '../../types/global';
6
4
  import { CHANGES_API_PATH, FlexChange, getFlexSettings } from './common';
5
+ import { getUi5Version } from '../utils/version';
7
6
 
8
7
  const connector = merge({}, ObjectStorageConnector, {
9
8
  layers: [Layer.VENDOR, Layer.CUSTOMER_BASE],
@@ -69,8 +68,7 @@ const connector = merge({}, ObjectStorageConnector, {
69
68
  } as typeof ObjectStorageConnector.storage,
70
69
  loadFeatures: async function () {
71
70
  const features = await ObjectStorageConnector.loadFeatures();
72
-
73
- const version = (await VersionInfo.load({library:'sap.ui.core'}) as SingleVersionInfo)?.version;
71
+ const version = await getUi5Version();
74
72
  const [majorVersion, minorVersion] = version.split('.').map((v: string) => parseInt(v, 10));
75
73
  features.isVariantAdaptationEnabled = majorVersion >= 1 && minorVersion >= 90;
76
74
  const settings = getFlexSettings();
@@ -5,10 +5,10 @@ sap.ui.define([
5
5
  'sap/ui/core/IconPool',
6
6
  'sap/base/i18n/ResourceBundle',
7
7
  '../adp/api-handler',
8
- 'sap/ui/VersionInfo',
9
8
  '../cpe/error-utils',
10
- './initConnectors'
11
- ], function (Log, ___sap_ux_private_control_property_editor_common, IconPool, ResourceBundle, ___adp_api_handler, VersionInfo, ___cpe_error_utils, __initConnectors) {
9
+ './initConnectors',
10
+ '../utils/version'
11
+ ], function (Log, ___sap_ux_private_control_property_editor_common, IconPool, ResourceBundle, ___adp_api_handler, ___cpe_error_utils, __initConnectors, ___utils_version) {
12
12
  'use strict';
13
13
  function _interopRequireDefault(obj) {
14
14
  return obj && obj.__esModule && typeof obj.default !== 'undefined' ? obj.default : obj;
@@ -17,6 +17,7 @@ sap.ui.define([
17
17
  const getManifestAppdescr = ___adp_api_handler['getManifestAppdescr'];
18
18
  const getError = ___cpe_error_utils['getError'];
19
19
  const initConnectors = _interopRequireDefault(__initConnectors);
20
+ const getUi5Version = ___utils_version['getUi5Version'];
20
21
  const UI5_LIBS = [
21
22
  'sap.apf',
22
23
  'sap.base',
@@ -88,7 +89,7 @@ sap.ui.define([
88
89
  function registerModules(dataFromAppIndex) {
89
90
  Object.keys(dataFromAppIndex).forEach(function (moduleDefinitionKey) {
90
91
  const moduleDefinition = dataFromAppIndex[moduleDefinitionKey];
91
- if (moduleDefinition && moduleDefinition.dependencies) {
92
+ if (moduleDefinition?.dependencies) {
92
93
  moduleDefinition.dependencies.forEach(function (dependency) {
93
94
  if (dependency.url && dependency.url.length > 0 && dependency.type === 'UI5LIB') {
94
95
  Log.info('Registering Library ' + dependency.componentId + ' from server ' + dependency.url);
@@ -159,7 +160,7 @@ sap.ui.define([
159
160
  const urlParams = new URLSearchParams(window.location.search);
160
161
  const container = sap?.ushell?.Container ?? sap.ui.require('sap/ushell/Container');
161
162
  let scenario = '';
162
- const version = (await VersionInfo.load({ library: 'sap.ui.core' }))?.version;
163
+ const version = await getUi5Version();
163
164
  if (flex) {
164
165
  const flexSettings = JSON.parse(flex);
165
166
  scenario = flexSettings.scenario;
@@ -7,10 +7,9 @@ import IconPool from 'sap/ui/core/IconPool';
7
7
  import ResourceBundle from 'sap/base/i18n/ResourceBundle';
8
8
  import AppState from 'sap/ushell/services/AppState';
9
9
  import { getManifestAppdescr } from '../adp/api-handler';
10
- import VersionInfo from 'sap/ui/VersionInfo';
11
10
  import { getError } from '../cpe/error-utils';
12
11
  import initConnectors from './initConnectors';
13
- import type {SingleVersionInfo} from '../../types/global';
12
+ import { getUi5Version } from '../utils/version';
14
13
 
15
14
  /**
16
15
  * SAPUI5 delivered namespaces from https://ui5.sap.com/#/api/sap
@@ -142,7 +141,7 @@ async function getManifestLibs(appUrls: string[]): Promise<string> {
142
141
  function registerModules(dataFromAppIndex: AppIndexData) {
143
142
  Object.keys(dataFromAppIndex).forEach(function (moduleDefinitionKey) {
144
143
  const moduleDefinition = dataFromAppIndex[moduleDefinitionKey];
145
- if (moduleDefinition && moduleDefinition.dependencies) {
144
+ if (moduleDefinition?.dependencies) {
146
145
  moduleDefinition.dependencies.forEach(function (dependency) {
147
146
  if (dependency.url && dependency.url.length > 0 && dependency.type === 'UI5LIB') {
148
147
  Log.info('Registering Library ' + dependency.componentId + ' from server ' + dependency.url);
@@ -270,7 +269,7 @@ export async function init({
270
269
  const urlParams = new URLSearchParams(window.location.search);
271
270
  const container = sap?.ushell?.Container ?? sap.ui.require('sap/ushell/Container');
272
271
  let scenario: string = '';
273
- const version = (await VersionInfo.load({library:'sap.ui.core'}) as SingleVersionInfo)?.version;
272
+ const version = await getUi5Version();
274
273
  // Register RTA if configured
275
274
  if (flex) {
276
275
  const flexSettings = JSON.parse(flex) as FlexSettings;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/ui/VersionInfo", "sap/base/Log"], function (VersionInfo, Log) {
4
+ "use strict";
5
+
6
+ /**
7
+ * Retrieve the UI5 version from sap.ui.core library
8
+ */
9
+ async function getUi5Version() {
10
+ let version = (await VersionInfo.load({
11
+ library: 'sap.ui.core'
12
+ }))?.version;
13
+ if (!version) {
14
+ Log.error('Could not get UI5 version of application. Using 1.121.0 as fallback.');
15
+ version = '1.121.0';
16
+ }
17
+ return version;
18
+ }
19
+ var __exports = {
20
+ __esModule: true
21
+ };
22
+ __exports.getUi5Version = getUi5Version;
23
+ return __exports;
24
+ });
25
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1,15 @@
1
+ import type { SingleVersionInfo } from '../../types/global';
2
+ import VersionInfo from 'sap/ui/VersionInfo';
3
+ import Log from 'sap/base/Log';
4
+
5
+ /**
6
+ * Retrieve the UI5 version from sap.ui.core library
7
+ */
8
+ export async function getUi5Version() {
9
+ let version = ((await VersionInfo.load({ library: 'sap.ui.core' })) as SingleVersionInfo)?.version;
10
+ if (!version) {
11
+ Log.error('Could not get UI5 version of application. Using 1.121.0 as fallback.');
12
+ version = '1.121.0';
13
+ }
14
+ return version;
15
+ }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apreview-middleware"
11
11
  },
12
- "version": "0.16.35",
12
+ "version": "0.16.37",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -27,7 +27,7 @@
27
27
  "mem-fs-editor": "9.4.0",
28
28
  "@sap-ux/logger": "0.6.0",
29
29
  "@sap-ux/btp-utils": "0.15.0",
30
- "@sap-ux/adp-tooling": "0.12.25",
30
+ "@sap-ux/adp-tooling": "0.12.26",
31
31
  "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.27",
32
32
  "@sap-ux/project-access": "1.26.3"
33
33
  },
@@ -45,8 +45,8 @@
45
45
  "supertest": "6.3.3",
46
46
  "@sap-ux-private/playwright": "0.1.0",
47
47
  "dotenv": "16.3.1",
48
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.10.5",
49
- "@sap-ux/axios-extension": "1.16.2",
48
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.10.7",
49
+ "@sap-ux/axios-extension": "1.16.3",
50
50
  "@sap-ux/store": "0.7.0",
51
51
  "@sap-ux/ui5-info": "0.7.0",
52
52
  "@sap-ux/i18n": "0.1.0"