vis-dev-utils 3.0.119 → 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.
- package/babel-register/index.js +26 -7
- package/babel-register/index.js.map +1 -1
- package/bin/ci-utils.js +4 -4
- package/bin/ci-utils.js.map +1 -1
- package/bin/generate-examples-index.js +695 -701
- package/bin/generate-examples-index.js.map +1 -1
- package/bin/test-e2e-interop.js +2818 -599
- package/bin/test-e2e-interop.js.map +1 -1
- package/declarations/generate-rollup-configuration/index.d.ts +2 -1
- package/declarations/generate-rollup-configuration/index.d.ts.map +1 -1
- package/dist/vis-dev-utils.cjs.js +317 -229
- package/dist/vis-dev-utils.cjs.js.map +1 -1
- package/dist/vis-dev-utils.esm.js +285 -218
- package/dist/vis-dev-utils.esm.js.map +1 -1
- package/package.json +12 -13
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Development utilities for the Vis family projects.
|
|
8
8
|
*
|
|
9
|
-
* @version 3.0.
|
|
10
|
-
* @date 2023-02-
|
|
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
|
|
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
|
|
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
|
|
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);
|
|
@@ -278,7 +294,7 @@ function generatePlaygroundData(baseURL, example$, examplePath) {
|
|
|
278
294
|
// Domain absolute.
|
|
279
295
|
baseURL + _sliceInstanceProperty__default["default"](rawPath).call(rawPath, 1) :
|
|
280
296
|
//Relative.
|
|
281
|
-
baseURL +
|
|
297
|
+
baseURL + node_path.relative(process.cwd(), node_path.resolve(node_path.dirname(examplePath), rawPath));
|
|
282
298
|
};
|
|
283
299
|
var resources = {
|
|
284
300
|
js: _mapInstanceProperty__default["default"](_context9 = _filterInstanceProperty__default["default"](_context10 = _mapInstanceProperty__default["default"](_context11 = example$("script")).call(_context11, function (_i, elem) {
|
|
@@ -330,7 +346,7 @@ var commonScreenshotScript = "/* global window: false */\n\n/**\n * Simulates co
|
|
|
330
346
|
|
|
331
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; } } }; }
|
|
332
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); }
|
|
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++)
|
|
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; }
|
|
334
350
|
var unlink = util.promisify(fs__default["default"].unlink);
|
|
335
351
|
var writeFile$1 = util.promisify(fs__default["default"].writeFile);
|
|
336
352
|
/**
|
|
@@ -356,45 +372,43 @@ function _isScreenshotValid() {
|
|
|
356
372
|
_isScreenshotValid = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(screenshot) {
|
|
357
373
|
var image, firstPixel, x, y;
|
|
358
374
|
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
359
|
-
while (1) {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
_context.next = 16;
|
|
371
|
-
break;
|
|
372
|
-
}
|
|
373
|
-
y = 0;
|
|
374
|
-
case 7:
|
|
375
|
-
if (!(y < image.getHeight())) {
|
|
376
|
-
_context.next = 13;
|
|
377
|
-
break;
|
|
378
|
-
}
|
|
379
|
-
if (!(firstPixel !== image.getPixelColor(x, y))) {
|
|
380
|
-
_context.next = 10;
|
|
381
|
-
break;
|
|
382
|
-
}
|
|
383
|
-
return _context.abrupt("return", true);
|
|
384
|
-
case 10:
|
|
385
|
-
++y;
|
|
386
|
-
_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;
|
|
387
386
|
break;
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
387
|
+
}
|
|
388
|
+
y = 0;
|
|
389
|
+
case 7:
|
|
390
|
+
if (!(y < image.getHeight())) {
|
|
391
|
+
_context.next = 13;
|
|
391
392
|
break;
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
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();
|
|
398
412
|
}
|
|
399
413
|
}, _callee);
|
|
400
414
|
}));
|
|
@@ -407,154 +421,152 @@ function _generateScreenshot() {
|
|
|
407
421
|
_generateScreenshot = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(browser, config) {
|
|
408
422
|
var debug, example, height, screenshotScript, width, cleanup, tmpPath, screenshotPage, context, page, $element, _context2, screenshot, _context3, _iterator, _step, callback;
|
|
409
423
|
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context4) {
|
|
410
|
-
while (1) {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
return unlink(tmpPath);
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
_context4.next = 11;
|
|
430
|
-
return browser.createIncognitoBrowserContext();
|
|
431
|
-
case 11:
|
|
432
|
-
context = _context4.sent;
|
|
433
|
-
if (!debug) {
|
|
434
|
-
cleanup.push(function () {
|
|
435
|
-
return context.close();
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
_context4.next = 15;
|
|
439
|
-
return context.newPage();
|
|
440
|
-
case 15:
|
|
441
|
-
page = _context4.sent;
|
|
442
|
-
if (!debug) {
|
|
443
|
-
cleanup.push(function () {
|
|
444
|
-
return page.close();
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
_context4.next = 19;
|
|
448
|
-
return page.setViewport({
|
|
449
|
-
width: width + 50,
|
|
450
|
-
height: height + 50
|
|
451
|
-
});
|
|
452
|
-
case 19:
|
|
453
|
-
_context4.next = 21;
|
|
454
|
-
return page.goto("file://" + tmpPath.split(path.sep).join(path.posix.sep));
|
|
455
|
-
case 21:
|
|
456
|
-
_context4.next = 23;
|
|
457
|
-
return page.waitForSelector(example.selector, {
|
|
458
|
-
visible: true,
|
|
459
|
-
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);
|
|
460
440
|
});
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
_context4.next = 30;
|
|
470
|
-
break;
|
|
471
|
-
case 28:
|
|
472
|
-
_context4.next = 30;
|
|
473
|
-
return page.waitForTimeout(example.delay * 1000);
|
|
474
|
-
case 30:
|
|
475
|
-
_context4.next = 32;
|
|
476
|
-
return page.$(example.selector);
|
|
477
|
-
case 32:
|
|
478
|
-
$element = _context4.sent;
|
|
479
|
-
if (!($element == null)) {
|
|
480
|
-
_context4.next = 35;
|
|
481
|
-
break;
|
|
482
|
-
}
|
|
483
|
-
throw new Error(_concatInstanceProperty__default["default"](_context2 = "Element \"".concat(example.selector, "\" not found in ")).call(_context2, example.path, "."));
|
|
484
|
-
case 35:
|
|
485
|
-
_context4.next = 37;
|
|
486
|
-
return $element.evaluate(function (element) {
|
|
487
|
-
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();
|
|
488
449
|
});
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
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();
|
|
493
458
|
});
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
case 51:
|
|
513
|
-
_context4.prev = 51;
|
|
514
|
-
_context4.t0 = _context4["catch"](2);
|
|
515
|
-
console.error(_context4.t0);
|
|
516
|
-
return _context4.abrupt("return", false);
|
|
517
|
-
case 55:
|
|
518
|
-
_context4.prev = 55;
|
|
519
|
-
_iterator = _createForOfIteratorHelper$3(_reverseInstanceProperty__default["default"](_context3 = _spliceInstanceProperty__default["default"](cleanup).call(cleanup, 0)).call(_context3));
|
|
520
|
-
_context4.prev = 57;
|
|
521
|
-
_iterator.s();
|
|
522
|
-
case 59:
|
|
523
|
-
if ((_step = _iterator.n()).done) {
|
|
524
|
-
_context4.next = 71;
|
|
525
|
-
break;
|
|
526
|
-
}
|
|
527
|
-
callback = _step.value;
|
|
528
|
-
_context4.prev = 61;
|
|
529
|
-
_context4.next = 64;
|
|
530
|
-
return callback();
|
|
531
|
-
case 64:
|
|
532
|
-
_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;
|
|
533
477
|
break;
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
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;
|
|
540
494
|
break;
|
|
541
|
-
|
|
542
|
-
|
|
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;
|
|
543
511
|
break;
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
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();
|
|
558
570
|
}
|
|
559
571
|
}, _callee2, null, [[2, 51, 55, 80], [57, 73, 76, 79], [61, 66]]);
|
|
560
572
|
}));
|
|
@@ -563,7 +575,7 @@ function _generateScreenshot() {
|
|
|
563
575
|
|
|
564
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; } } }; }
|
|
565
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); }
|
|
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++)
|
|
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; }
|
|
567
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; }
|
|
568
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; }
|
|
569
581
|
var collator = new Intl.Collator("US");
|
|
@@ -601,44 +613,40 @@ var ContentBuilder = /*#__PURE__*/function () {
|
|
|
601
613
|
var _context3;
|
|
602
614
|
var getStartStopMs, results;
|
|
603
615
|
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context5) {
|
|
604
|
-
while (1) {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
var
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
results
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
case 5:
|
|
639
|
-
case "end":
|
|
640
|
-
return _context5.stop();
|
|
641
|
-
}
|
|
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();
|
|
642
650
|
}
|
|
643
651
|
}, _callee2);
|
|
644
652
|
}))() :
|
|
@@ -648,58 +656,54 @@ var ContentBuilder = /*#__PURE__*/function () {
|
|
|
648
656
|
// Generate playground pages.
|
|
649
657
|
_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4() {
|
|
650
658
|
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context8) {
|
|
651
|
-
while (1) {
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
var
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
case 3:
|
|
700
|
-
case "end":
|
|
701
|
-
return _context8.stop();
|
|
702
|
-
}
|
|
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();
|
|
703
707
|
}
|
|
704
708
|
}, _callee4);
|
|
705
709
|
}))() :
|
|
@@ -710,133 +714,127 @@ var ContentBuilder = /*#__PURE__*/function () {
|
|
|
710
714
|
_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee7() {
|
|
711
715
|
var cleanup, _process$env$DEBUG, _context10, _context11, debug, browser, todo, total, reports, _context17, _iterator, _step, callback;
|
|
712
716
|
return _regeneratorRuntime__default["default"].wrap(function _callee7$(_context18) {
|
|
713
|
-
while (1) {
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
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();
|
|
723
744
|
});
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
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;
|
|
737
761
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
_context16.next = 14;
|
|
760
|
-
break;
|
|
761
|
-
}
|
|
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);
|
|
783
|
-
}
|
|
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();
|
|
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);
|
|
793
783
|
}
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
case 24:
|
|
817
|
-
_context18.prev = 24;
|
|
818
|
-
_context18.t0 = _context18["catch"](19);
|
|
819
|
-
console.error(_context18.t0);
|
|
820
|
-
case 27:
|
|
821
|
-
_context18.next = 17;
|
|
822
|
-
break;
|
|
823
|
-
case 29:
|
|
824
|
-
_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;
|
|
825
806
|
break;
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
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();
|
|
840
838
|
}
|
|
841
839
|
}, _callee7, null, [[1,, 13, 38], [15, 31, 34, 37], [19, 24]]);
|
|
842
840
|
}))() :
|
|
@@ -845,31 +843,29 @@ var ContentBuilder = /*#__PURE__*/function () {
|
|
|
845
843
|
var checks = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee8() {
|
|
846
844
|
var total;
|
|
847
845
|
return _regeneratorRuntime__default["default"].wrap(function _callee8$(_context19) {
|
|
848
|
-
while (1) {
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
return _context19.stop();
|
|
872
|
-
}
|
|
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();
|
|
873
869
|
}
|
|
874
870
|
}, _callee8);
|
|
875
871
|
}))();
|
|
@@ -905,7 +901,7 @@ var styleTemplate = ".examples-root {\n margin: 50px auto 200px;\n min-width:
|
|
|
905
901
|
|
|
906
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; } } }; }
|
|
907
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); }
|
|
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++)
|
|
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; }
|
|
909
905
|
/**
|
|
910
906
|
* @param example
|
|
911
907
|
*/
|
|
@@ -999,7 +995,7 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["def
|
|
|
999
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; }
|
|
1000
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; } } }; }
|
|
1001
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); }
|
|
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++)
|
|
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; }
|
|
1003
999
|
/**
|
|
1004
1000
|
* @param lines
|
|
1005
1001
|
*/
|
|
@@ -1051,7 +1047,7 @@ function processGroup(examples, output, title, collator) {
|
|
|
1051
1047
|
var example = examples[key];
|
|
1052
1048
|
if (isExample(example)) {
|
|
1053
1049
|
// An example in this group.
|
|
1054
|
-
items.push(header(2, key), "", image(key, "./" +
|
|
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(" | "), "");
|
|
1055
1051
|
} else {
|
|
1056
1052
|
var _context9;
|
|
1057
1053
|
// A subgroup of examples.
|
|
@@ -1216,10 +1212,10 @@ function fixAbsoluteInputURL(baseURL, url) {
|
|
|
1216
1212
|
* @param exampleAbsolutePath
|
|
1217
1213
|
*/
|
|
1218
1214
|
function generatePaths(config, exampleAbsolutePath) {
|
|
1219
|
-
var exampleRelativePath =
|
|
1215
|
+
var exampleRelativePath = node_path.relative(config.page.local, exampleAbsolutePath);
|
|
1220
1216
|
// It's important that the hash is created from the relative path so that it
|
|
1221
1217
|
// is the same on all computers.
|
|
1222
|
-
var hash =
|
|
1218
|
+
var hash = node_crypto.createHash("sha256").update(exampleRelativePath).digest("hex");
|
|
1223
1219
|
return {
|
|
1224
1220
|
codepen: generateLocalWebPair(config.codepen.local, config.codepen.web, hash, "codepen", "html"),
|
|
1225
1221
|
jsfiddle: generateLocalWebPair(config.jsfiddle.local, config.jsfiddle.web, hash, "jsfiddle", "html"),
|
|
@@ -1241,11 +1237,12 @@ function generateLocalWebPair(localRoot, webRoot, hash, prefix, extension) {
|
|
|
1241
1237
|
var _context, _context2;
|
|
1242
1238
|
var filename = _concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = "".concat(prefix, ".")).call(_context2, hash, ".")).call(_context, extension);
|
|
1243
1239
|
return {
|
|
1244
|
-
local:
|
|
1240
|
+
local: node_path.resolve(localRoot, filename),
|
|
1245
1241
|
web: joinURLs(webRoot, filename)
|
|
1246
1242
|
};
|
|
1247
1243
|
}
|
|
1248
1244
|
|
|
1245
|
+
var globby = Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('globby')); });
|
|
1249
1246
|
var argv = parseArguments();
|
|
1250
1247
|
// Log the parsed configuration for debugging purposes.
|
|
1251
1248
|
console.info("Configuration: ", _JSON$stringify__default["default"](argv, null, 2));
|
|
@@ -1254,7 +1251,7 @@ process.stdout.write("\n");
|
|
|
1254
1251
|
// parallel. This ensures there are no warnings about it.
|
|
1255
1252
|
process.setMaxListeners(40);
|
|
1256
1253
|
// Resolve paths relative to PWD.
|
|
1257
|
-
var screenshotScriptPath = typeof argv["screenshot-script"] === "string" ?
|
|
1254
|
+
var screenshotScriptPath = typeof argv["screenshot-script"] === "string" ? node_path.resolve(argv["screenshot-script"]) : undefined;
|
|
1258
1255
|
var mkdir = util__default["default"].promisify(fs__default["default"].mkdir);
|
|
1259
1256
|
var readFile = util__default["default"].promisify(fs__default["default"].readFile);
|
|
1260
1257
|
/**
|
|
@@ -1318,280 +1315,277 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
|
|
|
1318
1315
|
var _context4, _context6;
|
|
1319
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;
|
|
1320
1317
|
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context24) {
|
|
1321
|
-
while (1) {
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
}));
|
|
1350
|
-
return function (_x) {
|
|
1351
|
-
return _ref2.apply(this, arguments);
|
|
1352
|
-
};
|
|
1353
|
-
}()));
|
|
1354
|
-
case 6:
|
|
1355
|
-
baseURL = argv["base-url"];
|
|
1356
|
-
if (_endsWithInstanceProperty__default["default"](baseURL).call(baseURL, "/")) {
|
|
1357
|
-
_context24.next = 9;
|
|
1358
|
-
break;
|
|
1359
|
-
}
|
|
1360
|
-
throw new Error("Base URL (`base-url`) has to end with a slash (`/`).");
|
|
1361
|
-
case 9:
|
|
1362
|
-
// Paths.
|
|
1363
|
-
pathsConfig = {
|
|
1364
|
-
codepen: {
|
|
1365
|
-
local: argv["pages-local-directory"],
|
|
1366
|
-
web: fixAbsoluteInputURL(baseURL, argv["pages-web-directory"])
|
|
1367
|
-
},
|
|
1368
|
-
jsfiddle: {
|
|
1369
|
-
local: argv["pages-local-directory"],
|
|
1370
|
-
web: fixAbsoluteInputURL(baseURL, argv["pages-web-directory"])
|
|
1371
|
-
},
|
|
1372
|
-
page: {
|
|
1373
|
-
local: argv["examples-local-directory"],
|
|
1374
|
-
web: fixAbsoluteInputURL(baseURL, argv["examples-web-directory"])
|
|
1375
|
-
},
|
|
1376
|
-
screenshot: {
|
|
1377
|
-
local: argv["assets-local-directory"],
|
|
1378
|
-
web: fixAbsoluteInputURL(baseURL, argv["assets-web-directory"])
|
|
1379
|
-
}
|
|
1380
|
-
};
|
|
1381
|
-
examples = {};
|
|
1382
|
-
selector = "#" + argv["container-id"];
|
|
1383
|
-
stats = {
|
|
1384
|
-
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);
|
|
1385
1346
|
};
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
case 18:
|
|
1392
|
-
_context24.t2 = _context6 = _context24.sent;
|
|
1393
|
-
_context24.t3 = (0, _context24.t1)(_context24.t2).call(_context6, /*#__PURE__*/function () {
|
|
1394
|
-
var _ref3 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(pagePath) {
|
|
1395
|
-
var _context7;
|
|
1396
|
-
var html, $page, pageDelay, pageTimeout, pageSelector, titles, _context9;
|
|
1397
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context10) {
|
|
1398
|
-
while (1) {
|
|
1399
|
-
switch (_context10.prev = _context10.next) {
|
|
1400
|
-
case 0:
|
|
1401
|
-
_context10.next = 2;
|
|
1402
|
-
return readFile(pagePath, "utf-8");
|
|
1403
|
-
case 2:
|
|
1404
|
-
html = _context10.sent;
|
|
1405
|
-
$page = $__default["default"].load(html);
|
|
1406
|
-
pageDelay = getMeta($page, "example-screenshot-delay", 6);
|
|
1407
|
-
pageTimeout = getMeta($page, "example-screenshot-timeout", 60);
|
|
1408
|
-
pageSelector = getMeta($page, "example-screenshot-selector", selector); // Is this an examples?
|
|
1409
|
-
if (!($page(pageSelector).length === 0)) {
|
|
1410
|
-
_context10.next = 10;
|
|
1411
|
-
break;
|
|
1412
|
-
}
|
|
1413
|
-
skipped.push(pagePath);
|
|
1414
|
-
return _context10.abrupt("return");
|
|
1415
|
-
case 10:
|
|
1416
|
-
// Lint if requested.
|
|
1417
|
-
if (argv.lint) {
|
|
1418
|
-
lintExample(pagePath, $page);
|
|
1419
|
-
}
|
|
1420
|
-
// Body titles.
|
|
1421
|
-
titles = _mapInstanceProperty__default["default"](_context7 = $page("#title > *").get()).call(_context7, function (elem) {
|
|
1422
|
-
var _context8;
|
|
1423
|
-
return _trimInstanceProperty__default["default"](_context8 = $page(elem).text()).call(_context8);
|
|
1424
|
-
}); // Head title fallback.
|
|
1425
|
-
if (titles.length < 2) {
|
|
1426
|
-
titles = _mapInstanceProperty__default["default"](_context9 = $page("head > title").text().split("|")).call(_context9, function (title) {
|
|
1427
|
-
return _trimInstanceProperty__default["default"](title).call(title);
|
|
1428
|
-
});
|
|
1429
|
-
}
|
|
1430
|
-
// File path fallback.
|
|
1431
|
-
if (titles.length < 2) {
|
|
1432
|
-
titles = pagePath.split("/");
|
|
1433
|
-
}
|
|
1434
|
-
// Just ignore it.
|
|
1435
|
-
if (!(titles.length < 2)) {
|
|
1436
|
-
_context10.next = 17;
|
|
1437
|
-
break;
|
|
1438
|
-
}
|
|
1439
|
-
console.error("Title resolution failed. Skipping.");
|
|
1440
|
-
return _context10.abrupt("return");
|
|
1441
|
-
case 17:
|
|
1442
|
-
// Put this example into the structure while creating any missing groups in the process.
|
|
1443
|
-
_reduceInstanceProperty__default["default"](titles).call(titles, function (acc, title, i, arr) {
|
|
1444
|
-
while (acc[title] != null && acc[title].path != null) {
|
|
1445
|
-
console.error("The following group already exists: ", titles);
|
|
1446
|
-
title += "!";
|
|
1447
|
-
}
|
|
1448
|
-
if (i === arr.length - 1) {
|
|
1449
|
-
if (acc[title] != null) {
|
|
1450
|
-
console.error("The following example has the same name as an already existing group: ", titles);
|
|
1451
|
-
return null;
|
|
1452
|
-
} else {
|
|
1453
|
-
var example = {
|
|
1454
|
-
$: $page,
|
|
1455
|
-
delay: pageDelay,
|
|
1456
|
-
html: html,
|
|
1457
|
-
path: pagePath,
|
|
1458
|
-
paths: generatePaths(pathsConfig, pagePath),
|
|
1459
|
-
playground: generatePlaygroundData(baseURL, $page, pagePath),
|
|
1460
|
-
selector: pageSelector,
|
|
1461
|
-
timeout: pageTimeout,
|
|
1462
|
-
titles: titles
|
|
1463
|
-
};
|
|
1464
|
-
acc[title] = example;
|
|
1465
|
-
++stats.examples;
|
|
1466
|
-
}
|
|
1467
|
-
} else {
|
|
1468
|
-
return acc[title] = acc[title] || {};
|
|
1469
|
-
}
|
|
1470
|
-
}, examples);
|
|
1471
|
-
case 18:
|
|
1472
|
-
case "end":
|
|
1473
|
-
return _context10.stop();
|
|
1474
|
-
}
|
|
1475
|
-
}
|
|
1476
|
-
}, _callee2);
|
|
1477
|
-
}));
|
|
1478
|
-
return function (_x2) {
|
|
1479
|
-
return _ref3.apply(this, arguments);
|
|
1480
|
-
};
|
|
1481
|
-
}());
|
|
1482
|
-
_context24.next = 22;
|
|
1483
|
-
return _context24.t0.all.call(_context24.t0, _context24.t3);
|
|
1484
|
-
case 22:
|
|
1485
|
-
if (skipped.length) {
|
|
1486
|
-
process.stdout.write("\n");
|
|
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 "));
|
|
1488
|
-
}
|
|
1489
|
-
if (!(stats.examples === 0)) {
|
|
1490
|
-
_context24.next = 27;
|
|
1491
|
-
break;
|
|
1492
|
-
}
|
|
1493
|
-
console.info("No usable example files were found.");
|
|
1494
|
-
_context24.next = 67;
|
|
1347
|
+
}()));
|
|
1348
|
+
case 6:
|
|
1349
|
+
baseURL = argv["base-url"];
|
|
1350
|
+
if (_endsWithInstanceProperty__default["default"](baseURL).call(baseURL, "/")) {
|
|
1351
|
+
_context24.next = 9;
|
|
1495
1352
|
break;
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
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"])
|
|
1500
1373
|
}
|
|
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) {
|
|
1501
1481
|
process.stdout.write("\n");
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
_context24.next = 32;
|
|
1507
|
-
return readFile(screenshotScriptPath, "utf-8");
|
|
1508
|
-
case 32:
|
|
1509
|
-
_context24.t5 = _context24.sent;
|
|
1510
|
-
if (_context24.t5) {
|
|
1511
|
-
_context24.next = 35;
|
|
1512
|
-
break;
|
|
1513
|
-
}
|
|
1514
|
-
_context24.t5 = "";
|
|
1515
|
-
case 35:
|
|
1516
|
-
_context24.t4 = _context24.t5;
|
|
1517
|
-
_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;
|
|
1518
1486
|
break;
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
_context24.
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
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) {
|
|
1571
1555
|
_context24.next = 64;
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
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.");
|
|
1578
1576
|
} else {
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
} else {
|
|
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.");
|
|
1583
|
-
code = 3;
|
|
1584
|
-
}
|
|
1585
|
-
_forEachInstanceProperty__default["default"](_context23 = checks.failPaths).call(_context23, function (path) {
|
|
1586
|
-
console.error(path);
|
|
1587
|
-
});
|
|
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;
|
|
1588
1579
|
}
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
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();
|
|
1595
1589
|
}
|
|
1596
1590
|
}, _callee3);
|
|
1597
1591
|
}))().catch(function (error) {
|