swipl-wasm 1.0.1 → 1.0.3
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/dist/index.d.ts +9 -0
- package/dist/index.js +34 -0
- package/dist/locateFile-browser.d.ts +1 -0
- package/dist/locateFile-browser.js +13 -0
- package/dist/locateFile.d.ts +1 -0
- package/dist/locateFile.js +21 -0
- package/dist/swipl/swipl-web.data +0 -0
- package/dist/swipl/swipl-web.js +1 -1
- package/dist/swipl/swipl-web.wasm +0 -0
- package/dist/swipl/swipl.d.ts +27 -0
- package/dist/swipl/swipl.js +1 -1
- package/package.json +30 -6
- package/docker/Dockerfile +0 -53
- package/docker/build-all.sh +0 -29
- package/examples/browser.html +0 -32
- package/examples/run-on-node.js +0 -23
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SwiplOptions, SwiplModule } from './swipl/swipl';
|
|
2
|
+
export default function SWIPLIsomorphic(args: SwiplOptions): Promise<SwiplModule>;
|
|
3
|
+
/**
|
|
4
|
+
* A utility function for executing queries
|
|
5
|
+
* @param str The query
|
|
6
|
+
* @returns The results object
|
|
7
|
+
*/
|
|
8
|
+
export declare function query(str: string): Promise<any>;
|
|
9
|
+
export { SwiplOptions, SwiplModule } from './swipl/swipl';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.query = void 0;
|
|
16
|
+
const swipl_1 = __importDefault(require("./swipl/swipl"));
|
|
17
|
+
const locateFile_1 = require("./locateFile");
|
|
18
|
+
function SWIPLIsomorphic(args) {
|
|
19
|
+
return (0, swipl_1.default)(Object.assign({ locateFile: locateFile_1.locateFile, noInitialRun: true, arguments: ["-q"] }, args));
|
|
20
|
+
}
|
|
21
|
+
exports.default = SWIPLIsomorphic;
|
|
22
|
+
/**
|
|
23
|
+
* A utility function for executing queries
|
|
24
|
+
* @param str The query
|
|
25
|
+
* @returns The results object
|
|
26
|
+
*/
|
|
27
|
+
function query(str) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const swipl = yield SWIPLIsomorphic({});
|
|
30
|
+
// See https://swi-prolog.discourse.group/t/swi-prolog-in-the-browser-using-wasm/5650/1
|
|
31
|
+
return swipl.prolog.query(str);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
exports.query = query;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function locateFile(url: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.locateFile = void 0;
|
|
4
|
+
function locateFile(url) {
|
|
5
|
+
if (url === "swipl-web.data") {
|
|
6
|
+
return "/dist/swipl/swipl-web.data";
|
|
7
|
+
}
|
|
8
|
+
else if (url === "swipl-web.wasm") {
|
|
9
|
+
return "/dist/swipl/swipl-web.wasm";
|
|
10
|
+
}
|
|
11
|
+
return url;
|
|
12
|
+
}
|
|
13
|
+
exports.locateFile = locateFile;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function locateFile(url: string): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.locateFile = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
// This helps to find the correct locations of the
|
|
9
|
+
// .data and .wasm files.
|
|
10
|
+
const swiplModuleLocation = require.resolve("swipl-wasm/swipl");
|
|
11
|
+
function locateFile(url) {
|
|
12
|
+
// These are common with the web version.
|
|
13
|
+
if (url === "swipl-web.data") {
|
|
14
|
+
return path_1.default.join(path_1.default.dirname(swiplModuleLocation), "swipl-web.data");
|
|
15
|
+
}
|
|
16
|
+
else if (url === "swipl-web.wasm") {
|
|
17
|
+
return path_1.default.join(path_1.default.dirname(swiplModuleLocation), "swipl-web.wasm");
|
|
18
|
+
}
|
|
19
|
+
return url;
|
|
20
|
+
}
|
|
21
|
+
exports.locateFile = locateFile;
|
|
Binary file
|