Skip to content

Commit 0cb5f81

Browse files
committed
v0.7.1
1 parent ec11a4b commit 0cb5f81

30 files changed

+706
-321
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
build
3-
coverage
3+
coverage
4+
__pycache__

CHANGE.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
## v0.7.1
2+
3+
- Running Python libraries is implemented.
4+
15
## v0.7.0
26

3-
- Running C, C++, Go and Rust is implemented.
7+
- Running C-shared libraries is implemented.
48

59
## v0.6.1
610

@@ -12,7 +16,6 @@
1216
- New tests are added to the platform lib.
1317
- Running WebAssembly modules is implemented.
1418

15-
1619
## v0.5.15
1720

1821
- New tests are added to the platform lib.

apps/sample/browser-tensorflow/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"dependencies": {
99
"@tensorflow/tfjs": "^4.2.0",
10-
"@bitair/concurrent.js": "^0.7.0",
10+
"@bitair/concurrent.js": "^0.7.1",
1111
"http-server": "^14.1.1"
1212
},
1313
"devDependencies": {

apps/sample/browser-wasm/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"start": "npx http-server static"
77
},
88
"dependencies": {
9-
"@bitair/concurrent.js": "^0.7.0",
9+
"@bitair/concurrent.js": "^0.7.1",
1010
"http-server": "^14.1.1"
1111
},
1212
"devDependencies": {

apps/sample/browser/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"dependencies": {
88
"http-server": "^14.1.1",
9-
"@bitair/concurrent.js": "^0.7.0",
9+
"@bitair/concurrent.js": "^0.7.1",
1010
"extra-bigint": "^1.1.10"
1111
},
1212
"devDependencies": {

apps/sample/deno/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { concurrent } from 'https://deno.land/x/[email protected].0/mod.ts'
1+
import { concurrent } from 'https://deno.land/x/[email protected].1/mod.ts'
22

33
const { factorial } = await concurrent.import(new URL('./services/index.ts', import.meta.url)).load()
44

apps/sample/node/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"dependencies": {
1313
"extra-bigint": "^1.1.10",
14-
"@bitair/concurrent.js": "^0.7.0"
14+
"@bitair/concurrent.js": "^0.7.1"
1515
},
1616
"devDependencies": {
1717
"@tsconfig/strictest": "^1.0.2",

dist/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"type": "module",
33
"name": "@bitair/concurrent.js",
4-
"version": "0.7.0",
4+
"version": "0.7.1",
55
"description": "Easy Multithreading for JavaScript (Node.js, Deno & Browser)",
66
"main": "src/node/index.js",
77
"browser": "src/browser/index.js",

dist/src/browser/index.js

+17-10
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var __publicField = (obj, key, value) => {
1313
var constants_exports = {};
1414
__export(constants_exports, {
1515
ErrorMessage: () => ErrorMessage,
16-
ExternFunctionReturnType: () => ExternFunctionReturnType,
16+
ExternReturnType: () => ExternReturnType,
1717
ModuleExt: () => ModuleExt,
1818
TaskType: () => TaskType,
1919
ThreadMessageType: () => ThreadMessageType,
@@ -87,15 +87,16 @@ var defaultConcurrencySettings = Object.assign(
8787
var ModuleExt = /* @__PURE__ */ ((ModuleExt2) => {
8888
ModuleExt2["WASM"] = ".wasm";
8989
ModuleExt2["SO"] = ".so";
90+
ModuleExt2["PY"] = ".py";
9091
return ModuleExt2;
9192
})(ModuleExt || {});
92-
var ExternFunctionReturnType = /* @__PURE__ */ ((ExternFunctionReturnType2) => {
93-
ExternFunctionReturnType2[ExternFunctionReturnType2["ArrayBuffer"] = 0] = "ArrayBuffer";
94-
ExternFunctionReturnType2[ExternFunctionReturnType2["Boolean"] = 1] = "Boolean";
95-
ExternFunctionReturnType2[ExternFunctionReturnType2["Number"] = 2] = "Number";
96-
ExternFunctionReturnType2[ExternFunctionReturnType2["String"] = 3] = "String";
97-
return ExternFunctionReturnType2;
98-
})(ExternFunctionReturnType || {});
93+
var ExternReturnType = /* @__PURE__ */ ((ExternReturnType2) => {
94+
ExternReturnType2[ExternReturnType2["ArrayBuffer"] = 0] = "ArrayBuffer";
95+
ExternReturnType2[ExternReturnType2["Boolean"] = 1] = "Boolean";
96+
ExternReturnType2[ExternReturnType2["Number"] = 2] = "Number";
97+
ExternReturnType2[ExternReturnType2["String"] = 3] = "String";
98+
return ExternReturnType2;
99+
})(ExternReturnType || {});
99100

100101
// libs/platform/src/core/utils.ts
101102
function isBoolean(val) {
@@ -154,11 +155,17 @@ function createObject(properties) {
154155
return obj;
155156
}
156157
function isNativeModule(moduleSrc) {
157-
if (moduleSrc.endsWith(".wasm" /* WASM */) || moduleSrc.endsWith(".so" /* SO */))
158+
if (moduleSrc.endsWith(".wasm" /* WASM */) || moduleSrc.endsWith(".so" /* SO */) || moduleSrc.endsWith(".py" /* PY */))
158159
return false;
159160
else
160161
return true;
161162
}
163+
function isExternModule(moduleSrc) {
164+
if (moduleSrc.endsWith(".so" /* SO */) || moduleSrc.endsWith(".py" /* PY */))
165+
return true;
166+
else
167+
return false;
168+
}
162169

163170
// libs/platform/src/core/error.ts
164171
var ConcurrencyError = class extends Error {
@@ -284,7 +291,7 @@ var ConcurrentModule = class {
284291
if (!Reflect.has(cache, key)) {
285292
const threadedFunction = new ThreadedFunction(thread, moduleSrc, key);
286293
Reflect.set(cache, key, (...params) => {
287-
if (moduleSrc.endsWith(".so" /* SO */))
294+
if (isExternModule(moduleSrc))
288295
return threadedFunction.invoke([params, self.options.extern]);
289296
else
290297
return threadedFunction.invoke(params);

dist/src/browser/worker_script.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function createObject(properties) {
123123
return obj;
124124
}
125125
function isNativeModule(moduleSrc) {
126-
if (moduleSrc.endsWith(".wasm" /* WASM */) || moduleSrc.endsWith(".so" /* SO */))
126+
if (moduleSrc.endsWith(".wasm" /* WASM */) || moduleSrc.endsWith(".so" /* SO */) || moduleSrc.endsWith(".py" /* PY */))
127127
return false;
128128
else
129129
return true;

dist/src/deno/index.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,17 @@ function createObject(properties) {
149149
return obj;
150150
}
151151
function isNativeModule(moduleSrc) {
152-
if (moduleSrc.endsWith(".wasm" /* WASM */) || moduleSrc.endsWith(".so" /* SO */))
152+
if (moduleSrc.endsWith(".wasm" /* WASM */) || moduleSrc.endsWith(".so" /* SO */) || moduleSrc.endsWith(".py" /* PY */))
153153
return false;
154154
else
155155
return true;
156156
}
157+
function isExternModule(moduleSrc) {
158+
if (moduleSrc.endsWith(".so" /* SO */) || moduleSrc.endsWith(".py" /* PY */))
159+
return true;
160+
else
161+
return false;
162+
}
157163

158164
// libs/platform/src/core/error.ts
159165
var ConcurrencyError = class extends Error {
@@ -279,7 +285,7 @@ var ConcurrentModule = class {
279285
if (!Reflect.has(cache, key)) {
280286
const threadedFunction = new ThreadedFunction(thread, moduleSrc, key);
281287
Reflect.set(cache, key, (...params) => {
282-
if (moduleSrc.endsWith(".so" /* SO */))
288+
if (isExternModule(moduleSrc))
283289
return threadedFunction.invoke([params, self.options.extern]);
284290
else
285291
return threadedFunction.invoke(params);

dist/src/deno/worker_script.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var __publicField = (obj, key, value) => {
1313
var constants_exports = {};
1414
__export(constants_exports, {
1515
ErrorMessage: () => ErrorMessage,
16-
ExternFunctionReturnType: () => ExternFunctionReturnType,
16+
ExternReturnType: () => ExternReturnType,
1717
ModuleExt: () => ModuleExt,
1818
TaskType: () => TaskType,
1919
ThreadMessageType: () => ThreadMessageType,
@@ -87,15 +87,16 @@ var defaultConcurrencySettings = Object.assign(
8787
var ModuleExt = /* @__PURE__ */ ((ModuleExt2) => {
8888
ModuleExt2["WASM"] = ".wasm";
8989
ModuleExt2["SO"] = ".so";
90+
ModuleExt2["PY"] = ".py";
9091
return ModuleExt2;
9192
})(ModuleExt || {});
92-
var ExternFunctionReturnType = /* @__PURE__ */ ((ExternFunctionReturnType2) => {
93-
ExternFunctionReturnType2[ExternFunctionReturnType2["ArrayBuffer"] = 0] = "ArrayBuffer";
94-
ExternFunctionReturnType2[ExternFunctionReturnType2["Boolean"] = 1] = "Boolean";
95-
ExternFunctionReturnType2[ExternFunctionReturnType2["Number"] = 2] = "Number";
96-
ExternFunctionReturnType2[ExternFunctionReturnType2["String"] = 3] = "String";
97-
return ExternFunctionReturnType2;
98-
})(ExternFunctionReturnType || {});
93+
var ExternReturnType = /* @__PURE__ */ ((ExternReturnType2) => {
94+
ExternReturnType2[ExternReturnType2["ArrayBuffer"] = 0] = "ArrayBuffer";
95+
ExternReturnType2[ExternReturnType2["Boolean"] = 1] = "Boolean";
96+
ExternReturnType2[ExternReturnType2["Number"] = 2] = "Number";
97+
ExternReturnType2[ExternReturnType2["String"] = 3] = "String";
98+
return ExternReturnType2;
99+
})(ExternReturnType || {});
99100

100101
// libs/platform/src/core/utils.ts
101102
function isSymbol(val) {
@@ -155,7 +156,7 @@ function createObject(properties) {
155156
return obj;
156157
}
157158
function isNativeModule(moduleSrc) {
158-
if (moduleSrc.endsWith(".wasm" /* WASM */) || moduleSrc.endsWith(".so" /* SO */))
159+
if (moduleSrc.endsWith(".wasm" /* WASM */) || moduleSrc.endsWith(".so" /* SO */) || moduleSrc.endsWith(".py" /* PY */))
159160
return false;
160161
else
161162
return true;

dist/src/index.d.cts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
declare const concurrent: IConcurrent
2-
export { concurrent, ExternFunctionReturnType }
2+
export { concurrent, ExternReturnType }
33

44
export declare interface IConcurrent {
55
config(settings: Partial<ConcurrencySettings>): void
@@ -27,9 +27,9 @@ export type ModuleImportOptions = Partial<{
2727
}
2828
}>
2929

30-
declare enum ExternFunctionReturnType {
30+
declare enum ExternReturnType {
3131
ArrayBuffer,
3232
Boolean,
3333
Number,
3434
String
35-
}
35+
}

dist/src/index.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
declare const concurrent: IConcurrent
2-
export { concurrent, ExternFunctionReturnType }
2+
export { concurrent, ExternReturnType }
33

44
export declare interface IConcurrent {
55
config(settings: Partial<ConcurrencySettings>): void
@@ -27,9 +27,9 @@ export type ModuleImportOptions = Partial<{
2727
}
2828
}>
2929

30-
declare enum ExternFunctionReturnType {
30+
declare enum ExternReturnType {
3131
ArrayBuffer,
3232
Boolean,
3333
Number,
3434
String
35-
}
35+
}

dist/src/node/index.cjs

+17-11
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var __publicField = (obj, key, value) => {
2525
// libs/platform/src/node/index.cts
2626
var node_exports = {};
2727
__export(node_exports, {
28-
ExternFunctionReturnType: () => ExternFunctionReturnType,
28+
ExternReturnType: () => ExternReturnType,
2929
concurrent: () => concurrent
3030
});
3131
module.exports = __toCommonJS(node_exports);
@@ -119,13 +119,13 @@ var defaultConcurrencySettings = Object.assign(
119119
},
120120
defaultThreadPoolSettings
121121
);
122-
var ExternFunctionReturnType = /* @__PURE__ */ ((ExternFunctionReturnType2) => {
123-
ExternFunctionReturnType2[ExternFunctionReturnType2["ArrayBuffer"] = 0] = "ArrayBuffer";
124-
ExternFunctionReturnType2[ExternFunctionReturnType2["Boolean"] = 1] = "Boolean";
125-
ExternFunctionReturnType2[ExternFunctionReturnType2["Number"] = 2] = "Number";
126-
ExternFunctionReturnType2[ExternFunctionReturnType2["String"] = 3] = "String";
127-
return ExternFunctionReturnType2;
128-
})(ExternFunctionReturnType || {});
122+
var ExternReturnType = /* @__PURE__ */ ((ExternReturnType2) => {
123+
ExternReturnType2[ExternReturnType2["ArrayBuffer"] = 0] = "ArrayBuffer";
124+
ExternReturnType2[ExternReturnType2["Boolean"] = 1] = "Boolean";
125+
ExternReturnType2[ExternReturnType2["Number"] = 2] = "Number";
126+
ExternReturnType2[ExternReturnType2["String"] = 3] = "String";
127+
return ExternReturnType2;
128+
})(ExternReturnType || {});
129129

130130
// libs/platform/src/core/utils.ts
131131
function isBoolean(val) {
@@ -184,11 +184,17 @@ function createObject(properties) {
184184
return obj;
185185
}
186186
function isNativeModule(moduleSrc) {
187-
if (moduleSrc.endsWith(".wasm" /* WASM */) || moduleSrc.endsWith(".so" /* SO */))
187+
if (moduleSrc.endsWith(".wasm" /* WASM */) || moduleSrc.endsWith(".so" /* SO */) || moduleSrc.endsWith(".py" /* PY */))
188188
return false;
189189
else
190190
return true;
191191
}
192+
function isExternModule(moduleSrc) {
193+
if (moduleSrc.endsWith(".so" /* SO */) || moduleSrc.endsWith(".py" /* PY */))
194+
return true;
195+
else
196+
return false;
197+
}
192198

193199
// libs/platform/src/core/error.ts
194200
var ConcurrencyError = class extends Error {
@@ -314,7 +320,7 @@ var ConcurrentModule = class {
314320
if (!Reflect.has(cache, key)) {
315321
const threadedFunction = new ThreadedFunction(thread, moduleSrc, key);
316322
Reflect.set(cache, key, (...params) => {
317-
if (moduleSrc.endsWith(".so" /* SO */))
323+
if (isExternModule(moduleSrc))
318324
return threadedFunction.invoke([params, self.options.extern]);
319325
else
320326
return threadedFunction.invoke(params);
@@ -587,6 +593,6 @@ var concurrent = new Master({
587593
});
588594
// Annotate the CommonJS export names for ESM import in node:
589595
0 && (module.exports = {
590-
ExternFunctionReturnType,
596+
ExternReturnType,
591597
concurrent
592598
});

dist/src/node/index.js

+16-10
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ var defaultConcurrencySettings = Object.assign(
9494
},
9595
defaultThreadPoolSettings
9696
);
97-
var ExternFunctionReturnType = /* @__PURE__ */ ((ExternFunctionReturnType2) => {
98-
ExternFunctionReturnType2[ExternFunctionReturnType2["ArrayBuffer"] = 0] = "ArrayBuffer";
99-
ExternFunctionReturnType2[ExternFunctionReturnType2["Boolean"] = 1] = "Boolean";
100-
ExternFunctionReturnType2[ExternFunctionReturnType2["Number"] = 2] = "Number";
101-
ExternFunctionReturnType2[ExternFunctionReturnType2["String"] = 3] = "String";
102-
return ExternFunctionReturnType2;
103-
})(ExternFunctionReturnType || {});
97+
var ExternReturnType = /* @__PURE__ */ ((ExternReturnType2) => {
98+
ExternReturnType2[ExternReturnType2["ArrayBuffer"] = 0] = "ArrayBuffer";
99+
ExternReturnType2[ExternReturnType2["Boolean"] = 1] = "Boolean";
100+
ExternReturnType2[ExternReturnType2["Number"] = 2] = "Number";
101+
ExternReturnType2[ExternReturnType2["String"] = 3] = "String";
102+
return ExternReturnType2;
103+
})(ExternReturnType || {});
104104

105105
// libs/platform/src/core/utils.ts
106106
function isBoolean(val) {
@@ -159,11 +159,17 @@ function createObject(properties) {
159159
return obj;
160160
}
161161
function isNativeModule(moduleSrc) {
162-
if (moduleSrc.endsWith(".wasm" /* WASM */) || moduleSrc.endsWith(".so" /* SO */))
162+
if (moduleSrc.endsWith(".wasm" /* WASM */) || moduleSrc.endsWith(".so" /* SO */) || moduleSrc.endsWith(".py" /* PY */))
163163
return false;
164164
else
165165
return true;
166166
}
167+
function isExternModule(moduleSrc) {
168+
if (moduleSrc.endsWith(".so" /* SO */) || moduleSrc.endsWith(".py" /* PY */))
169+
return true;
170+
else
171+
return false;
172+
}
167173

168174
// libs/platform/src/core/error.ts
169175
var ConcurrencyError = class extends Error {
@@ -289,7 +295,7 @@ var ConcurrentModule = class {
289295
if (!Reflect.has(cache, key)) {
290296
const threadedFunction = new ThreadedFunction(thread, moduleSrc, key);
291297
Reflect.set(cache, key, (...params) => {
292-
if (moduleSrc.endsWith(".so" /* SO */))
298+
if (isExternModule(moduleSrc))
293299
return threadedFunction.invoke([params, self.options.extern]);
294300
else
295301
return threadedFunction.invoke(params);
@@ -561,6 +567,6 @@ var concurrent = new Master({
561567
}
562568
});
563569
export {
564-
ExternFunctionReturnType,
570+
ExternReturnType,
565571
concurrent
566572
};

0 commit comments

Comments
 (0)