deepclause-sdk 0.0.86 → 0.0.88

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.
@@ -17,11 +17,19 @@ interface FSFilesystems {
17
17
  NODEFS: unknown;
18
18
  MEMFS: unknown;
19
19
  }
20
+ interface SWIPLFileSystem {
21
+ filesystems: FSFilesystems;
22
+ mount(type: unknown, options: {
23
+ root: string;
24
+ }, mountpoint: string): void;
25
+ unmount(mountpoint: string): void;
26
+ mkdir(path: string): void;
27
+ writeFile(path: string, data: string): void;
28
+ unlink(path: string): void;
29
+ }
20
30
  export interface SWIPLModule {
21
31
  prolog: Prolog;
22
- FS: typeof FS & {
23
- filesystems: FSFilesystems;
24
- };
32
+ FS: SWIPLFileSystem;
25
33
  }
26
34
  /**
27
35
  * Load and initialize SWI-Prolog WASM
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/prolog/loader.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,UAAU,KAAK;IACb,IAAI,IAAI,OAAO,CAAC;IAChB,IAAI,IAAI,OAAO,CAAC;CACjB;AAGD,UAAU,MAAM;IACd,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC;IACzE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC;IAC5D,OAAO,CACL,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,OAAO,EACf,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,GACnD,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB;AAGD,UAAU,aAAa;IACrB,MAAM,EAAE,OAAO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qCAAqC;IACrC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAEzB,qFAAqF;IACrF,qGAAqG;IACrG,IAAI,CAAC;QACH,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,6EAA6E;IAC/E,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAC,KAAkB;IAC3C,kEAAkE;IAClE,gFAAgF;IAChF,MAAM,WAAW,GAAG;QAClB,uBAAuB;QACvB,kBAAkB;QAClB,wBAAwB;KACzB,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;QAC/B,iCAAiC;QACjC,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;QAC9C,MAAM,OAAO,GAAG,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAElD,mCAAmC;QACnC,MAAM,QAAQ,GAAG,QAAQ,IAAI,EAAE,CAAC;QAChC,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAEtC,mBAAmB;QACnB,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,QAAQ,IAAI,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC"}
@@ -1687,6 +1687,28 @@ mi_call(fail, _StateIn, _StateOut) :-
1687
1687
  mi_call(false, _StateIn, _StateOut) :-
1688
1688
  fail.
1689
1689
 
1690
+ %% mi_call(assertz(Head), +StateIn, -StateOut)
1691
+ %% mi_call(asserta(Head), +StateIn, -StateOut)
1692
+ %% mi_call(retract(Head), +StateIn, -StateOut)
1693
+ %% mi_call(retractall(Head), +StateIn, -StateOut)
1694
+ %% Database predicates must operate on the session module so DML-side facts
1695
+ %% (draft/4, claim/3, ...) are asserted/retracted in the right module.
1696
+ mi_call(assertz(Head), StateIn, StateIn) :-
1697
+ get_session_id(SessionId),
1698
+ assertz(SessionId:Head).
1699
+
1700
+ mi_call(asserta(Head), StateIn, StateIn) :-
1701
+ get_session_id(SessionId),
1702
+ asserta(SessionId:Head).
1703
+
1704
+ mi_call(retract(Head), StateIn, StateIn) :-
1705
+ get_session_id(SessionId),
1706
+ retract(SessionId:Head).
1707
+
1708
+ mi_call(retractall(Head), StateIn, StateIn) :-
1709
+ get_session_id(SessionId),
1710
+ retractall(SessionId:Head).
1711
+
1690
1712
  %% ============================================================
1691
1713
  %% List Predicates - Interpreted for proper state threading
1692
1714
  %% ============================================================
@@ -2201,6 +2223,10 @@ is_mi_special_predicate(!).
2201
2223
  is_mi_special_predicate(true).
2202
2224
  is_mi_special_predicate(fail).
2203
2225
  is_mi_special_predicate(false).
2226
+ is_mi_special_predicate(assertz(_)).
2227
+ is_mi_special_predicate(asserta(_)).
2228
+ is_mi_special_predicate(retract(_)).
2229
+ is_mi_special_predicate(retractall(_)).
2204
2230
  is_mi_special_predicate(_:_).
2205
2231
  %% List predicates
2206
2232
  is_mi_special_predicate(member(_,_)).
@@ -2305,12 +2331,9 @@ mi_call_dispatch(Goal, StateIn, StateOut) :-
2305
2331
  clause(SessionId:Goal, Body),
2306
2332
  NewDepth is Depth + 1,
2307
2333
  set_depth(StateIn, NewDepth, State1),
2308
- ( mi_call(Body, State1, State2)
2309
- -> add_trace_entry(SessionId, exit, Functor, Args, Depth),
2310
- set_depth(State2, Depth, StateOut)
2311
- ; add_trace_entry(SessionId, fail, Functor, Args, Depth),
2312
- fail
2313
- )
2334
+ mi_call(Body, State1, State2),
2335
+ add_trace_entry(SessionId, exit, Functor, Args, Depth),
2336
+ set_depth(State2, Depth, StateOut)
2314
2337
  ).
2315
2338
 
2316
2339
  mi_call_dispatch(Goal, StateIn, StateIn) :-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepclause-sdk",
3
- "version": "0.0.86",
3
+ "version": "0.0.88",
4
4
  "description": "DeepClause CLI Tool, TUI and Typescript SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -54,12 +54,12 @@
54
54
  "@types/node": "^20.0.0",
55
55
  "@typescript-eslint/eslint-plugin": "^7.0.0",
56
56
  "@typescript-eslint/parser": "^7.0.0",
57
- "@vitest/coverage-v8": "^2.0.0",
57
+ "@vitest/coverage-v8": "^4.1.10",
58
58
  "eslint": "^8.57.0",
59
59
  "memfs": "^4.56.10",
60
60
  "tsx": "^4.21.0",
61
61
  "typescript": "^5.5.0",
62
- "vitest": "^2.0.0"
62
+ "vitest": "^4.1.10"
63
63
  },
64
64
  "engines": {
65
65
  "node": ">=18.0.0"
@@ -1687,6 +1687,28 @@ mi_call(fail, _StateIn, _StateOut) :-
1687
1687
  mi_call(false, _StateIn, _StateOut) :-
1688
1688
  fail.
1689
1689
 
1690
+ %% mi_call(assertz(Head), +StateIn, -StateOut)
1691
+ %% mi_call(asserta(Head), +StateIn, -StateOut)
1692
+ %% mi_call(retract(Head), +StateIn, -StateOut)
1693
+ %% mi_call(retractall(Head), +StateIn, -StateOut)
1694
+ %% Database predicates must operate on the session module so DML-side facts
1695
+ %% (draft/4, claim/3, ...) are asserted/retracted in the right module.
1696
+ mi_call(assertz(Head), StateIn, StateIn) :-
1697
+ get_session_id(SessionId),
1698
+ assertz(SessionId:Head).
1699
+
1700
+ mi_call(asserta(Head), StateIn, StateIn) :-
1701
+ get_session_id(SessionId),
1702
+ asserta(SessionId:Head).
1703
+
1704
+ mi_call(retract(Head), StateIn, StateIn) :-
1705
+ get_session_id(SessionId),
1706
+ retract(SessionId:Head).
1707
+
1708
+ mi_call(retractall(Head), StateIn, StateIn) :-
1709
+ get_session_id(SessionId),
1710
+ retractall(SessionId:Head).
1711
+
1690
1712
  %% ============================================================
1691
1713
  %% List Predicates - Interpreted for proper state threading
1692
1714
  %% ============================================================
@@ -2201,6 +2223,10 @@ is_mi_special_predicate(!).
2201
2223
  is_mi_special_predicate(true).
2202
2224
  is_mi_special_predicate(fail).
2203
2225
  is_mi_special_predicate(false).
2226
+ is_mi_special_predicate(assertz(_)).
2227
+ is_mi_special_predicate(asserta(_)).
2228
+ is_mi_special_predicate(retract(_)).
2229
+ is_mi_special_predicate(retractall(_)).
2204
2230
  is_mi_special_predicate(_:_).
2205
2231
  %% List predicates
2206
2232
  is_mi_special_predicate(member(_,_)).
@@ -2305,12 +2331,9 @@ mi_call_dispatch(Goal, StateIn, StateOut) :-
2305
2331
  clause(SessionId:Goal, Body),
2306
2332
  NewDepth is Depth + 1,
2307
2333
  set_depth(StateIn, NewDepth, State1),
2308
- ( mi_call(Body, State1, State2)
2309
- -> add_trace_entry(SessionId, exit, Functor, Args, Depth),
2310
- set_depth(State2, Depth, StateOut)
2311
- ; add_trace_entry(SessionId, fail, Functor, Args, Depth),
2312
- fail
2313
- )
2334
+ mi_call(Body, State1, State2),
2335
+ add_trace_entry(SessionId, exit, Functor, Args, Depth),
2336
+ set_depth(State2, Depth, StateOut)
2314
2337
  ).
2315
2338
 
2316
2339
  mi_call_dispatch(Goal, StateIn, StateIn) :-
@@ -1,253 +0,0 @@
1
- # swipl-wasm
2
-
3
- SWI-Prolog WebAssembly build as a NPM package. Please see this page
4
- for ongoing progress and information:
5
- <https://swi-prolog.discourse.group/t/swi-prolog-in-the-browser-using-wasm/5650>
6
-
7
- ## Quickly Getting Started
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:
11
-
12
- script.mjs
13
- ```js
14
- import SWIPL from "swipl-wasm";
15
-
16
- async function main() {
17
- const swipl = await SWIPL({ arguments: ["-q"] });
18
- console.log(swipl.prolog.query("member(X, [a, b, c]).").once().X);
19
- }
20
-
21
- main();
22
- ```
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:
26
-
27
- ```bash
28
- # Make the project directory
29
- mkdir my-swipl-project && cd ./my-swipl-project
30
- # Initialise the project
31
- npm init
32
- # Install swipl-wasm
33
- npm i swipl-wasm
34
- ```
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.
38
-
39
- ## Usage
40
-
41
- In browser:
42
-
43
- ```html
44
- <div id="solution"></div>
45
- <script src="/dist/swipl/swipl-web.js"></script>
46
- <script>
47
- (async () => {
48
- const swipl = await SWIPL({
49
- arguments: ["-q"],
50
- locateFile: (path) => {
51
- return `/dist/swipl/${path}`;
52
- },
53
- });
54
- const query = "member(X, [a, b, c]).";
55
- const solutionElement = document.getElementById("solution");
56
- const firstSolution = swipl.prolog.query(query).once().X;
57
- solutionElement.textContent = firstSolution;
58
- })();
59
- </script>
60
- ```
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
64
- should be served along with `swipl-web.js` under the `/dist/swipl`
65
- directory in the web server.
66
-
67
- You can run this example by executing `npm run test:serve-http` and
68
- visiting <http://localhost:8080/examples/browser.html>.
69
-
70
- In Nodejs:
71
-
72
- ```js
73
- const SWIPL = require("swipl-wasm");
74
-
75
- const swipl = await SWIPL({ arguments: ["-q"] });
76
- console.log(swipl.prolog.query("member(X, [a, b, c]).").once().X);
77
- ```
78
-
79
- You can run this example with `node examples/run-on-node.js`.
80
-
81
- ## Using single-file bundle
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
85
- the `.js` file instead.
86
-
87
- ```html
88
- <div id="solution"></div>
89
- <script src="/dist/swipl/swipl-bundle.js"></script>
90
- <script>
91
- (async () => {
92
- const swipl = await SWIPL({ arguments: ["-q"] });
93
- const query = "member(X, [a, b, c]).";
94
- const solutionElement = document.getElementById("solution");
95
- const firstSolution = swipl.prolog.query(query).once().X;
96
- solutionElement.textContent = firstSolution;
97
- })();
98
- </script>
99
- ```
100
-
101
- ## Generating an image
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: `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
-
105
- ```ts
106
- import SWIPL from './max';
107
-
108
- async function main() {
109
- const Module = await SWIPL();
110
- const res = Module.prolog.query('max(1, 2, 3).');
111
- console.log(res.next())
112
- }
113
-
114
- main();
115
- ```
116
-
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
-
119
- To generate the image data without it pre-loaded into `SWIPL` use the `--image-only` flag.
120
-
121
- ## Running JavaScript from Prolog
122
-
123
- This uses `eval`:
124
-
125
- ```js
126
- swipl.prolog
127
- .query("js_run_script(Script)", {
128
- Script: `console.log('hello')`,
129
- })
130
- .once();
131
- ```
132
-
133
- ## Using with Webpack
134
-
135
- [Webpack](https://webpack.js.org/) is a JavaScript and resources
136
- bundler for large-scale frontend projects.
137
-
138
- There is an example Webpack project in `examples/webpack`. It uses
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
141
- fed to `locateFile` (see above).
142
-
143
- The package `swipl-wasm` is linked into the example. In an actual project
144
- you would declare `swipl-wasm` as a normal dependency.
145
-
146
- To start the example:
147
-
148
- ```
149
- cd examples/webpack
150
- npm install
151
- npm build
152
- npm run server
153
- ```
154
-
155
- and visit <http://127.0.0.1:8080>. You should see the message "Hello world from
156
- Prolog".
157
-
158
-
159
- ## Browser Builds
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.
162
-
163
- There is a bundled version for each release - which can be found at the url:
164
- <p align=center>
165
- https://SWI-Prolog.github.io/npm-swipl-wasm/vMajor/vMinor/vPatch/index.js
166
-
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:
168
- - the latest version https://SWI-Prolog.github.io/npm-swipl-wasm/latest/index.js,
169
- - the latest of each major version https://SWI-Prolog.github.io/npm-swipl-wasm/vMajor/latest/index.js, and
170
- - the latest of each minor version https://SWI-Prolog.github.io/npm-swipl-wasm/vMajor/vMinor/latest/index.js
171
-
172
- Available versions can be browsed at https://github.com/SWI-Prolog/npm-swipl-wasm/tree/pages.
173
-
174
- With this approach the following script will work
175
-
176
- ```html
177
- <div id="solution"></div>
178
- <script src="https://SWI-Prolog.github.io/npm-swipl-wasm/3/3/0/index.js"></script>
179
- <script>
180
- (async () => {
181
- const swipl = await SWIPL({ arguments: ["-q"] });
182
- const query = "member(X, [a, b, c]).";
183
- const solutionElement = document.getElementById("solution");
184
- const firstSolution = swipl.prolog.query(query).once().X;
185
- solutionElement.textContent = firstSolution;
186
- })();
187
- </script>
188
- ```
189
-
190
- Dynamic imports are also available with the `dynamic-import.js` import name and can be used as follows:
191
-
192
- ```html
193
- <div id="solution"></div>
194
- <script>
195
- (async () => {
196
- const { SWIPL } = await import("https://SWI-Prolog.github.io/npm-swipl-wasm/3/3/0/dynamic-import.js");
197
- const swipl = await SWIPL({ arguments: ["-q"] });
198
- const query = "member(X, [a, b, c]).";
199
- const solutionElement = document.getElementById("solution");
200
- const firstSolution = swipl.prolog.query(query).once().X;
201
- solutionElement.textContent = firstSolution;
202
- })();
203
- </script>
204
- ```
205
-
206
- ## Build
207
-
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.
211
-
212
- ### Development
213
-
214
- To develop with this package, clone the repository and run:
215
-
216
- ```
217
- # Install dependencies
218
- npm ci
219
- # Build the WebAssembly
220
- npm run build
221
- # Run tests
222
- npm t
223
- ```
224
-
225
- *Note* You need Docker and Node 16 or higher to installed build the package.
226
-
227
- ## Versioning
228
-
229
- The package uses its own versioning scheme using semver. It is
230
- detached from the versioning of SWI-Prolog itself.
231
-
232
- To get the underlying SWI-Prolog version:
233
-
234
- ```js
235
- const swipl = await SWIPL({ arguments: ["-q"] });
236
- const version = swipl.prolog
237
- .query("current_prolog_flag(version, Version)")
238
- .once().Version;
239
- ```
240
-
241
- The version is returned as integer `10000 × Major + 100 × Minor + Patch`.
242
-
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
- ## License
251
-
252
- Same as SWI-Prolog license, BSD simplified:
253
- <https://github.com/SWI-Prolog/swipl-devel/blob/master/LICENSE>