@ui5/webcomponents-tools 0.0.0-dff5837d7 → 0.0.0-ec448881d

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 (75) hide show
  1. package/CHANGELOG.md +208 -0
  2. package/README.md +1 -1
  3. package/assets-meta.js +18 -1
  4. package/bin/dev.js +10 -5
  5. package/components-package/nps.js +53 -26
  6. package/components-package/postcss.themes.js +6 -3
  7. package/components-package/rollup-plugins/empty-module.js +15 -0
  8. package/components-package/rollup.js +93 -77
  9. package/components-package/wdio.js +54 -29
  10. package/components-package/wdio.sync.js +360 -0
  11. package/icons-collection/nps.js +47 -9
  12. package/lib/copy-and-watch/index.js +30 -5
  13. package/lib/copy-list/index.js +28 -0
  14. package/lib/create-icons/index.js +82 -54
  15. package/lib/create-illustrations/index.js +161 -0
  16. package/lib/create-new-component/index.js +16 -4
  17. package/lib/documentation/index.js +124 -99
  18. package/lib/documentation/templates/api-properties-section.js +3 -1
  19. package/lib/documentation/templates/template.js +2 -1
  20. package/lib/esm-abs-to-rel/index.js +58 -0
  21. package/lib/generate-json-imports/i18n.js +74 -32
  22. package/lib/generate-json-imports/themes.js +64 -17
  23. package/lib/hbs2lit/src/compiler.js +12 -3
  24. package/lib/hbs2lit/src/includesReplacer.js +5 -5
  25. package/lib/hbs2lit/src/litVisitor2.js +43 -7
  26. package/lib/hbs2lit/src/svgProcessor.js +3 -3
  27. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +5 -5
  28. package/lib/hbs2ui5/index.js +50 -18
  29. package/lib/i18n/defaults.js +49 -57
  30. package/lib/i18n/toJSON.js +13 -12
  31. package/lib/jsdoc/config.json +1 -1
  32. package/lib/jsdoc/plugin.js +33 -4
  33. package/lib/jsdoc/template/publish.js +24 -4
  34. package/lib/postcss-combine-duplicated-selectors/index.js +178 -0
  35. package/lib/postcss-css-to-esm/index.js +19 -16
  36. package/lib/postcss-css-to-json/index.js +20 -11
  37. package/lib/postcss-new-files/index.js +36 -0
  38. package/lib/postcss-p/postcss-p.mjs +11 -0
  39. package/lib/replace-global-core/index.js +25 -0
  40. package/lib/scoping/get-all-tags.js +44 -0
  41. package/lib/scoping/lint-src.js +31 -0
  42. package/lib/scoping/missing-dependencies.js +65 -0
  43. package/lib/scoping/report-tags-usage.js +28 -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-lock.json +48 -0
  48. package/package.json +47 -53
  49. package/bin/init-ui5-package.js +0 -3
  50. package/lib/init-package/index.js +0 -112
  51. package/lib/init-package/resources/.eslintignore +0 -3
  52. package/lib/init-package/resources/bundle.es5.js +0 -25
  53. package/lib/init-package/resources/bundle.esm.js +0 -34
  54. package/lib/init-package/resources/config/.eslintrc.js +0 -1
  55. package/lib/init-package/resources/config/postcss.components/postcss.config.js +0 -1
  56. package/lib/init-package/resources/config/postcss.themes/postcss.config.js +0 -1
  57. package/lib/init-package/resources/config/rollup.config.js +0 -1
  58. package/lib/init-package/resources/config/wdio.conf.js +0 -1
  59. package/lib/init-package/resources/package-scripts.js +0 -11
  60. package/lib/init-package/resources/src/Assets.js +0 -5
  61. package/lib/init-package/resources/src/Demo.hbs +0 -1
  62. package/lib/init-package/resources/src/Demo.js +0 -56
  63. package/lib/init-package/resources/src/i18n/messagebundle.properties +0 -2
  64. package/lib/init-package/resources/src/i18n/messagebundle_de.properties +0 -1
  65. package/lib/init-package/resources/src/i18n/messagebundle_en.properties +0 -1
  66. package/lib/init-package/resources/src/i18n/messagebundle_es.properties +0 -1
  67. package/lib/init-package/resources/src/i18n/messagebundle_fr.properties +0 -1
  68. package/lib/init-package/resources/src/themes/Demo.css +0 -11
  69. package/lib/init-package/resources/src/themes/sap_belize/parameters-bundle.css +0 -3
  70. package/lib/init-package/resources/src/themes/sap_belize_hcb/parameters-bundle.css +0 -3
  71. package/lib/init-package/resources/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
  72. package/lib/init-package/resources/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
  73. package/lib/init-package/resources/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
  74. package/lib/init-package/resources/test/pages/index.html +0 -51
  75. package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
