Careful with the SWIPL WASM

I tried the SWIPL WASM locally on my machine via:

curl "https://dev.swi-prolog.org/wasm/shell" > shell.html
curl "https://dev.swi-prolog.org/wasm/swipl-web.js" > swipl-web.js
curl "https://dev.swi-prolog.org/wasm/swipl-web.data" > swipl-web.data
curl "https://dev.swi-prolog.org/wasm/swipl-web.wasm" > swipl-web.wasm

Works fine, except for one problem. It doesn’t allow me
to put everything into /foo/bar, it somehow requires to
put everything into /wasm, except maybe for the shell.

Shouldn’t things on the web work with relative links? Like
once I have something like in the shell:

<script src="<path>/swipl-web.js"></script>

The JavaScript file swipl-web.js should orient itself, and be able to
fetch swipl-web.data and swipl-web.wasm from the same <path>.
Ok, problem could be local store, if for example I have multiple

<path1>, <path2>, … SWIPL WASM on the same server, like
different versions. Will the browser access the same local store?
Or is it bound to the document? I am not so familiar with local

store, but the relative path request is independent.

shell.html contains

var Module = {
    noInitialRun: true,
    arguments: [],
    locateFile: function(file) {
	return '/wasm/' + file;
    },
    preRun:   [() => bindStdStreams(Module)]
};

By changing locateFile you can make it find the WASM components from where you want, (probably even simply from SWI-Prolog WebAssembly build test. See emscripten docs.

Now I have a curious question:

How would I use SWIPL WASM from for example within
JSFiddle, without much coding on my side. Currently the page
shell.html contains a hell lot of code. Is there some xxx.js

I can refer to and everything works fine?
A test case would be for example from Tau Prolog:

:- use_module(library(lists)).             
fruit(apple). fruit(pear). fruit(banana). 
fruits_in(Xs, X) :- member(X, Xs), fruit(X).

?- fruits_in([carrot, apple, banana, broccoli], X).

http://tau-prolog.org/manual/a-simple-tutorial

Not yet. Eventually something like that should emerge. As is, if you just want Prolog and no shell, you need some 20 lines of code. This can be shortened a bit further by moving initialization everyone needs into prolog.js (and from there to swipl-web.js).

Possibly some parts of shell.html should move there too. Most of that file is concerned with the (very minimal) user interface though.