@sap-ux/preview-middleware 0.12.13 → 0.12.15

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.
Files changed (36) hide show
  1. package/dist/base/flp.js +6 -1
  2. package/dist/client/adp/api-handler.js +141 -141
  3. package/dist/client/adp/command-executor.js +54 -54
  4. package/dist/client/adp/control-utils.js +44 -44
  5. package/dist/client/adp/controllers/AddFragment.controller.js +206 -206
  6. package/dist/client/adp/controllers/BaseDialog.controller.js +57 -57
  7. package/dist/client/adp/controllers/ControllerExtension.controller.js +174 -174
  8. package/dist/client/adp/controllers/ExtensionPoint.controller.js +100 -100
  9. package/dist/client/adp/init-dialogs.js +74 -74
  10. package/dist/client/adp/ui5-version-utils.js +63 -63
  11. package/dist/client/adp/utils.js +33 -33
  12. package/dist/client/cpe/changes/flex-change.js +51 -51
  13. package/dist/client/cpe/changes/index.js +10 -10
  14. package/dist/client/cpe/changes/service.js +11 -2
  15. package/dist/client/cpe/changes/service.ts +13 -4
  16. package/dist/client/cpe/changes/validator.js +35 -35
  17. package/dist/client/cpe/documentation.js +164 -164
  18. package/dist/client/cpe/init.js +13 -2
  19. package/dist/client/cpe/init.ts +15 -1
  20. package/dist/client/cpe/logger.js +30 -30
  21. package/dist/client/cpe/outline/nodes.js +84 -84
  22. package/dist/client/cpe/outline/utils.js +37 -37
  23. package/dist/client/cpe/types.js +4 -4
  24. package/dist/client/cpe/ui5-utils.js +49 -49
  25. package/dist/client/cpe/utils.js +48 -48
  26. package/dist/client/flp/WorkspaceConnector.js +84 -69
  27. package/dist/client/flp/WorkspaceConnector.ts +18 -1
  28. package/dist/client/flp/common.js +28 -28
  29. package/dist/client/flp/common.ts +2 -0
  30. package/dist/client/flp/enableFakeConnector.js +77 -77
  31. package/dist/client/flp/init.js +220 -220
  32. package/dist/client/flp/initConnectors.js +33 -33
  33. package/dist/client/flp/initRta.js +178 -178
  34. package/dist/client/thirdparty/@sap-ux-private/control-property-editor-common.js +3 -1
  35. package/package.json +6 -6
  36. package/templates/flp/editor.html +2 -1
@@ -1,39 +1,39 @@
1
- "use strict";
2
-
3
- sap.ui.define(["../control-data", "../utils", "sap/ui/dt/OverlayUtil", "sap/ui/dt/OverlayRegistry", "../ui5-utils"], function (___control_data, ___utils, OverlayUtil, OverlayRegistry, ___ui5_utils) {
4
- "use strict";
5
-
6
- const buildControlData = ___control_data["buildControlData"];
7
- const getRuntimeControl = ___utils["getRuntimeControl"];
8
- const getComponent = ___ui5_utils["getComponent"];
9
- const isEditable = function () {
10
- let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
11
- let editable = false;
12
- const control = sap.ui.getCore().byId(id);
13
- if (!control) {
14
- const component = getComponent(id);
15
- if (component) {
16
- return editable;
17
- }
18
- } else {
19
- let controlOverlay = OverlayRegistry.getOverlay(control);
20
- if (!controlOverlay?.getDomRef()) {
21
- //look for closest control
22
- controlOverlay = OverlayUtil.getClosestOverlayFor(control);
23
- }
24
- if (controlOverlay) {
25
- const runtimeControl = getRuntimeControl(controlOverlay);
26
- const controlData = buildControlData(runtimeControl, controlOverlay);
27
- const prop = controlData.properties.find(item => item.isEnabled === true);
28
- editable = prop !== undefined;
29
- }
30
- }
31
- return editable;
32
- };
33
- var __exports = {
34
- __esModule: true
35
- };
36
- __exports.isEditable = isEditable;
37
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define(["../control-data", "../utils", "sap/ui/dt/OverlayUtil", "sap/ui/dt/OverlayRegistry", "../ui5-utils"], function (___control_data, ___utils, OverlayUtil, OverlayRegistry, ___ui5_utils) {
4
+ "use strict";
5
+
6
+ const buildControlData = ___control_data["buildControlData"];
7
+ const getRuntimeControl = ___utils["getRuntimeControl"];
8
+ const getComponent = ___ui5_utils["getComponent"];
9
+ const isEditable = function () {
10
+ let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
11
+ let editable = false;
12
+ const control = sap.ui.getCore().byId(id);
13
+ if (!control) {
14
+ const component = getComponent(id);
15
+ if (component) {
16
+ return editable;
17
+ }
18
+ } else {
19
+ let controlOverlay = OverlayRegistry.getOverlay(control);
20
+ if (!controlOverlay?.getDomRef()) {
21
+ //look for closest control
22
+ controlOverlay = OverlayUtil.getClosestOverlayFor(control);
23
+ }
24
+ if (controlOverlay) {
25
+ const runtimeControl = getRuntimeControl(controlOverlay);
26
+ const controlData = buildControlData(runtimeControl, controlOverlay);
27
+ const prop = controlData.properties.find(item => item.isEnabled === true);
28
+ editable = prop !== undefined;
29
+ }
30
+ }
31
+ return editable;
32
+ };
33
+ var __exports = {
34
+ __esModule: true
35
+ };
36
+ __exports.isEditable = isEditable;
37
+ return __exports;
38
38
  });
39
39
  //# sourceMappingURL=utils.js.map
@@ -1,6 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
5
  });
