@sap-ux/preview-middleware 0.11.17 → 0.11.19

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.
@@ -31,6 +31,9 @@ export interface TemplateConfig {
31
31
  additionalInformation: string;
32
32
  applicationType: 'URL';
33
33
  url: string;
34
+ applicationDependencies?: {
35
+ manifest: boolean;
36
+ };
34
37
  }>;
35
38
  ui5: {
36
39
  libs: string;
@@ -116,6 +119,13 @@ export declare class FlpSandbox {
116
119
  * @param app configuration for the preview
117
120
  */
118
121
  addApp(manifest: Manifest, app: App): void;
122
+ /**
123
+ * Gets the UI5 libs dependencies from manifest.json.
124
+ *
125
+ * @param manifest application manifest
126
+ * @returns UI5 libs that should preloaded
127
+ */
128
+ private getUI5Libs;
119
129
  }
120
130
  /**
121
131
  * Initialize the preview for an adaptation project.
package/dist/base/flp.js CHANGED
@@ -25,6 +25,33 @@ const DEVELOPER_MODE_CONFIG = new Map([
25
25
  // Make sure that XML preprocessing results are correctly invalidated
26
26
  ['xx-viewCache', 'false']
27
27
  ]);
28
+ /**
29
+ * SAPUI5 delivered namespaces from https://ui5.sap.com/#/api/sap
30
+ */
31
+ const UI5_LIBS = [
32
+ 'sap.apf',
33
+ 'sap.base',
34
+ 'sap.chart',
35
+ 'sap.collaboration',
36
+ 'sap.f',
37
+ 'sap.fe',
38
+ 'sap.fileviewer',
39
+ 'sap.gantt',
40
+ 'sap.landvisz',
41
+ 'sap.m',
42
+ 'sap.ndc',
43
+ 'sap.ovp',
44
+ 'sap.rules',
45
+ 'sap.suite',
46
+ 'sap.tnt',
47
+ 'sap.ui',
48
+ 'sap.uiext',
49
+ 'sap.ushell',
50
+ 'sap.uxap',
51
+ 'sap.viz',
52
+ 'sap.webanalytics',
53
+ 'sap.zen'
54
+ ];
28
55
  /**
29
56
  * Default theme
30
57
  */
@@ -90,8 +117,8 @@ class FlpSandbox {
90
117
  * @param resources optional additional resource mappings
91
118
  */
92
119
  init(manifest, componentId, resources = {}) {
93
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
94
- var _l;
120
+ var _a, _b, _c, _d, _e, _f, _g;
121
+ var _h;
95
122
  return __awaiter(this, void 0, void 0, function* () {
96
123
  const flex = this.createFlexHandler();
97
124
  const supportedThemes = (_b = (_a = manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.supportedThemes) !== null && _b !== void 0 ? _b : [DEFAULT_THEME];
@@ -100,23 +127,23 @@ class FlpSandbox {
100
127
  basePath: (_d = (0, path_1.relative)((0, path_1.dirname)(this.config.path), '/')) !== null && _d !== void 0 ? _d : '.',
101
128
  apps: {},
102
129
  ui5: {
103
- libs: Object.keys((_g = (_f = (_e = manifest['sap.ui5']) === null || _e === void 0 ? void 0 : _e.dependencies) === null || _f === void 0 ? void 0 : _f.libs) !== null && _g !== void 0 ? _g : {}).join(','),
130
+ libs: this.getUI5Libs(manifest),
104
131
  theme: ui5Theme,
105
132
  flex,
106
133
  resources: Object.assign(Object.assign({}, resources), { [PREVIEW_URL.client.ns]: PREVIEW_URL.client.url }),
107
134
  bootstrapOptions: ''
108
135
  },
109
- locateReuseLibsScript: (_h = this.config.libs) !== null && _h !== void 0 ? _h : (yield this.hasLocateReuseLibsScript())
136
+ locateReuseLibsScript: (_e = this.config.libs) !== null && _e !== void 0 ? _e : (yield this.hasLocateReuseLibsScript())
110
137
  };
111
138
  this.addApp(manifest, {
112
139
  componentId,
113
- target: (_j = resources[componentId !== null && componentId !== void 0 ? componentId : manifest['sap.app'].id]) !== null && _j !== void 0 ? _j : this.templateConfig.basePath,
140
+ target: (_f = resources[componentId !== null && componentId !== void 0 ? componentId : manifest['sap.app'].id]) !== null && _f !== void 0 ? _f : this.templateConfig.basePath,
114
141
  local: '.',
115
142
  intent: this.config.intent
116
143
  });
117
144
  this.addStandardRoutes();
118
145
  if (this.rta) {
119
- (_k = (_l = this.rta).options) !== null && _k !== void 0 ? _k : (_l.options = {});
146
+ (_g = (_h = this.rta).options) !== null && _g !== void 0 ? _g : (_h.options = {});
120
147
  this.rta.options.baseId = componentId !== null && componentId !== void 0 ? componentId : manifest['sap.app'].id;
121
148
  this.addEditorRoutes(this.rta);
122
149
  }
@@ -311,9 +338,34 @@ class FlpSandbox {
311
338
  description: (_e = manifest['sap.app'].description) !== null && _e !== void 0 ? _e : '',
312
339
  additionalInformation: `SAPUI5.Component=${(_f = app.componentId) !== null && _f !== void 0 ? _f : id}`,
313
340
  applicationType: 'URL',
314
- url: app.target
341
+ url: app.target,
342
+ applicationDependencies: {
343
+ manifest: true
344
+ }
315
345
  };
316
346
  }
347
+ /**
348
+ * Gets the UI5 libs dependencies from manifest.json.
349
+ *
350
+ * @param manifest application manifest
351
+ * @returns UI5 libs that should preloaded
352
+ */
353
+ getUI5Libs(manifest) {
354
+ var _a, _b;
355
+ if ((_b = (_a = manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.dependencies) === null || _b === void 0 ? void 0 : _b.libs) {
356
+ const libNames = Object.keys(manifest['sap.ui5'].dependencies.libs);
357
+ return libNames
358
+ .filter((key) => {
359
+ return UI5_LIBS.some((substring) => {
360
+ return key === substring || key.startsWith(substring + '.');
361
+ });
362
+ })
363
+ .join(',');
364
+ }
365
+ else {
366
+ return 'sap.m,sap.ui.core,sap.ushell';
367
+ }
368
+ }
317
369
  }
318
370
  exports.FlpSandbox = FlpSandbox;
319
371
  /**
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.11.17",
12
+ "version": "0.11.19",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -23,9 +23,9 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "ejs": "3.1.9",
26
+ "@sap-ux/adp-tooling": "0.7.2",
26
27
  "@sap-ux/logger": "0.4.0",
27
- "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.6",
28
- "@sap-ux/adp-tooling": "0.7.2"
28
+ "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.6"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/ejs": "3.1.2",