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

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 (66) hide show
  1. package/CHANGELOG.md +867 -0
  2. package/index.js +0 -43
  3. package/lib/lbt/analyzer/FioriElementsAnalyzer.js +23 -12
  4. package/lib/lbt/analyzer/JSModuleAnalyzer.js +115 -61
  5. package/lib/lbt/analyzer/SmartTemplateAnalyzer.js +23 -12
  6. package/lib/lbt/analyzer/XMLCompositeAnalyzer.js +29 -19
  7. package/lib/lbt/analyzer/XMLTemplateAnalyzer.js +2 -1
  8. package/lib/lbt/analyzer/analyzeLibraryJS.js +15 -0
  9. package/lib/lbt/bundle/Builder.js +365 -138
  10. package/lib/lbt/bundle/BundleWriter.js +17 -0
  11. package/lib/lbt/bundle/Resolver.js +2 -2
  12. package/lib/lbt/calls/SapUiDefine.js +13 -7
  13. package/lib/lbt/resources/LocatorResource.js +7 -7
  14. package/lib/lbt/resources/LocatorResourcePool.js +8 -4
  15. package/lib/lbt/resources/ResourceCollector.js +22 -15
  16. package/lib/lbt/resources/ResourceInfoList.js +0 -1
  17. package/lib/lbt/resources/ResourcePool.js +7 -6
  18. package/lib/lbt/utils/ASTUtils.js +45 -18
  19. package/lib/lbt/utils/escapePropertiesFile.js +3 -6
  20. package/lib/lbt/utils/parseUtils.js +1 -1
  21. package/lib/processors/bundlers/moduleBundler.js +31 -10
  22. package/lib/processors/jsdoc/lib/createIndexFiles.js +1 -1
  23. package/lib/processors/jsdoc/lib/transformApiJson.js +78 -22
  24. package/lib/processors/jsdoc/lib/ui5/plugin.js +414 -122
  25. package/lib/processors/jsdoc/lib/ui5/template/publish.js +112 -91
  26. package/lib/processors/jsdoc/lib/ui5/template/utils/versionUtil.js +1 -1
  27. package/lib/processors/manifestCreator.js +8 -45
  28. package/lib/processors/minifier.js +11 -5
  29. package/lib/tasks/buildThemes.js +1 -1
  30. package/lib/tasks/bundlers/generateBundle.js +70 -30
  31. package/lib/tasks/bundlers/generateComponentPreload.js +26 -19
  32. package/lib/tasks/bundlers/generateFlexChangesBundle.js +10 -5
  33. package/lib/tasks/bundlers/generateLibraryPreload.js +113 -94
  34. package/lib/tasks/bundlers/generateManifestBundle.js +8 -10
  35. package/lib/tasks/bundlers/generateStandaloneAppBundle.js +42 -10
  36. package/lib/tasks/bundlers/utils/createModuleNameMapping.js +31 -0
  37. package/lib/tasks/generateCachebusterInfo.js +7 -3
  38. package/lib/tasks/generateLibraryManifest.js +6 -8
  39. package/lib/tasks/generateResourcesJson.js +3 -3
  40. package/lib/tasks/generateThemeDesignerResources.js +118 -2
  41. package/lib/tasks/generateVersionInfo.js +5 -5
  42. package/lib/tasks/jsdoc/generateJsdoc.js +1 -1
  43. package/lib/tasks/minify.js +14 -4
  44. package/lib/tasks/taskRepository.js +1 -13
  45. package/lib/tasks/transformBootstrapHtml.js +6 -1
  46. package/package.json +13 -11
  47. package/lib/builder/BuildContext.js +0 -56
  48. package/lib/builder/ProjectBuildContext.js +0 -57
  49. package/lib/builder/builder.js +0 -419
  50. package/lib/tasks/TaskUtil.js +0 -160
  51. package/lib/types/AbstractBuilder.js +0 -270
  52. package/lib/types/AbstractFormatter.js +0 -66
  53. package/lib/types/AbstractUi5Formatter.js +0 -95
  54. package/lib/types/application/ApplicationBuilder.js +0 -211
  55. package/lib/types/application/ApplicationFormatter.js +0 -227
  56. package/lib/types/application/applicationType.js +0 -15
  57. package/lib/types/library/LibraryBuilder.js +0 -231
  58. package/lib/types/library/LibraryFormatter.js +0 -519
  59. package/lib/types/library/libraryType.js +0 -15
  60. package/lib/types/module/ModuleBuilder.js +0 -7
  61. package/lib/types/module/ModuleFormatter.js +0 -54
  62. package/lib/types/module/moduleType.js +0 -15
  63. package/lib/types/themeLibrary/ThemeLibraryBuilder.js +0 -63
  64. package/lib/types/themeLibrary/ThemeLibraryFormatter.js +0 -90
  65. package/lib/types/themeLibrary/themeLibraryType.js +0 -15
  66. package/lib/types/typeRepository.js +0 -46