@@ -1,16 +1,21 @@
1
- const babel = require("rollup-plugin-babel");
2
1
  const process = require("process");
3
- const resolve = require("rollup-plugin-node-resolve");
4
- const url = require("rollup-plugin-url");
5
- const { terser } = require("rollup-plugin-terser");
6
- const notify = require('rollup-plugin-notify');
7
- const filesize = require('rollup-plugin-filesize');
8
- const livereload = require('rollup-plugin-livereload');
9
- const os = require("os");
10
2
  const fs = require("fs");
3
+ const os = require("os");
4
+ const { nodeResolve } = require("@rollup/plugin-node-resolve");
5
+ const { terser } = require("rollup-plugin-terser");
6
+ const json = require("@rollup/plugin-json");
7
+ const replace = require("@rollup/plugin-replace");
8
+ const colors = require("cli-color");
9
+ const livereload = require("rollup-plugin-livereload");
10
+ const emptyModulePlugin = require("./rollup-plugins/empty-module.js");
11
11
 
12
- const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
13
- const DEPLOY_PUBLIC_PATH = process.env.DEPLOY_PUBLIC_PATH || "";
12
+ const packageFile = JSON.parse(fs.readFileSync("./package.json"));
13
+ const packageName = packageFile.name;
14
+
15
+ const warningsToSkip = [{
16
+ warningCode: "THIS_IS_UNDEFINED",
17
+ filePath: /.+zxing.+/,
18
+ }];
14
19
 
15
20
  function ui5DevImportCheckerPlugin() {
16
21
  return {
@@ -20,115 +25,126 @@ function ui5DevImportCheckerPlugin() {
20
25
  if (re.test(code)) {
21
26
  throw new Error(`illegal import in ${file}`);
22
27
  }
23
- }
28
+ },
24
29
  };
25
30
  }
26
31
 