6
6
  //# sourceMappingURL=types.js.map
@@ -1,51 +1,51 @@
1
- "use strict";
2
-
3
- sap.ui.define(["sap/ui/core/Component", "sap/ui/core/IconPool"], function (Component, IconPool) {
4
- "use strict";
5
-
6
- /**
7
- * Gets Component by id.
8
- *
9
- * @param id - unique identifier for control
10
- * @returns Component | undefined
11
- */
12
- function getComponent(id) {
13
- if (Component?.get) {
14
- return Component.get(id);
15
- } else {
16
- // Older version must be still supported until maintenance period.
17
- return sap.ui.getCore().getComponent(id); // NOSONAR
18
- }
19
- }
20
-
21
- /**
22
- * Get ui5 icons.
23
- *
24
- * @returns IconDetails[]
25
- */
26
- function getIcons() {
27
- return IconPool.getIconNames('undefined').map(icon => {
28
- const iconInfo = IconPool.getIconInfo(icon);
29
- return {
30
- name: icon.toLowerCase(),
31
- content: iconInfo.content,
32
- fontFamily: iconInfo.fontFamily
33
- };
34
- }).sort((item1, item2) => {
35
- if (item1.name < item2.name) {
36
- return -1;
37
- }
38
- if (item1.name > item2.name) {
39
- return 1;
40
- }
41
- return 0;
42
- });
43
- }
44
- var __exports = {
45
- __esModule: true
46
- };
47
- __exports.getComponent = getComponent;
48
- __exports.getIcons = getIcons;
49
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/ui/core/Component", "sap/ui/core/IconPool"], function (Component, IconPool) {
4
+ "use strict";
5
+
6
+ /**
7
+ * Gets Component by id.
8
+ *
9
+ * @param id - unique identifier for control
10
+ * @returns Component | undefined
11
+ */
12
+ function getComponent(id) {
13
+ if (Component?.get) {
14
+ return Component.get(id);
15
+ } else {
16
+ // Older version must be still supported until maintenance period.
17
+ return sap.ui.getCore().getComponent(id); // NOSONAR
18
+ }
19
+ }
20
+
21
+ /**
22
+ * Get ui5 icons.
23
+ *
24
+ * @returns IconDetails[]
25
+ */
26
+ function getIcons() {
27
+ return IconPool.getIconNames('undefined').map(icon => {
28
+ const iconInfo = IconPool.getIconInfo(icon);
29
+ return {
30
+ name: icon.toLowerCase(),
31
+ content: iconInfo.content,
32
+ fontFamily: iconInfo.fontFamily
33
+ };
34
+ }).sort((item1, item2) => {
35
+ if (item1.name < item2.name) {
36
+ return -1;
37
+ }
38
+ if (item1.name > item2.name) {
39
+ return 1;
40
+ }
41
+ return 0;
42
+ });
43
+ }
44
+ var __exports = {
45
+ __esModule: true
46
+ };
47
+ __exports.getComponent = getComponent;
48
+ __exports.getIcons = getIcons;
49
+ return __exports;
50
50
  });
51
51
  //# sourceMappingURL=ui5-utils.js.map
