vis-dev-utils 3.0.118 → 3.0.119

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.119
10
+ * @date 2023-02-15T13:55:48.580Z
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
@@ -143,13 +143,10 @@ function isExample(value) {
143
143
  /**
144
144
  *
145
145
  */
146
-
147
146
  function measureStartStopMs() {
148
147
  var start = _Date$now__default["default"]();
149
-
150
148
  return function () {
151
149
  var stop = _Date$now__default["default"]();
152
-
153
150
  return {
154
151
  start: start,
155
152
  stop: stop
@@ -160,10 +157,8 @@ function measureStartStopMs() {
160
157
  * @param reports
161
158
  * @param fallback
162
159
  */
163
-
164
160
  function reduceReports(reports) {
165
161
  var _reports$reduce;
166
-
167
162
  var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
168
163
  count: 0,
169
164
  result: "fulfilled",
@@ -172,7 +167,6 @@ function reduceReports(reports) {
172
167
  };
173
168
  return (_reports$reduce = _reduceInstanceProperty__default["default"](reports).call(reports, function (acc, val) {
174
169
  var _acc$count, _val$count, _context, _acc$result, _acc$start, _acc$stop;
175
-
176
170
  return {
177
171
  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
172
  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 +182,9 @@ function reduceReports(reports) {
188
182
  * @param root0.start
189
183
  * @param root0.stop
190
184
  */
191
-
192
185
  function formatStartStopMs(_ref) {
193
186
  var start = _ref.start,
194
- stop = _ref.stop;
187
+ stop = _ref.stop;
195
188
  return "".concat((Math.round((stop - start) / 100) / 10).toFixed(1), "s");
196
189
  }
197
190
 
@@ -221,14 +214,12 @@ var template$1 = "<html>\n <head>\n <meta charset=\"utf-8\" />\n <title>C
221
214
  /**
222
215
  * @param example
223
216
  */
224
-
225
217
  function generateCodePenPage(example) {
226
218
  var data = example.playground;
227
219
  var title = example.titles.join(" | ");
228
220
  var page = $__default["default"].load(template$1);
229
221
  page("title").text(title);
230
222
  var form = page("#form");
231
-
232
223
  _findInstanceProperty__default["default"](form).call(form, 'input[name="data"]').attr("value", _JSON$stringify__default["default"]({
233
224
  css: data.code.css,
234
225
  css_external: data.resources.css.join(";"),
@@ -237,7 +228,6 @@ function generateCodePenPage(example) {
237
228
  js_external: data.resources.js.join(";"),
238
229
  title: example.titles.join(" | ")
239
230
  }));
240
-
241
231
  return page.html();
242
232
  }
243
233
 
@@ -246,55 +236,50 @@ function generateCodePenPage(example) {
246
236
  * @param example$
247
237
  * @param examplePath
248
238
  */
249
-
250
239
  function generatePlaygroundData(baseURL, example$, examplePath) {
251
240
  var _context, _context2, _context3, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12, _context13, _context14;
252
-
253
241
  // JavaScript
254
242
  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
243
  var _ref2 = _slicedToArray__default["default"](_ref, 1),
256
- name = _ref2[0];
257
-
244
+ name = _ref2[0];
258
245
  return /^on/.test(name);
259
246
  })).call(_context2, function (_ref3) {
260
247
  var _ref4 = _slicedToArray__default["default"](_ref3, 2),
261
- name = _ref4[0],
262
- value = _ref4[1];
263
-
248
+ name = _ref4[0],
249
+ value = _ref4[1];
264
250
  return [_sliceInstanceProperty__default["default"](name).call(name, 2), "".concat(value)];
265
251
  })).call(_context, function (_ref5) {
266
252
  var _context4;
267
-
268
253
  var _ref6 = _slicedToArray__default["default"](_ref5, 2),
269
- name = _ref6[0],
270
- value = _ref6[1];
271
-
254
+ name = _ref6[0],
255
+ value = _ref6[1];
272
256
  return _concatInstanceProperty__default["default"](_context4 = "window.addEventListener(\"".concat(name, "\", () => { ")).call(_context4, value, " });");
273
257
  }).join("\n");
274
-
275
258
  var js = formatJS(_mapInstanceProperty__default["default"](_context5 = _mapInstanceProperty__default["default"](_context6 = example$("script")).call(_context6, function (_i, elem) {
276
259
  return elem.children[0];
277
260
  }).get()).call(_context5, function (elem) {
278
261
  return elem.data;
279
- }).join("") + "\n\n;" + eventListeners); // Cascading Style Sheets
280
-
262
+ }).join("") + "\n\n;" + eventListeners);
263
+ // Cascading Style Sheets
281
264
  var css = formatCSS(_mapInstanceProperty__default["default"](_context7 = _mapInstanceProperty__default["default"](_context8 = example$("style")).call(_context8, function (_i, elem) {
282
265
  return elem.children[0];
283
266
  }).get()).call(_context7, function (elem) {
284
267
  return elem.data;
285
- }).join("")); // Hypertext Markup Language
286
-
268
+ }).join(""));
269
+ // Hypertext Markup Language
287
270
  var $html = $__default["default"].load(example$("body").html() || "");
288
271
  $html("script").remove();
289
- var html = formatHTML($html("body").html()); // Resources
290
-
272
+ var html = formatHTML($html("body").html());
273
+ // Resources
291
274
  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.
275
+ return /^https?:\/\//.test(rawPath) ?
276
+ // World wide web absolute.
277
+ rawPath : /^\//.test(rawPath) ?
278
+ // Domain absolute.
279
+ baseURL + _sliceInstanceProperty__default["default"](rawPath).call(rawPath, 1) :
280
+ //Relative.
295
281
  baseURL + path.relative(process.cwd(), path.resolve(path.dirname(examplePath), rawPath));
296
282
  };
297
-
298
283
  var resources = {
299
284
  js: _mapInstanceProperty__default["default"](_context9 = _filterInstanceProperty__default["default"](_context10 = _mapInstanceProperty__default["default"](_context11 = example$("script")).call(_context11, function (_i, elem) {
300
285
  return $__default["default"](elem).attr("src");
@@ -322,41 +307,29 @@ var template = "<html>\n <head>\n <meta charset=\"utf-8\" />\n <title>JSF
322
307
  /**
323
308
  * @param example
324
309
  */
325
-
326
310
  function generateJSFiddlePage(example) {
327
311
  var _context;
328
-
329
312
  var data = example.playground;
330
313
  var title = example.titles.join(" | ");
331
-
332
314
  var resources = _concatInstanceProperty__default["default"](_context = []).call(_context, _toConsumableArray__default["default"](data.resources.css), _toConsumableArray__default["default"](data.resources.js)).join(",");
333
-
334
315
  var page = $__default["default"].load(template);
335
316
  page("title").text(title);
336
- var form = page("#form"); // Playground data.
337
-
317
+ var form = page("#form");
318
+ // Playground data.
338
319
  _findInstanceProperty__default["default"](form).call(form, 'input[name="css"]').attr("value", data.code.css);
339
-
340
320
  _findInstanceProperty__default["default"](form).call(form, 'input[name="html"]').attr("value", data.code.html);
341
-
342
321
  _findInstanceProperty__default["default"](form).call(form, 'input[name="js"]').attr("value", data.code.js);
343
-
344
322
  _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
-
323
+ _findInstanceProperty__default["default"](form).call(form, 'input[name="title"]').attr("value", title);
324
+ // Don't run JS before the DOM is ready.
349
325
  _findInstanceProperty__default["default"](form).call(form, 'input[name="wrap"]').attr("value", "b");
350
-
351
326
  return page.html();
352
327
  }
353
328
 
354
329
  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
330
 
356
331
  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
332
  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
333
  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
334
  var unlink = util.promisify(fs__default["default"].unlink);
362
335
  var writeFile$1 = util.promisify(fs__default["default"].writeFile);
@@ -368,7 +341,6 @@ var writeFile$1 = util.promisify(fs__default["default"].writeFile);
368
341
  * @param screenshot - The binary data of the screenshot.
369
342
  * @returns True for valid and false for invalid.
370
343
  */
371
-
372
344
  function isScreenshotValid(_x) {
373
345
  return _isScreenshotValid.apply(this, arguments);
374
346
  }
@@ -380,8 +352,6 @@ function isScreenshotValid(_x) {
380
352
  * @param config - See the type's docs for detail.
381
353
  * @returns Whether or not the screenshot passed validation check.
382
354
  */
383
-
384
-
385
355
  function _isScreenshotValid() {
386
356
  _isScreenshotValid = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(screenshot) {
387
357
  var image, firstPixel, x, y;
@@ -391,46 +361,36 @@ function _isScreenshotValid() {
391
361
  case 0:
392
362
  _context.next = 2;
393
363
  return Jimp__default["default"].read(screenshot);
394
-
395
364
  case 2:
396
365
  image = _context.sent;
397
366
  firstPixel = image.getPixelColor(0, 0);
398
367
  x = 0;
399
-
400
368
  case 5:
401
369
  if (!(x < image.getWidth())) {
402
370
  _context.next = 16;
403
371
  break;
404
372
  }
405
-
406
373
  y = 0;
407
-
408
374
  case 7:
409
375
  if (!(y < image.getHeight())) {
410
376
  _context.next = 13;
411
377
  break;
412
378
  }
413
-
414
379
  if (!(firstPixel !== image.getPixelColor(x, y))) {
415
380
  _context.next = 10;
416
381
  break;
417
382
  }
418
-
419
383
  return _context.abrupt("return", true);
420
-
421
384
  case 10:
422
385
  ++y;
423
386
  _context.next = 7;
424
387
  break;
425
-
426
388
  case 13:
427
389
  ++x;
428
390
  _context.next = 5;
429
391
  break;
430
-
431
392
  case 16:
432
393
  return _context.abrupt("return", false);
433
-
434
394
  case 17:
435
395
  case "end":
436
396
  return _context.stop();
@@ -440,15 +400,12 @@ function _isScreenshotValid() {
440
400
  }));
441
401
  return _isScreenshotValid.apply(this, arguments);
442
402
  }
443
-
444
403
  function generateScreenshot(_x2, _x3) {
445
404
  return _generateScreenshot.apply(this, arguments);
446
405
  }
447
-
448
406
  function _generateScreenshot() {
449
407
  _generateScreenshot = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(browser, config) {
450
408
  var debug, example, height, screenshotScript, width, cleanup, tmpPath, screenshotPage, context, page, $element, _context2, screenshot, _context3, _iterator, _step, callback;
451
-
452
409
  return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context4) {
453
410
  while (1) {
454
411
  switch (_context4.prev = _context4.next) {
@@ -463,180 +420,137 @@ function _generateScreenshot() {
463
420
  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
421
  _context4.next = 8;
465
422
  return writeFile$1(tmpPath, formatHTML(screenshotPage.html()));
466
-
467
423
  case 8:
468
424
  if (!debug) {
469
425
  cleanup.push(function () {
470
426
  return unlink(tmpPath);
471
427
  });
472
428
  }
473
-
474
429
  _context4.next = 11;
475
430
  return browser.createIncognitoBrowserContext();
476
-
477
431
  case 11:
478
432
  context = _context4.sent;
479
-
480
433
  if (!debug) {
481
434
  cleanup.push(function () {
482
435
  return context.close();
483
436
  });
484
437
  }
485
-
486
438
  _context4.next = 15;
487
439
  return context.newPage();
488
-
489
440
  case 15:
490
441
  page = _context4.sent;
491
-
492
442
  if (!debug) {
493
443
  cleanup.push(function () {
494
444
  return page.close();
495
445
  });
496
446
  }
497
-
498
447
  _context4.next = 19;
499
448
  return page.setViewport({
500
449
  width: width + 50,
501
450
  height: height + 50
502
451
  });
503
-
504
452
  case 19:
505
453
  _context4.next = 21;
506
454
  return page.goto("file://" + tmpPath.split(path.sep).join(path.posix.sep));
507
-
508
455
  case 21:
509
456
  _context4.next = 23;
510
457
  return page.waitForSelector(example.selector, {
511
458
  visible: true,
512
459
  timeout: example.timeout * 1000
513
460
  });
514
-
515
461
  case 23:
516
462
  if (!(example.delay === "call")) {
517
463
  _context4.next = 28;
518
464
  break;
519
465
  }
520
-
521
466
  _context4.next = 26;
522
467
  return page.evaluate("function fn() { return window.readyToTakeAScreenshot; }");
523
-
524
468
  case 26:
525
469
  _context4.next = 30;
526
470
  break;
527
-
528
471
  case 28:
529
472
  _context4.next = 30;
530
473
  return page.waitForTimeout(example.delay * 1000);
531
-
532
474
  case 30:
533
475
  _context4.next = 32;
534
476
  return page.$(example.selector);
535
-
536
477
  case 32:
537
478
  $element = _context4.sent;
538
-
539
479
  if (!($element == null)) {
540
480
  _context4.next = 35;
541
481
  break;
542
482
  }
543
-
544
483
  throw new Error(_concatInstanceProperty__default["default"](_context2 = "Element \"".concat(example.selector, "\" not found in ")).call(_context2, example.path, "."));
545
-
546
484
  case 35:
547
485
  _context4.next = 37;
548
486
  return $element.evaluate(function (element) {
549
487
  element.scrollIntoView();
550
488
  });
551
-
552
489
  case 37:
553
490
  _context4.next = 39;
554
491
  return $element.screenshot({
555
492
  encoding: "binary"
556
493
  });
557
-
558
494
  case 39:
559
495
  screenshot = _context4.sent;
560
-
561
496
  if (!(screenshot == null)) {
562
497
  _context4.next = 44;
563
498
  break;
564
499
  }
565
-
566
500
  throw new Error("Failed to take screenshot of \u201C".concat(example.paths.page, "\u201D"));
567
-
568
501
  case 44:
569
502
  if (!(typeof screenshot === "string")) {
570
503
  _context4.next = 46;
571
504
  break;
572
505
  }
573
-
574
506
  throw new Error("Failed to get the binary data of the screenshot of \u201C".concat(example.paths.page, "\u201D"));
575
-
576
507
  case 46:
577
508
  _context4.next = 48;
578
509
  return writeFile$1(example.paths.screenshot.local, screenshot);
579
-
580
510
  case 48:
581
511
  return _context4.abrupt("return", isScreenshotValid(screenshot));
582
-
583
512
  case 51:
584
513
  _context4.prev = 51;
585
514
  _context4.t0 = _context4["catch"](2);
586
515
  console.error(_context4.t0);
587
516
  return _context4.abrupt("return", false);
588
-
589
517
  case 55:
590
518
  _context4.prev = 55;
591
519
  _iterator = _createForOfIteratorHelper$3(_reverseInstanceProperty__default["default"](_context3 = _spliceInstanceProperty__default["default"](cleanup).call(cleanup, 0)).call(_context3));
592
520
  _context4.prev = 57;
593
-
594
521
  _iterator.s();
595
-
596
522
  case 59:
597
523
  if ((_step = _iterator.n()).done) {
598
524
  _context4.next = 71;
599
525
  break;
600
526
  }
601
-
602
527
  callback = _step.value;
603
528
  _context4.prev = 61;
604
529
  _context4.next = 64;
605
530
  return callback();
606
-
607
531
  case 64:
608
532
  _context4.next = 69;
609
533
  break;
610
-
611
534
  case 66:
612
535
  _context4.prev = 66;
613
536
  _context4.t1 = _context4["catch"](61);
614
537
  console.error(_context4.t1);
615
-
616
538
  case 69:
617
539
  _context4.next = 59;
618
540
  break;
619
-
620
541
  case 71:
621
542
  _context4.next = 76;
622
543
  break;
623
-
624
544
  case 73:
625
545
  _context4.prev = 73;
626
546
  _context4.t2 = _context4["catch"](57);
627
-
628
547
  _iterator.e(_context4.t2);
629
-
630
548
  case 76:
631
549
  _context4.prev = 76;
632
-
633
550
  _iterator.f();
634
-
635
551
  return _context4.finish(76);
636
-
637
552
  case 79:
638
553
  return _context4.finish(55);
639
-
640
554
  case 80:
641
555
  case "end":
642
556
  return _context4.stop();
@@ -648,22 +562,16 @@ function _generateScreenshot() {
648
562
  }
649
563
 
650
564
  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
565
  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
566
  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
-
656
567
  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
568
  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
569
  var collator = new Intl.Collator("US");
660
570
  var writeFile = util.promisify(fs__default["default"].writeFile);
661
571
  var ContentBuilder = /*#__PURE__*/function () {
662
572
  function ContentBuilder(_config) {
663
573
  _classCallCheck__default["default"](this, ContentBuilder);
664
-
665
574
  _defineProperty__default["default"](this, "_config", void 0);
666
-
667
575
  this._config = _config;
668
576
  }
669
577
  /**
@@ -675,27 +583,22 @@ var ContentBuilder = /*#__PURE__*/function () {
675
583
  * @param emit.screenshots
676
584
  * @returns A report with check results and the number of written files.
677
585
  */
678
-
679
-
680
586
  _createClass__default["default"](ContentBuilder, [{
681
587
  key: "build",
682
588
  value: function build() {
683
589
  var _context,
684
- _context2,
685
- _this = this;
686
-
590
+ _context2,
591
+ _this = this;
687
592
  var emit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
688
-
689
593
  var allExamples = this._processGroup(this._config.examples);
690
-
691
594
  var okay = [];
692
595
  var fail = [];
693
596
  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
597
  process.stdout.write("\n");
695
- var index = emit.index ? // Generate indexes.
598
+ var index = emit.index ?
599
+ // Generate indexes.
696
600
  _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2() {
697
601
  var _context3;
698
-
699
602
  var getStartStopMs, results;
700
603
  return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context5) {
701
604
  while (1) {
@@ -712,7 +615,6 @@ var ContentBuilder = /*#__PURE__*/function () {
712
615
  case 0:
713
616
  content = _ref2.content, filename = _ref2.filename;
714
617
  return _context4.abrupt("return", writeFile(path.join(_this._config.output, filename), content));
715
-
716
618
  case 2:
717
619
  case "end":
718
620
  return _context4.stop();
@@ -720,12 +622,10 @@ var ContentBuilder = /*#__PURE__*/function () {
720
622
  }
721
623
  }, _callee);
722
624
  }));
723
-
724
625
  return function (_x) {
725
626
  return _ref3.apply(this, arguments);
726
627
  };
727
628
  }()));
728
-
729
629
  case 3:
730
630
  results = _context5.sent;
731
631
  return _context5.abrupt("return", [_objectSpread$1(_objectSpread$1({}, getStartStopMs()), {}, {
@@ -735,16 +635,17 @@ var ContentBuilder = /*#__PURE__*/function () {
735
635
  return status === "fulfilled";
736
636
  }) ? "fulfilled" : "rejected"
737
637
  })]);
738
-
739
638
  case 5:
740
639
  case "end":
741
640
  return _context5.stop();
742
641
  }
743
642
  }
744
643
  }, _callee2);
745
- }))() : // Skip indexes.
644
+ }))() :
645
+ // Skip indexes.
746
646
  _Promise__default["default"].resolve([]);
747
- var playgrounds = emit.playgrounds ? // Generate playground pages.
647
+ var playgrounds = emit.playgrounds ?
648
+ // Generate playground pages.
748
649
  _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4() {
749
650
  return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context8) {
750
651
  while (1) {
@@ -754,7 +655,6 @@ var ContentBuilder = /*#__PURE__*/function () {
754
655
  return _Promise__default["default"].all(_mapInstanceProperty__default["default"](allExamples).call(allExamples, /*#__PURE__*/function () {
755
656
  var _ref6 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(example) {
756
657
  var _context6;
757
-
758
658
  var getStartStopMs, results;
759
659
  return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context7) {
760
660
  while (1) {
@@ -770,10 +670,9 @@ var ContentBuilder = /*#__PURE__*/function () {
770
670
  path: example.paths.codepen.local
771
671
  }]).call(_context6, function (_ref7) {
772
672
  var html = _ref7.html,
773
- path = _ref7.path;
673
+ path = _ref7.path;
774
674
  return writeFile(path, formatHTML(html));
775
675
  }));
776
-
777
676
  case 3:
778
677
  results = _context7.sent;
779
678
  return _context7.abrupt("return", _objectSpread$1(_objectSpread$1({}, getStartStopMs()), {}, {
@@ -784,7 +683,6 @@ var ContentBuilder = /*#__PURE__*/function () {
784
683
  return status === "fulfilled";
785
684
  }) ? "fulfilled" : "rejected"
786
685
  }));
787
-
788
686
  case 5:
789
687
  case "end":
790
688
  return _context7.stop();
@@ -792,27 +690,25 @@ var ContentBuilder = /*#__PURE__*/function () {
792
690
  }
793
691
  }, _callee3);
794
692
  }));
795
-
796
693
  return function (_x2) {
797
694
  return _ref6.apply(this, arguments);
798
695
  };
799
696
  }()));
