@sap-ux/preview-middleware 0.7.7 → 0.7.9

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.
@@ -69,6 +69,14 @@ export declare class FlpSandbox {
69
69
  * @param resources optional additional resource mappings
70
70
  */
71
71
  init(manifest: Manifest, componentId?: string, resources?: Record<string, string>): Promise<void>;
72
+ /**
73
+ * Generates the FLP sandbox for an editor.
74
+ *
75
+ * @param rta runtime authoring configuration
76
+ * @param editor editor configuration
77
+ * @returns FLP sandbox html
78
+ */
79
+ private generateSandboxForEditor;
72
80
  /**
73
81
  * Add additional routes for configured editors.
74
82
  *
package/dist/base/flp.js CHANGED
@@ -124,6 +124,32 @@ class FlpSandbox {
124
124
  this.logger.debug(`Configured apps: ${JSON.stringify(this.templateConfig.apps)}`);
125
125
  });
126
126
  }
127
+ /**
128
+ * Generates the FLP sandbox for an editor.
129
+ *
130
+ * @param rta runtime authoring configuration
131
+ * @param editor editor configuration
132
+ * @returns FLP sandbox html
133
+ */
134
+ generateSandboxForEditor(rta, editor) {
135
+ var _a;
136
+ const defaultGenerator = editor.developerMode
137
+ ? '@sap-ux/control-property-editor'
138
+ : '@sap-ux/preview-middleware';
139
+ const config = Object.assign({}, this.templateConfig);
140
+ /* sap.ui.rta needs to be added to the list of preload libs for variants management and adaptation projects */
141
+ if (!config.ui5.libs.includes('sap.ui.rta')) {
142
+ const libs = config.ui5.libs.split(',');
143
+ libs.push('sap.ui.rta');
144
+ config.ui5.libs = libs.join(',');
145
+ }
146
+ config.flex = Object.assign(Object.assign({ layer: rta.layer }, rta.options), { generator: (_a = editor.generator) !== null && _a !== void 0 ? _a : defaultGenerator, developerMode: editor.developerMode === true, pluginScript: editor.pluginScript });
147
+ if (editor.developerMode === true) {
148
+ config.ui5.bootstrapOptions = serializeUi5Configuration(DEVELOPER_MODE_CONFIG);
149
+ }
150
+ const template = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../templates/flp/sandbox.html'), 'utf-8');
151
+ return (0, ejs_1.render)(template, config);
152
+ }
127
153
  /**
128
154
  * Add additional routes for configured editors.
129
155
  *
@@ -137,35 +163,25 @@ class FlpSandbox {
137
163
  if (editor.developerMode) {
138
164
  previewUrl = `${previewUrl}.inner.html`;
139
165
  (_a = editor.pluginScript) !== null && _a !== void 0 ? _a : (editor.pluginScript = 'open/ux/preview/client/cpe/init');
140
- this.router.get(editor.path, ((_req, res) => __awaiter(this, void 0, void 0, function* () {
141
- var _b, _c;
166
+ this.router.get(editor.path, (_req, res) => {
167
+ var _a, _b;
142
168
  const template = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../templates/flp/editor.html'), 'utf-8');
143
169
  const html = (0, ejs_1.render)(template, {
144
170
  previewUrl: `${previewUrl}?sap-ui-xx-viewCache=false&fiori-tools-rta-mode=forAdaptation&sap-ui-rta-skip-flex-validation=true&sap-ui-xx-condense-changes=true#${this.config.intent.object}-${this.config.intent.action}`,
145
- telemetry: (_c = (_b = rta.options) === null || _b === void 0 ? void 0 : _b.telemetry) !== null && _c !== void 0 ? _c : false
171
+ telemetry: (_b = (_a = rta.options) === null || _a === void 0 ? void 0 : _a.telemetry) !== null && _b !== void 0 ? _b : false
146
172
  });
147
173
  res.status(200).contentType('html').send(html);
148
- })));
174
+ });
149
175
  let path = (0, path_1.dirname)(editor.path);
150
176
  if (!path.endsWith('/')) {
151
177
  path = `${path}/`;
152
178
  }
153
179
  this.router.use(`${path}editor`, (0, express_1.static)(cpe));
154
180
  }
155
- const defaultGenerator = editor.developerMode
156
- ? '@sap-ux/control-property-editor'
157
- : '@sap-ux/preview-middleware';
158
- this.router.get(previewUrl, ((_req, res) => __awaiter(this, void 0, void 0, function* () {
159
- var _d;
160
- const config = Object.assign({}, this.templateConfig);
161
- config.flex = Object.assign(Object.assign({ layer: rta.layer }, rta.options), { generator: (_d = editor.generator) !== null && _d !== void 0 ? _d : defaultGenerator, developerMode: editor.developerMode === true, pluginScript: editor.pluginScript });
162
- if (editor.developerMode === true) {
163
- config.ui5.bootstrapOptions = serializeUi5Configuration(DEVELOPER_MODE_CONFIG);
164
- }
165
- const template = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../templates/flp/sandbox.html'), 'utf-8');
166
- const html = (0, ejs_1.render)(template, config);
181
+ this.router.get(previewUrl, (_req, res) => {
182
+ const html = this.generateSandboxForEditor(rta, editor);
167
183
  res.status(200).contentType('html').send(html);
168
- })));
184
+ });
169
185
  }
170
186
  }
171
187
  /**
@@ -180,7 +180,7 @@ sap.ui.define(["sap/base/Log", "sap/ui/core/IconPool", "sap/base/i18n/ResourceBu
180
180
  // init
181
181
  setI18nTitle();
182
182
  registerSAPFonts();
183
- const renderer = await sap.ushell.Container.createRenderer(true);
183
+ const renderer = await sap.ushell.Container.createRenderer(undefined, true);
184
184
  renderer.placeAt('content');
185
185
  }
186
186
  const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
@@ -215,7 +215,7 @@ export async function init({ appUrls, flex }: { appUrls?: string | null; flex?:
215
215
  // init
216
216
  setI18nTitle();
217
217
  registerSAPFonts();
218
- const renderer = await sap.ushell.Container.createRenderer(true);
218
+ const renderer = await sap.ushell.Container.createRenderer(undefined, true);
219
219
  renderer.placeAt('content');
220
220
  }
221
221
 
@@ -19,6 +19,12 @@ export interface App {
19
19
  componentId?: string;
20
20
  intent?: Intent;
21
21
  }
22
+ export interface Editor {
23
+ path: string;
24
+ developerMode?: boolean;
25
+ pluginScript?: string;
26
+ generator?: string;
27
+ }
22
28
  export interface RtaConfig {
23
29
  layer: UI5FlexLayer;
24
30
  options?: {
@@ -27,12 +33,7 @@ export interface RtaConfig {
27
33
  projectId?: string;
28
34
  scenario?: string;
29
35
  };
30
- editors: {
31
- path: string;
32
- developerMode?: boolean;
33
- pluginScript?: string;
34
- generator?: string;
35
- }[];
36
+ editors: Editor[];
36
37
  }
37
38
  /**
38
39
  * FLP preview configuration.
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.7.7",
12
+ "version": "0.7.9",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -36,7 +36,7 @@
36
36
  "npm-run-all": "4.1.5",
37
37
  "nock": "13.2.1",
38
38
  "supertest": "6.3.3",
39
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.4.1",
39
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.4.2",
40
40
  "@sap-ux/project-access": "1.13.7",
41
41
  "@sap-ux/store": "0.3.14"
42
42
  },