swipl-wasm 3.0.0 → 3.1.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
@@ -38,12 +38,34 @@ visiting <http://localhost:8080/examples/browser.html>.
38
38
  In Nodejs:
39
39
 
40
40
  ```js
41
+ const SWIPL = require("swipl-wasm/dist/swipl");
42
+
41
43
  const swipl = await SWIPL({ arguments: ["-q"] });
42
44
  console.log(swipl.prolog.query("member(X, [a, b, c]).").once().X);
43
45
  ```
44
46
 
45
47
  You can run this example with `node examples/run-on-node.js`.
46
48
 
49
+ ## Using single-file bundle
50
+
51
+ The `swipl-wasm` package comes also with the single-file bundle. This does not
52
+ require distributing the `.data` and `.wasm` files which are now embedded into
53
+ the `.js` file instead.
54
+
55
+ ```html
56
+ <div id="solution"></div>
57
+ <script src="/dist/swipl/swipl-bundle.js"></script>
58
+ <script>
59
+ (async () => {
60
+ const swipl = await SWIPL({ arguments: ["-q"] });
61
+ const query = "member(X, [a, b, c]).";
62
+ const solutionElement = document.getElementById("solution");
63
+ const firstSolution = swipl.prolog.query(query).once().X;
64
+ solutionElement.textContent = firstSolution;
65
+ })();
66
+ </script>
67
+ ```
68
+
47
69
  ## Running JavaScript from Prolog
48
70
 
49
71
  This uses `eval`:
@@ -0,0 +1,2 @@
1
+ import SWIPL = require("./common");
2
+ export = SWIPL;
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require("./swipl/swipl-bundle");
@@ -0,0 +1,2 @@
1
+ import SWIPL = require("../common");
2
+ export = SWIPL;