@@ -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
 
@@ -25,6 +25,11 @@ const log = (function() {
25
25
  }
26
26
  }());
27
27
 
28
+ function replaceLastPathSegment(p, replacement) {
29
+ // Note: path.join also correctly normalizes any POSIX paths on Windows
30
+ return path.join(path.dirname(p), replacement);
31
+ }
32
+
28
33
  /*
29
34
  * Transforms the api.json as created by the JSDoc build into a pre-processed api.json file suitable for the SDK.
30
35
  *
@@ -698,7 +703,7 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
698
703
  oMethod.returnValue.types.forEach(oType => {
699
704
 
700
705
  // Link Enabled
701
- if (!isBuiltInType(oType.value)) {
706
+ if (!isBuiltInType(oType.value) && possibleUI5Symbol(oType.value)) {
702
707
  oType.href = "api/" + oType.value.replace("[]", "");
703
708
  oType.linkEnabled = true;
704
709
  }
@@ -981,6 +986,57 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
981
986
  // Normalize path to resolve relative path
982
987
  sPath = path.normalize(sPath);
983
988
 
989
+ const {sources} = options;
990
+ let {librarySrcDir, libraryTestDir} = options;
991
+
992
+ // Using path.join to normalize POSIX paths to Windows paths on Windows
993
+ librarySrcDir = path.join(librarySrcDir);
994
+ libraryTestDir = path.join(libraryTestDir);
995
+
996
+ if (Array.isArray(sources) && typeof librarySrcDir === "string" && typeof libraryTestDir === "string") {
997
+ /**
998
+ * Calculate prefix to check
999
+ *
1000
+ * Example 1:
1001
+ * - sSource: /path/to/project/src
1002
+ * - sLibrarySrcDir: src
1003
+ *
1004
+ * Prefix: /path/to/project/test-resources
1005
+ *
1006
+ * Example 2:
1007
+ * - sSource: /path/to/project/src/main/js
1008
+ * - sLibrarySrcDir: src/main/js
1009
+ *
1010
+ * Prefix: /path/to/project/src/main/test-resources
1011
+ */
1012
+ const librarySrcDirWithTestResources = replaceLastPathSegment(librarySrcDir, "test-resources");
1013
+
1014
+ for (const sourcePath of sources) {
1015
+ /**
1016
+ * Replace prefix with file system path
1017
+ *
1018
+ * Example 1:
1019
+ * - sPath: /path/to/project/test-resources/sap/test/demokit/docuindex.json
1020
+ *
1021
+ * New sPath: /path/to/project/test/sap/test/demokit/docuindex.json
1022
+ *
1023
+ * Example 2:
1024
+ * - sPath: /path/to/project/src/main/test-resources/sap/test/demokit/docuindex.json
1025
+ *
1026
+ * New sPath: /path/to/project/src/main/test/sap/test/demokit/docuindex.json
1027
+ */
1028
+ if (!sourcePath.endsWith(librarySrcDir)) {
1029
+ continue;
1030
+ }
1031
+ const libraryDir = sourcePath.substring(0, sourcePath.lastIndexOf(librarySrcDir) - 1);
1032
+ const prefix = path.join(libraryDir, librarySrcDirWithTestResources);
1033
+ if (sPath.startsWith(prefix)) {
1034
+ sPath = path.join(libraryDir, libraryTestDir, sPath.substring(prefix.length));
1035
+ break;
1036
+ }
1037
+ }
1038
+ }
1039
+
984
1040
  fs.readFile(sPath, 'utf8', (oError, oFileData) => {
985
1041
  if (!oError) {
986
1042
  oFileData = JSON.parse(oFileData);
@@ -991,7 +1047,7 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
991
1047
  });
992
1048
  }
993
1049
  }
994
- // We aways resolve as this data is not mandatory
1050
+ // We always resolve as this data is not mandatory
995
1051
  oResolve(oChainObject);
996
1052
  });
997
1053
 
@@ -1154,7 +1210,7 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
1154
1210
  },
1155
1211
 
