1
+ <!DOCTYPE html>
2
+ < html >
3
+
4
+ < head > </ head >
5
+
6
+ < body >
7
+ < script type ="module ">
8
+ import { configs , flush , importObject , inputString } from '/assets/simulatedExtismSdk.js'
9
+
10
+ const wasmUnderTest = '/target/wasm/release/build/examples/arrays/arrays.wasm'
11
+
12
+ // WebAssembly.instantiateStreaming(fetch("/target/wasm-gc/release/build/examples/arrays/arrays.wasm"), importObject).then(
13
+ WebAssembly . instantiateStreaming ( fetch ( wasmUnderTest ) , importObject ) . then (
14
+ ( obj ) => {
15
+ console . log ( 'Using simulated Extism SDK...' )
16
+ console . log ( 'ints:' )
17
+ inputString . value = '[0,1,2,3,4,5,6]'
18
+ obj . instance . exports [ 'progressive_sum_ints' ] ( )
19
+
20
+ console . log ( 'floats:' )
21
+ inputString . value = '[0,0.1,0.2,0.3,0.4,0.5,0.6]'
22
+ obj . instance . exports [ 'progressive_sum_floats' ] ( )
23
+
24
+ console . log ( 'strings:' )
25
+ inputString . value = '["0","1","2","3","4","5","6"]'
26
+ obj . instance . exports [ 'progressive_concat_strings' ] ( )
27
+ flush ( )
28
+ }
29
+ )
30
+
31
+ // Next, use the official Extism JavaScript SDK:
32
+ // Read the JS SDK docs at: https://extism.github.io/js-sdk/
33
+ const extism = await import ( 'https://esm.sh/@extism/extism' )
34
+
35
+ const plugin = await extism . createPlugin (
36
+ fetch ( wasmUnderTest ) ,
37
+ { useWasi : true }
38
+ )
39
+
40
+ console . log ( 'Using official Extism JavaScript SDK...' )
41
+ console . log ( 'ints:' )
42
+ let out = await plugin . call ( 'progressive_sum_ints' , '[0,1,2,3,4,5,6]' )
43
+ console . log ( out . text ( ) )
44
+
45
+ console . log ( 'floats:' )
46
+ out = await plugin . call ( 'progressive_sum_floats' , '[0,0.1,0.2,0.3,0.4,0.5,0.6]' )
47
+ console . log ( out . text ( ) )
48
+
49
+ console . log ( 'strings:' )
50
+ out = await plugin . call ( 'progressive_concat_strings' , '["0","1","2","3","4","5","6"]' )
51
+ console . log ( out . text ( ) )
52
+ </ script >
53
+ </ body >
54
+
55
+ </ html >
0 commit comments