@ui5/builder 3.0.0-alpha.10 → 3.0.0-alpha.12
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/CHANGELOG.md +35 -2
- package/jsdoc.json +2 -2
- package/lib/lbt/UI5ClientConstants.js +7 -8
- package/lib/lbt/analyzer/ComponentAnalyzer.js +10 -10
- package/lib/lbt/analyzer/FioriElementsAnalyzer.js +31 -20
- package/lib/lbt/analyzer/JSModuleAnalyzer.js +107 -65
- package/lib/lbt/analyzer/SmartTemplateAnalyzer.js +31 -20
- package/lib/lbt/analyzer/XMLCompositeAnalyzer.js +35 -25
- package/lib/lbt/analyzer/XMLTemplateAnalyzer.js +19 -17
- package/lib/lbt/analyzer/analyzeLibraryJS.js +22 -6
- package/lib/lbt/bundle/AutoSplitter.js +10 -11
- package/lib/lbt/bundle/Builder.js +30 -33
- package/lib/lbt/bundle/BundleDefinition.js +1 -5
- package/lib/lbt/bundle/BundleWriter.js +1 -2
- package/lib/lbt/bundle/ResolvedBundleDefinition.js +6 -7
- package/lib/lbt/bundle/Resolver.js +9 -10
- package/lib/lbt/calls/SapUiDefine.js +16 -11
- package/lib/lbt/graph/dependencyGraph.js +3 -4
- package/lib/lbt/graph/dominatorTree.js +3 -3
- package/lib/lbt/graph/topologicalSort.js +3 -3
- package/lib/lbt/resources/LibraryFileAnalyzer.js +5 -8
- package/lib/lbt/resources/LocatorResource.js +2 -2
- package/lib/lbt/resources/LocatorResourcePool.js +3 -3
- package/lib/lbt/resources/ModuleInfo.js +1 -2
- package/lib/lbt/resources/Resource.js +3 -4
- package/lib/lbt/resources/ResourceCollector.js +7 -8
- package/lib/lbt/resources/ResourceFilterList.js +38 -40
- package/lib/lbt/resources/ResourceInfo.js +1 -1
- package/lib/lbt/resources/ResourceInfoList.js +2 -2
- package/lib/lbt/resources/ResourcePool.js +15 -21
- package/lib/lbt/utils/ASTUtils.js +58 -44
- package/lib/lbt/utils/JSTokenizer.js +4 -4
- package/lib/lbt/utils/ModuleName.js +10 -20
- package/lib/lbt/utils/escapePropertiesFile.js +3 -3
- package/lib/lbt/utils/parseUtils.js +4 -10
- package/lib/processors/bootstrapHtmlTransformer.js +15 -7
- package/lib/processors/bundlers/flexChangesBundler.js +16 -8
- package/lib/processors/bundlers/manifestBundler.js +19 -10
- package/lib/processors/bundlers/moduleBundler.js +26 -15
- package/lib/processors/jsdoc/apiIndexGenerator.js +16 -9
- package/lib/processors/jsdoc/jsdocGenerator.js +31 -17
- package/lib/processors/jsdoc/lib/{createIndexFiles.js → createIndexFiles.cjs} +0 -0
- package/lib/processors/jsdoc/lib/{transformApiJson.js → transformApiJson.cjs} +58 -2
- package/lib/processors/jsdoc/lib/ui5/{plugin.js → plugin.cjs} +306 -119
- package/lib/processors/jsdoc/lib/ui5/template/{publish.js → publish.cjs} +1 -1
- package/lib/processors/jsdoc/lib/ui5/template/utils/{versionUtil.js → versionUtil.cjs} +0 -0
- package/lib/processors/jsdoc/sdkTransformer.js +18 -11
- package/lib/processors/libraryLessGenerator.js +28 -16
- package/lib/processors/manifestCreator.js +14 -13
- package/lib/processors/minifier.js +21 -15
- package/lib/processors/nonAsciiEscaper.js +16 -6
- package/lib/processors/resourceListCreator.js +13 -13
- package/lib/processors/stringReplacer.js +13 -6
- package/lib/processors/themeBuilder.js +30 -22
- package/lib/processors/versionInfoGenerator.js +33 -23
- package/lib/tasks/buildThemes.js +17 -10
- package/lib/tasks/bundlers/generateBundle.js +23 -12
- package/lib/tasks/bundlers/generateComponentPreload.js +18 -10
- package/lib/tasks/bundlers/generateFlexChangesBundle.js +16 -8
- package/lib/tasks/bundlers/generateLibraryPreload.js +22 -12
- package/lib/tasks/bundlers/generateManifestBundle.js +15 -6
- package/lib/tasks/bundlers/generateStandaloneAppBundle.js +21 -13
- package/lib/tasks/bundlers/utils/createModuleNameMapping.js +6 -6
- package/lib/tasks/escapeNonAsciiCharacters.js +12 -5
- package/lib/tasks/generateCachebusterInfo.js +16 -8
- package/lib/tasks/generateLibraryManifest.js +14 -8
- package/lib/tasks/generateResourcesJson.js +15 -9
- package/lib/tasks/generateThemeDesignerResources.js +19 -9
- package/lib/tasks/generateVersionInfo.js +12 -5
- package/lib/tasks/jsdoc/executeJsdocSdkTransformation.js +17 -9
- package/lib/tasks/jsdoc/generateApiIndex.js +16 -10
- package/lib/tasks/jsdoc/generateJsdoc.js +131 -119
- package/lib/tasks/minify.js +13 -6
- package/lib/tasks/replaceBuildtime.js +12 -5
- package/lib/tasks/replaceCopyright.js +12 -5
- package/lib/tasks/replaceVersion.js +12 -5
- package/lib/tasks/taskRepository.js +24 -29
- package/lib/tasks/transformBootstrapHtml.js +6 -5
- package/package.json +30 -15
- package/index.js +0 -173
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Used by the ResourcePool to read raw module info as stored in the .
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
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,7 +48,7 @@ function createRawInfo(rawModule) {
|
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
function getDependencyInfos( name, content ) {
|
|
51
|
+
export function getDependencyInfos( name, content ) {
|
|
53
52
|
const infos = {};
|
|
54
53
|
parser.parseString(content, (err, result) => {
|
|
55
54
|
if ( result &&
|
|
@@ -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
|
-
|
|
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
|
-
|
|
22
|
+
export default LocatorResource;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
19
|
+
export default LocatorResourcePool;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
29
|
+
export default Resource;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
@@ -76,7 +75,7 @@ class ResourceCollector {
|
|
|
76
75
|
/**
|
|
77
76
|
* Processes a resource
|
|
78
77
|
*
|
|
79
|
-
* @param {
|
|
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
|
-
|
|
402
|
+
export default ResourceCollector;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
|
|
3
|
-
|
|
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
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
|
|
164
|
-
};
|
|
164
|
+
}
|
|
165
165
|
|
|
166
|
-
|
|
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
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import ResourceInfo from "./ResourceInfo.js";
|
|
2
2
|
|
|
3
3
|
const DEBUG_RESOURCES_PATTERN = /-dbg((?:\.view|\.fragment|\.controller|\.designtime|\.support)?\.js|\.css)$/;
|
|
4
4
|
|
|
@@ -114,4 +114,4 @@ class ResourceInfoList {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
export default ResourceInfoList;
|
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
235
|
+
export default ResourcePool;
|
|
242
236
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
|
|
3
|
-
|
|
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
|
-
|
|
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
|
|
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,7 @@ 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) {
|
|
39
59
|
// console.log("checking for named object ", node, objectPath, length);
|
|
40
60
|
while ( length > 1 &&
|
|
41
61
|
node.type === Syntax.MemberExpression &&
|
|
@@ -46,37 +66,37 @@ function isNamedObject(node, objectPath, length) {
|
|
|
46
66
|
return length === 1 && isIdentifier(node, objectPath[0]);
|
|
47
67
|
}
|
|
48
68
|
|
|
49
|
-
function isIdentifier(node, name) {
|
|
50
|
-
if ( node.type
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
if ( typeof name == "string" ) {
|
|
69
|
+
export function isIdentifier(node, name) {
|
|
70
|
+
if ( node.type === Syntax.Identifier && typeof name == "string" ) {
|
|
54
71
|
return name === node.name;
|
|
72
|
+
} else if ( node.type === Syntax.Identifier && Array.isArray(name) ) {
|
|
73
|
+
return name.find((name) => name === node.name || name === "*") !== undefined;
|
|
74
|
+
} else if ( node.type === Syntax.ObjectPattern ) {
|
|
75
|
+
return node.properties.filter((childnode) => isIdentifier(childnode.key, name)).length > 0;
|
|
76
|
+
} else if ( node.type === Syntax.ArrayPattern ) {
|
|
77
|
+
return node.elements.filter((childnode) => isIdentifier(childnode, name)).length > 0;
|
|
78
|
+
} else {
|
|
79
|
+
return false;
|
|
55
80
|
}
|
|
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
81
|
}
|
|
63
82
|
|
|
64
|
-
function getPropertyKey(property) {
|
|
65
|
-
if ( property.
|
|
83
|
+
export function getPropertyKey(property) {
|
|
84
|
+
if ( property.type === Syntax.SpreadElement ) {
|
|
85
|
+
// TODO: Support interpreting SpreadElements
|
|
86
|
+
return;
|
|
87
|
+
} else if ( property.key.type === Syntax.Identifier && property.computed !== true ) {
|
|
66
88
|
return property.key.name;
|
|
67
89
|
} else if ( property.key.type === Syntax.Literal ) {
|
|
68
90
|
return String(property.key.value);
|
|
69
|
-
} else {
|
|
70
|
-
throw new Error();
|
|
71
91
|
}
|
|
72
92
|
}
|
|
73
93
|
|
|
74
|
-
function findOwnProperty(obj, name) {
|
|
94
|
+
export function findOwnProperty(obj, name) {
|
|
75
95
|
const property = obj && obj.properties.find((property) => getPropertyKey(property) === name);
|
|
76
96
|
return property && property.value;
|
|
77
97
|
}
|
|
78
98
|
|
|
79
|
-
function getValue(obj, names) {
|
|
99
|
+
export function getValue(obj, names) {
|
|
80
100
|
let i = 0;
|
|
81
101
|
while ( i < names.length ) {
|
|
82
102
|
if ( obj == null || obj.type !== Syntax.ObjectExpression ) {
|
|
@@ -100,29 +120,23 @@ function getValue(obj, names) {
|
|
|
100
120
|
* @throws {TypeError}
|
|
101
121
|
* @returns {string[]}
|
|
102
122
|
*/
|
|
103
|
-
function getStringArray(array, skipNonStringLiterals) {
|
|
123
|
+
export function getStringArray(array, skipNonStringLiterals) {
|
|
104
124
|
return array.elements.reduce( (result, item) => {
|
|
105
|
-
|
|
106
|
-
|
|
125
|
+
const value = getStringValue(item);
|
|
126
|
+
if ( value !== undefined ) {
|
|
127
|
+
result.push(value);
|
|
107
128
|
} else if ( !skipNonStringLiterals ) {
|
|
108
|
-
|
|
129
|
+
if (item.type === Syntax.TemplateLiteral) {
|
|
130
|
+
throw new TypeError("array element is a template literal with expressions");
|
|
131
|
+
} else {
|
|
132
|
+
throw new TypeError("array element is not a string literal: " + item.type);
|
|
133
|
+
}
|
|
109
134
|
}
|
|
110
135
|
return result;
|
|
111
136
|
}, []);
|
|
112
137
|
}
|
|
113
138
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
};
|
|
139
|
+
export function getLocation(args) {
|
|
140
|
+
// NODE-TODO include line information in future
|
|
141
|
+
return args[0].value;
|
|
142
|
+
}
|
|
@@ -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
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
1
|
+
import nonAsciiEscaper from "../../processors/nonAsciiEscaper.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Can be used to escape *.properties files.
|
|
@@ -10,7 +10,7 @@ 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
|
-
|
|
13
|
+
export default async function(resource) {
|
|
14
14
|
const project = resource.getProject();
|
|
15
15
|
let propertiesFileSourceEncoding = project && project.getPropertiesFileSourceEncoding();
|
|
16
16
|
|
|
@@ -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
|
+
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
const {Syntax, VisitorKeys} = espree;
|
|
2
|
+
import {parse} from "espree";
|
|
5
3
|
|
|
6
4
|
const hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
|
|
7
5
|
|
|
8
|
-
function parseJS(code, userOptions = {}) {
|
|
6
|
+
export function parseJS(code, userOptions = {}) {
|
|
9
7
|
// allowed options and their defaults
|
|
10
8
|
const options = {
|
|
11
9
|
comment: false,
|
|
@@ -22,11 +20,7 @@ function parseJS(code, userOptions = {}) {
|
|
|
22
20
|
options[name] = value;
|
|
23
21
|
}
|
|
24
22
|
|
|
25
|
-
return
|
|
23
|
+
return parse(code, options);
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
parseJS,
|
|
30
|
-
Syntax,
|
|
31
|
-
VisitorKeys
|
|
32
|
-
};
|
|
26
|
+
export {Syntax, VisitorKeys} from "espree";
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
1
|
+
import logger from "@ui5/logger";
|
|
2
|
+
const log = logger.getLogger("builder:processors:bootstrapHtmlTransformer");
|
|
3
|
+
import cheerio from "cheerio";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @module @ui5/builder/processors/bootstrapHtmlTransformer
|
|
7
|
+
*/
|
|
3
8
|
|
|
4
9
|
/**
|
|
5
10
|
* Transforms the UI5 bootstrap of a HTML resource files.
|
|
6
11
|
*
|
|
7
|
-
* @
|
|
12
|
+
* @public
|
|
13
|
+
* @function default
|
|
14
|
+
* @static
|
|
15
|
+
*
|
|
8
16
|
* @param {object} parameters Parameters
|
|
9
|
-
* @param {
|
|
17
|
+
* @param {@ui5/fs/Resource[]} parameters.resources List of resources to be processed
|
|
10
18
|
* @param {object} parameters.options Options
|
|
11
19
|
* @param {string} parameters.options.src Bootstrap "src" that should be used
|
|
12
|
-
* @returns {Promise
|
|
20
|
+
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with the cloned resources
|
|
13
21
|
*/
|
|
14
|
-
|
|
22
|
+
export default function({resources, options: {src}}) {
|
|
15
23
|
async function processResource(resource) {
|
|
16
24
|
const content = await resource.getString();
|
|
17
25
|
const $ = cheerio.load(content);
|
|
@@ -30,4 +38,4 @@ module.exports = function({resources, options: {src}}) {
|
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
return Promise.all(resources.map(processResource));
|
|
33
|
-
}
|
|
41
|
+
}
|