swipl-wasm 1.1.0 → 2.0.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 +61 -27
- package/dist/common.d.ts +88 -0
- package/dist/swipl/swipl-web.d.ts +2 -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 +2 -17
- package/dist/swipl/swipl.js +1 -1
- package/dist/swipl-node.d.ts +2 -0
- package/dist/swipl-node.js +17 -0
- package/package.json +22 -56
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -34
- package/dist/locateFile-browser.d.ts +0 -1
- package/dist/locateFile-browser.js +0 -13
- package/dist/locateFile.d.ts +0 -1
- package/dist/locateFile.js +0 -21
- package/dist/swipl/.gitkeep +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const SWIPL = require("./swipl/swipl");
|
|
3
|
+
|
|
4
|
+
// Wraps swipl.js built by Emscripten to provide location for
|
|
5
|
+
// the .data file.
|
|
6
|
+
|
|
7
|
+
module.exports = (options) => {
|
|
8
|
+
return SWIPL({
|
|
9
|
+
locateFile: (url, prefix) => {
|
|
10
|
+
if (url === "swipl-web.data") {
|
|
11
|
+
return path.join(__dirname, "swipl", "swipl-web.data");
|
|
12
|
+
}
|
|
13
|
+
return prefix + url;
|
|
14
|
+
},
|
|
15
|
+
...options,
|
|
16
|
+
});
|
|
17
|
+
};
|
package/package.json
CHANGED
|
@@ -1,38 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swipl-wasm",
|
|
3
|
-
"version": "
|
|
4
|
-
"exports": {
|
|
5
|
-
"./swipl": "./dist/swipl/swipl.js",
|
|
6
|
-
"./swipl-web": "./dist/swipl/swipl-web.js",
|
|
7
|
-
".": "./dist/index.js"
|
|
8
|
-
},
|
|
9
|
-
"main": "./dist/index.js",
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
3
|
+
"version": "2.0.0",
|
|
11
4
|
"contributors": [
|
|
12
5
|
"Raivo Laanemets",
|
|
13
|
-
"Jesse Wright"
|
|
6
|
+
"Jesse Wright",
|
|
7
|
+
"Jan Wielemaker"
|
|
14
8
|
],
|
|
15
9
|
"license": "BSD-2-Clause",
|
|
16
10
|
"type": "commonjs",
|
|
17
11
|
"devDependencies": {
|
|
18
12
|
"@types/emscripten": "^1.39.6",
|
|
19
|
-
"@types/jest": "^29.0.0",
|
|
20
13
|
"@types/node": "^18.7.14",
|
|
21
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
22
|
-
"@typescript-eslint/parser": "^5.
|
|
23
|
-
"
|
|
24
|
-
"eslint": "^8.23.0",
|
|
14
|
+
"@typescript-eslint/eslint-plugin": "^5.39.0",
|
|
15
|
+
"@typescript-eslint/parser": "^5.39.0",
|
|
16
|
+
"eslint": "^8.24.0",
|
|
25
17
|
"http-server": "^14.1.1",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
18
|
+
"mocha": "^10.0.0",
|
|
19
|
+
"node-static": "^0.7.11",
|
|
28
20
|
"npm-run-all": "^4.1.5",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"typescript": "^4.8.2"
|
|
32
|
-
},
|
|
33
|
-
"browser": {
|
|
34
|
-
"./dist/locateFile.js": "./dist/locateFile-browser.js",
|
|
35
|
-
"./dist/swipl/swipl.js": "./dist/swipl/swipl-web.js"
|
|
21
|
+
"puppeteer": "^18.0.5",
|
|
22
|
+
"typescript": "^4.8.4"
|
|
36
23
|
},
|
|
37
24
|
"files": [
|
|
38
25
|
"dist"
|
|
@@ -41,40 +28,19 @@
|
|
|
41
28
|
"build:wasm-docker:build": "docker build -t swipl-wasm-image docker",
|
|
42
29
|
"build:wasm-docker:create": "docker create --name swipl-wasm swipl-wasm-image",
|
|
43
30
|
"build:wasm-docker:remove": "docker rm swipl-wasm",
|
|
44
|
-
"build:wasm-docker:extract:data": "docker cp swipl-wasm:/swipl-devel/
|
|
45
|
-
"build:wasm-docker:extract:wasm": "docker cp swipl-wasm:/swipl-devel/
|
|
46
|
-
"build:wasm-docker:extract:web": "docker cp swipl-wasm:/swipl-devel/
|
|
47
|
-
"build:wasm-docker:extract:node": "docker cp swipl-wasm:/swipl-devel/
|
|
31
|
+
"build:wasm-docker:extract:data": "docker cp swipl-wasm:/swipl-devel/build.wasm/src/swipl-web.data dist/swipl/swipl-web.data",
|
|
32
|
+
"build:wasm-docker:extract:wasm": "docker cp swipl-wasm:/swipl-devel/build.wasm/src/swipl-web.wasm dist/swipl/swipl-web.wasm",
|
|
33
|
+
"build:wasm-docker:extract:web": "docker cp swipl-wasm:/swipl-devel/build.wasm/src/swipl-web.js dist/swipl/swipl-web.js",
|
|
34
|
+
"build:wasm-docker:extract:node": "docker cp swipl-wasm:/swipl-devel/build.wasm/src/swipl-web.js dist/swipl/swipl.js",
|
|
48
35
|
"build:wasm-docker:extract": "run-s build:wasm-docker:extract:*",
|
|
49
36
|
"build:wasm-docker": "run-s build:wasm-docker:build build:wasm-docker:create build:wasm-docker:extract build:wasm-docker:remove",
|
|
50
|
-
"build
|
|
51
|
-
"build:tsc:copy": "copyfiles -u 1 \"src/**/*.d.ts\" dist",
|
|
52
|
-
"build:tsc": "run-s build:tsc:*",
|
|
53
|
-
"build": "run-s build:*",
|
|
54
|
-
"prepare": "yarn run build",
|
|
37
|
+
"build": "run-s build:wasm-docker",
|
|
55
38
|
"test:serve-http": "http-server . -c-1",
|
|
56
|
-
"test": "
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
"json-summary",
|
|
64
|
-
"text",
|
|
65
|
-
"lcov"
|
|
66
|
-
],
|
|
67
|
-
"coverageThreshold": {
|
|
68
|
-
"global": {
|
|
69
|
-
"branches": 10,
|
|
70
|
-
"functions": 10,
|
|
71
|
-
"lines": 10,
|
|
72
|
-
"statements": 10
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
"pre-commit": [
|
|
77
|
-
"lint",
|
|
78
|
-
"test"
|
|
79
|
-
]
|
|
39
|
+
"test:node": "mocha tests/node.js --timeout 20000",
|
|
40
|
+
"test:browser": "mocha tests/browser.js --timeout 20000",
|
|
41
|
+
"test": "run-s test:node test:browser",
|
|
42
|
+
"lint:types": "eslint dist --ext .ts",
|
|
43
|
+
"lint:tests": "eslint tests --ext .js",
|
|
44
|
+
"lint": "run-s lint:types lint:tests"
|
|
45
|
+
}
|
|
80
46
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function locateFile(url: string): string;
|
|
@@ -1,13 +0,0 @@
|
|
|
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;
|
package/dist/locateFile.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function locateFile(url: string): string;
|
package/dist/locateFile.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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;
|
package/dist/swipl/.gitkeep
DELETED
|
File without changes
|