orbidicom 0.1.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/LICENSE +21 -0
- package/bin/orbidicom.mjs +28 -0
- package/dist/args.d.ts +11 -0
- package/dist/args.js +40 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.js +15 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/serve.d.ts +15 -0
- package/dist/serve.js +58 -0
- package/package.json +47 -0
- package/public/assets/charlswasm_decode-484ovEoR.wasm +0 -0
- package/public/assets/computeWorker-Dd8a7Dqd.js +5 -0
- package/public/assets/decodeImageFrameWorker-wYf2-PFJ.js +90 -0
- package/public/assets/index-6485mdZB.css +1 -0
- package/public/assets/index-C3ZK2mXe.js +54 -0
- package/public/assets/index-CkA8WclG.js +4231 -0
- package/public/assets/index-DlHE1E-n.js +1 -0
- package/public/assets/index-GWuN1VuF.js +1 -0
- package/public/assets/jpeg-BQEpTZHd.js +1 -0
- package/public/assets/libjpegturbowasm_decode-daqMmuVl.wasm +0 -0
- package/public/assets/lossless-BIYWXcdg.js +1 -0
- package/public/assets/openjpegwasm_decode-B3gWTHpv.wasm +0 -0
- package/public/assets/openjphjs-C-BUUy4a.wasm +0 -0
- package/public/config.js +13 -0
- package/public/index.html +15 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OrbiDICOM contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { parseArgs } from "../dist/args.js";
|
|
3
|
+
import { serve, openBrowser } from "../dist/serve.js";
|
|
4
|
+
|
|
5
|
+
const opts = parseArgs(process.argv.slice(2));
|
|
6
|
+
|
|
7
|
+
if (opts.command === "serve") {
|
|
8
|
+
const { url } = await serve(opts);
|
|
9
|
+
if (opts.pacs) {
|
|
10
|
+
console.log(`OrbiDICOM running at ${url}`);
|
|
11
|
+
console.log(` PACS: ${opts.pacs}`);
|
|
12
|
+
if (opts.study) console.log(` study: ${opts.study}`);
|
|
13
|
+
else console.log(" (append ?study=<StudyInstanceUID> or pass --study to open a study)");
|
|
14
|
+
} else {
|
|
15
|
+
console.log(`OrbiDICOM running at ${url} (local mode — drag in .dcm / .nii files)`);
|
|
16
|
+
}
|
|
17
|
+
if (opts.open) openBrowser(url);
|
|
18
|
+
console.log("Press Ctrl+C to stop.");
|
|
19
|
+
} else if (opts.command === "init") {
|
|
20
|
+
console.log(
|
|
21
|
+
"Scaffolding is implemented in the CLI plan. For now: clone the repo and `make dev`.",
|
|
22
|
+
);
|
|
23
|
+
} else if (opts.command === "ai") {
|
|
24
|
+
console.log("The AI assistant is implemented in the CLI plan (optional, BYO key).");
|
|
25
|
+
} else {
|
|
26
|
+
console.log(`Unknown command: ${opts.command}`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
package/dist/args.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type Command = "serve" | "init" | "ai" | "generate";
|
|
2
|
+
export interface CliOptions {
|
|
3
|
+
command: Command;
|
|
4
|
+
pacs?: string;
|
|
5
|
+
study?: string;
|
|
6
|
+
auth?: "none" | "basic" | "bearer";
|
|
7
|
+
port: number;
|
|
8
|
+
open: boolean;
|
|
9
|
+
rest: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare function parseArgs(argv: string[]): CliOptions;
|
package/dist/args.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const COMMANDS = new Set(["serve", "init", "ai", "generate"]);
|
|
2
|
+
export function parseArgs(argv) {
|
|
3
|
+
const opts = { command: "serve", port: 4173, open: true, rest: [] };
|
|
4
|
+
let i = 0;
|
|
5
|
+
if (argv[0] && COMMANDS.has(argv[0])) {
|
|
6
|
+
opts.command = argv[0];
|
|
7
|
+
i = 1;
|
|
8
|
+
}
|
|
9
|
+
else if (argv[0] === "create") {
|
|
10
|
+
opts.command = "init";
|
|
11
|
+
i = 1;
|
|
12
|
+
}
|
|
13
|
+
for (; i < argv.length; i++) {
|
|
14
|
+
const a = argv[i];
|
|
15
|
+
switch (a) {
|
|
16
|
+
case "--pacs":
|
|
17
|
+
opts.pacs = argv[++i];
|
|
18
|
+
break;
|
|
19
|
+
case "--study":
|
|
20
|
+
opts.study = argv[++i];
|
|
21
|
+
break;
|
|
22
|
+
case "--auth":
|
|
23
|
+
opts.auth = argv[++i];
|
|
24
|
+
break;
|
|
25
|
+
case "--port":
|
|
26
|
+
opts.port = Number(argv[++i]);
|
|
27
|
+
break;
|
|
28
|
+
case "--open":
|
|
29
|
+
opts.open = true;
|
|
30
|
+
break;
|
|
31
|
+
case "--no-open":
|
|
32
|
+
opts.open = false;
|
|
33
|
+
break;
|
|
34
|
+
default:
|
|
35
|
+
if (a)
|
|
36
|
+
opts.rest.push(a);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return opts;
|
|
40
|
+
}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate the runtime `config.js` the served demo loads before its app module.
|
|
3
|
+
* Mirrors the container entrypoint (deploy/docker-entrypoint.d) so `npx orbidicom`
|
|
4
|
+
* and the Docker image produce an identical `window.__ORBIDICOM_CONFIG__` shape.
|
|
5
|
+
*/
|
|
6
|
+
export declare function configScript(opts: {
|
|
7
|
+
pacs?: string;
|
|
8
|
+
study?: string;
|
|
9
|
+
}): string;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Strip characters that would break out of the JS string literals below.
|
|
2
|
+
* Values are operator-supplied on the command line, so this is belt-and-braces. */
|
|
3
|
+
function sanitize(v) {
|
|
4
|
+
return v.replace(/["\\\r\n]/g, "");
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Generate the runtime `config.js` the served demo loads before its app module.
|
|
8
|
+
* Mirrors the container entrypoint (deploy/docker-entrypoint.d) so `npx orbidicom`
|
|
9
|
+
* and the Docker image produce an identical `window.__ORBIDICOM_CONFIG__` shape.
|
|
10
|
+
*/
|
|
11
|
+
export function configScript(opts) {
|
|
12
|
+
const pacsUrl = sanitize(opts.pacs ?? "");
|
|
13
|
+
const studyUid = sanitize(opts.study ?? "");
|
|
14
|
+
return `window.__ORBIDICOM_CONFIG__ = {\n pacsUrl: "${pacsUrl}",\n studyUid: "${studyUid}",\n};\n`;
|
|
15
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/serve.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CliOptions } from "./args";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the prebuilt demo's directory. Published layout: the demo build is
|
|
4
|
+
* bundled into this package's `public/` (see scripts/bundle-demo.mjs). When
|
|
5
|
+
* running from the monorepo source, fall back to apps/demo/dist.
|
|
6
|
+
*/
|
|
7
|
+
export declare function demoDistDir(): string;
|
|
8
|
+
export interface ServeHandle {
|
|
9
|
+
port: number;
|
|
10
|
+
url: string;
|
|
11
|
+
close: () => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare function serve(opts: CliOptions, root?: string): Promise<ServeHandle>;
|
|
14
|
+
/** Open a URL in the default browser (best-effort, never throws). */
|
|
15
|
+
export declare function openBrowser(url: string): void;
|
package/dist/serve.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { createServer } from "node:http";
|
|
4
|
+
import { dirname, join, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import sirv from "sirv";
|
|
7
|
+
import { configScript } from "./config.js";
|
|
8
|
+
/**
|
|
9
|
+
* Resolve the prebuilt demo's directory. Published layout: the demo build is
|
|
10
|
+
* bundled into this package's `public/` (see scripts/bundle-demo.mjs). When
|
|
11
|
+
* running from the monorepo source, fall back to apps/demo/dist.
|
|
12
|
+
*/
|
|
13
|
+
export function demoDistDir() {
|
|
14
|
+
const here = dirname(fileURLToPath(import.meta.url)); // …/packages/cli/dist
|
|
15
|
+
const bundled = resolve(here, "../public");
|
|
16
|
+
if (existsSync(join(bundled, "index.html")))
|
|
17
|
+
return bundled;
|
|
18
|
+
return resolve(here, "../../../apps/demo/dist"); // dev / monorepo fallback
|
|
19
|
+
}
|
|
20
|
+
export async function serve(opts, root = demoDistDir()) {
|
|
21
|
+
const handler = sirv(root, { single: true, dev: false });
|
|
22
|
+
const server = createServer((req, res) => {
|
|
23
|
+
const path = (req.url ?? "").split("?")[0];
|
|
24
|
+
// Inject runtime config so the static bundle connects to the chosen PACS
|
|
25
|
+
// without rebuilding — same role as config.js in the container image.
|
|
26
|
+
if (path === "/config.js") {
|
|
27
|
+
res.statusCode = 200;
|
|
28
|
+
res.setHeader("Content-Type", "application/javascript; charset=utf-8");
|
|
29
|
+
res.setHeader("Cache-Control", "no-store");
|
|
30
|
+
res.end(configScript(opts));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
handler(req, res, () => {
|
|
34
|
+
res.statusCode = 404;
|
|
35
|
+
res.end("Not found");
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
await new Promise((r) => server.listen(opts.port, r));
|
|
39
|
+
const addr = server.address();
|
|
40
|
+
const port = typeof addr === "object" && addr ? addr.port : opts.port;
|
|
41
|
+
return {
|
|
42
|
+
port,
|
|
43
|
+
url: `http://localhost:${port}/`,
|
|
44
|
+
close: () => new Promise((res, rej) => server.close((e) => (e ? rej(e) : res()))),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** Open a URL in the default browser (best-effort, never throws). */
|
|
48
|
+
export function openBrowser(url) {
|
|
49
|
+
const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
50
|
+
try {
|
|
51
|
+
const child = spawn(cmd, [url], { stdio: "ignore", detached: true, shell: cmd === "start" });
|
|
52
|
+
child.on("error", () => { });
|
|
53
|
+
child.unref();
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
/* headless / no browser — the printed URL is enough */
|
|
57
|
+
}
|
|
58
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "orbidicom",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI for OrbiDICOM, a modern, mobile-responsive, multilingual, Kubernetes-ready (Helm chart included) open-source DICOM viewer: `npx orbidicom` to run locally or against any PACS.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://github.com/docorbitapp/orbidicom#readme",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/docorbitapp/orbidicom.git",
|
|
10
|
+
"directory": "packages/cli"
|
|
11
|
+
},
|
|
12
|
+
"bugs": "https://github.com/docorbitapp/orbidicom/issues",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"dicom",
|
|
15
|
+
"dicomweb",
|
|
16
|
+
"viewer",
|
|
17
|
+
"cornerstone3d",
|
|
18
|
+
"pacs",
|
|
19
|
+
"cli"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
22
|
+
"bin": {
|
|
23
|
+
"orbidicom": "./bin/orbidicom.mjs"
|
|
24
|
+
},
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"bin",
|
|
29
|
+
"public"
|
|
30
|
+
],
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=20"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"sirv": "^3.0.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^22.0.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc -b && node ./scripts/bundle-demo.mjs",
|
|
45
|
+
"test": "vitest run"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
Binary file
|