@aduh95/viz.js
Advanced tools
Comparing version 3.0.0-beta.8 to 3.0.0-beta.9
@@ -47,5 +47,5 @@ # Changelog | ||
strictly limited to Node.js or webworker use. | ||
- **BREAKING:** Remove ES5 and CJS dist files, all modern browsers now support | ||
ES2015 modules. If you want to support an older browser, you would need to | ||
transpile it yourself or use an older version. | ||
- **BREAKING:** Remove ES5 dist files, all modern browsers now support ES2015 | ||
modules. If you want to support an older browser, you would need to transpile | ||
it yourself or use an older version. | ||
- **BREAKING:** On Node.js, `require('@aduh95/viz.js')` returns now a | ||
@@ -68,5 +68,6 @@ `Promise<Viz>`. | ||
- Switch to Mocha and Puppeteer for browser testing. | ||
- Add synchronous API using asm.js. | ||
- Add synchronous API using asm.js (`@aduh95/viz.js/sync`). | ||
- Add a helper module for asynchronous API (`@aduh95/viz.js/async`). | ||
- Upgrade deps: | ||
- Upgrade Emscripten to 1.39.12 | ||
- Upgrade Emscripten to 1.39.15 | ||
- Upgrade Graphviz to 2.44.0 | ||
@@ -73,0 +74,0 @@ - Upgrade Expat to 2.2.9 |
{ | ||
"name": "@aduh95/viz.js", | ||
"version": "3.0.0-beta.8", | ||
"version": "3.0.0-beta.9", | ||
"description": "A hack to put Graphviz on the web.", | ||
@@ -14,3 +14,4 @@ "main": "./dist/index.cjs", | ||
}, | ||
"./sync": "./dist/renderSync.js", | ||
"./async": "./dist/render_async.js", | ||
"./sync": "./dist/render_sync.js", | ||
"./wasm": "./dist/render.wasm", | ||
@@ -24,3 +25,3 @@ "./worker": { | ||
"engines": { | ||
"node": ">=12.8.0" | ||
"node": "^12.17.0 || >=13.2.0" | ||
}, | ||
@@ -43,4 +44,8 @@ "repository": { | ||
"dist/render.wasm", | ||
"dist/renderSync.js", | ||
"dist/renderSync.d.ts", | ||
"dist/render_async.js", | ||
"dist/render_async.d.ts", | ||
"dist/render_sync.js", | ||
"dist/render_sync.d.ts", | ||
"async/index.js", | ||
"async/index.d.ts", | ||
"sync/index.js", | ||
@@ -64,3 +69,3 @@ "sync/index.d.ts", | ||
"@typescript-eslint/parser": "^2.28.0", | ||
"eslint": "next", | ||
"eslint": "^7.0.0", | ||
"eslint-config-prettier": "^6.10.1", | ||
@@ -67,0 +72,0 @@ "eslint-plugin-prettier": "^3.1.3", |
# Viz.js | ||
[![CI](https://github.com/aduh95/viz.js/workflows/CI/badge.svg)](https://github.com/aduh95/viz.js/actions) | ||
[![NPM version](https://img.shields.io/npm/v/@aduh95/viz.js.svg)](https://www.npmjs.org/package/@aduh95/viz.js) | ||
[![Node >=13.2](https://img.shields.io/node/v/@aduh95/viz.js.svg)](https://nodejs.org) | ||
[![License MIT](https://img.shields.io/npm/l/@aduh95/viz.js.svg)](https://github.com/aduh95/viz.js/blob/master/LICENCE) | ||
@@ -15,2 +18,10 @@ This project builds [Graphviz](http://www.graphviz.org) with | ||
### Getting Viz.js | ||
- Install the | ||
[`@aduh95/viz.js` package](https://www.npmjs.com/package/@aduh95/viz.js) from | ||
the npm registry. | ||
- Download from the | ||
[GH Actions CI](https://github.com/aduh95/viz.js/actions?query=is%3Asuccess). | ||
### Node.js | ||
@@ -33,25 +44,28 @@ | ||
}) | ||
.finally(() => { | ||
// If you don't terminate the worker explicitly, it will be terminated at the end of process | ||
worker.terminate(); | ||
}); | ||
.finally( | ||
() => | ||
// You can either terminate explicitly: | ||
viz.terminateWorker() | ||
// or let it be auto-closed at the end of the process | ||
); | ||
``` | ||
If you want to use it from a CommonJS script, you would need to use a dynamic | ||
imports: | ||
If you want to use it from a CommonJS script, you can use the | ||
`@aduh95/viz.js/async` wrapper shortcut: | ||
```js | ||
async function dot2svg(dot, options = {}) { | ||
const Viz = await import("@aduh95/viz.js").then((m) => m.default); | ||
const getWorker = await import("@aduh95/viz.js/worker").then( | ||
(m) => m.default | ||
); | ||
const dot2svg = require("@aduh95/viz.js/async"); | ||
const worker = getWorker(); | ||
const viz = new Viz({ worker }); | ||
return viz.renderString(dot, options); | ||
} | ||
dot2svg("digraph{1 -> 2 }") | ||
.then((svgString) => { | ||
console.log(svgString); | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
}); | ||
``` | ||
> Note: If you want to your lib to be web-ready, it is recommended to build up | ||
> from the first code example rather than the CommonJS one. | ||
#### Synchronous API | ||
@@ -82,2 +96,4 @@ | ||
#### Using a bundler | ||
You can either use the `worker` or the `workerURL` on the constructor. Note that | ||
@@ -97,3 +113,3 @@ when using `workerURL`, `Viz` constructor will try to spawn a webworker using | ||
// If you are not using a bundler that supports package.json#exports | ||
// use /node_modules/@aduh95/viz.js/dist/render.browser.js instead. | ||
// use "./node_modules/@aduh95/viz.js/dist/render.browser.js" instead. | ||
@@ -103,3 +119,3 @@ import wasmURL from "file-loader!@aduh95/viz.js/wasm"; | ||
// Or doesn't have a file-loader plugin to get URL of the asset, | ||
// use "/node_modules/@aduh95/viz.js/dist/render.wasm" instead. | ||
// use "./node_modules/@aduh95/viz.js/dist/render.wasm" instead. | ||
@@ -119,5 +135,5 @@ initWASM({ | ||
// If you are not using a bundler that supports package.json#exports | ||
// use /node_modules/@aduh95/viz.js/dist/index.mjs instead. | ||
// use "./node_modules/@aduh95/viz.js/dist/index.mjs" instead. | ||
const workerURL = "/worker.js"; | ||
import VizWorker from "worker-loader!./worker.js"; | ||
@@ -127,3 +143,3 @@ let viz; | ||
if (viz === undefined) { | ||
viz = new Viz({ workerURL }); | ||
viz = new Viz({ worker: new VizWorker() }); | ||
} | ||
@@ -134,2 +150,4 @@ return viz.renderString(dot, options); | ||
#### Using a CDN | ||
If you are using a CDN and don't want a separate file for the worker module, | ||
@@ -139,6 +157,6 @@ there is a workaround: | ||
```js | ||
import Viz from "https://unpkg.com/@aduh95/viz.js@3.0.0-beta.6"; | ||
import Viz from "https://unpkg.com/@aduh95/viz.js"; | ||
const locateFile = (fileName) => | ||
"https://unpkg.com/@aduh95/viz.js@3.0.0-beta.6/dist/" + fileName; | ||
"https://unpkg.com/@aduh95/viz.js/dist/" + fileName; | ||
const onmessage = async function (event) { | ||
@@ -190,3 +208,3 @@ if (this.messageHandler === undefined) { | ||
if (this._messageHandler === undefined) { | ||
const vizDistFolder = "https://unpkg.com/@aduh95/viz.js@3.0.0-beta.6/dist"; | ||
const vizDistFolder = "https://unpkg.com/@aduh95/viz.js/dist"; | ||
const Module = { | ||
@@ -193,0 +211,0 @@ // locateFile is used by render module to locate WASM file. |
@@ -1,1 +0,1 @@ | ||
export {default} from "../dist/renderSync" | ||
export {default} from '../dist/render_sync' |
@@ -1,1 +0,1 @@ | ||
module.exports=require('../dist/renderSync.js') | ||
module.exports=require('../dist/render_sync).js') |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3372499
21
8922
270
8