vis-dev-utils 3.0.118 → 3.0.120

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.
@@ -6,8 +6,8 @@
6
6
  *
7
7
  * Development utilities for the Vis family projects.
8
8
  *
9
- * @version 3.0.118
10
- * @date 2023-02-14T20:12:46.682Z
9
+ * @version 3.0.120
10
+ * @date 2023-02-15T20:06:40.240Z
11
11
  *
12
12
  * @copyright (c) 2011-2017 Almende B.V, http://almende.com
13
13
  * @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
@@ -42,11 +42,10 @@ var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/ins
42
42
  var _sortInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/sort');
43
43
  var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
44
44
  var $ = require('cheerio');
45
- var fs = require('fs');
46
- var globby = require('globby');
47
- var util = require('util');
45
+ var fs = require('node:fs');
46
+ var util = require('node:util');
48
47
  var yargs = require('yargs');
49
- var path = require('path');
48
+ var node_path = require('node:path');
50
49
  var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
51
50
  var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
52
51
  var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
@@ -79,10 +78,28 @@ var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entr
79
78
  var Jimp = require('jimp');
80
79
  var _repeatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/repeat');
81
80
  var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
82
- var crypto = require('crypto');
81
+ var node_crypto = require('node:crypto');
83
82
 
84
83
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
85
84
 
85
+ function _interopNamespace(e) {
86
+ if (e && e.__esModule) return e;
87
+ var n = Object.create(null);
88
+ if (e) {
89
+ Object.keys(e).forEach(function (k) {
90
+ if (k !== 'default') {
91
+ var d = Object.getOwnPropertyDescriptor(e, k);
92
+ Object.defineProperty(n, k, d.get ? d : {
93
+ enumerable: true,
94
+ get: function () { return e[k]; }
95
+ });
96
+ }
97
+ });
98
+ }
99
+ n["default"] = e;
100
+ return Object.freeze(n);
101
+ }
102
+
86
103
  var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
87
104
  var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator);
88
105
  var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
@@ -98,7 +115,6 @@ var _sortInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_sortIns
98
115
  var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_forEachInstanceProperty);
99
116
  var $__default = /*#__PURE__*/_interopDefaultLegacy($);
100
117
  var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
101
- var globby__default = /*#__PURE__*/_interopDefaultLegacy(globby);
102
118
  var util__default = /*#__PURE__*/_interopDefaultLegacy(util);
103
119
  var yargs__default = /*#__PURE__*/_interopDefaultLegacy(yargs);
104
120
  var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefaultLegacy(_Object$getOwnPropertySymbols);
