@ui5/webcomponents-tools 0.0.0-934b4df24 → 0.0.0-a3eca7ade

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 (77) hide show
  1. package/CHANGELOG.md +139 -0
  2. package/README.md +1 -1
  3. package/assets-meta.js +14 -1
  4. package/bin/dev.js +16 -1
  5. package/components-package/nps.js +65 -26
  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 +100 -28
  10. package/components-package/wdio.sync.js +360 -0
  11. package/icons-collection/nps.js +53 -9
  12. package/lib/copy-and-watch/index.js +6 -4
  13. package/lib/copy-list/index.js +28 -0
  14. package/lib/create-icons/index.js +40 -22
  15. package/lib/create-illustrations/index.js +150 -0
  16. package/lib/create-new-component/index.js +16 -4
  17. package/lib/documentation/index.js +42 -20
  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 +54 -0
  21. package/lib/generate-json-imports/i18n.js +58 -20
  22. package/lib/generate-json-imports/themes.js +53 -13
  23. package/lib/hash/config.js +10 -0
  24. package/lib/hash/generate.js +19 -0
  25. package/lib/hash/upToDate.js +31 -0
  26. package/lib/hbs2lit/index.js +2 -4
  27. package/lib/hbs2lit/src/compiler.js +7 -11
  28. package/lib/hbs2lit/src/includesReplacer.js +20 -9
  29. package/lib/hbs2lit/src/litVisitor2.js +43 -7
  30. package/lib/hbs2lit/src/svgProcessor.js +3 -3
  31. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +5 -5
  32. package/lib/hbs2ui5/index.js +26 -20
  33. package/lib/i18n/toJSON.js +1 -1
  34. package/lib/jsdoc/config.json +1 -1
  35. package/lib/jsdoc/plugin.js +33 -4
  36. package/lib/jsdoc/template/publish.js +24 -4
  37. package/lib/polyfill-placeholder/index.js +5 -0
  38. package/lib/postcss-css-to-esm/index.js +19 -16
  39. package/lib/postcss-css-to-json/index.js +20 -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/missing-dependencies.js +65 -0
  45. package/lib/scoping/report-tags-usage.js +28 -0
  46. package/lib/scoping/scope-test-pages.js +40 -0
  47. package/lib/serve/index.js +46 -0
  48. package/{components-package → lib/serve}/serve.json +0 -0
  49. package/package-lock.json +48 -0
  50. package/package.json +53 -53
  51. package/bin/init-ui5-package.js +0 -3
  52. package/lib/init-package/index.js +0 -115
  53. package/lib/init-package/resources/.eslintignore +0 -3
  54. package/lib/init-package/resources/bundle.es5.js +0 -25
  55. package/lib/init-package/resources/bundle.esm.js +0 -34
  56. package/lib/init-package/resources/config/.eslintrc.js +0 -1
  57. package/lib/init-package/resources/config/postcss.components/postcss.config.js +0 -1
  58. package/lib/init-package/resources/config/postcss.themes/postcss.config.js +0 -1
  59. package/lib/init-package/resources/config/rollup.config.js +0 -1
  60. package/lib/init-package/resources/config/wdio.conf.js +0 -1
  61. package/lib/init-package/resources/package-scripts.js +0 -11
  62. package/lib/init-package/resources/src/Assets.js +0 -5
  63. package/lib/init-package/resources/src/Demo.hbs +0 -1
  64. package/lib/init-package/resources/src/Demo.js +0 -56
  65. package/lib/init-package/resources/src/i18n/messagebundle.properties +0 -2
  66. package/lib/init-package/resources/src/i18n/messagebundle_de.properties +0 -1
  67. package/lib/init-package/resources/src/i18n/messagebundle_en.properties +0 -1
  68. package/lib/init-package/resources/src/i18n/messagebundle_es.properties +0 -1
  69. package/lib/init-package/resources/src/i18n/messagebundle_fr.properties +0 -1
  70. package/lib/init-package/resources/src/themes/Demo.css +0 -11
  71. package/lib/init-package/resources/src/themes/sap_belize/parameters-bundle.css +0 -3
  72. package/lib/init-package/resources/src/themes/sap_belize_hcb/parameters-bundle.css +0 -3
  73. package/lib/init-package/resources/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
  74. package/lib/init-package/resources/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
  75. package/lib/init-package/resources/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
  76. package/lib/init-package/resources/test/pages/index.html +0 -51
  77. package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