27
- const getPlugins = ({ transpile }) => {
28
- const plugins = [];
29
- let publicPath = DEPLOY_PUBLIC_PATH || "/resources/";
32
+ function onwarn(warning, warn) {
33
+ // Skip warning for known false positives that will otherwise polute the log
34
+ let skip = warningsToSkip.find(warningToSkip => {
35
+ let loc, file;
36
+ return warning.code === warningToSkip.warningCode
37
+ && (loc = warning.loc)
38
+ && (file = loc.file)
39
+ && file.match(warningToSkip.filePath);
40
+ });
41
+ if (skip) {
42
+ return;
43
+ }
30
44
 
31
- if (!process.env.DEV) {
32
- plugins.push(filesize({
33
- render : function (options, bundle, { minSize, gzipSize, brotliSize, bundleSize }){
34
- return gzipSize;
45
+ // warn everything else
46
+ warn( warning );
47
+ }
48
+
49
+ const reportedForPackages = new Set(); // sometimes writeBundle is called more than once per bundle -> suppress extra messages
50
+ function ui5DevReadyMessagePlugin() {
51
+ return {
52
+ name: "ui5-dev-message-ready-plugin",
53
+ writeBundle: (assets, bundle) => {
54
+ if (reportedForPackages.has(packageName)) {
55
+ return;
35
56
  }
57
+ console.log(colors.blue(`${colors.bold(packageName)} successfully built!`));
58
+
59
+ if (fs.existsSync(".port")) {
60
+ const port = `${fs.readFileSync(".port")}`;
61
+ if (port) {
62
+ console.log(colors.blue(`Navigate to: ${colors.bold(`http://localhost:${port}/test-resources/pages/`)}`));
63
+ }
64
+ }
65
+ reportedForPackages.add(packageName);
66
+ },
67
+ };
68
+ }
69
+
70
+ const getPlugins = () => {
71
+ const plugins = [];
72
+
73
+ if (process.env.DEV) {
74
+ plugins.push(replace({
75
+ values: {
76
+ 'const DEV_MODE = false': 'const DEV_MODE = true',
77
+ },
78
+ preventAssignment: false,
79
+ }));
80
+ }
81
+
82
+ if (process.env.DEV && !process.env.ENABLE_CLDR) {
83
+ // Empty the CLDR assets file for better performance during development
84
+ plugins.push(emptyModulePlugin({
85
+ emptyModules: [
86
+ "localization/dist/Assets.js",
87
+ ],
36
88
  }));
37
89
  }
38
90
 
39
91
  plugins.push(ui5DevImportCheckerPlugin());
40
92
 
41
- plugins.push(url({
42
- limit: 0,
93
+ plugins.push(json({
43
94
  include: [
44
- /.*assets\/.*\.json/
95
+ /.*assets\/.*\.json/,
45
96
  ],
46
- emitFiles: true,
47
- fileName: "[name].[hash][extname]",
48
- publicPath,
97
+ namedExports: false,
49
98
  }));
50
99
 
51
-
52
- if (transpile) {
53
- plugins.push(babel({
54
- presets: ["@babel/preset-env"],
55
- exclude: "node_modules/**",
56
- sourcemap: true,
57
- }));
58
- }
59
-
60
- plugins.push(resolve());
100
+ plugins.push(nodeResolve());
61
101
 
62
102
  if (!process.env.DEV) {
63
- plugins.push(terser());
64
- }
65
-
66
- if (process.env.DEV) {
67
- plugins.push(notify());
103
+ plugins.push(terser({
104
+ numWorkers: 1,
105
+ }));
68
106
  }
69
107
 
70
- const es6DevMain = process.env.DEV && !transpile && packageName === "@ui5/webcomponents";
108
+ const es6DevMain = process.env.DEV && packageName === "@ui5/webcomponents";
71
109
  if (es6DevMain && os.platform() !== "win32") {
72
110
  plugins.push(livereload({
73
111
  watch: [
74
112
  "dist/resources/bundle.esm.js",
75
113
  "dist/**/*.html",
76
114
  "dist/**/*.json",
77
- ]
115
+ ],
78
116
  }));
79
117
  }
80
118
 
119
+ if (process.env.DEV) {
120
+ plugins.push(ui5DevReadyMessagePlugin());
121
+ }
122
+
81
123
  return plugins;
82
124
  };
83
125
 
84
- const getES6Config = () => {
126
+ const getES6Config = (input = "bundle.esm.js") => {
85
127
  return [{
86
- input: "bundle.esm.js",
128
+ input,
87
129
  output: {
88
130
  dir: "dist/resources",
89
131
  format: "esm",
90
- sourcemap: true
91
- },
92
- moduleContext: (id) => {
93
- if (id.includes("url-search-params-polyfill")) {
94
- // suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
95
- return "window";
96
- }
97
- },
98
- watch: {
99
- clearScreen: false
100
- },
101
- plugins: getPlugins({transpile: false}),
102
- }];
103
- };
104
-
105
- const getES5Config = () => {
106
- return [ {
107
- input: "bundle.es5.js",
108
- output: {
109
- dir: "dist/resources",
110
- format: "iife",
111
- name: "sap-ui-webcomponents-bundle",
112
- extend: "true", // Whether or not to extend the global variable defined by the name option in umd or iife formats.
113
- sourcemap: true
114
- },
115
- moduleContext: (id) => {
116
- if (id.includes("url-search-params-polyfill")) {
117
- // suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
118
- return "window";
119
- }
132
+ sourcemap: true,
120
133
  },
121
134
  watch: {
122
- clearScreen: false
135
+ clearScreen: false,
123
136
  },
124
- plugins: getPlugins({transpile: true}),
137
+ plugins: getPlugins(),
138
+ onwarn: onwarn,
125
139
  }];
126
140
  };
127
141
 
128
142
  let config = getES6Config();
129
143
 
130
- if (process.env.ES5_BUILD) {
131
- config = config.concat(getES5Config());
144
+ if (process.env.SCOPE) {
145
+ if (fs.existsSync("bundle.scoped.esm.js")) {
146
+ config = config.concat(getES6Config("bundle.scoped.esm.js"));
147
+ }
132
148
  }
133
149
 
134
150
  module.exports = config;
@@ -82,7 +82,7 @@ exports.config = {
82
82
  // with `/`, the base url gets prepended, not including the path portion of your baseUrl.
83
83
  // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
84
84
  // gets prepended directly.
85
- baseUrl: '',
85
+ baseUrl: undefined, // This is important since WDIO 7+ does not accept an empty string for baseUrl
86
86
  path: '',
87
87
  //
88
88
  // Default timeout for all waitFor* commands.
@@ -99,7 +99,7 @@ exports.config = {
99
99
  // Services take over a specific job you don't want to take care of. They enhance
100
100
  // your test setup with almost no effort. Unlike plugins, they don't add new
101
101
  // commands. Instead, they hook themselves up into the test process.
102
- services: ['chromedriver'],
102
+ services: ['chromedriver', 'devtools'],
103
103
  // options
104
104
  chromeDriverArgs: ['--port=9515'], // default
105
105
  // Framework you want to run your specs with.
@@ -152,9 +152,9 @@ exports.config = {
152
152
  * @param {Array.<Object>} capabilities list of capabilities details
153
153
  * @param {Array.<String>} specs List of spec file paths that are to be run
154
154
  */
155
- before: function (capabilities, specs) {
156
- browser.addCommand("isFocusedDeep", function () {
157
- return browser.execute(function (elem) {
155
+ before: async function (capabilities, specs) {
156
+ await browser.addCommand("isFocusedDeep", async function () {
157
+ return browser.executeAsync(function (elem, done) {
158
158
  let activeElement = document.activeElement;
159
159
 
160
160
  while (activeElement.shadowRoot) {
@@ -164,47 +164,69 @@ exports.config = {
164
164
  break;
165
165
  }
166
166
  }
167
- return elem === activeElement;
167
+ done(elem === activeElement);
168
168
  }, this);
169
169
  }, true);
170
170
 
171
- browser.addCommand("setProperty", function(property, value) {
172
- return browser.execute((elem, property, value) => {
173
- return elem[property] = value;
171
+ await browser.addCommand("isFocusedDeepElement", async function (element) {
172
+ return browser.executeAsync(function (elem, element, done) {
173
+ let activeElement = document.activeElement;
174
+
175
+ while (activeElement.shadowRoot) {
176
+ if (activeElement.shadowRoot.activeElement) {
177
+ activeElement = activeElement.shadowRoot.activeElement;
178
+ } else {
179
+ break;
180
+ }
181
+ }
182
+ done(element === activeElement);
183
+ }, this, element);
184
+ }, true);
185
+
186
+ await browser.addCommand("setProperty", async function(property, value) {
187
+ return browser.executeAsync((elem, property, value, done) => {
188
+ elem[property] = value;
189
+ done();
174
190
  }, this, property, value);
175
191
  }, true);
176
192
 
177
- browser.addCommand("setAttribute", function(attribute, value) {
178
- return browser.execute((elem, attribute, value) => {
179
- return elem.setAttribute(attribute, value);
193
+ await browser.addCommand("setAttribute", async function(attribute, value) {
194
+ return browser.executeAsync((elem, attribute, value, done) => {
195
+ elem.setAttribute(attribute, value);
196
+ done();
180
197
  }, this, attribute, value);
181
198
  }, true);
182
199
 
183
- browser.addCommand("removeAttribute", function(attribute) {
184
- return browser.execute((elem, attribute) => {
185
- return elem.removeAttribute(attribute);
200
+ await browser.addCommand("removeAttribute", async function(attribute) {
201
+ return browser.executeAsync((elem, attribute, done) => {
202
+ elem.removeAttribute(attribute);
203
+ done();
186
204
  }, this, attribute);
187
205
  }, true);
188
206
 
189
- browser.addCommand("hasClass", function(className) {
190
- return browser.execute((elem, className) => {
191
- return elem.classList.contains(className);
207
+ await browser.addCommand("hasClass", async function(className) {
208
+ return browser.executeAsync((elem, className, done) => {
209
+ done(elem.classList.contains(className));
192
210
  }, this, className);
193
211
  }, true);
194
212
 
195
- browser.addCommand("getStaticAreaItemClassName", function(selector) {
196
- return browser.execute(async (selector) => {
213
+ await browser.addCommand("getStaticAreaItemClassName", async function(selector) {
214
+ return browser.executeAsync(async (selector, done) => {
197
215
  const staticAreaItem = await document.querySelector(selector).getStaticAreaItemDomRef();
198
- return staticAreaItem.host.classList[0];
216
+ done(staticAreaItem.host.classList[0]);
199
217
  }, selector);
200
218
  }, false);
219
+
220
+ await browser.addLocatorStrategy('activeElement', (selector) => {
221
+ return document.querySelector(selector).shadowRoot.activeElement;
222
+ });
201
223
  },
202
224
  /**
203
225
  * Runs before a WebdriverIO command gets executed.
204
226
  * @param {String} commandName hook command name
205
227
  * @param {Array} args arguments that command would receive
206
228
  */
207
- beforeCommand: function (commandName, args) {
229
+ beforeCommand: async function (commandName, args) {
208
230
  const waitFor = [
209
231
  "$",
210
232
  "$$",
@@ -223,12 +245,13 @@ exports.config = {
223
245
  "isExisting",
224
246
  "isFocused",
225
247
  "isFocusedDeep", // custom
248
+ "isFocusedDeepElement", // custom
226
249
  "shadow$",
227
250
  "shadow$$",
228
251
  ];
229
252
  if (waitFor.includes(commandName)) {
230
- browser.executeAsync(function (done) {
231
- window.RenderScheduler.whenFinished().then(done);
253
+ await browser.executeAsync(function (done) {
254
+ window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
232
255
  });
233
256
  }
234
257
  },
@@ -277,12 +300,13 @@ exports.config = {
277
300
  * @param {Number} result 0 - command success, 1 - command error
278
301
  * @param {Object} error error object if any
279
302
  */
280
- afterCommand: function (commandName, args, result, error) {
303
+ afterCommand: async function (commandName, args, result, error) {
281
304
 
282
305
  // url -> set configuration first
283
306
  if (commandName === "url" && !args[0].includes("do-not-change-configuration")) {
284
- browser.execute(function() {
307
+ await browser.executeAsync(function(done) {
285
308
  window["sap-ui-webcomponents-bundle"].configuration.setNoConflict(true);
309
+ done();
286
310
  });
287
311
  }
288
312
 
@@ -295,16 +319,17 @@ exports.config = {
295
319
  "keys",
296
320
  "pause",
297
321
  "removeAttribute", // custom
322
+ "scrollIntoView",
298
323
  "setAttribute", // custom
299
324
  "setProperty", // custom
300
325
  "setValue",
301
326
  "setWindowSize",
302
327
  "touchAction",
303
- "url"
328
+ "url",
304
329
  ];
305
330
  if (waitFor.includes(commandName)) {
306
- browser.executeAsync(function (done) {
307
- window.RenderScheduler.whenFinished().then(done);
331
+ await browser.executeAsync(function (done) {
332
+ window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
308
333
  });
309
334
  }
310
335
  },