Skip to content

Commit

Permalink
Fix deno example
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmmease committed Apr 29, 2024
1 parent 56a842b commit b24a302
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
6 changes: 3 additions & 3 deletions avenger-vega-renderer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2021"
crate-type = [ "cdylib", "rlib",]

[features]
deno = [ "avenger-wgpu/deno",]

deno = [ "avenger-wgpu/deno", "wgpu/webgpu"]
default = [ "wgpu/webgl" ]
[dependencies]
lazy_static = "1.4.0"
serde_json = "1.0.114"
Expand Down Expand Up @@ -39,7 +39,7 @@ version = "0.0.4"
[dependencies.wgpu]
version = "0.19.3"
default-features = false
features = [ "wgsl", "webgl", "webgpu",]
features = [ "wgsl" ]

[dependencies.wasm-bindgen]
version = "=0.2.92"
Expand Down
2 changes: 1 addition & 1 deletion avenger-vega-renderer/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export async function viewToPng(view) {
);
});

const sceneGraph = importScenegraph(vegaSceneGroups, width, height, origin);
const sceneGraph = await importScenegraph(vegaSceneGroups, width, height, origin);
const png = await scene_graph_to_png(sceneGraph);
return png;
}
4 changes: 2 additions & 2 deletions examples/deno_png/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
Build wasm package for Deno in `avenger-vega-renderer/`

```
npm run build-deno
pixi run build-vega-renderer-deno
```

Then from this directory

```
deno run --allow-net --allow-read --allow-write --unstable-webgpu export_png.js
deno run --allow-net --allow-write --unstable-webgpu export_png.js
```

This should generate a `chart.png` file in the current directory
4 changes: 2 additions & 2 deletions examples/deno_png/export_png.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vega from "https://cdn.skypack.dev/pin/[email protected]/mode=imports/optimized/vega.js"
import * as avenger from "../../avenger-vega-renderer/dist_deno/js/index.js"
import { viewToPng } from "../../avenger-vega-renderer/dist-deno/js/index.js"

var spec = {
"$schema": "https://vega.github.io/schema/vega/v5.json",
Expand Down Expand Up @@ -111,5 +111,5 @@ var spec = {

const runtime = vega.parse(spec);
const view = new vega.View(runtime, {renderer: 'none'});
const png = await avenger.viewToPng(view);
const png = await viewToPng(view);
Deno.writeFile("chart.png", png);
14 changes: 14 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ npm pack &&
mv avenger-vega-renderer-*.tgz packed
"""

[tasks.build-vega-renderer-deno]
cwd = "avenger-vega-renderer"
cmd = """
rm -rf lib/ &&
deno run -A jsr:@deno/[email protected] -p avenger-vega-renderer -p avenger-vega-renderer --no-default-features --features "deno" --sync &&
rm -rf dist-deno/ &&
mkdir -p dist-deno/ &&
cp -r js dist-deno/js &&
cp -r lib dist-deno/ &&
cp package.json dist-deno/
"""

[tasks.publish-rs]
cmd = """
cargo publish -p avenger &&
Expand Down

0 comments on commit b24a302

Please sign in to comment.