@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
@@ -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,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,41 +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);
212
+
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]);
217
+ }, selector);
218
+ }, false);
219
+
220
+ await browser.addLocatorStrategy('activeElement', (selector) => {
221
+ return document.querySelector(selector).shadowRoot.activeElement;
222
+ });
231
223
  },
232
224
  /**
233
225
  * Runs before a WebdriverIO command gets executed.
234
226
  * @param {String} commandName hook command name
235
227
  * @param {Array} args arguments that command would receive
236
228
  */
237
- // beforeCommand: function (commandName, args) {
238
- // },
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
+ },
239
258
 
240
259
  /**
241
260
  * Hook that gets executed before the suite starts
@@ -281,13 +300,36 @@ exports.config = {
281
300
  * @param {Number} result 0 - command success, 1 - command error
282
301
  * @param {Object} error error object if any
283
302
  */
284
- afterCommand: function (commandName, args, result, error) {
285
- const waitFor = ["$", "$$", "shadow$", "click", "performActions", "elementClick", "keys", "sendKeys", "findElement", "elementClear", "elementSendKeys", "setValue", "addValue", "getHTML", "getProperty", "setAttribute", "removeAttribute", "getElementProperty"];
286
- if (waitFor.includes(commandName)) {
287
- browser.executeAsync(function (done) {
288
- // 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) {
289
308
  window["sap-ui-webcomponents-bundle"].configuration.setNoConflict(true);
290
- 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);
291
333
  });
292
334
  }
293
335
  },