1156
1212
  formatMethodCode: function (sName, aParams, aReturnValue) {
1157
- var result = '<pre class="prettyprint">' + sName + '(';
1213
+ var result = '<pre>' + sName + '(';
1158
1214
 
1159
1215
  if (aParams && aParams.length > 0) {
1160
1216
  /* We consider only root level parameters so we get rid of all that are not on the root level */
@@ -1258,7 +1314,7 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
1258
1314
  * @returns string - The code needed to create an object of that class
1259
1315
  */
1260
1316
  formatConstructor: function (name, params) {
1261
- var result = '<pre class="prettyprint">new ';
1317
+ var result = '<pre>new ';
1262
1318
 
1263
1319
  if (name) {
1264
1320
  result += name + '(';
@@ -1386,13 +1442,16 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
1386
1442
 
1387
1443
  },
1388
1444
 
1445
+ formatUrlToLink: function(sTarget, sText, bSAPHosted){
1446
+ return `<a target="_blank" rel="noopener noreferrer" href="${sTarget}">${sText}</a>
1447
+ <img src="./resources/sap/ui/documentation/sdk/images/${bSAPHosted ? 'link-sap' : 'link-external'}.png"
1448
+ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapUISDKExternalLink"/>`;
1449
+ },
1450
+
1389
1451
  handleExternalUrl: function (sTarget, sText) {
1390
1452
  // Check if the external domain is SAP hosted
1391
1453
  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"/>`;
1454
+ return this.formatUrlToLink(sTarget, sText, bSAPHosted);
1396
1455
  },
1397
1456
 
1398
1457
  /**
@@ -1505,8 +1564,7 @@ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapU
1505
1564
  name: oResult.static ? [self.name, oResult.name].join(".") : oResult.name,
1506
1565
  type: "methods",
1507
1566
  className: className,
1508
- text: text,
1509
- local: true
1567
+ text: text
1510
1568
  });
1511
1569
  }
1512
1570
  }
@@ -1546,7 +1604,7 @@ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapU
1546
1604
  * @param {string} [hrefAppend=""]
1547
1605
  * @returns {string} link
1548
1606
  */
1549
- createLink: function ({name, type, className, text=name, local=false, hrefAppend=""}) {
1607
+ createLink: function ({name, type, className, text=name, hrefAppend=""}) {
1550
1608
  let sLink;
1551
1609
 
1552
1610
  // handling module's
@@ -1561,12 +1619,7 @@ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapU
1561
1619
  sLink += hrefAppend;
1562
1620
  }
1563
1621
 
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>`;
1622
+ return `<a target="_self" href="api/${sLink}">${text}</a>`;
1570
1623
  },
1571
1624
 
1572
1625
  /**
@@ -1594,11 +1647,17 @@ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapU
1594
1647
  }
1595
1648
 
1596
1649
  // topic:xxx Topic
1597
- aMatch = sTarget.match(/^topic:(\w{32})$/);
1650
+ aMatch = sTarget.match(/^topic:(\w{32}(?:#\w*)?(?:\/\w*)?)$/);
1598
1651
  if (aMatch) {
1599
1652
  return '<a target="_self" href="topic/' + aMatch[1] + '">' + sText + '</a>';
1600
1653
  }
1601
1654
 
1655
+ // demo:xxx Demo, open the demonstration page in a new window
1656
+ aMatch = sTarget.match(/^demo:([a-zA-Z0-9\/.]*)$/);
1657
+ if (aMatch) {
1658
+ return this.formatUrlToLink("test-resources/" + aMatch[1], sText, true);
1659
+ }
1660
+
1602
1661
  // sap.x.Xxx.prototype.xxx - In case of prototype we have a link to method
1603
1662
  aMatch = sTarget.match(/([a-zA-Z0-9.$_]+?)\.prototype\.([a-zA-Z0-9.$_]+)$/);
1604
1663
  if (aMatch) {
@@ -1656,7 +1715,6 @@ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapU
1656
1715
  name: aMatch[1] ? `${oSelf.name}.${aMatch[2]}` : aMatch[2],
1657
1716
  type: "methods",
1658
1717
  className: oSelf.name,
1659
- local: true,
1660
1718
  text: sText
1661
1719
  });
1662
1720
  }
@@ -1668,7 +1726,6 @@ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapU
1668
1726
  name: aMatch[1],
1669
1727
  type: "annotations",
1670
1728
  className: oSelf.name,
1671
- local: true,
1672
1729
  text: sText
1673
1730
  });
1674
1731
  }
@@ -1695,7 +1752,6 @@ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapU
1695
1752
  name: aMatch[1],
1696
1753
  type: "events",
1697
1754
  className: oSelf.name,
1698
- local: true,
1699
1755
  text: sText
1700
1756
  });
1701
1757
  }