800
-
801
697
  case 2:
802
698
  return _context8.abrupt("return", _context8.sent);
803
-
804
699
  case 3:
805
700
  case "end":
806
701
  return _context8.stop();
807
702
  }
808
703
  }
809
704
  }, _callee4);
810
- }))() : // Skip playground pages.
705
+ }))() :
706
+ // Skip playground pages.
811
707
  _Promise__default["default"].resolve([]);
812
- var screenshots = emit.screenshots ? // Generate screenshots.
708
+ var screenshots = emit.screenshots ?
709
+ // Generate screenshots.
813
710
  _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee7() {
814
711
  var cleanup, _process$env$DEBUG, _context10, _context11, debug, browser, todo, total, reports, _context17, _iterator, _step, callback;
815
-
816
712
  return _regeneratorRuntime__default["default"].wrap(function _callee7$(_context18) {
817
713
  while (1) {
818
714
  switch (_context18.prev = _context18.next) {
@@ -825,10 +721,8 @@ var ContentBuilder = /*#__PURE__*/function () {
825
721
  headless: !debug,
826
722
  slowMo: debug ? 100 : undefined
827
723
  });
828
-
829
724
  case 5:
830
725
  browser = _context18.sent;
831
-
832
726
  if (debug) {
833
727
  cleanup.push( /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5() {
834
728
  return _regeneratorRuntime__default["default"].wrap(function _callee5$(_context9) {
@@ -836,7 +730,6 @@ var ContentBuilder = /*#__PURE__*/function () {
836
730
  switch (_context9.prev = _context9.next) {
837
731
  case 0:
838
732
  return _context9.abrupt("return", browser.disconnect());
839
-
840
733
  case 1:
841
734
  case "end":
842
735
  return _context9.stop();
@@ -848,18 +741,16 @@ var ContentBuilder = /*#__PURE__*/function () {
848
741
  cleanup.push(function () {
849
742
  return browser.close();
850
743
  });
851
- } // Generate screenshots.
744
+ }
745
+ // Generate screenshots.
852
746
  // There is quite long delay to ensure the chart is rendered properly
853
747
  // so it's much faster to run a lot of them at the same time.
854
-
855
-
856
748
  todo = _sliceInstanceProperty__default["default"](allExamples).call(allExamples);
857
749
  total = todo.length;
858
750
  reports = [];
859
751
  _context18.next = 12;
860
752
  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
753
  var example, _context12, _context13, _context14, _context15, getStartStopMs, valid, report, percentage, validText, msText;
862
-
863
754
  return _regeneratorRuntime__default["default"].wrap(function _callee6$(_context16) {
864
755
  while (1) {
865
756
  switch (_context16.prev = _context16.next) {
@@ -868,7 +759,6 @@ var ContentBuilder = /*#__PURE__*/function () {
868
759
  _context16.next = 14;
869
760
  break;
870
761
  }
871
-
872
762
  getStartStopMs = measureStartStopMs();
873
763
  _context16.next = 4;
874
764
  return generateScreenshot(browser, {
@@ -878,7 +768,6 @@ var ContentBuilder = /*#__PURE__*/function () {
878
768
  screenshotScript: _this._config.screenshotScript,
879
769
  width: _this._config.renderer.screenshot.width
880
770
  });
881
-
882
771
  case 4:
883
772
  valid = _context16.sent;
884
773
  report = _objectSpread$1(_objectSpread$1({}, getStartStopMs()), {}, {
@@ -887,20 +776,17 @@ var ContentBuilder = /*#__PURE__*/function () {
887
776
  result: valid ? "fulfilled" : "rejected"
888
777
  });
889
778
  reports.push(report);
890
-
891
779
  if (valid) {
892
780
  okay.push(example.path);
893
781
  } else {
894
782
  fail.push(example.path);
895
783
  }
896
-
897
784
  percentage = _padStartInstanceProperty__default["default"](_context12 = Math.floor(reports.length / total * 100) + "%").call(_context12, 4, " ");
898
785
  validText = valid ? "okay" : "fail";
899
786
  msText = formatStartStopMs(report);
900
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));
901
788
  _context16.next = 0;
902
789
  break;
903
-
904
790
  case 14:
905
791
  case "end":
906
792
  return _context16.stop();
@@ -908,70 +794,54 @@ var ContentBuilder = /*#__PURE__*/function () {
908
794
  }
909
795
  }, _callee6);
910
796
  }))));
911
-
912
797
  case 12:
913
798
  return _context18.abrupt("return", reports);
914
-
915
799
  case 13:
916
800
  _context18.prev = 13;
917
801
  _iterator = _createForOfIteratorHelper$2(_reverseInstanceProperty__default["default"](_context17 = _spliceInstanceProperty__default["default"](cleanup).call(cleanup, 0)).call(_context17));
918
802
  _context18.prev = 15;
919
-
920
803
  _iterator.s();
921
-
922
804
  case 17:
923
805
  if ((_step = _iterator.n()).done) {
924
806
  _context18.next = 29;
925
807
  break;
926
808
  }
927
-
928
809
  callback = _step.value;
929
810
  _context18.prev = 19;
930
811
  _context18.next = 22;
931
812
  return callback();
932
-
933
813
  case 22:
934
814
  _context18.next = 27;
935
815
  break;
936
-
937
816
  case 24:
938
817
  _context18.prev = 24;
939
818
  _context18.t0 = _context18["catch"](19);
940
819
  console.error(_context18.t0);
941
-
942
820
  case 27:
943
821
  _context18.next = 17;
944
822
  break;
945
-
946
823
  case 29:
947
824
  _context18.next = 34;
948
825
  break;
949
-
950
826
  case 31:
951
827
  _context18.prev = 31;
952
828
  _context18.t1 = _context18["catch"](15);
953
-
954
829
  _iterator.e(_context18.t1);
955
-
956
830
  case 34:
957
831
  _context18.prev = 34;
958
-
959
832
  _iterator.f();
960
-
961
833
  return _context18.finish(34);
962
-
963
834
  case 37:
964
835
  return _context18.finish(13);
965
-
966
836
  case 38:
967
837
  case "end":
968
838
  return _context18.stop();
969
839
  }
970
840
  }
971
841
  }, _callee7, null, [[1,, 13, 38], [15, 31, 34, 37], [19, 24]]);
972
- }))() : // Skip screenshots.
842
+ }))() :
843
+ // Skip screenshots.
973
844
  _Promise__default["default"].resolve([]);
