vis-dev-utils 6.0.15 → 7.0.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-preset/index.cjs +3 -3
- package/babel-preset/index.cjs.map +1 -1
- package/babel-preset/index.mjs +3 -3
- package/babel-preset/index.mjs.map +1 -1
- package/bin/ci-utils.js +3 -3
- package/bin/ci-utils.js.map +1 -1
- package/bin/generate-examples-index.js +121 -118
- package/bin/generate-examples-index.js.map +1 -1
- package/bin/test-e2e-interop.js +6 -6
- package/bin/test-e2e-interop.js.map +1 -1
- package/declarations/generate-examples-index/content-builder/builder.d.ts +2 -3
- package/declarations/generate-examples-index/content-builder/builder.d.ts.map +1 -1
- package/declarations/generate-examples-index/content-builder/format.d.ts.map +1 -1
- package/declarations/generate-examples-index/content-builder/html/index.d.ts.map +1 -1
- package/declarations/generate-examples-index/content-builder/md/index.d.ts.map +1 -1
- package/declarations/generate-examples-index/content-builder/playground/codepen.d.ts.map +1 -1
- package/declarations/generate-examples-index/content-builder/playground/data.d.ts.map +1 -1
- package/declarations/generate-examples-index/content-builder/playground/jsfiddle.d.ts.map +1 -1
- package/declarations/generate-examples-index/content-builder/screenshots/index.d.ts.map +1 -1
- package/declarations/generate-examples-index/paths.d.ts.map +1 -1
- package/declarations/module/generate-rollup-configuration/index.d.ts +3 -3
- package/declarations/module/generate-rollup-configuration/index.d.ts.map +1 -1
- package/declarations/module/inspect-npm-pack.d.ts.map +1 -1
- package/declarations/module/util.d.ts +1 -1
- package/declarations/module/util.d.ts.map +1 -1
- package/declarations/test-e2e-interop/test.d.ts.map +1 -1
- package/dist/vis-dev-utils.cjs +13 -10
- package/dist/vis-dev-utils.cjs.map +1 -1
- package/dist/vis-dev-utils.mjs +13 -10
- package/dist/vis-dev-utils.mjs.map +1 -1
- package/package.json +13 -26
- package/eslint-shareable-config/index.cjs +0 -254
package/babel-preset/index.cjs
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Development utilities for the Vis family projects.
|
|
8
8
|
*
|
|
9
|
-
* @version
|
|
10
|
-
* @date 2026-07-
|
|
9
|
+
* @version 7.0.0
|
|
10
|
+
* @date 2026-07-23T18:44:40.020Z
|
|
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
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
|
|
29
29
|
'use strict';
|
|
30
30
|
|
|
31
|
-
var babelPresetEnv = require('@babel/preset-env');
|
|
32
31
|
var babelTransformRuntime = require('@babel/plugin-transform-runtime');
|
|
32
|
+
var babelPresetEnv = require('@babel/preset-env');
|
|
33
33
|
var babelPresetTypescript = require('@babel/preset-typescript');
|
|
34
34
|
|
|
35
35
|
function index(_context, { ts = false } = {}) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/babel-preset/index.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/babel-preset/index.ts"],"sourcesContent":["import babelTransformRuntime from \"@babel/plugin-transform-runtime\";\nimport babelPresetEnv from \"@babel/preset-env\";\nimport babelPresetTypescript from \"@babel/preset-typescript\";\n\n/**\n * Provides shared configuration for Vis family of packages for Babel.\n * @param _context - The context provided by Babel, unused here.\n * @param [options] - The options object.\n * @param [options.ts] - Indicates if TypeScript is being used.\n * @returns Babel config.\n */\nexport default function (_context: unknown, { ts = false } = {}) {\n return {\n presets: [\n [\n babelPresetEnv,\n {\n targets: {\n // A browser is polyfilled if it is supported by it's maintainers\n // and if it is used by at least one in every thousand of users.\n browsers: \"> 0.1% and not dead\",\n // This forces Babel to polyfill ESM as if it was UMD. The reason\n // behind this is that that Babel doesn't include IE 11 polyfills\n // in ESM builds since IE 11 can't even load them. However many of\n // our users use bundlers to bundle ESM builds into IE 11\n // compatible UMD builds. Therefore even ESM builds need IE 11\n // polyfills.\n esmodules: false,\n },\n // This would pollute global scope. Babel's Transform Runtime plugin\n // is used instead.\n useBuiltIns: false,\n },\n ],\n ...(ts ? [babelPresetTypescript] : []),\n ],\n plugins: [\n [\n babelTransformRuntime,\n {\n // Force corejs 3. The default corejs 2 is deprecated and doesn't\n // contain some polyfills.\n corejs: 3,\n },\n ],\n ],\n env: {\n test: {\n presets: [\n [\n babelPresetEnv,\n {\n // Tests run in Node so there's no need to include any other\n // polyfills (we're testing our code, not the polyfills).\n targets: \"maintained node versions\",\n },\n ],\n ],\n },\n \"test-cov\": {\n presets: [\n [\n babelPresetEnv,\n {\n // dtto\n targets: \"maintained node versions\",\n },\n ],\n ],\n // This instruments the code to record coverage. It's more reliable if\n // done through Babel plugin.\n plugins: [\"istanbul\"],\n },\n },\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,cAAA,CAAyB,UAAmB,EAAE,EAAA,GAAK,KAAA,EAAM,GAAI,EAAC,EAAG;AAC/D,EAAA,OAAO;AAAA,IACL,OAAA,EAAS;AAAA,MACP;AAAA,QACE,cAAA;AAAA,QACA;AAAA,UACE,OAAA,EAAS;AAAA;AAAA;AAAA,YAGP,QAAA,EAAU,qBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAOV,SAAA,EAAW;AAAA,WACb;AAAA;AAAA;AAAA,UAGA,WAAA,EAAa;AAAA;AACf,OACF;AAAA,MACA,GAAI,EAAA,GAAK,CAAC,qBAAqB,IAAI;AAAC,KACtC;AAAA,IACA,OAAA,EAAS;AAAA,MACP;AAAA,QACE,qBAAA;AAAA,QACA;AAAA;AAAA;AAAA,UAGE,MAAA,EAAQ;AAAA;AACV;AACF,KACF;AAAA,IACA,GAAA,EAAK;AAAA,MACH,IAAA,EAAM;AAAA,QACJ,OAAA,EAAS;AAAA,UACP;AAAA,YACE,cAAA;AAAA,YACA;AAAA;AAAA;AAAA,cAGE,OAAA,EAAS;AAAA;AACX;AACF;AACF,OACF;AAAA,MACA,UAAA,EAAY;AAAA,QACV,OAAA,EAAS;AAAA,UACP;AAAA,YACE,cAAA;AAAA,YACA;AAAA;AAAA,cAEE,OAAA,EAAS;AAAA;AACX;AACF,SACF;AAAA;AAAA;AAAA,QAGA,OAAA,EAAS,CAAC,UAAU;AAAA;AACtB;AACF,GACF;AACF;;;;"}
|
package/babel-preset/index.mjs
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Development utilities for the Vis family projects.
|
|
8
8
|
*
|
|
9
|
-
* @version
|
|
10
|
-
* @date 2026-07-
|
|
9
|
+
* @version 7.0.0
|
|
10
|
+
* @date 2026-07-23T18:44:40.020Z
|
|
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
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
* vis.js may be distributed under either license.
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
-
import babelPresetEnv from '@babel/preset-env';
|
|
30
29
|
import babelTransformRuntime from '@babel/plugin-transform-runtime';
|
|
30
|
+
import babelPresetEnv from '@babel/preset-env';
|
|
31
31
|
import babelPresetTypescript from '@babel/preset-typescript';
|
|
32
32
|
|
|
33
33
|
function index(_context, { ts = false } = {}) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/babel-preset/index.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/babel-preset/index.ts"],"sourcesContent":["import babelTransformRuntime from \"@babel/plugin-transform-runtime\";\nimport babelPresetEnv from \"@babel/preset-env\";\nimport babelPresetTypescript from \"@babel/preset-typescript\";\n\n/**\n * Provides shared configuration for Vis family of packages for Babel.\n * @param _context - The context provided by Babel, unused here.\n * @param [options] - The options object.\n * @param [options.ts] - Indicates if TypeScript is being used.\n * @returns Babel config.\n */\nexport default function (_context: unknown, { ts = false } = {}) {\n return {\n presets: [\n [\n babelPresetEnv,\n {\n targets: {\n // A browser is polyfilled if it is supported by it's maintainers\n // and if it is used by at least one in every thousand of users.\n browsers: \"> 0.1% and not dead\",\n // This forces Babel to polyfill ESM as if it was UMD. The reason\n // behind this is that that Babel doesn't include IE 11 polyfills\n // in ESM builds since IE 11 can't even load them. However many of\n // our users use bundlers to bundle ESM builds into IE 11\n // compatible UMD builds. Therefore even ESM builds need IE 11\n // polyfills.\n esmodules: false,\n },\n // This would pollute global scope. Babel's Transform Runtime plugin\n // is used instead.\n useBuiltIns: false,\n },\n ],\n ...(ts ? [babelPresetTypescript] : []),\n ],\n plugins: [\n [\n babelTransformRuntime,\n {\n // Force corejs 3. The default corejs 2 is deprecated and doesn't\n // contain some polyfills.\n corejs: 3,\n },\n ],\n ],\n env: {\n test: {\n presets: [\n [\n babelPresetEnv,\n {\n // Tests run in Node so there's no need to include any other\n // polyfills (we're testing our code, not the polyfills).\n targets: \"maintained node versions\",\n },\n ],\n ],\n },\n \"test-cov\": {\n presets: [\n [\n babelPresetEnv,\n {\n // dtto\n targets: \"maintained node versions\",\n },\n ],\n ],\n // This instruments the code to record coverage. It's more reliable if\n // done through Babel plugin.\n plugins: [\"istanbul\"],\n },\n },\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,cAAA,CAAyB,UAAmB,EAAE,EAAA,GAAK,KAAA,EAAM,GAAI,EAAC,EAAG;AAC/D,EAAA,OAAO;AAAA,IACL,OAAA,EAAS;AAAA,MACP;AAAA,QACE,cAAA;AAAA,QACA;AAAA,UACE,OAAA,EAAS;AAAA;AAAA;AAAA,YAGP,QAAA,EAAU,qBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAOV,SAAA,EAAW;AAAA,WACb;AAAA;AAAA;AAAA,UAGA,WAAA,EAAa;AAAA;AACf,OACF;AAAA,MACA,GAAI,EAAA,GAAK,CAAC,qBAAqB,IAAI;AAAC,KACtC;AAAA,IACA,OAAA,EAAS;AAAA,MACP;AAAA,QACE,qBAAA;AAAA,QACA;AAAA;AAAA;AAAA,UAGE,MAAA,EAAQ;AAAA;AACV;AACF,KACF;AAAA,IACA,GAAA,EAAK;AAAA,MACH,IAAA,EAAM;AAAA,QACJ,OAAA,EAAS;AAAA,UACP;AAAA,YACE,cAAA;AAAA,YACA;AAAA;AAAA;AAAA,cAGE,OAAA,EAAS;AAAA;AACX;AACF;AACF,OACF;AAAA,MACA,UAAA,EAAY;AAAA,QACV,OAAA,EAAS;AAAA,UACP;AAAA,YACE,cAAA;AAAA,YACA;AAAA;AAAA,cAEE,OAAA,EAAS;AAAA;AACX;AACF,SACF;AAAA;AAAA;AAAA,QAGA,OAAA,EAAS,CAAC,UAAU;AAAA;AACtB;AACF,GACF;AACF;;;;"}
|
package/bin/ci-utils.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Development utilities for the Vis family projects.
|
|
8
8
|
*
|
|
9
|
-
* @version
|
|
10
|
-
* @date 2026-07-
|
|
9
|
+
* @version 7.0.0
|
|
10
|
+
* @date 2026-07-23T18:44:40.020Z
|
|
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
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
* vis.js may be distributed under either license.
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
-
import yargs from 'yargs';
|
|
30
29
|
import { spawnSync } from 'node:child_process';
|
|
30
|
+
import yargs from 'yargs';
|
|
31
31
|
|
|
32
32
|
yargs.strict(true).usage("test-e2e-interop <command> [options]").hide("version").config().help().command(
|
|
33
33
|
"install-dependencies-for [tools..]",
|
package/bin/ci-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ci-utils.js","sources":["../src/ci-utils/index.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"ci-utils.js","sources":["../src/ci-utils/index.ts"],"sourcesContent":["import { spawnSync } from \"node:child_process\";\n\nimport yargs from \"yargs\";\n\nyargs\n .strict(true)\n .usage(\"test-e2e-interop <command> [options]\")\n .hide(\"version\")\n .config()\n .help()\n\n .command(\n \"install-dependencies-for [tools..]\",\n \"Install the dependencies for given tool(s). Note that this is specific to CircleCI's Debian based Docker images.\",\n (yargs) =>\n yargs.positional(\"tools\", {\n choices: [\"chromium\", \"cypress\"],\n demandOption: true,\n describe: \"The tool whose dependecies will be installed.\",\n type: \"string\",\n }),\n (argv): void => {\n const dependecies = new Set<string>();\n\n if (argv.tools.includes(\"chromium\")) {\n dependecies.add(\"libasound2\");\n dependecies.add(\"libgbm1\");\n dependecies.add(\"libgtk-3-0\");\n dependecies.add(\"libnss3\");\n dependecies.add(\"libxss1\");\n dependecies.add(\"libxtst6\");\n }\n\n if (argv.tools.includes(\"cypress\")) {\n dependecies.add(\"libasound2\");\n dependecies.add(\"libgconf-2-4\");\n dependecies.add(\"libgtk-3-0\");\n dependecies.add(\"libgtk2.0-0\");\n dependecies.add(\"libnotify-dev\");\n dependecies.add(\"libnss3\");\n dependecies.add(\"libxss1\");\n dependecies.add(\"libxtst6\");\n dependecies.add(\"xauth\");\n dependecies.add(\"xvfb\");\n }\n\n spawnSync(\"sudo\", [\"apt-get\", \"install\", \"-yq\", ...dependecies], {\n stdio: \"inherit\",\n });\n },\n )\n\n .parserConfiguration({ \"camel-case-expansion\": false })\n .parse();\n"],"names":["yargs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,KAAA,CACG,MAAA,CAAO,IAAI,CAAA,CACX,KAAA,CAAM,sCAAsC,CAAA,CAC5C,IAAA,CAAK,SAAS,CAAA,CACd,MAAA,EAAO,CACP,IAAA,EAAK,CAEL,OAAA;AAAA,EACC,oCAAA;AAAA,EACA,kHAAA;AAAA,EACA,CAACA,MAAAA,KACCA,MAAAA,CAAM,UAAA,CAAW,OAAA,EAAS;AAAA,IACxB,OAAA,EAAS,CAAC,UAAA,EAAY,SAAS,CAAA;AAAA,IAC/B,YAAA,EAAc,IAAA;AAAA,IACd,QAAA,EAAU,+CAAA;AAAA,IACV,IAAA,EAAM;AAAA,GACP,CAAA;AAAA,EACH,CAAC,IAAA,KAAe;AACd,IAAA,MAAM,WAAA,uBAAkB,GAAA,EAAY;AAEpC,IAAA,IAAI,IAAA,CAAK,KAAA,CAAM,QAAA,CAAS,UAAU,CAAA,EAAG;AACnC,MAAA,WAAA,CAAY,IAAI,YAAY,CAAA;AAC5B,MAAA,WAAA,CAAY,IAAI,SAAS,CAAA;AACzB,MAAA,WAAA,CAAY,IAAI,YAAY,CAAA;AAC5B,MAAA,WAAA,CAAY,IAAI,SAAS,CAAA;AACzB,MAAA,WAAA,CAAY,IAAI,SAAS,CAAA;AACzB,MAAA,WAAA,CAAY,IAAI,UAAU,CAAA;AAAA,IAC5B;AAEA,IAAA,IAAI,IAAA,CAAK,KAAA,CAAM,QAAA,CAAS,SAAS,CAAA,EAAG;AAClC,MAAA,WAAA,CAAY,IAAI,YAAY,CAAA;AAC5B,MAAA,WAAA,CAAY,IAAI,cAAc,CAAA;AAC9B,MAAA,WAAA,CAAY,IAAI,YAAY,CAAA;AAC5B,MAAA,WAAA,CAAY,IAAI,aAAa,CAAA;AAC7B,MAAA,WAAA,CAAY,IAAI,eAAe,CAAA;AAC/B,MAAA,WAAA,CAAY,IAAI,SAAS,CAAA;AACzB,MAAA,WAAA,CAAY,IAAI,SAAS,CAAA;AACzB,MAAA,WAAA,CAAY,IAAI,UAAU,CAAA;AAC1B,MAAA,WAAA,CAAY,IAAI,OAAO,CAAA;AACvB,MAAA,WAAA,CAAY,IAAI,MAAM,CAAA;AAAA,IACxB;AAEA,IAAA,SAAA,CAAU,QAAQ,CAAC,SAAA,EAAW,WAAW,KAAA,EAAO,GAAG,WAAW,CAAA,EAAG;AAAA,MAC/D,KAAA,EAAO;AAAA,KACR,CAAA;AAAA,EACH;AACF,CAAA,CAEC,oBAAoB,EAAE,sBAAA,EAAwB,KAAA,EAAO,EACrD,KAAA,EAAM"}
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Development utilities for the Vis family projects.
|
|
8
8
|
*
|
|
9
|
-
* @version
|
|
10
|
-
* @date 2026-07-
|
|
9
|
+
* @version 7.0.0
|
|
10
|
+
* @date 2026-07-23T18:44:40.020Z
|
|
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
|
|
@@ -26,17 +26,93 @@
|
|
|
26
26
|
* vis.js may be distributed under either license.
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
-
import * as cheerio from 'cheerio';
|
|
30
29
|
import fs from 'node:fs';
|
|
30
|
+
import { relative, resolve, dirname, basename, sep, posix, join } from 'node:path';
|
|
31
31
|
import util, { promisify } from 'node:util';
|
|
32
|
+
import * as cheerio from 'cheerio';
|
|
32
33
|
import yargs from 'yargs';
|
|
33
|
-
import { relative, resolve, dirname, basename, sep, posix, join } from 'node:path';
|
|
34
|
-
import puppeteer from 'puppeteer';
|
|
35
|
-
import prettier from 'prettier';
|
|
36
|
-
import { Jimp } from 'jimp';
|
|
37
34
|
import { hideBin } from 'yargs/helpers';
|
|
35
|
+
import { launch } from 'puppeteer';
|
|
36
|
+
import { format } from 'oxfmt';
|
|
37
|
+
import { Jimp } from 'jimp';
|
|
38
38
|
import { createHash } from 'node:crypto';
|
|
39
39
|
|
|
40
|
+
const y = yargs(hideBin(process.argv)).strict(true).usage("generate-example-index [options]").hide("version").config().help().option("assets-local-directory", {
|
|
41
|
+
default: "./examples/thumbnails",
|
|
42
|
+
describe: "The directory where assets will be written to.",
|
|
43
|
+
type: "string"
|
|
44
|
+
}).option("assets-web-directory", {
|
|
45
|
+
default: "./thumbnails",
|
|
46
|
+
describe: "The directory where assets will be loaded from on the web.",
|
|
47
|
+
type: "string"
|
|
48
|
+
}).option("base-url", {
|
|
49
|
+
demand: true,
|
|
50
|
+
describe: "The base URL for relative imports. Web URLs starting with slash will be relative to this URL.",
|
|
51
|
+
type: "string"
|
|
52
|
+
}).option("examples-local-directory", {
|
|
53
|
+
default: "./examples/thumbnails",
|
|
54
|
+
describe: "The directory where examples will be loaded from locally.",
|
|
55
|
+
type: "string"
|
|
56
|
+
}).option("examples-web-directory", {
|
|
57
|
+
default: "./thumbnails",
|
|
58
|
+
describe: "The directory where examples will be loaded from on the web.",
|
|
59
|
+
type: "string"
|
|
60
|
+
}).option("output-directory", {
|
|
61
|
+
default: "./examples",
|
|
62
|
+
describe: "The directory where generated files will be emitted.",
|
|
63
|
+
type: "string"
|
|
64
|
+
}).option("pages-local-directory", {
|
|
65
|
+
default: "./examples/pages",
|
|
66
|
+
describe: "The directory where pages will be written to.",
|
|
67
|
+
type: "string"
|
|
68
|
+
}).option("pages-web-directory", {
|
|
69
|
+
default: "./pages",
|
|
70
|
+
describe: "The directory where pages will be loaded from on the web.",
|
|
71
|
+
type: "string"
|
|
72
|
+
}).option("index", {
|
|
73
|
+
default: false,
|
|
74
|
+
describe: "Generate index files.",
|
|
75
|
+
type: "boolean"
|
|
76
|
+
}).option("lint", {
|
|
77
|
+
default: false,
|
|
78
|
+
describe: "Lint examples.",
|
|
79
|
+
type: "boolean"
|
|
80
|
+
}).option("playgrounds", {
|
|
81
|
+
default: false,
|
|
82
|
+
describe: "Generate playground pages.",
|
|
83
|
+
type: "boolean"
|
|
84
|
+
}).option("screenshots", {
|
|
85
|
+
default: false,
|
|
86
|
+
describe: "Render screenshot thumbnails.",
|
|
87
|
+
type: "boolean"
|
|
88
|
+
}).option("container-id", {
|
|
89
|
+
default: "vis-container",
|
|
90
|
+
describe: "The id of the elements where Vis will put canvas.",
|
|
91
|
+
type: "string"
|
|
92
|
+
}).option("format", {
|
|
93
|
+
default: "html",
|
|
94
|
+
describe: "Whether HTML or Markdown should be generated.",
|
|
95
|
+
type: "string"
|
|
96
|
+
}).option("parallel", {
|
|
97
|
+
default: 6,
|
|
98
|
+
describe: "Generate n screenshots at the same time (there is quite high delay to make sure the graph is rendered before the screenshot is taken so the CPU utilization is generally quite low).",
|
|
99
|
+
type: "number"
|
|
100
|
+
}).option("screenshot-script", {
|
|
101
|
+
describe: "The path of JavaScript file that will be executed before taking a screenshot (and before any other JavaScript in the page).",
|
|
102
|
+
type: "string"
|
|
103
|
+
}).option("title", {
|
|
104
|
+
default: "Examples",
|
|
105
|
+
describe: "The title of the examples index.",
|
|
106
|
+
type: "string"
|
|
107
|
+
}).option("verify", {
|
|
108
|
+
default: 100,
|
|
109
|
+
describe: "Attempt to verify that the examples were generated correctly. The value is a percentage of checks that have to pass for the run to be considered success.",
|
|
110
|
+
type: "number"
|
|
111
|
+
});
|
|
112
|
+
function parseArguments() {
|
|
113
|
+
return y.parserConfiguration({ "camel-case-expansion": false }).parseSync();
|
|
114
|
+
}
|
|
115
|
+
|
|
40
116
|
function isExample(value) {
|
|
41
117
|
return typeof value === "object" && value !== null && typeof value.path === "string";
|
|
42
118
|
}
|
|
@@ -68,10 +144,10 @@ function formatStartStopMs({ start, stop }) {
|
|
|
68
144
|
return `${(Math.round((stop - start) / 100) / 10).toFixed(1)}s`;
|
|
69
145
|
}
|
|
70
146
|
|
|
71
|
-
const formatCSS = (css) =>
|
|
72
|
-
const formatHTML = (html) =>
|
|
73
|
-
const formatJS = (js) =>
|
|
74
|
-
const formatMD = (md) =>
|
|
147
|
+
const formatCSS = async (css) => (await format("style.css", css ?? "")).code;
|
|
148
|
+
const formatHTML = async (html) => (await format("index.html", html ?? "")).code;
|
|
149
|
+
const formatJS = async (js) => (await format("script.js", js ?? "")).code;
|
|
150
|
+
const formatMD = async (md) => (await format("README.md", md ?? "")).code;
|
|
75
151
|
|
|
76
152
|
var codepen_template_default = '<html>\n <head>\n <meta charset="utf-8" />\n <title>CodePen</title>\n </head>\n <body>\n <form\n id="form"\n action="https://codepen.io/pen/define"\n method="post"\n target="_self"\n >\n <input type="hidden" name="data" />\n <button id="open" alt="JSFiddle" title="JSFiddle">Open CodePen</button>\n </form>\n\n <script type="text/javascript">\n document.getElementById("open").click();\n <\/script>\n </body>\n</html>\n';
|
|
77
153
|
|
|
@@ -100,7 +176,7 @@ async function generatePlaygroundData(baseURL, example$, examplePath) {
|
|
|
100
176
|
if (firstBodyChild == null) {
|
|
101
177
|
throw new Error("Example body has no children.");
|
|
102
178
|
}
|
|
103
|
-
const eventListeners = Object.entries(firstBodyChild.attribs).filter(([name]) =>
|
|
179
|
+
const eventListeners = Object.entries(firstBodyChild.attribs).filter(([name]) => name.startsWith("on")).map(([name, value]) => [name.slice(2), `${value}`]).map(
|
|
104
180
|
([name, value]) => `window.addEventListener("${name}", () => { ${value} });`
|
|
105
181
|
).join("\n");
|
|
106
182
|
const js = formatJS(
|
|
@@ -115,7 +191,7 @@ async function generatePlaygroundData(baseURL, example$, examplePath) {
|
|
|
115
191
|
const fixPath = (rawPath) => /^https?:\/\//.test(rawPath) ? (
|
|
116
192
|
// World wide web absolute.
|
|
117
193
|
rawPath
|
|
118
|
-
) :
|
|
194
|
+
) : rawPath.startsWith("/") ? (
|
|
119
195
|
// Domain absolute.
|
|
120
196
|
baseURL + rawPath.slice(1)
|
|
121
197
|
) : (
|
|
@@ -255,7 +331,7 @@ async function generateScreenshot(browser, config) {
|
|
|
255
331
|
console.error(error);
|
|
256
332
|
return false;
|
|
257
333
|
} finally {
|
|
258
|
-
for (const callback of cleanup.splice(0).
|
|
334
|
+
for (const callback of cleanup.splice(0).toReversed()) {
|
|
259
335
|
try {
|
|
260
336
|
await callback();
|
|
261
337
|
} catch (error) {
|
|
@@ -268,8 +344,9 @@ async function generateScreenshot(browser, config) {
|
|
|
268
344
|
const collator = new Intl.Collator("US");
|
|
269
345
|
const writeFile = promisify(fs.writeFile);
|
|
270
346
|
class ContentBuilder {
|
|
271
|
-
|
|
272
|
-
|
|
347
|
+
#config;
|
|
348
|
+
constructor(config) {
|
|
349
|
+
this.#config = config;
|
|
273
350
|
}
|
|
274
351
|
/**
|
|
275
352
|
* Build the files and write them to the disk.
|
|
@@ -280,7 +357,7 @@ class ContentBuilder {
|
|
|
280
357
|
* @returns A report with check results and the number of written files.
|
|
281
358
|
*/
|
|
282
359
|
build(emit = {}) {
|
|
283
|
-
const allExamples = this
|
|
360
|
+
const allExamples = this.#processGroup(this.#config.examples);
|
|
284
361
|
const okay = [];
|
|
285
362
|
const fail = [];
|
|
286
363
|
console.info(
|
|
@@ -295,15 +372,15 @@ class ContentBuilder {
|
|
|
295
372
|
// Generate indexes.
|
|
296
373
|
(async () => {
|
|
297
374
|
const getStartStopMs = measureStartStopMs();
|
|
298
|
-
const contentParts = await this.
|
|
299
|
-
this.
|
|
300
|
-
this.
|
|
301
|
-
this.
|
|
375
|
+
const contentParts = await this.#config.renderer.render(
|
|
376
|
+
this.#config.examples,
|
|
377
|
+
this.#config.output,
|
|
378
|
+
this.#config.title,
|
|
302
379
|
collator
|
|
303
380
|
);
|
|
304
381
|
const results = await Promise.allSettled(
|
|
305
382
|
contentParts.map(
|
|
306
|
-
async ({ content, filename }) => writeFile(join(this.
|
|
383
|
+
async ({ content, filename }) => writeFile(join(this.#config.output, filename), content)
|
|
307
384
|
)
|
|
308
385
|
);
|
|
309
386
|
return [
|
|
@@ -359,7 +436,7 @@ class ContentBuilder {
|
|
|
359
436
|
const cleanup = [];
|
|
360
437
|
try {
|
|
361
438
|
const debug = /^1|y|yes|true$/i.test(process.env.DEBUG ?? "");
|
|
362
|
-
const browser = await
|
|
439
|
+
const browser = await launch({
|
|
363
440
|
args: [
|
|
364
441
|
// This allows us to use ESM imports from file paths.
|
|
365
442
|
// Since we only load local files and this script already runs on the local machine and can access arbitrary files, there is no meaningful security risk in disabling CORS.
|
|
@@ -377,16 +454,16 @@ class ContentBuilder {
|
|
|
377
454
|
const total = todo.length;
|
|
378
455
|
const reports = [];
|
|
379
456
|
await Promise.allSettled(
|
|
380
|
-
|
|
457
|
+
Array.from({ length: this.#config.parallel }).fill(null).map(async () => {
|
|
381
458
|
let example;
|
|
382
459
|
while (example = todo.pop()) {
|
|
383
460
|
const getStartStopMs = measureStartStopMs();
|
|
384
461
|
const valid = await generateScreenshot(browser, {
|
|
385
462
|
debug,
|
|
386
463
|
example,
|
|
387
|
-
height: this.
|
|
388
|
-
screenshotScript: this.
|
|
389
|
-
width: this.
|
|
464
|
+
height: this.#config.renderer.screenshot.height,
|
|
465
|
+
screenshotScript: this.#config.screenshotScript,
|
|
466
|
+
width: this.#config.renderer.screenshot.width
|
|
390
467
|
});
|
|
391
468
|
const report = {
|
|
392
469
|
...getStartStopMs(),
|
|
@@ -411,7 +488,7 @@ class ContentBuilder {
|
|
|
411
488
|
);
|
|
412
489
|
return reports;
|
|
413
490
|
} finally {
|
|
414
|
-
for (const callback of cleanup.splice(0).
|
|
491
|
+
for (const callback of cleanup.splice(0).toReversed()) {
|
|
415
492
|
try {
|
|
416
493
|
await callback();
|
|
417
494
|
} catch (error) {
|
|
@@ -440,21 +517,19 @@ class ContentBuilder {
|
|
|
440
517
|
})();
|
|
441
518
|
return { checks, index, playgrounds, screenshots };
|
|
442
519
|
}
|
|
443
|
-
|
|
444
|
-
return Object.keys(examples).
|
|
520
|
+
#processGroup(examples) {
|
|
521
|
+
return Object.keys(examples).toSorted(collator.compare).flatMap((key) => {
|
|
445
522
|
const example = examples[key];
|
|
446
523
|
if (isExample(example)) {
|
|
447
524
|
return [example];
|
|
448
525
|
} else {
|
|
449
|
-
return this
|
|
526
|
+
return this.#processGroup(example);
|
|
450
527
|
}
|
|
451
528
|
});
|
|
452
529
|
}
|
|
453
530
|
}
|
|
454
531
|
|
|
455
|
-
var index_template_default$1 =
|
|
456
|
-
|
|
457
|
-
var index_template_default = `.examples-root {
|
|
532
|
+
var index_template_default$1 = `.examples-root {
|
|
458
533
|
margin: 50px auto 200px;
|
|
459
534
|
min-width: calc(200px + 2em);
|
|
460
535
|
width: calc(100vw - 200px);
|
|
@@ -526,6 +601,8 @@ var index_template_default = `.examples-root {
|
|
|
526
601
|
}
|
|
527
602
|
`;
|
|
528
603
|
|
|
604
|
+
var index_template_default = '<html>\n <head>\n <meta charset="utf-8" />\n <title>Examples</title>\n\n <meta http-equiv="X-UA-Compatible" content="IE=edge" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n\n <link rel="stylesheet" type="text/css" href="examples.css" />\n </head>\n <body></body>\n</html>\n';
|
|
605
|
+
|
|
529
606
|
function generateJSFiddle(example) {
|
|
530
607
|
return cheerio.load([])("<a>").addClass("icon jsfiddle").attr("href", example.paths.jsfiddle.web).attr("title", "JSFiddle");
|
|
531
608
|
}
|
|
@@ -538,7 +615,7 @@ function processGroup$1(examples, title, level, collator) {
|
|
|
538
615
|
const list = cheerio.load([])("<div>");
|
|
539
616
|
const section = cheerio.load([])("<div>");
|
|
540
617
|
section.append(heading, list);
|
|
541
|
-
for (const key of Object.keys(examples).
|
|
618
|
+
for (const key of Object.keys(examples).toSorted(collator.compare)) {
|
|
542
619
|
const example = examples[key];
|
|
543
620
|
if (isExample(example)) {
|
|
544
621
|
const header = cheerio.load([])("<div>").addClass("example-header").append(
|
|
@@ -564,17 +641,17 @@ const htmlRenderer = {
|
|
|
564
641
|
const filename = "index.html";
|
|
565
642
|
const root = cheerio.load([])("<div>");
|
|
566
643
|
root.addClass("examples-root");
|
|
567
|
-
for (const key of Object.keys(examples).
|
|
644
|
+
for (const key of Object.keys(examples).toSorted(collator.compare)) {
|
|
568
645
|
root.append(processGroup$1(examples[key], key, 1, collator));
|
|
569
646
|
}
|
|
570
|
-
const page = cheerio.load(index_template_default
|
|
647
|
+
const page = cheerio.load(index_template_default);
|
|
571
648
|
page("title").text(title);
|
|
572
649
|
page("body").append(root);
|
|
573
650
|
const content = await formatHTML(page.html());
|
|
574
651
|
return [
|
|
575
652
|
{ content, filename, title },
|
|
576
653
|
{
|
|
577
|
-
content: index_template_default,
|
|
654
|
+
content: index_template_default$1,
|
|
578
655
|
filename: "examples.css",
|
|
579
656
|
title: "examples.css"
|
|
580
657
|
}
|
|
@@ -602,7 +679,7 @@ async function processGroup(examples, output, title, collator) {
|
|
|
602
679
|
const items = [];
|
|
603
680
|
const sections = [];
|
|
604
681
|
const filenamePart = title.replace(/[^a-zA-Z0-9]/g, "-").toLowerCase();
|
|
605
|
-
for (const key of Object.keys(examples).
|
|
682
|
+
for (const key of Object.keys(examples).toSorted(collator.compare)) {
|
|
606
683
|
const example = examples[key];
|
|
607
684
|
if (isExample(example)) {
|
|
608
685
|
items.push(
|
|
@@ -644,7 +721,7 @@ async function processGroup(examples, output, title, collator) {
|
|
|
644
721
|
const mdRenderer = {
|
|
645
722
|
async render(examples, output, _title, collator) {
|
|
646
723
|
const sections = [];
|
|
647
|
-
for (const key of Object.keys(examples).
|
|
724
|
+
for (const key of Object.keys(examples).toSorted(collator.compare)) {
|
|
648
725
|
sections.push(
|
|
649
726
|
...await processGroup(examples[key], output, key, collator)
|
|
650
727
|
);
|
|
@@ -670,82 +747,6 @@ const mdRenderer = {
|
|
|
670
747
|
}
|
|
671
748
|
};
|
|
672
749
|
|
|
673
|
-
const y = yargs(hideBin(process.argv)).strict(true).usage("generate-example-index [options]").hide("version").config().help().option("assets-local-directory", {
|
|
674
|
-
default: "./examples/thumbnails",
|
|
675
|
-
describe: "The directory where assets will be written to.",
|
|
676
|
-
type: "string"
|
|
677
|
-
}).option("assets-web-directory", {
|
|
678
|
-
default: "./thumbnails",
|
|
679
|
-
describe: "The directory where assets will be loaded from on the web.",
|
|
680
|
-
type: "string"
|
|
681
|
-
}).option("base-url", {
|
|
682
|
-
demand: true,
|
|
683
|
-
describe: "The base URL for relative imports. Web URLs starting with slash will be relative to this URL.",
|
|
684
|
-
type: "string"
|
|
685
|
-
}).option("examples-local-directory", {
|
|
686
|
-
default: "./examples/thumbnails",
|
|
687
|
-
describe: "The directory where examples will be loaded from locally.",
|
|
688
|
-
type: "string"
|
|
689
|
-
}).option("examples-web-directory", {
|
|
690
|
-
default: "./thumbnails",
|
|
691
|
-
describe: "The directory where examples will be loaded from on the web.",
|
|
692
|
-
type: "string"
|
|
693
|
-
}).option("output-directory", {
|
|
694
|
-
default: "./examples",
|
|
695
|
-
describe: "The directory where generated files will be emitted.",
|
|
696
|
-
type: "string"
|
|
697
|
-
}).option("pages-local-directory", {
|
|
698
|
-
default: "./examples/pages",
|
|
699
|
-
describe: "The directory where pages will be written to.",
|
|
700
|
-
type: "string"
|
|
701
|
-
}).option("pages-web-directory", {
|
|
702
|
-
default: "./pages",
|
|
703
|
-
describe: "The directory where pages will be loaded from on the web.",
|
|
704
|
-
type: "string"
|
|
705
|
-
}).option("index", {
|
|
706
|
-
default: false,
|
|
707
|
-
describe: "Generate index files.",
|
|
708
|
-
type: "boolean"
|
|
709
|
-
}).option("lint", {
|
|
710
|
-
default: false,
|
|
711
|
-
describe: "Lint examples.",
|
|
712
|
-
type: "boolean"
|
|
713
|
-
}).option("playgrounds", {
|
|
714
|
-
default: false,
|
|
715
|
-
describe: "Generate playground pages.",
|
|
716
|
-
type: "boolean"
|
|
717
|
-
}).option("screenshots", {
|
|
718
|
-
default: false,
|
|
719
|
-
describe: "Render screenshot thumbnails.",
|
|
720
|
-
type: "boolean"
|
|
721
|
-
}).option("container-id", {
|
|
722
|
-
default: "vis-container",
|
|
723
|
-
describe: "The id of the elements where Vis will put canvas.",
|
|
724
|
-
type: "string"
|
|
725
|
-
}).option("format", {
|
|
726
|
-
default: "html",
|
|
727
|
-
describe: "Whether HTML or Markdown should be generated.",
|
|
728
|
-
type: "string"
|
|
729
|
-
}).option("parallel", {
|
|
730
|
-
default: 6,
|
|
731
|
-
describe: "Generate n screenshots at the same time (there is quite high delay to make sure the graph is rendered before the screenshot is taken so the CPU utilization is generally quite low).",
|
|
732
|
-
type: "number"
|
|
733
|
-
}).option("screenshot-script", {
|
|
734
|
-
describe: "The path of JavaScript file that will be executed before taking a screenshot (and before any other JavaScript in the page).",
|
|
735
|
-
type: "string"
|
|
736
|
-
}).option("title", {
|
|
737
|
-
default: "Examples",
|
|
738
|
-
describe: "The title of the examples index.",
|
|
739
|
-
type: "string"
|
|
740
|
-
}).option("verify", {
|
|
741
|
-
default: 100,
|
|
742
|
-
describe: "Attempt to verify that the examples were generated correctly. The value is a percentage of checks that have to pass for the run to be considered success.",
|
|
743
|
-
type: "number"
|
|
744
|
-
});
|
|
745
|
-
function parseArguments() {
|
|
746
|
-
return y.parserConfiguration({ "camel-case-expansion": false }).parseSync();
|
|
747
|
-
}
|
|
748
|
-
|
|
749
750
|
function joinURLs(...urls) {
|
|
750
751
|
return urls.map(
|
|
751
752
|
(url) => (
|
|
@@ -892,7 +893,9 @@ function lintExample(path, page) {
|
|
|
892
893
|
const stats = { examples: 0 };
|
|
893
894
|
const skipped = [];
|
|
894
895
|
await Promise.all(
|
|
895
|
-
(await (await import('globby')).globby(
|
|
896
|
+
(await (await import('globby')).globby(
|
|
897
|
+
posix.join(pathsConfig.page.local, "**/*.html")
|
|
898
|
+
)).map(async (pagePath) => {
|
|
896
899
|
const html = await readFile(pagePath, "utf-8");
|
|
897
900
|
const $page = cheerio.load(html);
|
|
898
901
|
const pageDelay = getMeta(
|
|
@@ -966,7 +969,7 @@ function lintExample(path, page) {
|
|
|
966
969
|
console.info(
|
|
967
970
|
[
|
|
968
971
|
"The following files don't look like examples (there is nothing to take a screenshot of):",
|
|
969
|
-
...skipped.
|
|
972
|
+
...skipped.toSorted()
|
|
970
973
|
].join("\n ")
|
|
971
974
|
);
|
|
972
975
|
}
|