vis-dev-utils 3.0.121 → 3.1.0
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 +10 -35
- package/babel-register/index.js.map +1 -1
- package/bin/ci-utils.js +7 -15
- package/bin/ci-utils.js.map +1 -1
- package/bin/generate-examples-index.js +155 -225
- package/bin/generate-examples-index.js.map +1 -1
- package/bin/test-e2e-interop.js +1162 -915
- package/bin/test-e2e-interop.js.map +1 -1
- package/declarations/generate-rollup-configuration/index.d.ts +4 -4
- package/declarations/generate-rollup-configuration/index.d.ts.map +1 -1
- package/dist/vis-dev-utils.cjs.js +80 -140
- package/dist/vis-dev-utils.cjs.js.map +1 -1
- package/dist/vis-dev-utils.esm.js +14 -8
- package/dist/vis-dev-utils.esm.js.map +1 -1
- package/package.json +15 -14
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Development utilities for the Vis family projects.
|
|
8
8
|
*
|
|
9
|
-
* @version 3.0
|
|
10
|
-
* @date 2023-
|
|
9
|
+
* @version 3.1.0
|
|
10
|
+
* @date 2023-03-04T19:12:02.714Z
|
|
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
|
|
@@ -80,89 +80,19 @@ var _repeatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/ins
|
|
|
80
80
|
var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
81
81
|
var node_crypto = require('node:crypto');
|
|
82
82
|
|
|
83
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
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
|
-
|
|
103
|
-
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
|
104
|
-
var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator);
|
|
105
|
-
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
|
|
106
|
-
var _JSON$stringify__default = /*#__PURE__*/_interopDefaultLegacy(_JSON$stringify);
|
|
107
|
-
var _Number$isNaN__default = /*#__PURE__*/_interopDefaultLegacy(_Number$isNaN);
|
|
108
|
-
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_trimInstanceProperty);
|
|
109
|
-
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_mapInstanceProperty);
|
|
110
|
-
var _Promise__default = /*#__PURE__*/_interopDefaultLegacy(_Promise);
|
|
111
|
-
var _endsWithInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_endsWithInstanceProperty);
|
|
112
|
-
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_reduceInstanceProperty);
|
|
113
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_concatInstanceProperty);
|
|
114
|
-
var _sortInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_sortInstanceProperty);
|
|
115
|
-
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_forEachInstanceProperty);
|
|
116
|
-
var $__default = /*#__PURE__*/_interopDefaultLegacy($);
|
|
117
|
-
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
118
|
-
var util__default = /*#__PURE__*/_interopDefaultLegacy(util);
|
|
119
|
-
var yargs__default = /*#__PURE__*/_interopDefaultLegacy(yargs);
|
|
120
|
-
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefaultLegacy(_Object$getOwnPropertySymbols);
|
|
121
|
-
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_filterInstanceProperty);
|
|
122
|
-
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefaultLegacy(_Object$getOwnPropertyDescriptor);
|
|
123
|
-
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefaultLegacy(_Object$getOwnPropertyDescriptors);
|
|
124
|
-
var _Object$defineProperties__default = /*#__PURE__*/_interopDefaultLegacy(_Object$defineProperties);
|
|
125
|
-
var _Object$defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_Object$defineProperty);
|
|
126
|
-
var _Array$from__default = /*#__PURE__*/_interopDefaultLegacy(_Array$from);
|
|
127
|
-
var _Symbol__default = /*#__PURE__*/_interopDefaultLegacy(_Symbol);
|
|
128
|
-
var _getIteratorMethod__default = /*#__PURE__*/_interopDefaultLegacy(_getIteratorMethod);
|
|
129
|
-
var _Array$isArray__default = /*#__PURE__*/_interopDefaultLegacy(_Array$isArray);
|
|
130
|
-
var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);
|
|
131
|
-
var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
|
|
132
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
133
|
-
var _flatInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_flatInstanceProperty);
|
|
134
|
-
var _everyInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_everyInstanceProperty);
|
|
135
|
-
var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_sliceInstanceProperty);
|
|
136
|
-
var _fillInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_fillInstanceProperty);
|
|
137
|
-
var _padStartInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_padStartInstanceProperty);
|
|
138
|
-
var _reverseInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_reverseInstanceProperty);
|
|
139
|
-
var _spliceInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_spliceInstanceProperty);
|
|
140
|
-
var _flatMapInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_flatMapInstanceProperty);
|
|
141
|
-
var _Object$keys__default = /*#__PURE__*/_interopDefaultLegacy(_Object$keys);
|
|
142
|
-
var puppeteer__default = /*#__PURE__*/_interopDefaultLegacy(puppeteer);
|
|
143
|
-
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
|
|
144
|
-
var _Date$now__default = /*#__PURE__*/_interopDefaultLegacy(_Date$now);
|
|
145
|
-
var prettier__default = /*#__PURE__*/_interopDefaultLegacy(prettier);
|
|
146
|
-
var _findInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_findInstanceProperty);
|
|
147
|
-
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
148
|
-
var _Object$entries__default = /*#__PURE__*/_interopDefaultLegacy(_Object$entries);
|
|
149
|
-
var Jimp__default = /*#__PURE__*/_interopDefaultLegacy(Jimp);
|
|
150
|
-
var _repeatInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_repeatInstanceProperty);
|
|
151
|
-
var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_startsWithInstanceProperty);
|
|
152
|
-
|
|
153
83
|
/**
|
|
154
84
|
* @param value
|
|
155
85
|
*/
|
|
156
86
|
function isExample(value) {
|
|
157
|
-
return
|
|
87
|
+
return _typeof(value) === "object" && value !== null && typeof value.path === "string";
|
|
158
88
|
}
|
|
159
89
|
/**
|
|
160
90
|
*
|
|
161
91
|
*/
|
|
162
92
|
function measureStartStopMs() {
|
|
163
|
-
var start = _Date$
|
|
93
|
+
var start = _Date$now();
|
|
164
94
|
return function () {
|
|
165
|
-
var stop = _Date$
|
|
95
|
+
var stop = _Date$now();
|
|
166
96
|
return {
|
|
167
97
|
start: start,
|
|
168
98
|
stop: stop
|
|
@@ -181,11 +111,11 @@ function reduceReports(reports) {
|
|
|
181
111
|
start: -1,
|
|
182
112
|
stop: -1
|
|
183
113
|
};
|
|
184
|
-
return (_reports$reduce =
|
|
114
|
+
return (_reports$reduce = _reduceInstanceProperty(reports).call(reports, function (acc, val) {
|
|
185
115
|
var _acc$count, _val$count, _context, _acc$result, _acc$start, _acc$stop;
|
|
186
116
|
return {
|
|
187
117
|
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),
|
|
188
|
-
result:
|
|
118
|
+
result: _everyInstanceProperty(_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) {
|
|
189
119
|
return result === "fulfilled";
|
|
190
120
|
}) ? "fulfilled" : "rejected",
|
|
191
121
|
start: Math.min((_acc$start = acc === null || acc === void 0 ? void 0 : acc.start) !== null && _acc$start !== void 0 ? _acc$start : Number.POSITIVE_INFINITY, val.start),
|
|
@@ -205,22 +135,22 @@ function formatStartStopMs(_ref) {
|
|
|
205
135
|
}
|
|
206
136
|
|
|
207
137
|
var formatCSS = function formatCSS(css) {
|
|
208
|
-
return
|
|
138
|
+
return prettier.format(css || "", {
|
|
209
139
|
filepath: "style.css"
|
|
210
140
|
});
|
|
211
141
|
};
|
|
212
142
|
var formatHTML = function formatHTML(html) {
|
|
213
|
-
return
|
|
143
|
+
return prettier.format(html || "", {
|
|
214
144
|
filepath: "index.html"
|
|
215
145
|
});
|
|
216
146
|
};
|
|
217
147
|
var formatJS = function formatJS(js) {
|
|
218
|
-
return
|
|
148
|
+
return prettier.format(js || "", {
|
|
219
149
|
filepath: "script.js"
|
|
220
150
|
});
|
|
221
151
|
};
|
|
222
152
|
var formatMD = function formatMD(md) {
|
|
223
|
-
return
|
|
153
|
+
return prettier.format(md || "", {
|
|
224
154
|
filepath: "README.md"
|
|
225
155
|
});
|
|
226
156
|
};
|
|
@@ -233,10 +163,10 @@ var template$1 = "<html>\n <head>\n <meta charset=\"utf-8\" />\n <title>C
|
|
|
233
163
|
function generateCodePenPage(example) {
|
|
234
164
|
var data = example.playground;
|
|
235
165
|
var title = example.titles.join(" | ");
|
|
236
|
-
var page =
|
|
166
|
+
var page = $.load(template$1);
|
|
237
167
|
page("title").text(title);
|
|
238
168
|
var form = page("#form");
|
|
239
|
-
|
|
169
|
+
_findInstanceProperty(form).call(form, 'input[name="data"]').attr("value", _JSON$stringify({
|
|
240
170
|
css: data.code.css,
|
|
241
171
|
css_external: data.resources.css.join(";"),
|
|
242
172
|
html: data.code.html,
|
|
@@ -255,35 +185,35 @@ function generateCodePenPage(example) {
|
|
|
255
185
|
function generatePlaygroundData(baseURL, example$, examplePath) {
|
|
256
186
|
var _context, _context2, _context3, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12, _context13, _context14;
|
|
257
187
|
// JavaScript
|
|
258
|
-
var eventListeners =
|
|
259
|
-
var _ref2 =
|
|
188
|
+
var eventListeners = _mapInstanceProperty(_context = _mapInstanceProperty(_context2 = _filterInstanceProperty(_context3 = _Object$entries(example$("body").get(0).attribs)).call(_context3, function (_ref) {
|
|
189
|
+
var _ref2 = _slicedToArray(_ref, 1),
|
|
260
190
|
name = _ref2[0];
|
|
261
191
|
return /^on/.test(name);
|
|
262
192
|
})).call(_context2, function (_ref3) {
|
|
263
|
-
var _ref4 =
|
|
193
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
264
194
|
name = _ref4[0],
|
|
265
195
|
value = _ref4[1];
|
|
266
|
-
return [
|
|
196
|
+
return [_sliceInstanceProperty(name).call(name, 2), "".concat(value)];
|
|
267
197
|
})).call(_context, function (_ref5) {
|
|
268
198
|
var _context4;
|
|
269
|
-
var _ref6 =
|
|
199
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
270
200
|
name = _ref6[0],
|
|
271
201
|
value = _ref6[1];
|
|
272
|
-
return
|
|
202
|
+
return _concatInstanceProperty(_context4 = "window.addEventListener(\"".concat(name, "\", () => { ")).call(_context4, value, " });");
|
|
273
203
|
}).join("\n");
|
|
274
|
-
var js = formatJS(
|
|
204
|
+
var js = formatJS(_mapInstanceProperty(_context5 = _mapInstanceProperty(_context6 = example$("script")).call(_context6, function (_i, elem) {
|
|
275
205
|
return elem.children[0];
|
|
276
206
|
}).get()).call(_context5, function (elem) {
|
|
277
207
|
return elem.data;
|
|
278
208
|
}).join("") + "\n\n;" + eventListeners);
|
|
279
209
|
// Cascading Style Sheets
|
|
280
|
-
var css = formatCSS(
|
|
210
|
+
var css = formatCSS(_mapInstanceProperty(_context7 = _mapInstanceProperty(_context8 = example$("style")).call(_context8, function (_i, elem) {
|
|
281
211
|
return elem.children[0];
|
|
282
212
|
}).get()).call(_context7, function (elem) {
|
|
283
213
|
return elem.data;
|
|
284
214
|
}).join(""));
|
|
285
215
|
// Hypertext Markup Language
|
|
286
|
-
var $html =
|
|
216
|
+
var $html = $.load(example$("body").html() || "");
|
|
287
217
|
$html("script").remove();
|
|
288
218
|
var html = formatHTML($html("body").html());
|
|
289
219
|
// Resources
|
|
@@ -292,18 +222,18 @@ function generatePlaygroundData(baseURL, example$, examplePath) {
|
|
|
292
222
|
// World wide web absolute.
|
|
293
223
|
rawPath : /^\//.test(rawPath) ?
|
|
294
224
|
// Domain absolute.
|
|
295
|
-
baseURL +
|
|
225
|
+
baseURL + _sliceInstanceProperty(rawPath).call(rawPath, 1) :
|
|
296
226
|
//Relative.
|
|
297
227
|
baseURL + node_path.relative(process.cwd(), node_path.resolve(node_path.dirname(examplePath), rawPath));
|
|
298
228
|
};
|
|
299
229
|
var resources = {
|
|
300
|
-
js:
|
|
301
|
-
return
|
|
230
|
+
js: _mapInstanceProperty(_context9 = _filterInstanceProperty(_context10 = _mapInstanceProperty(_context11 = example$("script")).call(_context11, function (_i, elem) {
|
|
231
|
+
return $.load(elem)("script").attr("src");
|
|
302
232
|
}).get()).call(_context10, function (src) {
|
|
303
233
|
return typeof src === "string";
|
|
304
234
|
})).call(_context9, fixPath),
|
|
305
|
-
css:
|
|
306
|
-
return
|
|
235
|
+
css: _mapInstanceProperty(_context12 = _filterInstanceProperty(_context13 = _mapInstanceProperty(_context14 = example$("link[rel='stylesheet']")).call(_context14, function (_i, elem) {
|
|
236
|
+
return $.load(elem)("script").attr("href");
|
|
307
237
|
}).get()).call(_context13, function (href) {
|
|
308
238
|
return typeof href === "string";
|
|
309
239
|
})).call(_context12, fixPath)
|
|
@@ -327,28 +257,28 @@ function generateJSFiddlePage(example) {
|
|
|
327
257
|
var _context;
|
|
328
258
|
var data = example.playground;
|
|
329
259
|
var title = example.titles.join(" | ");
|
|
330
|
-
var resources =
|
|
331
|
-
var page =
|
|
260
|
+
var resources = _concatInstanceProperty(_context = []).call(_context, _toConsumableArray(data.resources.css), _toConsumableArray(data.resources.js)).join(",");
|
|
261
|
+
var page = $.load(template);
|
|
332
262
|
page("title").text(title);
|
|
333
263
|
var form = page("#form");
|
|
334
264
|
// Playground data.
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
265
|
+
_findInstanceProperty(form).call(form, 'input[name="css"]').attr("value", data.code.css);
|
|
266
|
+
_findInstanceProperty(form).call(form, 'input[name="html"]').attr("value", data.code.html);
|
|
267
|
+
_findInstanceProperty(form).call(form, 'input[name="js"]').attr("value", data.code.js);
|
|
268
|
+
_findInstanceProperty(form).call(form, 'input[name="resources"]').attr("value", resources);
|
|
269
|
+
_findInstanceProperty(form).call(form, 'input[name="title"]').attr("value", title);
|
|
340
270
|
// Don't run JS before the DOM is ready.
|
|
341
|
-
|
|
271
|
+
_findInstanceProperty(form).call(form, 'input[name="wrap"]').attr("value", "b");
|
|
342
272
|
return page.html();
|
|
343
273
|
}
|
|
344
274
|
|
|
345
275
|
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";
|
|
346
276
|
|
|
347
|
-
function _createForOfIteratorHelper$3(o, allowArrayLike) { var it = typeof
|
|
348
|
-
function _unsupportedIterableToArray$3(o, minLen) { var _context5; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n =
|
|
277
|
+
function _createForOfIteratorHelper$3(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (_Array$isArray(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; } } }; }
|
|
278
|
+
function _unsupportedIterableToArray$3(o, minLen) { var _context5; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = _sliceInstanceProperty(_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(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); }
|
|
349
279
|
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; }
|
|
350
|
-
var unlink = util.promisify(
|
|
351
|
-
var writeFile$1 = util.promisify(
|
|
280
|
+
var unlink = util.promisify(fs.unlink);
|
|
281
|
+
var writeFile$1 = util.promisify(fs.writeFile);
|
|
352
282
|
/**
|
|
353
283
|
* Check if the screenshot is valid. At the moment this simply considers
|
|
354
284
|
* everything except for solid color images as valid. This works pretty well
|
|
@@ -369,13 +299,13 @@ function isScreenshotValid(_x) {
|
|
|
369
299
|
* @returns Whether or not the screenshot passed validation check.
|
|
370
300
|
*/
|
|
371
301
|
function _isScreenshotValid() {
|
|
372
|
-
_isScreenshotValid =
|
|
302
|
+
_isScreenshotValid = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(screenshot) {
|
|
373
303
|
var image, firstPixel, x, y;
|
|
374
|
-
return
|
|
304
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
375
305
|
while (1) switch (_context.prev = _context.next) {
|
|
376
306
|
case 0:
|
|
377
307
|
_context.next = 2;
|
|
378
|
-
return
|
|
308
|
+
return Jimp.read(screenshot);
|
|
379
309
|
case 2:
|
|
380
310
|
image = _context.sent;
|
|
381
311
|
firstPixel = image.getPixelColor(0, 0);
|
|
@@ -418,9 +348,9 @@ function generateScreenshot(_x2, _x3) {
|
|
|
418
348
|
return _generateScreenshot.apply(this, arguments);
|
|
419
349
|
}
|
|
420
350
|
function _generateScreenshot() {
|
|
421
|
-
_generateScreenshot =
|
|
351
|
+
_generateScreenshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(browser, config) {
|
|
422
352
|
var debug, example, height, screenshotScript, width, cleanup, tmpPath, screenshotPage, context, page, $element, _context2, screenshot, _context3, _iterator, _step, callback;
|
|
423
|
-
return
|
|
353
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context4) {
|
|
424
354
|
while (1) switch (_context4.prev = _context4.next) {
|
|
425
355
|
case 0:
|
|
426
356
|
debug = config.debug, example = config.example, height = config.height, screenshotScript = config.screenshotScript, width = config.width;
|
|
@@ -429,8 +359,8 @@ function _generateScreenshot() {
|
|
|
429
359
|
// Prepare the page. It has to be written to the disk so that files with
|
|
430
360
|
// relative URLs can be loaded.
|
|
431
361
|
tmpPath = node_path.resolve(node_path.dirname(example.paths.page.local), ".tmp.example.screenshot." + node_path.basename(example.paths.page.local));
|
|
432
|
-
screenshotPage =
|
|
433
|
-
screenshotPage("head").prepend(
|
|
362
|
+
screenshotPage = $.load(example.html);
|
|
363
|
+
screenshotPage("head").prepend($.load([])("<script>").attr("type", "text/javascript").text("window.DEBUG = ".concat(true, ";")), $.load([])("<script>").attr("type", "text/javascript").text(commonScreenshotScript), $.load([])("<script>").attr("type", "text/javascript").text(screenshotScript), $.load([])("<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
364
|
_context4.next = 8;
|
|
435
365
|
return writeFile$1(tmpPath, formatHTML(screenshotPage.html()));
|
|
436
366
|
case 8:
|
|
@@ -493,7 +423,7 @@ function _generateScreenshot() {
|
|
|
493
423
|
_context4.next = 35;
|
|
494
424
|
break;
|
|
495
425
|
}
|
|
496
|
-
throw new Error(
|
|
426
|
+
throw new Error(_concatInstanceProperty(_context2 = "Element \"".concat(example.selector, "\" not found in ")).call(_context2, example.path, "."));
|
|
497
427
|
case 35:
|
|
498
428
|
_context4.next = 37;
|
|
499
429
|
return $element.evaluate(function (element) {
|
|
@@ -529,7 +459,7 @@ function _generateScreenshot() {
|
|
|
529
459
|
return _context4.abrupt("return", false);
|
|
530
460
|
case 55:
|
|
531
461
|
_context4.prev = 55;
|
|
532
|
-
_iterator = _createForOfIteratorHelper$3(
|
|
462
|
+
_iterator = _createForOfIteratorHelper$3(_reverseInstanceProperty(_context3 = _spliceInstanceProperty(cleanup).call(cleanup, 0)).call(_context3));
|
|
533
463
|
_context4.prev = 57;
|
|
534
464
|
_iterator.s();
|
|
535
465
|
case 59:
|
|
@@ -573,17 +503,17 @@ function _generateScreenshot() {
|
|
|
573
503
|
return _generateScreenshot.apply(this, arguments);
|
|
574
504
|
}
|
|
575
505
|
|
|
576
|
-
function _createForOfIteratorHelper$2(o, allowArrayLike) { var it = typeof
|
|
577
|
-
function _unsupportedIterableToArray$2(o, minLen) { var _context24; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$2(o, minLen); var n =
|
|
506
|
+
function _createForOfIteratorHelper$2(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (_Array$isArray(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; } } }; }
|
|
507
|
+
function _unsupportedIterableToArray$2(o, minLen) { var _context24; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$2(o, minLen); var n = _sliceInstanceProperty(_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(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen); }
|
|
578
508
|
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; }
|
|
579
|
-
function ownKeys$1(object, enumerableOnly) { var keys = _Object$
|
|
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 ?
|
|
509
|
+
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
510
|
+
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(_context22 = ownKeys$1(Object(source), !0)).call(_context22, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context23 = ownKeys$1(Object(source))).call(_context23, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
581
511
|
var collator = new Intl.Collator("US");
|
|
582
|
-
var writeFile = util.promisify(
|
|
512
|
+
var writeFile = util.promisify(fs.writeFile);
|
|
583
513
|
var ContentBuilder = /*#__PURE__*/function () {
|
|
584
514
|
function ContentBuilder(_config) {
|
|
585
|
-
|
|
586
|
-
|
|
515
|
+
_classCallCheck(this, ContentBuilder);
|
|
516
|
+
_defineProperty(this, "_config", void 0);
|
|
587
517
|
this._config = _config;
|
|
588
518
|
}
|
|
589
519
|
/**
|
|
@@ -595,7 +525,7 @@ var ContentBuilder = /*#__PURE__*/function () {
|
|
|
595
525
|
* @param emit.screenshots
|
|
596
526
|
* @returns A report with check results and the number of written files.
|
|
597
527
|
*/
|
|
598
|
-
|
|
528
|
+
_createClass(ContentBuilder, [{
|
|
599
529
|
key: "build",
|
|
600
530
|
value: function build() {
|
|
601
531
|
var _context,
|
|
@@ -605,22 +535,22 @@ var ContentBuilder = /*#__PURE__*/function () {
|
|
|
605
535
|
var allExamples = this._processGroup(this._config.examples);
|
|
606
536
|
var okay = [];
|
|
607
537
|
var fail = [];
|
|
608
|
-
console.info(
|
|
538
|
+
console.info(_concatInstanceProperty(_context = "Going to generate ".concat(_flatInstanceProperty(_context2 = [emit.index ? ["index files"] : [], emit.playgrounds ? ["playground openers"] : [], emit.screenshots ? ["screenshots"] : []]).call(_context2).join(", "), " for ")).call(_context, allExamples.length, " examples."));
|
|
609
539
|
process.stdout.write("\n");
|
|
610
540
|
var index = emit.index ?
|
|
611
541
|
// Generate indexes.
|
|
612
|
-
|
|
542
|
+
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
613
543
|
var _context3;
|
|
614
544
|
var getStartStopMs, results;
|
|
615
|
-
return
|
|
545
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context5) {
|
|
616
546
|
while (1) switch (_context5.prev = _context5.next) {
|
|
617
547
|
case 0:
|
|
618
548
|
getStartStopMs = measureStartStopMs();
|
|
619
549
|
_context5.next = 3;
|
|
620
|
-
return
|
|
621
|
-
var _ref3 =
|
|
550
|
+
return _Promise.allSettled(_mapInstanceProperty(_context3 = _this._config.renderer.render(_this._config.examples, _this._config.output, _this._config.title, collator)).call(_context3, /*#__PURE__*/function () {
|
|
551
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2) {
|
|
622
552
|
var content, filename;
|
|
623
|
-
return
|
|
553
|
+
return _regeneratorRuntime.wrap(function _callee$(_context4) {
|
|
624
554
|
while (1) switch (_context4.prev = _context4.next) {
|
|
625
555
|
case 0:
|
|
626
556
|
content = _ref2.content, filename = _ref2.filename;
|
|
@@ -639,7 +569,7 @@ var ContentBuilder = /*#__PURE__*/function () {
|
|
|
639
569
|
results = _context5.sent;
|
|
640
570
|
return _context5.abrupt("return", [_objectSpread$1(_objectSpread$1({}, getStartStopMs()), {}, {
|
|
641
571
|
count: results.length,
|
|
642
|
-
result:
|
|
572
|
+
result: _everyInstanceProperty(results).call(results, function (_ref4) {
|
|
643
573
|
var status = _ref4.status;
|
|
644
574
|
return status === "fulfilled";
|
|
645
575
|
}) ? "fulfilled" : "rejected"
|
|
@@ -651,24 +581,24 @@ var ContentBuilder = /*#__PURE__*/function () {
|
|
|
651
581
|
}, _callee2);
|
|
652
582
|
}))() :
|
|
653
583
|
// Skip indexes.
|
|
654
|
-
|
|
584
|
+
_Promise.resolve([]);
|
|
655
585
|
var playgrounds = emit.playgrounds ?
|
|
656
586
|
// Generate playground pages.
|
|
657
|
-
|
|
658
|
-
return
|
|
587
|
+
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
588
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context8) {
|
|
659
589
|
while (1) switch (_context8.prev = _context8.next) {
|
|
660
590
|
case 0:
|
|
661
591
|
_context8.next = 2;
|
|
662
|
-
return
|
|
663
|
-
var _ref6 =
|
|
592
|
+
return _Promise.all(_mapInstanceProperty(allExamples).call(allExamples, /*#__PURE__*/function () {
|
|
593
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(example) {
|
|
664
594
|
var _context6;
|
|
665
595
|
var getStartStopMs, results;
|
|
666
|
-
return
|
|
596
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context7) {
|
|
667
597
|
while (1) switch (_context7.prev = _context7.next) {
|
|
668
598
|
case 0:
|
|
669
599
|
getStartStopMs = measureStartStopMs();
|
|
670
600
|
_context7.next = 3;
|
|
671
|
-
return
|
|
601
|
+
return _Promise.allSettled(_mapInstanceProperty(_context6 = [{
|
|
672
602
|
html: generateJSFiddlePage(example),
|
|
673
603
|
path: example.paths.jsfiddle.local
|
|
674
604
|
}, {
|
|
@@ -684,7 +614,7 @@ var ContentBuilder = /*#__PURE__*/function () {
|
|
|
684
614
|
return _context7.abrupt("return", _objectSpread$1(_objectSpread$1({}, getStartStopMs()), {}, {
|
|
685
615
|
count: results.length,
|
|
686
616
|
example: example,
|
|
687
|
-
result:
|
|
617
|
+
result: _everyInstanceProperty(results).call(results, function (_ref8) {
|
|
688
618
|
var status = _ref8.status;
|
|
689
619
|
return status === "fulfilled";
|
|
690
620
|
}) ? "fulfilled" : "rejected"
|
|
@@ -708,27 +638,27 @@ var ContentBuilder = /*#__PURE__*/function () {
|
|
|
708
638
|
}, _callee4);
|
|
709
639
|
}))() :
|
|
710
640
|
// Skip playground pages.
|
|
711
|
-
|
|
641
|
+
_Promise.resolve([]);
|
|
712
642
|
var screenshots = emit.screenshots ?
|
|
713
643
|
// Generate screenshots.
|
|
714
|
-
|
|
644
|
+
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
715
645
|
var cleanup, _process$env$DEBUG, _context10, _context11, debug, browser, todo, total, reports, _context17, _iterator, _step, callback;
|
|
716
|
-
return
|
|
646
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context18) {
|
|
717
647
|
while (1) switch (_context18.prev = _context18.next) {
|
|
718
648
|
case 0:
|
|
719
649
|
cleanup = [];
|
|
720
650
|
_context18.prev = 1;
|
|
721
651
|
debug = /^1|y|yes|true$/i.test((_process$env$DEBUG = process.env.DEBUG) !== null && _process$env$DEBUG !== void 0 ? _process$env$DEBUG : "");
|
|
722
652
|
_context18.next = 5;
|
|
723
|
-
return
|
|
653
|
+
return puppeteer.launch({
|
|
724
654
|
headless: !debug,
|
|
725
655
|
slowMo: debug ? 100 : undefined
|
|
726
656
|
});
|
|
727
657
|
case 5:
|
|
728
658
|
browser = _context18.sent;
|
|
729
659
|
if (debug) {
|
|
730
|
-
cleanup.push( /*#__PURE__*/
|
|
731
|
-
return
|
|
660
|
+
cleanup.push( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
661
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context9) {
|
|
732
662
|
while (1) switch (_context9.prev = _context9.next) {
|
|
733
663
|
case 0:
|
|
734
664
|
return _context9.abrupt("return", browser.disconnect());
|
|
@@ -746,13 +676,13 @@ var ContentBuilder = /*#__PURE__*/function () {
|
|
|
746
676
|
// Generate screenshots.
|
|
747
677
|
// There is quite long delay to ensure the chart is rendered properly
|
|
748
678
|
// so it's much faster to run a lot of them at the same time.
|
|
749
|
-
todo =
|
|
679
|
+
todo = _sliceInstanceProperty(allExamples).call(allExamples);
|
|
750
680
|
total = todo.length;
|
|
751
681
|
reports = [];
|
|
752
682
|
_context18.next = 12;
|
|
753
|
-
return
|
|
683
|
+
return _Promise.allSettled(_mapInstanceProperty(_context10 = _fillInstanceProperty(_context11 = new Array(_this._config.parallel)).call(_context11, null)).call(_context10, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
754
684
|
var example, _context12, _context13, _context14, _context15, getStartStopMs, valid, report, percentage, validText, msText;
|
|
755
|
-
return
|
|
685
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context16) {
|
|
756
686
|
while (1) switch (_context16.prev = _context16.next) {
|
|
757
687
|
case 0:
|
|
758
688
|
if (!(example = todo.pop())) {
|
|
@@ -781,10 +711,10 @@ var ContentBuilder = /*#__PURE__*/function () {
|
|
|
781
711
|
} else {
|
|
782
712
|
fail.push(example.path);
|
|
783
713
|
}
|
|
784
|
-
percentage =
|
|
714
|
+
percentage = _padStartInstanceProperty(_context12 = Math.floor(reports.length / total * 100) + "%").call(_context12, 4, " ");
|
|
785
715
|
validText = valid ? "okay" : "fail";
|
|
786
716
|
msText = formatStartStopMs(report);
|
|
787
|
-
console.info(
|
|
717
|
+
console.info(_concatInstanceProperty(_context13 = _concatInstanceProperty(_context14 = _concatInstanceProperty(_context15 = "".concat(percentage, " ")).call(_context15, validText, " ")).call(_context14, msText, " - ")).call(_context13, example.path));
|
|
788
718
|
_context16.next = 0;
|
|
789
719
|
break;
|
|
790
720
|
case 14:
|
|
@@ -797,7 +727,7 @@ var ContentBuilder = /*#__PURE__*/function () {
|
|
|
797
727
|
return _context18.abrupt("return", reports);
|
|
798
728
|
case 13:
|
|
799
729
|
_context18.prev = 13;
|
|
800
|
-
_iterator = _createForOfIteratorHelper$2(
|
|
730
|
+
_iterator = _createForOfIteratorHelper$2(_reverseInstanceProperty(_context17 = _spliceInstanceProperty(cleanup).call(cleanup, 0)).call(_context17));
|
|
801
731
|
_context18.prev = 15;
|
|
802
732
|
_iterator.s();
|
|
803
733
|
case 17:
|
|
@@ -839,10 +769,10 @@ var ContentBuilder = /*#__PURE__*/function () {
|
|
|
839
769
|
}, _callee7, null, [[1,, 13, 38], [15, 31, 34, 37], [19, 24]]);
|
|
840
770
|
}))() :
|
|
841
771
|
// Skip screenshots.
|
|
842
|
-
|
|
843
|
-
var checks =
|
|
772
|
+
_Promise.resolve([]);
|
|
773
|
+
var checks = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
844
774
|
var total;
|
|
845
|
-
return
|
|
775
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context19) {
|
|
846
776
|
while (1) switch (_context19.prev = _context19.next) {
|
|
847
777
|
case 0:
|
|
848
778
|
_context19.next = 2;
|
|
@@ -882,7 +812,7 @@ var ContentBuilder = /*#__PURE__*/function () {
|
|
|
882
812
|
var _context20,
|
|
883
813
|
_context21,
|
|
884
814
|
_this2 = this;
|
|
885
|
-
return
|
|
815
|
+
return _flatMapInstanceProperty(_context20 = _sortInstanceProperty(_context21 = _Object$keys(examples)).call(_context21, collator.compare)).call(_context20, function (key) {
|
|
886
816
|
var example = examples[key];
|
|
887
817
|
if (isExample(example)) {
|
|
888
818
|
return [example];
|
|
@@ -899,20 +829,20 @@ var indexTemplate = "<html>\n <head>\n <meta charset=\"utf-8\" />\n <titl
|
|
|
899
829
|
|
|
900
830
|
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";
|
|
901
831
|
|
|
902
|
-
function _createForOfIteratorHelper$1(o, allowArrayLike) { var it = typeof
|
|
903
|
-
function _unsupportedIterableToArray$1(o, minLen) { var _context3; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n =
|
|
832
|
+
function _createForOfIteratorHelper$1(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (_Array$isArray(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; } } }; }
|
|
833
|
+
function _unsupportedIterableToArray$1(o, minLen) { var _context3; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = _sliceInstanceProperty(_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(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
|
|
904
834
|
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; }
|
|
905
835
|
/**
|
|
906
836
|
* @param example
|
|
907
837
|
*/
|
|
908
838
|
function generateJSFiddle(example) {
|
|
909
|
-
return
|
|
839
|
+
return $.load([])("<a>").addClass("icon jsfiddle").attr("href", example.paths.jsfiddle.web).attr("title", "JSFiddle");
|
|
910
840
|
}
|
|
911
841
|
/**
|
|
912
842
|
* @param example
|
|
913
843
|
*/
|
|
914
844
|
function generateCodePen(example) {
|
|
915
|
-
return
|
|
845
|
+
return $.load([])("<a>").addClass("icon codepen").attr("href", example.paths.codepen.web).attr("title", "CodePen");
|
|
916
846
|
}
|
|
917
847
|
/**
|
|
918
848
|
* @param examples
|
|
@@ -922,25 +852,25 @@ function generateCodePen(example) {
|
|
|
922
852
|
*/
|
|
923
853
|
function processGroup$1(examples, title, level, collator) {
|
|
924
854
|
var _context;
|
|
925
|
-
var heading =
|
|
855
|
+
var heading = $.load([])("<h".concat(Math.max(1, Math.min(6, level)), ">"));
|
|
926
856
|
heading.text(title);
|
|
927
|
-
var list =
|
|
928
|
-
var section =
|
|
857
|
+
var list = $.load([])("<div>");
|
|
858
|
+
var section = $.load([])("<div>");
|
|
929
859
|
section.append(heading, list);
|
|
930
|
-
var _iterator = _createForOfIteratorHelper$1(
|
|
860
|
+
var _iterator = _createForOfIteratorHelper$1(_sortInstanceProperty(_context = _Object$keys(examples)).call(_context, collator.compare)),
|
|
931
861
|
_step;
|
|
932
862
|
try {
|
|
933
863
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
934
864
|
var key = _step.value;
|
|
935
865
|
var example = examples[key];
|
|
936
866
|
if (isExample(example)) {
|
|
937
|
-
var header =
|
|
867
|
+
var header = $.load([])("<div>").addClass("example-header").append(
|
|
938
868
|
// Playgrounds
|
|
939
869
|
generateJSFiddle(example), generateCodePen(example),
|
|
940
870
|
// Title
|
|
941
|
-
|
|
942
|
-
var image =
|
|
943
|
-
var item =
|
|
871
|
+
$.load([])("<a>").attr("href", example.paths.page.web).text(key));
|
|
872
|
+
var image = $.load([])("<a>").addClass("example-image").attr("href", example.paths.page.web).append($.load([])("<img>").attr("src", example.paths.screenshot.web).attr("alt", key));
|
|
873
|
+
var item = $.load([])("<span>").addClass("example-link").append(header, image);
|
|
944
874
|
list.append(item);
|
|
945
875
|
} else {
|
|
946
876
|
section.append(processGroup$1(example, key, level + 1, collator));
|
|
@@ -957,9 +887,9 @@ var htmlRenderer = {
|
|
|
957
887
|
render: function render(examples, _output, title, collator) {
|
|
958
888
|
var _context2;
|
|
959
889
|
var filename = "index.html";
|
|
960
|
-
var root =
|
|
890
|
+
var root = $.load([])("<div>");
|
|
961
891
|
root.addClass("examples-root");
|
|
962
|
-
var _iterator2 = _createForOfIteratorHelper$1(
|
|
892
|
+
var _iterator2 = _createForOfIteratorHelper$1(_sortInstanceProperty(_context2 = _Object$keys(examples)).call(_context2, collator.compare)),
|
|
963
893
|
_step2;
|
|
964
894
|
try {
|
|
965
895
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
@@ -971,7 +901,7 @@ var htmlRenderer = {
|
|
|
971
901
|
} finally {
|
|
972
902
|
_iterator2.f();
|
|
973
903
|
}
|
|
974
|
-
var page =
|
|
904
|
+
var page = $.load(indexTemplate);
|
|
975
905
|
page("title").text(title);
|
|
976
906
|
page("body").append(root);
|
|
977
907
|
var content = formatHTML(page.html());
|
|
@@ -991,10 +921,10 @@ var htmlRenderer = {
|
|
|
991
921
|
}
|
|
992
922
|
};
|
|
993
923
|
|
|
994
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$
|
|
995
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context14, _context15; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ?
|
|
996
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof
|
|
997
|
-
function _unsupportedIterableToArray(o, minLen) { var _context13; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n =
|
|
924
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
925
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context14, _context15; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context14 = ownKeys(Object(source), !0)).call(_context14, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context15 = ownKeys(Object(source))).call(_context15, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
926
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (_Array$isArray(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; } } }; }
|
|
927
|
+
function _unsupportedIterableToArray(o, minLen) { var _context13; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_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(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
998
928
|
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; }
|
|
999
929
|
/**
|
|
1000
930
|
* @param lines
|
|
@@ -1009,7 +939,7 @@ function linesToContent(lines) {
|
|
|
1009
939
|
*/
|
|
1010
940
|
function image(title, src, href) {
|
|
1011
941
|
var _context, _context2;
|
|
1012
|
-
return href == null ?
|
|
942
|
+
return href == null ? _concatInstanceProperty(_context = ").call(_context, src, ")") : link(href, _concatInstanceProperty(_context2 = ").call(_context2, src, ")"));
|
|
1013
943
|
}
|
|
1014
944
|
/**
|
|
1015
945
|
* @param href
|
|
@@ -1018,7 +948,7 @@ function image(title, src, href) {
|
|
|
1018
948
|
function link(href) {
|
|
1019
949
|
var _context3;
|
|
1020
950
|
var text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : href;
|
|
1021
|
-
return
|
|
951
|
+
return _concatInstanceProperty(_context3 = "[".concat(text, "](")).call(_context3, href, ")");
|
|
1022
952
|
}
|
|
1023
953
|
/**
|
|
1024
954
|
* @param level
|
|
@@ -1026,7 +956,7 @@ function link(href) {
|
|
|
1026
956
|
*/
|
|
1027
957
|
function header(level, text) {
|
|
1028
958
|
var _context4, _context5;
|
|
1029
|
-
return
|
|
959
|
+
return _concatInstanceProperty(_context4 = "".concat(_repeatInstanceProperty(_context5 = "#").call(_context5, level), " ")).call(_context4, text);
|
|
1030
960
|
}
|
|
1031
961
|
/**
|
|
1032
962
|
* @param examples
|
|
@@ -1039,7 +969,7 @@ function processGroup(examples, output, title, collator) {
|
|
|
1039
969
|
var items = [];
|
|
1040
970
|
var sections = [];
|
|
1041
971
|
var filenamePart = title.replace(/[^a-zA-Z0-9]/g, "-").toLowerCase();
|
|
1042
|
-
var _iterator = _createForOfIteratorHelper(
|
|
972
|
+
var _iterator = _createForOfIteratorHelper(_sortInstanceProperty(_context8 = _Object$keys(examples)).call(_context8, collator.compare)),
|
|
1043
973
|
_step;
|
|
1044
974
|
try {
|
|
1045
975
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -1051,7 +981,7 @@ function processGroup(examples, output, title, collator) {
|
|
|
1051
981
|
} else {
|
|
1052
982
|
var _context9;
|
|
1053
983
|
// A subgroup of examples.
|
|
1054
|
-
sections.push.apply(sections,
|
|
984
|
+
sections.push.apply(sections, _toConsumableArray(_mapInstanceProperty(_context9 = processGroup(example, output, key, collator)).call(_context9, function (contentPart) {
|
|
1055
985
|
return _objectSpread(_objectSpread({}, contentPart), {}, {
|
|
1056
986
|
filename: filenamePart + "." + contentPart.filename
|
|
1057
987
|
});
|
|
@@ -1063,8 +993,8 @@ function processGroup(examples, output, title, collator) {
|
|
|
1063
993
|
} finally {
|
|
1064
994
|
_iterator.f();
|
|
1065
995
|
}
|
|
1066
|
-
return
|
|
1067
|
-
content: linesToContent(
|
|
996
|
+
return _concatInstanceProperty(_context6 = [{
|
|
997
|
+
content: linesToContent(_concatInstanceProperty(_context7 = [header(1, title), ""]).call(_context7, items)),
|
|
1068
998
|
filename: filenamePart + ".md",
|
|
1069
999
|
title: title
|
|
1070
1000
|
}]).call(_context6, sections);
|
|
@@ -1073,20 +1003,20 @@ var mdRenderer = {
|
|
|
1073
1003
|
render: function render(examples, output, _title, collator) {
|
|
1074
1004
|
var _context10, _context11, _context12;
|
|
1075
1005
|
var sections = [];
|
|
1076
|
-
var _iterator2 = _createForOfIteratorHelper(
|
|
1006
|
+
var _iterator2 = _createForOfIteratorHelper(_sortInstanceProperty(_context12 = _Object$keys(examples)).call(_context12, collator.compare)),
|
|
1077
1007
|
_step2;
|
|
1078
1008
|
try {
|
|
1079
1009
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1080
1010
|
var key = _step2.value;
|
|
1081
|
-
sections.push.apply(sections,
|
|
1011
|
+
sections.push.apply(sections, _toConsumableArray(processGroup(examples[key], output, key, collator)));
|
|
1082
1012
|
}
|
|
1083
1013
|
} catch (err) {
|
|
1084
1014
|
_iterator2.e(err);
|
|
1085
1015
|
} finally {
|
|
1086
1016
|
_iterator2.f();
|
|
1087
1017
|
}
|
|
1088
|
-
return
|
|
1089
|
-
content: linesToContent(
|
|
1018
|
+
return _concatInstanceProperty(_context10 = [{
|
|
1019
|
+
content: linesToContent(_concatInstanceProperty(_context11 = [header(1, "Examples"), ""]).call(_context11, _toConsumableArray(_mapInstanceProperty(sections).call(sections, function (_ref) {
|
|
1090
1020
|
var filename = _ref.filename,
|
|
1091
1021
|
title = _ref.title;
|
|
1092
1022
|
return "- " + link("./" + filename, title);
|
|
@@ -1101,7 +1031,7 @@ var mdRenderer = {
|
|
|
1101
1031
|
}
|
|
1102
1032
|
};
|
|
1103
1033
|
|
|
1104
|
-
var y =
|
|
1034
|
+
var y = yargs.strict(true).usage("generate-example-index [options]").hide("version").config().help().option("assets-local-directory", {
|
|
1105
1035
|
default: "./examples/thumbnails",
|
|
1106
1036
|
describe: "The directory where assets will be written to.",
|
|
1107
1037
|
type: "string"
|
|
@@ -1189,7 +1119,7 @@ function joinURLs() {
|
|
|
1189
1119
|
for (var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1190
1120
|
urls[_key] = arguments[_key];
|
|
1191
1121
|
}
|
|
1192
|
-
return
|
|
1122
|
+
return _mapInstanceProperty(urls).call(urls, function (url) {
|
|
1193
1123
|
return (
|
|
1194
1124
|
// Strip the parts of leading and trailing slashes if they have them.
|
|
1195
1125
|
url.replace(/^\/?(.*?)\/?$/, "$1")
|
|
@@ -1201,9 +1131,9 @@ function joinURLs() {
|
|
|
1201
1131
|
* @param url
|
|
1202
1132
|
*/
|
|
1203
1133
|
function fixAbsoluteInputURL(baseURL, url) {
|
|
1204
|
-
return
|
|
1134
|
+
return _startsWithInstanceProperty(url).call(url, "/") ?
|
|
1205
1135
|
// Relative to the base URL. Base URL starts and URL ends with a slash.
|
|
1206
|
-
baseURL +
|
|
1136
|
+
baseURL + _sliceInstanceProperty(url).call(url, 1) :
|
|
1207
1137
|
// Relative to some other point or absolute already.
|
|
1208
1138
|
url;
|
|
1209
1139
|
}
|
|
@@ -1235,25 +1165,25 @@ function generatePaths(config, exampleAbsolutePath) {
|
|
|
1235
1165
|
*/
|
|
1236
1166
|
function generateLocalWebPair(localRoot, webRoot, hash, prefix, extension) {
|
|
1237
1167
|
var _context, _context2;
|
|
1238
|
-
var filename =
|
|
1168
|
+
var filename = _concatInstanceProperty(_context = _concatInstanceProperty(_context2 = "".concat(prefix, ".")).call(_context2, hash, ".")).call(_context, extension);
|
|
1239
1169
|
return {
|
|
1240
1170
|
local: node_path.resolve(localRoot, filename),
|
|
1241
1171
|
web: joinURLs(webRoot, filename)
|
|
1242
1172
|
};
|
|
1243
1173
|
}
|
|
1244
1174
|
|
|
1245
|
-
var globby =
|
|
1175
|
+
var globby = import('globby');
|
|
1246
1176
|
var argv = parseArguments();
|
|
1247
1177
|
// Log the parsed configuration for debugging purposes.
|
|
1248
|
-
console.info("Configuration: ", _JSON$
|
|
1178
|
+
console.info("Configuration: ", _JSON$stringify(argv, null, 2));
|
|
1249
1179
|
process.stdout.write("\n");
|
|
1250
1180
|
// Pageres uses quite a lot of listeners when invoked multiple times in
|
|
1251
1181
|
// parallel. This ensures there are no warnings about it.
|
|
1252
1182
|
process.setMaxListeners(40);
|
|
1253
1183
|
// Resolve paths relative to PWD.
|
|
1254
1184
|
var screenshotScriptPath = typeof argv["screenshot-script"] === "string" ? node_path.resolve(argv["screenshot-script"]) : undefined;
|
|
1255
|
-
var mkdir =
|
|
1256
|
-
var readFile =
|
|
1185
|
+
var mkdir = util.promisify(fs.mkdir);
|
|
1186
|
+
var readFile = util.promisify(fs.readFile);
|
|
1257
1187
|
/**
|
|
1258
1188
|
* Extract and coerce a value from meta tag.
|
|
1259
1189
|
*
|
|
@@ -1268,7 +1198,7 @@ function getMeta(page, name, fallback) {
|
|
|
1268
1198
|
if (content == null) {
|
|
1269
1199
|
// No meta of this name exists in the page, use the fallback.
|
|
1270
1200
|
return fallback;
|
|
1271
|
-
} else if (!_Number$
|
|
1201
|
+
} else if (!_Number$isNaN(+content)) {
|
|
1272
1202
|
// Number.
|
|
1273
1203
|
return +content;
|
|
1274
1204
|
} else if (typeof content === "string") {
|
|
@@ -1298,9 +1228,9 @@ function lintExample(path, page) {
|
|
|
1298
1228
|
msgs.push("There have to be at least two headings (group and example name).");
|
|
1299
1229
|
valid = false;
|
|
1300
1230
|
}
|
|
1301
|
-
var headTitle =
|
|
1302
|
-
var bodyTitle =
|
|
1303
|
-
return
|
|
1231
|
+
var headTitle = _trimInstanceProperty(_context = page("head > title").text()).call(_context);
|
|
1232
|
+
var bodyTitle = _trimInstanceProperty(_context2 = _mapInstanceProperty(_context3 = page("#title > *")).call(_context3, function (_i, elem) {
|
|
1233
|
+
return $.load([])(elem).text();
|
|
1304
1234
|
}).get().join(" | ")).call(_context2);
|
|
1305
1235
|
if (headTitle !== bodyTitle) {
|
|
1306
1236
|
msgs.push("The title in the head doesn't match the title in the body.", " head: ".concat(headTitle), " body: ".concat(bodyTitle));
|
|
@@ -1311,10 +1241,10 @@ function lintExample(path, page) {
|
|
|
1311
1241
|
}
|
|
1312
1242
|
return valid;
|
|
1313
1243
|
}
|
|
1314
|
-
|
|
1244
|
+
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
1315
1245
|
var _context4, _context6;
|
|
1316
1246
|
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;
|
|
1317
|
-
return
|
|
1247
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context24) {
|
|
1318
1248
|
while (1) switch (_context24.prev = _context24.next) {
|
|
1319
1249
|
case 0:
|
|
1320
1250
|
code = 0;
|
|
@@ -1322,13 +1252,13 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
|
|
|
1322
1252
|
_context24.next = 4;
|
|
1323
1253
|
break;
|
|
1324
1254
|
}
|
|
1325
|
-
|
|
1255
|
+
yargs.parse("--help");
|
|
1326
1256
|
return _context24.abrupt("return");
|
|
1327
1257
|
case 4:
|
|
1328
1258
|
_context24.next = 6;
|
|
1329
|
-
return
|
|
1330
|
-
var _ref2 =
|
|
1331
|
-
return
|
|
1259
|
+
return _Promise.all(_mapInstanceProperty(_context4 = [argv["assets-local-directory"], argv["examples-local-directory"], argv["output-directory"], argv["pages-local-directory"]]).call(_context4, /*#__PURE__*/function () {
|
|
1260
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(path) {
|
|
1261
|
+
return _regeneratorRuntime.wrap(function _callee$(_context5) {
|
|
1332
1262
|
while (1) switch (_context5.prev = _context5.next) {
|
|
1333
1263
|
case 0:
|
|
1334
1264
|
_context5.next = 2;
|
|
@@ -1347,7 +1277,7 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
|
|
|
1347
1277
|
}()));
|
|
1348
1278
|
case 6:
|
|
1349
1279
|
baseURL = argv["base-url"];
|
|
1350
|
-
if (
|
|
1280
|
+
if (_endsWithInstanceProperty(baseURL).call(baseURL, "/")) {
|
|
1351
1281
|
_context24.next = 9;
|
|
1352
1282
|
break;
|
|
1353
1283
|
}
|
|
@@ -1378,8 +1308,8 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
|
|
|
1378
1308
|
examples: 0
|
|
1379
1309
|
};
|
|
1380
1310
|
skipped = [];
|
|
1381
|
-
_context24.t0 =
|
|
1382
|
-
_context24.t1 =
|
|
1311
|
+
_context24.t0 = _Promise;
|
|
1312
|
+
_context24.t1 = _mapInstanceProperty;
|
|
1383
1313
|
_context24.next = 18;
|
|
1384
1314
|
return globby;
|
|
1385
1315
|
case 18:
|
|
@@ -1388,17 +1318,17 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
|
|
|
1388
1318
|
case 20:
|
|
1389
1319
|
_context24.t2 = _context6 = _context24.sent;
|
|
1390
1320
|
_context24.t3 = (0, _context24.t1)(_context24.t2).call(_context6, /*#__PURE__*/function () {
|
|
1391
|
-
var _ref3 =
|
|
1321
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(pagePath) {
|
|
1392
1322
|
var _context7;
|
|
1393
1323
|
var html, $page, pageDelay, pageTimeout, pageSelector, titles, _context9;
|
|
1394
|
-
return
|
|
1324
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context10) {
|
|
1395
1325
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1396
1326
|
case 0:
|
|
1397
1327
|
_context10.next = 2;
|
|
1398
1328
|
return readFile(pagePath, "utf-8");
|
|
1399
1329
|
case 2:
|
|
1400
1330
|
html = _context10.sent;
|
|
1401
|
-
$page =
|
|
1331
|
+
$page = $.load(html);
|
|
1402
1332
|
pageDelay = getMeta($page, "example-screenshot-delay", 6);
|
|
1403
1333
|
pageTimeout = getMeta($page, "example-screenshot-timeout", 60);
|
|
1404
1334
|
pageSelector = getMeta($page, "example-screenshot-selector", selector); // Is this an examples?
|
|
@@ -1414,13 +1344,13 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
|
|
|
1414
1344
|
lintExample(pagePath, $page);
|
|
1415
1345
|
}
|
|
1416
1346
|
// Body titles.
|
|
1417
|
-
titles =
|
|
1347
|
+
titles = _mapInstanceProperty(_context7 = $page("#title > *").get()).call(_context7, function (elem) {
|
|
1418
1348
|
var _context8;
|
|
1419
|
-
return
|
|
1349
|
+
return _trimInstanceProperty(_context8 = $page(elem).text()).call(_context8);
|
|
1420
1350
|
}); // Head title fallback.
|
|
1421
1351
|
if (titles.length < 2) {
|
|
1422
|
-
titles =
|
|
1423
|
-
return
|
|
1352
|
+
titles = _mapInstanceProperty(_context9 = $page("head > title").text().split("|")).call(_context9, function (title) {
|
|
1353
|
+
return _trimInstanceProperty(title).call(title);
|
|
1424
1354
|
});
|
|
1425
1355
|
}
|
|
1426
1356
|
// File path fallback.
|
|
@@ -1436,7 +1366,7 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
|
|
|
1436
1366
|
return _context10.abrupt("return");
|
|
1437
1367
|
case 17:
|
|
1438
1368
|
// Put this example into the structure while creating any missing groups in the process.
|
|
1439
|
-
|
|
1369
|
+
_reduceInstanceProperty(titles).call(titles, function (acc, title, i, arr) {
|
|
1440
1370
|
while (acc[title] != null && acc[title].path != null) {
|
|
1441
1371
|
console.error("The following group already exists: ", titles);
|
|
1442
1372
|
title += "!";
|
|
@@ -1479,7 +1409,7 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
|
|
|
1479
1409
|
case 24:
|
|
1480
1410
|
if (skipped.length) {
|
|
1481
1411
|
process.stdout.write("\n");
|
|
1482
|
-
console.info(
|
|
1412
|
+
console.info(_concatInstanceProperty(_context11 = ["The following files don't look like examples (there is nothing to take a screenshot of):"]).call(_context11, _toConsumableArray(_sortInstanceProperty(skipped).call(skipped))).join("\n "));
|
|
1483
1413
|
}
|
|
1484
1414
|
if (!(stats.examples === 0)) {
|
|
1485
1415
|
_context24.next = 29;
|
|
@@ -1537,7 +1467,7 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
|
|
|
1537
1467
|
case 47:
|
|
1538
1468
|
_context24.t7 = _context24.sent;
|
|
1539
1469
|
cummulativeReport = (0, _context24.t6)(_context24.t7);
|
|
1540
|
-
console.info(
|
|
1470
|
+
console.info(_concatInstanceProperty(_context12 = _concatInstanceProperty(_context13 = "Index with ".concat(stats.examples, " examples written (")).call(_context13, cummulativeReport.count, " files in ")).call(_context12, formatStartStopMs(cummulativeReport), ")."));
|
|
1541
1471
|
case 50:
|
|
1542
1472
|
if (!argv.index) {
|
|
1543
1473
|
_context24.next = 57;
|
|
@@ -1549,7 +1479,7 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
|
|
|
1549
1479
|
case 54:
|
|
1550
1480
|
_context24.t9 = _context24.sent;
|
|
1551
1481
|
_cummulativeReport = (0, _context24.t8)(_context24.t9);
|
|
1552
|
-
console.info(
|
|
1482
|
+
console.info(_concatInstanceProperty(_context14 = _concatInstanceProperty(_context15 = "Playground opener files for ".concat(stats.examples, " examples written (")).call(_context15, _cummulativeReport.count, " files in ")).call(_context14, formatStartStopMs(_cummulativeReport), ")."));
|
|
1553
1483
|
case 57:
|
|
1554
1484
|
if (!argv.screenshots) {
|
|
1555
1485
|
_context24.next = 64;
|
|
@@ -1561,7 +1491,7 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
|
|
|
1561
1491
|
case 61:
|
|
1562
1492
|
_context24.t11 = _context24.sent;
|
|
1563
1493
|
_cummulativeReport2 = (0, _context24.t10)(_context24.t11);
|
|
1564
|
-
console.info(
|
|
1494
|
+
console.info(_concatInstanceProperty(_context16 = _concatInstanceProperty(_context17 = "Screenshot files for ".concat(stats.examples, " written (")).call(_context17, _cummulativeReport2.count, " files in ")).call(_context16, formatStartStopMs(_cummulativeReport2), ")."));
|
|
1565
1495
|
case 64:
|
|
1566
1496
|
_context24.next = 66;
|
|
1567
1497
|
return builtData.checks;
|
|
@@ -1569,15 +1499,15 @@ _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default
|
|
|
1569
1499
|
checks = _context24.sent;
|
|
1570
1500
|
process.stdout.write("\n");
|
|
1571
1501
|
if (checks.fail === 0) {
|
|
1572
|
-
console.info(
|
|
1502
|
+
console.info(_concatInstanceProperty(_context18 = "Verification: ".concat(checks.okay, " passed (")).call(_context18, Math.round(checks.percentage), " %) passed."));
|
|
1573
1503
|
} else {
|
|
1574
1504
|
if (checks.percentage >= argv.verify) {
|
|
1575
|
-
console.info(
|
|
1505
|
+
console.info(_concatInstanceProperty(_context19 = _concatInstanceProperty(_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.");
|
|
1576
1506
|
} else {
|
|
1577
|
-
console.error(
|
|
1507
|
+
console.error(_concatInstanceProperty(_context21 = _concatInstanceProperty(_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
1508
|
code = 3;
|
|
1579
1509
|
}
|
|
1580
|
-
|
|
1510
|
+
_forEachInstanceProperty(_context23 = checks.failPaths).call(_context23, function (path) {
|
|
1581
1511
|
console.error(path);
|
|
1582
1512
|
});
|
|
1583
1513
|
}
|