@sap-ux/preview-middleware 0.16.11 → 0.16.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.
@@ -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,86 +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
- 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;
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;
85
85
  });
86
86
  //# sourceMappingURL=WorkspaceConnector.js.map
@@ -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
@@ -1,86 +1,86 @@
1
- "use strict";
2
-
3
- sap.ui.define(["sap/ui/fl/LrepConnector", "sap/ui/fl/FakeLrepConnector", "./common"], function (LrepConnector, FakeLrepConnector, ___common) {
4
- "use strict";
5
-
6
- const CHANGES_API_PATH = ___common["CHANGES_API_PATH"];
7
- const getFlexSettings = ___common["getFlexSettings"];
8
- /**
9
- * Processes an array of FlexChange objects.
10
- * It updates each change object with settings and sends them to a API endpoint.
11
- *
12
- * @param {FlexChange[]} changes - Array of FlexChange objects to be processed.
13
- * @returns {Promise<void>} A promise that resolves when all changes are processed.
14
- */
15
- async function create(changes) {
16
- const settings = getFlexSettings();
17
- await Promise.all(changes.map(change => {
18
- if (settings) {
19
- change.support ??= {};
20
- change.support.generator = settings.generator;
21
- }
22
- if (typeof FakeLrepConnector.fileChangeRequestNotifier === 'function' && change.fileName) {
23
- try {
24
- FakeLrepConnector.fileChangeRequestNotifier(change.fileName, 'create', change.changeType);
25
- } catch (e) {
26
- // exceptions in the listener call are ignored
27
- }
28
- }
29
- return fetch(CHANGES_API_PATH, {
30
- method: 'POST',
31
- body: JSON.stringify(change, null, 2),
32
- headers: {
33
- 'content-type': 'application/json'
34
- }
35
- });
36
- }));
37
- }
38
-
39
- /**
40
- * Loads changes from a given path and processes them using an LrepConnector instance.
41
- * The changes are then formatted and returned in a specified structure.
42
- *
43
- * @returns {Promise<LoadChangesResult>} A promise that resolves to an object of type LoadChangesResult.
44
- */
45
- async function loadChanges() {
46
- const lrep = new LrepConnector();
47
- const response = await fetch(CHANGES_API_PATH, {
48
- method: 'GET',
49
- headers: {
50
- 'content-type': 'application/json'
51
- }
52
- });
53
- const changes = await response.json();
54
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
55
- args[_key] = arguments[_key];
56
- }
57
- return LrepConnector.prototype.loadChanges.apply(lrep, args).then(res => {
58
- const flexChanges = Object.values(changes);
59
- res.changes.changes = flexChanges;
60
- return res;
61
- });
62
- }
63
-
64
- /**
65
- * Configures and enables the FakeLrepConnector based on the SAP UI5 version.
66
- * If the minor version of the SAP UI5 is less than 72, this function extends
67
- * the FakeLrepConnector's prototype with specific methods and enables the fake connector.
68
- *
69
- * Assumes the existence of a global 'sap' object with a 'ui.version' property,
70
- * and global jQuery object with 'extend' method.
71
- *
72
- * @returns {void}
73
- */
74
- var __exports = function () {
75
- jQuery.extend(FakeLrepConnector.prototype, {
76
- create,
77
- loadChanges,
78
- loadSettings: () => Promise.resolve()
79
- });
80
- FakeLrepConnector.enableFakeConnector();
81
- };
82
- __exports.create = create;
83
- __exports.loadChanges = loadChanges;
84
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/ui/fl/LrepConnector", "sap/ui/fl/FakeLrepConnector", "./common"], function (LrepConnector, FakeLrepConnector, ___common) {
4
+ "use strict";
5
+
6
+ const CHANGES_API_PATH = ___common["CHANGES_API_PATH"];
7
+ const getFlexSettings = ___common["getFlexSettings"];
8
+ /**
9
+ * Processes an array of FlexChange objects.
10
+ * It updates each change object with settings and sends them to a API endpoint.
11
+ *
12
+ * @param {FlexChange[]} changes - Array of FlexChange objects to be processed.
13
+ * @returns {Promise<void>} A promise that resolves when all changes are processed.
14
+ */
15
+ async function create(changes) {
16
+ const settings = getFlexSettings();
17
+ await Promise.all(changes.map(change => {
18
+ if (settings) {
19
+ change.support ??= {};
20
+ change.support.generator = settings.generator;
21
+ }
22
+ if (typeof FakeLrepConnector.fileChangeRequestNotifier === 'function' && change.fileName) {
23
+ try {
24
+ FakeLrepConnector.fileChangeRequestNotifier(change.fileName, 'create', change.changeType);
25
+ } catch (e) {
26
+ // exceptions in the listener call are ignored
27
+ }
28
+ }
29
+ return fetch(CHANGES_API_PATH, {
30
+ method: 'POST',
31
+ body: JSON.stringify(change, null, 2),
32
+ headers: {
33
+ 'content-type': 'application/json'
34
+ }
35
+ });
36
+ }));
37
+ }
38
+
39
+ /**
40
+ * Loads changes from a given path and processes them using an LrepConnector instance.
41
+ * The changes are then formatted and returned in a specified structure.
42
+ *
43
+ * @returns {Promise<LoadChangesResult>} A promise that resolves to an object of type LoadChangesResult.
44
+ */
45
+ async function loadChanges() {
46
+ const lrep = new LrepConnector();
47
+ const response = await fetch(CHANGES_API_PATH, {
48
+ method: 'GET',
49
+ headers: {
50
+ 'content-type': 'application/json'
51
+ }
52
+ });
53
+ const changes = await response.json();
54
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
55
+ args[_key] = arguments[_key];
56
+ }
57
+ return LrepConnector.prototype.loadChanges.apply(lrep, args).then(res => {
58
+ const flexChanges = Object.values(changes);
59
+ res.changes.changes = flexChanges;
60
+ return res;
61
+ });
62
+ }
63
+
64
+ /**
65
+ * Configures and enables the FakeLrepConnector based on the SAP UI5 version.
66
+ * If the minor version of the SAP UI5 is less than 72, this function extends
67
+ * the FakeLrepConnector's prototype with specific methods and enables the fake connector.
68
+ *
69
+ * Assumes the existence of a global 'sap' object with a 'ui.version' property,
70
+ * and global jQuery object with 'extend' method.
71
+ *
72
+ * @returns {void}
73
+ */
74
+ var __exports = function () {
75
+ jQuery.extend(FakeLrepConnector.prototype, {
76
+ create,
77
+ loadChanges,
78
+ loadSettings: () => Promise.resolve()
79
+ });
80
+ FakeLrepConnector.enableFakeConnector();
81
+ };
82
+ __exports.create = create;
83
+ __exports.loadChanges = loadChanges;
84
+ return __exports;
85
85
  });
