@ui5/webcomponents-tools 0.0.0-c6155714e → 0.0.0-c638668a1

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 (64) hide show
  1. package/CHANGELOG.md +164 -1
  2. package/README.md +1 -1
  3. package/assets-meta.js +149 -0
  4. package/bin/dev.js +16 -1
  5. package/components-package/nps.js +73 -34
  6. package/components-package/postcss.themes.js +5 -2
  7. package/components-package/rollup-plugins/empty-module.js +15 -0
  8. package/components-package/rollup.js +155 -50
  9. package/components-package/wdio.js +102 -60
  10. package/components-package/wdio.sync.js +360 -0
  11. package/icons-collection/nps.js +72 -28
  12. package/lib/copy-and-watch/index.js +122 -0
  13. package/lib/copy-list/index.js +28 -0
  14. package/lib/create-icons/index.js +45 -23
  15. package/lib/create-illustrations/index.js +150 -0
  16. package/lib/create-new-component/index.js +18 -6
  17. package/lib/documentation/index.js +43 -21
  18. package/lib/documentation/templates/template.js +1 -1
  19. package/lib/esm-abs-to-rel/index.js +54 -0
  20. package/lib/generate-json-imports/i18n.js +91 -47
  21. package/lib/generate-json-imports/themes.js +61 -13
  22. package/lib/hash/config.js +10 -0
  23. package/lib/hash/generate.js +19 -0
  24. package/lib/hash/upToDate.js +31 -0
  25. package/lib/hbs2lit/index.js +2 -4
  26. package/lib/hbs2lit/src/compiler.js +8 -7
  27. package/lib/hbs2lit/src/includesReplacer.js +22 -16
  28. package/lib/hbs2lit/src/litVisitor2.js +57 -11
  29. package/lib/hbs2lit/src/svgProcessor.js +3 -3
  30. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +5 -5
  31. package/lib/hbs2ui5/index.js +26 -20
  32. package/lib/i18n/defaults.js +25 -6
  33. package/lib/i18n/toJSON.js +15 -4
  34. package/lib/jsdoc/config.json +1 -1
  35. package/lib/jsdoc/plugin.js +24 -4
  36. package/lib/jsdoc/template/publish.js +11 -2
  37. package/lib/polyfill-placeholder/index.js +5 -0
  38. package/lib/postcss-css-to-esm/index.js +31 -19
  39. package/lib/postcss-css-to-json/index.js +27 -11
  40. package/lib/postcss-new-files/index.js +36 -0
  41. package/lib/replace-global-core/index.js +20 -0
  42. package/lib/scoping/get-all-tags.js +44 -0
  43. package/lib/scoping/lint-src.js +31 -0
  44. package/lib/scoping/scope-test-pages.js +40 -0
  45. package/lib/serve/index.js +46 -0
  46. package/{components-package → lib/serve}/serve.json +0 -0
  47. package/package.json +55 -55
  48. package/bin/init-ui5-package.js +0 -3
  49. package/lib/init-package/index.js +0 -119
  50. package/lib/init-package/resources/config/postcss.components/postcss.config.js +0 -1
  51. package/lib/init-package/resources/config/postcss.themes/postcss.config.js +0 -1
  52. package/lib/init-package/resources/config/rollup.config.js +0 -1
  53. package/lib/init-package/resources/package-scripts.js +0 -11
  54. package/lib/init-package/resources/src/Assets.js +0 -6
  55. package/lib/init-package/resources/src/Demo.hbs +0 -1
  56. package/lib/init-package/resources/src/Demo.js +0 -57
  57. package/lib/init-package/resources/src/i18n/messagebundle.properties +0 -2
  58. package/lib/init-package/resources/src/i18n/messagebundle_de.properties +0 -1
  59. package/lib/init-package/resources/src/i18n/messagebundle_en.properties +0 -1
  60. package/lib/init-package/resources/src/i18n/messagebundle_es.properties +0 -1
  61. package/lib/init-package/resources/src/i18n/messagebundle_fr.properties +0 -1
  62. package/lib/init-package/resources/test/pages/index.html +0 -51
  63. package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
  64. package/package-lock.json +0 -9994
