@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.
- package/.reuse/dep5 +2 -2
- package/CHANGELOG.md +59 -1
- package/CONTRIBUTING.md +1 -1
- package/README.md +4 -4
- package/jsdoc.json +2 -2
- package/lib/lbt/UI5ClientConstants.js +7 -8
- package/lib/lbt/analyzer/ComponentAnalyzer.js +60 -22
- package/lib/lbt/analyzer/FioriElementsAnalyzer.js +31 -20
- package/lib/lbt/analyzer/JSModuleAnalyzer.js +119 -77
- package/lib/lbt/analyzer/SmartTemplateAnalyzer.js +31 -20
- package/lib/lbt/analyzer/XMLCompositeAnalyzer.js +35 -25
- package/lib/lbt/analyzer/XMLTemplateAnalyzer.js +71 -18
- package/lib/lbt/analyzer/analyzeLibraryJS.js +22 -6
- package/lib/lbt/bundle/AutoSplitter.js +10 -11
- package/lib/lbt/bundle/Builder.js +33 -36
- 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 +11 -12
- 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 +6 -9
- package/lib/lbt/resources/LocatorResource.js +2 -2
- package/lib/lbt/resources/LocatorResourcePool.js +3 -3
- package/lib/lbt/resources/ModuleInfo.js +2 -3
- package/lib/lbt/resources/Resource.js +3 -4
- package/lib/lbt/resources/ResourceCollector.js +8 -9
- package/lib/lbt/resources/ResourceFilterList.js +38 -40
- package/lib/lbt/resources/ResourceInfo.js +1 -1
- package/lib/lbt/resources/ResourceInfoList.js +5 -3
- package/lib/lbt/resources/ResourcePool.js +15 -21
- package/lib/lbt/utils/ASTUtils.js +60 -44
- package/lib/lbt/utils/JSTokenizer.js +4 -4
- package/lib/lbt/utils/ModuleName.js +10 -20
- package/lib/lbt/utils/escapePropertiesFile.js +4 -4
- package/lib/lbt/utils/parseUtils.js +5 -11
- package/lib/processors/bootstrapHtmlTransformer.js +15 -7
- package/lib/processors/bundlers/flexChangesBundler.js +16 -8
- package/lib/processors/bundlers/moduleBundler.js +26 -15
- package/lib/processors/jsdoc/apiIndexGenerator.js +16 -9
- package/lib/processors/jsdoc/jsdocGenerator.js +37 -25
- package/lib/processors/jsdoc/lib/{createIndexFiles.js → createIndexFiles.cjs} +0 -0
- package/lib/processors/jsdoc/lib/{transformApiJson.js → transformApiJson.cjs} +59 -2
- package/lib/processors/jsdoc/lib/ui5/{plugin.js → plugin.cjs} +310 -119
- package/lib/processors/jsdoc/lib/ui5/template/{publish.js → publish.cjs} +6 -2
- 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 +15 -14
- package/lib/processors/minifier.js +22 -16
- package/lib/processors/nonAsciiEscaper.js +17 -7
- package/lib/processors/resourceListCreator.js +13 -13
- package/lib/processors/stringReplacer.js +13 -6
- package/lib/processors/themeBuilder.js +33 -24
- package/lib/processors/versionInfoGenerator.js +40 -30
- package/lib/tasks/buildThemes.js +18 -11
- package/lib/tasks/bundlers/generateBundle.js +23 -12
- package/lib/tasks/bundlers/generateComponentPreload.js +23 -12
- package/lib/tasks/bundlers/generateFlexChangesBundle.js +16 -8
- package/lib/tasks/bundlers/generateLibraryPreload.js +33 -17
- package/lib/tasks/bundlers/generateStandaloneAppBundle.js +21 -13
- package/lib/tasks/bundlers/utils/createModuleNameMapping.js +7 -7
- package/lib/tasks/escapeNonAsciiCharacters.js +12 -5
- package/lib/tasks/generateCachebusterInfo.js +17 -9
- 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 -30
- package/lib/tasks/transformBootstrapHtml.js +6 -5
- package/package.json +44 -31
- package/index.js +0 -173
- package/lib/processors/bundlers/manifestBundler.js +0 -172
- package/lib/tasks/bundlers/generateManifestBundle.js +0 -49
|
@@ -27,7 +27,7 @@ const info = logger.info.bind(logger);
|
|
|
27
27
|
const warning = logger.warn.bind(logger);
|
|
28
28
|
const error = logger.error.bind(logger);
|
|
29
29
|
|
|
30
|
-
const {extractVersion, extractSince} = require("./utils/versionUtil");
|
|
30
|
+
const {extractVersion, extractSince} = require("./utils/versionUtil.cjs");
|
|
31
31
|
|
|
32
32
|
/* errors that might fail the build in future */
|
|
33
33
|
function future(msg) {
|
|
@@ -2877,7 +2877,11 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
|
|
|
2877
2877
|
}
|
|
2878
2878
|
tag("method");
|
|
2879
2879
|
attrib("name", name || member.name);
|
|
2880
|
-
|
|
2880
|
+
// write out module and export only when the module is different from the module of the parent entity
|
|
2881
|
+
// and when the member was not cloned (e.g. because it is borrowed)
|
|
2882
|
+
if ( member.__ui5.module
|
|
2883
|
+
&& member.__ui5.module !== symbol.__ui5.module
|
|
2884
|
+
&& member.__ui5.initialLongname === member.longname ) {
|
|
2881
2885
|
attrib("module", member.__ui5.module);
|
|
2882
2886
|
attrib("export", member.__ui5.globalOnly ? GLOBAL_ONLY : member.__ui5.export, '', true);
|
|
2883
2887
|
}
|
|
File without changes
|
|
@@ -1,23 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {createResource} from "@ui5/fs/resourceFactory";
|
|
2
|
+
import transformer from "./lib/transformApiJson.cjs";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* @public
|
|
6
|
+
* @module @ui5/builder/processors/jsdoc/sdkTransformer
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Transform api.json as created by [jsdocGenerator]{@link @ui5/builder/processors/jsdoc/jsdocGenerator}
|
|
6
11
|
* for usage in a UI5 SDK
|
|
7
12
|
*
|
|
8
13
|
* @public
|
|
9
|
-
* @
|
|
14
|
+
* @function default
|
|
15
|
+
* @static
|
|
16
|
+
*
|
|
10
17
|
* @param {object} parameters Parameters
|
|
11
18
|
* @param {string} parameters.apiJsonPath Path to the projects api.json file as created by
|
|
12
|
-
* [jsdocGenerator]{@link
|
|
19
|
+
* [jsdocGenerator]{@link @ui5/builder/processors/jsdoc/jsdocGenerator}
|
|
13
20
|
* @param {string} parameters.dotLibraryPath Path to the projects .library file
|
|
14
21
|
* @param {string[]} parameters.dependencyApiJsonPaths List of paths to the api.json files of all dependencies of
|
|
15
|
-
* the project as created by [jsdocGenerator]{@link
|
|
22
|
+
* the project as created by [jsdocGenerator]{@link @ui5/builder/processors/jsdoc/jsdocGenerator}
|
|
16
23
|
* @param {string} parameters.targetApiJsonPath Path to create the new, transformed api.json resource for
|
|
17
|
-
* @param {fs|module:@ui5/fs
|
|
18
|
-
* custom [fs interface]{@link module
|
|
24
|
+
* @param {fs|module:@ui5/fs/fsInterface} parameters.fs Node fs or
|
|
25
|
+
* custom [fs interface]{@link module:@ui5/fs/fsInterface} to use
|
|
19
26
|
*
|
|
20
|
-
* @returns {Promise
|
|
27
|
+
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with created resources
|
|
21
28
|
*/
|
|
22
29
|
const sdkTransformer = async function({
|
|
23
30
|
apiJsonPath, dotLibraryPath, dependencyApiJsonPaths, targetApiJsonPath, fs} = {}
|
|
@@ -30,10 +37,10 @@ const sdkTransformer = async function({
|
|
|
30
37
|
fs,
|
|
31
38
|
returnOutputFiles: true
|
|
32
39
|
});
|
|
33
|
-
return [
|
|
40
|
+
return [createResource({
|
|
34
41
|
path: targetApiJsonPath,
|
|
35
42
|
string: apiJsonContent
|
|
36
43
|
})];
|
|
37
44
|
};
|
|
38
45
|
|
|
39
|
-
|
|
46
|
+
export default sdkTransformer;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import logger from "@ui5/logger";
|
|
2
|
+
const log = logger.getLogger("builder:processors:libraryLessGenerator");
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import {promisify} from "node:util";
|
|
5
|
+
import posixPath from "node:path/posix";
|
|
6
|
+
import Resource from "@ui5/fs/Resource";
|
|
6
7
|
|
|
7
8
|
const IMPORT_PATTERN = /@import .*"(.*)";/g;
|
|
8
9
|
const BASE_LESS_PATTERN = /^\/resources\/sap\/ui\/core\/themes\/([^/]+)\/base\.less$/;
|
|
@@ -24,10 +25,10 @@ class LibraryLessGenerator {
|
|
|
24
25
|
async generate({filePath, fileContent}) {
|
|
25
26
|
return `/* NOTE: This file was generated as an optimized version of ` +
|
|
26
27
|
`"library.source.less" for the Theme Designer. */\n\n` +
|
|
27
|
-
await this.resolveLessImports({
|
|
28
|
+
(await this.resolveLessImports({
|
|
28
29
|
filePath,
|
|
29
30
|
fileContent
|
|
30
|
-
});
|
|
31
|
+
}));
|
|
31
32
|
}
|
|
32
33
|
static getPathToRoot(baseDir) {
|
|
33
34
|
return posixPath.relative(baseDir, "/") + "/";
|
|
@@ -132,10 +133,10 @@ class LibraryLessGenerator {
|
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
135
|
return `/* START "${originalFilePath}" */\n` +
|
|
135
|
-
await this.resolveLessImports({
|
|
136
|
+
(await this.resolveLessImports({
|
|
136
137
|
filePath: resolvedFilePath,
|
|
137
138
|
fileContent: importedFileContent
|
|
138
|
-
}) +
|
|
139
|
+
})) +
|
|
139
140
|
`\n/* END "${originalFilePath}" */\n`;
|
|
140
141
|
}
|
|
141
142
|
findLessImports(fileContent) {
|
|
@@ -153,6 +154,11 @@ class LibraryLessGenerator {
|
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
156
|
|
|
157
|
+
/**
|
|
158
|
+
* @public
|
|
159
|
+
* @module @ui5/builder/processors/libraryLessGenerator
|
|
160
|
+
*/
|
|
161
|
+
|
|
156
162
|
/**
|
|
157
163
|
* Creates a "library.less" file for the SAP Theme Designer based on a "library.source.less" file.
|
|
158
164
|
*
|
|
@@ -165,15 +171,17 @@ class LibraryLessGenerator {
|
|
|
165
171
|
* </ul>
|
|
166
172
|
*
|
|
167
173
|
* @public
|
|
168
|
-
* @
|
|
174
|
+
* @function default
|
|
175
|
+
* @static
|
|
176
|
+
*
|
|
169
177
|
* @param {object} parameters Parameters
|
|
170
|
-
* @param {
|
|
178
|
+
* @param {@ui5/fs/Resource[]} parameters.resources List of <code>library.source.less</code>
|
|
171
179
|
* resources
|
|
172
|
-
* @param {fs|module:@ui5/fs
|
|
173
|
-
* [fs interface]{@link module
|
|
174
|
-
* @returns {Promise
|
|
180
|
+
* @param {fs|module:@ui5/fs/fsInterface} parameters.fs Node fs or custom
|
|
181
|
+
* [fs interface]{@link module:@ui5/fs/fsInterface}
|
|
182
|
+
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with library.less resources
|
|
175
183
|
*/
|
|
176
|
-
|
|
184
|
+
async function createLibraryLess({resources, fs}) {
|
|
177
185
|
const generator = new LibraryLessGenerator({fs});
|
|
178
186
|
return Promise.all(resources.map(async (librarySourceLessResource) => {
|
|
179
187
|
const filePath = librarySourceLessResource.getPath();
|
|
@@ -189,10 +197,14 @@ module.exports = async function({resources, fs}) {
|
|
|
189
197
|
string: libraryLessFileContent
|
|
190
198
|
});
|
|
191
199
|
}));
|
|
192
|
-
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export default createLibraryLess;
|
|
193
203
|
|
|
204
|
+
let myLibraryLessGenerator;
|
|
194
205
|
// Export class for testing only
|
|
195
206
|
/* istanbul ignore else */
|
|
196
207
|
if (process.env.NODE_ENV === "test") {
|
|
197
|
-
|
|
208
|
+
myLibraryLessGenerator = LibraryLessGenerator;
|
|
198
209
|
}
|
|
210
|
+
export const _LibraryLessGenerator = myLibraryLessGenerator;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
2
|
+
import posixPath from "node:path/posix";
|
|
3
|
+
import semver from "semver";
|
|
4
|
+
const {SemVer: Version} = semver;
|
|
5
|
+
import logger from "@ui5/logger";
|
|
6
|
+
const log = logger.getLogger("builder:processors:manifestCreator");
|
|
7
|
+
import Resource from "@ui5/fs/Resource";
|
|
8
|
+
import xml2js from "xml2js";
|
|
9
|
+
import analyzeLibraryJS from "../lbt/analyzer/analyzeLibraryJS.js";
|
|
9
10
|
|
|
10
11
|
/*
|
|
11
12
|
* A single parse instance to be used by all invocations (TODO check reentrance capa of xml2js)
|
|
@@ -128,7 +129,7 @@ class LibraryBundle {
|
|
|
128
129
|
/**
|
|
129
130
|
*
|
|
130
131
|
* @param {string} prefix
|
|
131
|
-
* @param {
|
|
132
|
+
* @param {@ui5/fs/Resource[]} resources
|
|
132
133
|
*/
|
|
133
134
|
constructor(prefix, resources) {
|
|
134
135
|
this.prefix = prefix;
|
|
@@ -138,7 +139,7 @@ class LibraryBundle {
|
|
|
138
139
|
/**
|
|
139
140
|
*
|
|
140
141
|
* @param {string} name
|
|
141
|
-
* @returns {
|
|
142
|
+
* @returns {@ui5/fs/Resource}
|
|
142
143
|
*/
|
|
143
144
|
findResource(name) {
|
|
144
145
|
return this.resources.find((res) => res.getPath() === this.prefix + name);
|
|
@@ -147,7 +148,7 @@ class LibraryBundle {
|
|
|
147
148
|
/**
|
|
148
149
|
*
|
|
149
150
|
* @param {RegExp} pattern
|
|
150
|
-
* @returns {
|
|
151
|
+
* @returns {@ui5/fs/Resource[]}
|
|
151
152
|
*/
|
|
152
153
|
getResources(pattern) {
|
|
153
154
|
return this.resources.filter((res) => pattern == null || pattern.test(res.getPath()));
|
|
@@ -348,7 +349,7 @@ async function createManifest(
|
|
|
348
349
|
}
|
|
349
350
|
|
|
350
351
|
function collectThemes() {
|
|
351
|
-
const themes =
|
|
352
|
+
const themes = Object.create(null);
|
|
352
353
|
|
|
353
354
|
// find theme resources and determine theme names from their paths
|
|
354
355
|
libBundle.getResources(/(?:[^/]+\/)*themes\//).forEach((res) => {
|
|
@@ -620,7 +621,7 @@ async function createManifest(
|
|
|
620
621
|
};
|
|
621
622
|
}
|
|
622
623
|
|
|
623
|
-
|
|
624
|
+
export default function({libraryResource, resources, getProjectVersion, options}) {
|
|
624
625
|
// merge options with defaults
|
|
625
626
|
options = Object.assign({
|
|
626
627
|
descriptorVersion: APP_DESCRIPTOR_V22, // TODO 3.0: change this to type string instead of a semver object
|
|
@@ -642,9 +643,9 @@ module.exports = function({libraryResource, resources, getProjectVersion, option
|
|
|
642
643
|
return createManifest(libraryResource, libBundle, options.descriptorVersion, options.include3rdParty,
|
|
643
644
|
options.omitMinVersions, getProjectVersion)
|
|
644
645
|
.then((manifest) => {
|
|
645
|
-
return new
|
|
646
|
+
return new Resource({
|
|
646
647
|
path: resourcePathPrefix + "manifest.json",
|
|
647
648
|
string: JSON.stringify(manifest, null, options.prettyPrint ? " " : undefined)
|
|
648
649
|
});
|
|
649
650
|
});
|
|
650
|
-
}
|
|
651
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import posixPath from "node:path/posix";
|
|
2
|
+
import {minify} from "terser";
|
|
3
|
+
import Resource from "@ui5/fs/Resource";
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* Preserve comments which contain:
|
|
6
7
|
* <ul>
|
|
@@ -12,41 +13,46 @@ const Resource = require("@ui5/fs").Resource;
|
|
|
12
13
|
*
|
|
13
14
|
* @type {RegExp}
|
|
14
15
|
*/
|
|
15
|
-
const copyrightCommentsAndBundleCommentPattern = /copyright|\(c\)(?:[0-9]+|\s+[0-9A-
|
|
16
|
+
const copyrightCommentsAndBundleCommentPattern = /copyright|\(c\)(?:[0-9]+|\s+[0-9A-Za-z])|released under|license|\u00a9|^@ui5-bundle-raw-include |^@ui5-bundle /i;
|
|
16
17
|
const debugFileRegex = /((?:\.view|\.fragment|\.controller|\.designtime|\.support)?\.js)$/;
|
|
17
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @public
|
|
21
|
+
* @module @ui5/builder/processors/minifier
|
|
22
|
+
*/
|
|
18
23
|
|
|
19
24
|
/**
|
|
20
25
|
* Result set
|
|
21
26
|
*
|
|
22
27
|
* @public
|
|
23
28
|
* @typedef {object} MinifierResult
|
|
24
|
-
* @property {
|
|
25
|
-
* @property {
|
|
26
|
-
* @property {
|
|
27
|
-
* @memberof module:@ui5/builder.processors
|
|
29
|
+
* @property {@ui5/fs/Resource} resource Minified resource
|
|
30
|
+
* @property {@ui5/fs/Resource} dbgResource Debug (non-minified) variant
|
|
31
|
+
* @property {@ui5/fs/Resource} sourceMap Source Map
|
|
28
32
|
*/
|
|
29
33
|
|
|
30
34
|
/**
|
|
31
35
|
* Minifies the supplied resources.
|
|
32
36
|
*
|
|
33
37
|
* @public
|
|
34
|
-
* @
|
|
38
|
+
* @function default
|
|
39
|
+
* @static
|
|
40
|
+
*
|
|
35
41
|
* @param {object} parameters Parameters
|
|
36
|
-
* @param {
|
|
42
|
+
* @param {@ui5/fs/Resource[]} parameters.resources List of resources to be processed
|
|
37
43
|
* @param {object} [parameters.options] Options
|
|
38
44
|
* @param {boolean} [parameters.options.addSourceMappingUrl=true]
|
|
39
45
|
* Whether to add a sourceMappingURL reference to the end of the minified resource
|
|
40
|
-
* @returns {Promise<module:@ui5/builder
|
|
46
|
+
* @returns {Promise<module:@ui5/builder/processors/minifier~MinifierResult[]>}
|
|
41
47
|
* Promise resolving with object of resource, dbgResource and sourceMap
|
|
42
48
|
*/
|
|
43
|
-
|
|
49
|
+
export default async function({resources, options: {addSourceMappingUrl = true} = {}}) {
|
|
44
50
|
return Promise.all(resources.map(async (resource) => {
|
|
45
51
|
const dbgPath = resource.getPath().replace(debugFileRegex, "-dbg$1");
|
|
46
52
|
const dbgResource = await resource.clone();
|
|
47
53
|
dbgResource.setPath(dbgPath);
|
|
48
54
|
|
|
49
|
-
const filename =
|
|
55
|
+
const filename = posixPath.basename(resource.getPath());
|
|
50
56
|
const code = await resource.getString();
|
|
51
57
|
try {
|
|
52
58
|
const sourceMapOptions = {
|
|
@@ -55,8 +61,8 @@ module.exports = async function({resources, options: {addSourceMappingUrl = true
|
|
|
55
61
|
if (addSourceMappingUrl) {
|
|
56
62
|
sourceMapOptions.url = filename + ".map";
|
|
57
63
|
}
|
|
58
|
-
const dbgFilename =
|
|
59
|
-
const result = await
|
|
64
|
+
const dbgFilename = posixPath.basename(dbgPath);
|
|
65
|
+
const result = await minify({
|
|
60
66
|
// Use debug-name since this will be referenced in the source map "sources"
|
|
61
67
|
[dbgFilename]: code
|
|
62
68
|
}, {
|
|
@@ -87,4 +93,4 @@ module.exports = async function({resources, options: {addSourceMappingUrl = true
|
|
|
87
93
|
`(line ${err.line}, col ${err.col}, pos ${err.pos})`);
|
|
88
94
|
}
|
|
89
95
|
}));
|
|
90
|
-
}
|
|
96
|
+
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import escapeUnicode from "escape-unicode";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* @module @ui5/builder/processors/nonAsciiEscaper
|
|
6
|
+
*/
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
9
|
* @see https://en.wikipedia.org/wiki/ASCII
|
|
@@ -9,7 +14,7 @@ const escapeUnicode = require("escape-unicode");
|
|
|
9
14
|
const CHAR_CODE_OF_LAST_ASCII_CHARACTER = 127;
|
|
10
15
|
|
|
11
16
|
// use memoization for escapeUnicode function for performance
|
|
12
|
-
const memoizeEscapeUnicodeMap =
|
|
17
|
+
const memoizeEscapeUnicodeMap = Object.create(null);
|
|
13
18
|
const memoizeEscapeUnicode = function(sChar) {
|
|
14
19
|
if (memoizeEscapeUnicodeMap[sChar]) {
|
|
15
20
|
return memoizeEscapeUnicodeMap[sChar];
|
|
@@ -58,14 +63,16 @@ const escapeNonAscii = function(string) {
|
|
|
58
63
|
*
|
|
59
64
|
*
|
|
60
65
|
* @public
|
|
61
|
-
* @
|
|
66
|
+
* @function default
|
|
67
|
+
* @static
|
|
68
|
+
*
|
|
62
69
|
* @param {object} parameters Parameters
|
|
63
|
-
* @param {
|
|
70
|
+
* @param {@ui5/fs/Resource[]} parameters.resources List of resources to be processed
|
|
64
71
|
* @param {object} [parameters.options] Options
|
|
65
72
|
* @param {string} [parameters.options.encoding="utf8"] resource file encoding
|
|
66
73
|
* ({@link https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings Node.js character encodings}).
|
|
67
74
|
* Use #getEncodingFromAlias to get the encoding string
|
|
68
|
-
* @returns {Promise
|
|
75
|
+
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with the processed resources
|
|
69
76
|
*/
|
|
70
77
|
async function nonAsciiEscaper({resources, options: {encoding}}) {
|
|
71
78
|
encoding = encoding || "utf8";
|
|
@@ -94,7 +101,10 @@ const encodingMap = {
|
|
|
94
101
|
* such that it can be used standalone without the respective task (e.g. in Splitter, Bundler and related projects).
|
|
95
102
|
*
|
|
96
103
|
* @public
|
|
97
|
-
* @
|
|
104
|
+
* @function getEncodingFromAlias
|
|
105
|
+
* @alias @ui5/builder/processors/nonAsciiEscaper․getEncodingFromAlias
|
|
106
|
+
* @static
|
|
107
|
+
*
|
|
98
108
|
* @param {string} encoding encoding labels: "UTF-8" and "ISO-8859-1"
|
|
99
109
|
* @returns {string} node.js character encoding string, e.g. utf8 and latin1
|
|
100
110
|
*/
|
|
@@ -106,4 +116,4 @@ nonAsciiEscaper.getEncodingFromAlias = function(encoding) {
|
|
|
106
116
|
return encodingMap[encoding];
|
|
107
117
|
};
|
|
108
118
|
|
|
109
|
-
|
|
119
|
+
export default nonAsciiEscaper;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import logger from "@ui5/logger";
|
|
3
|
+
const log = logger.getLogger("builder:processors:resourceListCreator");
|
|
4
|
+
import ResourceCollector from "../lbt/resources/ResourceCollector.js";
|
|
5
|
+
import LocatorResourcePool from "../lbt/resources/LocatorResourcePool.js";
|
|
6
|
+
import ResourceInfo from "../lbt/resources/ResourceInfo.js";
|
|
7
|
+
import Resource from "@ui5/fs/Resource";
|
|
7
8
|
|
|
8
|
-
const EvoResource = require("@ui5/fs").Resource;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* List of resource patterns that describe all debug resources.
|
|
@@ -115,12 +115,12 @@ function makeResourcesJSON(list, prefix) {
|
|
|
115
115
|
*
|
|
116
116
|
* @private
|
|
117
117
|
* @param {object} parameters Parameters
|
|
118
|
-
* @param {
|
|
119
|
-
* @param {
|
|
118
|
+
* @param {@ui5/fs/Resource[]} parameters.resources List of resources
|
|
119
|
+
* @param {@ui5/fs/Resource[]} [parameters.dependencyResources=[]] List of dependency resources
|
|
120
120
|
* @param {object} [parameters.options] Options
|
|
121
|
-
* @returns {Promise
|
|
121
|
+
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with the resources.json resources
|
|
122
122
|
*/
|
|
123
|
-
|
|
123
|
+
export default async function({resources, dependencyResources = [], options}) {
|
|
124
124
|
options = Object.assign({
|
|
125
125
|
failOnOrphans: false,
|
|
126
126
|
externalResources: undefined,
|
|
@@ -163,7 +163,7 @@ module.exports = async function({resources, dependencyResources = [], options})
|
|
|
163
163
|
|
|
164
164
|
const contentString = makeResourcesJSON(list, prefix);
|
|
165
165
|
|
|
166
|
-
resourceLists.push(new
|
|
166
|
+
resourceLists.push(new Resource({
|
|
167
167
|
path: `/resources/${prefix}resources.json`,
|
|
168
168
|
string: contentString
|
|
169
169
|
}));
|
|
@@ -173,7 +173,7 @@ module.exports = async function({resources, dependencyResources = [], options})
|
|
|
173
173
|
|
|
174
174
|
const contentString = makeResourcesJSON(list, prefix);
|
|
175
175
|
|
|
176
|
-
resourceLists.push(new
|
|
176
|
+
resourceLists.push(new Resource({
|
|
177
177
|
path: `/resources/${prefix}resources.json`,
|
|
178
178
|
string: contentString
|
|
179
179
|
}));
|
|
@@ -187,4 +187,4 @@ module.exports = async function({resources, dependencyResources = [], options})
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
return resourceLists;
|
|
190
|
-
}
|
|
190
|
+
}
|
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
import replaceStream from "replacestream";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* @module @ui5/builder/processors/stringReplacer
|
|
6
|
+
*/
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
9
|
* Replaces placeholders with corresponding values.
|
|
5
10
|
*
|
|
6
11
|
* @public
|
|
7
|
-
* @
|
|
12
|
+
* @function default
|
|
13
|
+
* @static
|
|
14
|
+
*
|
|
8
15
|
* @param {object} parameters Parameters
|
|
9
|
-
* @param {
|
|
16
|
+
* @param {@ui5/fs/Resource[]} parameters.resources List of resources to be processed
|
|
10
17
|
* @param {object} parameters.options Options
|
|
11
18
|
* @param {string} parameters.options.pattern Pattern of placeholders
|
|
12
19
|
* @param {string} parameters.options.replacement Replacement for placeholders
|
|
13
|
-
* @returns {Promise
|
|
20
|
+
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with modified resources
|
|
14
21
|
*/
|
|
15
|
-
|
|
22
|
+
export default function({resources, options: {pattern, replacement}}) {
|
|
16
23
|
return Promise.all(resources.map((resource) => {
|
|
17
24
|
let stream = resource.getStream();
|
|
18
25
|
stream.setEncoding("utf8");
|
|
@@ -21,4 +28,4 @@ module.exports = function({resources, options: {pattern, replacement}}) {
|
|
|
21
28
|
resource.setStream(stream);
|
|
22
29
|
return resource;
|
|
23
30
|
}));
|
|
24
|
-
}
|
|
31
|
+
}
|
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import logger from "@ui5/logger";
|
|
2
|
+
const log = logger.getLogger("builder:processors:themeBuilder");
|
|
3
|
+
import posixPath from "node:path/posix";
|
|
4
|
+
import less from "less-openui5";
|
|
5
|
+
import Resource from "@ui5/fs/Resource";
|
|
5
6
|
|
|
6
7
|
const libraryMatchPattern = /^\/resources\/(.*)\/themes\/[^/]*\/library\.source\.less$/i;
|
|
7
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @public
|
|
11
|
+
* @module @ui5/builder/processors/ThemeBuilder
|
|
12
|
+
*/
|
|
13
|
+
|
|
8
14
|
/**
|
|
9
15
|
* Builds a library theme
|
|
10
16
|
*
|
|
11
17
|
* @public
|
|
12
|
-
* @
|
|
18
|
+
* @class
|
|
13
19
|
*/
|
|
14
|
-
class ThemeBuilder {
|
|
20
|
+
export class ThemeBuilder {
|
|
15
21
|
/**
|
|
16
22
|
* Constructor
|
|
17
23
|
*
|
|
18
24
|
* @public
|
|
19
|
-
* @param {fs|module:@ui5/fs
|
|
20
|
-
* [fs interface]{@link module
|
|
25
|
+
* @param {fs|module:@ui5/fs/fsInterface} fs Node fs or custom
|
|
26
|
+
* [fs interface]{@link module:@ui5/fs/fsInterface}
|
|
21
27
|
*/
|
|
22
28
|
constructor({fs}) {
|
|
23
29
|
this.builder = new less.Builder({fs});
|
|
@@ -27,13 +33,13 @@ class ThemeBuilder {
|
|
|
27
33
|
* Starts the theme build
|
|
28
34
|
*
|
|
29
35
|
* @public
|
|
30
|
-
* @param {
|
|
36
|
+
* @param {@ui5/fs/Resource[]} resources Library files
|
|
31
37
|
* @param {object} [options] Build options
|
|
32
38
|
* @param {boolean} [options.compress=false] Compress build output (CSS / JSON)
|
|
33
39
|
* @param {boolean} [options.cssVariables=false] Generates the CSS variables
|
|
34
40
|
* (css-variables.css, css-variables.source.less) and the skeleton for a theme
|
|
35
41
|
* (library-skeleton.css, [library-skeleton-RTL.css])
|
|
36
|
-
* @returns {Promise
|
|
42
|
+
* @returns {Promise<@ui5/fs/Resource[]>} Resolving with array of created files
|
|
37
43
|
*/
|
|
38
44
|
build(resources, {compress = false, cssVariables = false} = {}) {
|
|
39
45
|
const files = [];
|
|
@@ -57,7 +63,7 @@ class ThemeBuilder {
|
|
|
57
63
|
},
|
|
58
64
|
cssVariables
|
|
59
65
|
}).then((result) => {
|
|
60
|
-
const themeDir =
|
|
66
|
+
const themeDir = posixPath.dirname(resource.getPath());
|
|
61
67
|
|
|
62
68
|
const libCss = new Resource({
|
|
63
69
|
path: themeDir + "/library.css",
|
|
@@ -108,10 +114,11 @@ class ThemeBuilder {
|
|
|
108
114
|
}
|
|
109
115
|
|
|
110
116
|
/**
|
|
111
|
-
* Clears all cached build results
|
|
117
|
+
* Clears all cached build results.
|
|
112
118
|
*
|
|
113
|
-
* @public
|
|
114
119
|
* Use this method to prevent high memory consumption when building many themes within the same process.
|
|
120
|
+
*
|
|
121
|
+
* @public
|
|
115
122
|
*/
|
|
116
123
|
clearCache() {
|
|
117
124
|
this.builder.clearCache();
|
|
@@ -132,21 +139,25 @@ class ThemeBuilder {
|
|
|
132
139
|
* Builds a library theme.
|
|
133
140
|
*
|
|
134
141
|
* @public
|
|
135
|
-
* @
|
|
142
|
+
* @function default
|
|
143
|
+
* @static
|
|
144
|
+
*
|
|
145
|
+
* @alias @ui5/builder/processors/themeBuilder
|
|
136
146
|
* @param {object} parameters Parameters
|
|
137
|
-
* @param {
|
|
147
|
+
* @param {@ui5/fs/Resource[]} parameters.resources List of <code>library.source.less</code>
|
|
138
148
|
* resources to be processed
|
|
139
|
-
* @param {fs|module:@ui5/fs
|
|
140
|
-
* [fs interface]{@link module
|
|
141
|
-
* @param {ThemeBuilderOptions} [parameters.options] Options
|
|
142
|
-
* @returns {Promise
|
|
149
|
+
* @param {fs|module:@ui5/fs/fsInterface} parameters.fs Node fs or custom
|
|
150
|
+
* [fs interface]{@link module:@ui5/fs/fsInterface}
|
|
151
|
+
* @param {module:@ui5/builder/processors/ThemeBuilder~ThemeBuilderOptions} [parameters.options] Options
|
|
152
|
+
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with theme resources
|
|
143
153
|
*/
|
|
144
|
-
|
|
154
|
+
export default async function({
|
|
145
155
|
resources,
|
|
146
156
|
fs,
|
|
147
157
|
options = {}
|
|
148
158
|
}) {
|
|
149
|
-
const {compress, cssVariables} =
|
|
159
|
+
const {compress, cssVariables} =
|
|
160
|
+
/** @type {module:@ui5/builder/processors/ThemeBuilder~ThemeBuilderOptions} */ (options);
|
|
150
161
|
const themeBuilder = new ThemeBuilder({fs});
|
|
151
162
|
return themeBuilder.build(resources, {
|
|
152
163
|
compress,
|
|
@@ -155,6 +166,4 @@ module.exports = async function({
|
|
|
155
166
|
themeBuilder.clearCache();
|
|
156
167
|
return files;
|
|
157
168
|
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
module.exports.ThemeBuilder = ThemeBuilder;
|
|
169
|
+
}
|