Skip to content

Commit

Permalink
feat(itk-dicom): Browser package configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Sep 8, 2022
1 parent be4f08b commit 6cc2574
Show file tree
Hide file tree
Showing 26 changed files with 3,480 additions and 2,954 deletions.
10 changes: 10 additions & 0 deletions dist/dicom/cypress.config.ts
@@ -0,0 +1,10 @@
import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
defaultCommandTimeout: 5000,
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
14 changes: 14 additions & 0 deletions dist/dicom/cypress/e2e/structured_report_to_text.cy.ts
@@ -0,0 +1,14 @@
describe('structuredReportToText', () => {
beforeEach(function() {
cy.visit('/')

const fileName = '88.33-comprehensive-SR.dcm'
const testFilePath = `../../build-emscripten/ExternalData/test/Input/${fileName}`
cy.readFile(testFilePath, null).as('inputData')
})

it('runs and produces the expected text', function() {
cy.get('input[type=file]').selectFile({ contents: new Uint8Array(this.inputData), fileName: 'inputData.dcm' })
cy.get('textarea').contains('Comprehensive SR Document')
})
})
37 changes: 37 additions & 0 deletions dist/dicom/cypress/support/commands.ts
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
9 changes: 9 additions & 0 deletions dist/dicom/cypress/support/compareImageToBaseline.ts
@@ -0,0 +1,9 @@
const compareImageToBaseline = (itk, testImage, baselineImage) => {
expect(testImage.imageType, 'imageType').to.deep.equal(baselineImage.imageType)
expect(testImage.origin, 'origin').to.deep.equal(baselineImage.origin)
expect(testImage.spacing, 'spacing').to.deep.equal(baselineImage.spacing)
expect(testImage.size, 'size').to.deep.equal(baselineImage.size)
expect(testImage.data, 'data').to.deep.equal(baselineImage.data)
}

export default compareImageToBaseline
20 changes: 20 additions & 0 deletions dist/dicom/cypress/support/e2e.ts
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
43 changes: 43 additions & 0 deletions dist/dicom/index.html
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html>
<head>
<title>structured-report-to-text example</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<style>
html, body {
height: 90%;
}

