@ui5/builder 3.0.0-alpha.9 → 3.0.0-beta.2

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 (83) hide show
  1. package/.reuse/dep5 +2 -2
  2. package/CHANGELOG.md +59 -1
  3. package/CONTRIBUTING.md +1 -1
  4. package/README.md +4 -4
  5. package/jsdoc.json +2 -2
  6. package/lib/lbt/UI5ClientConstants.js +7 -8
  7. package/lib/lbt/analyzer/ComponentAnalyzer.js +60 -22
  8. package/lib/lbt/analyzer/FioriElementsAnalyzer.js +31 -20
  9. package/lib/lbt/analyzer/JSModuleAnalyzer.js +119 -77
  10. package/lib/lbt/analyzer/SmartTemplateAnalyzer.js +31 -20
  11. package/lib/lbt/analyzer/XMLCompositeAnalyzer.js +35 -25
  12. package/lib/lbt/analyzer/XMLTemplateAnalyzer.js +71 -18
  13. package/lib/lbt/analyzer/analyzeLibraryJS.js +22 -6
  14. package/lib/lbt/bundle/AutoSplitter.js +10 -11
  15. package/lib/lbt/bundle/Builder.js +33 -36
  16. package/lib/lbt/bundle/BundleDefinition.js +1 -5
  17. package/lib/lbt/bundle/BundleWriter.js +1 -2
  18. package/lib/lbt/bundle/ResolvedBundleDefinition.js +6 -7
  19. package/lib/lbt/bundle/Resolver.js +11 -12
  20. package/lib/lbt/calls/SapUiDefine.js +16 -11
  21. package/lib/lbt/graph/dependencyGraph.js +3 -4
  22. package/lib/lbt/graph/dominatorTree.js +3 -3
  23. package/lib/lbt/graph/topologicalSort.js +3 -3
  24. package/lib/lbt/resources/LibraryFileAnalyzer.js +6 -9
  25. package/lib/lbt/resources/LocatorResource.js +2 -2
  26. package/lib/lbt/resources/LocatorResourcePool.js +3 -3
  27. package/lib/lbt/resources/ModuleInfo.js +2 -3
  28. package/lib/lbt/resources/Resource.js +3 -4
  29. package/lib/lbt/resources/ResourceCollector.js +8 -9
  30. package/lib/lbt/resources/ResourceFilterList.js +38 -40
  31. package/lib/lbt/resources/ResourceInfo.js +1 -1
  32. package/lib/lbt/resources/ResourceInfoList.js +5 -3
  33. package/lib/lbt/resources/ResourcePool.js +15 -21
  34. package/lib/lbt/utils/ASTUtils.js +60 -44
  35. package/lib/lbt/utils/JSTokenizer.js +4 -4
  36. package/lib/lbt/utils/ModuleName.js +10 -20
  37. package/lib/lbt/utils/escapePropertiesFile.js +4 -4
  38. package/lib/lbt/utils/parseUtils.js +5 -11
  39. package/lib/processors/bootstrapHtmlTransformer.js +15 -7
  40. package/lib/processors/bundlers/flexChangesBundler.js +16 -8
  41. package/lib/processors/bundlers/moduleBundler.js +26 -15
  42. package/lib/processors/jsdoc/apiIndexGenerator.js +16 -9
  43. package/lib/processors/jsdoc/jsdocGenerator.js +37 -25
  44. package/lib/processors/jsdoc/lib/{createIndexFiles.js → createIndexFiles.cjs} +0 -0
  45. package/lib/processors/jsdoc/lib/{transformApiJson.js → transformApiJson.cjs} +59 -2
  46. package/lib/processors/jsdoc/lib/ui5/{plugin.js → plugin.cjs} +310 -119
  47. package/lib/processors/jsdoc/lib/ui5/template/{publish.js → publish.cjs} +6 -2
  48. package/lib/processors/jsdoc/lib/ui5/template/utils/{versionUtil.js → versionUtil.cjs} +0 -0
  49. package/lib/processors/jsdoc/sdkTransformer.js +18 -11
  50. package/lib/processors/libraryLessGenerator.js +28 -16
  51. package/lib/processors/manifestCreator.js +15 -14
  52. package/lib/processors/minifier.js +22 -16
  53. package/lib/processors/nonAsciiEscaper.js +17 -7
  54. package/lib/processors/resourceListCreator.js +13 -13
  55. package/lib/processors/stringReplacer.js +13 -6
  56. package/lib/processors/themeBuilder.js +33 -24
  57. package/lib/processors/versionInfoGenerator.js +40 -30
  58. package/lib/tasks/buildThemes.js +18 -11
  59. package/lib/tasks/bundlers/generateBundle.js +23 -12
  60. package/lib/tasks/bundlers/generateComponentPreload.js +23 -12
  61. package/lib/tasks/bundlers/generateFlexChangesBundle.js +16 -8
  62. package/lib/tasks/bundlers/generateLibraryPreload.js +33 -17
  63. package/lib/tasks/bundlers/generateStandaloneAppBundle.js +21 -13
  64. package/lib/tasks/bundlers/utils/createModuleNameMapping.js +7 -7
  65. package/lib/tasks/escapeNonAsciiCharacters.js +12 -5
  66. package/lib/tasks/generateCachebusterInfo.js +17 -9
  67. package/lib/tasks/generateLibraryManifest.js +14 -8
  68. package/lib/tasks/generateResourcesJson.js +15 -9
  69. package/lib/tasks/generateThemeDesignerResources.js +19 -9
  70. package/lib/tasks/generateVersionInfo.js +12 -5
  71. package/lib/tasks/jsdoc/executeJsdocSdkTransformation.js +17 -9
  72. package/lib/tasks/jsdoc/generateApiIndex.js +16 -10
  73. package/lib/tasks/jsdoc/generateJsdoc.js +131 -119
  74. package/lib/tasks/minify.js +13 -6
  75. package/lib/tasks/replaceBuildtime.js +12 -5
  76. package/lib/tasks/replaceCopyright.js +12 -5
  77. package/lib/tasks/replaceVersion.js +12 -5
  78. package/lib/tasks/taskRepository.js +24 -30
  79. package/lib/tasks/transformBootstrapHtml.js +6 -5
  80. package/package.json +44 -31
  81. package/index.js +0 -173
  82. package/lib/processors/bundlers/manifestBundler.js +0 -172
  83. package/lib/tasks/bundlers/generateManifestBundle.js +0 -49
