@sap-ux/preview-middleware 0.12.13 → 0.12.14

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
@@ -53,6 +53,7 @@ const UI5_LIBS = [
53
53
  'sap.webanalytics',
54
54
  'sap.zen'
55
55
  ];
56
+ const DEFAULT_LIVERELOAD_PORT = 35729;
56
57
  /**
57
58
  * Default theme
58
59
  */
@@ -210,11 +211,15 @@ class FlpSandbox {
210
211
  templatePreviewUrl = templatePreviewUrl.replace('?', `?sap-ui-layer=${rta.layer}&`);
211
212
  }
212
213
  const template = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../templates/flp/editor.html'), 'utf-8');
214
+ const envPort = process.env.FIORI_TOOLS_LIVERELOAD_PORT;
215
+ let livereloadPort = envPort ? parseInt(envPort, 10) : DEFAULT_LIVERELOAD_PORT;
216
+ livereloadPort = isNaN(livereloadPort) ? DEFAULT_LIVERELOAD_PORT : livereloadPort;
213
217
  const html = (0, ejs_1.render)(template, {
214
218
  previewUrl: templatePreviewUrl,
215
219
  telemetry: (_c = (_b = rta.options) === null || _b === void 0 ? void 0 : _b.telemetry) !== null && _c !== void 0 ? _c : false,
216
220
  appName: (_d = rta.options) === null || _d === void 0 ? void 0 : _d.appName,
217
- scenario
221
+ scenario,
222
+ livereloadPort
218
223
  });
219
224
  res.status(200).contentType('html').send(html);
220
225
  });
