@sap-ux/preview-middleware 0.24.6 → 0.25.0
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 +16 -0
- package/dist/base/config.js +27 -0
- package/dist/base/flp.js +2 -0
- package/package.json +2 -2
package/dist/base/config.d.ts
CHANGED
|
@@ -135,6 +135,22 @@ export declare function addApp(templateConfig: TemplateConfig, manifest: Partial
|
|
|
135
135
|
* @returns The application name.
|
|
136
136
|
*/
|
|
137
137
|
export declare function getAppName(manifest: Partial<Manifest>, intent?: Intent): string;
|
|
138
|
+
/**
|
|
139
|
+
* Remaps all relative resource-root URLs in a TemplateConfig so they are correct
|
|
140
|
+
* relative to a different HTML page path (e.g. an editor path vs the FLP path).
|
|
141
|
+
*
|
|
142
|
+
* Only the entries that are derived from `basePath` are updated:
|
|
143
|
+
* - the preview-client namespace (`open.ux.preview.client`)
|
|
144
|
+
* - the primary application namespace (keyed by `appId`)
|
|
145
|
+
*
|
|
146
|
+
* Additional applications configured via `flpConfig.apps` use absolute `target`
|
|
147
|
+
* values and therefore do not need remapping.
|
|
148
|
+
*
|
|
149
|
+
* @param config - cloned TemplateConfig already built for the FLP path
|
|
150
|
+
* @param newPagePath - the path of the HTML page that will serve the resources (e.g. `editor.path`)
|
|
151
|
+
* @param appId - the `sap.app.id` used as resource-root key for the primary application
|
|
152
|
+
*/
|
|
153
|
+
export declare function remapResourcesForPath(config: TemplateConfig, newPagePath: string, appId: string): void;
|
|
138
154
|
/**
|
|
139
155
|
* Creates the configuration object for the sandbox.html template.
|
|
140
156
|
*
|
package/dist/base/config.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.sanitizeConfig = sanitizeConfig;
|
|
|
7
7
|
exports.sanitizeRtaConfig = sanitizeRtaConfig;
|
|
8
8
|
exports.addApp = addApp;
|
|
9
9
|
exports.getAppName = getAppName;
|
|
10
|
+
exports.remapResourcesForPath = remapResourcesForPath;
|
|
10
11
|
exports.createFlpTemplateConfig = createFlpTemplateConfig;
|
|
11
12
|
exports.createTestTemplateConfig = createTestTemplateConfig;
|
|
12
13
|
exports.getPreviewPaths = getPreviewPaths;
|
|
@@ -255,6 +256,32 @@ async function getI18nTextFromProperty(projectRoot, propertyValue, appId, logger
|
|
|
255
256
|
}
|
|
256
257
|
return propertyI18nKey;
|
|
257
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* Remaps all relative resource-root URLs in a TemplateConfig so they are correct
|
|
261
|
+
* relative to a different HTML page path (e.g. an editor path vs the FLP path).
|
|
262
|
+
*
|
|
263
|
+
* Only the entries that are derived from `basePath` are updated:
|
|
264
|
+
* - the preview-client namespace (`open.ux.preview.client`)
|
|
265
|
+
* - the primary application namespace (keyed by `appId`)
|
|
266
|
+
*
|
|
267
|
+
* Additional applications configured via `flpConfig.apps` use absolute `target`
|
|
268
|
+
* values and therefore do not need remapping.
|
|
269
|
+
*
|
|
270
|
+
* @param config - cloned TemplateConfig already built for the FLP path
|
|
271
|
+
* @param newPagePath - the path of the HTML page that will serve the resources (e.g. `editor.path`)
|
|
272
|
+
* @param appId - the `sap.app.id` used as resource-root key for the primary application
|
|
273
|
+
*/
|
|
274
|
+
function remapResourcesForPath(config, newPagePath, appId) {
|
|
275
|
+
const newBasePath = node_path_1.posix.relative(node_path_1.posix.dirname(newPagePath), '/') || '.';
|
|
276
|
+
// Update the well-known client namespace to be relative to the new page path
|
|
277
|
+
config.ui5.resources[exports.PREVIEW_URL.client.ns] = exports.PREVIEW_URL.client.getUrl(newBasePath);
|
|
278
|
+
// Update the primary app's resource root (was set to basePath for the main app)
|
|
279
|
+
if (appId && appId in config.ui5.resources) {
|
|
280
|
+
config.ui5.resources[appId] = newBasePath;
|
|
281
|
+
}
|
|
282
|
+
// Keep basePath in sync for any other template usage (e.g. basePath/resources/...)
|
|
283
|
+
config.basePath = newBasePath;
|
|
284
|
+
}
|
|
258
285
|
/**
|
|
259
286
|
* Creates the configuration object for the sandbox.html template.
|
|
260
287
|
*
|
package/dist/base/flp.js
CHANGED
|
@@ -211,6 +211,8 @@ class FlpSandbox {
|
|
|
211
211
|
pluginScript: editor.pluginScript
|
|
212
212
|
};
|
|
213
213
|
config.features = feature_toggle_1.FeatureToggleAccess.getAllFeatureToggles();
|
|
214
|
+
const appId = this.manifest['sap.app']?.id ?? '';
|
|
215
|
+
(0, config_1.remapResourcesForPath)(config, editor.path, appId);
|
|
214
216
|
return (0, ejs_1.render)(this.getSandboxTemplate(ui5Version), config);
|
|
215
217
|
}
|
|
216
218
|
/**
|
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
|
+
"version": "0.25.0",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"@sap/bas-sdk": "3.13.3",
|
|
30
30
|
"@sap-ux/adp-tooling": "0.18.99",
|
|
31
31
|
"@sap-ux/btp-utils": "1.1.10",
|
|
32
|
-
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.7.22",
|
|
33
32
|
"@sap-ux/feature-toggle": "0.3.7",
|
|
33
|
+
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.7.22",
|
|
34
34
|
"@sap-ux/logger": "0.8.2",
|
|
35
35
|
"@sap-ux/project-access": "1.35.14",
|
|
36
36
|
"@sap-ux/system-access": "0.7.1",
|