@ui5/builder 3.0.0-alpha.1 → 3.0.0-alpha.10

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +850 -0
  2. package/index.js +0 -43
  3. package/lib/lbt/analyzer/JSModuleAnalyzer.js +27 -8
  4. package/lib/lbt/analyzer/XMLTemplateAnalyzer.js +2 -1
  5. package/lib/lbt/bundle/Builder.js +364 -137
  6. package/lib/lbt/bundle/BundleWriter.js +17 -0
  7. package/lib/lbt/bundle/Resolver.js +2 -2
  8. package/lib/lbt/resources/LocatorResource.js +7 -7
  9. package/lib/lbt/resources/LocatorResourcePool.js +8 -4
  10. package/lib/lbt/resources/ResourceCollector.js +22 -15
  11. package/lib/lbt/resources/ResourceInfoList.js +0 -1
  12. package/lib/lbt/resources/ResourcePool.js +7 -6
  13. package/lib/lbt/utils/escapePropertiesFile.js +3 -6
  14. package/lib/lbt/utils/parseUtils.js +1 -1
  15. package/lib/processors/bundlers/moduleBundler.js +31 -10
  16. package/lib/processors/jsdoc/lib/createIndexFiles.js +1 -1
  17. package/lib/processors/jsdoc/lib/transformApiJson.js +20 -20
  18. package/lib/processors/jsdoc/lib/ui5/plugin.js +111 -6
  19. package/lib/processors/jsdoc/lib/ui5/template/publish.js +112 -91
  20. package/lib/processors/jsdoc/lib/ui5/template/utils/versionUtil.js +1 -1
  21. package/lib/processors/manifestCreator.js +8 -45
  22. package/lib/processors/minifier.js +11 -5
  23. package/lib/tasks/buildThemes.js +1 -1
  24. package/lib/tasks/bundlers/generateBundle.js +70 -30
  25. package/lib/tasks/bundlers/generateComponentPreload.js +26 -19
  26. package/lib/tasks/bundlers/generateFlexChangesBundle.js +10 -5
  27. package/lib/tasks/bundlers/generateLibraryPreload.js +113 -94
  28. package/lib/tasks/bundlers/generateManifestBundle.js +8 -10
  29. package/lib/tasks/bundlers/generateStandaloneAppBundle.js +42 -10
  30. package/lib/tasks/bundlers/utils/createModuleNameMapping.js +31 -0
  31. package/lib/tasks/generateCachebusterInfo.js +7 -3
  32. package/lib/tasks/generateLibraryManifest.js +6 -8
  33. package/lib/tasks/generateResourcesJson.js +3 -3
  34. package/lib/tasks/generateThemeDesignerResources.js +118 -2
  35. package/lib/tasks/generateVersionInfo.js +5 -5
  36. package/lib/tasks/jsdoc/generateJsdoc.js +1 -1
  37. package/lib/tasks/minify.js +14 -4
  38. package/lib/tasks/taskRepository.js +1 -13
  39. package/lib/tasks/transformBootstrapHtml.js +6 -1
  40. package/package.json +11 -10
  41. package/lib/builder/BuildContext.js +0 -56
  42. package/lib/builder/ProjectBuildContext.js +0 -57
  43. package/lib/builder/builder.js +0 -419
  44. package/lib/tasks/TaskUtil.js +0 -160
  45. package/lib/types/AbstractBuilder.js +0 -270
  46. package/lib/types/AbstractFormatter.js +0 -66
  47. package/lib/types/AbstractUi5Formatter.js +0 -95
  48. package/lib/types/application/ApplicationBuilder.js +0 -211
  49. package/lib/types/application/ApplicationFormatter.js +0 -227
  50. package/lib/types/application/applicationType.js +0 -15
  51. package/lib/types/library/LibraryBuilder.js +0 -231
  52. package/lib/types/library/LibraryFormatter.js +0 -519
  53. package/lib/types/library/libraryType.js +0 -15
  54. package/lib/types/module/ModuleBuilder.js +0 -7
  55. package/lib/types/module/ModuleFormatter.js +0 -54
  56. package/lib/types/module/moduleType.js +0 -15
  57. package/lib/types/themeLibrary/ThemeLibraryBuilder.js +0 -63
  58. package/lib/types/themeLibrary/ThemeLibraryFormatter.js +0 -90
  59. package/lib/types/themeLibrary/themeLibraryType.js +0 -15
  60. package/lib/types/typeRepository.js +0 -46