974
-
975
845
  var checks = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee8() {
976
846
  var total;
977
847
  return _regeneratorRuntime__default["default"].wrap(function _callee8$(_context19) {
@@ -980,15 +850,12 @@ var ContentBuilder = /*#__PURE__*/function () {
980
850
  case 0:
981
851
  _context19.next = 2;
982
852
  return index;
983
-
984
853
  case 2:
985
854
  _context19.next = 4;
986
855
  return playgrounds;
987
-
988
856
  case 4:
989
857
  _context19.next = 6;
990
858
  return screenshots;
991
-
992
859
  case 6:
993
860
  total = okay.length + fail.length;
994
861
  return _context19.abrupt("return", {
@@ -999,7 +866,6 @@ var ContentBuilder = /*#__PURE__*/function () {
999
866
  percentage: total === 0 ? 100 : 100 * okay.length / total,
1000
867
  total: total
1001
868
  });
1002
-
1003
869
  case 8:
1004
870
  case "end":
1005
871
  return _context19.stop();
@@ -1007,7 +873,6 @@ var ContentBuilder = /*#__PURE__*/function () {
1007
873
  }
1008
874
  }, _callee8);
1009
875
  }))();
1010
-
1011
876
  return {
1012
877
  checks: checks,
1013
878
  index: index,
@@ -1019,12 +884,10 @@ var ContentBuilder = /*#__PURE__*/function () {
1019
884
  key: "_processGroup",
1020
885
  value: function _processGroup(examples) {
1021
886
  var _context20,
1022
- _context21,
1023
- _this2 = this;
1024
-
887
+ _context21,
888
+ _this2 = this;
1025
889
  return _flatMapInstanceProperty__default["default"](_context20 = _sortInstanceProperty__default["default"](_context21 = _Object$keys__default["default"](examples)).call(_context21, collator.compare)).call(_context20, function (key) {
1026
890
  var example = examples[key];
1027
-
1028
891
  if (isExample(example)) {
1029
892
  return [example];
1030
893
  } else {
@@ -1033,7 +896,6 @@ var ContentBuilder = /*#__PURE__*/function () {
1033
896
  });
1034
897
  }
1035
898
  }]);
1036
-
1037
899
  return ContentBuilder;
1038
900
  }();
