@dcmjs-org/media 0.0.0-bootstrap.0 → 1.0.0-beta.3

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 CHANGED
@@ -1 +1,32 @@
1
1
  # @dcmjs-org/media
2
+
3
+ The dcmjs bulk-data bundle. One dependency that re-exports the bulk-data
4
+ packages under the namespace shapes dcmjs v2 consumers already know:
5
+
6
+ | Namespace | Backed by | Contents |
7
+ | -------------- | ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
8
+ | `media` | `@dcmjs-org/dicomdir` | `buildDicomDirDataset`, `writeDicomDir`, `MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID` |
9
+ | `encapsulated` | `@dcmjs-org/encapsulated` + `@dcmjs-org/video` | `encapsulate`, `encapsulatePdf`, `extractEncapsulatedPdf`, `buildVideoDataset`, `encapsulateVideo`, `extractEncapsulatedVideo`, the base blocks `encapsulatedBase`, `encapsulatedPdfBase`, `videoBase`, `PDF_MIME_TYPE`, the SOP class UIDs, `DEFAULT_FRAGMENT_BYTES` |
10
+ | `image` | `@dcmjs-org/imaging` + `@dcmjs-org/video` | `buildImageDataset`, the base blocks `imageBase` and `derivedImageBase`, `parseJpegInfo`, `parseMp4Info`, `h264TransferSyntaxUID`, `SECONDARY_CAPTURE_SOP_CLASS_UID` |
11
+
12
+ `createVideoEventSource` (the streaming MP4 → event-stream source) is a
13
+ top-level named export.
14
+
15
+ The builders take the `createInstance` options of `@dcmjs-org/core`
16
+ (`instance`, `dataLevel`, `levels`, `predecessor`, `postProcess`,
17
+ `baseDicom`, `overrides`). The DICOM attributes go in `overrides`; a
18
+ top-level attribute key has no effect (CORE-USR-7).
19
+
20
+ ```js
21
+ import { media, encapsulated, image } from "@dcmjs-org/media";
22
+
23
+ const dataset = encapsulated.encapsulatePdf(pdfBytes, {
24
+ instance: existingNaturalizedInstance,
25
+ overrides: { DocumentTitle: "Discharge Summary" }
26
+ });
27
+ const dicomdir = media.buildDicomDirDataset(fileSetDescription);
28
+ const info = image.parseMp4Info(mp4Bytes);
29
+ ```
30
+
31
+ Every export here is the same object as the underlying package's export —
32
+ this bundle adds no behavior, only a single install surface.
package/package.json CHANGED
@@ -1,11 +1,18 @@
1
1
  {
2
2
  "name": "@dcmjs-org/media",
3
- "version": "0.0.0-bootstrap.0",
4
- "description": "Placeholder that reserves the name. CI publishes the real releases.",
3
+ "version": "1.0.0-beta.3",
4
+ "description": "The dcmjs bulk-data bundle: DICOMDIR building (@dcmjs-org/dicomdir), Encapsulated PDF wrapping (@dcmjs-org/encapsulated), image building (@dcmjs-org/imaging), and video encapsulation (@dcmjs-org/video) re-exported under the stable dcmjs media, encapsulated, and image namespaces",
5
+ "main": "./src/index.js",
5
6
  "license": "MIT",
6
7
  "repository": {
7
8
  "type": "git",
8
9
  "url": "git+https://github.com/dcmjs-org/dcmjs.git",
9
10
  "directory": "packages/media"
11
+ },
12
+ "dependencies": {
13
+ "@dcmjs-org/dicomdir": "1.0.0-beta.3",
14
+ "@dcmjs-org/encapsulated": "1.0.0-beta.3",
15
+ "@dcmjs-org/video": "1.0.0-beta.3",
16
+ "@dcmjs-org/imaging": "1.0.0-beta.3"
10
17
  }
11
- }
18
+ }
package/src/index.js ADDED
@@ -0,0 +1,82 @@
1
+ // The @dcmjs-org/media bundle: one dependency for the bulk-data surfaces —
2
+ // DICOMDIR building (@dcmjs-org/dicomdir), Encapsulated PDF wrapping
3
+ // (@dcmjs-org/encapsulated), image building (@dcmjs-org/imaging), and video
4
+ // encapsulation (@dcmjs-org/video) — re-exported under the namespace shapes
5
+ // of dcmjs v2's src/index.js (`media`, `encapsulated`, `image`), so a
6
+ // consumer of `dcmjs.media` / `dcmjs.encapsulated` / `dcmjs.image` reads the
7
+ // same names here. The builders take the createInstance options of
8
+ // @dcmjs-org/core; the base blocks ride along for a custom `baseDicom`.
9
+ import {
10
+ buildDicomDirDataset,
11
+ writeDicomDir,
12
+ MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID
13
+ } from "@dcmjs-org/dicomdir";
14
+ import {
15
+ encapsulate,
16
+ encapsulatedBase,
17
+ encapsulatePdf,
18
+ encapsulatedPdfBase,
19
+ extractEncapsulatedPdf,
20
+ ENCAPSULATED_PDF_SOP_CLASS_UID,
21
+ PDF_MIME_TYPE
22
+ } from "@dcmjs-org/encapsulated";
23
+ import {
24
+ buildImageDataset,
25
+ imageBase,
26
+ derivedImageBase,
27
+ SECONDARY_CAPTURE_SOP_CLASS_UID,
28
+ parseJpegInfo,
29
+ h264TransferSyntaxUID
30
+ } from "@dcmjs-org/imaging";
31
+ import {
32
+ buildVideoDataset,
33
+ videoBase,
34
+ encapsulateVideo,
35
+ extractEncapsulatedVideo,
36
+ VIDEO_PHOTOGRAPHIC_SOP_CLASS_UID,
37
+ DEFAULT_FRAGMENT_BYTES,
38
+ parseMp4Info,
39
+ createVideoEventSource
40
+ } from "@dcmjs-org/video";
41
+
42
+ // Media storage (PS3.10): the DICOMDIR builder — dcmjs v2's `media` namespace.
43
+ export const media = {
44
+ buildDicomDirDataset,
45
+ writeDicomDir,
46
+ MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID
47
+ };
48
+
49
+ // Encapsulated payloads (documents and video, in and out) — v2's
50
+ // `encapsulated`.
51
+ export const encapsulated = {
52
+ encapsulate,
53
+ encapsulatedBase,
54
+ encapsulatePdf,
55
+ encapsulatedPdfBase,
56
+ extractEncapsulatedPdf,
57
+ ENCAPSULATED_PDF_SOP_CLASS_UID,
58
+ PDF_MIME_TYPE,
59
+ buildVideoDataset,
60
+ videoBase,
61
+ encapsulateVideo,
62
+ extractEncapsulatedVideo,
63
+ VIDEO_PHOTOGRAPHIC_SOP_CLASS_UID,
64
+ DEFAULT_FRAGMENT_BYTES
65
+ };
66
+
67
+ // Image instances from decoded pixels (codec-free) — v2's `image`.
68
+ export const image = {
69
+ buildImageDataset,
70
+ imageBase,
71
+ derivedImageBase,
72
+ SECONDARY_CAPTURE_SOP_CLASS_UID,
73
+ parseJpegInfo,
74
+ parseMp4Info,
75
+ h264TransferSyntaxUID
76
+ };
77
+
78
+ // The streaming MP4 → events source has no v2 namespace; it rides along
79
+ // as a named export for event-stream consumers.
80
+ export { createVideoEventSource };
81
+
82
+ export default { media, encapsulated, image, createVideoEventSource };
@@ -0,0 +1,87 @@
1
+ // packages/media/test/bundle.test.js
2
+ //
3
+ // The bundle adds no behavior: every name it re-exports must be the very
4
+ // same object as the underlying package's export (identity, not a copy or
5
+ // a wrapper), and the namespace shapes must match dcmjs v2's src/index.js.
6
+
7
+ import * as dicomdir from "@dcmjs-org/dicomdir";
8
+ import * as encapsulatedPackage from "@dcmjs-org/encapsulated";
9
+ import * as imaging from "@dcmjs-org/imaging";
10
+ import * as video from "@dcmjs-org/video";
11
+ import bundle, {
12
+ media,
13
+ encapsulated,
14
+ image,
15
+ createVideoEventSource
16
+ } from "../src/index.js";
17
+
18
+ /** Each name of `namespace` is the same object as the export of `source`. */
19
+ function expectSameExports(namespace, source, names) {
20
+ for (const name of names) {
21
+ expect(source[name]).toBeDefined();
22
+ expect(namespace[name]).toBe(source[name]);
23
+ }
24
+ }
25
+
26
+ test("media namespace re-exports the @dcmjs-org/dicomdir surface by identity", () => {
27
+ expectSameExports(media, dicomdir, [
28
+ "buildDicomDirDataset",
29
+ "writeDicomDir",
30
+ "MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID"
31
+ ]);
32
+ });
33
+
34
+ test("encapsulated namespace re-exports the encapsulated and video surfaces by identity", () => {
35
+ expectSameExports(encapsulated, encapsulatedPackage, [
36
+ "encapsulate",
37
+ "encapsulatedBase",
38
+ "encapsulatePdf",
39
+ "encapsulatedPdfBase",
40
+ "extractEncapsulatedPdf",
41
+ "ENCAPSULATED_PDF_SOP_CLASS_UID",
42
+ "PDF_MIME_TYPE"
43
+ ]);
44
+ expectSameExports(encapsulated, video, [
45
+ "buildVideoDataset",
46
+ "videoBase",
47
+ "encapsulateVideo",
48
+ "extractEncapsulatedVideo",
49
+ "VIDEO_PHOTOGRAPHIC_SOP_CLASS_UID",
50
+ "DEFAULT_FRAGMENT_BYTES"
51
+ ]);
52
+ });
53
+
54
+ test("image namespace re-exports the imaging and MP4 surfaces by identity", () => {
55
+ expectSameExports(image, imaging, [
56
+ "buildImageDataset",
57
+ "imageBase",
58
+ "derivedImageBase",
59
+ "SECONDARY_CAPTURE_SOP_CLASS_UID",
60
+ "parseJpegInfo",
61
+ "h264TransferSyntaxUID"
62
+ ]);
63
+ expectSameExports(image, video, ["parseMp4Info"]);
64
+ });
65
+
66
+ test("the streaming video source and the default export ride along", () => {
67
+ expect(createVideoEventSource).toBe(video.createVideoEventSource);
68
+ expect(bundle.media).toBe(media);
69
+ expect(bundle.encapsulated).toBe(encapsulated);
70
+ expect(bundle.image).toBe(image);
71
+ expect(bundle.createVideoEventSource).toBe(createVideoEventSource);
72
+ });
73
+
74
+ test("a re-exported builder actually works through the bundle", () => {
75
+ const pdfBytes = new Uint8Array([
76
+ 0x25, 0x50, 0x44, 0x46, 0x2d, 0x31, 0x2e, 0x34
77
+ ]); // "%PDF-1.4"
78
+ const dataset = encapsulated.encapsulatePdf(pdfBytes, {
79
+ overrides: { PatientName: "DOE^JANE" }
80
+ });
81
+ expect(dataset.SOPClassUID).toBe(
82
+ encapsulated.ENCAPSULATED_PDF_SOP_CLASS_UID
83
+ );
84
+ expect(dataset.PatientName).toBe("DOE^JANE");
85
+ const { bytes } = encapsulated.extractEncapsulatedPdf(dataset);
86
+ expect(Array.from(new Uint8Array(bytes))).toEqual(Array.from(pdfBytes));
87
+ });