drop bun support, add deno compile support

This commit is contained in:
2026-02-16 23:27:00 -08:00
parent 52d9e33b46
commit 8ba7b78854
8 changed files with 134 additions and 234 deletions
+1
View File
@@ -0,0 +1 @@
@sugoidogo:registry=https://gitea.sugoidogo.com/api/packages/sugoidogo/npm/
+88 -198
View File
@@ -9,16 +9,36 @@
"version": "0.1.0",
"license": "LGPL-3.0-or-later",
"dependencies": {
"hardware-concurrency": "^0.1.4",
"web-worker": "^1.5.0"
},
"devDependencies": {
"@types/node": "^24.10.1",
"@types/web": "^0.0.294",
"bun": "^1.3.3",
"@sugoidogo/importable-types-web": "^1.0.0",
"@sugoidogo/node-web-globals": "^2.0.0",
"@types/node": "^25.2.3",
"deno": "^2.5.6",
"typescript": "^5.9.3"
}
},
"node_modules/@blackglory/types": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/@blackglory/types/-/types-1.4.0.tgz",
"integrity": "sha512-pOVWHkbM6wGGBmAgc6zKGRyds4amAV9GOYOiWQp7McaTp8QREDQZlcIrgTwQKtA9StBrKm/GC874RpDg/AIf7g==",
"license": "MIT",
"dependencies": {
"justypes": "^3.0.0",
"lodash": "^4.17.21"
},
"engines": {
"node": ">=12"
}
},
"node_modules/@blackglory/types/node_modules/justypes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/justypes/-/justypes-3.1.2.tgz",
"integrity": "sha512-XPx3j+Og45DhqXqROKgmUzZ7DMBKL7xQbAfwTjouXVYUY72ydc1BEpO2ygIj1K674UPmSq8YQpkoq/B7RrtuSA==",
"license": "MIT"
},
"node_modules/@deno/darwin-arm64": {
"version": "2.5.6",
"resolved": "https://registry.npmjs.org/@deno/darwin-arm64/-/darwin-arm64-2.5.6.tgz",
@@ -103,210 +123,42 @@
"win32"
]
},
"node_modules/@oven/bun-darwin-aarch64": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/@oven/bun-darwin-aarch64/-/bun-darwin-aarch64-1.3.3.tgz",
"integrity": "sha512-eJopQrUk0WR7jViYDC29+Rp50xGvs4GtWOXBeqCoFMzutkkO3CZvHehA4JqnjfWMTSS8toqvRhCSOpOz62Wf9w==",
"cpu": [
"arm64"
],
"node_modules/@sugoidogo/importable-types-web": {
"version": "1.0.0",
"resolved": "https://gitea.sugoidogo.com/api/packages/sugoidogo/npm/%40sugoidogo%2Fimportable-types-web/-/1.0.0/importable-types-web-1.0.0.tgz",
"integrity": "sha512-MqWkQ/WsllO7GiQjqWiFB3ZzsDwJwGPXIWkyd0E24d3CMcI0FKGgsOn6G/RVjCO9k2d/aRlzxqVmyuPAYOZ8tQ==",
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
]
"license": "Apache-2.0",
"dependencies": {
"undici-types": "^7.16.0"
}
},
"node_modules/@oven/bun-darwin-x64": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64/-/bun-darwin-x64-1.3.3.tgz",
"integrity": "sha512-xGDePueVFrNgkS+iN0QdEFeRrx2MQ5hQ9ipRFu7N73rgoSSJsFlOKKt2uGZzunczedViIfjYl0ii0K4E9aZ0Ow==",
"cpu": [
"x64"
],
"node_modules/@sugoidogo/node-web-globals": {
"version": "2.0.0",
"resolved": "https://gitea.sugoidogo.com/api/packages/sugoidogo/npm/%40sugoidogo%2Fnode-web-globals/-/2.0.0/node-web-globals-2.0.0.tgz",
"integrity": "sha512-bPFW3kBVj5pmshivjLQE/ZWKs4+6hx2rQc7YSgzK9RX48pjAeJ9/9p5/45M3Wg4KIxNi+8Jz7WpIntcDYovuHA==",
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
]
},
"node_modules/@oven/bun-darwin-x64-baseline": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64-baseline/-/bun-darwin-x64-baseline-1.3.3.tgz",
"integrity": "sha512-1ij4wQ9ECLFf1XFry+IFUN+28if40ozDqq6+QtuyOhIwraKzXOlAUbILhRMGvM3ED3yBex2mTwlKpA4Vja/V2g==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
]
},
"node_modules/@oven/bun-linux-aarch64": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64/-/bun-linux-aarch64-1.3.3.tgz",
"integrity": "sha512-DabZ3Mt1XcJneWdEEug8l7bCPVvDBRBpjUIpNnRnMFWFnzr8KBEpMcaWTwYOghjXyJdhB4MPKb19MwqyQ+FHAw==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@oven/bun-linux-aarch64-musl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64-musl/-/bun-linux-aarch64-musl-1.3.3.tgz",
"integrity": "sha512-XWQ3tV/gtZj0wn2AdSUq/tEOKWT4OY+Uww70EbODgrrq00jxuTfq5nnYP6rkLD0M/T5BHJdQRSfQYdIni9vldw==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@oven/bun-linux-x64": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/@oven/bun-linux-x64/-/bun-linux-x64-1.3.3.tgz",
"integrity": "sha512-7eIARtKZKZDtah1aCpQUj/1/zT/zHRR063J6oAxZP9AuA547j5B9OM2D/vi/F4En7Gjk9FPjgPGTSYeqpQDzJw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@oven/bun-linux-x64-baseline": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-baseline/-/bun-linux-x64-baseline-1.3.3.tgz",
"integrity": "sha512-IU8pxhIf845psOv55LqJyL+tSUc6HHMfs6FGhuJcAnyi92j+B1HjOhnFQh9MW4vjoo7do5F8AerXlvk59RGH2w==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@oven/bun-linux-x64-musl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-musl/-/bun-linux-x64-musl-1.3.3.tgz",
"integrity": "sha512-xNSDRPn1yyObKteS8fyQogwsS4eCECswHHgaKM+/d4wy/omZQrXn8ZyGm/ZF9B73UfQytUfbhE7nEnrFq03f0w==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@oven/bun-linux-x64-musl-baseline": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-musl-baseline/-/bun-linux-x64-musl-baseline-1.3.3.tgz",
"integrity": "sha512-JoRTPdAXRkNYouUlJqEncMWUKn/3DiWP03A7weBbtbsKr787gcdNna2YeyQKCb1lIXE4v1k18RM3gaOpQobGIQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@oven/bun-windows-x64": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/@oven/bun-windows-x64/-/bun-windows-x64-1.3.3.tgz",
"integrity": "sha512-kWqa1LKvDdAIzyfHxo3zGz3HFWbFHDlrNK77hKjUN42ycikvZJ+SHSX76+1OW4G8wmLETX4Jj+4BM1y01DQRIQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
]
},
"node_modules/@oven/bun-windows-x64-baseline": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/@oven/bun-windows-x64-baseline/-/bun-windows-x64-baseline-1.3.3.tgz",
"integrity": "sha512-u5eZHKq6TPJSE282KyBOicGQ2trkFml0RoUfqkPOJVo7TXGrsGYYzdsugZRnVQY/WEmnxGtBy4T3PAaPqgQViA==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
]
"license": "Apache-2.0",
"dependencies": {
"undici-types": "^7.21.0"
}
},
"node_modules/@types/node": {
"version": "24.10.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.1.tgz",
"integrity": "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ==",
"version": "25.2.3",
"resolved": "https://registry.npmjs.org/@types/node/-/node-25.2.3.tgz",
"integrity": "sha512-m0jEgYlYz+mDJZ2+F4v8D1AyQb+QzsNqRuI7xg1VQX/KlKS0qT9r1Mo16yo5F/MtifXFgaofIFsdFMox2SxIbQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"undici-types": "~7.16.0"
}
},
"node_modules/@types/web": {
"version": "0.0.294",
"resolved": "https://registry.npmjs.org/@types/web/-/web-0.0.294.tgz",
"integrity": "sha512-prZi2M3jd/lGeOhW9P3txXfn6/nXIJRn+w/aFHz94/dl04riO5V99n+sKSeIciq7FM2XY6wPWoNhNbm6S/AdMQ==",
"node_modules/@types/node/node_modules/undici-types": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz",
"integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==",
"dev": true,
"license": "Apache-2.0"
},
"node_modules/bun": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/bun/-/bun-1.3.3.tgz",
"integrity": "sha512-2hJ4ocTZ634/Ptph4lysvO+LbbRZq8fzRvMwX0/CqaLBxrF2UB5D1LdMB8qGcdtCer4/VR9Bx5ORub0yn+yzmw==",
"cpu": [
"arm64",
"x64"
],
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"os": [
"darwin",
"linux",
"win32"
],
"bin": {
"bun": "bin/bun.exe",
"bunx": "bin/bunx.exe"
},
"optionalDependencies": {
"@oven/bun-darwin-aarch64": "1.3.3",
"@oven/bun-darwin-x64": "1.3.3",
"@oven/bun-darwin-x64-baseline": "1.3.3",
"@oven/bun-linux-aarch64": "1.3.3",
"@oven/bun-linux-aarch64-musl": "1.3.3",
"@oven/bun-linux-x64": "1.3.3",
"@oven/bun-linux-x64-baseline": "1.3.3",
"@oven/bun-linux-x64-musl": "1.3.3",
"@oven/bun-linux-x64-musl-baseline": "1.3.3",
"@oven/bun-windows-x64": "1.3.3",
"@oven/bun-windows-x64-baseline": "1.3.3"
}
"license": "MIT"
},
"node_modules/deno": {
"version": "2.5.6",
@@ -327,6 +179,33 @@
"@deno/win32-x64": "2.5.6"
}
},
"node_modules/hardware-concurrency": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/hardware-concurrency/-/hardware-concurrency-0.1.4.tgz",
"integrity": "sha512-Xov0kaNNuaM32f1rzI7vMNEqzMmgIJubjqVQYvveZ8iooLnoSySX6mHyXFEpP6BUQFEKZXST6Fg0mYfBkSmn5Q==",
"license": "MIT",
"dependencies": {
"value-getter": "^0.2.3"
}
},
"node_modules/hotypes": {
"version": "0.4.8",
"resolved": "https://registry.npmjs.org/hotypes/-/hotypes-0.4.8.tgz",
"integrity": "sha512-+f8NqgoFOee1owm+QD4/rJCgPQyQYMbvLK2M0LWrPf1NPbN6v4SrsewzxgreRVauKhrxNL3z1bdjyEAj+ArqPA==",
"license": "MIT"
},
"node_modules/justypes": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/justypes/-/justypes-2.3.0.tgz",
"integrity": "sha512-DXRU5+tXXEdFscEbI5cF+suUEx0vEyUM1UbyyX1swbnx5+3QmzYWVmsEXImGfwHRxrsB7g4bL/rr+5VNDH5SEg==",
"license": "MIT"
},
"node_modules/lodash": {
"version": "4.17.23",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz",
"integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==",
"license": "MIT"
},
"node_modules/typescript": {
"version": "5.9.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
@@ -342,12 +221,23 @@
}
},
"node_modules/undici-types": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz",
"integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==",
"version": "7.22.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.22.0.tgz",
"integrity": "sha512-RKZvifiL60xdsIuC80UY0dq8Z7DbJUV8/l2hOVbyZAxBzEeQU4Z58+4ZzJ6WN2Lidi9KzT5EbiGX+PI/UGYuRw==",
"dev": true,
"license": "MIT"
},
"node_modules/value-getter": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/value-getter/-/value-getter-0.2.4.tgz",
"integrity": "sha512-JOIhJZhuOlwso0Ri/dzvxjplbPWFWqvuvDqCWxMaLt0gCKOVuOfI8LRcq+t91YYgZS9NwsLcSAkNI7jxRJnBwQ==",
"license": "MIT",
"dependencies": {
"@blackglory/types": "^1.1.0",
"hotypes": "^0.4.4",
"justypes": "^2.0.0"
}
},
"node_modules/web-worker": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/web-worker/-/web-worker-1.5.0.tgz",
+4 -3
View File
@@ -26,13 +26,14 @@
"prepack": "tsc"
},
"devDependencies": {
"@types/node": "^24.10.1",
"@types/web": "^0.0.294",
"bun": "^1.3.3",
"@sugoidogo/importable-types-web": "^1.0.0",
"@sugoidogo/node-web-globals": "^2.0.0",
"@types/node": "^25.2.3",
"deno": "^2.5.6",
"typescript": "^5.9.3"
},
"dependencies": {
"hardware-concurrency": "^0.1.4",
"web-worker": "^1.5.0"
}
}
+18 -16
View File
@@ -1,18 +1,20 @@
addEventListener('message', async function (messageEvent) {
const response:any={id:messageEvent.data.id}
try {
response.value = await new Function(`return ${messageEvent.data.func}`)()(...messageEvent.data.args)
} catch (reason) {
if (reason instanceof Error) {
reason = {
name: reason.name,
message: reason.message,
stack: reason.stack,
cause: reason.cause
if ('addEventListener' in globalThis) {
addEventListener('message', async function (messageEvent) {
const response:any={id:messageEvent.data.id}
try {
response.value = await new Function(`return ${messageEvent.data.func}`)()(...messageEvent.data.args)
} catch (reason) {
if (reason instanceof Error) {
reason = {
name: reason.name,
message: reason.message,
stack: reason.stack,
cause: reason.cause
}
}
response.reason=reason
} finally {
postMessage(response)
}
response.reason=reason
} finally {
postMessage(response)
}
})
})
}
+4 -12
View File
@@ -1,14 +1,6 @@
if (!globalThis.Worker) {
globalThis.Worker = await import('web-worker').then(module => module.default)
}
// @ts-expect-error
const defaultThreads = await import('node:os').then(module => module.cpus().length).catch(() => {
if (navigator && navigator.hardwareConcurrency) {
return navigator.hardwareConcurrency
} else {
return 1
}
})
import Worker from 'web-worker'
import { minus1Cores } from 'hardware-concurrency'
import './worker.js' // deno compile compatibility
export default class WorkerlessPool {
#workers: Worker[] = []
@@ -31,7 +23,7 @@ export default class WorkerlessPool {
delete this.#callbacks[messageEvent.data.id]
}
/** allocates a number of workers for this pool, defaulting to the cpu thread count */
constructor(threads = defaultThreads) {
constructor(threads = minus1Cores()) {
for (let i = 0; i < threads; i++) {
const worker = new Worker(new URL('worker.js', import.meta.url), { 'type': 'module' })
worker.onmessage = (messageEvent) => this.#onWorkerMessage(messageEvent)
+7 -3
View File
@@ -1,8 +1,12 @@
import { execSync } from "node:child_process";
import { unlinkSync } from "node:fs";
console.log('testing with node')
execSync('node test/test.ts', { 'stdio': 'inherit' })
console.log('\ntesting with deno')
execSync('deno run --allow-sys=cpus --allow-read=dist/worker.js test/test.ts', { 'stdio': 'inherit' })
console.log('\ntesting with bun')
execSync('bun run test/test.ts', { 'stdio': 'inherit' })
execSync('deno run --allow-all test/test.ts', { 'stdio': 'inherit' })
console.log('testing with deno compile')
execSync('deno compile --allow-all --no-check --output test/test.exe test/test.ts', { 'stdio': 'inherit' })
execSync('test/test.exe', { 'stdio': 'inherit' })
console.log('cleaning up test files')
unlinkSync('test/test.exe')
+9
View File
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"target": "es2022",
"module": "es2022",
"moduleResolution": "node",
"lib": ["ES2022"],
"types": ["node"]
}
}
+3 -2
View File
@@ -3,13 +3,14 @@
"target": "es2022",
"module": "es2022",
"moduleResolution": "node",
"lib": ["ESNext"],
"lib": ["ES2022","WebWorker"],
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"outDir": "dist",
"skipLibCheck": true,
"types": [
"web"
"@sugoidogo/node-web-globals"
]
},
"include": [