@@ -143,13 +159,10 @@ function isExample(value) {
143
159
  /**
144
160
  *
145
161
  */
146
-
147
162
  function measureStartStopMs() {
148
163
  var start = _Date$now__default["default"]();
149
-
150
164
  return function () {
151
165
  var stop = _Date$now__default["default"]();
152
-
153
166
  return {
154
167
  start: start,
155
168
  stop: stop
@@ -160,10 +173,8 @@ function measureStartStopMs() {
160
173
  * @param reports
161
174
  * @param fallback
162
175
  */
163
-
164
176
  function reduceReports(reports) {
165
177
  var _reports$reduce;
166
-
167
178
  var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
168
179
  count: 0,
169
180
  result: "fulfilled",
@@ -172,7 +183,6 @@ function reduceReports(reports) {
172
183
  };
173
184
  return (_reports$reduce = _reduceInstanceProperty__default["default"](reports).call(reports, function (acc, val) {
174
185
  var _acc$count, _val$count, _context, _acc$result, _acc$start, _acc$stop;
175
-
176
186
  return {
177
187
  count: ((_acc$count = acc === null || acc === void 0 ? void 0 : acc.count) !== null && _acc$count !== void 0 ? _acc$count : 0) + ((_val$count = val === null || val === void 0 ? void 0 : val.count) !== null && _val$count !== void 0 ? _val$count : 0),
178
188
  result: _everyInstanceProperty__default["default"](_context = [(_acc$result = acc === null || acc === void 0 ? void 0 : acc.result) !== null && _acc$result !== void 0 ? _acc$result : "fulfilled", val.result]).call(_context, function (result) {
@@ -188,10 +198,9 @@ function reduceReports(reports) {
188
198
  * @param root0.start
189
199
  * @param root0.stop
190
200
  */
191
-
192
201
  function formatStartStopMs(_ref) {
193
202
  var start = _ref.start,
194
- stop = _ref.stop;
203
+ stop = _ref.stop;
195
204
  return "".concat((Math.round((stop - start) / 100) / 10).toFixed(1), "s");
196
205
  }
197
206
 
@@ -221,14 +230,12 @@ var template$1 = "<html>\n <head>\n <meta charset=\"utf-8\" />\n <title>C
221
230
  /**
222
231
  * @param example
223
232
  */
224
-
225
233
  function generateCodePenPage(example) {
226
234
  var data = example.playground;
227
235
  var title = example.titles.join(" | ");
228
236
  var page = $__default["default"].load(template$1);
229
237
  page("title").text(title);
230
238
  var form = page("#form");
231
-
232
239
  _findInstanceProperty__default["default"](form).call(form, 'input[name="data"]').attr("value", _JSON$stringify__default["default"]({
233
240
  css: data.code.css,
234
241
  css_external: data.resources.css.join(";"),
@@ -237,7 +244,6 @@ function generateCodePenPage(example) {
237
244
  js_external: data.resources.js.join(";"),
238
245
  title: example.titles.join(" | ")
239
246
  }));
240
-
241
247
  return page.html();
242
248
  }
243
249
 
@@ -246,55 +252,50 @@ function generateCodePenPage(example) {
246
252
  * @param example$
247
253
  * @param examplePath
248
254
  */
249
-
250
255
  function generatePlaygroundData(baseURL, example$, examplePath) {
251
256
  var _context, _context2, _context3, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12, _context13, _context14;
252
-
253
257
  // JavaScript
254
258
  var eventListeners = _mapInstanceProperty__default["default"](_context = _mapInstanceProperty__default["default"](_context2 = _filterInstanceProperty__default["default"](_context3 = _Object$entries__default["default"](example$("body").get(0).attribs)).call(_context3, function (_ref) {
255
259
  var _ref2 = _slicedToArray__default["default"](_ref, 1),
256
- name = _ref2[0];
257
-
260
+ name = _ref2[0];
258
261
  return /^on/.test(name);
259
262
  })).call(_context2, function (_ref3) {
260
263
  var _ref4 = _slicedToArray__default["default"](_ref3, 2),
261
- name = _ref4[0],
262
- value = _ref4[1];
263
-
264
+ name = _ref4[0],
265
+ value = _ref4[1];
264
266
  return [_sliceInstanceProperty__default["default"](name).call(name, 2), "".concat(value)];
265
267
  })).call(_context, function (_ref5) {
266
268
  var _context4;
267
-
268
269
  var _ref6 = _slicedToArray__default["default"](_ref5, 2),
269
- name = _ref6[0],
270
- value = _ref6[1];
271
-
270
+ name = _ref6[0],
271
+ value = _ref6[1];
272
272
  return _concatInstanceProperty__default["default"](_context4 = "window.addEventListener(\"".concat(name, "\", () => { ")).call(_context4, value, " });");
273
273
  }).join("\n");
274
-
275
274
  var js = formatJS(_mapInstanceProperty__default["default"](_context5 = _mapInstanceProperty__default["default"](_context6 = example$("script")).call(_context6, function (_i, elem) {
276
275
  return elem.children[0];
277
276
  }).get()).call(_context5, function (elem) {
278
277
  return elem.data;
279
- }).join("") + "\n\n;" + eventListeners); // Cascading Style Sheets
280
-
278
+ }).join("") + "\n\n;" + eventListeners);
279
+ // Cascading Style Sheets
281
280
  var css = formatCSS(_mapInstanceProperty__default["default"](_context7 = _mapInstanceProperty__default["default"](_context8 = example$("style")).call(_context8, function (_i, elem) {
282
281
  return elem.children[0];
283
282
  }).get()).call(_context7, function (elem) {
284
283
  return elem.data;
285
- }).join("")); // Hypertext Markup Language
286
-
284
+ }).join(""));
285
+ // Hypertext Markup Language
287
286
  var $html = $__default["default"].load(example$("body").html() || "");
288
287
  $html("script").remove();
289
- var html = formatHTML($html("body").html()); // Resources
290
-
288
+ var html = formatHTML($html("body").html());
289
+ // Resources
291
290
  var fixPath = function fixPath(rawPath) {
292
- return /^https?:\/\//.test(rawPath) ? // World wide web absolute.
293
- rawPath : /^\//.test(rawPath) ? // Domain absolute.
294
- baseURL + _sliceInstanceProperty__default["default"](rawPath).call(rawPath, 1) : //Relative.
295
- baseURL + path.relative(process.cwd(), path.resolve(path.dirname(examplePath), rawPath));
291
+ return /^https?:\/\//.test(rawPath) ?
292
+ // World wide web absolute.
293
+ rawPath : /^\//.test(rawPath) ?
294
+ // Domain absolute.
295
+ baseURL + _sliceInstanceProperty__default["default"](rawPath).call(rawPath, 1) :
296
+ //Relative.
297
+ baseURL + node_path.relative(process.cwd(), node_path.resolve(node_path.dirname(examplePath), rawPath));
296
298
  };
297
-
298
299
  var resources = {
299
300
  js: _mapInstanceProperty__default["default"](_context9 = _filterInstanceProperty__default["default"](_context10 = _mapInstanceProperty__default["default"](_context11 = example$("script")).call(_context11, function (_i, elem) {
300
301
  return $__default["default"](elem).attr("src");
@@ -322,42 +323,30 @@ var template = "<html>\n <head>\n <meta charset=\"utf-8\" />\n <title>JSF
322
323
  /**
323
324
  * @param example
324
325
  */
325
-
326
326
  function generateJSFiddlePage(example) {
327
327
  var _context;
328
-
329
328
  var data = example.playground;
330
329
  var title = example.titles.join(" | ");
331
-
332
330
  var resources = _concatInstanceProperty__default["default"](_context = []).call(_context, _toConsumableArray__default["default"](data.resources.css), _toConsumableArray__default["default"](data.resources.js)).join(",");
333
-
334
331
  var page = $__default["default"].load(template);
335
332
  page("title").text(title);
336
- var form = page("#form"); // Playground data.
337
-
333
+ var form = page("#form");
334
+ // Playground data.
338
335
  _findInstanceProperty__default["default"](form).call(form, 'input[name="css"]').attr("value", data.code.css);
339
-
340
336
  _findInstanceProperty__default["default"](form).call(form, 'input[name="html"]').attr("value", data.code.html);
341
-
342
337
  _findInstanceProperty__default["default"](form).call(form, 'input[name="js"]').attr("value", data.code.js);
343
-
344
338
  _findInstanceProperty__default["default"](form).call(form, 'input[name="resources"]').attr("value", resources);
345
-
346
- _findInstanceProperty__default["default"](form).call(form, 'input[name="title"]').attr("value", title); // Don't run JS before the DOM is ready.
347
-
348
-
339
+ _findInstanceProperty__default["default"](form).call(form, 'input[name="title"]').attr("value", title);
340
+ // Don't run JS before the DOM is ready.
349
341
  _findInstanceProperty__default["default"](form).call(form, 'input[name="wrap"]').attr("value", "b");
350
-
351
342
  return page.html();
352
343
  }
353
344
 
354
345
  var commonScreenshotScript = "/* global window: false */\n\n/**\n * Simulates confirmation usind window.confirm and window.alert otherwise the\n * screenshot generator would just hang forever.\n */\nwindow.realAlert = window.alert;\nwindow.alert = function () {};\nwindow.confirm = function () {\n return true;\n};\n\n/**\n * Wait for the page to report it's ready to take a screenshot.\n */\nwindow.readyToTakeAScreenshot = new Promise(function (resolve) {\n window.takeScreenshot = resolve;\n});\n";
355
346
 
356
347
  function _createForOfIteratorHelper$3(o, allowArrayLike) { var it = typeof _Symbol__default["default"] !== "undefined" && _getIteratorMethod__default["default"](o) || o["@@iterator"]; if (!it) { if (_Array$isArray__default["default"](o) || (it = _unsupportedIterableToArray$3(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
357
-
358
348
  function _unsupportedIterableToArray$3(o, minLen) { var _context5; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = _sliceInstanceProperty__default["default"](_context5 = Object.prototype.toString.call(o)).call(_context5, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from__default["default"](o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); }
359
-
360
- function _arrayLikeToArray$3(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
349
+ function _arrayLikeToArray$3(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
361
350
  var unlink = util.promisify(fs__default["default"].unlink);
362
351
  var writeFile$1 = util.promisify(fs__default["default"].writeFile);
363
352
  /**
@@ -368,7 +357,6 @@ var writeFile$1 = util.promisify(fs__default["default"].writeFile);
368
357
  * @param screenshot - The binary data of the screenshot.
369
358
  * @returns True for valid and false for invalid.
370
359
  */
371
-
372
360
  function isScreenshotValid(_x) {
373
361
  return _isScreenshotValid.apply(this, arguments);
374
362
  }
@@ -380,267 +368,205 @@ function isScreenshotValid(_x) {
380
368
  * @param config - See the type's docs for detail.
381
369
  * @returns Whether or not the screenshot passed validation check.
382
370
  */
383
-
384
-
385
371
  function _isScreenshotValid() {
386
372
  _isScreenshotValid = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(screenshot) {
387
373
  var image, firstPixel, x, y;
388
374
  return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
389
- while (1) {
390
- switch (_context.prev = _context.next) {
391
- case 0:
392
- _context.next = 2;
393
- return Jimp__default["default"].read(screenshot);
394
-
395
- case 2:
396
- image = _context.sent;
397
- firstPixel = image.getPixelColor(0, 0);
398
- x = 0;
399
-
400
- case 5:
401
- if (!(x < image.getWidth())) {
402
- _context.next = 16;
403
- break;
404
- }
405
-
406
- y = 0;
407
-
408
- case 7:
409
- if (!(y < image.getHeight())) {
410
- _context.next = 13;
411
- break;
412
- }
413
-
414
- if (!(firstPixel !== image.getPixelColor(x, y))) {
415
- _context.next = 10;
416
- break;
417
- }
418
-
419
- return _context.abrupt("return", true);
420
-
421
- case 10:
422
- ++y;
423
- _context.next = 7;
375
+ while (1) switch (_context.prev = _context.next) {
376
+ case 0:
377
+ _context.next = 2;
378
+ return Jimp__default["default"].read(screenshot);
379
+ case 2:
380
+ image = _context.sent;
381
+ firstPixel = image.getPixelColor(0, 0);
382
+ x = 0;
383
+ case 5:
384
+ if (!(x < image.getWidth())) {
385
+ _context.next = 16;
424
386
  break;
425
-
426
- case 13:
427
- ++x;
428
- _context.next = 5;
387
+ }
388
+ y = 0;
389
+ case 7:
390
+ if (!(y < image.getHeight())) {
391
+ _context.next = 13;
429
392
  break;
430
-
431
- case 16:
432
- return _context.abrupt("return", false);
433
-
434
- case 17:
435
- case "end":
436
- return _context.stop();
437
- }
393
+ }
394
+ if (!(firstPixel !== image.getPixelColor(x, y))) {
395
+ _context.next = 10;
396
+ break;
397
+ }
398
+ return _context.abrupt("return", true);
399
+ case 10:
400
+ ++y;
401
+ _context.next = 7;
402
+ break;
403
+ case 13:
404
+ ++x;
405
+ _context.next = 5;
406
+ break;
407
+ case 16:
408
+ return _context.abrupt("return", false);
409
+ case 17:
410
+ case "end":
411
+ return _context.stop();
438
412
  }
439
413
  }, _callee);
440
414
  }));
441
415
  return _isScreenshotValid.apply(this, arguments);
442
416
  }
443
-
444
417
  function generateScreenshot(_x2, _x3) {
445
418
  return _generateScreenshot.apply(this, arguments);
446
419
  }
447
-
448
420
  function _generateScreenshot() {
449
421
  _generateScreenshot = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(browser, config) {
450
422
  var debug, example, height, screenshotScript, width, cleanup, tmpPath, screenshotPage, context, page, $element, _context2, screenshot, _context3, _iterator, _step, callback;
451
-
452
423
  return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context4) {
453
- while (1) {
454
- switch (_context4.prev = _context4.next) {
455
- case 0:
456
- debug = config.debug, example = config.example, height = config.height, screenshotScript = config.screenshotScript, width = config.width;
457
- cleanup = [];
458
- _context4.prev = 2;
459
- // Prepare the page. It has to be written to the disk so that files with
460
- // relative URLs can be loaded.
461
- tmpPath = path.resolve(path.dirname(example.paths.page.local), ".tmp.example.screenshot." + path.basename(example.paths.page.local));
462
- screenshotPage = $__default["default"].load(example.html);
463
- screenshotPage("head").prepend($__default["default"]("<script>").attr("type", "text/javascript").text("window.DEBUG = ".concat(true, ";")), $__default["default"]("<script>").attr("type", "text/javascript").text(commonScreenshotScript), $__default["default"]("<script>").attr("type", "text/javascript").text(screenshotScript), $__default["default"]("<style>").attr("type", "text/css").text(["".concat(example.selector, " {"), " border: none !important;", "", " min-width: ".concat(width, "px !important;"), " min-height: ".concat(height, "px !important;"), " width: ".concat(width, "px !important;"), " height: ".concat(height, "px !important;"), " max-width: ".concat(width, "px !important;"), " max-height: ".concat(height, "px !important;"), "}"].join("\n")));
464
- _context4.next = 8;
465
- return writeFile$1(tmpPath, formatHTML(screenshotPage.html()));
466
-
467
- case 8:
468
- if (!debug) {
469
- cleanup.push(function () {
470
- return unlink(tmpPath);
471
- });
472
- }
473
-
474
- _context4.next = 11;
475
- return browser.createIncognitoBrowserContext();
476
-
477
- case 11:
478
- context = _context4.sent;
479
-
480
- if (!debug) {
481
- cleanup.push(function () {
482
- return context.close();
483
- });
484
- }
485
-
486
- _context4.next = 15;
487
- return context.newPage();
488
-
489
- case 15:
490
- page = _context4.sent;
491
-
492
- if (!debug) {
493
- cleanup.push(function () {
494
- return page.close();
495
- });
496
- }
497
-
498
- _context4.next = 19;
499
- return page.setViewport({
500
- width: width + 50,
501
- height: height + 50
502
- });
503
-
504
- case 19:
505
- _context4.next = 21;
506
- return page.goto("file://" + tmpPath.split(path.sep).join(path.posix.sep));
507
-
508
- case 21:
509
- _context4.next = 23;
510
- return page.waitForSelector(example.selector, {
511
- visible: true,
512
- timeout: example.timeout * 1000
424
+ while (1) switch (_context4.prev = _context4.next) {
425
+ case 0:
426
+ debug = config.debug, example = config.example, height = config.height, screenshotScript = config.screenshotScript, width = config.width;
427
+ cleanup = [];
428
+ _context4.prev = 2;
429
+ // Prepare the page. It has to be written to the disk so that files with
430
+ // relative URLs can be loaded.
431
+ tmpPath = node_path.resolve(node_path.dirname(example.paths.page.local), ".tmp.example.screenshot." + node_path.basename(example.paths.page.local));
432
+ screenshotPage = $__default["default"].load(example.html);
433
+ screenshotPage("head").prepend($__default["default"]("<script>").attr("type", "text/javascript").text("window.DEBUG = ".concat(true, ";")), $__default["default"]("<script>").attr("type", "text/javascript").text(commonScreenshotScript), $__default["default"]("<script>").attr("type", "text/javascript").text(screenshotScript), $__default["default"]("<style>").attr("type", "text/css").text(["".concat(example.selector, " {"), " border: none !important;", "", " min-width: ".concat(width, "px !important;"), " min-height: ".concat(height, "px !important;"), " width: ".concat(width, "px !important;"), " height: ".concat(height, "px !important;"), " max-width: ".concat(width, "px !important;"), " max-height: ".concat(height, "px !important;"), "}"].join("\n")));
434
+ _context4.next = 8;
435
+ return writeFile$1(tmpPath, formatHTML(screenshotPage.html()));
436
+ case 8:
437
+ if (!debug) {
438
+ cleanup.push(function () {
439
+ return unlink(tmpPath);
513
440
  });
514
-
515
- case 23:
516
- if (!(example.delay === "call")) {
517
- _context4.next = 28;
518
- break;
519
- }
520
-
521
- _context4.next = 26;
522
- return page.evaluate("function fn() { return window.readyToTakeAScreenshot; }");
523
-
524
- case 26:
525
- _context4.next = 30;
526
- break;
527
-
528
- case 28:
529
- _context4.next = 30;
530
- return page.waitForTimeout(example.delay * 1000);
531
-
532
- case 30:
533
- _context4.next = 32;
534
- return page.$(example.selector);
535
-
536
- case 32:
537
- $element = _context4.sent;
538
-
539
- if (!($element == null)) {
540
- _context4.next = 35;
541
- break;
542
- }
543
-
544
- throw new Error(_concatInstanceProperty__default["default"](_context2 = "Element \"".concat(example.selector, "\" not found in ")).call(_context2, example.path, "."));
545
-
546
- case 35:
547
- _context4.next = 37;
548
- return $element.evaluate(function (element) {
549
- element.scrollIntoView();
441
+ }
442
+ _context4.next = 11;
443
+ return browser.createIncognitoBrowserContext();
444
+ case 11:
445
+ context = _context4.sent;
446
+ if (!debug) {
447
+ cleanup.push(function () {
448
+ return context.close();
550
449
  });
551
-
552
- case 37:
553
- _context4.next = 39;
554
- return $element.screenshot({
555
- encoding: "binary"
450
+ }
451
+ _context4.next = 15;
452
+ return context.newPage();
453
+ case 15:
454
+ page = _context4.sent;
455
+ if (!debug) {
456
+ cleanup.push(function () {
457
+ return page.close();
556
458
  });
557
-
558
- case 39:
559
- screenshot = _context4.sent;
560
-
561
- if (!(screenshot == null)) {
562
- _context4.next = 44;
563
- break;
564
- }
565
-
566
- throw new Error("Failed to take screenshot of \u201C".concat(example.paths.page, "\u201D"));
567
-
568
- case 44:
569
- if (!(typeof screenshot === "string")) {
570
- _context4.next = 46;
571
- break;
572
- }
573
-
574
- throw new Error("Failed to get the binary data of the screenshot of \u201C".concat(example.paths.page, "\u201D"));
575
-
576
- case 46:
577
- _context4.next = 48;
578
- return writeFile$1(example.paths.screenshot.local, screenshot);
579
-
580
- case 48:
581
- return _context4.abrupt("return", isScreenshotValid(screenshot));
582
-
583
- case 51:
584
- _context4.prev = 51;
585
- _context4.t0 = _context4["catch"](2);
586
- console.error(_context4.t0);
587
- return _context4.abrupt("return", false);
588
-
589
- case 55:
590
- _context4.prev = 55;
591
- _iterator = _createForOfIteratorHelper$3(_reverseInstanceProperty__default["default"](_context3 = _spliceInstanceProperty__default["default"](cleanup).call(cleanup, 0)).call(_context3));
592
- _context4.prev = 57;
593
-
594
- _iterator.s();
595
-
596
- case 59:
597
- if ((_step = _iterator.n()).done) {
598
- _context4.next = 71;
599
- break;
600
- }
601
-
602
- callback = _step.value;
603
- _context4.prev = 61;
604
- _context4.next = 64;
605
- return callback();
606
-
607
- case 64:
608
- _context4.next = 69;
459
+ }
460
+ _context4.next = 19;
461
+ return page.setViewport({
462
+ width: width + 50,
463
+ height: height + 50
464
+ });
465
+ case 19:
466
+ _context4.next = 21;
467
+ return page.goto("file://" + tmpPath.split(node_path.sep).join(node_path.posix.sep));
468
+ case 21:
469
+ _context4.next = 23;
470
+ return page.waitForSelector(example.selector, {
471
+ visible: true,
472
+ timeout: example.timeout * 1000
473
+ });
474
+ case 23:
475
+ if (!(example.delay === "call")) {
476
+ _context4.next = 28;
609
477
  break;
610
-
611
- case 66:
612
- _context4.prev = 66;
613
- _context4.t1 = _context4["catch"](61);
614
- console.error(_context4.t1);
615
-
616
- case 69:
617
- _context4.next = 59;
478
+ }
479
+ _context4.next = 26;
480
+ return page.evaluate("function fn() { return window.readyToTakeAScreenshot; }");
481
+ case 26:
482
+ _context4.next = 30;
483
+ break;
484
+ case 28:
485
+ _context4.next = 30;
486
+ return page.waitForTimeout(example.delay * 1000);
487
+ case 30:
488
+ _context4.next = 32;
489
+ return page.$(example.selector);
490
+ case 32:
491
+ $element = _context4.sent;
492
+ if (!($element == null)) {
493
+ _context4.next = 35;
618
494
  break;
619
-
620
- case 71:
621
- _context4.next = 76;
495
+ }
496
+ throw new Error(_concatInstanceProperty__default["default"](_context2 = "Element \"".concat(example.selector, "\" not found in ")).call(_context2, example.path, "."));
497
+ case 35:
498
+ _context4.next = 37;
499
+ return $element.evaluate(function (element) {
500
+ element.scrollIntoView();
501
+ });
502
+ case 37:
503
+ _context4.next = 39;
504
+ return $element.screenshot({
505
+ encoding: "binary"
506
+ });
507
+ case 39:
508
+ screenshot = _context4.sent;
509
+ if (!(screenshot == null)) {
510
+ _context4.next = 44;
622
511
  break;
623
-
624
- case 73:
625
- _context4.prev = 73;
626
- _context4.t2 = _context4["catch"](57);
627
-
628
- _iterator.e(_context4.t2);
629
-
630
- case 76:
631
- _context4.prev = 76;
632
-
633
- _iterator.f();
634
-
635
- return _context4.finish(76);
636
-
637
- case 79:
638
- return _context4.finish(55);
639
-
640
- case 80:
641
- case "end":
642
- return _context4.stop();
643
- }
512
+ }
513
+ throw new Error("Failed to take screenshot of \u201C".concat(example.paths.page, "\u201D"));
514
+ case 44:
515
+ if (!(typeof screenshot === "string")) {
516
+ _context4.next = 46;
517
+ break;
518
+ }
519
+ throw new Error("Failed to get the binary data of the screenshot of \u201C".concat(example.paths.page, "\u201D"));
520
+ case 46:
521
+ _context4.next = 48;
522
+ return writeFile$1(example.paths.screenshot.local, screenshot);
523
+ case 48:
524
+ return _context4.abrupt("return", isScreenshotValid(screenshot));
525
+ case 51:
526
+ _context4.prev = 51;
527
+ _context4.t0 = _context4["catch"](2);
528
+ console.error(_context4.t0);
529
+ return _context4.abrupt("return", false);
530
+ case 55:
531
+ _context4.prev = 55;
532
+ _iterator = _createForOfIteratorHelper$3(_reverseInstanceProperty__default["default"](_context3 = _spliceInstanceProperty__default["default"](cleanup).call(cleanup, 0)).call(_context3));
533
+ _context4.prev = 57;
534
+ _iterator.s();
535
+ case 59:
536
+ if ((_step = _iterator.n()).done) {
537
+ _context4.next = 71;
538
+ break;
539
+ }
540
+ callback = _step.value;
541
+ _context4.prev = 61;
542
+ _context4.next = 64;
543
+ return callback();
544
+ case 64:
545
+ _context4.next = 69;
546
+ break;
547
+ case 66:
548
+ _context4.prev = 66;
549
+ _context4.t1 = _context4["catch"](61);
550
+ console.error(_context4.t1);
551
+ case 69:
552
+ _context4.next = 59;
553
+ break;
554
+ case 71:
555
+ _context4.next = 76;
556
+ break;
557
+ case 73:
558
+ _context4.prev = 73;
559
+ _context4.t2 = _context4["catch"](57);
560
+ _iterator.e(_context4.t2);
561
+ case 76:
562
+ _context4.prev = 76;
563
+ _iterator.f();
564
+ return _context4.finish(76);
565
+ case 79:
566
+ return _context4.finish(55);
567
+ case 80:
568
+ case "end":
569
+ return _context4.stop();
644
570
  }
645
571
  }, _callee2, null, [[2, 51, 55, 80], [57, 73, 76, 79], [61, 66]]);
646
572
  }));
@@ -648,22 +574,16 @@ function _generateScreenshot() {
648
574
  }
649
575
 
650
576
  function _createForOfIteratorHelper$2(o, allowArrayLike) { var it = typeof _Symbol__default["default"] !== "undefined" && _getIteratorMethod__default["default"](o) || o["@@iterator"]; if (!it) { if (_Array$isArray__default["default"](o) || (it = _unsupportedIterableToArray$2(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
651
-
652
577
  function _unsupportedIterableToArray$2(o, minLen) { var _context24; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$2(o, minLen); var n = _sliceInstanceProperty__default["default"](_context24 = Object.prototype.toString.call(o)).call(_context24, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from__default["default"](o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen); }
653
-
654
- function _arrayLikeToArray$2(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
655
-
578
+ function _arrayLikeToArray$2(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
656
579
  function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
657
-
658
580
  function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context22, _context23; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context22 = ownKeys$1(Object(source), !0)).call(_context22, function (key) { _defineProperty__default["default"](target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context23 = ownKeys$1(Object(source))).call(_context23, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
659
581
  var collator = new Intl.Collator("US");
660
582
  var writeFile = util.promisify(fs__default["default"].writeFile);
661
583
  var ContentBuilder = /*#__PURE__*/function () {
662
584
  function ContentBuilder(_config) {
663
585
  _classCallCheck__default["default"](this, ContentBuilder);
664
-
665
586
  _defineProperty__default["default"](this, "_config", void 0);
666
-
667
587
  this._config = _config;
668
588
  }
669
589
  /**
@@ -675,339 +595,280 @@ var ContentBuilder = /*#__PURE__*/function () {
675
595
  * @param emit.screenshots
676
596
  * @returns A report with check results and the number of written files.
677
597
  */
678
-
679
-
680
598
  _createClass__default["default"](ContentBuilder, [{
681
599
  key: "build",
682
600
  value: function build() {
683
601
  var _context,
684
- _context2,
685
- _this = this;
686
-
602
+ _context2,
603
+ _this = this;
687
604
  var emit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
688
-
689
605
  var allExamples = this._processGroup(this._config.examples);
690
-
691
606
  var okay = [];
692
607
  var fail = [];
693
608
  console.info(_concatInstanceProperty__default["default"](_context = "Going to generate ".concat(_flatInstanceProperty__default["default"](_context2 = [emit.index ? ["index files"] : [], emit.playgrounds ? ["playground openers"] : [], emit.screenshots ? ["screenshots"] : []]).call(_context2).join(", "), " for ")).call(_context, allExamples.length, " examples."));
694
609
  process.stdout.write("\n");
695
- var index = emit.index ? // Generate indexes.
610
+ var index = emit.index ?
611
+ // Generate indexes.
696
612
  _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2() {
697
613
  var _context3;
698
-
699
614
  var getStartStopMs, results;
700
615
  return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context5) {
701
- while (1) {
702
- switch (_context5.prev = _context5.next) {
703
- case 0:
704
- getStartStopMs = measureStartStopMs();
705
- _context5.next = 3;
706
- return _Promise__default["default"].allSettled(_mapInstanceProperty__default["default"](_context3 = _this._config.renderer.render(_this._config.examples, _this._config.output, _this._config.title, collator)).call(_context3, /*#__PURE__*/function () {
707
- var _ref3 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(_ref2) {
708
- var content, filename;
709
- return _regeneratorRuntime__default["default"].wrap(function _callee$(_context4) {
710
- while (1) {
711
- switch (_context4.prev = _context4.next) {
712
- case 0:
713
- content = _ref2.content, filename = _ref2.filename;
714
- return _context4.abrupt("return", writeFile(path.join(_this._config.output, filename), content));
715
-
716
- case 2:
717
- case "end":
718
- return _context4.stop();
719
- }
720
- }
721
- }, _callee);
722
- }));
723
-
724
- return function (_x) {
725
- return _ref3.apply(this, arguments);
726
- };
727
- }()));
728
-
729
- case 3:
730
- results = _context5.sent;
731
- return _context5.abrupt("return", [_objectSpread$1(_objectSpread$1({}, getStartStopMs()), {}, {
732
- count: results.length,
733
- result: _everyInstanceProperty__default["default"](results).call(results, function (_ref4) {
734
- var status = _ref4.status;
735
- return status === "fulfilled";
736
- }) ? "fulfilled" : "rejected"
737
- })]);
738
-
739
- case 5:
740
- case "end":
741
- return _context5.stop();
742
- }
616
+ while (1) switch (_context5.prev = _context5.next) {
617
+ case 0:
618
+ getStartStopMs = measureStartStopMs();
619
+ _context5.next = 3;
620
+ return _Promise__default["default"].allSettled(_mapInstanceProperty__default["default"](_context3 = _this._config.renderer.render(_this._config.examples, _this._config.output, _this._config.title, collator)).call(_context3, /*#__PURE__*/function () {
621
+ var _ref3 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(_ref2) {
622
+ var content, filename;
623
+ return _regeneratorRuntime__default["default"].wrap(function _callee$(_context4) {
624
+ while (1) switch (_context4.prev = _context4.next) {
625
+ case 0:
626
+ content = _ref2.content, filename = _ref2.filename;
627
+ return _context4.abrupt("return", writeFile(node_path.join(_this._config.output, filename), content));
628
+ case 2:
629
+ case "end":
630
+ return _context4.stop();
631
+ }
632
+ }, _callee);
633
+ }));
634
+ return function (_x) {
635
+ return _ref3.apply(this, arguments);
636
+ };
637
+ }()));
638
+ case 3:
639
+ results = _context5.sent;
640
+ return _context5.abrupt("return", [_objectSpread$1(_objectSpread$1({}, getStartStopMs()), {}, {
641
+ count: results.length,
642
+ result: _everyInstanceProperty__default["default"](results).call(results, function (_ref4) {
643
+ var status = _ref4.status;
644
+ return status === "fulfilled";
645
+ }) ? "fulfilled" : "rejected"
646
+ })]);
647
+ case 5:
648
+ case "end":
649
+ return _context5.stop();
743
650
  }
744
651
  }, _callee2);
745
- }))() : // Skip indexes.
652
+ }))() :
653
+ // Skip indexes.
746
654
  _Promise__default["default"].resolve([]);
747
- var playgrounds = emit.playgrounds ? // Generate playground pages.
655
+ var playgrounds = emit.playgrounds ?
656
+ // Generate playground pages.
748
657
  _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4() {
749
658
  return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context8) {
750
- while (1) {
751
- switch (_context8.prev = _context8.next) {
752
- case 0:
753
- _context8.next = 2;
754
- return _Promise__default["default"].all(_mapInstanceProperty__default["default"](allExamples).call(allExamples, /*#__PURE__*/function () {
755
- var _ref6 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(example) {
756
- var _context6;
757
-
758
- var getStartStopMs, results;
759
- return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context7) {
760
- while (1) {
761
- switch (_context7.prev = _context7.next) {
762
- case 0:
763
- getStartStopMs = measureStartStopMs();
764
- _context7.next = 3;
765
- return _Promise__default["default"].allSettled(_mapInstanceProperty__default["default"](_context6 = [{
766
- html: generateJSFiddlePage(example),
767
- path: example.paths.jsfiddle.local
768
- }, {
769
- html: generateCodePenPage(example),
770
- path: example.paths.codepen.local
771
- }]).call(_context6, function (_ref7) {
772
- var html = _ref7.html,
773
- path = _ref7.path;
774
- return writeFile(path, formatHTML(html));
775
- }));
776
-
777
- case 3:
778
- results = _context7.sent;
779
- return _context7.abrupt("return", _objectSpread$1(_objectSpread$1({}, getStartStopMs()), {}, {
780
- count: results.length,
781
- example: example,
782
- result: _everyInstanceProperty__default["default"](results).call(results, function (_ref8) {
783
- var status = _ref8.status;
784
- return status === "fulfilled";
785
- }) ? "fulfilled" : "rejected"
786
- }));
787
-
788
- case 5:
789
- case "end":
790
- return _context7.stop();
791
- }
792
- }
793
- }, _callee3);
794
- }));
795
-
796
- return function (_x2) {
797
- return _ref6.apply(this, arguments);
798
- };
799
- }()));
800
-
801
- case 2:
802
- return _context8.abrupt("return", _context8.sent);
803
-
804
- case 3:
805
- case "end":
806
- return _context8.stop();
807
- }
659
+ while (1) switch (_context8.prev = _context8.next) {
660
+ case 0:
661
+ _context8.next = 2;
662
+ return _Promise__default["default"].all(_mapInstanceProperty__default["default"](allExamples).call(allExamples, /*#__PURE__*/function () {
663
+ var _ref6 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(example) {
664
+ var _context6;
665
+ var getStartStopMs, results;
666
+ return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context7) {
667
+ while (1) switch (_context7.prev = _context7.next) {
668
+ case 0:
669
+ getStartStopMs = measureStartStopMs();
670
+ _context7.next = 3;
671
+ return _Promise__default["default"].allSettled(_mapInstanceProperty__default["default"](_context6 = [{
672
+ html: generateJSFiddlePage(example),
673
+ path: example.paths.jsfiddle.local
674
+ }, {
675
+ html: generateCodePenPage(example),
676
+ path: example.paths.codepen.local
677
+ }]).call(_context6, function (_ref7) {
678
+ var html = _ref7.html,
679
+ path = _ref7.path;
680
+ return writeFile(path, formatHTML(html));
681
+ }));
682
+ case 3:
683
+ results = _context7.sent;
684
+ return _context7.abrupt("return", _objectSpread$1(_objectSpread$1({}, getStartStopMs()), {}, {
685
+ count: results.length,
686
+ example: example,
687
+ result: _everyInstanceProperty__default["default"](results).call(results, function (_ref8) {
688
+ var status = _ref8.status;
689
+ return status === "fulfilled";
690
+ }) ? "fulfilled" : "rejected"
691
+ }));
692
+ case 5:
693
+ case "end":
694
+ return _context7.stop();
695
+ }
696
+ }, _callee3);
697
+ }));
698
+ return function (_x2) {
699
+ return _ref6.apply(this, arguments);
700
+ };
701
+ }()));
702
+ case 2:
703
+ return _context8.abrupt("return", _context8.sent);
704
+ case 3:
705
+ case "end":
706
+ return _context8.stop();
808
707
  }
809
708
  }, _callee4);
810
- }))() : // Skip playground pages.
709
+ }))() :
710
+ // Skip playground pages.
811
711
  _Promise__default["default"].resolve([]);
812
- var screenshots = emit.screenshots ? // Generate screenshots.
712
+ var screenshots = emit.screenshots ?
713
+ // Generate screenshots.
813
714
  _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee7() {
814
715
  var cleanup, _process$env$DEBUG, _context10, _context11, debug, browser, todo, total, reports, _context17, _iterator, _step, callback;
815
-
816
716
  return _regeneratorRuntime__default["default"].wrap(function _callee7$(_context18) {
817
- while (1) {
818
- switch (_context18.prev = _context18.next) {
819
- case 0:
820
- cleanup = [];
821
- _context18.prev = 1;
822
- debug = /^1|y|yes|true$/i.test((_process$env$DEBUG = process.env.DEBUG) !== null && _process$env$DEBUG !== void 0 ? _process$env$DEBUG : "");
823
- _context18.next = 5;
824
- return puppeteer__default["default"].launch({
825
- headless: !debug,
826
- slowMo: debug ? 100 : undefined
717
+ while (1) switch (_context18.prev = _context18.next) {
718
+ case 0:
719
+ cleanup = [];
720
+ _context18.prev = 1;
721
+ debug = /^1|y|yes|true$/i.test((_process$env$DEBUG = process.env.DEBUG) !== null && _process$env$DEBUG !== void 0 ? _process$env$DEBUG : "");
722
+ _context18.next = 5;
723
+ return puppeteer__default["default"].launch({
724
+ headless: !debug,
725
+ slowMo: debug ? 100 : undefined
726
+ });
727
+ case 5:
728
+ browser = _context18.sent;
729
+ if (debug) {
730
+ cleanup.push( /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5() {
731
+ return _regeneratorRuntime__default["default"].wrap(function _callee5$(_context9) {
732
+ while (1) switch (_context9.prev = _context9.next) {
733
+ case 0:
734
+ return _context9.abrupt("return", browser.disconnect());
735
+ case 1:
736
+ case "end":
737
+ return _context9.stop();
738
+ }
739
+ }, _callee5);
740
+ })));
741
+ } else {
742
+ cleanup.push(function () {
743
+ return browser.close();
827
744
  });
828
-
829
- case 5:
830
- browser = _context18.sent;
831
-
832
- if (debug) {
833
- cleanup.push( /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5() {
834
- return _regeneratorRuntime__default["default"].wrap(function _callee5$(_context9) {
835
- while (1) {
836
- switch (_context9.prev = _context9.next) {
837
- case 0:
838
- return _context9.abrupt("return", browser.disconnect());
839
-
840
- case 1:
841
- case "end":
842
- return _context9.stop();
843
- }
745
+ }
746
+ // Generate screenshots.
747
+ // There is quite long delay to ensure the chart is rendered properly
748
+ // so it's much faster to run a lot of them at the same time.
749
+ todo = _sliceInstanceProperty__default["default"](allExamples).call(allExamples);
750
+ total = todo.length;
751
+ reports = [];
752
+ _context18.next = 12;
753
+ return _Promise__default["default"].allSettled(_mapInstanceProperty__default["default"](_context10 = _fillInstanceProperty__default["default"](_context11 = new Array(_this._config.parallel)).call(_context11, null)).call(_context10, /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee6() {
754
+ var example, _context12, _context13, _context14, _context15, getStartStopMs, valid, report, percentage, validText, msText;
755
+ return _regeneratorRuntime__default["default"].wrap(function _callee6$(_context16) {
756
+ while (1) switch (_context16.prev = _context16.next) {
757
+ case 0:
758
+ if (!(example = todo.pop())) {
759
+ _context16.next = 14;
760
+ break;
844
761
  }
845
- }, _callee5);
846
- })));
847
- } else {
848
- cleanup.push(function () {
849
- return browser.close();
850
- });
851
- } // Generate screenshots.
852
- // There is quite long delay to ensure the chart is rendered properly
853
- // so it's much faster to run a lot of them at the same time.
854
-
855
-
856
- todo = _sliceInstanceProperty__default["default"](allExamples).call(allExamples);
857
- total = todo.length;
858
- reports = [];
859
- _context18.next = 12;
860
- return _Promise__default["default"].allSettled(_mapInstanceProperty__default["default"](_context10 = _fillInstanceProperty__default["default"](_context11 = new Array(_this._config.parallel)).call(_context11, null)).call(_context10, /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee6() {
861
- var example, _context12, _context13, _context14, _context15, getStartStopMs, valid, report, percentage, validText, msText;
862
-
863
- return _regeneratorRuntime__default["default"].wrap(function _callee6$(_context16) {
864
- while (1) {
865
- switch (_context16.prev = _context16.next) {
866
- case 0:
867
- if (!(example = todo.pop())) {
868
- _context16.next = 14;
869
- break;
870
- }
871
-
872
- getStartStopMs = measureStartStopMs();
873
- _context16.next = 4;
874
- return generateScreenshot(browser, {
875
- debug: debug,
876
- example: example,
877
- height: _this._config.renderer.screenshot.height,
878
- screenshotScript: _this._config.screenshotScript,
879
- width: _this._config.renderer.screenshot.width
880
- });
881
-
882
- case 4:
883
- valid = _context16.sent;
884
- report = _objectSpread$1(_objectSpread$1({}, getStartStopMs()), {}, {
885
- count: 1,
886
- example: example,
887
- result: valid ? "fulfilled" : "rejected"
888
- });
889
- reports.push(report);
890
-
891
- if (valid) {
892
- okay.push(example.path);
893
- } else {
894
- fail.push(example.path);
895
- }
896
-
897
- percentage = _padStartInstanceProperty__default["default"](_context12 = Math.floor(reports.length / total * 100) + "%").call(_context12, 4, " ");
898
- validText = valid ? "okay" : "fail";
899
- msText = formatStartStopMs(report);
900
- console.info(_concatInstanceProperty__default["default"](_context13 = _concatInstanceProperty__default["default"](_context14 = _concatInstanceProperty__default["default"](_context15 = "".concat(percentage, " ")).call(_context15, validText, " ")).call(_context14, msText, " - ")).call(_context13, example.path));
901
- _context16.next = 0;
902
- break;
903
-
904
- case 14:
905
- case "end":
906
- return _context16.stop();
762
+ getStartStopMs = measureStartStopMs();
763
+ _context16.next = 4;
764
+ return generateScreenshot(browser, {
765
+ debug: debug,
766
+ example: example,
767
+ height: _this._config.renderer.screenshot.height,
768
+ screenshotScript: _this._config.screenshotScript,
769
+ width: _this._config.renderer.screenshot.width
770
+ });
771
+ case 4:
772
+ valid = _context16.sent;
773
+ report = _objectSpread$1(_objectSpread$1({}, getStartStopMs()), {}, {
774
+ count: 1,
775
+ example: example,
776
+ result: valid ? "fulfilled" : "rejected"
777
+ });
778
+ reports.push(report);
779
+ if (valid) {
780
+ okay.push(example.path);
781
+ } else {
782
+ fail.push(example.path);
907
783
  }
908
- }
909
- }, _callee6);
910
- }))));
911
-
912
- case 12:
913
- return _context18.abrupt("return", reports);
914
-
915
- case 13:
916
- _context18.prev = 13;
917
- _iterator = _createForOfIteratorHelper$2(_reverseInstanceProperty__default["default"](_context17 = _spliceInstanceProperty__default["default"](cleanup).call(cleanup, 0)).call(_context17));
918
- _context18.prev = 15;
919
-
920
- _iterator.s();
921
-
922
- case 17:
923
- if ((_step = _iterator.n()).done) {
924
- _context18.next = 29;
925
- break;
926
- }
927
-
928
- callback = _step.value;
929
- _context18.prev = 19;
930
- _context18.next = 22;
931
- return callback();
932
-
933
- case 22:
934
- _context18.next = 27;
935
- break;
936
-
937
- case 24:
938
- _context18.prev = 24;
939
- _context18.t0 = _context18["catch"](19);
940
- console.error(_context18.t0);
941
-
942
- case 27:
943
- _context18.next = 17;
944
- break;
945
-
946
- case 29:
947
- _context18.next = 34;
784
+ percentage = _padStartInstanceProperty__default["default"](_context12 = Math.floor(reports.length / total * 100) + "%").call(_context12, 4, " ");
785
+ validText = valid ? "okay" : "fail";
786
+ msText = formatStartStopMs(report);
787
+ console.info(_concatInstanceProperty__default["default"](_context13 = _concatInstanceProperty__default["default"](_context14 = _concatInstanceProperty__default["default"](_context15 = "".concat(percentage, " ")).call(_context15, validText, " ")).call(_context14, msText, " - ")).call(_context13, example.path));
788
+ _context16.next = 0;
789
+ break;
790
+ case 14:
791
+ case "end":
792
+ return _context16.stop();
793
+ }
794
+ }, _callee6);
795
+ }))));
796
+ case 12:
797
+ return _context18.abrupt("return", reports);
798
+ case 13:
799
+ _context18.prev = 13;
800
+ _iterator = _createForOfIteratorHelper$2(_reverseInstanceProperty__default["default"](_context17 = _spliceInstanceProperty__default["default"](cleanup).call(cleanup, 0)).call(_context17));
801
+ _context18.prev = 15;
802
+ _iterator.s();
803
+ case 17:
804
+ if ((_step = _iterator.n()).done) {
805
+ _context18.next = 29;
948
806
  break;
949
-
950
- case 31:
951
- _context18.prev = 31;
952
- _context18.t1 = _context18["catch"](15);
953
-
954
- _iterator.e(_context18.t1);
955
-
956
- case 34:
957
- _context18.prev = 34;
958
-
959
- _iterator.f();
960
-
961
- return _context18.finish(34);
962
-
963
- case 37:
964
- return _context18.finish(13);
965
-
966
- case 38:
967
- case "end":
968
- return _context18.stop();
969
- }
807
+ }
808
+ callback = _step.value;
809
+ _context18.prev = 19;
810
+ _context18.next = 22;
811
+ return callback();
812
+ case 22:
813
+ _context18.next = 27;
814
+ break;
815
+ case 24:
816
+ _context18.prev = 24;
817
+ _context18.t0 = _context18["catch"](19);
818
+ console.error(_context18.t0);
819
+ case 27:
820
+ _context18.next = 17;
821
+ break;
822
+ case 29:
823
+ _context18.next = 34;
824
+ break;
825
+ case 31:
826
+ _context18.prev = 31;
827
+ _context18.t1 = _context18["catch"](15);
828
+ _iterator.e(_context18.t1);
829
+ case 34:
830
+ _context18.prev = 34;
831
+ _iterator.f();
832
+ return _context18.finish(34);
833
+ case 37:
834
+ return _context18.finish(13);
835
+ case 38:
836
+ case "end":
837
+ return _context18.stop();
970
838
  }
971
839
  }, _callee7, null, [[1,, 13, 38], [15, 31, 34, 37], [19, 24]]);
972
- }))() : // Skip screenshots.
840
+ }))() :
841
+ // Skip screenshots.
973
842
  _Promise__default["default"].resolve([]);
974
-
975
843
  var checks = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee8() {
976
844
  var total;
977
845
  return _regeneratorRuntime__default["default"].wrap(function _callee8$(_context19) {
978
- while (1) {
979
- switch (_context19.prev = _context19.next) {
980
- case 0:
981
- _context19.next = 2;
982
- return index;
983
-
984
- case 2:
985
- _context19.next = 4;
986
- return playgrounds;
987
-
988
- case 4:
989
- _context19.next = 6;
990
- return screenshots;
991
-
992
- case 6:
993
- total = okay.length + fail.length;
994
- return _context19.abrupt("return", {
995
- fail: fail.length,
996
- failPaths: fail,
997
- okay: okay.length,
998
- okayPaths: okay,
999
- percentage: total === 0 ? 100 : 100 * okay.length / total,
1000
- total: total
1001
- });
1002
-
1003
- case 8:
1004
- case "end":
1005
- return _context19.stop();
1006
- }
846
+ while (1) switch (_context19.prev = _context19.next) {
847
+ case 0:
848
+ _context19.next = 2;
849
+ return index;
850
+ case 2:
851
+ _context19.next = 4;
852
+ return playgrounds;
853
+ case 4:
854
+ _context19.next = 6;
855
+ return screenshots;
856
+ case 6:
857
+ total = okay.length + fail.length;
858
+ return _context19.abrupt("return", {
859
+ fail: fail.length,
860
+ failPaths: fail,
861
+ okay: okay.length,
862
+ okayPaths: okay,
863
+ percentage: total === 0 ? 100 : 100 * okay.length / total,
864
+ total: total
865
+ });
866
+ case 8:
867
+ case "end":
868
+ return _context19.stop();
1007
869
  }
1008
870
  }, _callee8);
1009
871
  }))();
1010
-
1011
872
  return {
1012
873
  checks: checks,
1013
874
  index: index,
@@ -1019,12 +880,10 @@ var ContentBuilder = /*#__PURE__*/function () {
1019
880
  key: "_processGroup",
1020
881
  value: function _processGroup(examples) {
1021
882
  var _context20,
1022
- _context21,
1023
- _this2 = this;
1024
-
883
+ _context21,
884
+ _this2 = this;
1025
885
  return _flatMapInstanceProperty__default["default"](_context20 = _sortInstanceProperty__default["default"](_context21 = _Object$keys__default["default"](examples)).call(_context21, collator.compare)).call(_context20, function (key) {
1026
886
  var example = examples[key];
1027
-
1028
887
  if (isExample(example)) {
1029
888
  return [example];
1030
889
  } else {
@@ -1033,7 +892,6 @@ var ContentBuilder = /*#__PURE__*/function () {
1033
892
  });
1034
893
  }
1035
894
  }]);
1036
-
1037
895
  return ContentBuilder;
1038
896
  }();
1039
897
 
@@ -1042,22 +900,17 @@ var indexTemplate = "<html>\n <head>\n <meta charset=\"utf-8\" />\n <titl
1042
900
  var styleTemplate = ".examples-root {\n margin: 50px auto 200px;\n min-width: calc(200px + 2em);\n width: calc(100vw - 200px);\n}\n\n.examples-root a {\n color: #2b7ce9;\n}\n.examples-root a:visited {\n color: #46417a;\n}\n\n.examples-root .example-link {\n margin: 1em;\n position: relative;\n width: 200px;\n\n display: inline-block;\n}\n\n.examples-root .example-link .example-image {\n display: block;\n height: 200px;\n margin-top: 1ex;\n position: relative;\n width: 200px;\n}\n.examples-root .example-link .example-image > img {\n position: absolute;\n top: 0px;\n left: 0px;\n width: 200px;\n height: 200px;\n\n background: #2b7ce9;\n border: 1px solid #2b7ce9;\n color: #ffffff;\n\n transition: transform 0.5s ease 0s, z-index 0.5s linear 0s;\n z-index: 1;\n}\n.examples-root .example-link:hover .example-image > img {\n transform: translate(0px, 95px) scale(2, 2);\n z-index: 100;\n}\n\n.examples-root .example-header > *:last-child {\n margin-left: 0.5em;\n}\n.examples-root .icon {\n height: 1.5em;\n margin-bottom: -0.25em;\n width: 1.5em;\n\n background: none;\n border: none;\n cursor: pointer;\n display: inline-block;\n}\n.examples-root .icon.jsfiddle {\n background-size: contain;\n background-image: url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3E%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%232b7ce9' d='M16.45,17.5C17.45,17.5 18.3,17.15 19,16.5C19.67,15.8 20,15 20,14C20,13.05 19.66,12.22 18.96,11.53C18.26,10.84 17.41,10.5 16.41,10.5C15.47,10.5 14.64,10.83 13.92,11.5L9.14,15.56C8.7,16 8.17,16.22 7.55,16.22C6.92,16.22 6.39,16 5.95,15.56C5.5,15.13 5.3,14.61 5.3,14C5.3,13.42 5.5,12.91 5.95,12.47C6.39,12.03 6.92,11.81 7.55,11.81C8.14,11.81 8.69,12.03 9.19,12.47L9.94,13.13L10.92,12.23L10.08,11.53C9.39,10.84 8.55,10.5 7.55,10.5C6.58,10.5 5.74,10.84 5.04,11.53C4.34,12.22 4,13.05 4,14C4,15 4.34,15.8 5.04,16.5C5.74,17.15 6.59,17.5 7.59,17.5C8.53,17.5 9.36,17.16 10.08,16.5L14.86,12.42C15.27,12 15.8,11.81 16.45,11.81C17.08,11.81 17.61,12.03 18.05,12.47C18.5,12.91 18.7,13.42 18.7,14C18.7,14.61 18.5,15.13 18.05,15.56C17.61,16 17.08,16.22 16.45,16.22C15.89,16.22 15.34,16 14.81,15.5L14.06,14.86L13.08,15.75L13.92,16.45C14.61,17.14 15.45,17.5 16.45,17.5M19.36,10.03C20.64,10.13 21.73,10.65 22.64,11.6C23.55,12.55 24,13.69 24,15C24,16.38 23.5,17.55 22.5,18.54C21.54,19.5 20.36,20 19,20H6C4.34,20 2.93,19.43 1.76,18.26C0.59,17.09 0,15.67 0,14C0,12.55 0.5,11.23 1.57,10.05C2.62,8.88 3.88,8.22 5.34,8.06C6,6.84 6.92,5.86 8.11,5.11C9.3,4.36 10.59,4 12,4C13.69,4 15.26,4.58 16.71,5.77C18.16,6.95 19.05,8.38 19.36,10.03Z' /%3E%3C/svg%3E\");\n}\n.examples-root .icon.codepen {\n background-size: contain;\n background-image: url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3E%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%232b7ce9' d='M15.09,12L12,14.08V14.09L8.91,12L12,9.92V9.92L15.09,12M12,2C11.84,2 11.68,2.06 11.53,2.15L2.5,8.11C2.27,8.22 2.09,8.43 2,8.67V14.92C2,15.33 2,15.33 2.15,15.53L11.53,21.86C11.67,21.96 11.84,22 12,22C12.16,22 12.33,21.95 12.47,21.85L21.85,15.5C22,15.33 22,15.33 22,14.92V8.67C21.91,8.42 21.73,8.22 21.5,8.1L12.47,2.15C12.32,2.05 12.16,2 12,2M16.58,13L19.59,15.04L12.83,19.6V15.53L16.58,13M19.69,8.9L16.58,11L12.83,8.47V4.38L19.69,8.9M20.33,10.47V13.53L18.07,12L20.33,10.47M7.42,13L11.17,15.54V19.6L4.41,15.04L7.42,13M4.31,8.9L11.17,4.39V8.5L7.42,11L4.31,8.9M3.67,10.5L5.93,12L3.67,13.54V10.5Z' /%3E%3C/svg%3E\");\n}\n";
1043
901
 
1044
902
  function _createForOfIteratorHelper$1(o, allowArrayLike) { var it = typeof _Symbol__default["default"] !== "undefined" && _getIteratorMethod__default["default"](o) || o["@@iterator"]; if (!it) { if (_Array$isArray__default["default"](o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
1045
-
1046
903
  function _unsupportedIterableToArray$1(o, minLen) { var _context3; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = _sliceInstanceProperty__default["default"](_context3 = Object.prototype.toString.call(o)).call(_context3, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from__default["default"](o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
1047
-
1048
- function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
904
+ function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
1049
905
  /**
1050
906
  * @param example
1051
907
  */
1052
-
1053
908
  function generateJSFiddle(example) {
1054
909
  return $__default["default"]("<a>").addClass("icon jsfiddle").attr("href", example.paths.jsfiddle.web).attr("title", "JSFiddle");
1055
910
  }
1056
911
  /**
1057
912
  * @param example
1058
913
  */
1059
-
1060
-
1061
914
  function generateCodePen(example) {
1062
915
  return $__default["default"]("<a>").addClass("icon codepen").attr("href", example.paths.codepen.web).attr("title", "CodePen");
1063
916
  }
@@ -1067,28 +920,24 @@ function generateCodePen(example) {
1067
920
  * @param level
1068
921
  * @param collator
1069
922
  */
1070
-
1071
-
1072
923
  function processGroup$1(examples, title, level, collator) {
1073
924
  var _context;
1074
-
1075
925
  var heading = $__default["default"]("<h".concat(Math.max(1, Math.min(6, level)), ">"));
1076
926
  heading.text(title);
1077
927
  var list = $__default["default"]("<div>");
1078
928
  var section = $__default["default"]("<div>");
1079
929
  section.append(heading, list);
1080
-
1081
930
  var _iterator = _createForOfIteratorHelper$1(_sortInstanceProperty__default["default"](_context = _Object$keys__default["default"](examples)).call(_context, collator.compare)),
1082
- _step;
1083
-
931
+ _step;
1084
932
  try {
1085
933
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
1086
934
  var key = _step.value;
1087
935
  var example = examples[key];
1088
-
1089
936
  if (isExample(example)) {
1090
- var header = $__default["default"]("<div>").addClass("example-header").append( // Playgrounds
1091
- generateJSFiddle(example), generateCodePen(example), // Title
937
+ var header = $__default["default"]("<div>").addClass("example-header").append(
938
+ // Playgrounds
939
+ generateJSFiddle(example), generateCodePen(example),
940
+ // Title
1092
941
  $__default["default"]("<a>").attr("href", example.paths.page.web).text(key));
1093
942
  var image = $__default["default"]("<a>").addClass("example-image").attr("href", example.paths.page.web).append($__default["default"]("<img>").attr("src", example.paths.screenshot.web).attr("alt", key));
1094
943
  var item = $__default["default"]("<span>").addClass("example-link").append(header, image);
@@ -1102,21 +951,16 @@ function processGroup$1(examples, title, level, collator) {
1102
951
  } finally {
1103
952
  _iterator.f();
1104
953
  }
1105
-
1106
954
  return section;
1107
955
  }
1108
-
1109
956
  var htmlRenderer = {
1110
957
  render: function render(examples, _output, title, collator) {
1111
958
  var _context2;
1112
-
1113
959
  var filename = "index.html";
1114
960
  var root = $__default["default"]("<div>");
1115
961
  root.addClass("examples-root");
1116
-
1117
962
  var _iterator2 = _createForOfIteratorHelper$1(_sortInstanceProperty__default["default"](_context2 = _Object$keys__default["default"](examples)).call(_context2, collator.compare)),
1118
- _step2;
1119
-
963
+ _step2;
1120
964
  try {
1121
965
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1122
966
  var key = _step2.value;
@@ -1127,7 +971,6 @@ var htmlRenderer = {
1127
971
  } finally {
1128
972
  _iterator2.f();
1129
973
  }
1130
-
1131
974
  var page = $__default["default"].load(indexTemplate);
1132
975
  page("title").text(title);
1133
976
  page("body").append(root);
@@ -1149,18 +992,13 @@ var htmlRenderer = {
1149
992
  };
1150
993
 
1151
994
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1152
-
1153
995
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context14, _context15; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context14 = ownKeys(Object(source), !0)).call(_context14, function (key) { _defineProperty__default["default"](target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context15 = ownKeys(Object(source))).call(_context15, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
1154
-
1155
996
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol__default["default"] !== "undefined" && _getIteratorMethod__default["default"](o) || o["@@iterator"]; if (!it) { if (_Array$isArray__default["default"](o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
1156
-
1157
997
  function _unsupportedIterableToArray(o, minLen) { var _context13; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty__default["default"](_context13 = Object.prototype.toString.call(o)).call(_context13, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from__default["default"](o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
1158
-
1159
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
998
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
1160
999
  /**
1161
1000
  * @param lines
1162
1001
  */
1163
-
1164
1002
  function linesToContent(lines) {
1165
1003
  return formatMD(lines.join("\n"));
1166
1004
  }
@@ -1169,22 +1007,16 @@ function linesToContent(lines) {
1169
1007
  * @param src
1170
1008
  * @param href
1171
1009
  */
1172
-
1173
-
1174
1010
  function image(title, src, href) {
1175
1011
  var _context, _context2;
1176
-
1177
1012
  return href == null ? _concatInstanceProperty__default["default"](_context = "![".concat(title, "](")).call(_context, src, ")") : link(href, _concatInstanceProperty__default["default"](_context2 = "![".concat(title, "](")).call(_context2, src, ")"));
1178
1013
  }
1179
1014
  /**
1180
1015
  * @param href
1181
1016
  * @param text
1182
1017
  */
1183
-
1184
-
1185
1018
  function link(href) {
1186
1019
  var _context3;
1187
-
1188
1020
  var text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : href;
1189
1021
  return _concatInstanceProperty__default["default"](_context3 = "[".concat(text, "](")).call(_context3, href, ")");
1190
1022
  }
@@ -1192,11 +1024,8 @@ function link(href) {
1192
1024
  * @param level
1193
1025
  * @param text
1194
1026
  */
1195
-
1196
-
1197
1027
  function header(level, text) {
1198
1028
  var _context4, _context5;
1199
-
1200
1029
  return _concatInstanceProperty__default["default"](_context4 = "".concat(_repeatInstanceProperty__default["default"](_context5 = "#").call(_context5, level), " ")).call(_context4, text);
1201
1030
  }
1202
1031
  /**
@@ -1205,29 +1034,22 @@ function header(level, text) {
1205
1034
  * @param title
1206
1035
  * @param collator
1207
1036
  */
1208
-
1209
-
1210
1037
  function processGroup(examples, output, title, collator) {
1211
1038
  var _context6, _context7, _context8;
1212
-
1213
1039
  var items = [];
1214
1040
  var sections = [];
1215
1041
  var filenamePart = title.replace(/[^a-zA-Z0-9]/g, "-").toLowerCase();
1216
-
1217
1042
  var _iterator = _createForOfIteratorHelper(_sortInstanceProperty__default["default"](_context8 = _Object$keys__default["default"](examples)).call(_context8, collator.compare)),
1218
- _step;
1219
-
1043
+ _step;
1220
1044
  try {
1221
1045
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
1222
1046
  var key = _step.value;
1223
1047
  var example = examples[key];
1224
-
1225
1048
  if (isExample(example)) {
1226
1049
  // An example in this group.
1227
- items.push(header(2, key), "", image(key, "./" + path.relative(output, example.paths.screenshot.local), example.paths.page.web), "", [link(example.paths.page.web, "Open"), link(example.paths.jsfiddle.web, "JSFiddle"), link(example.paths.codepen.web, "CodePen")].join(" | "), "");
1050
+ items.push(header(2, key), "", image(key, "./" + node_path.relative(output, example.paths.screenshot.local), example.paths.page.web), "", [link(example.paths.page.web, "Open"), link(example.paths.jsfiddle.web, "JSFiddle"), link(example.paths.codepen.web, "CodePen")].join(" | "), "");
1228
1051
  } else {
1229
1052
  var _context9;
1230
-
1231
1053
  // A subgroup of examples.
1232
1054
  sections.push.apply(sections, _toConsumableArray__default["default"](_mapInstanceProperty__default["default"](_context9 = processGroup(example, output, key, collator)).call(_context9, function (contentPart) {
1233
1055
  return _objectSpread(_objectSpread({}, contentPart), {}, {
@@ -1241,23 +1063,18 @@ function processGroup(examples, output, title, collator) {
1241
1063
  } finally {
1242
1064
  _iterator.f();
1243
1065
  }
1244
-
1245
1066
  return _concatInstanceProperty__default["default"](_context6 = [{
1246
1067
  content: linesToContent(_concatInstanceProperty__default["default"](_context7 = [header(1, title), ""]).call(_context7, items)),
1247
1068
  filename: filenamePart + ".md",
1248
1069
  title: title
1249
1070
  }]).call(_context6, sections);
1250
1071
  }
1251
-
1252
1072
  var mdRenderer = {
1253
1073
  render: function render(examples, output, _title, collator) {
1254
1074
  var _context10, _context11, _context12;
1255
-
1256
1075
  var sections = [];
1257
-
1258
1076
  var _iterator2 = _createForOfIteratorHelper(_sortInstanceProperty__default["default"](_context12 = _Object$keys__default["default"](examples)).call(_context12, collator.compare)),
1259
- _step2;
1260
-
1077
+ _step2;
1261
1078
  try {
1262
1079
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1263
1080
  var key = _step2.value;
@@ -1268,11 +1085,10 @@ var mdRenderer = {
1268
1085
  } finally {
1269
1086
  _iterator2.f();
1270
1087
  }
1271
-
1272
1088
  return _concatInstanceProperty__default["default"](_context10 = [{
1273
1089
  content: linesToContent(_concatInstanceProperty__default["default"](_context11 = [header(1, "Examples"), ""]).call(_context11, _toConsumableArray__default["default"](_mapInstanceProperty__default["default"](sections).call(sections, function (_ref) {
1274
1090
  var filename = _ref.filename,
1275
- title = _ref.title;
1091
+ title = _ref.title;
1276
1092
  return "- " + link("./" + filename, title);
1277
1093
  })))),
1278
1094
  filename: "README.md",
@@ -1360,7 +1176,6 @@ var y = yargs__default["default"].strict(true).usage("generate-example-index [op
1360
1176
  /**
1361
1177
  *
1362
1178
  */
1363
-
1364
1179
  function parseArguments() {
1365
1180
  return y.parserConfiguration({
1366
1181
  "camel-case-expansion": false
@@ -1370,14 +1185,13 @@ function parseArguments() {
1370
1185
  /**
1371
1186
  * @param urls
1372
1187
  */
1373
-
1374
1188
  function joinURLs() {
1375
1189
  for (var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++) {
1376
1190
  urls[_key] = arguments[_key];
1377
1191
  }
1378
-
1379
1192
  return _mapInstanceProperty__default["default"](urls).call(urls, function (url) {
1380
- return (// Strip the parts of leading and trailing slashes if they have them.
1193
+ return (
1194
+ // Strip the parts of leading and trailing slashes if they have them.
1381
1195
  url.replace(/^\/?(.*?)\/?$/, "$1")
1382
1196
  );
1383
1197
  }).join("/");
@@ -1386,22 +1200,22 @@ function joinURLs() {
1386
1200
  * @param baseURL
1387
1201
  * @param url
1388
1202
  */
1389
-
1390
1203
  function fixAbsoluteInputURL(baseURL, url) {
1391
- return _startsWithInstanceProperty__default["default"](url).call(url, "/") ? // Relative to the base URL. Base URL starts and URL ends with a slash.
1392
- baseURL + _sliceInstanceProperty__default["default"](url).call(url, 1) : // Relative to some other point or absolute already.
1204
+ return _startsWithInstanceProperty__default["default"](url).call(url, "/") ?
1205
+ // Relative to the base URL. Base URL starts and URL ends with a slash.
1206
+ baseURL + _sliceInstanceProperty__default["default"](url).call(url, 1) :
1207
+ // Relative to some other point or absolute already.
1393
1208
  url;
1394
1209
  }
1395
1210
  /**
1396
1211
  * @param config
1397
1212
  * @param exampleAbsolutePath
1398
1213
  */
1399
-
1400
1214
  function generatePaths(config, exampleAbsolutePath) {
1401
- var exampleRelativePath = path.relative(config.page.local, exampleAbsolutePath); // It's important that the hash is created from the relative path so that it
1215
+ var exampleRelativePath = node_path.relative(config.page.local, exampleAbsolutePath);
1216
+ // It's important that the hash is created from the relative path so that it
1402
1217
  // is the same on all computers.
1403
-
1404
- var hash = crypto.createHash("sha256").update(exampleRelativePath).digest("hex");
1218
+ var hash = node_crypto.createHash("sha256").update(exampleRelativePath).digest("hex");
1405
1219
  return {
1406
1220
  codepen: generateLocalWebPair(config.codepen.local, config.codepen.web, hash, "codepen", "html"),
1407
1221
  jsfiddle: generateLocalWebPair(config.jsfiddle.local, config.jsfiddle.web, hash, "jsfiddle", "html"),
@@ -1419,27 +1233,25 @@ function generatePaths(config, exampleAbsolutePath) {
1419
1233
  * @param prefix
1420
1234
  * @param extension
1421
1235
  */
1422
-
1423
1236
  function generateLocalWebPair(localRoot, webRoot, hash, prefix, extension) {
1424
1237
  var _context, _context2;
1425
-
1426
1238
  var filename = _concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = "".concat(prefix, ".")).call(_context2, hash, ".")).call(_context, extension);
1427
-
1428
1239
  return {
1429
- local: path.resolve(localRoot, filename),
1240
+ local: node_path.resolve(localRoot, filename),
1430
1241
  web: joinURLs(webRoot, filename)
1431
1242
  };
1432
1243
  }
1433
1244
 
1434
- var argv = parseArguments(); // Log the parsed configuration for debugging purposes.
1435
-
1245
+ var globby = Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('globby')); });
1246
+ var argv = parseArguments();
1247
+ // Log the parsed configuration for debugging purposes.
1436
1248
  console.info("Configuration: ", _JSON$stringify__default["default"](argv, null, 2));
1437
- process.stdout.write("\n"); // Pageres uses quite a lot of listeners when invoked multiple times in
1249
+ process.stdout.write("\n");
1250
+ // Pageres uses quite a lot of listeners when invoked multiple times in
1438
1251
  // parallel. This ensures there are no warnings about it.
1439
-
1440
- process.setMaxListeners(40); // Resolve paths relative to PWD.
1441
-
1442
- var screenshotScriptPath = typeof argv["screenshot-script"] === "string" ? path.resolve(argv["screenshot-script"]) : undefined;
1252
+ process.setMaxListeners(40);
1253
+ // Resolve paths relative to PWD.
1254
+ var screenshotScriptPath = typeof argv["screenshot-script"] === "string" ? node_path.resolve(argv["screenshot-script"]) : undefined;
1443
1255
  var mkdir = util__default["default"].promisify(fs__default["default"].mkdir);
1444
1256
  var readFile = util__default["default"].promisify(fs__default["default"].readFile);
1445
1257
  /**
@@ -1451,10 +1263,8 @@ var readFile = util__default["default"].promisify(fs__default["default"].readFil
1451
1263
  * @returns The value “smartly” coerced or the fallback if conversion isn't
1452
1264
  * possible or the value is not present in the page.
1453
1265
  */
1454
-
1455
1266
  function getMeta(page, name, fallback) {
1456
1267
  var content = page("meta[name=\"".concat(name, "\"]")).attr("content");
1457
-
1458
1268
  if (content == null) {
1459
1269
  // No meta of this name exists in the page, use the fallback.
1460
1270
  return fallback;
@@ -1476,376 +1286,306 @@ function getMeta(page, name, fallback) {
1476
1286
  * @param page - The HTML to be linted.
1477
1287
  * @returns True if everything's okay, false otherwise.
1478
1288
  */
1479
-
1480
-
1481
1289
  function lintExample(path, page) {
1482
1290
  var _context, _context2, _context3;
1483
-
1484
1291
  var valid = true;
1485
1292
  var msgs = ["".concat(path, ":")];
1486
-
1487
1293
  if (page("#title").length !== 1) {
1488
1294
  msgs.push("Missing #title element in the body.");
1489
1295
  valid = false;
1490
1296
  }
1491
-
1492
1297
  if (page("#title > *").length < 2) {
1493
1298
  msgs.push("There have to be at least two headings (group and example name).");
1494
1299
  valid = false;
1495
1300
  }
1496
-
1497
1301
  var headTitle = _trimInstanceProperty__default["default"](_context = page("head > title").text()).call(_context);
1498
-
1499
1302
  var bodyTitle = _trimInstanceProperty__default["default"](_context2 = _mapInstanceProperty__default["default"](_context3 = page("#title > *")).call(_context3, function (_i, elem) {
1500
1303
  return $__default["default"](elem).text();
1501
1304
  }).get().join(" | ")).call(_context2);
1502
-
1503
1305
  if (headTitle !== bodyTitle) {
1504
1306
  msgs.push("The title in the head doesn't match the title in the body.", " head: ".concat(headTitle), " body: ".concat(bodyTitle));
1505
1307
  valid = false;
1506
1308
  }
1507
-
1508
1309
  if (msgs.length > 1) {
1509
1310
  console.warn("\n" + msgs.join("\n "));
1510
1311
  }
1511
-
1512
1312
  return valid;
1513
1313
  }
1514
-
1515
1314
  _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3() {
1516
1315
  var _context4, _context6;
1517
-
1518
1316
  var code, baseURL, pathsConfig, examples, selector, stats, skipped, _context11, screenshotScript, builtData, _context12, _context13, cummulativeReport, _context14, _context15, _cummulativeReport, _context16, _context17, _cummulativeReport2, checks, _context18, _context23, _context19, _context20, _context21, _context22;
1519
-
1520
1317
  return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context24) {
1521
- while (1) {
1522
- switch (_context24.prev = _context24.next) {
1523
- case 0:
1524
- code = 0;
1525
-
1526
- if (!(!argv.index && !argv.screenshots && !argv.lint)) {
1527
- _context24.next = 4;
1528
- break;
1529
- }
1530
-
1531
- yargs__default["default"].parse("--help");
1532
- return _context24.abrupt("return");
1533
-
1534
- case 4:
1535
- _context24.next = 6;
1536
- return _Promise__default["default"].all(_mapInstanceProperty__default["default"](_context4 = [argv["assets-local-directory"], argv["examples-local-directory"], argv["output-directory"], argv["pages-local-directory"]]).call(_context4, /*#__PURE__*/function () {
1537
- var _ref2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(path) {
1538
- return _regeneratorRuntime__default["default"].wrap(function _callee$(_context5) {
1539
- while (1) {
1540
- switch (_context5.prev = _context5.next) {
1541
- case 0:
1542
- _context5.next = 2;
1543
- return mkdir(path, {
1544
- recursive: true
1545
- });
1546
-
1547
- case 2:
1548
- case "end":
1549
- return _context5.stop();
1550
- }
1551
- }
1552
- }, _callee);
1553
- }));
1554
-
1555
- return function (_x) {
1556
- return _ref2.apply(this, arguments);
1557
- };
1558
- }()));
1559
-
1560
- case 6:
1561
- baseURL = argv["base-url"];
1562
-
1563
- if (_endsWithInstanceProperty__default["default"](baseURL).call(baseURL, "/")) {
1564
- _context24.next = 9;
1565
- break;
1566
- }
1567
-
1568
- throw new Error("Base URL (`base-url`) has to end with a slash (`/`).");
1569
-
1570
- case 9:
1571
- // Paths.
1572
- pathsConfig = {
1573
- codepen: {
1574
- local: argv["pages-local-directory"],
1575
- web: fixAbsoluteInputURL(baseURL, argv["pages-web-directory"])
1576
- },
1577
- jsfiddle: {
1578
- local: argv["pages-local-directory"],
1579
- web: fixAbsoluteInputURL(baseURL, argv["pages-web-directory"])
1580
- },
1581
- page: {
1582
- local: argv["examples-local-directory"],
1583
- web: fixAbsoluteInputURL(baseURL, argv["examples-web-directory"])
1584
- },
1585
- screenshot: {
1586
- local: argv["assets-local-directory"],
1587
- web: fixAbsoluteInputURL(baseURL, argv["assets-web-directory"])
1588
- }
1589
- };
1590
- examples = {};
1591
- selector = "#" + argv["container-id"];
1592
- stats = {
1593
- examples: 0
1318
+ while (1) switch (_context24.prev = _context24.next) {
1319
+ case 0:
1320
+ code = 0;
1321
+ if (!(!argv.index && !argv.screenshots && !argv.lint)) {
1322
+ _context24.next = 4;
1323
+ break;
1324
+ }
1325
+ yargs__default["default"].parse("--help");
1326
+ return _context24.abrupt("return");
1327
+ case 4:
1328
+ _context24.next = 6;
1329
+ return _Promise__default["default"].all(_mapInstanceProperty__default["default"](_context4 = [argv["assets-local-directory"], argv["examples-local-directory"], argv["output-directory"], argv["pages-local-directory"]]).call(_context4, /*#__PURE__*/function () {
1330
+ var _ref2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(path) {
1331
+ return _regeneratorRuntime__default["default"].wrap(function _callee$(_context5) {
1332
+ while (1) switch (_context5.prev = _context5.next) {
1333
+ case 0:
1334
+ _context5.next = 2;
1335
+ return mkdir(path, {
1336
+ recursive: true
1337
+ });
1338
+ case 2:
1339
+ case "end":
1340
+ return _context5.stop();
1341
+ }
1342
+ }, _callee);
1343
+ }));
1344
+ return function (_x) {
1345
+ return _ref2.apply(this, arguments);
1594
1346
  };
1595
- skipped = [];
1596
- _context24.t0 = _Promise__default["default"];
1597
- _context24.t1 = _mapInstanceProperty__default["default"];
1598
- _context24.next = 18;
1599
- return globby__default["default"](path.join(pathsConfig.page.local, "**/*.html"));
1600
-
1601
- case 18:
1602
- _context24.t2 = _context6 = _context24.sent;
1603
- _context24.t3 = (0, _context24.t1)(_context24.t2).call(_context6, /*#__PURE__*/function () {
1604
- var _ref3 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(pagePath) {
1605
- var _context7;
1606
-
1607
- var html, $page, pageDelay, pageTimeout, pageSelector, titles, _context9;
1608
-
1609
- return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context10) {
1610
- while (1) {
1611
- switch (_context10.prev = _context10.next) {
1612
- case 0:
1613
- _context10.next = 2;
1614
- return readFile(pagePath, "utf-8");
1615
-
1616
- case 2:
1617
- html = _context10.sent;
1618
- $page = $__default["default"].load(html);
1619
- pageDelay = getMeta($page, "example-screenshot-delay", 6);
1620
- pageTimeout = getMeta($page, "example-screenshot-timeout", 60);
1621
- pageSelector = getMeta($page, "example-screenshot-selector", selector); // Is this an examples?
1622
-
1623
- if (!($page(pageSelector).length === 0)) {
1624
- _context10.next = 10;
1625
- break;
1626
- }
1627
-
1628
- skipped.push(pagePath);
1629
- return _context10.abrupt("return");
1630
-
1631
- case 10:
1632
- // Lint if requested.
1633
- if (argv.lint) {
1634
- lintExample(pagePath, $page);
1635
- } // Body titles.
1636
-
1637
-
1638
- titles = _mapInstanceProperty__default["default"](_context7 = $page("#title > *").get()).call(_context7, function (elem) {
1639
- var _context8;
1640
-
1641
- return _trimInstanceProperty__default["default"](_context8 = $page(elem).text()).call(_context8);
1642
- }); // Head title fallback.
1643
-
1644
- if (titles.length < 2) {
1645
- titles = _mapInstanceProperty__default["default"](_context9 = $page("head > title").text().split("|")).call(_context9, function (title) {
1646
- return _trimInstanceProperty__default["default"](title).call(title);
1647
- });
1648
- } // File path fallback.
1649
-
1650
-
1651
- if (titles.length < 2) {
1652
- titles = pagePath.split("/");
1653
- } // Just ignore it.
1654
-
1655
-
1656
- if (!(titles.length < 2)) {
1657
- _context10.next = 17;
1658
- break;
1659
- }
1660
-
1661
- console.error("Title resolution failed. Skipping.");
1662
- return _context10.abrupt("return");
1663
-
1664
- case 17:
1665
- // Put this example into the structure while creating any missing groups in the process.
1666
- _reduceInstanceProperty__default["default"](titles).call(titles, function (acc, title, i, arr) {
1667
- while (acc[title] != null && acc[title].path != null) {
1668
- console.error("The following group already exists: ", titles);
1669
- title += "!";
1670
- }
1671
-
1672
- if (i === arr.length - 1) {
1673
- if (acc[title] != null) {
1674
- console.error("The following example has the same name as an already existing group: ", titles);
1675
- return null;
1676
- } else {
1677
- var example = {
1678
- $: $page,
1679
- delay: pageDelay,
1680
- html: html,
1681
- path: pagePath,
1682
- paths: generatePaths(pathsConfig, pagePath),
1683
- playground: generatePlaygroundData(baseURL, $page, pagePath),
1684
- selector: pageSelector,
1685
- timeout: pageTimeout,
1686
- titles: titles
1687
- };
1688
- acc[title] = example;
1689
- ++stats.examples;
1690
- }
1691
- } else {
1692
- return acc[title] = acc[title] || {};
1693
- }
1694
- }, examples);
1695
-
1696
- case 18:
1697
- case "end":
1698
- return _context10.stop();
1699
- }
1700
- }
1701
- }, _callee2);
1702
- }));
1703
-
1704
- return function (_x2) {
1705
- return _ref3.apply(this, arguments);
1706
- };
1707
- }());
1708
- _context24.next = 22;
1709
- return _context24.t0.all.call(_context24.t0, _context24.t3);
1710
-
1711
- case 22:
1712
- if (skipped.length) {
1713
- process.stdout.write("\n");
1714
- console.info(_concatInstanceProperty__default["default"](_context11 = ["The following files don't look like examples (there is nothing to take a screenshot of):"]).call(_context11, _toConsumableArray__default["default"](_sortInstanceProperty__default["default"](skipped).call(skipped))).join("\n "));
1715
- }
1716
-
1717
- if (!(stats.examples === 0)) {
1718
- _context24.next = 27;
1719
- break;
1720
- }
1721
-
1722
- console.info("No usable example files were found.");
1723
- _context24.next = 67;
1347
+ }()));
1348
+ case 6:
1349
+ baseURL = argv["base-url"];
1350
+ if (_endsWithInstanceProperty__default["default"](baseURL).call(baseURL, "/")) {
1351
+ _context24.next = 9;
1724
1352
  break;
1725
-
1726
- case 27:
1727
- if (!(argv.index || argv.playgrounds || argv.screenshots)) {
1728
- _context24.next = 67;
1729
- break;
1353
+ }
1354
+ throw new Error("Base URL (`base-url`) has to end with a slash (`/`).");
1355
+ case 9:
1356
+ // Paths.
1357
+ pathsConfig = {
1358
+ codepen: {
1359
+ local: argv["pages-local-directory"],
1360
+ web: fixAbsoluteInputURL(baseURL, argv["pages-web-directory"])
1361
+ },
1362
+ jsfiddle: {
1363
+ local: argv["pages-local-directory"],
1364
+ web: fixAbsoluteInputURL(baseURL, argv["pages-web-directory"])
1365
+ },
1366
+ page: {
1367
+ local: argv["examples-local-directory"],
1368
+ web: fixAbsoluteInputURL(baseURL, argv["examples-web-directory"])
1369
+ },
1370
+ screenshot: {
1371
+ local: argv["assets-local-directory"],
1372
+ web: fixAbsoluteInputURL(baseURL, argv["assets-web-directory"])
1730
1373
  }
1731
-
1374
+ };
1375
+ examples = {};
1376
+ selector = "#" + argv["container-id"];
1377
+ stats = {
1378
+ examples: 0
1379
+ };
1380
+ skipped = [];
1381
+ _context24.t0 = _Promise__default["default"];
1382
+ _context24.t1 = _mapInstanceProperty__default["default"];
1383
+ _context24.next = 18;
1384
+ return globby;
1385
+ case 18:
1386
+ _context24.next = 20;
1387
+ return _context24.sent.default(node_path.join(pathsConfig.page.local, "**/*.html"));
1388
+ case 20:
1389
+ _context24.t2 = _context6 = _context24.sent;
1390
+ _context24.t3 = (0, _context24.t1)(_context24.t2).call(_context6, /*#__PURE__*/function () {
1391
+ var _ref3 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(pagePath) {
1392
+ var _context7;
1393
+ var html, $page, pageDelay, pageTimeout, pageSelector, titles, _context9;
1394
+ return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context10) {
1395
+ while (1) switch (_context10.prev = _context10.next) {
1396
+ case 0:
1397
+ _context10.next = 2;
1398
+ return readFile(pagePath, "utf-8");
1399
+ case 2:
1400
+ html = _context10.sent;
1401
+ $page = $__default["default"].load(html);
1402
+ pageDelay = getMeta($page, "example-screenshot-delay", 6);
1403
+ pageTimeout = getMeta($page, "example-screenshot-timeout", 60);
1404
+ pageSelector = getMeta($page, "example-screenshot-selector", selector); // Is this an examples?
1405
+ if (!($page(pageSelector).length === 0)) {
1406
+ _context10.next = 10;
1407
+ break;
1408
+ }
1409
+ skipped.push(pagePath);
1410
+ return _context10.abrupt("return");
1411
+ case 10:
1412
+ // Lint if requested.
1413
+ if (argv.lint) {
1414
+ lintExample(pagePath, $page);
1415
+ }
1416
+ // Body titles.
1417
+ titles = _mapInstanceProperty__default["default"](_context7 = $page("#title > *").get()).call(_context7, function (elem) {
1418
+ var _context8;
1419
+ return _trimInstanceProperty__default["default"](_context8 = $page(elem).text()).call(_context8);
1420
+ }); // Head title fallback.
1421
+ if (titles.length < 2) {
1422
+ titles = _mapInstanceProperty__default["default"](_context9 = $page("head > title").text().split("|")).call(_context9, function (title) {
1423
+ return _trimInstanceProperty__default["default"](title).call(title);
1424
+ });
1425
+ }
1426
+ // File path fallback.
1427
+ if (titles.length < 2) {
1428
+ titles = pagePath.split("/");
1429
+ }
1430
+ // Just ignore it.
1431
+ if (!(titles.length < 2)) {
1432
+ _context10.next = 17;
1433
+ break;
1434
+ }
1435
+ console.error("Title resolution failed. Skipping.");
1436
+ return _context10.abrupt("return");
1437
+ case 17:
1438
+ // Put this example into the structure while creating any missing groups in the process.
1439
+ _reduceInstanceProperty__default["default"](titles).call(titles, function (acc, title, i, arr) {
1440
+ while (acc[title] != null && acc[title].path != null) {
1441
+ console.error("The following group already exists: ", titles);
1442
+ title += "!";
1443
+ }
1444
+ if (i === arr.length - 1) {
1445
+ if (acc[title] != null) {
1446
+ console.error("The following example has the same name as an already existing group: ", titles);
1447
+ return null;
1448
+ } else {
1449
+ var example = {
1450
+ $: $page,
1451
+ delay: pageDelay,
1452
+ html: html,
1453
+ path: pagePath,
1454
+ paths: generatePaths(pathsConfig, pagePath),
1455
+ playground: generatePlaygroundData(baseURL, $page, pagePath),
1456
+ selector: pageSelector,
1457
+ timeout: pageTimeout,
1458
+ titles: titles
1459
+ };
1460
+ acc[title] = example;
1461
+ ++stats.examples;
1462
+ }
1463
+ } else {
1464
+ return acc[title] = acc[title] || {};
1465
+ }
1466
+ }, examples);
1467
+ case 18:
1468
+ case "end":
1469
+ return _context10.stop();
1470
+ }
1471
+ }, _callee2);
1472
+ }));
1473
+ return function (_x2) {
1474
+ return _ref3.apply(this, arguments);
1475
+ };
1476
+ }());
1477
+ _context24.next = 24;
1478
+ return _context24.t0.all.call(_context24.t0, _context24.t3);
1479
+ case 24:
1480
+ if (skipped.length) {
1732
1481
  process.stdout.write("\n");
1733
-
1734
- if (!(screenshotScriptPath != null)) {
1735
- _context24.next = 38;
1736
- break;
1737
- }
1738
-
1739
- _context24.next = 32;
1740
- return readFile(screenshotScriptPath, "utf-8");
1741
-
1742
- case 32:
1743
- _context24.t5 = _context24.sent;
1744
-
1745
- if (_context24.t5) {
1746
- _context24.next = 35;
1747
- break;
1748
- }
1749
-
1750
- _context24.t5 = "";
1751
-
1752
- case 35:
1753
- _context24.t4 = _context24.t5;
1754
- _context24.next = 39;
1482
+ console.info(_concatInstanceProperty__default["default"](_context11 = ["The following files don't look like examples (there is nothing to take a screenshot of):"]).call(_context11, _toConsumableArray__default["default"](_sortInstanceProperty__default["default"](skipped).call(skipped))).join("\n "));
1483
+ }
1484
+ if (!(stats.examples === 0)) {
1485
+ _context24.next = 29;
1755
1486
  break;
1756
-
1757
- case 38:
1758
- _context24.t4 = "";
1759
-
1760
- case 39:
1761
- screenshotScript = _context24.t4;
1762
- builtData = new ContentBuilder({
1763
- examples: examples,
1764
- output: path.resolve(argv["output-directory"]),
1765
- parallel: argv.parallel,
1766
- renderer: argv.format === "md" ? mdRenderer : htmlRenderer,
1767
- screenshotScript: screenshotScript,
1768
- title: argv.title
1769
- }).build({
1770
- index: argv.index,
1771
- playgrounds: argv.playgrounds,
1772
- screenshots: argv.screenshots
1773
- }); // Create and write the page.
1774
-
1775
- if (!argv.index) {
1776
- _context24.next = 48;
1777
- break;
1778
- }
1779
-
1780
- _context24.t6 = reduceReports;
1781
- _context24.next = 45;
1782
- return builtData.index;
1783
-
1784
- case 45:
1785
- _context24.t7 = _context24.sent;
1786
- cummulativeReport = (0, _context24.t6)(_context24.t7);
1787
- console.info(_concatInstanceProperty__default["default"](_context12 = _concatInstanceProperty__default["default"](_context13 = "Index with ".concat(stats.examples, " examples written (")).call(_context13, cummulativeReport.count, " files in ")).call(_context12, formatStartStopMs(cummulativeReport), ")."));
1788
-
1789
- case 48:
1790
- if (!argv.index) {
1791
- _context24.next = 55;
1792
- break;
1793
- }
1794
-
1795
- _context24.t8 = reduceReports;
1796
- _context24.next = 52;
1797
- return builtData.playgrounds;
1798
-
1799
- case 52:
1800
- _context24.t9 = _context24.sent;
1801
- _cummulativeReport = (0, _context24.t8)(_context24.t9);
1802
- console.info(_concatInstanceProperty__default["default"](_context14 = _concatInstanceProperty__default["default"](_context15 = "Playground opener files for ".concat(stats.examples, " examples written (")).call(_context15, _cummulativeReport.count, " files in ")).call(_context14, formatStartStopMs(_cummulativeReport), ")."));
1803
-
1804
- case 55:
1805
- if (!argv.screenshots) {
1806
- _context24.next = 62;
1807
- break;
1808
- }
1809
-
1810
- _context24.t10 = reduceReports;
1811
- _context24.next = 59;
1812
- return builtData.screenshots;
1813
-
1814
- case 59:
1815
- _context24.t11 = _context24.sent;
1816
- _cummulativeReport2 = (0, _context24.t10)(_context24.t11);
1817
- console.info(_concatInstanceProperty__default["default"](_context16 = _concatInstanceProperty__default["default"](_context17 = "Screenshot files for ".concat(stats.examples, " written (")).call(_context17, _cummulativeReport2.count, " files in ")).call(_context16, formatStartStopMs(_cummulativeReport2), ")."));
1818
-
1819
- case 62:
1487
+ }
1488
+ console.info("No usable example files were found.");
1489
+ _context24.next = 69;
1490
+ break;
1491
+ case 29:
1492
+ if (!(argv.index || argv.playgrounds || argv.screenshots)) {
1493
+ _context24.next = 69;
1494
+ break;
1495
+ }
1496
+ process.stdout.write("\n");
1497
+ if (!(screenshotScriptPath != null)) {
1498
+ _context24.next = 40;
1499
+ break;
1500
+ }
1501
+ _context24.next = 34;
1502
+ return readFile(screenshotScriptPath, "utf-8");
1503
+ case 34:
1504
+ _context24.t5 = _context24.sent;
1505
+ if (_context24.t5) {
1506
+ _context24.next = 37;
1507
+ break;
1508
+ }
1509
+ _context24.t5 = "";
1510
+ case 37:
1511
+ _context24.t4 = _context24.t5;
1512
+ _context24.next = 41;
1513
+ break;
1514
+ case 40:
1515
+ _context24.t4 = "";
1516
+ case 41:
1517
+ screenshotScript = _context24.t4;
1518
+ builtData = new ContentBuilder({
1519
+ examples: examples,
1520
+ output: node_path.resolve(argv["output-directory"]),
1521
+ parallel: argv.parallel,
1522
+ renderer: argv.format === "md" ? mdRenderer : htmlRenderer,
1523
+ screenshotScript: screenshotScript,
1524
+ title: argv.title
1525
+ }).build({
1526
+ index: argv.index,
1527
+ playgrounds: argv.playgrounds,
1528
+ screenshots: argv.screenshots
1529
+ }); // Create and write the page.
1530
+ if (!argv.index) {
1531
+ _context24.next = 50;
1532
+ break;
1533
+ }
1534
+ _context24.t6 = reduceReports;
1535
+ _context24.next = 47;
1536
+ return builtData.index;
1537
+ case 47:
1538
+ _context24.t7 = _context24.sent;
1539
+ cummulativeReport = (0, _context24.t6)(_context24.t7);
1540
+ console.info(_concatInstanceProperty__default["default"](_context12 = _concatInstanceProperty__default["default"](_context13 = "Index with ".concat(stats.examples, " examples written (")).call(_context13, cummulativeReport.count, " files in ")).call(_context12, formatStartStopMs(cummulativeReport), ")."));
1541
+ case 50:
1542
+ if (!argv.index) {
1543
+ _context24.next = 57;
1544
+ break;
1545
+ }
1546
+ _context24.t8 = reduceReports;
1547
+ _context24.next = 54;
1548
+ return builtData.playgrounds;
1549
+ case 54:
1550
+ _context24.t9 = _context24.sent;
1551
+ _cummulativeReport = (0, _context24.t8)(_context24.t9);
1552
+ console.info(_concatInstanceProperty__default["default"](_context14 = _concatInstanceProperty__default["default"](_context15 = "Playground opener files for ".concat(stats.examples, " examples written (")).call(_context15, _cummulativeReport.count, " files in ")).call(_context14, formatStartStopMs(_cummulativeReport), ")."));
1553
+ case 57:
1554
+ if (!argv.screenshots) {
1820
1555
  _context24.next = 64;
1821
- return builtData.checks;
1822
-
1823
- case 64:
1824
- checks = _context24.sent;
1825
- process.stdout.write("\n");
1826
-
1827
- if (checks.fail === 0) {
1828
- console.info(_concatInstanceProperty__default["default"](_context18 = "Verification: ".concat(checks.okay, " passed (")).call(_context18, Math.round(checks.percentage), " %) passed."));
1556
+ break;
1557
+ }
1558
+ _context24.t10 = reduceReports;
1559
+ _context24.next = 61;
1560
+ return builtData.screenshots;
1561
+ case 61:
1562
+ _context24.t11 = _context24.sent;
1563
+ _cummulativeReport2 = (0, _context24.t10)(_context24.t11);
1564
+ console.info(_concatInstanceProperty__default["default"](_context16 = _concatInstanceProperty__default["default"](_context17 = "Screenshot files for ".concat(stats.examples, " written (")).call(_context17, _cummulativeReport2.count, " files in ")).call(_context16, formatStartStopMs(_cummulativeReport2), ")."));
1565
+ case 64:
1566
+ _context24.next = 66;
1567
+ return builtData.checks;
1568
+ case 66:
1569
+ checks = _context24.sent;
1570
+ process.stdout.write("\n");
1571
+ if (checks.fail === 0) {
1572
+ console.info(_concatInstanceProperty__default["default"](_context18 = "Verification: ".concat(checks.okay, " passed (")).call(_context18, Math.round(checks.percentage), " %) passed."));
1573
+ } else {
1574
+ if (checks.percentage >= argv.verify) {
1575
+ console.info(_concatInstanceProperty__default["default"](_context19 = _concatInstanceProperty__default["default"](_context20 = "Verification: ".concat(checks.okay, " passed (")).call(_context20, Math.round(checks.percentage), " %), ")).call(_context19, checks.fail, " failed.\n") + "This is within the threshold set by --verify.");
1829
1576
  } else {
1830
- if (checks.percentage >= argv.verify) {
1831
- console.info(_concatInstanceProperty__default["default"](_context19 = _concatInstanceProperty__default["default"](_context20 = "Verification: ".concat(checks.okay, " passed (")).call(_context20, Math.round(checks.percentage), " %), ")).call(_context19, checks.fail, " failed.\n") + "This is within the threshold set by --verify.");
1832
- } else {
1833
- console.error(_concatInstanceProperty__default["default"](_context21 = _concatInstanceProperty__default["default"](_context22 = "Verification: Only ".concat(checks.okay, " passed (")).call(_context22, Math.round(checks.percentage), " %), ")).call(_context21, checks.fail, " failed.\n") + "This is not within the threshold set by --verify. Exiting with an error.");
1834
- code = 3;
1835
- }
1836
-
1837
- _forEachInstanceProperty__default["default"](_context23 = checks.failPaths).call(_context23, function (path) {
1838
- console.error(path);
1839
- });
1577
+ console.error(_concatInstanceProperty__default["default"](_context21 = _concatInstanceProperty__default["default"](_context22 = "Verification: Only ".concat(checks.okay, " passed (")).call(_context22, Math.round(checks.percentage), " %), ")).call(_context21, checks.fail, " failed.\n") + "This is not within the threshold set by --verify. Exiting with an error.");
1578
+ code = 3;
1840
1579
  }
1841
-
1842
- case 67:
1843
- process.exitCode = code;
1844
-
1845
- case 68:
1846
- case "end":
1847
- return _context24.stop();
1848
- }
1580
+ _forEachInstanceProperty__default["default"](_context23 = checks.failPaths).call(_context23, function (path) {
1581
+ console.error(path);
1582
+ });
1583
+ }
1584
+ case 69:
1585
+ process.exitCode = code;
1586
+ case 70:
1587
+ case "end":
1588
+ return _context24.stop();
1849
1589
  }
1850
1590
  }, _callee3);
1851
1591
  }))().catch(function (error) {