@@ -1,6 +1,6 @@
1
- "use strict";
2
1
 
3
- const log = require("@ui5/logger").getLogger("lbt:graph:topologicalSort");
2
+ import logger from "@ui5/logger";
3
+ const log = logger.getLogger("lbt:graph:topologicalSort");
4
4
 
5
5
  /**
6
6
  * Represents a module and its dependencies in a dependency graph.
@@ -186,4 +186,4 @@ function topologicalSort(pool, moduleNames) {
186
186
  });
187
187
  }
188
188
 
189
- module.exports = topologicalSort;
189
+ export default topologicalSort;
@@ -1,11 +1,10 @@
1
1
  /**
2
- * Used by the ResourcePool to read raw module info as stored in the .liubrary files.
2
+ * Used by the ResourcePool to read raw module info as stored in the .library files.
3
3
  * It does not (yet) analyze dependencies of the library and therefore isn't part of the analyzer package (yet).
4
4
  */
5
- "use strict";
6
-
7
- const xml2js = require("xml2js");
8
- const log = require("@ui5/logger").getLogger("lbt:resources:LibraryFileAnalyzer");
5
+ import xml2js from "xml2js";
6
+ import logger from "@ui5/logger";
7
+ const log = logger.getLogger("lbt:resources:LibraryFileAnalyzer");
9
8
 
