You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The easiest way to get started is my importing swipl-wasm into your npm project.
10
-
It imported for both node and browser builds as follows:
9
+
The easiest way to get started is by importing swipl-wasm into your npm project.
10
+
It can be imported for both Node.js and browser builds as follows:
11
11
12
12
script.mjs
13
13
```js
@@ -21,8 +21,8 @@ async function main() {
21
21
main();
22
22
```
23
23
24
-
For those who have not done this before you will first need to [install node and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
25
-
After doing this you can make a new project as follows:
24
+
For those who have not done this before, you will first need to [install Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
25
+
After doing this, you can make a new project as follows:
26
26
27
27
```bash
28
28
# Make the project directory
@@ -33,8 +33,8 @@ npm init
33
33
npm i swipl-wasm
34
34
```
35
35
36
-
After this place the above code in `script.mjs` in the root of your directory and run `node script.mjs`
37
-
to run the script.
36
+
After this, place the above code in `script.mjs` in the root of your directory and run `node script.mjs`
37
+
to execute the script.
38
38
39
39
## Usage
40
40
@@ -59,15 +59,15 @@ In browser:
59
59
</script>
60
60
```
61
61
62
-
The function `locateFile` will help the browser to find the necessary
63
-
files (`swipl-web.wasm` and `swipl-web.data`). In this case the files
62
+
The function `locateFile` will help the browser find the necessary
63
+
files (`swipl-web.wasm` and `swipl-web.data`). In this case, the files
64
64
should be served along with `swipl-web.js` under the `/dist/swipl`
65
65
directory in the web server.
66
66
67
67
You can run this example by executing `npm run test:serve-http` and
You can run this example with `node examples/run-on-node.js`.
80
80
81
-
## Using single-file bundle
81
+
## Using Single-File Bundle
82
82
83
-
The `swipl-wasm` package comes also with the single-file bundle. This does not
84
-
require distributing the `.data` and `.wasm` files which are now embedded into
83
+
The `swipl-wasm` package also comes with a single-file bundle. This does not
84
+
require distributing the `.data` and `.wasm` files, which are now embedded into
85
85
the `.js` file instead.
86
86
87
87
```html
@@ -98,9 +98,9 @@ the `.js` file instead.
98
98
</script>
99
99
```
100
100
101
-
## Generating an image
101
+
## Generating an Image
102
102
103
-
Often you will want to bundle a pre-built image of your Prolog file. The easiest way to do this is using the `swipl-generate` command to generate the image. For example in `./examples/generation` the script:`npx swipl-generate ./max.pl ./dist/max.ts` will generate a file `./dist/max.ts` which contains the image of `./max.pl`. This file can then be imported into your project and used as follows:
103
+
Often you will want to bundle a pre-built image of your Prolog file. The easiest way to do this is using the `swipl-generate` command to generate the image. For example, in `./examples/generation`, the script `npx swipl-generate ./max.pl ./dist/max.ts` will generate a file `./dist/max.ts` which contains the image of `./max.pl`. This file can then be imported into your project and used as follows:
104
104
105
105
```ts
106
106
importSWIPLfrom'./max';
@@ -116,7 +116,7 @@ main();
116
116
117
117
Note that this procedure generates a file which imports directly from `swipl-wasm/dist/loadImageDefault`, so make sure that `swipl-wasm` is a direct dependency in your project rather than a dev dependency.
118
118
119
-
To generate the image data without it pre-loaded into `SWIPL` use the `--image-only` flag.
119
+
To generate the image data without it being pre-loaded into `SWIPL`, use the `--image-only` flag.
120
120
121
121
## Running JavaScript from Prolog
122
122
@@ -137,41 +137,43 @@ bundler for large-scale frontend projects.
137
137
138
138
There is an example Webpack project in `examples/webpack`. It uses
139
139
[Asset Modules](https://webpack.js.org/guides/asset-modules/) to "load"
140
-
necessary `.data` and `.wasm` files. The location of these files and then
140
+
necessary `.data` and `.wasm` files. The location of these files is then
141
141
fed to `locateFile` (see above).
142
142
143
-
The package `swipl-wasm` is linked into the example. In an actual project
143
+
The package `swipl-wasm` is linked into the example. In an actual project,
144
144
you would declare `swipl-wasm` as a normal dependency.
145
145
146
146
To start the example:
147
147
148
148
```
149
149
cd examples/webpack
150
150
npm install
151
-
npm build
151
+
npm run build
152
152
npm run server
153
153
```
154
154
155
-
and visit <http://127.0.0.1:8080>. You should see the message "Hello world from
155
+
Then visit <http://127.0.0.1:8080>. You should see the message "Hello world from
156
156
Prolog".
157
157
158
158
159
159
## Browser Builds
160
160
161
-
For convenience we provide deploy bundled versions of the SWI-Prolog on github pages which can be directly used in an HTML document.
161
+
For convenience, we provide deployed bundled versions of SWI-Prolog on GitHub Pages which can be directly used in an HTML document.
162
+
163
+
There is a bundled version for each release, which can be found at the URL:
162
164
163
-
There is a bundled version for each release - which can be found at the url:
0 commit comments