1039
901
 
@@ -1042,22 +904,17 @@ var indexTemplate = "<html>\n <head>\n <meta charset=\"utf-8\" />\n <titl
1042
904
  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
905
 
1044
906
  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
907
  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
908
  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
909
  /**
1050
910
  * @param example
1051
911
  */
1052
-
1053
912
  function generateJSFiddle(example) {
1054
913
  return $__default["default"]("<a>").addClass("icon jsfiddle").attr("href", example.paths.jsfiddle.web).attr("title", "JSFiddle");
1055
914
  }
1056
915
  /**
1057
916
  * @param example
1058
917
  */
1059
-
1060
-
1061
918
  function generateCodePen(example) {
1062
919
  return $__default["default"]("<a>").addClass("icon codepen").attr("href", example.paths.codepen.web).attr("title", "CodePen");
1063
920
  }
@@ -1067,28 +924,24 @@ function generateCodePen(example) {
1067
924
  * @param level
1068
925
  * @param collator
1069
926
  */
1070
-
1071
-
1072
927
  function processGroup$1(examples, title, level, collator) {
1073
928
  var _context;
1074
-
1075
929
  var heading = $__default["default"]("<h".concat(Math.max(1, Math.min(6, level)), ">"));
1076
930
  heading.text(title);
1077
931
  var list = $__default["default"]("<div>");
1078
932
  var section = $__default["default"]("<div>");
1079
933
  section.append(heading, list);
1080
-
1081
934
  var _iterator = _createForOfIteratorHelper$1(_sortInstanceProperty__default["default"](_context = _Object$keys__default["default"](examples)).call(_context, collator.compare)),
1082
- _step;
1083
-
935
+ _step;
1084
936
  try {
1085
937
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
1086
938
  var key = _step.value;
1087
939
  var example = examples[key];
1088
-
1089
940
  if (isExample(example)) {
1090
- var header = $__default["default"]("<div>").addClass("example-header").append( // Playgrounds
1091
- generateJSFiddle(example), generateCodePen(example), // Title
941
+ var header = $__default["default"]("<div>").addClass("example-header").append(
942
+ // Playgrounds
943
+ generateJSFiddle(example), generateCodePen(example),
944
+ // Title
1092
945
  $__default["default"]("<a>").attr("href", example.paths.page.web).text(key));
1093
946
  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
947
  var item = $__default["default"]("<span>").addClass("example-link").append(header, image);
@@ -1102,21 +955,16 @@ function processGroup$1(examples, title, level, collator) {
1102
955
  } finally {
1103
956
  _iterator.f();
1104
957
  }
1105
-
1106
958
  return section;
1107
959
  }
1108
-
1109
960
  var htmlRenderer = {
1110
961
  render: function render(examples, _output, title, collator) {
1111
962
  var _context2;
1112
-
1113
963
  var filename = "index.html";
1114
964
  var root = $__default["default"]("<div>");
1115
965
  root.addClass("examples-root");
1116
-
1117
966
  var _iterator2 = _createForOfIteratorHelper$1(_sortInstanceProperty__default["default"](_context2 = _Object$keys__default["default"](examples)).call(_context2, collator.compare)),
1118
- _step2;
1119
-
967
+ _step2;
1120
968
  try {
1121
969
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1122
970
  var key = _step2.value;
@@ -1127,7 +975,6 @@ var htmlRenderer = {
1127
975
  } finally {
1128
976
  _iterator2.f();
1129
977
  }
1130
-
1131
978
  var page = $__default["default"].load(indexTemplate);
1132
979
  page("title").text(title);
1133
980
  page("body").append(root);
@@ -1149,18 +996,13 @@ var htmlRenderer = {
1149
996
  };
1150
997
 
1151
998
  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
999
  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
1000
  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
1001
  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
1002
  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
1003
  /**
1161
1004
  * @param lines
1162
1005
  */
1163
-
1164
1006
  function linesToContent(lines) {
1165
1007
  return formatMD(lines.join("\n"));
1166
1008
  }
@@ -1169,22 +1011,16 @@ function linesToContent(lines) {
1169
1011
  * @param src
1170
1012
  * @param href
1171
1013
  */
1172
-
1173
-
1174
1014
  function image(title, src, href) {
1175
1015
  var _context, _context2;
1176
-
1177
1016
  return href == null ? _concatInstanceProperty__default["default"](_context = "![".concat(title, "](")).call(_context, src, ")") : link(href, _concatInstanceProperty__default["default"](_context2 = "![".concat(title, "](")).call(_context2, src, ")"));
1178
1017
  }
1179
1018
  /**
1180
1019
  * @param href
1181
1020
  * @param text
1182
1021
  */
1183
-
1184
-
1185
1022
  function link(href) {
1186
1023
  var _context3;
1187
-
1188
1024
  var text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : href;
1189
1025
  return _concatInstanceProperty__default["default"](_context3 = "[".concat(text, "](")).call(_context3, href, ")");
1190
1026
  }
@@ -1192,11 +1028,8 @@ function link(href) {
1192
1028
  * @param level
1193
1029
  * @param text
1194
1030
  */
1195
-
1196
-
1197
1031
  function header(level, text) {
1198
1032
  var _context4, _context5;
1199
-
1200
1033
  return _concatInstanceProperty__default["default"](_context4 = "".concat(_repeatInstanceProperty__default["default"](_context5 = "#").call(_context5, level), " ")).call(_context4, text);
1201
1034
  }
1202
1035
  /**
@@ -1205,29 +1038,22 @@ function header(level, text) {
1205
1038
  * @param title
1206
1039
  * @param collator
1207
1040
  */
1208
-
1209
-
1210
1041
  function processGroup(examples, output, title, collator) {
1211
1042
  var _context6, _context7, _context8;
1212
-
1213
1043
  var items = [];
1214
1044
  var sections = [];
1215
1045
  var filenamePart = title.replace(/[^a-zA-Z0-9]/g, "-").toLowerCase();
1216
-
1217
1046
  var _iterator = _createForOfIteratorHelper(_sortInstanceProperty__default["default"](_context8 = _Object$keys__default["default"](examples)).call(_context8, collator.compare)),
1218
- _step;
1219
-
1047
+ _step;
1220
1048
  try {
1221
1049
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
1222
1050
  var key = _step.value;
1223
1051
  var example = examples[key];
1224
-
1225
1052
  if (isExample(example)) {
1226
1053
  // An example in this group.
1227
1054
  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(" | "), "");
1228
1055
  } else {
1229
1056
  var _context9;
1230
-
1231
1057
  // A subgroup of examples.
1232
1058
  sections.push.apply(sections, _toConsumableArray__default["default"](_mapInstanceProperty__default["default"](_context9 = processGroup(example, output, key, collator)).call(_context9, function (contentPart) {
1233
1059
  return _objectSpread(_objectSpread({}, contentPart), {}, {
@@ -1241,23 +1067,18 @@ function processGroup(examples, output, title, collator) {
1241
1067
  } finally {
1242
1068
  _iterator.f();
1243
1069
  }
1244
-
1245
1070
  return _concatInstanceProperty__default["default"](_context6 = [{
1246
1071
  content: linesToContent(_concatInstanceProperty__default["default"](_context7 = [header(1, title), ""]).call(_context7, items)),
1247
1072
  filename: filenamePart + ".md",
1248
1073
  title: title
1249
1074
  }]).call(_context6, sections);
1250
1075
  }
1251
-
1252
1076
  var mdRenderer = {
1253
1077
  render: function render(examples, output, _title, collator) {
1254
1078
  var _context10, _context11, _context12;
1255
-
1256
1079
  var sections = [];
1257
-
1258
1080
  var _iterator2 = _createForOfIteratorHelper(_sortInstanceProperty__default["default"](_context12 = _Object$keys__default["default"](examples)).call(_context12, collator.compare)),
1259
- _step2;
1260
-
1081
+ _step2;
1261
1082
  try {
1262
1083
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1263
1084
  var key = _step2.value;
@@ -1268,11 +1089,10 @@ var mdRenderer = {
1268
1089
  } finally {
1269
1090
  _iterator2.f();
1270
1091
  }
1271
-
1272
1092
  return _concatInstanceProperty__default["default"](_context10 = [{
1273
1093
  content: linesToContent(_concatInstanceProperty__default["default"](_context11 = [header(1, "Examples"), ""]).call(_context11, _toConsumableArray__default["default"](_mapInstanceProperty__default["default"](sections).call(sections, function (_ref) {
1274
1094
  var filename = _ref.filename,
1275
- title = _ref.title;
1095
+ title = _ref.title;
1276
1096
  return "- " + link("./" + filename, title);
1277
1097
  })))),
1278
1098
  filename: "README.md",
@@ -1360,7 +1180,6 @@ var y = yargs__default["default"].strict(true).usage("generate-example-index [op
1360
1180
  /**
1361
1181
  *
1362
1182
  */
1363
-
1364
1183
  function parseArguments() {
1365
1184
  return y.parserConfiguration({
1366
1185
  "camel-case-expansion": false
@@ -1370,14 +1189,13 @@ function parseArguments() {
1370
1189
  /**
1371
1190
  * @param urls
1372
1191
  */
1373
-
1374
1192
  function joinURLs() {
1375
1193
  for (var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++) {
1376
1194
  urls[_key] = arguments[_key];
1377
1195
  }
1378
-
1379
1196
  return _mapInstanceProperty__default["default"](urls).call(urls, function (url) {
1380
- return (// Strip the parts of leading and trailing slashes if they have them.
1197
+ return (
1198
+ // Strip the parts of leading and trailing slashes if they have them.
1381
1199
  url.replace(/^\/?(.*?)\/?$/, "$1")
1382
1200
  );
1383
1201
  }).join("/");
@@ -1386,21 +1204,21 @@ function joinURLs() {
1386
1204
  * @param baseURL
1387
1205
  * @param url
1388
1206
  */
1389
-
1390
1207
  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.
1208
+ return _startsWithInstanceProperty__default["default"](url).call(url, "/") ?
1209
+ // Relative to the base URL. Base URL starts and URL ends with a slash.
1210
+ baseURL + _sliceInstanceProperty__default["default"](url).call(url, 1) :
1211
+ // Relative to some other point or absolute already.
1393
1212
  url;
1394
1213
  }
1395
1214
  /**
1396
1215
  * @param config
1397
1216
  * @param exampleAbsolutePath
1398
1217
  */
1399
-
1400
1218
  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
1219
+ var exampleRelativePath = path.relative(config.page.local, exampleAbsolutePath);
1220
+ // It's important that the hash is created from the relative path so that it
1402
1221
  // is the same on all computers.
1403
-
1404
1222
  var hash = crypto.createHash("sha256").update(exampleRelativePath).digest("hex");
1405
1223
  return {
1406
1224
  codepen: generateLocalWebPair(config.codepen.local, config.codepen.web, hash, "codepen", "html"),
@@ -1419,26 +1237,23 @@ function generatePaths(config, exampleAbsolutePath) {
1419
1237
  * @param prefix
1420
1238
  * @param extension
1421
1239
  */
1422
-
1423
1240
  function generateLocalWebPair(localRoot, webRoot, hash, prefix, extension) {
1424
1241
  var _context, _context2;
1425
-
1426
1242
  var filename = _concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = "".concat(prefix, ".")).call(_context2, hash, ".")).call(_context, extension);
1427
-
1428
1243
  return {
1429
1244
  local: path.resolve(localRoot, filename),
1430
1245
  web: joinURLs(webRoot, filename)
1431
1246
  };
1432
1247
  }
1433
1248
 
1434
- var argv = parseArguments(); // Log the parsed configuration for debugging purposes.
1435
-
1249
+ var argv = parseArguments();
1250
+ // Log the parsed configuration for debugging purposes.
1436
1251
  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
1252
+ process.stdout.write("\n");
1253
+ // Pageres uses quite a lot of listeners when invoked multiple times in
1438
1254
  // parallel. This ensures there are no warnings about it.
1439
-
1440
- process.setMaxListeners(40); // Resolve paths relative to PWD.
1441
-
1255
+ process.setMaxListeners(40);
1256
+ // Resolve paths relative to PWD.
1442
1257
  var screenshotScriptPath = typeof argv["screenshot-script"] === "string" ? path.resolve(argv["screenshot-script"]) : undefined;
1443
1258
  var mkdir = util__default["default"].promisify(fs__default["default"].mkdir);
1444
1259
  var readFile = util__default["default"].promisify(fs__default["default"].readFile);
@@ -1451,10 +1266,8 @@ var readFile = util__default["default"].promisify(fs__default["default"].readFil
1451
1266
  * @returns The value “smartly” coerced or the fallback if conversion isn't
1452
1267
  * possible or the value is not present in the page.
1453
1268
  */
1454
-
1455
1269
  function getMeta(page, name, fallback) {
1456
1270
  var content = page("meta[name=\"".concat(name, "\"]")).attr("content");
1457
-
1458
1271
  if (content == null) {
1459
1272
  // No meta of this name exists in the page, use the fallback.
1460
1273
  return fallback;
@@ -1476,61 +1289,45 @@ function getMeta(page, name, fallback) {
1476
1289
  * @param page - The HTML to be linted.
1477
1290
  * @returns True if everything's okay, false otherwise.
1478
1291
  */
1479
-
1480
-
1481
1292
  function lintExample(path, page) {
1482
1293
  var _context, _context2, _context3;
1483
-
1484
1294
  var valid = true;
1485
1295
  var msgs = ["".concat(path, ":")];
1486
-
1487
1296
  if (page("#title").length !== 1) {
1488
1297
  msgs.push("Missing #title element in the body.");
1489
1298
  valid = false;
1490
1299
  }
1491
-
1492
1300
  if (page("#title > *").length < 2) {
1493
1301
  msgs.push("There have to be at least two headings (group and example name).");
1494
1302
  valid = false;
1495
1303
  }
1496
-
1497
1304
  var headTitle = _trimInstanceProperty__default["default"](_context = page("head > title").text()).call(_context);
1498
-
1499
1305
  var bodyTitle = _trimInstanceProperty__default["default"](_context2 = _mapInstanceProperty__default["default"](_context3 = page("#title > *")).call(_context3, function (_i, elem) {
1500
1306
  return $__default["default"](elem).text();
1501
1307
  }).get().join(" | ")).call(_context2);
1502
-
1503
1308
  if (headTitle !== bodyTitle) {
1504
1309
  msgs.push("The title in the head doesn't match the title in the body.", " head: ".concat(headTitle), " body: ".concat(bodyTitle));
1505
1310
  valid = false;
1506
1311
  }
1507
-
1508
1312
  if (msgs.length > 1) {
1509
1313
  console.warn("\n" + msgs.join("\n "));
1510
1314
  }
1511
-
1512
1315
  return valid;
1513
1316
  }
1514
-
1515
1317
  _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3() {
1516
1318
  var _context4, _context6;
1517
-
1518
1319
  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
1320
  return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context24) {
1521
1321
  while (1) {
1522
1322
  switch (_context24.prev = _context24.next) {
1523
1323
  case 0:
1524
1324
  code = 0;
1525
-
1526
1325
  if (!(!argv.index && !argv.screenshots && !argv.lint)) {
1527
1326
  _context24.next = 4;
1528
1327
  break;
1529
1328
  }
1530
-
1531
1329
  yargs__default["default"].parse("--help");
1532
1330
  return _context24.abrupt("return");
1533
-
1534
1331
  case 4:
1535
1332
  _context24.next = 6;
1536
1333
  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 () {
@@ -1543,7 +1340,6 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
1543
1340
  return mkdir(path, {
1544
1341
  recursive: true
1545
1342
  });
1546
-
1547
1343
  case 2:
1548
1344
  case "end":
1549
1345
  return _context5.stop();
@@ -1551,22 +1347,17 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
1551
1347
  }
1552
1348
  }, _callee);
1553
1349
  }));
1554
-
1555
1350
  return function (_x) {
1556
1351
  return _ref2.apply(this, arguments);
1557
1352
  };
1558
1353
  }()));
1559
-
1560
1354
  case 6:
1561
1355
  baseURL = argv["base-url"];
1562
-
1563
1356
  if (_endsWithInstanceProperty__default["default"](baseURL).call(baseURL, "/")) {
1564
1357
  _context24.next = 9;
1565
1358
  break;
1566
1359
  }
1567
-
1568
1360
  throw new Error("Base URL (`base-url`) has to end with a slash (`/`).");
1569
-
1570
1361
  case 9:
1571
1362
  // Paths.
1572
1363
  pathsConfig = {
@@ -1597,70 +1388,56 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
1597
1388
  _context24.t1 = _mapInstanceProperty__default["default"];
1598
1389
  _context24.next = 18;
1599
1390
  return globby__default["default"](path.join(pathsConfig.page.local, "**/*.html"));
1600
-
1601
1391
  case 18:
1602
1392
  _context24.t2 = _context6 = _context24.sent;
1603
1393
  _context24.t3 = (0, _context24.t1)(_context24.t2).call(_context6, /*#__PURE__*/function () {
1604
1394
  var _ref3 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(pagePath) {
1605
1395
  var _context7;
1606
-
1607
1396
  var html, $page, pageDelay, pageTimeout, pageSelector, titles, _context9;
1608
-
1609
1397
  return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context10) {
1610
1398
  while (1) {
1611
1399
  switch (_context10.prev = _context10.next) {
1612
1400
  case 0:
1613
1401
  _context10.next = 2;
1614
1402
  return readFile(pagePath, "utf-8");
1615
-
1616
1403
  case 2:
1617
1404
  html = _context10.sent;
1618
1405
  $page = $__default["default"].load(html);
1619
1406
  pageDelay = getMeta($page, "example-screenshot-delay", 6);
1620
1407
  pageTimeout = getMeta($page, "example-screenshot-timeout", 60);
1621
1408
  pageSelector = getMeta($page, "example-screenshot-selector", selector); // Is this an examples?
1622
-
1623
1409
  if (!($page(pageSelector).length === 0)) {
1624
1410
  _context10.next = 10;
1625
1411
  break;
1626
1412
  }
1627
-
1628
1413
  skipped.push(pagePath);
1629
1414
  return _context10.abrupt("return");
1630
-
1631
1415
  case 10:
1632
1416
  // Lint if requested.
1633
1417
  if (argv.lint) {
1634
1418
  lintExample(pagePath, $page);
1635
- } // Body titles.
1636
-
1637
-
1419
+ }
1420
+ // Body titles.
1638
1421
  titles = _mapInstanceProperty__default["default"](_context7 = $page("#title > *").get()).call(_context7, function (elem) {
1639
1422
  var _context8;
1640
-
1641
1423
  return _trimInstanceProperty__default["default"](_context8 = $page(elem).text()).call(_context8);
1642
1424
  }); // Head title fallback.
1643
-
1644
1425
  if (titles.length < 2) {
1645
1426
  titles = _mapInstanceProperty__default["default"](_context9 = $page("head > title").text().split("|")).call(_context9, function (title) {
1646
1427
  return _trimInstanceProperty__default["default"](title).call(title);
1647
1428
  });
1648
- } // File path fallback.
1649
-
1650
-
1429
+ }
1430
+ // File path fallback.
1651
1431
  if (titles.length < 2) {
1652
1432
  titles = pagePath.split("/");
1653
- } // Just ignore it.
1654
-
1655
-
1433
+ }
1434
+ // Just ignore it.
1656
1435
  if (!(titles.length < 2)) {
1657
1436
  _context10.next = 17;
1658
1437
  break;
1659
1438
  }
1660
-
1661
1439
  console.error("Title resolution failed. Skipping.");
1662
1440
  return _context10.abrupt("return");
1663
-
1664
1441
  case 17:
1665
1442
  // Put this example into the structure while creating any missing groups in the process.
1666
1443
  _reduceInstanceProperty__default["default"](titles).call(titles, function (acc, title, i, arr) {
@@ -1668,7 +1445,6 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
1668
1445
  console.error("The following group already exists: ", titles);
1669
1446
  title += "!";
1670
1447
  }
1671
-
1672
1448
  if (i === arr.length - 1) {
1673
1449
  if (acc[title] != null) {
1674
1450
  console.error("The following example has the same name as an already existing group: ", titles);
@@ -1692,7 +1468,6 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
1692
1468
  return acc[title] = acc[title] || {};
1693
1469
  }
1694
1470
  }, examples);
1695
-
1696
1471
  case 18:
1697
1472
  case "end":
1698
1473
  return _context10.stop();
@@ -1700,63 +1475,49 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
1700
1475
  }
1701
1476
  }, _callee2);
1702
1477
  }));
1703
-
1704
1478
  return function (_x2) {
1705
1479
  return _ref3.apply(this, arguments);
1706
1480
  };
1707
1481
  }());
1708
1482
  _context24.next = 22;
1709
1483
  return _context24.t0.all.call(_context24.t0, _context24.t3);
1710
-
1711
1484
  case 22:
1712
1485
  if (skipped.length) {
1713
1486
  process.stdout.write("\n");
1714
1487
  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
1488
  }
1716
-
1717
1489
  if (!(stats.examples === 0)) {
1718
1490
  _context24.next = 27;
1719
1491
  break;
1720
1492
  }
1721
-
1722
1493
  console.info("No usable example files were found.");
1723
1494
  _context24.next = 67;
1724
1495
  break;
1725
-
1726
1496
  case 27:
1727
1497
  if (!(argv.index || argv.playgrounds || argv.screenshots)) {
1728
1498
  _context24.next = 67;
1729
1499
  break;
1730
1500
  }
1731
-
1732
1501
  process.stdout.write("\n");
1733
-
1734
1502
  if (!(screenshotScriptPath != null)) {
1735
1503
  _context24.next = 38;
1736
1504
  break;
1737
1505
  }
1738
-
1739
1506
  _context24.next = 32;
1740
1507
  return readFile(screenshotScriptPath, "utf-8");
1741
-
1742
1508
  case 32:
1743
1509
  _context24.t5 = _context24.sent;
1744
-
1745
1510
  if (_context24.t5) {
1746
1511
  _context24.next = 35;
1747
1512
  break;
1748
1513
  }
1749
-
1750
1514
  _context24.t5 = "";
1751
-
1752
1515
  case 35:
1753
1516
  _context24.t4 = _context24.t5;
1754
1517
  _context24.next = 39;
1755
1518
  break;
1756
-
1757
1519
  case 38:
1758
1520
  _context24.t4 = "";
1759
-
1760
1521
  case 39:
1761
1522
  screenshotScript = _context24.t4;
1762
1523
  builtData = new ContentBuilder({
@@ -1771,59 +1532,47 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
1771
1532
  playgrounds: argv.playgrounds,
1772
1533
  screenshots: argv.screenshots
1773
1534
  }); // Create and write the page.
1774
-
1775
1535
  if (!argv.index) {
1776
1536
  _context24.next = 48;
1777
1537
  break;
1778
1538
  }
1779
-
1780
1539
  _context24.t6 = reduceReports;
1781
1540
  _context24.next = 45;
1782
1541
  return builtData.index;
1783
-
1784
1542
  case 45:
1785
1543
  _context24.t7 = _context24.sent;
1786
1544
  cummulativeReport = (0, _context24.t6)(_context24.t7);
1787
1545
  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
1546
  case 48:
1790
1547
  if (!argv.index) {
1791
1548
  _context24.next = 55;
1792
1549
  break;
1793
1550
  }
1794
-
1795
1551
  _context24.t8 = reduceReports;
1796
1552
  _context24.next = 52;
1797
1553
  return builtData.playgrounds;
1798
-
1799
1554
  case 52:
1800
1555
  _context24.t9 = _context24.sent;
1801
1556
  _cummulativeReport = (0, _context24.t8)(_context24.t9);
1802
1557
  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
1558
  case 55:
1805
1559
  if (!argv.screenshots) {
1806
1560
  _context24.next = 62;
1807
1561
  break;
1808
1562
  }
1809
-
1810
1563
  _context24.t10 = reduceReports;
1811
1564
  _context24.next = 59;
1812
1565
  return builtData.screenshots;
1813
-
1814
1566
  case 59:
1815
1567
  _context24.t11 = _context24.sent;
1816
1568
  _cummulativeReport2 = (0, _context24.t10)(_context24.t11);
1817
1569
  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
1570
  case 62:
1820
1571
  _context24.next = 64;
1821
1572
  return builtData.checks;
1822
-
1823
1573
  case 64:
1824
1574
  checks = _context24.sent;
1825
1575
  process.stdout.write("\n");
1826
-
1827
1576
  if (checks.fail === 0) {
1828
1577
  console.info(_concatInstanceProperty__default["default"](_context18 = "Verification: ".concat(checks.okay, " passed (")).call(_context18, Math.round(checks.percentage), " %) passed."));
1829
1578
  } else {
@@ -1833,15 +1582,12 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
1833
1582
  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
1583
  code = 3;
1835
1584
  }
1836
-
1837
1585
  _forEachInstanceProperty__default["default"](_context23 = checks.failPaths).call(_context23, function (path) {
1838
1586
  console.error(path);
1839
1587
  });
1840
1588
  }
1841
-
1842
1589
  case 67:
1843
1590
  process.exitCode = code;
1844
-
1845
1591
  case 68:
1846
1592
  case "end":
1847
1593
  return _context24.stop();