@ui5/webcomponents-tools 0.0.0-389bdbabc → 0.0.0-453158269

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 +244 -1
  2. package/README.md +1 -1
  3. package/assets-meta.js +153 -0
  4. package/bin/dev.js +16 -1
  5. package/components-package/nps.js +62 -34
  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 +101 -65
  10. package/components-package/wdio.sync.js +360 -0
  11. package/icons-collection/nps.js +66 -28
  12. package/lib/copy-and-watch/index.js +145 -0
  13. package/lib/copy-list/index.js +28 -0
  14. package/lib/create-icons/index.js +82 -50
  15. package/lib/create-illustrations/index.js +161 -0
  16. package/lib/create-new-component/index.js +18 -6
  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 +98 -47
  22. package/lib/generate-json-imports/themes.js +71 -16
  23. package/lib/hbs2lit/index.js +2 -4
  24. package/lib/hbs2lit/src/compiler.js +18 -8
  25. package/lib/hbs2lit/src/includesReplacer.js +23 -17
  26. package/lib/hbs2lit/src/litVisitor2.js +57 -11
  27. package/lib/hbs2lit/src/svgProcessor.js +3 -3
  28. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +5 -5
  29. package/lib/hbs2ui5/index.js +52 -30
  30. package/lib/i18n/defaults.js +63 -52
  31. package/lib/i18n/toJSON.js +25 -13
  32. package/lib/jsdoc/config.json +1 -1
  33. package/lib/jsdoc/plugin.js +33 -4
  34. package/lib/jsdoc/template/publish.js +24 -4
  35. package/lib/postcss-combine-duplicated-selectors/index.js +178 -0
  36. package/lib/postcss-css-to-esm/index.js +31 -19
  37. package/lib/postcss-css-to-json/index.js +27 -11
  38. package/lib/postcss-new-files/index.js +36 -0
  39. package/lib/postcss-p/postcss-p.mjs +11 -0
  40. package/lib/replace-global-core/index.js +25 -0
  41. package/lib/scoping/get-all-tags.js +44 -0
  42. package/lib/scoping/lint-src.js +31 -0
  43. package/lib/scoping/missing-dependencies.js +65 -0
  44. package/lib/scoping/report-tags-usage.js +28 -0
  45. package/lib/scoping/scope-test-pages.js +40 -0
  46. package/lib/serve/index.js +46 -0
  47. package/{components-package → lib/serve}/serve.json +0 -0
  48. package/package-lock.json +48 -0
  49. package/package.json +49 -55
  50. package/bin/init-ui5-package.js +0 -3
  51. package/lib/init-package/index.js +0 -119
  52. package/lib/init-package/resources/.eslintignore +0 -3
  53. package/lib/init-package/resources/bundle.es5.js +0 -25
  54. package/lib/init-package/resources/bundle.esm.js +0 -34
  55. package/lib/init-package/resources/config/.eslintrc.js +0 -1
  56. package/lib/init-package/resources/config/postcss.components/postcss.config.js +0 -1
  57. package/lib/init-package/resources/config/postcss.themes/postcss.config.js +0 -1
  58. package/lib/init-package/resources/config/rollup.config.js +0 -1
  59. package/lib/init-package/resources/config/wdio.conf.js +0 -1
  60. package/lib/init-package/resources/package-scripts.js +0 -11
  61. package/lib/init-package/resources/src/Assets.js +0 -6
  62. package/lib/init-package/resources/src/Demo.hbs +0 -1
  63. package/lib/init-package/resources/src/Demo.js +0 -57
  64. package/lib/init-package/resources/src/i18n/messagebundle.properties +0 -2
  65. package/lib/init-package/resources/src/i18n/messagebundle_de.properties +0 -1
  66. package/lib/init-package/resources/src/i18n/messagebundle_en.properties +0 -1
  67. package/lib/init-package/resources/src/i18n/messagebundle_es.properties +0 -1
  68. package/lib/init-package/resources/src/i18n/messagebundle_fr.properties +0 -1
  69. package/lib/init-package/resources/src/themes/Demo.css +0 -11
  70. package/lib/init-package/resources/src/themes/sap_belize/parameters-bundle.css +0 -3
  71. package/lib/init-package/resources/src/themes/sap_belize_hcb/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;
