@sap-ux/preview-middleware 0.16.133 → 0.16.137
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/config.d.ts +15 -20
- package/dist/base/flex.js +1 -2
- package/dist/base/flp.d.ts +33 -0
- package/dist/base/flp.js +104 -18
- package/dist/client/flp/WorkspaceConnector.js +1 -2
- package/dist/client/flp/WorkspaceConnector.ts +1 -2
- package/dist/client/flp/enableFakeConnector.js +1 -2
- package/dist/client/flp/enableFakeConnector.ts +1 -2
- package/dist/client/flp/init.js +1 -1
- package/dist/client/flp/init.ts +3 -1
- package/dist/client/flp/initRta.js +1 -1
- package/dist/client/flp/initRta.ts +1 -1
- package/dist/ui5/middleware.js +1 -0
- package/package.json +5 -5
- package/templates/flp/sandbox.html +2 -3
- package/templates/flp/sandbox2.html +87 -0
- package/dist/client/flp/bootstrap.js +0 -77
package/dist/base/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ToolsLogger, type Logger } from '@sap-ux/logger';
|
|
2
|
-
import type { App, FlpConfig, Intent, InternalTestConfig, MiddlewareConfig } from '../types';
|
|
2
|
+
import type { App, FlpConfig, Intent, InternalTestConfig, MiddlewareConfig, TestConfig } from '../types';
|
|
3
3
|
import { type Manifest, type UI5FlexLayer } from '@sap-ux/project-access';
|
|
4
4
|
import { type Editor } from 'mem-fs-editor';
|
|
5
5
|
import type { MergedAppDescriptor } from '@sap-ux/axios-extension';
|
|
@@ -13,6 +13,17 @@ export interface FlexConnector {
|
|
|
13
13
|
layers: string[];
|
|
14
14
|
url?: string;
|
|
15
15
|
}
|
|
16
|
+
type TestTemplateConfig = {
|
|
17
|
+
id: string;
|
|
18
|
+
framework: TestConfig['framework'];
|
|
19
|
+
basePath: string;
|
|
20
|
+
initPath: string;
|
|
21
|
+
theme: string;
|
|
22
|
+
};
|
|
23
|
+
export type PreviewUrls = {
|
|
24
|
+
path: string;
|
|
25
|
+
type: 'preview' | 'editor' | 'test';
|
|
26
|
+
};
|
|
16
27
|
/**
|
|
17
28
|
* Internal structure used to fill the sandbox.html template
|
|
18
29
|
*/
|
|
@@ -76,14 +87,7 @@ export declare const DEFAULT_INTENT: Readonly<Intent>;
|
|
|
76
87
|
* @param config partial configuration
|
|
77
88
|
* @returns a full configuration with default values
|
|
78
89
|
*/
|
|
79
|
-
export declare function getFlpConfigWithDefaults(config?: Partial<FlpConfig>):
|
|
80
|
-
path: string;
|
|
81
|
-
intent: Readonly<Intent>;
|
|
82
|
-
apps: App[];
|
|
83
|
-
libs: boolean | undefined;
|
|
84
|
-
theme: string | undefined;
|
|
85
|
-
init: string | undefined;
|
|
86
|
-
};
|
|
90
|
+
export declare function getFlpConfigWithDefaults(config?: Partial<FlpConfig>): FlpConfig;
|
|
87
91
|
/**
|
|
88
92
|
* The developer mode is only supported for adaptation projects, therefore, notify the user if it is wrongly configured and then disable it.
|
|
89
93
|
*
|
|
@@ -125,17 +129,7 @@ export declare function createFlpTemplateConfig(config: FlpConfig, manifest: Par
|
|
|
125
129
|
* @param theme theme to be used
|
|
126
130
|
* @returns configuration object for the test template
|
|
127
131
|
*/
|
|
128
|
-
export declare function createTestTemplateConfig(config: InternalTestConfig, id: string, theme: string):
|
|
129
|
-
id: string;
|
|
130
|
-
framework: "OPA5" | "QUnit" | "Testsuite";
|
|
131
|
-
basePath: string;
|
|
132
|
-
initPath: string;
|
|
133
|
-
theme: string;
|
|
134
|
-
};
|
|
135
|
-
export type PreviewUrls = {
|
|
136
|
-
path: string;
|
|
137
|
-
type: 'preview' | 'editor' | 'test';
|
|
138
|
-
};
|
|
132
|
+
export declare function createTestTemplateConfig(config: InternalTestConfig, id: string, theme: string): TestTemplateConfig;
|
|
139
133
|
/**
|
|
140
134
|
* Returns the preview paths.
|
|
141
135
|
*
|
|
@@ -154,4 +148,5 @@ export declare function getPreviewPaths(config: MiddlewareConfig, logger?: Tools
|
|
|
154
148
|
* @returns a mem-fs editor with the preview files
|
|
155
149
|
*/
|
|
156
150
|
export declare function generatePreviewFiles(basePath: string, config: MiddlewareConfig, fs?: Editor, logger?: ToolsLogger): Promise<Editor>;
|
|
151
|
+
export {};
|
|
157
152
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/base/flex.js
CHANGED
|
@@ -17,8 +17,7 @@ async function readChanges(project, logger) {
|
|
|
17
17
|
const files = await project.byGlob('/**/changes/*.*');
|
|
18
18
|
for (const file of files) {
|
|
19
19
|
try {
|
|
20
|
-
|
|
21
|
-
changes[`sap.ui.fl.${(0, path_1.parse)(file.getName()).name}`] = change;
|
|
20
|
+
changes[`sap.ui.fl.${(0, path_1.parse)(file.getName()).name}`] = JSON.parse(await file.getString());
|
|
22
21
|
logger.debug(`Read change from ${file.getPath()}`);
|
|
23
22
|
}
|
|
24
23
|
catch (error) {
|
package/dist/base/flp.d.ts
CHANGED
|
@@ -53,9 +53,18 @@ export declare class FlpSandbox {
|
|
|
53
53
|
* @param adp optional reference to the ADP tooling
|
|
54
54
|
*/
|
|
55
55
|
init(manifest: Manifest, componentId?: string, resources?: Record<string, string>, adp?: AdpPreview): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Get the configuration for the developer mode.
|
|
58
|
+
*
|
|
59
|
+
* @param ui5MajorVersion - the major version of UI5
|
|
60
|
+
* @returns the configuration for the developer mode
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
private getDeveloperModeConfig;
|
|
56
64
|
/**
|
|
57
65
|
* Generates the FLP sandbox for an editor.
|
|
58
66
|
*
|
|
67
|
+
* @param req the request
|
|
59
68
|
* @param rta runtime authoring configuration
|
|
60
69
|
* @param editor editor configuration
|
|
61
70
|
* @returns FLP sandbox html
|
|
@@ -78,6 +87,29 @@ export declare class FlpSandbox {
|
|
|
78
87
|
* Add routes for html and scripts required for a local FLP.
|
|
79
88
|
*/
|
|
80
89
|
private addStandardRoutes;
|
|
90
|
+
/**
|
|
91
|
+
* Read the UI5 version.
|
|
92
|
+
* In case of an error, the default UI5 version '1.121.0' is returned.
|
|
93
|
+
*
|
|
94
|
+
* @param protocol - the protocol that should be used to request the UI5 version ('http' or 'https')
|
|
95
|
+
* @param host - the host that should be used to request the UI5 version
|
|
96
|
+
* @param baseUrl - the base path of the request that should be added to the host
|
|
97
|
+
* @returns the template for the sandbox HTML file
|
|
98
|
+
* @private
|
|
99
|
+
*/
|
|
100
|
+
private getUi5Version;
|
|
101
|
+
/**
|
|
102
|
+
* Read the sandbox template file based on the given UI5 version.
|
|
103
|
+
*
|
|
104
|
+
* @param ui5MajorVersion - the major version of UI5
|
|
105
|
+
* @returns the template for the sandbox HTML file
|
|
106
|
+
*/
|
|
107
|
+
private getSandboxTemplate;
|
|
108
|
+
/**
|
|
109
|
+
* For UI5 version 1.71 and below, the asyncHints.requests need to be removed from the template configuration
|
|
110
|
+
* to load the changes in an Adaptation project.
|
|
111
|
+
*/
|
|
112
|
+
private removeAsyncHintsRequests;
|
|
81
113
|
/**
|
|
82
114
|
* Try finding a locate-reuse-libs script in the project.
|
|
83
115
|
*
|
|
@@ -126,6 +158,7 @@ export declare class FlpSandbox {
|
|
|
126
158
|
* @param flp FlpSandbox instance
|
|
127
159
|
* @param util middleware utilities provided by the UI5 CLI
|
|
128
160
|
* @param logger logger instance
|
|
161
|
+
* @throws Error in case no manifest.appdescr_variant found
|
|
129
162
|
*/
|
|
130
163
|
export declare function initAdp(rootProject: ReaderCollection, config: AdpPreviewConfig, flp: FlpSandbox, util: MiddlewareUtils, logger: ToolsLogger): Promise<void>;
|
|
131
164
|
export {};
|
package/dist/base/flp.js
CHANGED
|
@@ -14,15 +14,6 @@ const feature_toggle_1 = require("@sap-ux/feature-toggle");
|
|
|
14
14
|
const flex_1 = require("./flex");
|
|
15
15
|
const test_1 = require("./test");
|
|
16
16
|
const config_1 = require("./config");
|
|
17
|
-
const DEVELOPER_MODE_CONFIG = new Map([
|
|
18
|
-
// Run application in design time mode
|
|
19
|
-
// Adds bindingString to BindingInfo objects. Required to create and read PropertyBinding changes
|
|
20
|
-
['xx-designMode', 'true'],
|
|
21
|
-
// In design mode, the controller code will not be executed by default, which is not desired in our case, so we suppress the deactivation
|
|
22
|
-
['xx-suppressDeactivationOfControllerCode', 'true'],
|
|
23
|
-
// Make sure that XML preprocessing results are correctly invalidated
|
|
24
|
-
['xx-viewCache', 'false']
|
|
25
|
-
]);
|
|
26
17
|
const DEFAULT_LIVERELOAD_PORT = 35729;
|
|
27
18
|
/**
|
|
28
19
|
* Class handling preview of a sandbox FLP.
|
|
@@ -101,14 +92,46 @@ class FlpSandbox {
|
|
|
101
92
|
this.logger.info(`Initialized for app ${id}`);
|
|
102
93
|
this.logger.debug(`Configured apps: ${JSON.stringify(this.templateConfig.apps)}`);
|
|
103
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Get the configuration for the developer mode.
|
|
97
|
+
*
|
|
98
|
+
* @param ui5MajorVersion - the major version of UI5
|
|
99
|
+
* @returns the configuration for the developer mode
|
|
100
|
+
* @private
|
|
101
|
+
*/
|
|
102
|
+
getDeveloperModeConfig(ui5MajorVersion) {
|
|
103
|
+
if (ui5MajorVersion < 2) {
|
|
104
|
+
return new Map([
|
|
105
|
+
// Run application in design time mode
|
|
106
|
+
// Adds bindingString to BindingInfo objects. Required to create and read PropertyBinding changes
|
|
107
|
+
['xx-designMode', 'true'],
|
|
108
|
+
// In design mode, the controller code will not be executed by default, which is not desired in our case, so we suppress the deactivation
|
|
109
|
+
['xx-suppressDeactivationOfControllerCode', 'true'],
|
|
110
|
+
// Make sure that XML preprocessing results are correctly invalidated
|
|
111
|
+
['xx-viewCache', 'false']
|
|
112
|
+
]);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
return new Map([
|
|
116
|
+
// Run application in design time mode
|
|
117
|
+
// Adds bindingString to BindingInfo objects. Required to create and read PropertyBinding changes
|
|
118
|
+
['xx-design-mode', 'true'],
|
|
119
|
+
// In design mode, the controller code will not be executed by default, which is not desired in our case, so we suppress the deactivation
|
|
120
|
+
['xx-suppress-deactivation-of-controller-code', 'true'],
|
|
121
|
+
// Make sure that XML preprocessing results are correctly invalidated
|
|
122
|
+
['xx-view-cache', 'false']
|
|
123
|
+
]);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
104
126
|
/**
|
|
105
127
|
* Generates the FLP sandbox for an editor.
|
|
106
128
|
*
|
|
129
|
+
* @param req the request
|
|
107
130
|
* @param rta runtime authoring configuration
|
|
108
131
|
* @param editor editor configuration
|
|
109
132
|
* @returns FLP sandbox html
|
|
110
133
|
*/
|
|
111
|
-
async generateSandboxForEditor(rta, editor) {
|
|
134
|
+
async generateSandboxForEditor(req, rta, editor) {
|
|
112
135
|
const defaultGenerator = editor.developerMode
|
|
113
136
|
? '@sap-ux/control-property-editor'
|
|
114
137
|
: '@sap-ux/preview-middleware';
|
|
@@ -128,11 +151,14 @@ class FlpSandbox {
|
|
|
128
151
|
pluginScript: editor.pluginScript
|
|
129
152
|
};
|
|
130
153
|
config.features = feature_toggle_1.FeatureToggleAccess.getAllFeatureToggles();
|
|
154
|
+
const ui5Version = await this.getUi5Version(req.protocol, req.headers.host, req['ui5-patched-router']?.baseUrl);
|
|
131
155
|
if (editor.developerMode === true) {
|
|
132
|
-
config.ui5.bootstrapOptions = serializeUi5Configuration(
|
|
156
|
+
config.ui5.bootstrapOptions = serializeUi5Configuration(this.getDeveloperModeConfig(ui5Version.major));
|
|
157
|
+
}
|
|
158
|
+
if (ui5Version.major === 1 && ui5Version.minor <= 71) {
|
|
159
|
+
this.removeAsyncHintsRequests();
|
|
133
160
|
}
|
|
134
|
-
|
|
135
|
-
return (0, ejs_1.render)(template, config);
|
|
161
|
+
return (0, ejs_1.render)(this.getSandboxTemplate(ui5Version.major), config);
|
|
136
162
|
}
|
|
137
163
|
/**
|
|
138
164
|
* Sets application dependencies in the template configuration.
|
|
@@ -198,7 +224,7 @@ class FlpSandbox {
|
|
|
198
224
|
res.redirect(302, `${previewUrl}?${new URLSearchParams(params)}`);
|
|
199
225
|
return;
|
|
200
226
|
}
|
|
201
|
-
const html = (await this.generateSandboxForEditor(rta, editor)).replace('</body>', `</body>\n<!-- livereload disabled for editor </body>-->`);
|
|
227
|
+
const html = (await this.generateSandboxForEditor(req, rta, editor)).replace('</body>', `</body>\n<!-- livereload disabled for editor </body>-->`);
|
|
202
228
|
this.sendResponse(res, 'text/html', 200, html);
|
|
203
229
|
});
|
|
204
230
|
}
|
|
@@ -209,21 +235,79 @@ class FlpSandbox {
|
|
|
209
235
|
addStandardRoutes() {
|
|
210
236
|
// register static client sources
|
|
211
237
|
this.router.use(config_1.PREVIEW_URL.client.path, (0, express_1.static)(config_1.PREVIEW_URL.client.local));
|
|
212
|
-
// add route for the sandbox
|
|
213
|
-
this.router.get(this.config.path, (async (
|
|
238
|
+
// add route for the sandbox html
|
|
239
|
+
this.router.get(this.config.path, (async (req, res, next) => {
|
|
214
240
|
// inform the user if a html file exists on the filesystem
|
|
241
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
215
242
|
const file = await this.project.byPath(this.config.path);
|
|
216
243
|
if (file) {
|
|
217
244
|
this.logger.info(`HTML file returned at ${this.config.path} is loaded from the file system.`);
|
|
218
245
|
next();
|
|
219
246
|
}
|
|
220
247
|
else {
|
|
221
|
-
const
|
|
222
|
-
const html = (0, ejs_1.render)(
|
|
248
|
+
const ui5Version = await this.getUi5Version(req.protocol, req.headers.host, req['ui5-patched-router']?.baseUrl);
|
|
249
|
+
const html = (0, ejs_1.render)(this.getSandboxTemplate(ui5Version.major), this.templateConfig);
|
|
223
250
|
this.sendResponse(res, 'text/html', 200, html);
|
|
224
251
|
}
|
|
225
252
|
}));
|
|
226
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* Read the UI5 version.
|
|
256
|
+
* In case of an error, the default UI5 version '1.121.0' is returned.
|
|
257
|
+
*
|
|
258
|
+
* @param protocol - the protocol that should be used to request the UI5 version ('http' or 'https')
|
|
259
|
+
* @param host - the host that should be used to request the UI5 version
|
|
260
|
+
* @param baseUrl - the base path of the request that should be added to the host
|
|
261
|
+
* @returns the template for the sandbox HTML file
|
|
262
|
+
* @private
|
|
263
|
+
*/
|
|
264
|
+
async getUi5Version(protocol, host, baseUrl = '') {
|
|
265
|
+
let version;
|
|
266
|
+
if (!host) {
|
|
267
|
+
this.logger.error('Unable to fetch UI5 version: No host found in request header.');
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
try {
|
|
271
|
+
const versionUrl = `${protocol}://${host}${baseUrl}/resources/sap-ui-version.json`;
|
|
272
|
+
const responseJson = (await fetch(versionUrl).then((res) => res.json()));
|
|
273
|
+
version = responseJson?.libraries?.find((lib) => lib.name === 'sap.ui.core')?.version;
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
this.logger.error(error);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (!version) {
|
|
280
|
+
this.logger.error('Could not get UI5 version of application. Using 1.121.0 as fallback.');
|
|
281
|
+
version = '1.121.0';
|
|
282
|
+
}
|
|
283
|
+
const [major, minor] = version.split('.').map((versionPart) => parseInt(versionPart, 10));
|
|
284
|
+
return {
|
|
285
|
+
major,
|
|
286
|
+
minor
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Read the sandbox template file based on the given UI5 version.
|
|
291
|
+
*
|
|
292
|
+
* @param ui5MajorVersion - the major version of UI5
|
|
293
|
+
* @returns the template for the sandbox HTML file
|
|
294
|
+
*/
|
|
295
|
+
getSandboxTemplate(ui5MajorVersion) {
|
|
296
|
+
this.logger.info(`Using sandbox template for UI5 major version ${ui5MajorVersion}.`);
|
|
297
|
+
return (0, fs_1.readFileSync)((0, path_1.join)(__dirname, `../../templates/flp/sandbox${ui5MajorVersion === 1 ? '' : ui5MajorVersion}.html`), 'utf-8');
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* For UI5 version 1.71 and below, the asyncHints.requests need to be removed from the template configuration
|
|
301
|
+
* to load the changes in an Adaptation project.
|
|
302
|
+
*/
|
|
303
|
+
removeAsyncHintsRequests() {
|
|
304
|
+
for (const app in this.templateConfig.apps) {
|
|
305
|
+
const appDependencies = this.templateConfig.apps[app].applicationDependencies;
|
|
306
|
+
if (appDependencies?.asyncHints.requests) {
|
|
307
|
+
appDependencies.asyncHints.requests = [];
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
227
311
|
/**
|
|
228
312
|
* Try finding a locate-reuse-libs script in the project.
|
|
229
313
|
*
|
|
@@ -401,6 +485,7 @@ class FlpSandbox {
|
|
|
401
485
|
// add route for the *.qunit.html
|
|
402
486
|
this.router.get(config.path, (async (_req, res, next) => {
|
|
403
487
|
this.logger.debug(`Serving test route: ${config.path}`);
|
|
488
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
404
489
|
const file = await this.project.byPath(config.path);
|
|
405
490
|
if (file) {
|
|
406
491
|
this.logger.warn(`HTML file returned at ${config.path} is loaded from the file system.`);
|
|
@@ -468,6 +553,7 @@ function serializeUi5Configuration(config) {
|
|
|
468
553
|
* @param flp FlpSandbox instance
|
|
469
554
|
* @param util middleware utilities provided by the UI5 CLI
|
|
470
555
|
* @param logger logger instance
|
|
556
|
+
* @throws Error in case no manifest.appdescr_variant found
|
|
471
557
|
*/
|
|
472
558
|
async function initAdp(rootProject, config, flp, util, logger) {
|
|
473
559
|
const appVariant = await rootProject.byPath('/manifest.appdescr_variant');
|
|
@@ -64,8 +64,7 @@ sap.ui.define(["sap/base/util/merge", "sap/ui/fl/write/api/connectors/ObjectStor
|
|
|
64
64
|
'content-type': 'application/json'
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
|
-
|
|
68
|
-
return changes;
|
|
67
|
+
return await response.json();
|
|
69
68
|
}
|
|
70
69
|
},
|
|
71
70
|
loadFeatures: async function () {
|
|
@@ -62,8 +62,7 @@ const connector = merge({}, ObjectStorageConnector, {
|
|
|
62
62
|
'content-type': 'application/json'
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
|
-
|
|
66
|
-
return changes;
|
|
65
|
+
return (await response.json()) as unknown as FlexChange[];
|
|
67
66
|
}
|
|
68
67
|
} as typeof ObjectStorageConnector.storage,
|
|
69
68
|
loadFeatures: async function () {
|
|
@@ -55,8 +55,7 @@ sap.ui.define(["sap/ui/fl/LrepConnector", "sap/ui/fl/FakeLrepConnector", "./comm
|
|
|
55
55
|
args[_key] = arguments[_key];
|
|
56
56
|
}
|
|
57
57
|
return LrepConnector.prototype.loadChanges.apply(lrep, args).then(res => {
|
|
58
|
-
|
|
59
|
-
res.changes.changes = flexChanges;
|
|
58
|
+
res.changes.changes = Object.values(changes);
|
|
60
59
|
return res;
|
|
61
60
|
});
|
|
62
61
|
}
|
|
@@ -74,8 +74,7 @@ export async function loadChanges(...args: []): Promise<LoadChangesResult> {
|
|
|
74
74
|
const changes = (await response.json()) as FetchedChanges;
|
|
75
75
|
|
|
76
76
|
return LrepConnector.prototype.loadChanges.apply(lrep, args).then((res: LoadChangesResult) => {
|
|
77
|
-
|
|
78
|
-
res.changes.changes = flexChanges;
|
|
77
|
+
res.changes.changes = Object.values(changes);
|
|
79
78
|
return res;
|
|
80
79
|
});
|
|
81
80
|
}
|
package/dist/client/flp/init.js
CHANGED
|
@@ -122,10 +122,10 @@ sap.ui.define([
|
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
async function resetAppState(container) {
|
|
125
|
-
const appStateService = await container.getServiceAsync('AppState');
|
|
126
125
|
const urlParams = new URLSearchParams(window.location.hash);
|
|
127
126
|
const appStateValue = urlParams.get('sap-iapp-state') ?? urlParams.get('/?sap-iapp-state');
|
|
128
127
|
if (appStateValue) {
|
|
128
|
+
const appStateService = await container.getServiceAsync('AppState');
|
|
129
129
|
appStateService.deleteAppState(appStateValue);
|
|
130
130
|
}
|
|
131
131
|
}
|
package/dist/client/flp/init.ts
CHANGED
|
@@ -165,10 +165,10 @@ function registerModules(dataFromAppIndex: AppIndexData) {
|
|
|
165
165
|
* @param container the UShell container
|
|
166
166
|
*/
|
|
167
167
|
export async function resetAppState(container: typeof sap.ushell.Container): Promise<void> {
|
|
168
|
-
const appStateService = await container.getServiceAsync<AppState>('AppState');
|
|
169
168
|
const urlParams = new URLSearchParams(window.location.hash);
|
|
170
169
|
const appStateValue = urlParams.get('sap-iapp-state') ?? urlParams.get('/?sap-iapp-state');
|
|
171
170
|
if (appStateValue) {
|
|
171
|
+
const appStateService = await container.getServiceAsync<AppState>('AppState');
|
|
172
172
|
appStateService.deleteAppState(appStateValue);
|
|
173
173
|
}
|
|
174
174
|
}
|
|
@@ -346,6 +346,8 @@ export async function init({
|
|
|
346
346
|
: await container.createRendererInternal(undefined, true);
|
|
347
347
|
renderer.placeAt('content');
|
|
348
348
|
}
|
|
349
|
+
|
|
350
|
+
// eslint-disable-next-line fiori-custom/sap-no-dom-access,fiori-custom/sap-browser-api-warning
|
|
349
351
|
const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
|
|
350
352
|
if (bootstrapConfig) {
|
|
351
353
|
init({
|
|
@@ -151,7 +151,7 @@ sap.ui.define(["sap/base/util/merge", "sap/ui/core/Control", "sap/ui/core/UIComp
|
|
|
151
151
|
* Initializes custom RuntimeAuthoring for UI5 Versions < 1.72 and start UI Adaptation.
|
|
152
152
|
* Ensures that the passed options are valid.
|
|
153
153
|
*
|
|
154
|
-
* @param {RTAOptions} options - Options
|
|
154
|
+
* @param {RTAOptions} options - Options that are passed to RuntimeAuthoring upon initialization.
|
|
155
155
|
* @param {RTAPlugin} loadPlugins - Script that needs to be executed after rta is initialized.
|
|
156
156
|
* @returns {Promise<void>} A promise that resolves when all the checks have passed and RuntimeAuthoring is started.
|
|
157
157
|
*/
|
|
@@ -164,7 +164,7 @@ function removeExtraBtnsFromToolbar(): void {
|
|
|
164
164
|
* Initializes custom RuntimeAuthoring for UI5 Versions < 1.72 and start UI Adaptation.
|
|
165
165
|
* Ensures that the passed options are valid.
|
|
166
166
|
*
|
|
167
|
-
* @param {RTAOptions} options - Options
|
|
167
|
+
* @param {RTAOptions} options - Options that are passed to RuntimeAuthoring upon initialization.
|
|
168
168
|
* @param {RTAPlugin} loadPlugins - Script that needs to be executed after rta is initialized.
|
|
169
169
|
* @returns {Promise<void>} A promise that resolves when all the checks have passed and RuntimeAuthoring is started.
|
|
170
170
|
*/
|
package/dist/ui5/middleware.js
CHANGED
|
@@ -24,6 +24,7 @@ async function createRouter({ resources, options, middlewareUtil }, logger) {
|
|
|
24
24
|
await (0, flp_1.initAdp)(resources.rootProject, config.adp, flp, middlewareUtil, logger);
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
27
28
|
const manifest = await resources.rootProject.byPath('/manifest.json');
|
|
28
29
|
if (manifest) {
|
|
29
30
|
await flp.init(JSON.parse(await manifest.getString()));
|
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.
|
|
12
|
+
"version": "0.16.137",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"@sap-ux/logger": "0.6.0",
|
|
29
29
|
"@sap-ux/feature-toggle": "0.2.2",
|
|
30
30
|
"@sap-ux/btp-utils": "0.17.0",
|
|
31
|
-
"@sap-ux/adp-tooling": "0.12.
|
|
31
|
+
"@sap-ux/adp-tooling": "0.12.87",
|
|
32
32
|
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.5.28",
|
|
33
|
-
"@sap-ux/project-access": "1.28.
|
|
33
|
+
"@sap-ux/project-access": "1.28.8"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/ejs": "3.1.2",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"supertest": "6.3.3",
|
|
47
47
|
"@sap-ux-private/playwright": "0.1.0",
|
|
48
48
|
"dotenv": "16.3.1",
|
|
49
|
-
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.
|
|
50
|
-
"@sap-ux/store": "0.9.3",
|
|
49
|
+
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.40",
|
|
51
50
|
"@sap-ux/axios-extension": "1.17.4",
|
|
51
|
+
"@sap-ux/store": "0.9.3",
|
|
52
52
|
"@sap-ux/ui5-info": "0.8.3",
|
|
53
53
|
"@sap-ux/i18n": "0.2.0"
|
|
54
54
|
},
|
|
@@ -44,9 +44,8 @@
|
|
|
44
44
|
window["data-open-ux-preview-basePath"] = "<%- basePath %>";
|
|
45
45
|
</script>
|
|
46
46
|
|
|
47
|
-
<script src="<%- basePath %>/
|
|
48
|
-
|
|
49
|
-
<!-- Bootstrap the UI5 core library. 'data-sap-ui-frameOptions="allow"'' is a NON-SECURE setting for test environments -->
|
|
47
|
+
<script src="<%- basePath %>/test-resources/sap/ushell/bootstrap/sandbox.js" id="sap-ushell-bootstrap"></script>
|
|
48
|
+
<!-- Bootstrap the UI5 core library. 'data-sap-ui-frameOptions="allow"' is a NON-SECURE setting for test environments -->
|
|
50
49
|
<script id="sap-ui-bootstrap"
|
|
51
50
|
src="<%- basePath %>/resources/sap-ui-core.js"
|
|
52
51
|
data-sap-ui-libs="<%- ui5.libs %>"
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<!DOCTYPE HTML>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<!-- Copyright (c) 2015 SAP AG, All Rights Reserved -->
|
|
4
|
+
|
|
5
|
+
<head>
|
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
7
|
+
<meta charset="UTF-8">
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
9
|
+
<title>Local FLP Sandbox</title>
|
|
10
|
+
|
|
11
|
+
<!-- Bootstrap the unified shell in sandbox mode for standalone usage.
|
|
12
|
+
|
|
13
|
+
The renderer is specified in the global Unified Shell configuration object "sap-ushell-config".
|
|
14
|
+
|
|
15
|
+
The fiori2 renderer will render the shell header allowing, for instance,
|
|
16
|
+
testing of additional application setting buttons.
|
|
17
|
+
|
|
18
|
+
The navigation target resolution service is configured in a way that the empty URL hash is
|
|
19
|
+
resolved to our own application.
|
|
20
|
+
|
|
21
|
+
This example uses relative path references for the SAPUI5 resources and test-resources;
|
|
22
|
+
it might be necessary to adapt them depending on the target runtime platform.
|
|
23
|
+
The sandbox platform is restricted to development or demo use cases and must NOT be used
|
|
24
|
+
for productive scenarios.
|
|
25
|
+
-->
|
|
26
|
+
<script type="text/javascript">
|
|
27
|
+
window["sap-ushell-config"] = {
|
|
28
|
+
defaultRenderer: "fiori2",
|
|
29
|
+
renderers: {
|
|
30
|
+
fiori2: {
|
|
31
|
+
componentData: {
|
|
32
|
+
config: {
|
|
33
|
+
search: "hidden",
|
|
34
|
+
enableSearch: false
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
applications: <%- JSON.stringify(apps) %>
|
|
40
|
+
};
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<script type="text/javascript">
|
|
44
|
+
window["data-open-ux-preview-basePath"] = "<%- basePath %>";
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<script src="<%- basePath %>/resources/sap/ushell/bootstrap/sandbox2.js" id="sap-ushell-bootstrap"></script>
|
|
48
|
+
<!-- Bootstrap the UI5 core library. 'data-sap-ui-frameOptions="allow"' is a NON-SECURE setting for test environments -->
|
|
49
|
+
<script id="sap-ui-bootstrap"
|
|
50
|
+
src="<%- basePath %>/resources/sap-ui-core.js"
|
|
51
|
+
data-sap-ui-libs="<%- ui5.libs %>"
|
|
52
|
+
data-sap-ui-async="true"
|
|
53
|
+
data-sap-ui-theme="<%- ui5.theme %>"
|
|
54
|
+
data-sap-ui-compat-version="edge"
|
|
55
|
+
data-sap-ui-language="en"
|
|
56
|
+
data-sap-ui-flexibility-services='<%- JSON.stringify(ui5.flex) %>'
|
|
57
|
+
data-sap-ui-resource-roots='<%- JSON.stringify(ui5.resources) %>'
|
|
58
|
+
data-sap-ui-frame-options="allow"
|
|
59
|
+
data-sap-ui-xx-component-preload="off"<%- ui5.bootstrapOptions %>
|
|
60
|
+
data-sap-ui-on-init="module:open/ux/preview/client/flp/init"<% if (locals.init) { %>
|
|
61
|
+
data-open-ux-preview-customInit='<%- init %>'<% } if (locals.flex) { %>
|
|
62
|
+
data-open-ux-preview-features='<%- JSON.stringify(features) %>'
|
|
63
|
+
data-open-ux-preview-flex-settings='<%- JSON.stringify(flex) %>'<% } if (locals.locateReuseLibsScript) { %>
|
|
64
|
+
data-open-ux-preview-libs-manifests='<%- JSON.stringify(Object.values(apps).map(app => app.url)) %>'<% } %>>
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<% if (locals.flex && flex?.developerMode) { %>
|
|
68
|
+
<!-- Hides Rta native toolbar -->
|
|
69
|
+
<style>
|
|
70
|
+
#shell-header, .sapUiRtaToolbar {
|
|
71
|
+
visibility: hidden;
|
|
72
|
+
height: 1px;
|
|
73
|
+
}
|
|
74
|
+
.sapUshellShellCanvas {
|
|
75
|
+
top: 0 !important;
|
|
76
|
+
}
|
|
77
|
+
.sapUiRtaMode .sapUiShellBackgroundImage.sapUiGlobalBackgroundImageForce.sapUshellShellBG {
|
|
78
|
+
background-color: transparent !important;
|
|
79
|
+
}
|
|
80
|
+
</style><% } %>
|
|
81
|
+
</head>
|
|
82
|
+
|
|
83
|
+
<!-- UI Content -->
|
|
84
|
+
<body class="sapUiBody" id="content">
|
|
85
|
+
</body>
|
|
86
|
+
|
|
87
|
+
</html>
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment,
|
|
2
|
-
@typescript-eslint/no-unsafe-member-access,
|
|
3
|
-
@typescript-eslint/no-unsafe-argument,
|
|
4
|
-
no-console */
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Calculates the script content for accessing the right sap/ushell/bootstrap sandbox.
|
|
8
|
-
* @param fnCallback {Function} The callback function to be executed after the bootstrap is loaded.
|
|
9
|
-
*/
|
|
10
|
-
async function ushellBootstrap(fnCallback) {
|
|
11
|
-
const basePath = window['data-open-ux-preview-basePath'] ?? '';
|
|
12
|
-
|
|
13
|
-
let src = `${basePath}/test-resources/sap/ushell/bootstrap/sandbox.js`;
|
|
14
|
-
try {
|
|
15
|
-
const response = await fetch(`${basePath}/resources/sap-ui-version.json`);
|
|
16
|
-
const json = await response.json();
|
|
17
|
-
const version = json?.libraries?.find((lib) => lib.name === 'sap.ui.core')?.version ?? '1.121.0';
|
|
18
|
-
const [major, minor] = version.split('.');
|
|
19
|
-
const majorUi5Version = parseInt(major, 10);
|
|
20
|
-
const minorUi5Version = parseInt(minor, 10);
|
|
21
|
-
if (majorUi5Version >= 2) {
|
|
22
|
-
src = `${basePath}/resources/sap/ushell/bootstrap/sandbox2.js`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (majorUi5Version === 1 && minorUi5Version < 72) {
|
|
26
|
-
removeAsyncHintsRequests();
|
|
27
|
-
}
|
|
28
|
-
} catch (error) {
|
|
29
|
-
console.warn('Failed to fetch sap-ui-version.json. Assuming it is a 1.x version.');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// eslint-disable-next-line fiori-custom/sap-no-dom-access,fiori-custom/sap-browser-api-warning
|
|
33
|
-
const shellBootstrap = document.getElementById('sap-ushell-bootstrap');
|
|
34
|
-
if (shellBootstrap) {
|
|
35
|
-
shellBootstrap.onload = () => {
|
|
36
|
-
window['sap-ui-config']['xx-bootTask'](fnCallback);
|
|
37
|
-
};
|
|
38
|
-
shellBootstrap.setAttribute('src', src);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* For UI5 version 1.71 and below, we need to remove the asyncHints.requests
|
|
44
|
-
* to load the changes in an Adaptation project.
|
|
45
|
-
* This logic needs to be executed here to have a reliable check for
|
|
46
|
-
* UI5 version and remove the asyncHints.requests before the sandbox is loaded.
|
|
47
|
-
* The sandbox shell modifies the `window['sap-ushell-config']`.
|
|
48
|
-
*/
|
|
49
|
-
function removeAsyncHintsRequests() {
|
|
50
|
-
const obj = window['sap-ushell-config']['applications'];
|
|
51
|
-
|
|
52
|
-
if (!obj || typeof obj !== 'object') return;
|
|
53
|
-
|
|
54
|
-
const stack = [obj];
|
|
55
|
-
|
|
56
|
-
while (stack.length > 0) {
|
|
57
|
-
const current = stack.pop();
|
|
58
|
-
|
|
59
|
-
if (current.asyncHints) {
|
|
60
|
-
if (current.asyncHints.requests) {
|
|
61
|
-
current.asyncHints.requests = [];
|
|
62
|
-
}
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
for (const key in current) {
|
|
67
|
-
if (typeof current[key] === 'object' && current[key] !== null) {
|
|
68
|
-
stack.push(current[key]);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// eslint-disable-next-line fiori-custom/sap-no-global-define
|
|
75
|
-
window['sap-ui-config'] = {
|
|
76
|
-
'xx-bootTask': ushellBootstrap
|
|
77
|
-
};
|