@@ -1,50 +1,50 @@
1
- "use strict";
2
-
3
- sap.ui.define([], function () {
4
- "use strict";
5
-
6
- /**
7
- * Get runtime control.
8
- *
9
- * @param overlayControl - element overlay.
10
- * @returns ManagedObject
11
- */
12
- function getRuntimeControl(overlayControl) {
13
- let runtimeControl;
14
- if (overlayControl.getElementInstance) {
15
- runtimeControl = overlayControl.getElementInstance();
16
- } else {
17
- runtimeControl = overlayControl.getElement();
18
- }
19
- return runtimeControl;
20
- }
21
-
22
- /**
23
- * Get library of a control name.
24
- *
25
- * @param controlName - name of the ui5 control eg: sap.m.Button.
26
- * @returns Promise<string>
27
- */
28
- async function getLibrary(controlName) {
29
- return new Promise(resolve => {
30
- const controlPath = controlName.replace(/\./g, '/');
31
- sap.ui.require([controlPath], control => {
32
- const contMetadata = control.getMetadata();
33
- // getLibraryName method does not exist on events
34
- if (contMetadata?.getLibraryName) {
35
- const contLibName = contMetadata.getLibraryName();
36
- resolve(contLibName);
37
- } else {
38
- resolve(''); // return empty for events
39
- }
40
- });
41
- });
42
- }
43
- var __exports = {
44
- __esModule: true
45
- };
46
- __exports.getRuntimeControl = getRuntimeControl;
47
- __exports.getLibrary = getLibrary;
48
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define([], function () {
4
+ "use strict";
5
+
6
+ /**
7
+ * Get runtime control.
8
+ *
9
+ * @param overlayControl - element overlay.
10
+ * @returns ManagedObject
11
+ */
12
+ function getRuntimeControl(overlayControl) {
13
+ let runtimeControl;
14
+ if (overlayControl.getElementInstance) {
15
+ runtimeControl = overlayControl.getElementInstance();
16
+ } else {
17
+ runtimeControl = overlayControl.getElement();
18
+ }
19
+ return runtimeControl;
20
+ }
21
+
22
+ /**
23
+ * Get library of a control name.
24
+ *
25
+ * @param controlName - name of the ui5 control eg: sap.m.Button.
26
+ * @returns Promise<string>
27
+ */
28
+ async function getLibrary(controlName) {
29
+ return new Promise(resolve => {
30
+ const controlPath = controlName.replace(/\./g, '/');
31
+ sap.ui.require([controlPath], control => {
32
+ const contMetadata = control.getMetadata();
33
+ // getLibraryName method does not exist on events
34
+ if (contMetadata?.getLibraryName) {
35
+ const contLibName = contMetadata.getLibraryName();
36
+ resolve(contLibName);
37
+ } else {
38
+ resolve(''); // return empty for events
39
+ }
40
+ });
41
+ });
42
+ }
43
+ var __exports = {
44
+ __esModule: true
45
+ };
46
+ __exports.getRuntimeControl = getRuntimeControl;
47
+ __exports.getLibrary = getLibrary;
48
+ return __exports;
49
49
  });
50
50
  //# sourceMappingURL=utils.js.map
@@ -1,71 +1,86 @@
1
- "use strict";
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) {
4
- "use strict";
5
-
6
- const CHANGES_API_PATH = ___common["CHANGES_API_PATH"];
7
- const getFlexSettings = ___common["getFlexSettings"];
8
- const connector = merge({}, ObjectStorageConnector, {
9
- layers: [Layer.VENDOR, Layer.CUSTOMER_BASE],
10
- storage: {
11
- _itemsStoredAsObjects: true,
12
- setItem: function (_key, change) {
13
- const settings = getFlexSettings();
14
- if (settings) {
15
- change.support ??= {};
16
- change.support.generator = settings.generator;
17
- }
18
- return fetch(CHANGES_API_PATH, {
19
- method: 'POST',
20
- body: JSON.stringify(change, null, 2),
21
- headers: {
22
- 'content-type': 'application/json'
23
- }
24
- });
25
- },
26
- removeItem: function (key) {
27
- return fetch(CHANGES_API_PATH, {
28
- method: 'DELETE',
29
- body: JSON.stringify({
30
- fileName: key
31
- }),
32
- headers: {
33
- 'content-type': 'application/json'
34
- }
35
- });
36
- },
37
- clear: function () {
38
- // not implemented
39
- },
40
- getItem: function (_key) {
41
- // not implemented
42
- },
43
- getItems: async function () {
44
- const response = await fetch(CHANGES_API_PATH, {
45
- method: 'GET',
46
- headers: {
47
- 'content-type': 'application/json'
48
- }
49
- });
50
- const changes = await response.json();
51
- return changes;
52
- }
53
- },
54
- loadFeatures: async function () {
55
- const features = await ObjectStorageConnector.loadFeatures();
56
- const ui5Version = await VersionInfo.load();
57
- const [majorVersion, minorVersion] = ui5Version.version.split('.').map(v => parseInt(v, 10));
58
- features.isVariantAdaptationEnabled = majorVersion >= 1 && minorVersion >= 90;
59
- const settings = getFlexSettings();
60
- if (settings?.developerMode) {
61
- features.isVariantAdaptationEnabled = false;
62
- }
63
- if (settings?.scenario === 'ADAPTATION_PROJECT') {
64
- features.isVariantAdaptationEnabled = true;
65
- }
66
- return features;
67
- }
68
- });
69
- return connector;
1
+ "use strict";
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) {
4
+ "use strict";
5
+
6
+ const CHANGES_API_PATH = ___common["CHANGES_API_PATH"];
7
+ const getFlexSettings = ___common["getFlexSettings"];
8
+ const connector = merge({}, ObjectStorageConnector, {
9
+ layers: [Layer.VENDOR, Layer.CUSTOMER_BASE],
10
+ storage: {
11
+ _itemsStoredAsObjects: true,
12
+ fileChangeRequestNotifier: undefined,
13
+ setItem: function (_key, change) {
14
+ const settings = getFlexSettings();
15
+ if (settings) {
16
+ change.support ??= {};
17
+ change.support.generator = settings.generator;
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
+ return fetch(CHANGES_API_PATH, {
27
+ method: 'POST',
28
+ body: JSON.stringify(change, null, 2),
29
+ headers: {
30
+ 'content-type': 'application/json'
31
+ }
32
+ });
33
+ },
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
+ }
42
+ return fetch(CHANGES_API_PATH, {
43
+ method: 'DELETE',
44
+ body: JSON.stringify({
45
+ fileName: key
46
+ }),
47
+ headers: {
48
+ 'content-type': 'application/json'
49
+ }
50
+ });
51
+ },
52
+ clear: function () {
53
+ // not implemented
54
+ },
55
+ getItem: function (_key) {
56
+ // not implemented
57
+ },
58
+ getItems: async function () {
59
+ const response = await fetch(CHANGES_API_PATH, {
60
+ method: 'GET',
61
+ headers: {
62
+ 'content-type': 'application/json'
63
+ }
64
+ });
65
+ const changes = await response.json();
66
+ return changes;
67
+ }
68
+ },
69
+ loadFeatures: async function () {
70
+ const features = await ObjectStorageConnector.loadFeatures();
71
+ const ui5Version = await VersionInfo.load();
72
+ const [majorVersion, minorVersion] = ui5Version.version.split('.').map(v => parseInt(v, 10));
73
+ features.isVariantAdaptationEnabled = majorVersion >= 1 && minorVersion >= 90;
74
+ const settings = getFlexSettings();
75
+ if (settings?.developerMode) {
76
+ features.isVariantAdaptationEnabled = false;
77
+ }
78
+ if (settings?.scenario === 'ADAPTATION_PROJECT') {
79
+ features.isVariantAdaptationEnabled = true;
80
+ }
81
+ return features;
82
+ }
83
+ });
84
+ return connector;
70
85
  });