@@ -0,0 +1,10 @@
1
+ const config = {
2
+ files: {
3
+ exclude: ['serve.json']
4
+ },
5
+ folders: {
6
+ exclude: ['resources']
7
+ },
8
+ };
9
+
10
+ module.exports = config;
@@ -0,0 +1,19 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const process = require("process");
4
+ const { hashElement } = require("folder-hash");
5
+ const config = require("./config.js");
6
+
7
+ const inputDir = path.normalize(process.argv[2]);
8
+ const outputFileName = path.normalize(process.argv[3]);
9
+
10
+ const generateHash = async (inputDir, outputFileName) => {
11
+ const result = await hashElement(inputDir, config);
12
+ const hash = result.hash;
13
+ fs.writeFileSync(outputFileName, hash);
14
+ return hash;
15
+ };
16
+
17
+ generateHash(inputDir, outputFileName).then(hash => {
18
+ console.log(`Generated hash: ${hash}`);
19
+ });
@@ -0,0 +1,31 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const process = require("process");
4
+ const { hashElement } = require("folder-hash");
5
+ const config = require("./config.js");
6
+
7
+ const inputDir = path.normalize(process.argv[2]);
8
+ const hashFileName = path.normalize(process.argv[3]);
9
+
10
+ const isUpToDate = async (inputDir, hashFileName) => {
11
+ // No dist/ directory or no hash file
12
+ if (!fs.existsSync(inputDir) || !fs.existsSync(hashFileName)) {
13
+ return false;
14
+ }
15
+
16
+ // Empty hash file
17
+ const existingHash = `${fs.readFileSync(hashFileName)}`;
18
+ if (!existingHash) {
19
+ return false;
20
+ }
21
+
22
+ // Calculate the hash of the dist/ directory
23
+ const result = await hashElement(inputDir, config);
24
+ const newHash = result.hash;
25
+
26
+ return newHash === existingHash;
27
+ };
28
+
29
+ isUpToDate(inputDir, hashFileName).then(upToDate => {
30
+ process.exit(upToDate ? 0 : 1); // 0 means success (it is up to date), 1 means failure (must rebuild the dist/)
31
+ });
@@ -1,5 +1,3 @@
1
- const compiler = require("./src/compiler");
1
+ const hbs2lit = require("./src/compiler");
2
2
 
3
- module.exports = {
4
- compileString: compiler.compileString
5
- };
3
+ module.exports = hbs2lit;
@@ -5,13 +5,16 @@ const includesReplacer = require("./includesReplacer");
5
5
  const svgProcessor = require("./svgProcessor");
6
6
 
7
7
  const removeWhiteSpaces = (source) => {
8
- return source.replace(/\n+/g, "").replace(/\s+</g, "<").replace(/}}\s+{{/g, "}}{{");
8
+ return source
9
+ .replace(/\s*\r*\n+\s*/g, " ") // Replace new lines and all whitespace between them with a space
10
+ .replace(/\s*<\s*/g, "<") // Strip whitespace round <
11
+ .replace(/\s*>\s*/g, ">") // Strip whitespace round >
12
+ .replace(/}}\s+{{/g, "}}{{"); // Remove whitespace between }} and {{
9
13
  };
10
14
 
