swipl-wasm 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +9 -0
- package/dist/index.js +34 -0
- package/dist/locateFile-browser.d.ts +1 -0
- package/dist/locateFile-browser.js +13 -0
- package/dist/locateFile.d.ts +1 -0
- package/dist/locateFile.js +21 -0
- package/dist/swipl/swipl-web.data +0 -0
- package/dist/swipl/swipl-web.js +1 -1
- package/dist/swipl/swipl-web.wasm +0 -0
- package/dist/swipl/swipl.d.ts +27 -0
- package/dist/swipl/swipl.js +1 -1
- package/package.json +30 -6
- package/docker/Dockerfile +0 -53
- package/docker/build-all.sh +0 -29
- package/examples/browser.html +0 -32
- package/examples/run-on-node.js +0 -23
package/package.json
CHANGED
|
@@ -1,17 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swipl-wasm",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"exports": {
|
|
5
5
|
"./swipl": "./dist/swipl/swipl.js",
|
|
6
|
-
"./swipl-web": "./dist/swipl/swipl-web.js"
|
|
6
|
+
"./swipl-web": "./dist/swipl/swipl-web.js",
|
|
7
|
+
".": "./dist/index.js"
|
|
7
8
|
},
|
|
8
|
-
"
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"contributors": [
|
|
12
|
+
"Raivo Laanemets",
|
|
13
|
+
"Jesse Wright"
|
|
14
|
+
],
|
|
9
15
|
"license": "BSD-2-Clause",
|
|
10
16
|
"type": "commonjs",
|
|
11
17
|
"devDependencies": {
|
|
18
|
+
"@types/jest": "^29.0.0",
|
|
19
|
+
"@types/node": "^18.7.14",
|
|
20
|
+
"copyfiles": "^2.4.1",
|
|
21
|
+
"http-server": "^14.1.1",
|
|
22
|
+
"jest": "^29.0.1",
|
|
23
|
+
"jest-environment-jsdom": "^29.0.1",
|
|
12
24
|
"npm-run-all": "^4.1.5",
|
|
13
|
-
"
|
|
25
|
+
"typescript": "^4.8.2"
|
|
14
26
|
},
|
|
27
|
+
"browser": {
|
|
28
|
+
"./dist/locateFile.js": "./dist/locateFile-browser.js",
|
|
29
|
+
"./dist/swipl/swipl.js": "./dist/swipl/swipl-web.js"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
15
34
|
"scripts": {
|
|
16
35
|
"build:wasm-docker:build": "docker build -t swipl-wasm-image docker",
|
|
17
36
|
"build:wasm-docker:create": "docker create --name swipl-wasm swipl-wasm-image",
|
|
@@ -22,7 +41,12 @@
|
|
|
22
41
|
"build:wasm-docker:extract:node": "docker cp swipl-wasm:/swipl-devel/swipl.wasm/src/swipl-web.js dist/swipl/swipl.js",
|
|
23
42
|
"build:wasm-docker:extract": "run-s build:wasm-docker:extract:*",
|
|
24
43
|
"build:wasm-docker": "run-s build:wasm-docker:build build:wasm-docker:create build:wasm-docker:extract build:wasm-docker:remove",
|
|
25
|
-
"build": "
|
|
26
|
-
"
|
|
44
|
+
"build:tsc:compile": "tsc",
|
|
45
|
+
"build:tsc:copy": "copyfiles -u 1 \"src/**/*.d.ts\" dist",
|
|
46
|
+
"build:tsc": "run-s build:tsc:*",
|
|
47
|
+
"build": "run-s build:*",
|
|
48
|
+
"prepare": "yarn run build",
|
|
49
|
+
"test:serve-http": "http-server . -c-1",
|
|
50
|
+
"test": "jest"
|
|
27
51
|
}
|
|
28
52
|
}
|
package/docker/Dockerfile
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# Builds SWI-Prolog WebAssembly version.
|
|
2
|
-
# https://swi-prolog.discourse.group/t/swi-prolog-in-the-browser-using-wasm/5650
|
|
3
|
-
|
|
4
|
-
FROM debian:bullseye
|
|
5
|
-
|
|
6
|
-
# Installs build dependencies.
|
|
7
|
-
|
|
8
|
-
ENV DEBIAN_FRONTEND noninteractive
|
|
9
|
-
|
|
10
|
-
RUN apt-get update && apt-get install -y \
|
|
11
|
-
bzip2 \
|
|
12
|
-
cmake \
|
|
13
|
-
git \
|
|
14
|
-
ninja-build \
|
|
15
|
-
python3 \
|
|
16
|
-
wget \
|
|
17
|
-
xz-utils
|
|
18
|
-
|
|
19
|
-
RUN git config --global pull.ff only
|
|
20
|
-
|
|
21
|
-
# Installs Emscripten.
|
|
22
|
-
# See https://emscripten.org/docs/getting_started/downloads.html
|
|
23
|
-
|
|
24
|
-
ENV EMSDK_VERSION 3.1.20
|
|
25
|
-
|
|
26
|
-
RUN git clone https://github.com/emscripten-core/emsdk.git /emsdk
|
|
27
|
-
WORKDIR /emsdk
|
|
28
|
-
RUN git pull
|
|
29
|
-
RUN ./emsdk install $EMSDK_VERSION
|
|
30
|
-
RUN ./emsdk activate $EMSDK_VERSION
|
|
31
|
-
|
|
32
|
-
# Downloads ZLIB.
|
|
33
|
-
|
|
34
|
-
RUN wget --no-verbose https://zlib.net/zlib-1.2.12.tar.gz -O /zlib-1.2.12.tar.gz
|
|
35
|
-
RUN tar -xf /zlib-1.2.12.tar.gz --directory /
|
|
36
|
-
|
|
37
|
-
# Clones SWI-Prolog.
|
|
38
|
-
|
|
39
|
-
RUN git clone https://github.com/SWI-Prolog/swipl-devel.git /swipl-devel
|
|
40
|
-
WORKDIR /swipl-devel
|
|
41
|
-
|
|
42
|
-
# Uncomment the following to build a specific commit.
|
|
43
|
-
# ENV SWIPL_COMMIT 5c7d1f8352b27d45cb8066eac5af95cf925a05b7
|
|
44
|
-
# RUN git checkout $SWIPL_COMMIT -b local-wasm
|
|
45
|
-
|
|
46
|
-
RUN git fetch
|
|
47
|
-
RUN git submodule update --init
|
|
48
|
-
|
|
49
|
-
# Compiles everything.
|
|
50
|
-
|
|
51
|
-
COPY build-all.sh /build-all.sh
|
|
52
|
-
RUN chmod +x /build-all.sh
|
|
53
|
-
RUN /build-all.sh
|
package/docker/build-all.sh
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
set -o errexit
|
|
4
|
-
set -o xtrace
|
|
5
|
-
|
|
6
|
-
source /emsdk/emsdk_env.sh
|
|
7
|
-
|
|
8
|
-
# ZLIB
|
|
9
|
-
|
|
10
|
-
cd /zlib-1.2.12
|
|
11
|
-
emconfigure ./configure
|
|
12
|
-
EMCC_CFLAGS=-Wno-deprecated-non-prototype emmake make
|
|
13
|
-
|
|
14
|
-
# SWI-Prolog
|
|
15
|
-
|
|
16
|
-
mkdir /swipl-devel/swipl.wasm
|
|
17
|
-
cd /swipl-devel/swipl.wasm
|
|
18
|
-
cmake -DCMAKE_TOOLCHAIN_FILE=/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
|
|
19
|
-
-DCMAKE_BUILD_TYPE=Release \
|
|
20
|
-
-DZLIB_LIBRARY=/zlib-1.2.12/libz.a \
|
|
21
|
-
-DZLIB_INCLUDE_DIR=/zlib-1.2.12 \
|
|
22
|
-
-DINSTALL_DOCUMENTATION=OFF \
|
|
23
|
-
-DMULTI_THREADED=OFF \
|
|
24
|
-
-DUSE_SIGNALS=OFF \
|
|
25
|
-
-DUSE_GMP=OFF \
|
|
26
|
-
-DBUILD_SWIPL_LD=OFF \
|
|
27
|
-
-DSWIPL_PACKAGES=OFF \
|
|
28
|
-
-G Ninja ..
|
|
29
|
-
ninja
|
package/examples/browser.html
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF8">
|
|
5
|
-
<title>SWI-Prolog WebAssembly browser test</title>
|
|
6
|
-
</head>
|
|
7
|
-
<body>
|
|
8
|
-
<div id="solution"></div>
|
|
9
|
-
<script src="/dist/swipl/swipl-web.js"></script>
|
|
10
|
-
<script>
|
|
11
|
-
(async () => {
|
|
12
|
-
const swipl = await SWIPL({
|
|
13
|
-
noInitialRun: true,
|
|
14
|
-
arguments: ['-q'],
|
|
15
|
-
locateFile: (url) => {
|
|
16
|
-
if (url === 'swipl-web.data') {
|
|
17
|
-
return '/dist/swipl/swipl-web.data';
|
|
18
|
-
} else if (url === 'swipl-web.wasm') {
|
|
19
|
-
return '/dist/swipl/swipl-web.wasm';
|
|
20
|
-
}
|
|
21
|
-
return url;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
const query = "member(X, [a, b, c]).";
|
|
25
|
-
const solutionElement = document.getElementById('solution');
|
|
26
|
-
// See https://swi-prolog.discourse.group/t/swi-prolog-in-the-browser-using-wasm/5650/1
|
|
27
|
-
const firstSolution = swipl.prolog.query(query).once().X;
|
|
28
|
-
solutionElement.textContent = firstSolution;
|
|
29
|
-
})();
|
|
30
|
-
</script>
|
|
31
|
-
</body>
|
|
32
|
-
</html>
|
package/examples/run-on-node.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const SWIPL = require('swipl-wasm/swipl');
|
|
3
|
-
|
|
4
|
-
(async () => {
|
|
5
|
-
// This helps to find the correct locations of the
|
|
6
|
-
// .data and .wasm files.
|
|
7
|
-
const swiplModuleLocation = require.resolve('swipl-wasm/swipl');
|
|
8
|
-
const swipl = await SWIPL({
|
|
9
|
-
noInitialRun: true,
|
|
10
|
-
arguments: ['-q'],
|
|
11
|
-
locateFile: (url) => {
|
|
12
|
-
// These are common with the web version.
|
|
13
|
-
if (url === 'swipl-web.data') {
|
|
14
|
-
return path.join(path.dirname(swiplModuleLocation), 'swipl-web.data');
|
|
15
|
-
} else if (url === 'swipl-web.wasm') {
|
|
16
|
-
return path.join(path.dirname(swiplModuleLocation), 'swipl-web.wasm');
|
|
17
|
-
}
|
|
18
|
-
return url;
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
// See https://swi-prolog.discourse.group/t/swi-prolog-in-the-browser-using-wasm/5650/1
|
|
22
|
-
console.log(swipl.prolog.query("member(X, [a, b, c]).").once().X);
|
|
23
|
-
})();
|