swipl-wasm 5.2.2 → 5.2.4

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/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # swipl-wasm
2
2
 
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
4
4
  for ongoing progress and information:
5
5
  <https://swi-prolog.discourse.group/t/swi-prolog-in-the-browser-using-wasm/5650>
6
6
 
7
7
  ## Quickly Getting Started
8
8
 
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:
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
68
68
  visiting <http://localhost:8080/examples/browser.html>.
69
69
 
70
- In Nodejs:
70
+ In Node.js:
71
71
 
72
72
  ```js
73
73
  const SWIPL = require("swipl-wasm");
@@ -78,10 +78,10 @@ console.log(swipl.prolog.query("member(X, [a, b, c]).").once().X);
78
78
 
79
79
  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
  import SWIPL from './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,10 +137,10 @@ 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:
@@ -148,30 +148,32 @@ To start the example:
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:
164
- <p align=center>
165
+ ```
165
166
  https://SWI-Prolog.github.io/npm-swipl-wasm/vMajor/vMinor/vPatch/index.js
167
+ ```
166
168
 
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:
168
170
  - the latest version https://SWI-Prolog.github.io/npm-swipl-wasm/latest/index.js,
169
171
  - the latest of each major version https://SWI-Prolog.github.io/npm-swipl-wasm/vMajor/latest/index.js, and
170
172
  - the latest of each minor version https://SWI-Prolog.github.io/npm-swipl-wasm/vMajor/vMinor/latest/index.js
171
173
 
172
174
  Available versions can be browsed at https://github.com/SWI-Prolog/npm-swipl-wasm/tree/pages.
173
175
 
174
- With this approach the following script will work
176
+ With this approach, the following script will work:
175
177
 
176
178
  ```html
177
179
  <div id="solution"></div>
@@ -205,9 +207,9 @@ Dynamic imports are also available with the `dynamic-import.js` import name and
205
207
 
206
208
  ## Build
207
209
 
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.
211
213
 
212
214
  ### Development
213
215
 
@@ -222,7 +224,7 @@ npm run build
222
224
  npm t
223
225
  ```
224
226
 
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.
226
228
 
227
229
  ## Versioning
228
230
 
@@ -240,14 +242,7 @@ const version = swipl.prolog
240
242
 
241
243
  The version is returned as integer `10000 × Major + 100 × Minor + Patch`.
242
244
 
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
-
250
245
  ## License
251
246
 
252
- Same as SWI-Prolog license, BSD simplified:
247
+ This package uses the same license as SWI-Prolog (BSD-2-Clause):
253
248
  <https://github.com/SWI-Prolog/swipl-devel/blob/master/LICENSE>