@@ -10,6 +10,7 @@ sap.ui.define([
10
10
  const deletePropertyChanges = ___sap_ux_private_control_property_editor_common['deletePropertyChanges'];
11
11
  const propertyChangeFailed = ___sap_ux_private_control_property_editor_common['propertyChangeFailed'];
12
12
  const FlexChangesEndPoints = ___sap_ux_private_control_property_editor_common['FlexChangesEndPoints'];
13
+ const reloadApplication = ___sap_ux_private_control_property_editor_common['reloadApplication'];
13
14
  const applyChange = ___flex_change['applyChange'];
14
15
  function assertProperties(properties, target) {
15
16
  for (const property of properties) {
@@ -62,10 +63,15 @@ sap.ui.define([
62
63
  }
63
64
  } else if (deletePropertyChanges.match(action)) {
64
65
  await this.deleteChange(action.payload.controlId, action.payload.propertyName, action.payload.fileName);
66
+ } else if (reloadApplication.match(action)) {
67
+ await this.options.rta.stop(false, true);
65
68
  }
66
69
  });
67
70
  await this.fetchSavedChanges();
68
71
  this.updateStack();
72
+ this.options.rta.attachStop(() => {
73
+ location.reload();
74
+ });
69
75
  this.options.rta.attachUndoRedoStackModified(this.createOnStackChangeHandler());
70
76
  }
71
77
  updateStack() {
@@ -180,6 +186,7 @@ sap.ui.define([
180
186
  value = command.getProperty('newBinding');
181
187
  break;
182
188
  }
189
+ const {fileName} = command.getPreparedChange().getDefinition();
183
190
  if (changeType === 'propertyChange' || changeType === 'propertyBindingChange') {
184
191
  result = {
185
192
  type: 'pending',
@@ -188,7 +195,8 @@ sap.ui.define([
188
195
  propertyName: command.getProperty('propertyName'),
189
196
  isActive: index >= inactiveCommandCount,
190
197
  value,
191
- controlName: command.getElement().getMetadata().getName().split('.').pop() ?? ''
198
+ controlName: command.getElement().getMetadata().getName().split('.').pop() ?? '',
199
+ fileName
192
200
  };
193
201
  } else {
194
202
  result = {
@@ -196,7 +204,8 @@ sap.ui.define([
196
204
  controlId: selectorId,
197
205
  changeType,
198
206
  isActive: index >= inactiveCommandCount,
199
- controlName: changeType === 'addXMLAtExtensionPoint' ? command.getSelector().name ?? '' : command.getElement().getMetadata().getName().split('.').pop() ?? ''
207
+ controlName: changeType === 'addXMLAtExtensionPoint' ? command.getSelector().name ?? '' : command.getElement().getMetadata().getName().split('.').pop() ?? '',
208
+ fileName
200
209
  };
201
210
  }
202
211
  return result;
@@ -9,7 +9,8 @@ import {
9
9
  changeStackModified,
10
10
  deletePropertyChanges,
11
11
  propertyChangeFailed,
12
- FlexChangesEndPoints
12
+ FlexChangesEndPoints,
13
+ reloadApplication
13
14
  } from '@sap-ux-private/control-property-editor-common';
14
15
  import { applyChange } from './flex-change';
15
16
  import type { SelectionService } from '../selection';
@@ -127,12 +128,17 @@ export class ChangeService {
127
128
  }
128
129
  } else if (deletePropertyChanges.match(action)) {
129
130
  await this.deleteChange(action.payload.controlId, action.payload.propertyName, action.payload.fileName);
131
+ } else if (reloadApplication.match(action)) {
132
+ await this.options.rta.stop(false, true);
130
133
  }
131
134
  });
132
135
 
133
136
  await this.fetchSavedChanges();
134
137
  this.updateStack();
135
-
138
+ this.options.rta.attachStop(() => {
139
+ // eslint-disable-next-line fiori-custom/sap-no-location-reload
140
+ location.reload();
141
+ });
136
142
  this.options.rta.attachUndoRedoStackModified(this.createOnStackChangeHandler());
137
143
  }
138
144
 
@@ -300,6 +306,7 @@ export class ChangeService {
300
306
  value = command.getProperty('newBinding');
301
307
  break;
302
308
  }
309
+ const { fileName } = command.getPreparedChange().getDefinition();
303
310
  if (changeType === 'propertyChange' || changeType === 'propertyBindingChange') {
304
311
  result = {
305
312
  type: 'pending',
@@ -308,7 +315,8 @@ export class ChangeService {
308
315
  propertyName: command.getProperty('propertyName'),
309
316
  isActive: index >= inactiveCommandCount,
310
317
  value,
311
- controlName: command.getElement().getMetadata().getName().split('.').pop() ?? ''
318
+ controlName: command.getElement().getMetadata().getName().split('.').pop() ?? '',
319
+ fileName
312
320
  };
313
321
  } else {
314
322
  result = {
@@ -319,7 +327,8 @@ export class ChangeService {
319
327
  controlName:
320
328
  changeType === 'addXMLAtExtensionPoint'
321
329
  ? command.getSelector().name ?? ''
322
- : command.getElement().getMetadata().getName().split('.').pop() ?? ''
330
+ : command.getElement().getMetadata().getName().split('.').pop() ?? '',
331
+ fileName
323
332
  };
324
333
  }
325
334
 
@@ -7,18 +7,24 @@ sap.ui.define([
7
7
  './documentation',
8
8
  'sap/base/Log',
9
9
  './logger',
10
- './ui5-utils'
11
- ], function (___sap_ux_private_control_property_editor_common, ___outline_index, ___selection, ___changes_service, ___documentation, Log, ___logger, ___ui5_utils) {
10
+ './ui5-utils',
11
+ '../flp/WorkspaceConnector'
12
+ ], function (___sap_ux_private_control_property_editor_common, ___outline_index, ___selection, ___changes_service, ___documentation, Log, ___logger, ___ui5_utils, __workspaceConnector) {
12
13
  'use strict';
14
+ function _interopRequireDefault(obj) {
15
+ return obj && obj.__esModule && typeof obj.default !== 'undefined' ? obj.default : obj;
16
+ }
13
17
  const startPostMessageCommunication = ___sap_ux_private_control_property_editor_common['startPostMessageCommunication'];
14
18
  const iconsLoaded = ___sap_ux_private_control_property_editor_common['iconsLoaded'];
15
19
  const enableTelemetry = ___sap_ux_private_control_property_editor_common['enableTelemetry'];
20
+ const storageFileChanged = ___sap_ux_private_control_property_editor_common['storageFileChanged'];
16
21
  const initOutline = ___outline_index['initOutline'];
17
22
  const SelectionService = ___selection['SelectionService'];
18
23
  const ChangeService = ___changes_service['ChangeService'];
19
24
  const loadDefaultLibraries = ___documentation['loadDefaultLibraries'];
20
25
  const logger = ___logger['logger'];
21
26
  const getIcons = ___ui5_utils['getIcons'];
27
+ const workspaceConnector = _interopRequireDefault(__workspaceConnector);
22
28
  function init(rta) {
23
29
  Log.info('Initializing Control Property Editor');
24
30
  const flexSettings = rta.getFlexSettings();
@@ -51,6 +57,11 @@ sap.ui.define([
51
57
  }
52
58
  initOutline(rta, sendAction).catch(error => Log.error('Error during initialization of Control Property Editor', error));
53
59
  const icons = getIcons();
60
+ workspaceConnector.storage.fileChangeRequestNotifier = (fileName, kind, changeType) => {
61
+ if (changeType && changeType !== 'appdescr_fe_changePageConfiguration' || kind === 'delete') {
62
+ sendAction(storageFileChanged(fileName?.replace('sap.ui.fl.', '')));
63
+ }
64
+ };
54
65
  sendAction(iconsLoaded(icons));
55
66
  } catch (error) {
56
67
  Log.error('Error during initialization of Control Property Editor', error);
@@ -2,7 +2,8 @@ import type { ExternalAction } from '@sap-ux-private/control-property-editor-com
2
2
  import {
3
3
  startPostMessageCommunication,
4
4
  iconsLoaded,
5
- enableTelemetry
5
+ enableTelemetry,
6
+ storageFileChanged
6
7
  } from '@sap-ux-private/control-property-editor-common';
7
8
  import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
8
9
 
@@ -14,6 +15,7 @@ import { loadDefaultLibraries } from './documentation';
14
15
  import Log from 'sap/base/Log';
15
16
  import { logger } from './logger';
16
17
  import { getIcons } from './ui5-utils';
18
+ import workspaceConnector from '../flp/WorkspaceConnector';
17
19
 
18
20
  export default function init(rta: RuntimeAuthoring): Promise<void> {
19
21
  Log.info('Initializing Control Property Editor');
@@ -62,6 +64,18 @@ export default function init(rta: RuntimeAuthoring): Promise<void> {
62
64
  Log.error('Error during initialization of Control Property Editor', error)
63
65
  );
64
66
  const icons = getIcons();
67
+
68
+ // hook the file deletion listener to the UI5 workspace connector
69
+ workspaceConnector.storage.fileChangeRequestNotifier = (
70
+ fileName: string,
71
+ kind: 'delete' | 'create',
72
+ changeType?: string
73
+ ) => {
74
+ if ((changeType && changeType !== 'appdescr_fe_changePageConfiguration') || kind === 'delete') {
75
+ sendAction(storageFileChanged(fileName?.replace('sap.ui.fl.', '')));
76
+ }
77
+ };
78
+
65
79
  sendAction(iconsLoaded(icons));
66
80
  } catch (error) {
67
81
  Log.error('Error during initialization of Control Property Editor', error);
@@ -9,12 +9,20 @@ sap.ui.define(["sap/base/util/merge", "sap/ui/fl/write/api/connectors/ObjectStor
9
9
  layers: [Layer.VENDOR, Layer.CUSTOMER_BASE],
10
10
  storage: {
11
11
  _itemsStoredAsObjects: true,
12
+ fileChangeRequestNotifier: undefined,
12
13
  setItem: function (_key, change) {
13
14
  const settings = getFlexSettings();
14
15
  if (settings) {
15
16
  change.support ??= {};
16
17
  change.support.generator = settings.generator;
17
18
  }
19
+ if (typeof this.fileChangeRequestNotifier === 'function' && change.fileName) {
20
+ try {
21
+ this.fileChangeRequestNotifier(change.fileName, 'create', change.changeType);
22
+ } catch (e) {
23
+ // exceptions in the listener call are ignored
24
+ }
25
+ }
18
26
  return fetch(CHANGES_API_PATH, {
19
27
  method: 'POST',
20
28
  body: JSON.stringify(change, null, 2),
@@ -24,6 +32,13 @@ sap.ui.define(["sap/base/util/merge", "sap/ui/fl/write/api/connectors/ObjectStor
24
32
  });
25
33
  },
26
34
  removeItem: function (key) {
35
+ if (typeof this.fileChangeRequestNotifier === 'function') {
36
+ try {
37
+ this.fileChangeRequestNotifier(key, 'delete');
38
+ } catch (e) {
39
+ // exceptions in the listener call are ignored
40
+ }
41
+ }
27
42
  return fetch(CHANGES_API_PATH, {
28
43
  method: 'DELETE',
29
44
  body: JSON.stringify({
@@ -8,6 +8,7 @@ const connector = merge({}, ObjectStorageConnector, {
8
8
  layers: [Layer.VENDOR, Layer.CUSTOMER_BASE],
9
9
  storage: {
10
10
  _itemsStoredAsObjects: true,
11
+ fileChangeRequestNotifier: undefined,
11
12
  setItem: function (_key: string, change: FlexChange) {
12
13
  const settings = getFlexSettings();
13
14
  if (settings) {
@@ -15,6 +16,14 @@ const connector = merge({}, ObjectStorageConnector, {
15
16
  change.support.generator = settings.generator;
16
17
  }
17
18
 
19
+ if (typeof this.fileChangeRequestNotifier === 'function' && change.fileName) {
20
+ try {
21
+ this.fileChangeRequestNotifier(change.fileName, 'create', change.changeType);
22
+ } catch (e) {
23
+ // exceptions in the listener call are ignored
24
+ }
25
+ }
26
+
18
27
  return fetch(CHANGES_API_PATH, {
19
28
  method: 'POST',
20
29
  body: JSON.stringify(change, null, 2),
@@ -24,6 +33,14 @@ const connector = merge({}, ObjectStorageConnector, {
24
33
  });
25
34
  },
26
35
  removeItem: function (key: string) {
36
+ if (typeof this.fileChangeRequestNotifier === 'function') {
37
+ try {
38
+ this.fileChangeRequestNotifier(key, 'delete');
39
+ } catch (e) {
40
+ // exceptions in the listener call are ignored
41
+ }
42
+ }
43
+
27
44
  return fetch(CHANGES_API_PATH, {
28
45
  method: 'DELETE',
29
46
  body: JSON.stringify({ fileName: key }),
@@ -48,7 +65,7 @@ const connector = merge({}, ObjectStorageConnector, {
48
65
  const changes = await response.json();
49
66
  return changes;
50
67
  }
51
- },
68
+ } as typeof ObjectStorageConnector.storage,
52
69
  loadFeatures: async function () {
53
70
  const features = await ObjectStorageConnector.loadFeatures();
54
71
 
@@ -2,6 +2,8 @@ import { FlexSettings } from 'sap/ui/rta/RuntimeAuthoring';
2
2
 
3
3
  export interface FlexChange {
4
4
  [key: string]: string | object | undefined;
5
+ changeType: string;
6
+ fileName: string;
5
7
  support: {
6
8
  generator?: string;
7
9
  };
@@ -8,7 +8,7 @@ sap.ui.define((function () { 'use strict';
8
8
 
9
9
  (function (exports) {
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.showMessage = exports.changeStackModified = exports.propertyChangeFailed = exports.propertyChanged = exports.changeProperty = exports.outlineChanged = exports.deletePropertyChanges = exports.addExtensionPoint = exports.selectControl = exports.controlSelected = exports.iconsLoaded = exports.EXTERNAL_ACTION_PREFIX = exports.scenario = exports.CHECKBOX_EDITOR_TYPE = exports.DROPDOWN_EDITOR_TYPE = exports.INPUT_EDITOR_TYPE = exports.STRING_VALUE_TYPE = exports.FLOAT_VALUE_TYPE = exports.INTEGER_VALUE_TYPE = exports.BOOLEAN_VALUE_TYPE = void 0;
11
+ exports.storageFileChanged = exports.reloadApplication = exports.showMessage = exports.changeStackModified = exports.propertyChangeFailed = exports.propertyChanged = exports.changeProperty = exports.outlineChanged = exports.deletePropertyChanges = exports.addExtensionPoint = exports.selectControl = exports.controlSelected = exports.iconsLoaded = exports.EXTERNAL_ACTION_PREFIX = exports.scenario = exports.CHECKBOX_EDITOR_TYPE = exports.DROPDOWN_EDITOR_TYPE = exports.INPUT_EDITOR_TYPE = exports.STRING_VALUE_TYPE = exports.FLOAT_VALUE_TYPE = exports.INTEGER_VALUE_TYPE = exports.BOOLEAN_VALUE_TYPE = void 0;
12
12
  exports.BOOLEAN_VALUE_TYPE = 'boolean';
13
13
  exports.INTEGER_VALUE_TYPE = 'integer';
14
14
  exports.FLOAT_VALUE_TYPE = 'float';
@@ -72,6 +72,8 @@ sap.ui.define((function () { 'use strict';
72
72
  exports.propertyChangeFailed = createExternalAction('change-property-failed');
73
73
  exports.changeStackModified = createExternalAction('change-stack-modified');
74
74
  exports.showMessage = createExternalAction('show-dialog-message');
75
+ exports.reloadApplication = createExternalAction('reload-application');
76
+ exports.storageFileChanged = createExternalAction('storage-file-changed');
75
77
 
76
78
  } (api));
77
79
 
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.12.13",
12
+ "version": "0.12.14",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -24,8 +24,8 @@
24
24
  "dependencies": {
25
25
  "ejs": "3.1.9",
26
26
  "@sap-ux/logger": "0.5.1",
27
- "@sap-ux/adp-tooling": "0.9.4",
28
- "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.15"
27
+ "@sap-ux/adp-tooling": "0.9.5",
28
+ "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.16"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/ejs": "3.1.2",
@@ -39,8 +39,8 @@
39
39
  "supertest": "6.3.3",
40
40
  "@sap-ux-private/playwright": "0.0.3",
41
41
  "dotenv": "16.3.1",
42
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.9.2",
43
- "@sap-ux/project-access": "1.19.0",
42
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.9.3",
43
+ "@sap-ux/project-access": "1.19.2",
44
44
  "@sap-ux/axios-extension": "1.11.3",
45
45
  "@sap-ux/store": "0.5.0"
46
46
  },
@@ -17,7 +17,8 @@
17
17
  previewUrl: '<%- previewUrl %>',
18
18
  telemetry: <%- telemetry %>,
19
19
  rootElementId: 'root',
20
- scenario: '<%- scenario %>'
20
+ scenario: '<%- scenario %>',
21
+ livereloadPort: <%- livereloadPort %>
21
22
  });
22
23
  </script>
23
24
  </body>