71
86
  //# sourceMappingURL=WorkspaceConnector.js.map
@@ -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
 
@@ -1,30 +1,30 @@
1
- "use strict";
2
-
3
- sap.ui.define([], function () {
4
- "use strict";
5
-
6
- const CHANGES_API_PATH = '/preview/api/changes';
7
-
8
- /**
9
- * Retrieves Flex settings from a 'sap-ui-bootstrap' element's data attribute.
10
- * Parses the 'data-open-ux-preview-flex-settings' attribute as JSON.
11
- *
12
- * @returns {FlexSettings | undefined} The parsed Flex settings if available, otherwise undefined.
13
- */
14
- function getFlexSettings() {
15
- let result;
16
- const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
17
- const flexSetting = bootstrapConfig?.getAttribute('data-open-ux-preview-flex-settings');
18
- if (flexSetting) {
19
- result = JSON.parse(flexSetting);
20
- }
21
- return result;
22
- }
23
- var __exports = {
24
- __esModule: true
25
- };
26
- __exports.CHANGES_API_PATH = CHANGES_API_PATH;
27
- __exports.getFlexSettings = getFlexSettings;
28
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define([], function () {
4
+ "use strict";
5
+
6
+ const CHANGES_API_PATH = '/preview/api/changes';
7
+
8
+ /**
9
+ * Retrieves Flex settings from a 'sap-ui-bootstrap' element's data attribute.
10
+ * Parses the 'data-open-ux-preview-flex-settings' attribute as JSON.
11
+ *
12
+ * @returns {FlexSettings | undefined} The parsed Flex settings if available, otherwise undefined.
13
+ */
14
+ function getFlexSettings() {
15
+ let result;
16
+ const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
17
+ const flexSetting = bootstrapConfig?.getAttribute('data-open-ux-preview-flex-settings');
18
+ if (flexSetting) {
19
+ result = JSON.parse(flexSetting);
20
+ }
21
+ return result;
22
+ }
23
+ var __exports = {
24
+ __esModule: true
25
+ };
26
+ __exports.CHANGES_API_PATH = CHANGES_API_PATH;
27
+ __exports.getFlexSettings = getFlexSettings;
28
+ return __exports;
29
29
  });
30
30
  //# sourceMappingURL=common.js.map
@@ -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
  };