textarea {
resize: none;
overflow-y: scroll;
position: absolute;
box-sizing: border-box;
width: 600px;
height: 600px;
bottom: 0px;
left: 0px;
top: 50px;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/xstate@4.16.0/dist/xstate.min.js"></script>
</head>

<body>
<!-- Input selector -->
<div>
<label>Select dicom file:</label>
<input name="inputFile" type="file" />
</div>

<!-- File information -->
<div>
<textarea readonly name="outputTextArea">Output representation...</textarea>
<div name="outputDiv"></div>
</div>

<!-- Javascript -->
<script type="module" src="./dist/itk-dicom.js"></script>
<script type="module" src="./test/app.js"></script>
</body>
</html>
46 changes: 26 additions & 20 deletions dist/dicom/package.json
@@ -1,46 +1,52 @@
{
"name": "itk-vite-example",
"version": "1.0.2",
"description": "This example demonstrates how to use itk-wasm in a Rollup project that targets the browser.",
"main": "index.js",
"name": "itk-dicom",
"version": "0.0.1",
"description": "DICOM IO from itk-wasm",
"type": "module",
"main": "./dist/itk-dicom.umd.cjs",
"module": "./dist/itk-dicom.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/itk-dicom.js",
"require": "./dist/itk-dicom.umd.cjs"
}
},
"scripts": {
"start": "vite --port 8080",
"build": "vite build",
"start:production": "vite preview --port 8080",
"dev": "vite --port 8173",
"build": "tsc && vite build --sourcemap",
"build:watch": "tsc && vite build --minify false --mode development --watch",
"cypress:open": "npx cypress open",
"cypress:run": "npx cypress run",
"cypress:runChrome": "npx cypress run --browser chrome",
"cypress:runFirefox": "npx cypress run --browser firefox",
"test:debug": "start-server-and-test start http-get://localhost:8080 cypress:open",
"test": "start-server-and-test start:production http-get://localhost:8080 cypress:run",
"test:chrome": "start-server-and-test start:production http-get://localhost:8080 cypress:runChrome",
"test:firefox": "start-server-and-test start:production http-get://localhost:8080 cypress:runFirefox"
"test:debug": "start-server-and-test dev http-get://localhost:8173 cypress:open",
"test": "start-server-and-test dev http-get://localhost:8173 cypress:run",
"test:chrome": "start-server-and-test dev http-get://localhost:8173 cypress:runChrome",
"test:firefox": "start-server-and-test dev http-get://localhost:8173 cypress:runFirefox"
},
"repository": {
"type": "git",
"url": "git+https://github.com/InsightSoftwareConsortium/itk-wasm.git"
"url": "https://github.com/InsightSoftwareConsortium/itk-wasm.git"
},
"keywords": [
"itk",
"rollup",
"vite"
"dicom"
],
"author": "Matt McCormick <matt.mccormick@kitware.com>",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/InsightSoftwareConsortium/itk-wasm/issues"
},
"homepage": "https://github.com/InsightSoftwareConsortium/itk-wasm#readme",
"homepage": "https://wasm.itk.org",
"dependencies": {
"curry": "^1.2.0",
"itk-image-io": "^1.0.0-b.18",
"itk-mesh-io": "^1.0.0-b.18",
"itk-wasm": "^1.0.0-b.18"
"itk-wasm": "^1.0.0-b.21"
},
"devDependencies": {
"cypress": "^10.3.0",
"cypress": "^10.7.0",
"rollup-plugin-copy": "^3.4.0",
"start-server-and-test": "^1.14.0",
"typescript": "^4.7.4",
"vite": "^3.0.9"
}
}
55 changes: 55 additions & 0 deletions dist/dicom/src/StructuredReportToTextOptions.ts
@@ -0,0 +1,55 @@
interface StructuredReportToTextOptions {
/** Accept unknown relationship type */
unknownRelationship?: boolean

/** Accept invalid content item value */
invalidItemValue?: boolean

/** Ignore relationship constraints */
ignoreConstraints?: boolean

/** Ignore content item errors */
ignoreItemErrors?: boolean

/** Skip invalid content items */
skipInvalidItems?: boolean

/** Print no document header */
noDocumentHeader?: boolean

/** Number nested items */
numberNestedItems?: boolean

/** Shorten long item values */
shortenLongValues?: boolean

/** Print SOP Instance UID */
printInstanceUid?: boolean

/** Print short SOP class name */
printSopclassShort?: boolean

/** Print SOP class name */
printSopclassLong?: boolean

/** Print long SOP class name */
printSopclassUid?: boolean

/** Print all codes */
printAllCodes?: boolean

/** Print invalid codes */
printInvalidCodes?: boolean

/** Print template identification */
printTemplateId?: boolean

/** Indicate enhanced encoding mode */
indicateEnhanced?: boolean

/** Use ANSI escape codes */
printColor?: boolean

}

export default StructuredReportToTextOptions
10 changes: 10 additions & 0 deletions dist/dicom/src/StructuredReportToTextResult.ts
@@ -0,0 +1,10 @@
interface StructuredReportToTextResult {
/** WebWorker used for computation */
webWorker: Worker | null

/** Output text file */
outputText: string

}

export default StructuredReportToTextResult
10 changes: 10 additions & 0 deletions dist/dicom/src/index.ts
@@ -0,0 +1,10 @@


import StructuredReportToTextResult from './StructuredReportToTextResult.js'
export type { StructuredReportToTextResult }

import StructuredReportToTextOptions from './StructuredReportToTextOptions.js'
export type { StructuredReportToTextOptions }

import structuredReportToText from './structuredReportToText.js'
export { structuredReportToText }
10 changes: 10 additions & 0 deletions dist/dicom/src/itkConfigDevelopment.js
@@ -0,0 +1,10 @@
const version = '1.0.0-b.21'

const itkConfig = {
pipelineWorkerUrl: '/dist/pipelines/web-workers/pipeline.worker.js',
imageIOUrl: `https://cdn.jsdelivr.net/npm/itk-image-io@${version}`,
meshIOUrl: `https://cdn.jsdelivr.net/npm/itk-mesh-io@${version}`,
pipelinesUrl: '/dist/pipelines'
}

export default itkConfig

0 comments on commit 6cc2574

Please sign in to comment.