diff --git a/package-lock.json b/package-lock.json index 835489b67..0677a2e7a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,7 +47,7 @@ "cypress": "^10.10.0", "cz-conventional-changelog": "2.1.0", "file-api": "^0.10.4", - "glob": "^7.1.6", + "glob": "^8.1.0", "karma": "^6.3.2", "karma-chrome-launcher": "^3.1.0", "karma-tap": "^4.2.0", @@ -2625,6 +2625,26 @@ "rollup": "^2.38.3" } }, + "node_modules/@rollup/plugin-commonjs/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@rollup/plugin-node-resolve": { "version": "13.3.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.3.0.tgz", @@ -5348,6 +5368,26 @@ "node": ">=10" } }, + "node_modules/commitizen/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/commitizen/node_modules/longest": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/longest/-/longest-2.0.1.tgz", @@ -8357,20 +8397,6 @@ "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, - "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -8577,20 +8603,19 @@ } }, "node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "minimatch": "^5.0.1", + "once": "^1.3.0" }, "engines": { - "node": "*" + "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -8614,6 +8639,27 @@ "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", "dev": true }, + "node_modules/glob/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/global-dirs": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-3.0.0.tgz", @@ -10207,6 +10253,46 @@ "webpack": "^5.0.0" } }, + "node_modules/karma-webpack/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/karma/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/karma/node_modules/mime": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", @@ -15548,6 +15634,26 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rimraf/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/rollup": { "version": "2.79.0", "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.0.tgz", @@ -16041,6 +16147,26 @@ "node": ">=6" } }, + "node_modules/shx/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/shx/node_modules/shelljs": { "version": "0.8.5", "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.5.tgz", @@ -17265,6 +17391,26 @@ "tape": "bin/tape" } }, + "node_modules/tape/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/tar-fs": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", @@ -21006,6 +21152,22 @@ "is-reference": "^1.2.1", "magic-string": "^0.25.7", "resolve": "^1.17.0" + }, + "dependencies": { + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } } }, "@rollup/plugin-node-resolve": { @@ -23060,6 +23222,20 @@ "universalify": "^2.0.0" } }, + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "longest": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/longest/-/longest-2.0.1.tgz", @@ -25388,13 +25564,6 @@ "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, - "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "optional": true - }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -25561,17 +25730,36 @@ } }, "glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "dependencies": { + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + } } }, "glob-parent": { @@ -26699,6 +26887,20 @@ "yargs": "^16.1.1" }, "dependencies": { + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "mime": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", @@ -26767,6 +26969,22 @@ "glob": "^7.1.3", "minimatch": "^3.0.4", "webpack-merge": "^4.1.5" + }, + "dependencies": { + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } } }, "kind-of": { @@ -30600,6 +30818,22 @@ "dev": true, "requires": { "glob": "^7.1.3" + }, + "dependencies": { + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } } }, "rollup": { @@ -30987,6 +31221,20 @@ "shelljs": "^0.8.5" }, "dependencies": { + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "shelljs": { "version": "0.8.5", "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.5.tgz", @@ -31937,6 +32185,22 @@ "resumer": "~0.0.0", "string.prototype.trim": "~1.2.6", "through": "~2.3.8" + }, + "dependencies": { + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } } }, "tar-fs": { diff --git a/package.json b/package.json index ee8e8768a..ac58b59f9 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,8 @@ "build:workerMinBundles": "rollup -c rollup.worker.min.config.js ./dist/web-workers/pipeline.worker.js && shx cp ./dist/web-workers/min-bundles/pipeline.worker.js ./dist/web-workers/bundles/pipeline.min.worker.js", "build:webpack": "webpack --mode production --progress --color && webpack --mode development --progress --color", "build:emscripten": "node ./src/build-emscripten.js", - "build:emscripten:compress-stringify": "node ./src/itk-wasm-cli.js -s packages/compress-stringify -b emscripten-build build", + "build:emscripten:compress-stringify": "node ./src/itk-wasm-cli.js -s packages/compress-stringify -b emscripten-build build ", + "build:bindgen:typescript:compress-stringify": "./src/itk-wasm-cli.js -s packages/compress-stringify -b emscripten-build bindgen --package-name itk-compress-stringify --package-description \"Zstandard compression and decompression and base64 encoding and decoding in WebAssembly.\" --repository 'https://github.com/InsightSoftwareConsortium/itk-wasm'", "build:wasi": "node ./src/build-wasi.js", "build:wasi:compress-stringify": "node ./src/itk-wasm-cli.js -i itkwasm/wasi:latest -s packages/compress-stringify -b wasi-build build", "cypress:open": "npx cypress open", @@ -109,7 +110,7 @@ "cypress": "^10.10.0", "cz-conventional-changelog": "2.1.0", "file-api": "^0.10.4", - "glob": "^7.1.6", + "glob": "^8.1.0", "karma": "^6.3.2", "karma-chrome-launcher": "^3.1.0", "karma-tap": "^4.2.0", diff --git a/packages/compress-stringify/typescript/README.md b/packages/compress-stringify/typescript/README.md index 5405253ca..efc85ee51 100644 --- a/packages/compress-stringify/typescript/README.md +++ b/packages/compress-stringify/typescript/README.md @@ -4,9 +4,9 @@ Zstandard compression and decompression and base64 encoding and decoding in WebAssembly. -[**

Example

**](https://itk-compress-stringify-app.on.fleek.co/ ':include :type=iframe width=100% height=800px') +[Example](https://itk-compress-stringify-app.on.fleek.co/ ':include :type=iframe width=100% height=800px') -[**

Documentation

**](https://itk-compress-stringify-docs.on.fleek.co/) +[Documentation](https://itk-compress-stringify-docs.on.fleek.co/) ## Installation @@ -26,6 +26,8 @@ import { parseStringDecompress, setPipelinesBaseUrl, getPipelinesBaseUrl, + setPipelineWorkerUrl, + getPipelineWorkerUrl, } from "itk-compress-stringify" ``` @@ -109,6 +111,24 @@ function setPipelinesBaseUrl( function getPipelinesBaseUrl() : string | URL ``` +#### setPipelineWorkerUrl + +*Set base URL for the itk-wasm pipeline worker script when vendored.* + +```ts +function setPipelineWorkerUrl( + baseUrl: string | URL +) : void +``` + +#### getPipelineWorkerUrl + +*Get base URL for the itk-wasm pipeline worker script when vendored.* + +```ts +function getPipelineWorkerUrl() : string | URL +``` + ### Node interface Import: diff --git a/packages/compress-stringify/typescript/build/vite.config.js b/packages/compress-stringify/typescript/build/vite.config.js index cb96abdb6..c8a55d36e 100644 --- a/packages/compress-stringify/typescript/build/vite.config.js +++ b/packages/compress-stringify/typescript/build/vite.config.js @@ -13,6 +13,7 @@ export default defineConfig({ viteStaticCopy({ targets: [ { src: '../../dist/pipelines/*', dest: 'pipelines' }, + { src: '../../dist/web-workers/*', dest: 'web-workers' }, ], }) ], diff --git a/packages/compress-stringify/typescript/package.json b/packages/compress-stringify/typescript/package.json index 48b430493..a7c2751ac 100644 --- a/packages/compress-stringify/typescript/package.json +++ b/packages/compress-stringify/typescript/package.json @@ -1,6 +1,6 @@ { "name": "itk-compress-stringify", - "version": "0.1.0", + "version": "0.3.0", "description": "Zstandard compression and decompression and base64 encoding and decoding in WebAssembly.", "type": "module", "module": "./dist/bundles/itk-compress-stringify.js", @@ -38,7 +38,7 @@ "author": "", "license": "Apache-2.0", "dependencies": { - "itk-wasm": "^1.0.0-b.57" + "itk-wasm": "^1.0.0-b.62" }, "devDependencies": { "@rollup/plugin-commonjs": "^24.0.0", diff --git a/packages/compress-stringify/typescript/pnpm-lock.yaml b/packages/compress-stringify/typescript/pnpm-lock.yaml index f73dfc6f6..612c5df3a 100644 --- a/packages/compress-stringify/typescript/pnpm-lock.yaml +++ b/packages/compress-stringify/typescript/pnpm-lock.yaml @@ -9,7 +9,7 @@ specifiers: '@types/node': ^18.11.18 ava: ^5.1.0 cypress: ^12.3.0 - itk-wasm: ^1.0.0-b.57 + itk-wasm: ^1.0.0-b.62 rollup: ^3.9.0 rollup-plugin-copy: ^3.4.0 rollup-plugin-ignore: ^1.0.10 @@ -20,7 +20,7 @@ specifiers: vite-plugin-static-copy: ^0.13.0 dependencies: - itk-wasm: 1.0.0-b.57 + itk-wasm: 1.0.0-b.62 devDependencies: '@rollup/plugin-commonjs': 24.0.0_rollup@3.9.1 @@ -1809,8 +1809,8 @@ packages: resolution: {integrity: sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==} dev: true - /itk-wasm/1.0.0-b.57: - resolution: {integrity: sha512-vmVveqWibN0IYrCSQJbQVA4DhBsoW/oyfXnq6J9gYyJEpGBrJb/BVTi0Jvyhb/VnDaJ3k4WYzbuUyLr2dLSAyg==} + /itk-wasm/1.0.0-b.62: + resolution: {integrity: sha512-A5PEHEGtJ/ZPphaa1KNiRF+jSX5RLNjuaEwkRXtRzrRxo7TnDkSQR/vrSNtj9cYL0SQQtLAXjHbDn/UJUAD43A==} hasBin: true dependencies: '@babel/runtime': 7.20.7 @@ -1818,6 +1818,7 @@ packages: axios: 0.23.0 commander: 9.5.0 fs-extra: 10.1.0 + markdown-table: 3.0.3 mime-types: 2.1.35 promise-file-reader: 1.0.3 webworker-promise: 0.4.4 @@ -1971,6 +1972,10 @@ packages: resolution: {integrity: sha512-CkYQrPYZfWnu/DAmVCpTSX/xHpKZ80eKh2lAkyA6AJTef6bW+6JpbQZN5rofum7da+SyN1bi5ctTm+lTfcCW3g==} dev: true + /markdown-table/3.0.3: + resolution: {integrity: sha512-Z1NL3Tb1M9wH4XESsCDEksWoKTdlUafKc4pt0GRwjUyXaCFZ+dc3g2erqB6zm3szA2IUSi7VnPI+o/9jnxh9hw==} + dev: false + /matcher/5.0.0: resolution: {integrity: sha512-s2EMBOWtXFc8dgqvoAzKJXxNHibcdJMV0gwqKUaw9E2JBJuGUK7DrNKrA6g/i+v72TT16+6sVm5mS3thaMLQUw==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} diff --git a/packages/compress-stringify/typescript/src/compress-stringify.ts b/packages/compress-stringify/typescript/src/compress-stringify.ts index 2e83dc1ca..35a4358c0 100644 --- a/packages/compress-stringify/typescript/src/compress-stringify.ts +++ b/packages/compress-stringify/typescript/src/compress-stringify.ts @@ -11,6 +11,9 @@ import CompressStringifyResult from './compress-stringify-result.js' import { getPipelinesBaseUrl } from './pipelines-base-url.js' + +import { getPipelineWorkerUrl } from './pipeline-worker-url.js' + /** * Given a binary, compress and optionally base64 encode. * @@ -55,7 +58,7 @@ async function compressStringify( returnValue, stderr, outputs - } = await runPipeline(webWorker, pipelinePath, args, desiredOutputs, inputs, getPipelinesBaseUrl()) + } = await runPipeline(webWorker, pipelinePath, args, desiredOutputs, inputs, getPipelinesBaseUrl(), getPipelineWorkerUrl()) if (returnValue !== 0) { throw new Error(stderr) } diff --git a/packages/compress-stringify/typescript/src/index.ts b/packages/compress-stringify/typescript/src/index.ts index e1e465c16..c734de2ed 100644 --- a/packages/compress-stringify/typescript/src/index.ts +++ b/packages/compress-stringify/typescript/src/index.ts @@ -1,5 +1,5 @@ export * from './pipelines-base-url.js' - +export * from './pipeline-worker-url.js' import CompressStringifyResult from './compress-stringify-result.js' diff --git a/packages/compress-stringify/typescript/src/parse-string-decompress.ts b/packages/compress-stringify/typescript/src/parse-string-decompress.ts index 645210254..8e063697d 100644 --- a/packages/compress-stringify/typescript/src/parse-string-decompress.ts +++ b/packages/compress-stringify/typescript/src/parse-string-decompress.ts @@ -11,6 +11,9 @@ import ParseStringDecompressResult from './parse-string-decompress-result.js' import { getPipelinesBaseUrl } from './pipelines-base-url.js' + +import { getPipelineWorkerUrl } from './pipeline-worker-url.js' + /** * Given a binary or string produced with compress-stringify, decompress and optionally base64 decode. * @@ -49,7 +52,7 @@ async function parseStringDecompress( returnValue, stderr, outputs - } = await runPipeline(webWorker, pipelinePath, args, desiredOutputs, inputs, getPipelinesBaseUrl()) + } = await runPipeline(webWorker, pipelinePath, args, desiredOutputs, inputs, getPipelinesBaseUrl(), getPipelineWorkerUrl()) if (returnValue !== 0) { throw new Error(stderr) } diff --git a/packages/compress-stringify/typescript/src/pipeline-worker-url.ts b/packages/compress-stringify/typescript/src/pipeline-worker-url.ts new file mode 100644 index 000000000..e3bc77b12 --- /dev/null +++ b/packages/compress-stringify/typescript/src/pipeline-worker-url.ts @@ -0,0 +1,10 @@ +import packageJson from '../package.json' +let pipelineWorkerUrl: string | URL | null = `https://cdn.jsdelivr.net/npm/itk-compress-stringify@${packageJson.version}/dist/web-workers/pipeline.worker.js` + +export function setPipelineWorkerUrl (workerUrl: string | URL | null): void { + pipelineWorkerUrl = workerUrl +} + +export function getPipelineWorkerUrl (): string | URL | null { + return pipelineWorkerUrl +} diff --git a/packages/compress-stringify/typescript/src/pipelines-base-url.ts b/packages/compress-stringify/typescript/src/pipelines-base-url.ts index 4453af190..af0561f20 100644 --- a/packages/compress-stringify/typescript/src/pipelines-base-url.ts +++ b/packages/compress-stringify/typescript/src/pipelines-base-url.ts @@ -1,4 +1,5 @@ -let pipelinesBaseUrl: string | URL = new URL('/pipelines', document.location.origin).href +import packageJson from '../package.json' +let pipelinesBaseUrl: string | URL = `https://cdn.jsdelivr.net/npm/itk-compress-stringify@${packageJson.version}/dist/pipelines` export function setPipelinesBaseUrl (baseUrl: string | URL): void { pipelinesBaseUrl = baseUrl diff --git a/packages/compress-stringify/typescript/test/browser/app.ts b/packages/compress-stringify/typescript/test/browser/app.ts index 03e0938cd..840c05318 100644 --- a/packages/compress-stringify/typescript/test/browser/app.ts +++ b/packages/compress-stringify/typescript/test/browser/app.ts @@ -1,5 +1,11 @@ import * as itkCompressStringify from '../../dist/bundles/itk-compress-stringify.js' +// Use local, vendored WebAssembly module assets +const pipelinesBaseUrl: string | URL = new URL('/pipelines', document.location.origin).href +itkCompressStringify.setPipelinesBaseUrl(pipelinesBaseUrl) +let pipelineWorkerUrl: string | URL | null = new URL('/web-workers/pipeline.worker.js', document.location.origin).href +itkCompressStringify.setPipelineWorkerUrl(pipelineWorkerUrl) + // promise-file-reader function readAsArrayBuffer (file) { @@ -107,7 +113,7 @@ function setupCompressStringify() { form.addEventListener('submit', async (event) => { event.preventDefault() - const { webWorker, output } = await itkCompressStringify.compressStringify(null, ...context.inputs, context.options) + const { webWorker, output } = await itkCompressStringify.compressStringify(null, context.inputs[0].slice(), context.options) webWorker.terminate() context.outputs.output = output @@ -161,7 +167,7 @@ function setupParseStringDecompress() { form.addEventListener('submit', async (event) => { event.preventDefault() - const { webWorker, output } = await itkCompressStringify.parseStringDecompress(null, ...context.inputs, context.options) + const { webWorker, output } = await itkCompressStringify.parseStringDecompress(null, context.inputs[0].slice(), context.options) webWorker.terminate() context.outputs.output = output diff --git a/src/bindgen/typescript-resources/pipeline-worker-url.ts b/src/bindgen/typescript-resources/pipeline-worker-url.ts new file mode 100644 index 000000000..d4e040a87 --- /dev/null +++ b/src/bindgen/typescript-resources/pipeline-worker-url.ts @@ -0,0 +1,11 @@ +// @ts-expect-error error TS2732: Cannot find module '../package.json'. Consider using '--resolveJsonModule' to import module with '.json' extension. +import packageJson from '../package.json' +let pipelineWorkerUrl: string | URL | null = `https://cdn.jsdelivr.net/npm/@${packageJson.version as string}/dist/web-workers/pipeline.worker.js` + +export function setPipelineWorkerUrl (workerUrl: string | URL | null): void { + pipelineWorkerUrl = workerUrl +} + +export function getPipelineWorkerUrl (): string | URL | null { + return pipelineWorkerUrl +} diff --git a/src/bindgen/typescript-resources/pipelines-base-url.ts b/src/bindgen/typescript-resources/pipelines-base-url.ts index 4453af190..1be63f43c 100644 --- a/src/bindgen/typescript-resources/pipelines-base-url.ts +++ b/src/bindgen/typescript-resources/pipelines-base-url.ts @@ -1,4 +1,6 @@ -let pipelinesBaseUrl: string | URL = new URL('/pipelines', document.location.origin).href +// @ts-expect-error error TS2732: Cannot find module '../package.json'. Consider using '--resolveJsonModule' to import module with '.json' extension. +import packageJson from '../package.json' +let pipelinesBaseUrl: string | URL = `https://cdn.jsdelivr.net/npm/@${packageJson.version as string}/dist/pipelines` export function setPipelinesBaseUrl (baseUrl: string | URL): void { pipelinesBaseUrl = baseUrl diff --git a/src/bindgen/typescript-resources/template.package.json b/src/bindgen/typescript-resources/template.package.json index a7bce061a..0e041c56c 100644 --- a/src/bindgen/typescript-resources/template.package.json +++ b/src/bindgen/typescript-resources/template.package.json @@ -30,7 +30,7 @@ "author": "", "license": "Apache-2.0", "dependencies": { - "itk-wasm": "^1.0.0-b.57" + "itk-wasm": "^1.0.0-b.62" }, "devDependencies": { "@rollup/plugin-commonjs": "^24.0.0", diff --git a/src/bindgen/typescript-resources/vite.config.js b/src/bindgen/typescript-resources/vite.config.js index cb96abdb6..c8a55d36e 100644 --- a/src/bindgen/typescript-resources/vite.config.js +++ b/src/bindgen/typescript-resources/vite.config.js @@ -13,6 +13,7 @@ export default defineConfig({ viteStaticCopy({ targets: [ { src: '../../dist/pipelines/*', dest: 'pipelines' }, + { src: '../../dist/web-workers/*', dest: 'web-workers' }, ], }) ], diff --git a/src/bindgen/typescript.js b/src/bindgen/typescript.js index 8ec037640..5156b8ff2 100644 --- a/src/bindgen/typescript.js +++ b/src/bindgen/typescript.js @@ -99,7 +99,8 @@ function typescriptBindings(outputDir, buildDir, wasmBinaries, options, forNode= } if (!forNode) { - indexContent += "export * from './pipelines-base-url.js'\n\n" + indexContent += "export * from './pipelines-base-url.js'\n" + indexContent += "export * from './pipeline-worker-url.js'\n" try { fs.mkdirSync(path.join(outputDir, 'build'), { recursive: true }) } catch (err) { @@ -315,6 +316,7 @@ function typescriptBindings(outputDir, buildDir, wasmBinaries, options, forNode= functionContent += "\nimport path from 'path'\n\n" } else { functionContent += "\nimport { getPipelinesBaseUrl } from './pipelines-base-url.js'\n\n" + functionContent += "\nimport { getPipelineWorkerUrl } from './pipeline-worker-url.js'\n\n" } const readmeParametersTable = [['Parameter', 'Type', 'Description'],] @@ -446,7 +448,7 @@ function typescriptBindings(outputDir, buildDir, wasmBinaries, options, forNode= functionContent += ` const {\n returnValue,\n stderr,\n outputs\n } = await runPipelineNode(pipelinePath, args, desiredOutputs, inputs)\n` } else { functionContent += `\n const pipelinePath = '${moduleKebabCase}'\n\n` - functionContent += ` const {\n webWorker: usedWebWorker,\n returnValue,\n stderr,\n outputs\n } = await runPipeline(webWorker, pipelinePath, args, desiredOutputs, inputs, getPipelinesBaseUrl())\n` + functionContent += ` const {\n webWorker: usedWebWorker,\n returnValue,\n stderr,\n outputs\n } = await runPipeline(webWorker, pipelinePath, args, desiredOutputs, inputs, getPipelinesBaseUrl(), getPipelineWorkerUrl())\n` } functionContent += ' if (returnValue !== 0) {\n throw new Error(stderr)\n }\n\n' @@ -483,6 +485,15 @@ function typescriptBindings(outputDir, buildDir, wasmBinaries, options, forNode= const pipelinesBaseUrlPath = path.join(outputDir, 'src', 'pipelines-base-url.ts') if (!fs.existsSync(pipelinesBaseUrlPath)) { fs.copyFileSync(bindgenResource('pipelines-base-url.ts'), pipelinesBaseUrlPath) + let pipelinesBaseUrlPathContent = fs.readFileSync(bindgenResource('pipelines-base-url.ts'), { encoding: 'utf8', flag: 'r' }) + pipelinesBaseUrlPathContent = pipelinesBaseUrlPathContent.replaceAll('', packageName) + fs.writeFileSync(pipelinesBaseUrlPath, pipelinesBaseUrlPathContent) + } + const pipelineWorkerUrlPath = path.join(outputDir, 'src', 'pipeline-worker-url.ts') + if (!fs.existsSync(pipelineWorkerUrlPath)) { + let pipelineWorkerUrlPathContent = fs.readFileSync(bindgenResource('pipeline-worker-url.ts'), { encoding: 'utf8', flag: 'r' }) + pipelineWorkerUrlPathContent = pipelineWorkerUrlPathContent.replaceAll('', packageName) + fs.writeFileSync(pipelineWorkerUrlPath, pipelineWorkerUrlPathContent) } const itkConfigPath = path.join(outputDir, 'src', 'itkConfig.js') diff --git a/src/browser/index.ts b/src/browser/index.ts index 21ae3a1a7..e890135bb 100644 --- a/src/browser/index.ts +++ b/src/browser/index.ts @@ -2,6 +2,9 @@ export * from '../core/index.js' +export * from '../core/pipeline-worker-url.js' +export * from '../core/pipelines-base-url.js' + export { default as ReadImageResult } from '../io/ReadImageResult.js' export { default as ReadMeshResult } from '../io/ReadMeshResult.js' diff --git a/src/core/pipeline-worker-url.ts b/src/core/pipeline-worker-url.ts new file mode 100644 index 000000000..dd8ff4f21 --- /dev/null +++ b/src/core/pipeline-worker-url.ts @@ -0,0 +1,9 @@ +let pipelineWorkerUrl: string | URL | null | undefined + +export function setPipelineWorkerUrl (workerUrl: string | URL | null): void { + pipelineWorkerUrl = workerUrl +} + +export function getPipelineWorkerUrl (): string | URL | null | undefined { + return pipelineWorkerUrl +} diff --git a/src/core/pipelines-base-url.ts b/src/core/pipelines-base-url.ts new file mode 100644 index 000000000..eb7a221a1 --- /dev/null +++ b/src/core/pipelines-base-url.ts @@ -0,0 +1,9 @@ +let pipelinesBaseUrl: string | URL | undefined + +export function setPipelinesBaseUrl (baseUrl: string | URL): void { + pipelinesBaseUrl = baseUrl +} + +export function getPipelinesBaseUrl (): string | URL | undefined { + return pipelinesBaseUrl +} diff --git a/src/itk-wasm-cli.js b/src/itk-wasm-cli.js index 59c96b953..24f490724 100755 --- a/src/itk-wasm-cli.js +++ b/src/itk-wasm-cli.js @@ -4,17 +4,16 @@ import fs from 'fs-extra' import path from 'path' import { spawnSync } from 'child_process' +import glob from 'glob' import { Command, Option } from 'commander/esm.mjs' import typescriptBindgen from './bindgen/typescript.js' const program = new Command() - -const defaultImageTag = '20230122-5e3aea6c' - // Array of types that will require an import from itk-wasm const typesRequireImport = ['Image'] +const defaultImageTag = '20230122-5e3aea6c' function processCommonOptions() { const options = program.opts() @@ -214,71 +213,18 @@ function run(wasmBinary, options) { } } -function camelCase(param) { - // make any alphabets that follows '-' an uppercase character, and remove the corresponding hyphen - let cameledParam = param.replace(/-([a-z])/g, (kk) => { - return kk[1].toUpperCase(); - }); - - // remove all non-alphanumeric characters - const outParam = cameledParam.replace(/([^0-9a-z])/ig, '') - - // check if resulting string is empty - if(outParam === '') { - console.error(`Resulting string is empty.`) - } - return outParam -} - -const interfaceJsonTypeToTypeScriptType = new Map([ - ['INPUT_TEXT_FILE:FILE', 'string'], - ['OUTPUT_TEXT_FILE:FILE', 'string'], - ['INPUT_BINARY_FILE:FILE', 'Uint8Array'], - ['OUTPUT_BINARY_FILE:FILE', 'Uint8Array'], - ['INPUT_TEXT_STREAM', 'string'], - ['OUTPUT_TEXT_STREAM', 'string'], - ['INPUT_BINARY_STREAM', 'Uint8Array'], - ['OUTPUT_BINARY_STREAM', 'Uint8Array'], - ['INPUT_IMAGE', 'Image'], - ['OUTPUT_IMAGE', 'Image'], - ['INPUT_MESH', 'Mesh'], - ['OUTPUT_MESH', 'Mesh'], - ['INPUT_POLYDATA', 'PolyData'], - ['OUTPUT_POLYDATA', 'PolyData'], - ['BOOL', 'boolean'], - ['TEXT', 'string'], - ['INT', 'number'], - ['OUTPUT_JSON', 'Object'], -]) - -const interfaceJsonTypeToInterfaceType = new Map([ - ['INPUT_TEXT_FILE:FILE', 'TextFile'], - ['OUTPUT_TEXT_FILE:FILE', 'TextFile'], - ['INPUT_BINARY_FILE:FILE', 'BinaryFile'], - ['OUTPUT_BINARY_FILE:FILE', 'BinaryFile'], - ['INPUT_TEXT_STREAM', 'TextStream'], - ['OUTPUT_TEXT_STREAM', 'TextStream'], - ['INPUT_BINARY_STREAM', 'BinaryStream'], - ['OUTPUT_BINARY_STREAM', 'BinaryStream'], - ['INPUT_IMAGE', 'Image'], - ['OUTPUT_IMAGE', 'Image'], - ['INPUT_MESH', 'Mesh'], - ['OUTPUT_MESH', 'Mesh'], - ['INPUT_POLYDATA', 'PolyData'], - ['OUTPUT_POLYDATA', 'PolyData'], - ['OUTPUT_JSON', 'JsonObject'], -]) - -function bindgen(wasmBinaries, options) { +function bindgen(options) { const { buildDir } = processCommonOptions() const language = options.language ?? 'typescript' const outputDir = options.outputDir ?? language + const wasmBinaries = glob.sync(path.join(buildDir, '**/*.wasm')) + try { fs.mkdirSync(outputDir, { recursive: true }) } catch (err) { - if (err.code !== 'EEXIST') throw err + if (err.code !== 'EE XIST') throw err } // Building for emscripten can generate duplicate .umd.wasm and .wasm binaries @@ -314,14 +260,14 @@ program .description('run the wasm binary, whose path is specified relative to the build directory') .action(run) program - .command('bindgen [wasmBinaries...]') + .command('bindgen') .option('-o, --output-dir ', 'Output directory name. Defaults to the language option value.') .requiredOption('-p, --package-name ', 'Output a package configuration files with the given packages name') .requiredOption('-d, --package-description ', 'Description for package') .addOption(new Option('-l, --language ', 'language to generate bindings for, defaults to "typescript"').choices(['typescript',])) .option('-r, --repository ', 'Source code repository URL') - .usage('[options] [wasmBinaries...]') - .description('Generate Wasm module bindings for a language') + .usage('[options]') + .description('Generate language bindings for Wasm modules') .action(bindgen) program