Skip to content

Commit 03bc03f

Browse files
Copilotjeswr
andauthored
Polish README: resolve typos, improve clarity, remove TODO section (#1042)
* Initial plan * Update README: fix typos, improve readability, and remove TODO section Co-authored-by: jeswr <63333554+jeswr@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jeswr <63333554+jeswr@users.noreply.github.com>
1 parent c9e2720 commit 03bc03f

File tree

1 file changed

+32
-37
lines changed

1 file changed

+32
-37
lines changed

README.md

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# swipl-wasm
22

3-
SWI-Prolog WebAssembly build as a NPM package. Please see this page
3+
SWI-Prolog WebAssembly build as an NPM package. Please see this page
44
for ongoing progress and information:
55
<https://swi-prolog.discourse.group/t/swi-prolog-in-the-browser-using-wasm/5650>
66

77
## Quickly Getting Started
88

9-
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:
1111

1212
script.mjs
1313
```js
@@ -21,8 +21,8 @@ async function main() {
2121
main();
2222
```
2323

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:
2626

2727
```bash
2828
# Make the project directory
@@ -33,8 +33,8 @@ npm init
3333
npm i swipl-wasm
3434
```
3535

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.
3838

3939
## Usage
4040

@@ -59,15 +59,15 @@ In browser:
5959
</script>
6060
```
6161

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
6464
should be served along with `swipl-web.js` under the `/dist/swipl`
6565
directory in the web server.
6666

6767
You can run this example by executing `npm run test:serve-http` and
6868
visiting <http://localhost:8080/examples/browser.html>.
6969

70-
In Nodejs:
70+
In Node.js:
7171

7272
```js
7373
const SWIPL = require("swipl-wasm");
@@ -78,10 +78,10 @@ console.log(swipl.prolog.query("member(X, [a, b, c]).").once().X);
7878

7979
You can run this example with `node examples/run-on-node.js`.
8080

81-
## Using single-file bundle
81+
## Using Single-File Bundle
8282

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
8585
the `.js` file instead.
8686

8787
```html
@@ -98,9 +98,9 @@ the `.js` file instead.
9898
</script>
9999
```
100100

101-
## Generating an image
101+
## Generating an Image
102102

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:
104104

105105
```ts
106106
import SWIPL from './max';
@@ -116,7 +116,7 @@ main();
116116

117117
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.
118118

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.
120120

121121
## Running JavaScript from Prolog
122122

@@ -137,41 +137,43 @@ bundler for large-scale frontend projects.
137137

138138
There is an example Webpack project in `examples/webpack`. It uses
139139
[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
141141
fed to `locateFile` (see above).
142142

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,
144144
you would declare `swipl-wasm` as a normal dependency.
145145

146146
To start the example:
147147

148148
```
149149
cd examples/webpack
150150
npm install
151-
npm build
151+
npm run build
152152
npm run server
153153
```
154154

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
156156
Prolog".
157157

158158

159159
## Browser Builds
160160

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:
162164

163-
There is a bundled version for each release - which can be found at the url:
164-
<p align=center>
165+
```
165166
https://SWI-Prolog.github.io/npm-swipl-wasm/vMajor/vMinor/vPatch/index.js
167+
```
166168

167-
for instance v3.3.0 has the url https://SWI-Prolog.github.io/npm-swipl-wasm/3/3/0/index.js. We also have shortcuts for:
169+
For instance, v3.3.0 has the URL https://SWI-Prolog.github.io/npm-swipl-wasm/3/3/0/index.js. We also have shortcuts for:
168170
- the latest version https://SWI-Prolog.github.io/npm-swipl-wasm/latest/index.js,
169171
- the latest of each major version https://SWI-Prolog.github.io/npm-swipl-wasm/vMajor/latest/index.js, and
170172
- the latest of each minor version https://SWI-Prolog.github.io/npm-swipl-wasm/vMajor/vMinor/latest/index.js
171173

172174
Available versions can be browsed at https://github.com/SWI-Prolog/npm-swipl-wasm/tree/pages.
173175

174-
With this approach the following script will work
176+
With this approach, the following script will work:
175177

176178
```html
177179
<div id="solution"></div>
@@ -205,9 +207,9 @@ Dynamic imports are also available with the `dynamic-import.js` import name and
205207

206208
## Build
207209

208-
The package can be built using npm. Please use npm to
209-
add new dependencies and update package-lock.json file. SWI-Prolog WebAssembly
210-
version is currently built inside Docker with Emscripten.
210+
The package can be built using npm. Please use npm to add new dependencies
211+
and update the package-lock.json file. The SWI-Prolog WebAssembly version is
212+
currently built inside Docker with Emscripten.
211213

212214
### Development
213215

@@ -222,7 +224,7 @@ npm run build
222224
npm t
223225
```
224226

225-
*Note* You need Docker and Node 16 or higher to installed build the package.
227+
**Note:** You need Docker and Node 16 or higher to be installed to build the package.
226228

227229
## Versioning
228230

@@ -240,14 +242,7 @@ const version = swipl.prolog
240242

241243
The version is returned as integer `10000 × Major + 100 × Minor + Patch`.
242244

243-
## TODO
244-
245-
- Integrate with SWI-Prolog CI
246-
- TypeScript types for Prolog.js (and the Query interface)
247-
- Use EcmaScript modules as output:
248-
<https://github.com/emscripten-core/emscripten/issues/11792>
249-
250245
## License
251246

252-
Same as SWI-Prolog license, BSD simplified:
247+
This package uses the same license as SWI-Prolog (BSD-2-Clause):
253248
<https://github.com/SWI-Prolog/swipl-devel/blob/master/LICENSE>

0 commit comments

Comments
 (0)