86
86
  //# sourceMappingURL=enableFakeConnector.js.map
@@ -1,35 +1,35 @@
1
- "use strict";
2
-
3
- sap.ui.define([], function () {
4
- "use strict";
5
-
6
- /**
7
- * Initializes UI5 connectors based on the current UI5 version.
8
- *
9
- * For UI5 versions below 1.72, this function dynamically requires and executes a FakeLrepConnector.
10
- * For UI5 versions 1.72 and above, it defines a local connector that reuses the WorkspaceConnector.
11
- * This setup allows for flexibility in using different connectors based on the UI5 version.
12
- *
13
- * @example
14
- * intiConnectors(); // Simply call the function without any arguments.
15
- * @returns {void}
16
- */
17
- function initConnectors() {
18
- const version = sap.ui.version;
19
- const minor = parseInt(version.split('.')[1], 10);
20
- if (minor < 72) {
21
- sap.ui.require(['open/ux/preview/client/flp/enableFakeConnector'], function (enableFakeConnector) {
22
- enableFakeConnector();
23
- });
24
- } else {
25
- sap.ui.define('custom.connectors.WorkspaceConnector', ['open/ux/preview/client/flp/WorkspaceConnector'], connector => connector, true);
26
- }
27
- }
28
- initConnectors();
29
- var __exports = {
30
- __esModule: true
31
- };
32
- __exports.initConnectors = initConnectors;
33
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define([], function () {
4
+ "use strict";
5
+
6
+ /**
7
+ * Initializes UI5 connectors based on the current UI5 version.
8
+ *
9
+ * For UI5 versions below 1.72, this function dynamically requires and executes a FakeLrepConnector.
10
+ * For UI5 versions 1.72 and above, it defines a local connector that reuses the WorkspaceConnector.
11
+ * This setup allows for flexibility in using different connectors based on the UI5 version.
12
+ *
13
+ * @example
14
+ * intiConnectors(); // Simply call the function without any arguments.
15
+ * @returns {void}
16
+ */
17
+ function initConnectors() {
18
+ const version = sap.ui.version;
19
+ const minor = parseInt(version.split('.')[1], 10);
20
+ if (minor < 72) {
21
+ sap.ui.require(['open/ux/preview/client/flp/enableFakeConnector'], function (enableFakeConnector) {
22
+ enableFakeConnector();
23
+ });
24
+ } else {
25
+ sap.ui.define('custom.connectors.WorkspaceConnector', ['open/ux/preview/client/flp/WorkspaceConnector'], connector => connector, true);
26
+ }
27
+ }
28
+ initConnectors();
29
+ var __exports = {
30
+ __esModule: true
31
+ };
32
+ __exports.initConnectors = initConnectors;
33
+ return __exports;
34
34
  });
35
35
  //# sourceMappingURL=initConnectors.js.map