Skip to content

Commit 70e0528

Browse files
committed
fix: Update test/demo pages to work with es6
Fixes #146 Signed-off-by: Gordon Smith <[email protected]>
1 parent 5b5f2c0 commit 70e0528

File tree

5 files changed

+48
-70
lines changed

5 files changed

+48
-70
lines changed

.vscode/launch.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,6 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7-
{
8-
"name": "sfx-wasm",
9-
"request": "launch",
10-
"runtimeArgs": [
11-
"run-script",
12-
"gen-sfx-graphviz"
13-
],
14-
"runtimeExecutable": "npm",
15-
"skipFiles": [
16-
"<node_internals>/**"
17-
],
18-
"type": "node"
19-
},
207
{
218
"name": "index.html",
229
"type": "msedge",
@@ -54,6 +41,19 @@
5441
"url": "http://localhost:8000/hw-base91.html",
5542
"webRoot": "${workspaceRoot}"
5643
},
44+
{
45+
"name": "sfx-wasm",
46+
"request": "launch",
47+
"runtimeArgs": [
48+
"run-script",
49+
"gen-sfx-graphviz"
50+
],
51+
"runtimeExecutable": "npm",
52+
"skipFiles": [
53+
"<node_internals>/**"
54+
],
55+
"type": "node"
56+
},
5757
{
5858
"name": "test-browser",
5959
"type": "msedge",

hw-base91.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
<body>
1010
<div id="placeholder"></div>
1111
<script type="module">
12-
import { Base91 } from "./dist/index.es6.js";
13-
//import { Base91 } from "https://cdn.jsdelivr.net/npm/@hpcc-js/wasm/dist/index.es6.js";
12+
// Prefer local version (if available) ---
13+
import { Base91 as Base91Local } from "./dist/index.js";
14+
import { Base91 as Base91External } from "https://cdn.jsdelivr.net/npm/@hpcc-js/wasm/dist/index.js";
15+
16+
const Base91 = Base91Local ?? Base91External;
1417

1518
const base91 = await Base91.load();
1619
const data = new Uint8Array(Array.from({ length: 100 }, (_, i) => Math.random() * 100));

hw-graphviz.html

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,17 @@
44
<head>
55
<meta charset="UTF-8">
66
<title>GraphViz WASM</title>
7-
<script src="https://cdn.jsdelivr.net/npm/@hpcc-js/wasm/dist/index.min.js"></script>
8-
<script>
9-
var hpccWasm = window["@hpcc-js/wasm"];
10-
</script>
117
</head>
128

139
<body>
14-
<div id="placeholder0"></div>
15-
<script>
16-
const test = `\
17-
digraph {
18-
layout = neato
19-
splines = true
20-
edge [len = 2]
21-
a -> b
22-
b -> a
23-
}`;
24-
hpccWasm.graphviz.layout(test, "svg", "dot").then(svg => {
25-
const div = document.getElementById("placeholder0");
26-
div.innerHTML = svg;
27-
});
28-
</script>
29-
<div id="placeholder1"></div>
30-
<div id="placeholder2"></div>
31-
<script>
10+
<div id="placeholder"></div>
11+
<script type="module">
12+
// Prefer local version (if available) ---
13+
import { Graphviz as GraphvizLocal } from "./dist/index.js";
14+
import { Graphviz as GraphvizExternal } from "https://cdn.jsdelivr.net/npm/@hpcc-js/wasm/dist/index.js";
15+
16+
const Graphviz = GraphvizLocal ?? GraphvizExternal;
17+
3218
const dot = `
3319
digraph G {
3420
node [shape=rect];
@@ -61,21 +47,9 @@
6147
}
6248
`;
6349

64-
// Asynchronous call to layout
65-
hpccWasm.graphviz.layout(dot, "svg", "dot").then(svg => {
66-
const div = document.getElementById("placeholder1");
67-
div.innerHTML = svg;
68-
});
69-
</script>
70-
71-
<script type="module">
72-
import { graphvizSync } from "https://cdn.jsdelivr.net/npm/@hpcc-js/wasm/dist/index.es6.js";
73-
74-
graphvizSync().then(graphviz => {
75-
const div = document.getElementById("placeholder2");
76-
// Synchronous call to layout
77-
div.innerHTML = graphviz.layout(dot, "svg", "dot");
78-
});
50+
const graphviz = await Graphviz.load();
51+
const div = document.getElementById("placeholder");
52+
div.innerHTML = graphviz.layout(dot, "svg", "dot");
7953
</script>
8054

8155
</body>

hw-zstd.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
<body>
1010
<div id="placeholder"></div>
1111
<script type="module">
12-
import { Zstd } from "./dist/index.es6.js";
13-
//import { Zstd } from "https://cdn.jsdelivr.net/npm/@hpcc-js/wasm/dist/index.es6.js";
12+
// Prefer local version (if available) ---
13+
import { Zstd as ZstdLocal } from "./dist/index.js";
14+
import { Zstd as ZstdExternal } from "https://cdn.jsdelivr.net/npm/@hpcc-js/wasm/dist/index.js";
15+
16+
const Zstd = ZstdLocal ?? ZstdExternal;
1417

1518
const zstd = await Zstd.load();
1619
const data = new Uint8Array(Array.from({ length: 100000 }, (_, i) => i % 256));

index.html

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,20 @@
3333
a3 -> end;
3434
b3 -> end;
3535
36-
start [shape=Mdiamond,label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" >
37-
<TR>
38-
<TD COLSPAN="3" BGCOLOR="azure3" >
39-
<b><FONT FACE="Times-Roman" POINT-SIZE="12.0" >one obj</FONT></b>
40-
</TD>
41-
</TR>
42-
<TR>
43-
<TD PORT="in1" BGCOLOR="white">in1<br/>:In1</TD>
44-
<TD ROWSPAN="2" BGCOLOR="azure3"> some text </TD>
45-
<TD PORT="out1" BGCOLOR="0.5 0.5 0.5">out1<br/>:Out1</TD>
46-
</TR>
47-
<TR>
48-
<TD PORT="in2" HREF="somepage.html" BGCOLOR="0.45 0.5 0.75">in2<br/>:In2</TD>
49-
<TD PORT="out2" HREF="somepage.html" BGCOLOR="0.8 0.5 1">out2<br/>:Out2</TD>
50-
</TR>
51-
</TABLE>>];
36+
start [shape=Mdiamond, label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" >
37+
<TR>
38+
<TD COLSPAN="3" BGCOLOR="azure3"><b><FONT FACE="Times-Roman" POINT-SIZE="12.0" >one obj</FONT></b></TD>
39+
</TR>
40+
<TR>
41+
<TD PORT="in1" BGCOLOR="white">in1<br/>:In1</TD>
42+
<TD ROWSPAN="2" BGCOLOR="azure3"> some text </TD>
43+
<TD PORT="out1" BGCOLOR="0.5 0.5 0.5">out1<br/>:Out1</TD>
44+
</TR>
45+
<TR>
46+
<TD PORT="in2" HREF="somepage.html" BGCOLOR="0.45 0.5 0.75">in2<br/>:In2</TD>
47+
<TD PORT="out2" HREF="somepage.html" BGCOLOR="0.8 0.5 1">out2<br/>:Out2</TD>
48+
</TR>
49+
</TABLE>>];
5250
end [shape=Msquare];
5351
}
5452
`;

0 commit comments

Comments
 (0)