@@ -1,17 +1,27 @@
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");
11
-
12
- const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
3
+ const os = require("os");
4
+ const { babel } = require("@rollup/plugin-babel");
5
+ const { nodeResolve } = require("@rollup/plugin-node-resolve");
6
+ const url = require("@rollup/plugin-url");
7
+ const { terser } = require("rollup-plugin-terser");
8
+ const json = require("@rollup/plugin-json");
9
+ const replace = require("@rollup/plugin-replace");
10
+ const commonjs = require("@rollup/plugin-commonjs");
11
+ const colors = require("cli-color");
12
+ const filesize = require("rollup-plugin-filesize");
13
+ const livereload = require("rollup-plugin-livereload");
14
+ const emptyModulePlugin = require("./rollup-plugins/empty-module.js");
15
+
16
+ const packageFile = JSON.parse(fs.readFileSync("./package.json"));
17
+ const packageName = packageFile.name;
13
18
  const DEPLOY_PUBLIC_PATH = process.env.DEPLOY_PUBLIC_PATH || "";
14
19
 
20
+ const warningsToSkip = [{
21
+ warningCode: "THIS_IS_UNDEFINED",
22
+ filePath: /.+zxing.+/,
23
+ }];
24
+
15
25
  function ui5DevImportCheckerPlugin() {
16
26
  return {
17
27
  name: "ui5-dev-import-checker-plugin",
@@ -20,51 +30,129 @@ function ui5DevImportCheckerPlugin() {
20
30
  if (re.test(code)) {
21
31
  throw new Error(`illegal import in ${file}`);
22
32
  }
23
- }
33
+ },
34
+ };
35
+ }
36
+
37
+ function onwarn(warning, warn) {
38
+ // Skip warning for known false positives that will otherwise polute the log
39
+ let skip = warningsToSkip.find(warningToSkip => {
40
+ let loc, file;
41
+ return warning.code === warningToSkip.warningCode
42
+ && (loc = warning.loc)
43
+ && (file = loc.file)
44
+ && file.match(warningToSkip.filePath);
45
+ });
46
+ if (skip) {
47
+ return;
48
+ }
49
+
50
+ // warn everything else
51
+ warn( warning );
52
+ }
53
+
54
+ const reportedForPackages = new Set(); // sometimes writeBundle is called more than once per bundle -> suppress extra messages
55
+ function ui5DevReadyMessagePlugin() {
56
+ return {
57
+ name: "ui5-dev-message-ready-plugin",
58
+ writeBundle: (assets, bundle) => {
59
+ if (reportedForPackages.has(packageName)) {
60
+ return;
61
+ }
62
+ console.log(colors.blue(`${colors.bold(packageName)} successfully built!`));
63
+
64
+ if (fs.existsSync(".port")) {
65
+ const port = `${fs.readFileSync(".port")}`;
66
+ if (port) {
67
+ console.log(colors.blue(`Navigate to: ${colors.bold(`http://localhost:${port}/test-resources/pages/`)}`));
68
+ }
69
+ }
70
+ reportedForPackages.add(packageName);
71
+ },
24
72
  };
25
73
  }
26
74
 
27
75
  const getPlugins = ({ transpile }) => {
28
76
  const plugins = [];
29
- let publicPath = DEPLOY_PUBLIC_PATH || "/resources/";
30
77
 
31
- if (!process.env.DEV) {
32
- plugins.push(filesize({
33
- render : function (options, bundle, { minSize, gzipSize, brotliSize, bundleSize }){
34
- return gzipSize;
35
- }
78
+ if (process.env.DEV) {
79
+ plugins.push(replace({
80
+ values: {
81
+ 'const DEV_MODE = false': 'const DEV_MODE = true',
82
+ },
83
+ preventAssignment: false,
84
+ }));
85
+ }
86
+
87
+ if (process.env.DEV && !process.env.ENABLE_CLDR) {
88
+ // Empty the CLDR assets file for better performance during development
89
+ plugins.push(emptyModulePlugin({
90
+ emptyModules: [
91
+ "localization/dist/Assets.js",
92
+ ],
36
93
  }));
37
94
  }
38
95
 
96
+ if (!process.env.DEV) {
97
+ plugins.push(filesize(
98
+ {
99
+ reporter(options, bundle, {
100
+ minSize, gzipSize, brotliSize, bundleSize,
101
+ fileName,
102
+ // "showBeforeSizes: release"
103
+ lastVersion,
104
+ // "showBeforeSizes: "release" or "showBeforeSizes": "build"
105
+ bundleSizeBefore, brotliSizeBefore, minSizeBefore, gzipSizeBefore,
106
+ }) {
107
+ // If a promise is returned, it will be awaited before rendering.
108
+ return `${fileName.padEnd(35)} ${minSize} / gzipped: ${gzipSize}`;
109
+ },
110
+ },
111
+
112
+ ));
113
+ }
114
+
115
+ const publicPath = DEPLOY_PUBLIC_PATH;
116
+
39
117
  plugins.push(ui5DevImportCheckerPlugin());
40
118
 
41
- plugins.push(url({
42
- limit: 0,
43
- include: [
44
- /.*assets\/.*\.json/
45
- ],
46
- emitFiles: true,
47
- fileName: "[name].[hash][extname]",
48
- publicPath,
49
- }));
119
+ if (!transpile) {
120
+ plugins.push(json({
121
+ include: [
122
+ /.*assets\/.*\.json/,
123
+ ],
124
+ namedExports: false,
125
+ }));
126
+ }
50
127
 
128
+ if (transpile) {
129
+ plugins.push(url({
130
+ limit: 0,
131
+ include: [
132
+ /.*assets\/.*\.json/,
133
+ ],
134
+ emitFiles: true,
135
+ fileName: "[name].[hash][extname]",
136
+ publicPath,
137
+ }));
138
+ }
51
139
 
52
140
  if (transpile) {
141
+ plugins.push(commonjs());
53
142
  plugins.push(babel({
54
143
  presets: ["@babel/preset-env"],
55
- exclude: "node_modules/**",
56
- sourcemap: true,
144
+ exclude: /node_modules\/(?!(lit-html|@ui5\/webcomponents))/, // exclude all node_modules/ except lit-html and all starting with @ui5/webcomponents
145
+ sourcemap: false,
146
+ babelHelpers: "bundled",
57
147
  }));
58
148
  }
59
149
 
60
- plugins.push(resolve());
150
+ plugins.push(nodeResolve());
61
151
 
62
152
  if (!process.env.DEV) {
63
- plugins.push(terser());
64
- }
65
-
66
- if (process.env.DEV) {
67
- plugins.push(notify());
153
+ plugins.push(terser({
154
+ numWorkers: 1,
155
+ }));
68
156
  }
69
157
 
70
158
  const es6DevMain = process.env.DEV && !transpile && packageName === "@ui5/webcomponents";
@@ -74,61 +162,78 @@ const getPlugins = ({ transpile }) => {
74
162
  "dist/resources/bundle.esm.js",
75
163
  "dist/**/*.html",
76
164
  "dist/**/*.json",
77
- ]
165
+ ],
78
166
  }));
79
167
  }
80
168
 
169
+ if (process.env.DEV) {
170
+ plugins.push(ui5DevReadyMessagePlugin());
171
+ }
172
+
81
173
  return plugins;
82
174
  };
83
175
 
84
- const getES6Config = () => {
176
+ const getES6Config = (input = "bundle.esm.js") => {
85
177
  return [{
86
- input: "bundle.esm.js",
178
+ input,
87
179
  output: {
88
180
  dir: "dist/resources",
89
181
  format: "esm",
90
- sourcemap: true
182
+ sourcemap: true,
91
183
  },
92
- moduleContext: (id) => {
93
- if (id.includes("url-search-params-polyfill")) {
184
+ moduleContext: id => {
185
+ if (typeof id === "string" && id.includes("url-search-params-polyfill")) {
94
186
  // suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
95
187
  return "window";
96
188
  }
97
189
  },
98
190
  watch: {
99
- clearScreen: false
191
+ clearScreen: false,
100
192
  },
101
- plugins: getPlugins({transpile: false}),
193
+ plugins: getPlugins({ transpile: false }),
194
+ onwarn: onwarn,
102
195
  }];
103
196
  };
104
197
 
105
- const getES5Config = () => {
106
- return [ {
107
- input: "bundle.es5.js",
198
+ const getES5Config = (input = "bundle.es5.js") => {
199
+ return [{
200
+ input,
108
201
  output: {
109
202
  dir: "dist/resources",
110
203
  format: "iife",
204
+ inlineDynamicImports: true,
111
205
  name: "sap-ui-webcomponents-bundle",
112
206
  extend: "true", // Whether or not to extend the global variable defined by the name option in umd or iife formats.
113
- sourcemap: true
207
+ sourcemap: true,
114
208
  },
115
- moduleContext: (id) => {
209
+ moduleContext: id => {
116
210
  if (id.includes("url-search-params-polyfill")) {
117
211
  // suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
118
212
  return "window";
119
213
  }
120
214
  },
121
215
  watch: {
122
- clearScreen: false
216
+ clearScreen: false,
123
217
  },
124
- plugins: getPlugins({transpile: true}),
218
+ plugins: getPlugins({ transpile: true }),
219
+ onwarn: onwarn,
125
220
  }];
126
221
  };
127
222
 
128
223
  let config = getES6Config();
129
224
 
130
- if (process.env.ES5_BUILD) {
225
+ if (process.env.ES5_BUILD && fs.existsSync("bundle.es5.js")) {
131
226
  config = config.concat(getES5Config());
132
227
  }
133
228
 
229
+ if (process.env.SCOPE) {
230
+ if (fs.existsSync("bundle.scoped.esm.js")) {
231
+ config = config.concat(getES6Config("bundle.scoped.esm.js"));
232
+
233
+ if (fs.existsSync("bundle.scoped.es5.js") && process.env.ES5_BUILD) {
234
+ config = config.concat(getES5Config("bundle.scoped.es5.js"));
235
+ }
236
+ }
237
+ }
238
+
134
239
  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.
@@ -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,48 +164,97 @@ 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) {
208
- // },
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
+ },
209
258
 
210
259
  /**
211
260
  * Hook that gets executed before the suite starts
@@ -251,13 +300,36 @@ exports.config = {
251
300
  * @param {Number} result 0 - command success, 1 - command error
252
301
  * @param {Object} error error object if any
253
302
  */
254
- afterCommand: function (commandName, args, result, error) {
255
- const waitFor = ["$", "$$", "shadow$", "shadow$$", "getStaticAreaItemClassName", "click", "performActions", "elementClick", "keys", "sendKeys", "findElement", "elementClear", "elementSendKeys", "setValue", "addValue", "getHTML", "getProperty", "setProperty", "setAttribute", "removeAttribute", "getElementProperty"];
256
- if (waitFor.includes(commandName)) {
257
- browser.executeAsync(function (done) {
258
- // 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) {
259
308
  window["sap-ui-webcomponents-bundle"].configuration.setNoConflict(true);
260
- 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);
261
333
  });
262
334
  }
263
335
  },