@@ -11,6 +11,8 @@ const SPACES_OR_TABS_ONLY = /^[ \t]+$/;
11
11
  *
12
12
  * Most methods have been extracted from JSMergeWriter.
13
13
  *
14
+ * columnOffset and lineOffset are used for sourcemap merging as reference to where we are at a given point in time
15
+ *
14
16
  * @author Frank Weigel
15
17
  * @since 1.27.0
16
18
  * @private
@@ -18,6 +20,8 @@ const SPACES_OR_TABS_ONLY = /^[ \t]+$/;
18
20
  class BundleWriter {
19
21
  constructor() {
20
22
  this.buf = "";
23
+ this.lineOffset = 0;
24
+ this.columnOffset = 0;
21
25
  this.segments = [];
22
26
  this.currentSegment = null;
23
27
  this.currentSourceIndex = 0;
@@ -28,6 +32,11 @@ class BundleWriter {
28
32
  let writeBuf = "";
29
33
  for ( let i = 0; i < str.length; i++ ) {
30
34
  writeBuf += str[i];
35
+ if (str[i] != null && str[i].split) {
36
+ const strSplit = str[i].split(NL);
37
+ this.lineOffset += strSplit.length - 1;
38
+ this.columnOffset += strSplit[strSplit.length - 1].length;
39
+ }
31
40
  }
32
41
  if ( writeBuf.length >= 1 ) {
33
42
  this.buf += writeBuf;
@@ -40,15 +49,23 @@ class BundleWriter {
40
49
  writeln(...str) {
41
50
  for ( let i = 0; i < str.length; i++ ) {
42
51
  this.buf += str[i];
52
+ if (str[i] != null && str[i].split) {
53
+ const strSplit = str[i].split(NL);
54
+ this.lineOffset += strSplit.length - 1;
55
+ }
43
56
  }
44
57
  this.buf += NL;
45
58
  this.endsWithNewLine = true;
59
+ this.lineOffset += 1;
60
+ this.columnOffset = 0;
46
61
  }
47
62
 
48
63
  ensureNewLine() {
49
64
  if ( !this.endsWithNewLine ) {
50
65
  this.buf += NL;
51
66
  this.endsWithNewLine = true;
67
+ this.lineOffset += 1;
68
+ this.columnOffset = 0;
52
69
  }
53
70
  }
54
71
 
@@ -292,12 +292,12 @@ class BundleResolver {
292
292
  if ( section.mode == SectionType.Raw && section.sort !== false ) {
293
293
  // sort the modules in topological order
294
294
  return topologicalSort(pool, modules).then( (modules) => {
295
- log.verbose(" resolved modules (sorted): %s", modules);
295
+ log.silly(" resolved modules (sorted): %s", modules);
296
296
  return modules;
297
297
  });
298
298
  }
299
299
 
300
- log.verbose(" resolved modules: %s", modules);
300
+ log.silly(" resolved modules: %s", modules);
301
301
  return modules;
302
302
  }).then( function(modules) {
303
303
  resolvedSection.modules = modules;
@@ -1,12 +1,8 @@
1
1
  const Resource = require("./Resource");
2
2
 
3
- function extractName(path) {
4
- return path.slice( "/resources/".length);
5
- }
6
-
7
3
  class LocatorResource extends Resource {
8
- constructor(pool, resource) {
9
- super(pool, extractName(resource.getPath()), null, resource.getStatInfo());
4
+ constructor(pool, resource, moduleName) {
5
+ super(pool, moduleName, null, resource.getStatInfo());
10
6
  this.resource = resource;
11
7
  }
12
8
 
@@ -15,7 +11,11 @@ class LocatorResource extends Resource {
15
11
  }
16
12
 
17
13
  getProject() {
18
- return this.resource._project;
14
+ return this.resource.getProject();
15
+ }
16
+
17
+ getPath() {
18
+ return this.resource.getPath();
19
19
  }
20
20
  }
21
21
 
@@ -2,12 +2,16 @@ const ResourcePool = require("./ResourcePool");
2
2
  const LocatorResource = require("./LocatorResource");
3
3
 
4
4
  class LocatorResourcePool extends ResourcePool {
5
- prepare(resources) {
5
+ prepare(resources, moduleNameMapping) {
6
6
  resources = resources.filter( (res) => !res.getStatInfo().isDirectory() );
7
7
  return Promise.all(
8
- resources.map(
9
- (resource) => this.addResource( new LocatorResource(this, resource) )
10
- ).filter(Boolean)
8
+ resources.map((resource) => {
9
+ let moduleName = moduleNameMapping && moduleNameMapping[resource.getPath()];
10
+ if (!moduleName) {
11
+ moduleName = resource.getPath().slice("/resources/".length);
12
+ }
13
+ return this.addResource(new LocatorResource(this, resource, moduleName));
14
+ }).filter(Boolean)
11
15
  );
12
16
  }
13
17
  }
@@ -110,10 +110,11 @@ class ResourceCollector {
110
110
  }
111
111
 
112
112
  async enrichWithDependencyInfo(resourceInfo) {
113
- return this._pool.getModuleInfo(resourceInfo.name).then(async (moduleInfo) => {
114
- if ( moduleInfo.name ) {
113
+ return this._pool.getModuleInfo(resourceInfo.name, resourceInfo.module).then(async (moduleInfo) => {
114
+ if ( !resourceInfo.module && moduleInfo.name ) {
115
115
  resourceInfo.module = moduleInfo.name;
116
116
  }
117
+
117
118
  if ( moduleInfo.dynamicDependencies ) {
118
119
  resourceInfo.dynRequired = true;
119
120
  }
@@ -279,37 +280,43 @@ class ResourceCollector {
279
280
 
280
281
  await Promise.all(promises);
281
282
 
282
- const debugBundlePromises = [];
283
-
284
- for (let i = debugResourcesInfo.length - 1; i >= 0; i--) {
285
- const dbgInfo = debugResourcesInfo[i];
286
- const nonDebugName = ResourceInfoList.getNonDebugName(dbgInfo.name);
283
+ await Promise.all(debugResourcesInfo.map(async (dbgInfo) => {
284
+ const debugName = dbgInfo.name;
285
+ const nonDebugName = ResourceInfoList.getNonDebugName(debugName);
287
286
  const nonDbgInfo = this._resources.get(nonDebugName);
288
287
 
289
288
  // FIXME: "merged" property is only calculated in ResourceInfo#copyFrom
290
289
  // Therefore using the same logic here to compute it.
290
+
291
+ // TODO: Idea: Use IsDebugVariant tag to decide whether to analyze the resource
292
+ // If the tag is set, we don't expect different analysis results so we can copy the info (else-path)
293
+ // Only when the tag is not set, we analyze the resource with its name (incl. -dbg)
294
+
291
295
  if (!nonDbgInfo || (nonDbgInfo.included != null && nonDbgInfo.included.size > 0)) {
292
296
  // We need to analyze the dbg resource if there is no non-dbg variant or
293
297
  // it is a bundle because we will (usually) have different content.
294
- debugBundlePromises.push(
295
- this.enrichWithDependencyInfo(dbgInfo)
296
- );
298
+
299
+ if (nonDbgInfo) {
300
+ // Always use the non-debug module name, if available
301
+ dbgInfo.module = nonDbgInfo.module;
302
+ }
303
+ await this.enrichWithDependencyInfo(dbgInfo);
297
304
  } else {
298
305
  // If the non-dbg resource is not a bundle, we can just copy over the info and skip
299
306
  // analyzing the dbg variant as both should have the same info.
300
307
 
301
- const newDbgInfo = new ResourceInfo(dbgInfo.name);
308
+ const newDbgInfo = new ResourceInfo(debugName);
302
309
 
303
310
  // First copy info of analysis from non-dbg file (included, required, condRequired, ...)
304
311
  newDbgInfo.copyFrom(null, nonDbgInfo);
305
312
  // Then copy over info from dbg file to properly set name, isDebug, etc.
306
313
  newDbgInfo.copyFrom(null, dbgInfo);
314
+ // Finally, set the module name to the non-dbg name
315
+ newDbgInfo.module = nonDbgInfo.module;
307
316
 
308
- this._resources.set(dbgInfo.name, newDbgInfo);
317
+ this._resources.set(debugName, newDbgInfo);
309
318
  }
310
- }
311
-
312
- await Promise.all(debugBundlePromises);
319
+ }));
313
320
  }
314
321
 
315
322
  createOrphanFilters() {
@@ -48,7 +48,6 @@ class ResourceInfoList {
48
48
  if ( myInfo == null ) {
49
49
  myInfo = new ResourceInfo(relativeName);
50
50
  myInfo.size = info.size;
51
- myInfo.module = ResourceInfoList.getNonDebugName(info.name);
52
51
  this.resources.push(myInfo);
53
52
  this.resourcesByName.set(relativeName, myInfo);
54
53
  }
@@ -176,17 +176,18 @@ class ResourcePool {
176
176
  /**
177
177
  * Retrieves the module info
178
178
  *
179
- * @param {string} name module name
179
+ * @param {string} resourceName resource/module name
180
+ * @param {string} [moduleName] module name, in case it differs from the resource name (e.g. for -dbg resources)
180
181
  * @returns {Promise<ModuleInfo>}
181
182
  */
182
- async getModuleInfo(name) {
183
- let info = this._dependencyInfos.get(name);
183
+ async getModuleInfo(resourceName, moduleName) {
184
+ let info = this._dependencyInfos.get(resourceName);
184
185
  if ( info == null ) {
185
186
  info = Promise.resolve().then(async () => {
186
- const resource = await this.findResource(name);
187
- return determineDependencyInfo( resource, this._rawModuleInfos.get(name), this );
187
+ const resource = await this.findResource(resourceName);
188
+ return determineDependencyInfo( resource, this._rawModuleInfos.get(moduleName || resourceName), this );
188
189
  });
189
- this._dependencyInfos.set(name, info);
190
+ this._dependencyInfos.set(resourceName, info);
190
191
  }
191
192
  return info;
192
193
  }
@@ -4,7 +4,7 @@ const nonAsciiEscaper = require("../../processors/nonAsciiEscaper");
4
4
  * Can be used to escape *.properties files.
5
5
  *
6
6
  * Input encoding is read from project configuration.
7
- * In case the resource belongs to no project (e.g. bundler is used standalone) the default is "ISO-8859-1".
7
+ * In case the resource belongs to no project (e.g. bundler is used standalone) the default is "UTF-8".
8
8
  *
9
9
  * @private
10
10
  * @param {Resource} resource the resource for which the content will be escaped
@@ -12,13 +12,10 @@ const nonAsciiEscaper = require("../../processors/nonAsciiEscaper");
12
12
  */
13
13
  module.exports = async function(resource) {
14
14
  const project = resource.getProject();
15
- let propertiesFileSourceEncoding = project &&
16
- project.resources &&
17
- project.resources.configuration &&
18
- project.resources.configuration.propertiesFileSourceEncoding;
15
+ let propertiesFileSourceEncoding = project && project.getPropertiesFileSourceEncoding();
19
16
 
20
17
  if (!propertiesFileSourceEncoding) {
21
- if (project && ["0.1", "1.0", "1.1"].includes(project.specVersion)) {
18
+ if (project && ["0.1", "1.0", "1.1"].includes(project.getSpecVersion())) {
22
19
  // default encoding to "ISO-8859-1" for old specVersions
23
20
  propertiesFileSourceEncoding = "ISO-8859-1";
24
21
  } else {
@@ -9,7 +9,7 @@ function parseJS(code, userOptions = {}) {
9
9
  // allowed options and their defaults
10
10
  const options = {
11
11
  comment: false,
12
- ecmaVersion: 2021,
12
+ ecmaVersion: 2021, // NOTE: Adopt JSModuleAnalyzer.js to allow new Syntax when upgrading to newer ECMA versions
13
13
  range: false,
14
14
  sourceType: "script",
15
15
  };
@@ -90,9 +90,10 @@ const log = require("@ui5/logger").getLogger("builder:processors:bundlers:module
90
90
  * @public
91
91
  * @typedef {object} ModuleBundleOptions
92
92
  * @property {boolean} [optimize=true] Whether the module bundle gets minified
93
- * @property {boolean} [decorateBootstrapModule=false] If set to 'false', the module won't be decorated
93
+ * @property {boolean} [sourceMap=true] Whether to generate a source map file for the bundle
94
+ * @property {boolean} [decorateBootstrapModule=false] If set to 'false', bootable bundles won't be decorated
94
95
  * with an optimization marker
95
- * @property {boolean} [addTryCatchRestartWrapper=false] Whether to wrap bootable module bundles with
96
+ * @property {boolean} [addTryCatchRestartWrapper=false] Whether to wrap bootable bundles with
96
97
  * a try/catch to filter out "Restart" errors
97
98
  * @property {boolean} [usePredefineCalls=false] If set to 'true', sap.ui.predefine is used for UI5 modules
98
99
  * @property {number} [numberOfParts=1] The number of parts the module bundle should be splitted
@@ -101,21 +102,35 @@ const log = require("@ui5/logger").getLogger("builder:processors:bundlers:module
101
102
  */
102
103
 
103
104
  /**
104
- * Legacy preload bundler.
105
+ * Result set
106
+ *
107
+ * @public
108
+ * @typedef {object} ModuleBundlerResult
109
+ * @property {module:@ui5/fs.Resource} bundle Bundle resource
110
+ * @property {module:@ui5/fs.Resource} sourceMap Source Map
111
+ * @memberof module:@ui5/builder.processors
112
+ */
113
+
114
+ /**
115
+ * Legacy module bundler.
105
116
  *
106
117
  * @public
107
118
  * @alias module:@ui5/builder.processors.moduleBundler
108
119
  * @param {object} parameters Parameters
109
120
  * @param {module:@ui5/fs.Resource[]} parameters.resources Resources
110
121
  * @param {object} parameters.options Options
122
+ * @param {object} [parameters.options.moduleNameMapping]
123
+ Optional mapping of resource paths to module name in order to overwrite the default determination
111
124
  * @param {ModuleBundleDefinition} parameters.options.bundleDefinition Module bundle definition
112
125
  * @param {ModuleBundleOptions} [parameters.options.bundleOptions] Module bundle options
113
- * @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving with module bundle resources
126
+ * @returns {Promise<module:@ui5/builder.processors.ModuleBundlerResult[]>}
127
+ * Promise resolving with module bundle resources
114
128
  */
115
- module.exports = function({resources, options: {bundleDefinition, bundleOptions}}) {
129
+ module.exports = function({resources, options: {bundleDefinition, bundleOptions, moduleNameMapping}}) {
116
130
  // Apply defaults without modifying the passed object
117
131
  bundleOptions = Object.assign({}, {
118
132
  optimize: true,
133
+ sourceMap: true,
119
134
  decorateBootstrapModule: false,
120
135
  addTryCatchRestartWrapper: false,
121
136
  usePredefineCalls: false,
@@ -133,8 +148,7 @@ module.exports = function({resources, options: {bundleDefinition, bundleOptions}
133
148
  log.verbose(`bundleDefinition: ${JSON.stringify(bundleDefinition, null, 2)}`);
134
149
  log.verbose(`bundleOptions: ${JSON.stringify(bundleOptions, null, 2)}`);
135
150
  }
136
-
137
- return pool.prepare( resources ).
151
+ return pool.prepare( resources, moduleNameMapping ).
138
152
  then( () => builder.createBundle(bundleDefinition, bundleOptions) ).
139
153
  then( (results) => {
140
154
  let bundles;
@@ -146,13 +160,20 @@ module.exports = function({resources, options: {bundleDefinition, bundleOptions}
146
160
 
147
161
  return Promise.all(bundles.map((bundleObj) => {
148
162
  if ( bundleObj ) {
149
- const {name, content} = bundleObj;
163
+ const {name, content, sourceMap} = bundleObj;
150
164
  // console.log("creating bundle as '%s'", "/resources/" + name);
151
- const resource = new EvoResource({
165
+ const res = {};
166
+ res.bundle = new EvoResource({
152
167
  path: "/resources/" + name,
153
168
  string: content
154
169
  });
155
- return resource;
170
+ if (sourceMap) {
171
+ res.sourceMap = new EvoResource({
172
+ path: "/resources/" + name + ".map",
173
+ string: sourceMap
174
+ });
175
+ }
176
+ return res;
156
177
  }
157
178
  }));
158
179
  });
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Node script to create cross-library API index files for use in the UI5 SDKs.
3
3
  *
4
- * (c) Copyright 2009-2021 SAP SE or an SAP affiliate company.
4
+ * (c) Copyright 2009-2022 SAP SE or an SAP affiliate company.
5
5
  * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
6
6
  */
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Node script to preprocess api.json files for use in the UI5 SDKs.
3
3
  *
4
- * (c) Copyright 2009-2021 SAP SE or an SAP affiliate company.
4
+ * (c) Copyright 2009-2022 SAP SE or an SAP affiliate company.
5
5
  * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
6
6
  */
7
7
 
@@ -1154,7 +1154,7 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
1154
1154
  },
1155
1155
 
1156
1156
  formatMethodCode: function (sName, aParams, aReturnValue) {
1157
- var result = '<pre class="prettyprint">' + sName + '(';
1157
+ var result = '<pre>' + sName + '(';
1158
1158
 
1159
1159
  if (aParams && aParams.length > 0) {
1160
1160
  /* We consider only root level parameters so we get rid of all that are not on the root level */
@@ -1258,7 +1258,7 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
1258
1258
  * @returns string - The code needed to create an object of that class
1259
1259
  */
1260
1260
  formatConstructor: function (name, params) {
1261
- var result = '<pre class="prettyprint">new ';
1261
+ var result = '<pre>new ';
1262
1262
 
1263
1263
  if (name) {
1264
1264
  result += name + '(';
@@ -1386,13 +1386,16 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
1386
1386
 
1387
1387
  },
1388
1388
 
1389
+ formatUrlToLink: function(sTarget, sText, bSAPHosted){
1390
+ return `<a target="_blank" rel="noopener noreferrer" href="${sTarget}">${sText}</a>
1391
+ <img src="./resources/sap/ui/documentation/sdk/images/${bSAPHosted ? 'link-sap' : 'link-external'}.png"
1392
+ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapUISDKExternalLink"/>`;
1393
+ },
1394
+
1389
1395
  handleExternalUrl: function (sTarget, sText) {
1390
1396
  // Check if the external domain is SAP hosted
1391
1397
  let bSAPHosted = /^https?:\/\/([\w.]*\.)?(?:sap|hana\.ondemand|sapfioritrial)\.com/.test(sTarget);
1392
-
1393
- return `<a target="_blank" rel="noopener noreferrer" href="${sTarget}">${sText}</a>
1394
- <img src="./resources/sap/ui/documentation/sdk/images/${bSAPHosted ? 'link-sap' : 'link-external'}.png"
1395
- title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapUISDKExternalLink"/>`;
1398
+ return this.formatUrlToLink(sTarget, sText, bSAPHosted);
1396
1399
  },
1397
1400
 
1398
1401
  /**
@@ -1505,8 +1508,7 @@ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapU
1505
1508
  name: oResult.static ? [self.name, oResult.name].join(".") : oResult.name,
1506
1509
  type: "methods",
1507
1510
  className: className,
1508
- text: text,
1509
- local: true
1511
+ text: text
1510
1512
  });
1511
1513
  }
1512
1514
  }
@@ -1546,7 +1548,7 @@ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapU
1546
1548
  * @param {string} [hrefAppend=""]
1547
1549
  * @returns {string} link
1548
1550
  */
1549
- createLink: function ({name, type, className, text=name, local=false, hrefAppend=""}) {
1551
+ createLink: function ({name, type, className, text=name, hrefAppend=""}) {
1550
1552
  let sLink;
1551
1553
 
1552
1554
  // handling module's
@@ -1561,12 +1563,7 @@ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapU
1561
1563
  sLink += hrefAppend;
1562
1564
  }
1563
1565
 
1564
- if (local) {
1565
- let sScrollClass = "scrollTo" + type[0].toUpperCase() + type.slice(1, -1);
1566
- return `<a target="_self" class="jsdoclink ${sScrollClass}" data-target="${name}" href="api/${sLink}">${text}</a>`;
1567
- }
1568
-
1569
- return `<a target="_self" class="jsdoclink" href="api/${sLink}">${text}</a>`;
1566
+ return `<a target="_self" href="api/${sLink}">${text}</a>`;
1570
1567
  },
1571
1568
 
1572
1569
  /**
@@ -1594,11 +1591,17 @@ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapU
1594
1591
  }
1595
1592
 
1596
1593
  // topic:xxx Topic
1597
- aMatch = sTarget.match(/^topic:(\w{32})$/);
1594
+ aMatch = sTarget.match(/^topic:(\w{32}(?:#\w*)?(?:\/\w*)?)$/);
1598
1595
  if (aMatch) {
1599
1596
  return '<a target="_self" href="topic/' + aMatch[1] + '">' + sText + '</a>';
1600
1597
  }
1601
1598
 
1599
+ // demo:xxx Demo, open the demonstration page in a new window
1600
+ aMatch = sTarget.match(/^demo:([a-zA-Z0-9\/.]*)$/);
1601
+ if (aMatch) {
1602
+ return this.formatUrlToLink("test-resources/" + aMatch[1], sText, true);
1603
+ }
1604
+
1602
1605
  // sap.x.Xxx.prototype.xxx - In case of prototype we have a link to method
1603
1606
  aMatch = sTarget.match(/([a-zA-Z0-9.$_]+?)\.prototype\.([a-zA-Z0-9.$_]+)$/);
1604
1607
  if (aMatch) {
@@ -1656,7 +1659,6 @@ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapU
1656
1659
  name: aMatch[1] ? `${oSelf.name}.${aMatch[2]}` : aMatch[2],
1657
1660
  type: "methods",
1658
1661
  className: oSelf.name,
1659
- local: true,
1660
1662
  text: sText
1661
1663
  });
1662
1664
  }
@@ -1668,7 +1670,6 @@ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapU
1668
1670
  name: aMatch[1],
1669
1671
  type: "annotations",
1670
1672
  className: oSelf.name,
1671
- local: true,
1672
1673
  text: sText
1673
1674
  });
1674
1675
  }
@@ -1695,7 +1696,6 @@ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapU
1695
1696
  name: aMatch[1],
1696
1697
  type: "events",
1697
1698
  className: oSelf.name,
1698
- local: true,
1699
1699
  text: sText
1700
1700
  });
1701
1701
  }
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * JSDoc3 plugin for UI5 documentation generation.
3
3
  *
4
- * (c) Copyright 2009-2021 SAP SE or an SAP affiliate company.
4
+ * (c) Copyright 2009-2022 SAP SE or an SAP affiliate company.
5
5
  * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
6
6
  */
7
7
 
@@ -288,10 +288,11 @@ function collectShortcuts(body) {
288
288
  } else if ( valueNode.type === Syntax.MemberExpression ) {
289
289
  const _import = getLeftmostName(valueNode);
290
290
  const local = _import && currentModule.localNames[_import];
291
- if ( typeof local === 'object' && local.module ) {
291
+ const objectName = getObjectName(valueNode);
292
+ if ( objectName && typeof local === 'object' && local.module ) {
292
293
  currentModule.localNames[name] = {
293
294
  module: local.module,
294
- path: getObjectName(valueNode).split('.').slice(1).join('.') // TODO chaining if local has path
295
+ path: objectName.split('.').slice(1).join('.') // TODO chaining if local has path
295
296
  };
296
297
  debug(` found local shortcut: ${name} ${currentModule.localNames[name]}`);
297
298
  }
@@ -1617,7 +1618,7 @@ function createAutoDoc(oClassInfo, classComment, doclet, node, parser, filename,
1617
1618
  "Removes a " + n1 + " from the aggregation " + link + ".",
1618
1619
  "",
1619
1620
  "@param {int | string | " + makeTypeString(info, true) + "} " + varname(n1, "variant") + " The " + n1 + " to remove or its index or id",
1620
- "@returns {" + makeTypeString(info, true) + "} The removed " + n1 + " or <code>null</code>",
1621
+ "@returns {" + makeTypeString(info, true) + "|null} The removed " + n1 + " or <code>null</code>",
1621
1622
  info.since ? "@since " + info.since : "",
1622
1623
  info.deprecation ? "@deprecated " + info.deprecation : "",
1623
1624
  info.experimental ? "@experimental " + info.experimental : "",
@@ -1812,7 +1813,7 @@ function createAutoDoc(oClassInfo, classComment, doclet, node, parser, filename,
1812
1813
  "",
1813
1814
  "@param {object}",
1814
1815
  " [oData] An application-specific payload object that will be passed to the event handler along with the event object when firing the event",
1815
- "@param {function}",
1816
+ "@param {function(sap.ui.base.Event):void}",
1816
1817
  " fnFunction The function to be called when the event occurs",
1817
1818
  "@param {object}",
1818
1819
  " [oListener] Context object to call the event handler with. Defaults to this <code>" + oClassInfo.name + "</code> itself",
@@ -1830,7 +1831,7 @@ function createAutoDoc(oClassInfo, classComment, doclet, node, parser, filename,
1830
1831
  "",
1831
1832
  "The passed function and listener object must match the ones used for event registration.",
1832
1833
  "",
1833
- "@param {function}",
1834
+ "@param {function(sap.ui.base.Event):void}",
1834
1835
  " fnFunction The function to be called, when the event occurs",
1835
1836
  "@param {object}",
1836
1837
  " [oListener] Context object on which the given function had to be called",
@@ -2677,3 +2678,107 @@ exports.astNodeVisitor = {
2677
2678
  }
2678
2679
 
2679
2680
  };
2681
+
2682
+ (function() {
2683
+ const jsdocType = require("jsdoc/lib/jsdoc/tag/type");
2684
+ const catharsis = require('catharsis');
2685
+ const TYPES = catharsis.Types;
2686
+
2687
+ const toTypeString = (type) => getTypeStrings(type).join("|");
2688
+
2689
+ /*
2690
+ * This function has been copied from jsdoc/lib/jsdoc/tag/type (version 3.6.7)
2691
+ * The copy has been enhanced with the changes from https://github.com/jsdoc/jsdoc/pull/1735
2692
+ * to retain the full function signature for function types.
2693
+ *
2694
+ * JSDoc is copyright (c) 2011-present Michael Mathews micmath@gmail.com and the contributors to JSDoc.
2695
+ */
2696
+ function getTypeStrings(parsedType, isOutermostType) {
2697
+ let applications;
2698
+ let typeString;
2699
+ let types = [];
2700
+ switch (parsedType.type) {
2701
+ case TYPES.AllLiteral:
2702
+ types.push('*');
2703
+ break;
2704
+ case TYPES.FunctionType:
2705
+ typeString = 'function';
2706
+ // #### BEGIN: MODIFIED BY SAP
2707
+ const paramTypes = [];
2708
+ if (parsedType.new) {
2709
+ paramTypes.push(toTypeString(parsedType.new));
2710
+ }
2711
+ if (Array.isArray(parsedType.params)) {
2712
+ paramTypes.push(...parsedType.params.map(toTypeString));
2713
+ }
2714
+ if (paramTypes.length || parsedType.result) {
2715
+ typeString += `(${paramTypes.join(", ")})`;
2716
+ }
2717
+ if (parsedType.result) {
2718
+ typeString += `:${toTypeString(parsedType.result)}`;
2719
+ }
2720
+ types.push(typeString);
2721
+ // #### END: MODIFIED BY SAP
2722
+ break;
2723
+ case TYPES.NameExpression:
2724
+ types.push(parsedType.name);
2725
+ break;
2726
+ case TYPES.NullLiteral:
2727
+ types.push('null');
2728
+ break;
2729
+ case TYPES.RecordType:
2730
+ // #### BEGIN: MODIFIED BY SAP
2731
+ // types.push('Object');
2732
+ if (Array.isArray(parsedType.fields)) {
2733
+ typeString = `{${parsedType.fields.map(
2734
+ ({key,value}) => `${catharsis.stringify(key)}: ${toTypeString(value)}`
2735
+ ).join(', ')}}`;
2736
+ types.push(typeString);
2737
+ } else {
2738
+ types.push('Object');
2739
+ }
2740
+ // #### END: MODIFIED BY SAP
2741
+ break;
2742
+ case TYPES.TypeApplication:
2743
+ // if this is the outermost type, we strip the modifiers; otherwise, we keep them
2744
+ if (isOutermostType) {
2745
+ applications = parsedType.applications.map(application =>
2746
+ catharsis.stringify(application)).join(', ');
2747
+ typeString = `${getTypeStrings(parsedType.expression)[0]}.<${applications}>`;
2748
+ types.push(typeString);
2749
+ }
2750
+ else {
2751
+ types.push( catharsis.stringify(parsedType) );
2752
+ }
2753
+ break;
2754
+ case TYPES.TypeUnion:
2755
+ parsedType.elements.forEach(element => {
2756
+ types = types.concat( getTypeStrings(element) );
2757
+ });
2758
+ break;
2759
+ case TYPES.UndefinedLiteral:
2760
+ types.push('undefined');
2761
+ break;
2762
+ case TYPES.UnknownLiteral:
2763
+ types.push('?');
2764
+ break;
2765
+ default:
2766
+ // this shouldn't happen
2767
+ throw new Error(`unrecognized type ${parsedType.type} in parsed type: ${parsedType}`);
2768
+ }
2769
+ return types;
2770
+ }
2771
+
2772
+ const origParse = jsdocType.parse;
2773
+ jsdocType.parse = function() {
2774
+ const tagInfo = origParse.apply(this, arguments);
2775
+ if ( tagInfo && /function/.test(tagInfo.typeExpression) && tagInfo.parsedType ) {
2776
+ // console.info("old typeExpression", tagInfo.typeExpression);
2777
+ // console.info("old parse tree", tagInfo.parsedType);
2778
+ // console.info("old parse result", tagInfo.type);
2779
+ tagInfo.type = getTypeStrings(tagInfo.parsedType);
2780
+ // console.info("new parse result", tagInfo.type);
2781
+ }
2782
+ return tagInfo;
2783
+ }
2784
+ }());