@aduh95/viz.js
Advanced tools
Comparing version 3.0.0-beta.2 to 3.0.0-beta.3
@@ -5,14 +5,52 @@ # Changelog | ||
##### Notable changes | ||
- The library is now compiled to WASM, which shrinks the file size (Viz.js | ||
(2.1.2 full version) brotlified: 409K; @aduh95/viz.js (3.0.0-beta.3) | ||
brotlified: 371K), should improve performances, allows dynamic memory growth. | ||
- The library is able to reset its internal error state, which makes the | ||
[v2 wiki caveat](https://github.com/mdaines/viz.js/wiki/Caveats#rendering-graphs-with-user-input) | ||
unnecessary. | ||
- Rendering from main thread is no longer supported, you must use a worker | ||
(webworker or worker_thread). | ||
- The JS code is now transpiled from TypeScript, and typings are packed within | ||
the npm package. You can find the API documentation there! | ||
##### Breaking changes and deprecations | ||
- **BREAKING:** Bump required version of Node.js to v12 LTS (might work on v10 | ||
using CLI flags). | ||
- **BREAKING:** Limit the API to `renderString` and `renderJSON`. | ||
- **BREAKING:** Remove support for non-worker environment (you must now specify | ||
either `worker` or `workerURL` on the `Viz` constructor). | ||
LTS using CLI flags). | ||
- **BREAKING:** Remove `Viz.prototype.renderSVGElement`. You can use | ||
`renderString` and `DOMParser` to achieve the same result. | ||
- **BREAKING:** Remove `Viz.prototype.renderImageElement`. You can use | ||
`renderString` and `Canvas` to achieve the same result. | ||
- **BREAKING:** Remove `Module` and `render` from `Viz` constructor's options | ||
(you must now specify either `worker` or `workerURL`). | ||
- **BREAKING:** Remove _lite_ version, Viz.js now comes in only one variant. | ||
- **BREAKING:** The `render.js` file (that replaces `full.render.js`) exports a | ||
worker_thread factory. It's available through `@aduh95/viz.js/worker` on | ||
Node.js and bundle tools that support `package.json`#`exports`. | ||
- **BREAKING:** Compiles to WebAssembly, which cannot be bundled in the | ||
`render.js` file like asm.js used to. Depending on your bundling tool, you may | ||
need some extra config to make everything work. | ||
- **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:** On Node.js, `require('@aduh95/viz.js')` returns now a | ||
`Promise<Viz>`. | ||
- **DEPRECATED:** `require('@aduh95/viz.js')` is deprecated, use | ||
`import('@aduh95/viz.js')` instead. | ||
##### Added features | ||
- Add support for Node.js `worker_threads`. | ||
- Use ES modules and WebAssembly (if you need support for ES5 or asm.js, you | ||
would need to transpile it yourself or use an older version). | ||
- Refactor JS files to Typescript. | ||
- Refactor `viz.c` to C++ to use | ||
[Emscripten's Embind](https://emscripten.org/docs/porting/connecting_cpp_and_javascript/embind.html). | ||
- Use `ALLOW_MEMORY_GROW` compiler option to avoid failing on large graphs. | ||
- Improve error handling: | ||
- Rejects with the full error string from Graphviz. | ||
- Remove the need of creating new instances when render fails by resetting | ||
internal error state. | ||
- Switch to Mocha and Puppeteer for browser testing. | ||
- Upgrade deps: | ||
@@ -19,0 +57,0 @@ - Upgrade Emscripten to 1.38.44 |
{ | ||
"name": "@aduh95/viz.js", | ||
"version": "3.0.0-beta.2", | ||
"version": "3.0.0-beta.3", | ||
"description": "A hack to put Graphviz on the web.", | ||
"main": "./src/index.mjs", | ||
"module": "./src/index.mjs", | ||
"main": "./dist/index.cjs", | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"require": "./src/index.cjs", | ||
"import": "./src/index.mjs" | ||
"require": "./dist/index.cjs", | ||
"import": "./dist/index.mjs" | ||
}, | ||
"./worker": "./src/render.js" | ||
"./worker": "./dist/render.js" | ||
}, | ||
@@ -27,7 +28,3 @@ "type": "commonjs", | ||
"files": [ | ||
"src/index.cjs", | ||
"src/index.mjs", | ||
"src/worker.js", | ||
"src/render.js", | ||
"src/render.wasm" | ||
"dist/" | ||
], | ||
@@ -44,8 +41,8 @@ "contributors": [ | ||
"devDependencies": { | ||
"@types/node": "^13.5.2", | ||
"@types/node": "^13.5.3", | ||
"mocha": "^7.0.0", | ||
"puppeteer": "^2.0.0", | ||
"terser": "^4.6.3", | ||
"typescript": "beta" | ||
"typescript": "^3.8.0-beta" | ||
} | ||
} |
@@ -9,4 +9,2 @@ # Viz.js | ||
For more information, [see the wiki](https://github.com/mdaines/viz.js/wiki). | ||
## See Also | ||
@@ -46,6 +44,4 @@ | ||
async function dot2svg(dot, options = {}) { | ||
const Viz = await import("@aduh95/viz.js").then(module => module.default); | ||
const getWorker = await import("@aduh95/viz.js/worker").then( | ||
module => module.default | ||
); | ||
const Viz = await import("@aduh95/viz.js").then(m => m.default); | ||
const getWorker = await import("@aduh95/viz.js/worker").then(m => m.default); | ||
@@ -61,11 +57,39 @@ const worker = getWorker(); | ||
In a world where Import Maps and `import.meta.resolve` are reality, you could | ||
have something like that: | ||
You can either use the `worker` or the `workerURL` on the constructor. | ||
```js | ||
import Viz from "@aduh95/viz.js"; | ||
import Viz from "/node_modules/@aduh95/viz.js/dist/index.mjs"; | ||
const workerURL = "/node_modules/@aduh95/viz.js/dist/render.js"; | ||
``` | ||
N.B.: Emscripten `render.js` expects to find a `render.wasm` on the same | ||
directory as `render.js`. If you are using a building tool that changes file | ||
names and/or file location, the loading would fail. | ||
If you are using a CDN or loading the files from a different origin, most | ||
browsers will block you from spawning a cross-origin webworker. There is a | ||
workaround: | ||
```js | ||
import Viz from "https://unpkg.com/@aduh95/viz.js@3.0.0-beta.2/dist/index.mjs"; | ||
const workerURL = URL.createObjectURL( | ||
new Blob( | ||
[ | ||
"self.Module =", | ||
"{ locateFile: file =>", | ||
'"https://unpkg.com/@aduh95/viz.js@3.0.0-beta.2/dist/"', | ||
"+ file", | ||
"};", // Module.locateFile let the worker resolve the wasm file URL | ||
"importScripts(", // importScripts is not restricted by same-origin policy | ||
"Module.locateFile(", // We can use it to load the JS file | ||
'"render.js"', | ||
"));", | ||
], | ||
{ type: "application/javascript" } | ||
) | ||
); | ||
async function dot2svg(dot, options) { | ||
const workerURL = await import.meta.resolve("@aduh95/viz.js/worker"); | ||
const viz = new Viz({ workerURL }); | ||
@@ -81,3 +105,4 @@ | ||
[install the Emscripten SDK](http://kripken.github.io/emscripten-site/docs/getting_started/index.html). | ||
You'll also need [Node.js](https://nodejs.org/) and [Yarn](https://yarnpkg.com). | ||
You'll also need [Node.js 13+](https://nodejs.org/) and | ||
[Yarn 2+](https://yarnpkg.com). | ||
@@ -84,0 +109,0 @@ On macOS: |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1280638
120
470
6