11
- const compileString = async (sInput, config) => {
12
- let sPreprocessed = sInput;
15
+ const hbs2lit = (file) => {
16
+ let sPreprocessed = includesReplacer.replace(file);
13
17
 
14
- sPreprocessed = await includesReplacer.replace(sPreprocessed, config);
15
18
  sPreprocessed = removeWhiteSpaces(sPreprocessed);
16
19
 
17
20
  const ast = Handlebars.parse(sPreprocessed);
@@ -34,6 +37,4 @@ const compileString = async (sInput, config) => {
34
37
  return result;
35
38
  };
36
39
 
37
- module.exports = {
38
- compileString
39
- };
40
+ module.exports = hbs2lit;
@@ -1,25 +1,31 @@
1
1
  const path = require("path");
2
- const {promisify} = require("util");
3
- const nativeFs = require("fs");
2
+ const fs = require("fs");
4
3
 
5
- function replaceIncludes(hbs, config) {
6
- const fs = config.fs || nativeFs;
7
- const readFile = promisify(fs.readFile);
8
- const inclRegex = /{{>\s*include\s*["']([a-zA-Z.\/]+)["']}}/g;
9
-
10
- async function replacer(match, p1) {
11
- const includeContent = await readFile(path.join(config.templatesPath, p1), "utf-8");
12
- hbs = hbs.replace(match, includeContent);
13
- }
4
+ function replaceIncludes(file) {
5
+ const filePath = path.dirname(file);
6
+ let fileContent = fs.readFileSync(file, "utf-8");
14
7
 
8
+ const inclRegex = /{{>\s*include\s*["'](.+?)["']}}/g;
15
9
  let match;
16
- const replacers = [];
17
- while ((match = inclRegex.exec (hbs)) !== null) {
18
- replacers.push(replacer(match[0], match[1]));
10
+
11
+ while((match = inclRegex.exec(fileContent)) !== null) {
12
+ inclRegex.lastIndex = 0;
13
+
14
+ let targetFile = match[1];
15
+ if (targetFile.startsWith(".")) {
16
+ // Relative path, f.e. {{>include "./Popup.hbs"}} or {{>include "../partials/Header.hbs"}}
17
+ targetFile = path.join(filePath, targetFile);
18
+ } else {
19
+ // Node module path, f.e. {{>include "@ui5/webcomponents/src/Popup.hbs"}}
20
+ targetFile = require.resolve(targetFile);
21
+ }
22
+
23
+ fileContent = fileContent.replace(match[0], replaceIncludes(targetFile));
19
24
  }
20
- return Promise.all(replacers).then(() => hbs);
25
+
26
+ return fileContent;
21
27
  }
22
28
 
23
29
  module.exports = {
24
30
  replace: replaceIncludes
25
- };
31
+ };
@@ -2,6 +2,32 @@ const Handlebars = require("handlebars/dist/handlebars.min.js");
2
2
  const path = require("path");
3
3
  const Visitor = Handlebars.Visitor;
4
4
 
5
+ // skip ifDefined for event handlers and boolean attrs
6
+ let skipIfDefined = false;
7
+
8
+ // when true => an HTML node value, when false => an attribute value
9
+ let isNodeValue = false;
10
+
11
+ // when true => the current attribute is "style"
12
+ let isStyleAttribute = false;
13
+
14
+ // matches event handlers @click= and boolean attrs ?disabled=
15
+ const dynamicAttributeRgx = /\s(\?|@)([a-zA-Z|-]+)="?\s*$/;
16
+
17
+ if (!String.prototype.replaceAll) {
18
+ String.prototype.replaceAll = function(str, newStr){
19
+
20
+ // If a regex pattern
21
+ if (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') {
22
+ return this.replace(str, newStr);
23
+ }
24
+
25
+ // If a string
26
+ return this.replace(new RegExp(str, 'g'), newStr);
27
+
28
+ };
29
+ }
30
+
5
31
  function HTMLLitVisitor(debug) {
6
32
  this.blockCounter = 0;
7
33
  this.keys = [];
@@ -9,7 +35,7 @@ function HTMLLitVisitor(debug) {
9
35
  this.result = "";
10
36
  this.mainBlock = "";
11
37
  this.blockPath = "context";
12
- this.blockParameters = ["context"];
38
+ this.blockParameters = ["context", "tags", "suffix"];
13
39
  this.paths = []; //contains all normalized relative paths
14
40
  this.debug = debug;
15
41
  if (this.debug) {
@@ -25,7 +51,7 @@ HTMLLitVisitor.prototype.Program = function(program) {
25
51
  this.keys.push(key);
26
52
  this.debug && this.blockByNumber.push(key);
27
53
 
28
- this.blocks[this.currentKey()] = "const " + this.currentKey() + " = (" + this.blockParameters.join(", ") + ") => { return ";
54
+ this.blocks[this.currentKey()] = "const " + this.currentKey() + " = (" + this.blockParameters.join(", ") + ") => ";
29
55
 
30
56
  if (this.keys.length > 1) { //it's a nested block
31
57
  this.blocks[this.prevKey()] += this.currentKey() + "(" + this.blockParameters.join(", ") + ")";
@@ -36,7 +62,7 @@ HTMLLitVisitor.prototype.Program = function(program) {
36
62
 
37
63
  this.blocks[this.currentKey()] += "html`";
38
64
  Visitor.prototype.Program.call(this, program);
39
- this.blocks[this.currentKey()] += "`; };";
65
+ this.blocks[this.currentKey()] += "`;";
40
66
 
41
67
  this.keys.pop(key);
42
68
  };
@@ -45,8 +71,25 @@ HTMLLitVisitor.prototype.ContentStatement = function(content) {
45
71
  Visitor.prototype.ContentStatement.call(this, content);
46
72
  // let content = content.orgiinal; // attribute="__ attribute = "__ attribute ="__
47
73
 
48
- this.blocks[this.currentKey()] += content.original;
74
+ let contentStatement = content.original;
75
+ skipIfDefined = !!dynamicAttributeRgx.exec(contentStatement);
76
+
77
+ const closingIndex = contentStatement.lastIndexOf(">");
78
+ const openingIndex = contentStatement.lastIndexOf("<");
79
+ if (closingIndex !== -1 || openingIndex !== -1) { // Only change isNodeValue whenever < or > is found in the content statement
80
+ isNodeValue = closingIndex > openingIndex;
81
+ }
82
+
83
+ isStyleAttribute = !isNodeValue && contentStatement.match(/style *= *["']? *$/);
49
84
 
85
+ if (!isStyleAttribute && contentStatement.match(/style=/)) {
86
+ console.log("WARNING: style hard-coded", contentStatement);
87
+ }
88
+
89
+ // Scope custom element tags
90
+ contentStatement = contentStatement.replaceAll(/(<\/?\s*)([a-zA-Z0-9_]+-[a-zA-Z0-9_-]+)/g, "$1\${scopeTag(\"$2\", tags, suffix)}");
91
+
92
+ this.blocks[this.currentKey()] += contentStatement;
50
93
  };
51
94
 
52
95
  HTMLLitVisitor.prototype.MustacheStatement = function(mustache) {
@@ -57,14 +100,17 @@ HTMLLitVisitor.prototype.MustacheStatement = function(mustache) {
57
100
  } else {
58
101
  const path = normalizePath.call(this, mustache.path.original);
59
102
  const hasCalculatingClasses = path.includes("context.classes");
60
- const hasStylesCalculation = path.includes("context.styles");
61
-
103
+
62
104
  let parsedCode = "";
63
105
 
64
- if (hasCalculatingClasses) {
65
- parsedCode = `\${ifDefined(classMap(${path}))}`;
66
- } else if (hasStylesCalculation) {
67
- parsedCode = `\${ifDefined(styleMap(${path}))}`;
106
+ if (isNodeValue && !mustache.escaped) {
107
+ parsedCode = `\${unsafeHTML(${path})}`;
108
+ } else if (hasCalculatingClasses) {
109
+ parsedCode = `\${classMap(${path})}`;
110
+ } else if (isStyleAttribute) {
111
+ parsedCode = `\${styleMap(${path})}`;
112
+ } else if (skipIfDefined){
113
+ parsedCode = `\${${path}}`;
68
114
  } else {
69
115
  parsedCode = `\${ifDefined(${path})}`;
70
116
  }
@@ -125,7 +171,7 @@ function visitEachBlock(block) {
125
171
  var bParamAdded = false;
126
172
  visitSubExpression.call(this, block);
127
173
 
128
- this.blocks[this.currentKey()] += "${ repeat(" + normalizePath.call(this, block.params[0].original) + ", undefined, (item, index) => ";
174
+ this.blocks[this.currentKey()] += "${ repeat(" + normalizePath.call(this, block.params[0].original) + ", (item, index) => item._id || index, (item, index) => ";
129
175
  this.paths.push(normalizePath.call(this, block.params[0].original));
130
176
  this.blockPath = "item";
131
177
 
@@ -46,8 +46,8 @@ function getSVGMatches(template) {
46
46
 
47
47
  function getSVGBlock(input, blockCounter) {
48
48
  return {
49
- usage: `\${blockSVG${blockCounter}(context)}`,
50
- definition: `\nconst blockSVG${blockCounter} = (context) => {return svg\`${input}\`};`,
49
+ usage: `\${blockSVG${blockCounter}(context, tags, suffix)}`,
50
+ definition: `\nconst blockSVG${blockCounter} = (context, tags, suffix) => svg\`${input}\`;`,
51
51
  };
52
52
  }
53
53
 
@@ -55,7 +55,7 @@ function replaceInternalBlocks(template, svgContent) {
55
55
  const internalBlocks = svgContent.match(blockrx) || [];
56
56
 
57
57
  internalBlocks.forEach(blockName => {
58
- const rx = new RegExp(`const ${blockName}.*(html\`).*};`);
58
+ const rx = new RegExp(`const ${blockName}.*(html\`).*;`);
59
59
  template = template.replace(rx, (match, p1) => {
60
60
  return match.replace(p1, "svg\`");
61
61
  });
@@ -1,10 +1,10 @@
1
1
  const buildRenderer = (controlName, litTemplate) => {
2
- return `
3
- /* eslint no-unused-vars: 0 */
4
- import ifDefined from '@ui5/webcomponents-base/dist/renderer/ifDefined.js';
5
- import { html, svg, repeat, classMap, styleMap } from '@ui5/webcomponents-base/dist/renderer/LitRenderer.js';
2
+ return `/* eslint no-unused-vars: 0 */
3
+ import { html, svg, repeat, classMap, styleMap, ifDefined, unsafeHTML, scopeTag } from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
4
+
6
5
  ${litTemplate}
7
- export default block0;`
6
+
7
+ export default block0;`;
8
8
  };
9
9
 
10
10
  module.exports = {
@@ -3,6 +3,8 @@ const getopts = require('getopts');
3
3
  const hbs2lit = require('../hbs2lit');
4
4
  const path = require('path');
5
5
  const litRenderer = require('./RenderTemplates/LitRenderer');
6
+ const recursiveReadDir = require("recursive-readdir");
7
+ const mkdirp = require('mkdirp');
6
8
 
7
9
  const args = getopts(process.argv.slice(2), {
8
10
  alias: {
@@ -18,32 +20,34 @@ const args = getopts(process.argv.slice(2), {
18
20
 
19
21
  const onError = (place) => {
20
22
  console.log(`A problem occoured when reading ${place}. Please recheck passed parameters.`);
21
- }
23
+ };
24
+
22
25
  const isHandlebars = (fileName) => fileName.indexOf('.hbs') !== -1;
23
- const parseFile = (filePath, inputDir, outputDir) => {
24
- fs.readFile(filePath, 'utf-8', (err, content) => {
25
26
 
26
- if (err) {
27
- onError('file');
28
- }
27
+ const processFile = (file, outputDir) => {
28
+ const litCode = hbs2lit(file);
29
+ const absoluteOutputDir = composeAbsoluteOutputDir(file, outputDir);
30
+ const componentNameMatcher = /(\w+)(\.hbs)/gim;
31
+ const componentName = componentNameMatcher.exec(file)[1];
29
32
 
30
- hbs2lit.compileString(content, {
31
- templatesPath: inputDir,
32
- compiledTemplatesPath: outputDir
33
- }).then((litCode) => {
34
- const componentNameMatcher = /(\w+)(\.hbs)/gim;
35
- const componentName = componentNameMatcher.exec(filePath)[1];
33
+ writeRenderers(absoluteOutputDir, componentName, litRenderer.generateTemplate(componentName, litCode));
34
+ };
36
35
 
37
- writeRenderers(outputDir, componentName, litRenderer.generateTemplate(componentName, litCode));
38
- });
39
- });
40
- }
36
+ const composeAbsoluteOutputDir = (file, outputDir) => {
37
+ // (1) Extract the dir structure from the source file path - "src/lvl1/lvl2/MyCompBadge.hbs"
38
+ // - remove the filename - "src/lvl1/lvl2"
39
+ // - remove the leading dir - "lvl1/lvl2"
40
+ const fileDir = file.split(path.sep).slice(1, -1).join(path.sep);
41
+
42
+ // (2) Compose full output dir - "dist/generated/templates/lvl1/lvl2"
43
+ return `${outputDir}${path.sep}${fileDir}`;
44
+ };
41
45
 
42
46
  const wrapDirectory = (directory, outputDir) => {
43
47
  directory = path.normalize(directory);
44
48
  outputDir = path.normalize(outputDir);
45
49
 
46
- fs.readdir(directory, (err, files) => {
50
+ recursiveReadDir(directory, (err, files) => {
47
51
 
48
52
  if (err) {
49
53
  onError('directory');
@@ -51,9 +55,7 @@ const wrapDirectory = (directory, outputDir) => {
51
55
 
52
56
  files.forEach(fileName => {
53
57
  if (isHandlebars(fileName)) {
54
-
55
- // could be refactored a bit
56
- parseFile(directory + fileName, directory, outputDir);
58
+ processFile(fileName, outputDir);
57
59
  }
58
60
  });
59
61
  })
@@ -61,6 +63,10 @@ const wrapDirectory = (directory, outputDir) => {
61
63
 
62
64
  const writeRenderers = (outputDir, controlName, fileContent) => {
63
65
  try {
66
+ if (!fs.existsSync(outputDir)) {
67
+ mkdirp.sync(outputDir);
68
+ }
69
+
64
70
  const compiledFilePath = `${outputDir}${path.sep}${controlName}Template.lit.js`;
65
71
 
66
72
  // strip DOS line endings because the break the source maps
@@ -1,7 +1,13 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
  const PropertiesReader = require('properties-reader');
4
+ const mkdirp = require("mkdirp");
5
+ const assets = require('../../assets-meta.js');
6
+
7
+ const defaultLanguage = assets.languages.default;
8
+
4
9
  const messageBundle = path.normalize(`${process.argv[2]}/messagebundle.properties`);
10
+ const messageBundleDefaultLanguage = path.normalize(`${process.argv[2]}/messagebundle_${defaultLanguage}.properties`);
5
11
  const outputFile = path.normalize(`${process.argv[3]}/i18n-defaults.js`);
6
12
 
7
13
  if (!messageBundle || !outputFile) {
@@ -10,6 +16,13 @@ if (!messageBundle || !outputFile) {
10
16
 
11
17
  const properties = PropertiesReader(messageBundle)._properties;
12
18
 
19
+ let defaultLanguageProperties;
20
+ try {
21
+ defaultLanguageProperties = PropertiesReader(messageBundleDefaultLanguage)._properties;
22
+ }
23
+ catch (e) {}
24
+
25
+
13
26
  /*
14
27
  * Returns the single text object to enable single export.
15
28
  *
@@ -19,7 +32,12 @@ const properties = PropertiesReader(messageBundle)._properties;
19
32
  * defaultText: "Card Content",
20
33
  * };
21
34
  */
22
- const getTextInfo = (key, value) => `const ${key} = {key: "${key}", defaultText: "${value}"};`;
35
+ const getTextInfo = (key, value, defaultLanguageValue) => {
36
+ let effectiveValue = defaultLanguageValue || value;
37
+ effectiveValue = effectiveValue.replace(/\"/g, "\\\""); // escape double quotes in translations
38
+
39
+ return `const ${key} = {key: "${key}", defaultText: "${effectiveValue}"};`;
40
+ };
23
41
 
24
42
  /*
25
43
  * Returns the complete content of i18n-defaults.js file:
@@ -31,13 +49,13 @@ const getTextInfo = (key, value) => `const ${key} = {key: "${key}", defaultText:
31
49
  * ARIA_LABEL_CARD_CONTENT,
32
50
  * }
33
51
  */
34
- const getOutputFileContent = (properties) => {
52
+ const getOutputFileContent = (properties, defaultLanguageProperties) => {
35
53
  const textKeys = Object.keys(properties);
36
- const texts = textKeys.map(prop => getTextInfo(prop, properties[prop])).join('');
54
+ const texts = textKeys.map(prop => getTextInfo(prop, properties[prop], defaultLanguageProperties && defaultLanguageProperties[prop])).join('');
37
55
 
38
56
  return `${texts}
39
57
  export {${textKeys.join()}};`;
40
- }
58
+ };
41
59
 
42
60
  /*
43
61
  * Writes the i18n-defaults.js.
@@ -50,6 +68,7 @@ const writeI18nDefaultsFile = (file, content) => {
50
68
 
51
69
  console.log(`[i18n]: "${file}" file has been created`);
52
70
  });
53
- }
71
+ };
54
72
 
55
- writeI18nDefaultsFile(outputFile, getOutputFileContent(properties));
73
+ mkdirp.sync(path.dirname(outputFile));
74
+ writeI18nDefaultsFile(outputFile, getOutputFileContent(properties, defaultLanguageProperties));
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Execution (note: the paths depends on the the execution context)
5
5
  * node toJSON.js ../../src/assets/i18n ../../dist/generated/assets/i18n
6
- *
6
+ *
7
7
  * The 1st param '../../src/assets/i18n' is the location of messagebundle_*.properties files
8
8
  * The 2nd param './../dist/generated/assets/i18n' is where the JSON files would be written to.
9
9
  */
@@ -11,21 +11,32 @@ const path = require("path");
11
11
  const glob = require("glob");
12
12
  const PropertiesReader = require('properties-reader');
13
13
  const fs = require('fs');
14
+ const assets = require('../../assets-meta.js');
15
+ const mkdirp = require("mkdirp");
16
+
17
+ const allLanguages = assets.languages.all;
18
+
14
19
  const messagesBundles = path.normalize(`${process.argv[2]}/messagebundle_*.properties`);
15
20
  const messagesJSONDist = path.normalize(`${process.argv[3]}`);
16
21
 
17
22
  const convertToJSON = (file) => {
18
23
  const properties = PropertiesReader(file)._properties;
19
24
  const filename = path.basename(file, path.extname(file));
25
+ const language = filename.match(/^messagebundle_(.*?)$/)[1];
26
+ if (!allLanguages.includes(language)) {
27
+ console.log("Not supported language: ", language);
28
+ return;
29
+ }
20
30
  const outputFile = path.normalize(`${messagesJSONDist}/${filename}.json`);
21
31
 
22
32
  fs.writeFileSync(outputFile, JSON.stringify(properties));
23
- console.log(`[i18n]: "${filename}.json" has been generated!`);
24
- }
33
+ // console.log(`[i18n]: "${filename}.json" has been generated!`);
34
+ };
25
35
 
36
+ mkdirp.sync(messagesJSONDist);
26
37
  glob(messagesBundles, {}, (err, files) => {
27
38
  if (err) {
28
39
  return console.log("No messagebundle files found!");
29
40
  }
30
41
  files.forEach(convertToJSON);
31
- });
42
+ });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "source": {
3
3
  "include": "src",
4
- "excludePattern": "(/|\\\\)library-all\\.js|(/|\\\\).*-preload\\.js|^jquery-.*\\.js|^sap-.*\\.js|.+Renderer\\.lit\\.js|.*library\\.js"
4
+ "excludePattern": "(/|\\\\)library-all\\.js|(/|\\\\).*-preload\\.js|^jquery-.*\\.js|^sap-.*\\.js|.+Renderer\\.lit\\.js|.*library\\.js|thirdparty"
5
5
  },
6
6
  "opts" : {
7
7
  "recurse": true,
@@ -29,7 +29,11 @@
29
29
  *
30
30
  * appenddocs
31
31
  *
32
- * customtag
32
+ * tagname
33
+ *
34
+ * native
35
+ *
36
+ * allowPreventDefault
33
37
  *
34
38
  * It furthermore listens to the following JSDoc3 events to implement additional functionality
35
39
  *
@@ -2060,9 +2064,11 @@ exports.defineTags = function(dictionary) {
2060
2064
  });
2061
2065
 
2062
2066
  dictionary.defineTag('slot', {
2063
- mustNotHaveValue: true,
2064
2067
  onTagged: function(doclet, tag) {
2065
2068
  doclet.slot = true;
2069
+ if (tag.value) {
2070
+ doclet.propertyName = tag.value;
2071
+ }
2066
2072
  }
2067
2073
  });
2068
2074
 
@@ -2073,10 +2079,24 @@ exports.defineTags = function(dictionary) {
2073
2079
  }
2074
2080
  });
2075
2081
 
2076
- dictionary.defineTag('customtag', {
2082
+ dictionary.defineTag('tagname', {
2077
2083
  mustHaveValue: true,
2078
2084
  onTagged: function(doclet, tag) {
2079
- doclet.customtag = tag.value;
2085
+ doclet.tagname = tag.value;
2086
+ }
2087
+ });
2088
+
2089
+ dictionary.defineTag('allowPreventDefault', {
2090
+ mustHaveValue: false,
2091
+ onTagged: function(doclet, tag) {
2092
+ doclet.allowPreventDefault = true;
2093
+ }
2094
+ });
2095
+
2096
+ dictionary.defineTag('native', {
2097
+ mustHaveValue: false,
2098
+ onTagged: function(doclet, tag) {
2099
+ doclet.native = true;
2080
2100
  }
2081
2101
  });
2082
2102
  };
@@ -2651,8 +2651,8 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
2651
2651
 
2652
2652
  attrib("name", symbol.longname);
2653
2653
  attrib("basename", symbol.name);
2654
- if (symbol.customtag) {
2655
- attrib("customTag", symbol.customtag);
2654
+ if (symbol.tagname) {
2655
+ attrib("tagname", symbol.tagname);
2656
2656
  }
2657
2657
  if (symbol.appenddocs) {
2658
2658
  attrib("appenddocs", symbol.appenddocs);
@@ -2838,6 +2838,9 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
2838
2838
  if (member.slot) {
2839
2839
  tag("property");
2840
2840
  attrib("name", member.name);
2841
+ if (member.propertyName) {
2842
+ attrib("propertyName", member.propertyName);
2843
+ }
2841
2844
  if (member.__ui5.module && member.__ui5.module !== symbol.__ui5.module) {
2842
2845
  attrib("module", member.__ui5.module);
2843
2846
  attrib("export", undefined, '', true);
@@ -2879,6 +2882,12 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
2879
2882
  attrib("module", member.__ui5.module);
2880
2883
  attrib("export", undefined, '', true);
2881
2884
  }
2885
+ if (member.allowPreventDefault) {
2886
+ attrib("allowPreventDefault", true);
2887
+ }
2888
+ if (member.native) {
2889
+ attrib("native", true);
2890
+ }
2882
2891
  attrib("visibility", visibility(member), 'public');
2883
2892
  if ( member.scope === 'static' ) {
2884
2893
  attrib("static", true, false, /* raw = */true);
@@ -0,0 +1,5 @@
1
+ const mkdirp = require("mkdirp");
2
+ const fs = require("fs");
3
+
4
+ mkdirp.sync("dist/webcomponentsjs/");
5
+ fs.writeFileSync("dist/webcomponentsjs/webcomponents-loader.js", "");