@@ -57,7 +57,7 @@ exports.config = {
57
57
  // to run chrome headless the following flags are required
58
58
  // (see https://developers.google.com/web/updates/2017/04/headless-chrome)
59
59
  args: ['--headless', '--disable-gpu'],
60
- //args: ['--disable-gpu'],
60
+ // args: ['--disable-gpu'],
61
61
  }
62
62
  }],
63
63
  //
@@ -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,46 +152,24 @@ 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("findElementDeep", function (selector) {
157
- const selectors = selector.split(">>>");
155
+ before: async function (capabilities, specs) {
156
+ await browser.addCommand("isFocusedDeep", async function () {
157
+ return browser.executeAsync(function (elem, done) {
158
+ let activeElement = document.activeElement;
158
159
 
159
- for (var i = 0; i < selectors.length; i++) {
160
- if (i === 0) {
161
- curElement = browser.$(selectors[i]);
162
- continue;
160
+ while (activeElement.shadowRoot) {
161
+ if (activeElement.shadowRoot.activeElement) {
162
+ activeElement = activeElement.shadowRoot.activeElement;
163
+ } else {
164
+ break;
165
+ }
163
166
  }
167
+ done(elem === activeElement);
168
+ }, this);
169
+ }, true);
164
170
 
165
- // wait for the shadowDom to be filled before executing the selector
166
- browser.executeAsync(function (elem, done) {
167
- elem._waitForDomRef().then(done);
168
- }, curElement);
169
-
170
- // find the next element from the selector
171
- curElement = curElement.$(new Function (`
172
- return this.shadowRoot.querySelector("${selectors[i]}");
173
- `));
174
- }
175
-
176
- return curElement;
177
-
178
- });
179
-
180
- browser.addCommand("findElementDeep", function (selector) {
181
- const selectors = selector.split(">>>");
182
- let curElement = this;
183
-
184
- for (var i = 0; i < selectors.length; i++) {
185
- curElement = curElement.$(new Function (`
186
- return this.shadowRoot.querySelector("${selectors[i]}");
187
- `));
188
- }
189
-
190
- return curElement;
191
- }, this);
192
-
193
- browser.addCommand("isFocusedDeep", function () {
194
- return browser.execute(function (elem) {
171
+ await browser.addCommand("isFocusedDeepElement", async function (element) {
172
+ return browser.executeAsync(function (elem, element, done) {
195
173
  let activeElement = document.activeElement;
196
174
 
197
175
  while (activeElement.shadowRoot) {
@@ -201,47 +179,82 @@ exports.config = {
201
179
  break;
202
180
  }
203
181
  }
204
- return elem === activeElement;
205
- }, this);
182
+ done(element === activeElement);
183
+ }, this, element);
206
184
  }, true);
207
185
 
208
- browser.addCommand("setProperty", function(property, value) {
209
- return browser.execute((elem, property, value) => {
210
- return elem[property] = value;
186
+ await browser.addCommand("setProperty", async function(property, value) {
187
+ return browser.executeAsync((elem, property, value, done) => {
188
+ elem[property] = value;
189
+ done();
211
190
  }, this, property, value);
212
191
  }, true);
213
192
 
214
- browser.addCommand("setAttribute", function(attribute, value) {
215
- return browser.execute((elem, attribute, value) => {
216
- 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();
217
197
  }, this, attribute, value);
218
198
  }, true);
219
199
 
220
- browser.addCommand("removeAttribute", function(attribute) {
221
- return browser.execute((elem, attribute) => {
222
- 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();
223
204
  }, this, attribute);
224
205
  }, true);
225
206
 
226
- browser.addCommand("hasClass", function(className) {
227
- return browser.execute((elem, className) => {
228
- 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));
229
210
  }, this, className);
230
211
  }, true);
231
212
 
232
- browser.addCommand("getStaticAreaItemClassName", function(selector) {
233
- return browser.execute((selector) => {
234
- return document.querySelector(selector).getStaticAreaItemDomRef().host.classList[0];
213
+ await browser.addCommand("getStaticAreaItemClassName", async function(selector) {
214
+ return browser.executeAsync(async (selector, done) => {
215
+ const staticAreaItem = await document.querySelector(selector).getStaticAreaItemDomRef();
216
+ done(staticAreaItem.host.classList[0]);
235
217
  }, selector);
236
218
  }, false);
219
+
220
+ await browser.addLocatorStrategy('activeElement', (selector) => {
221
+ return document.querySelector(selector).shadowRoot.activeElement;
222
+ });
237
223
  },
238
224
  /**
239
225
  * Runs before a WebdriverIO command gets executed.
240
226
  * @param {String} commandName hook command name
241
227
  * @param {Array} args arguments that command would receive
242
228
  */
243
- // beforeCommand: function (commandName, args) {
244
- // },
229
+ beforeCommand: async function (commandName, args) {
230
+ const waitFor = [
231
+ "$",
232
+ "$$",
233
+ "getAttribute",
234
+ "getCSSProperty",
235
+ "getHTML",
236
+ "getProperty",
237
+ "getSize",
238
+ "getStaticAreaItemClassName", // custom
239
+ "getText",
240
+ "getValue",
241
+ "hasClass", // custom
242
+ "isDisplayed",
243
+ "isDisplayedInViewport",
244
+ "isEnabled",
245
+ "isExisting",
246
+ "isFocused",
247
+ "isFocusedDeep", // custom
248
+ "isFocusedDeepElement", // custom
249
+ "shadow$",
250
+ "shadow$$",
251
+ ];
252
+ if (waitFor.includes(commandName)) {
253
+ await browser.executeAsync(function (done) {
254
+ window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
255
+ });
256
+ }
257
+ },
245
258
 
246
259
  /**
247
260
  * Hook that gets executed before the suite starts
@@ -287,13 +300,36 @@ exports.config = {
287
300
  * @param {Number} result 0 - command success, 1 - command error
288
301
  * @param {Object} error error object if any
289
302
  */
290
- afterCommand: function (commandName, args, result, error) {
291
- const waitFor = ["$", "$$", "shadow$", "click", "performActions", "elementClick", "keys", "sendKeys", "findElement", "elementClear", "elementSendKeys", "setValue", "addValue", "getHTML", "getProperty", "setAttribute", "removeAttribute", "getElementProperty"];
292
- if (waitFor.includes(commandName)) {
293
- browser.executeAsync(function (done) {
294
- // run all the tests in no conflict mode
303
+ afterCommand: async function (commandName, args, result, error) {
304
+
305
+ // url -> set configuration first
306
+ if (commandName === "url" && !args[0].includes("do-not-change-configuration")) {
307
+ await browser.executeAsync(function(done) {
295
308
  window["sap-ui-webcomponents-bundle"].configuration.setNoConflict(true);
296
- window.RenderScheduler.whenFinished().then(done);
309
+ done();
310
+ });
311
+ }
312
+
313
+ const waitFor = [
314
+ "addValue",
315
+ "clearValue",
316
+ "click",
317
+ "doubleClick",
318
+ "dragAndDrop",
319
+ "keys",
320
+ "pause",
321
+ "removeAttribute", // custom
322
+ "scrollIntoView",
323
+ "setAttribute", // custom
324
+ "setProperty", // custom
325
+ "setValue",
326
+ "setWindowSize",
327
+ "touchAction",
328
+ "url",
329
+ ];
330
+ if (waitFor.includes(commandName)) {
331
+ await browser.executeAsync(function (done) {
332
+ window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
297
333
  });
298
334
  }
299
335
  },