10
9
  const parser = new xml2js.Parser({
11
10
  // explicitChildren: true,
@@ -49,8 +48,8 @@ function createRawInfo(rawModule) {
49
48
  }
50
49
  }
51
50
 
52
- function getDependencyInfos( name, content ) {
53
- const infos = {};
51
+ export function getDependencyInfos( name, content ) {
52
+ const infos = Object.create(null);
54
53
  parser.parseString(content, (err, result) => {
55
54
  if ( result &&
56
55
  result.library &&
@@ -77,5 +76,3 @@ function getDependencyInfos( name, content ) {
77
76
  // console.log("done", infos);
78
77
  return infos;
79
78
  }
80
-
81
- module.exports.getDependencyInfos = getDependencyInfos;
@@ -1,4 +1,4 @@
1
- const Resource = require("./Resource");
1
+ import Resource from "./Resource.js";
2
2
 
3
3
  class LocatorResource extends Resource {
4
4
  constructor(pool, resource, moduleName) {
@@ -19,4 +19,4 @@ class LocatorResource extends Resource {
19
19
  }
20
20
  }
21
21
 
22
- module.exports = LocatorResource;
22
+ export default LocatorResource;
@@ -1,5 +1,5 @@
1
- const ResourcePool = require("./ResourcePool");
2
- const LocatorResource = require("./LocatorResource");
1
+ import ResourcePool from "./ResourcePool.js";
2
+ import LocatorResource from "./LocatorResource.js";
3
3
 
4
4
  class LocatorResourcePool extends ResourcePool {
5
5
  prepare(resources, moduleNameMapping) {
@@ -16,4 +16,4 @@ class LocatorResourcePool extends ResourcePool {
16
16
  }
17
17
  }
18
18
 
19
- module.exports = LocatorResourcePool;
19
+ export default LocatorResourcePool;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
 
3
2
  /**
4
3
  * A strict dependency always has to be fulfilled and is declared as part of the module's definition.
@@ -40,7 +39,7 @@ class ModuleInfo {
40
39
  constructor(name) {
41
40
  this._name = name;
42
41
  this.subModules = [];
43
- this._dependencies = {};
42
+ this._dependencies = Object.create(null);
44
43
  this.dynamicDependencies = false;
45
44
 
46
45
  /**
@@ -250,4 +249,4 @@ public class ModuleInfo {
250
249
 
251
250
  } */
252
251
 
253
- module.exports = ModuleInfo;
252
+ export default ModuleInfo;
@@ -1,7 +1,6 @@
1
- "use strict";
2
1
 
3
- const {promisify} = require("util");
4
- const fs = require("graceful-fs");
2
+ import {promisify} from "node:util";
3
+ import fs from "graceful-fs";
5
4
  const readFile = promisify(fs.readFile);
6
5
 
7
6
  class Resource {
@@ -27,4 +26,4 @@ class Resource {
27
26
  }
28
27
  }
29
28
 
30
- module.exports = Resource;
29
+ export default Resource;
@@ -1,13 +1,12 @@
1
- const ResourceInfoList = require("./ResourceInfoList");
2
- const ResourceFilterList = require("./ResourceFilterList");
3
- const ResourceInfo = require("./ResourceInfo");
4
-
1
+ import ResourceInfoList from "./ResourceInfoList.js";
2
+ import ResourceFilterList from "./ResourceFilterList.js";
3
+ import ResourceInfo from "./ResourceInfo.js";
4
+ import logger from "@ui5/logger";
5
+ const log = logger.getLogger("lbt:resources:ResourceCollector");
5
6
 
6
7
  const LOCALE = /^((?:[^/]+\/)*[^/]+?)_([A-Z]{2}(?:_[A-Z]{2}(?:_[A-Z0-9_]+)?)?)(\.properties|\.hdbtextbundle)$/i;
7
8
  const THEME = /^((?:[^/]+\/)*)themes\/([^/]+)\//;
8
9
 
9
- const log = require("@ui5/logger").getLogger("lbt:resources:ResourceCollector");
10
-
11
10
  /**
12
11
  * Collects all resources in a set of resource folders or from an archive
13
12
  * and writes a 'resources.json' file for each component or library
@@ -67,7 +66,7 @@ class ResourceCollector {
67
66
  *
68
67
  * If no component is given, orphans will only be reported but not added to any component (default).
69
68
  *
70
- * @param {object<string, string[]>} list component to list of components
69
+ * @param {Object<string, string[]>} list component to list of components
71
70
  */
72
71
  setExternalResources(list) {
73
72
  this._externalResources = list;
@@ -76,7 +75,7 @@ class ResourceCollector {
76
75
  /**
77
76
  * Processes a resource
78
77
  *
79
- * @param {module:@ui5/fs.Resource} resource
78
+ * @param {@ui5/fs/Resource} resource
80
79
  */
81
80
  async visitResource(resource) {
82
81
  const virPath = resource.getPath();
@@ -400,4 +399,4 @@ class ResourceCollector {
400
399
  }
401
400
  }
402
401
 
403
- module.exports = ResourceCollector;
402
+ export default ResourceCollector;
@@ -1,6 +1,6 @@
1
- "use strict";
2
1
 
3
- const log = require("@ui5/logger").getLogger("lbt:resources:ResourceFilterList");
2
+ import logger from "@ui5/logger";
3
+ const log = logger.getLogger("lbt:resources:ResourceFilterList");
4
4
 
5
5
  const FILTER_PREFIXES = /^[-!+]/;
6
6
 
@@ -95,7 +95,7 @@ function makeMatcher(globPattern, fileTypesPattern) {
95
95
  * @since 1.16.2
96
96
  * @private
97
97
  */
98
- class ResourceFilterList {
98
+ export default class ResourceFilterList {
99
99
  constructor(filters, fileTypes) {
100
100
  this.matchers = [];
101
101
  this.matchByDefault = true;
@@ -127,43 +127,43 @@ class ResourceFilterList {
127
127
  toString() {
128
128
  return this.matchers.map((matcher) => matcher.pattern).join(",");
129
129
  }
130
- }
131
130
 
132
- /**
133
- * Each filter entry can be a comma separated list of simple filters. Each simple filter
134
- * can be a pattern in resource name pattern syntax: A double asterisk '&0x2a;&0x2a;/' denotes an arbitrary
135
- * number of resource name segments (folders) incl. a trailing slash, whereas a simple asterisk '*'
136
- * denotes an arbitrary number of resource name characters, but not the segment separator '/'.
137
- * A dot is interpreted as a dot, all other special regular expression characters keep their
138
- * special meaning. This is a mixture of ANT-style path patterns and regular expressions.
139
- *
140
- * Excludes can be denoted by a leading '-' or '!', includes optionally by a leading '+'.
141
- * Order of filters is significant, a later exclusion overrides an earlier inclusion
142
- * and vice versa.
143
- *
144
- * Example:
145
- * <pre>
146
- * !sap/ui/core/
147
- * +sap/ui/core/utils/
148
- * </pre>
149
- * excludes everything from sap/ui/core, but includes everything from the subpackage sap/ui/core/utils/.
150
- *
151
- * Note that the filter operates on the full name of each resource. If a resource name
152
- * <code>prefix</code> is configured for a resource set, the filter will be applied
153
- * to the combination of prefix and local file path and not only to the local file path.
154
- *
155
- * @param {string} filterStr comma separated list of simple filters
156
- * @returns {ResourceFilterList}
157
- */
158
- ResourceFilterList.fromString = function(filterStr) {
159
- const result = new ResourceFilterList();
160
- if ( filterStr != null ) {
161
- result.addFilters( filterStr.trim().split(/\s*,\s*/).filter(Boolean) );
131
+ /**
132
+ * Each filter entry can be a comma separated list of simple filters. Each simple filter
133
+ * can be a pattern in resource name pattern syntax: A double asterisk '&0x2a;&0x2a;/' denotes an arbitrary
134
+ * number of resource name segments (folders) incl. a trailing slash, whereas a simple asterisk '*'
135
+ * denotes an arbitrary number of resource name characters, but not the segment separator '/'.
136
+ * A dot is interpreted as a dot, all other special regular expression characters keep their
137
+ * special meaning. This is a mixture of ANT-style path patterns and regular expressions.
138
+ *
139
+ * Excludes can be denoted by a leading '-' or '!', includes optionally by a leading '+'.
140
+ * Order of filters is significant, a later exclusion overrides an earlier inclusion
141
+ * and vice versa.
142
+ *
143
+ * Example:
144
+ * <pre>
145
+ * !sap/ui/core/
146
+ * +sap/ui/core/utils/
147
+ * </pre>
148
+ * excludes everything from sap/ui/core, but includes everything from the subpackage sap/ui/core/utils/.
149
+ *
150
+ * Note that the filter operates on the full name of each resource. If a resource name
151
+ * <code>prefix</code> is configured for a resource set, the filter will be applied
152
+ * to the combination of prefix and local file path and not only to the local file path.
153
+ *
154
+ * @param {string} filterStr comma separated list of simple filters
155
+ * @returns {ResourceFilterList}
156
+ */
157
+ static fromString(filterStr) {
158
+ const result = new ResourceFilterList();
159
+ if ( filterStr != null ) {
160
+ result.addFilters( filterStr.trim().split(/\s*,\s*/).filter(Boolean) );
161
+ }
162
+ return result;
162
163
  }
163
- return result;
164
- };
164
+ }
165
165
 
166
- ResourceFilterList.negateFilters = function(patterns) {
166
+ export function negateFilters(patterns) {
167
167
  return patterns.map((pattern) => {
168
168
  let include = true;
169
169
 
@@ -181,6 +181,4 @@ ResourceFilterList.negateFilters = function(patterns) {
181
181
  return "+" + pattern;
182
182
  }
183
183
  });
184
- };
185
-
186
- module.exports = ResourceFilterList;
184
+ }
@@ -177,4 +177,4 @@ class ResourceInfo {
177
177
  }
178
178
  }
179
179
 
180
- module.exports = ResourceInfo;
180
+ export default ResourceInfo;
@@ -1,4 +1,4 @@
1
- const ResourceInfo = require("./ResourceInfo");
1
+ import ResourceInfo from "./ResourceInfo.js";
2
2
 
3
3
  const DEBUG_RESOURCES_PATTERN = /-dbg((?:\.view|\.fragment|\.controller|\.designtime|\.support)?\.js|\.css)$/;
4
4
 
@@ -24,7 +24,9 @@ class ResourceInfoList {
24
24
 
25
25
  // --- transient state ---
26
26
  /**
27
- * @type {string} name of the resource
27
+ * The name of the resource
28
+ *
29
+ * @type {string}
28
30
  */
29
31
  this.name = prefix;
30
32
  /**
@@ -114,4 +116,4 @@ class ResourceInfoList {
114
116
  }
115
117
  }
116
118
 
117
- module.exports = ResourceInfoList;
119
+ export default ResourceInfoList;
@@ -1,24 +1,18 @@
1
- "use strict";
2
-
3
- /*
4
- const fs = require("fs");
5
- const path = require("path");
6
- */
7
- const {parseJS} = require("../utils/parseUtils");
8
- const ComponentAnalyzer = require("../analyzer/ComponentAnalyzer");
9
- const SmartTemplateAnalyzer = require("../analyzer/SmartTemplateAnalyzer");
10
- const FioriElementsAnalyzer = require("../analyzer/FioriElementsAnalyzer");
11
- const XMLCompositeAnalyzer = require("../analyzer/XMLCompositeAnalyzer");
12
- const JSModuleAnalyzer = require("../analyzer/JSModuleAnalyzer");
13
- const XMLTemplateAnalyzer = require("../analyzer/XMLTemplateAnalyzer");
14
-
15
- const LibraryFileAnalyzer = require("./LibraryFileAnalyzer");
16
- const ModuleInfo = require("./ModuleInfo");
17
- const ResourceFilterList = require("./ResourceFilterList");
1
+ import {parseJS} from "../utils/parseUtils.js";
2
+ import ComponentAnalyzer from "../analyzer/ComponentAnalyzer.js";
3
+ import SmartTemplateAnalyzer from "../analyzer/SmartTemplateAnalyzer.js";
4
+ import FioriElementsAnalyzer from "../analyzer/FioriElementsAnalyzer.js";
5
+ import XMLCompositeAnalyzer from "../analyzer/XMLCompositeAnalyzer.js";
6
+ import JSModuleAnalyzer from "../analyzer/JSModuleAnalyzer.js";
7
+ import XMLTemplateAnalyzer from "../analyzer/XMLTemplateAnalyzer.js";
8
+ import {getDependencyInfos} from "./LibraryFileAnalyzer.js";
9
+ import ModuleInfo from "./ModuleInfo.js";
10
+ import ResourceFilterList from "./ResourceFilterList.js";
11
+ import logger from "@ui5/logger";
12
+ const log = logger.getLogger("lbt:resources:ResourcePool");
18
13
  /*
19
- const Resource = require("./Resource");
14
+ import Resource from "./Resource";
20
15
  */
21
- const log = require("@ui5/logger").getLogger("lbt:resources:ResourcePool");
22
16
 
23
17
  const jsAnalyzer = new JSModuleAnalyzer();
24
18
 
@@ -165,7 +159,7 @@ class ResourcePool {
165
159
  if ( /\.library$/.test(resource.name) ) {
166
160
  // read raw-module info from .library files
167
161
  return resource.buffer().then( (buffer) => {
168
- const infos = LibraryFileAnalyzer.getDependencyInfos( resource.name, buffer );
162
+ const infos = getDependencyInfos( resource.name, buffer );
169
163
  for ( const name of Object.keys(infos) ) {
170
164
  this._rawModuleInfos.set(name, infos[name]);
171
165
  }
@@ -238,5 +232,5 @@ class ResourcePool {
238
232
  }
239
233
  }
240
234
 
241
- module.exports = ResourcePool;
235
+ export default ResourcePool;
242
236
 
@@ -1,6 +1,5 @@
1
- "use strict";
2
1
 
3
- const {Syntax} = require("../utils/parseUtils");
2
+ import {Syntax} from "../utils/parseUtils.js";
4
3
 
5
4
  /**
6
5
  * Checks whether the given node is a string literal.
@@ -12,21 +11,42 @@ const {Syntax} = require("../utils/parseUtils");
12
11
  * @param {string} [literal]
13
12
  * @returns {boolean} Whether the node is a literal and whether its value matches the given string
14
13
  */
15
- function isString(node, literal) {
16
- if ( node == null || node.type !== Syntax.Literal || typeof node.value !== "string" ) {
14
+ export function isString(node, literal) {
15
+ const value = getStringValue(node);
16
+ if (value === undefined) {
17
17
  return false;
18
18
  }
19
- return literal == null ? true : node.value === literal;
19
+ return literal == null ? true: value === literal;
20
+ }
21
+
22
+ export function getStringValue(node) {
23
+ if (isLiteral(node)) {
24
+ return node.value;
25
+ } else if (isTemplateLiteralWithoutExpression(node)) {
26
+ return node?.quasis?.[0]?.value?.cooked;
27
+ } else {
28
+ return undefined;
29
+ }
30
+ }
31
+
32
+ export function isLiteral(node) {
33
+ return node && node.type === Syntax.Literal && typeof node.value === "string";
34
+ }
35
+
36
+ export function isTemplateLiteralWithoutExpression(node) {
37
+ return node?.type === Syntax.TemplateLiteral &&
38
+ node?.expressions?.length === 0 &&
39
+ node?.quasis?.length === 1;
20
40
  }
21
41
 
22
- function isBoolean(node, literal) {
42
+ export function isBoolean(node, literal) {
23
43
  if ( node == null || node.type !== Syntax.Literal || typeof node.value !== "boolean" ) {
24
44
  return false;
25
45
  }
26
46
  return literal == null ? true : node.value === literal;
27
47
  }
28
48
 
29
- function isMethodCall(node, methodPath) {
49
+ export function isMethodCall(node, methodPath) {
30
50
  if ( node.type !== Syntax.CallExpression ) {
31
51
  return false;
32
52
  }
@@ -35,7 +55,9 @@ function isMethodCall(node, methodPath) {
35
55
  return isNamedObject(node.callee, methodPath, methodPath.length);
36
56
  }
37
57
 
38
- function isNamedObject(node, objectPath, length) {
58
+ export function isNamedObject(node, objectPath, length) {
59
+ // TODO: Support PrivateIdentifier (foo.#bar)
60
+
39
61
  // console.log("checking for named object ", node, objectPath, length);
40
62
  while ( length > 1 &&
41
63
  node.type === Syntax.MemberExpression &&
@@ -46,37 +68,37 @@ function isNamedObject(node, objectPath, length) {
46
68
  return length === 1 && isIdentifier(node, objectPath[0]);
47
69
  }
48
70
 
49
- function isIdentifier(node, name) {
50
- if ( node.type != Syntax.Identifier ) {
51
- return false;
52
- }
53
- if ( typeof name == "string" ) {
71
+ export function isIdentifier(node, name) {
72
+ if ( node.type === Syntax.Identifier && typeof name == "string" ) {
54
73
  return name === node.name;
74
+ } else if ( node.type === Syntax.Identifier && Array.isArray(name) ) {
75
+ return name.find((name) => name === node.name || name === "*") !== undefined;
76
+ } else if ( node.type === Syntax.ObjectPattern ) {
77
+ return node.properties.filter((childnode) => isIdentifier(childnode.key, name)).length > 0;
78
+ } else if ( node.type === Syntax.ArrayPattern ) {
79
+ return node.elements.filter((childnode) => isIdentifier(childnode, name)).length > 0;
80
+ } else {
81
+ return false;
55
82
  }
56
- for (let i = 0; i < name.length; i++) {
57
- if ( name[i] === node.name || name[i] === "*" ) {
58
- return true;
59
- }
60
- }
61
- return false;
62
83
  }
63
84
 
64
- function getPropertyKey(property) {
65
- if ( property.key.type === Syntax.Identifier ) {
85
+ export function getPropertyKey(property) {
86
+ if ( property.type === Syntax.SpreadElement ) {
87
+ // TODO: Support interpreting SpreadElements
88
+ return;
89
+ } else if ( property.key.type === Syntax.Identifier && property.computed !== true ) {
66
90
  return property.key.name;
67
91
  } else if ( property.key.type === Syntax.Literal ) {
68
92
  return String(property.key.value);
69
- } else {
70
- throw new Error();
71
93
  }
72
94
  }
73
95
 
74
- function findOwnProperty(obj, name) {
96
+ export function findOwnProperty(obj, name) {
75
97
  const property = obj && obj.properties.find((property) => getPropertyKey(property) === name);
76
98
  return property && property.value;
77
99
  }
78
100
 
79
- function getValue(obj, names) {
101
+ export function getValue(obj, names) {
80
102
  let i = 0;
81
103
  while ( i < names.length ) {
82
104
  if ( obj == null || obj.type !== Syntax.ObjectExpression ) {
@@ -100,29 +122,23 @@ function getValue(obj, names) {
100
122
  * @throws {TypeError}
101
123
  * @returns {string[]}
102
124
  */
103
- function getStringArray(array, skipNonStringLiterals) {
125
+ export function getStringArray(array, skipNonStringLiterals) {
104
126
  return array.elements.reduce( (result, item) => {
105
- if ( isString(item) ) {
106
- result.push(item.value);
127
+ const value = getStringValue(item);
128
+ if ( value !== undefined ) {
129
+ result.push(value);
107
130
  } else if ( !skipNonStringLiterals ) {
108
- throw new TypeError("array element is not a string literal:" + item.type);
131
+ if (item.type === Syntax.TemplateLiteral) {
132
+ throw new TypeError("array element is a template literal with expressions");
133
+ } else {
134
+ throw new TypeError("array element is not a string literal: " + item.type);
135
+ }
109
136
  }
110
137
  return result;
111
138
  }, []);
112
139
  }
113
140
 
114
- module.exports = {
115
- isString,
116
- isBoolean,
117
- isMethodCall,
118
- isNamedObject,
119
- isIdentifier,
120
- getLocation: function(args) {
121
- // NODE-TODO include line information in future
122
- return args[0].value;
123
- },
124
- getPropertyKey,
125
- findOwnProperty,
126
- getValue,
127
- getStringArray
128
- };
141
+ export function getLocation(args) {
142
+ // NODE-TODO include line information in future
143
+ return args[0].value;
144
+ }
@@ -13,7 +13,7 @@
13
13
  * Code other than the OpenUI5 libraries must not introduce dependencies to this module.
14
14
  */
15
15
  //sap.ui.define([], function() {
16
- "use strict";
16
+ //"use strict";
17
17
 
18
18
  /*
19
19
  * The following code has been taken from the component JSON in JavaScript
@@ -25,7 +25,7 @@
25
25
  */
26
26
 
27
27
  /**
28
- * @class Tokenizer for JS values.
28
+ * Tokenizer for JS values.
29
29
  *
30
30
  * Contains functions to consume tokens on an input string.
31
31
  *
@@ -34,7 +34,7 @@
34
34
  * JSTokenizer().parseJS("{test:'123'}"); // {test:'123'}
35
35
  * });
36
36
  *
37
- * @alias module:sap/base/util/JSTokenizer
37
+ * @class sap/base/util/JSTokenizer
38
38
  * @since 1.58
39
39
  * @private
40
40
  * @ui5-restricted sap.ui.core
@@ -384,4 +384,4 @@
384
384
  // return JSTokenizer;
385
385
  //});
386
386
 
387
- module.exports = JSTokenizer;
387
+ export default JSTokenizer;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
 
3
2
  /**
4
3
  * Creates a ModuleName from a string in UI5 module name syntax.
@@ -8,7 +7,7 @@
8
7
  * @param {string} [suffix='.js'] Suffix to add to the resulting resource name
9
8
  * @returns {string} URN representing the same resource
10
9
  */
11
- function fromUI5LegacyName(name, suffix) {
10
+ export function fromUI5LegacyName(name, suffix) {
12
11
  // UI5 only supports a few names with dots in them, anything else will be converted to slashes
13
12
  if ( name.startsWith("sap.ui.thirdparty.jquery.jquery-") ) {
14
13
  name = "sap/ui/thirdparty/jquery/jquery-" + name.slice("sap.ui.thirdparty.jquery.jquery-".length);
@@ -20,7 +19,7 @@ function fromUI5LegacyName(name, suffix) {
20
19
  return name + (suffix || ".js");
21
20
  }
22
21
 
23
- function toUI5LegacyName(path) {
22
+ export function toUI5LegacyName(path) {
24
23
  if ( !path.endsWith(".js") ) {
25
24
  throw new Error("can't convert a non-JS resource name " + path + " to a UI5 module name");
26
25
  }
@@ -34,11 +33,11 @@ function toUI5LegacyName(path) {
34
33
  }
35
34
  }
36
35
 
37
- function fromRequireJSName(name) {
36
+ export function fromRequireJSName(name) {
38
37
  return name + ".js";
39
38
  }
40
39
 
41
- function toRequireJSName(path) {
40
+ export function toRequireJSName(path) {
42
41
  if ( !path.endsWith(".js") ) {
43
42
  throw new Error("can't convert a non-JS resource name " + path + " to a requireJS module name");
44
43
  }
@@ -47,7 +46,7 @@ function toRequireJSName(path) {
47
46
 
48
47
  const KNOWN_TYPES = /\.(properties|css|(?:(?:view\.|fragment\.)?(?:html|json|xml|js))|(?:(?:controller\.|designtime\.|support\.)?js))$/;
49
48
 
50
- function getDebugName(name) {
49
+ export function getDebugName(name) {
51
50
  const m = KNOWN_TYPES.exec(name);
52
51
  if ( m && ( m[0].endsWith(".css") || m[0].endsWith(".js") ) && !name.slice(0, m.index).endsWith("-dbg") ) {
53
52
  return name.slice(0, m.index) + "-dbg" + m[0];
@@ -55,7 +54,7 @@ function getDebugName(name) {
55
54
  return null;
56
55
  }
57
56
 
58
- function getNonDebugName(name) {
57
+ export function getNonDebugName(name) {
59
58
  const m = KNOWN_TYPES.exec(name);
60
59
  if ( m && ( m[0].endsWith(".css") || m[0].endsWith(".js") ) && name.slice(0, m.index).endsWith("-dbg") ) {
61
60
  return name.slice(0, m.index - "-dbg".length) + m[0];
@@ -66,7 +65,7 @@ function getNonDebugName(name) {
66
65
  const ANY_SPECIAL_PATH_SEGMENT = /(?:^|\/)\.+\//;
67
66
  const SPECIAL_PATH_SEGMENT = /^\.+$/;
68
67
 
69
- function resolveRelativePath(path, relativePath) {
68
+ export function resolveRelativePath(path, relativePath) {
70
69
  // while has segment
71
70
  // if ( segment == . )
72
71
  // ignore segment
@@ -117,16 +116,7 @@ function resolveRelativePath(path, relativePath) {
117
116
  return relativePath;
118
117
  }
119
118
 
120
- module.exports = {
121
- getDebugName,
122
- getNonDebugName,
123
- fromUI5LegacyName,
124
- fromRequireJSName,
125
- resolveRelativePath,
126
- resolveRelativeRequireJSName: function(path, relativeName) {
127
- return resolveRelativePath(path, relativeName + ".js");
128
- },
129
- toUI5LegacyName,
130
- toRequireJSName
131
- };
119
+ export function resolveRelativeRequireJSName(path, relativeName) {
120
+ return resolveRelativePath(path, relativeName + ".js");
121
+ }
132
122
 
@@ -1,4 +1,4 @@
1
- const nonAsciiEscaper = require("../../processors/nonAsciiEscaper");
1
+ import nonAsciiEscaper from "../../processors/nonAsciiEscaper.js";
2
2
 
3
3
  /**
4
4
  * Can be used to escape *.properties files.
@@ -10,12 +10,12 @@ const nonAsciiEscaper = require("../../processors/nonAsciiEscaper");
10
10
  * @param {Resource} resource the resource for which the content will be escaped
11
11
  * @returns {Promise<string>} resolves with the escaped string content of the given Resource
12
12
  */
13
- module.exports = async function(resource) {
13
+ export default async function(resource) {
14
14
  const project = resource.getProject();
15
15
  let propertiesFileSourceEncoding = project && project.getPropertiesFileSourceEncoding();
16
16
 
17
17
  if (!propertiesFileSourceEncoding) {
18
- if (project && ["0.1", "1.0", "1.1"].includes(project.getSpecVersion())) {
18
+ if (project && project.getSpecVersion().lte("1.1")) {
19
19
  // default encoding to "ISO-8859-1" for old specVersions
20
20
  propertiesFileSourceEncoding = "ISO-8859-1";
21
21
  } else {
@@ -34,4 +34,4 @@ module.exports = async function(resource) {
34
34
  const fileContent = await resource.buffer();
35
35
 
36
36
  return fileContent.toString();
37
- };
37
+ }