swipl-wasm 3.2.1 → 3.3.0
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
|
@@ -123,6 +123,54 @@ npm run server
|
|
|
123
123
|
and visit <http://127.0.0.1:8080>. You should see the message "Hello world from
|
|
124
124
|
Prolog".
|
|
125
125
|
|
|
126
|
+
|
|
127
|
+
## Browser Builds
|
|
128
|
+
|
|
129
|
+
For convenience we provide deploy bundled versions of the SWI-Prolog on github pages which can be directly used in an HTML document.
|
|
130
|
+
|
|
131
|
+
There is a bundled version for each release - which can be found at the url:
|
|
132
|
+
<p align=center>
|
|
133
|
+
https://SWI-Prolog.github.io/npm-swipl-wasm/vMajor/vMinor/vPatch/index.js
|
|
134
|
+
|
|
135
|
+
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:
|
|
136
|
+
- the latest version https://SWI-Prolog.github.io/npm-swipl-wasm/latest/index.js,
|
|
137
|
+
- the latest of each major version https://SWI-Prolog.github.io/npm-swipl-wasm/vMajor/latest/index.js, and
|
|
138
|
+
- the latest of each minor version https://SWI-Prolog.github.io/npm-swipl-wasm/vMajor/vMinor/latest/index.js
|
|
139
|
+
|
|
140
|
+
Available versions can be browsed at https://github.com/SWI-Prolog/npm-swipl-wasm/tree/pages.
|
|
141
|
+
|
|
142
|
+
With this approach the following script will work
|
|
143
|
+
|
|
144
|
+
```html
|
|
145
|
+
<div id="solution"></div>
|
|
146
|
+
<script src="https://SWI-Prolog.github.io/npm-swipl-wasm/3/3/0/index.js"></script>
|
|
147
|
+
<script>
|
|
148
|
+
(async () => {
|
|
149
|
+
const swipl = await SWIPL({ arguments: ["-q"] });
|
|
150
|
+
const query = "member(X, [a, b, c]).";
|
|
151
|
+
const solutionElement = document.getElementById("solution");
|
|
152
|
+
const firstSolution = swipl.prolog.query(query).once().X;
|
|
153
|
+
solutionElement.textContent = firstSolution;
|
|
154
|
+
})();
|
|
155
|
+
</script>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Dynamic imports are also available with the `dynamic-import.js` import name and can be used as follows:
|
|
159
|
+
|
|
160
|
+
```html
|
|
161
|
+
<div id="solution"></div>
|
|
162
|
+
<script>
|
|
163
|
+
(async () => {
|
|
164
|
+
const { SWIPL } = await import("https://SWI-Prolog.github.io/npm-swipl-wasm/3/3/0/dynamic-import.js");
|
|
165
|
+
const swipl = await SWIPL({ arguments: ["-q"] });
|
|
166
|
+
const query = "member(X, [a, b, c]).";
|
|
167
|
+
const solutionElement = document.getElementById("solution");
|
|
168
|
+
const firstSolution = swipl.prolog.query(query).once().X;
|
|
169
|
+
solutionElement.textContent = firstSolution;
|
|
170
|
+
})();
|
|
171
|
+
</script>
|
|
172
|
+
```
|
|
173
|
+
|
|
126
174
|
## Build
|
|
127
175
|
|
|
128
176
|
The package can be built using npm or yarn. Please use yarn to
|