Skip to content

Commit ba0d421

Browse files
committed
Updated angular project to allow wasm files to load with this PR - cornerstonejs/cornerstone3D#1982
1 parent 7a6c05b commit ba0d421

2 files changed

Lines changed: 37 additions & 17 deletions

File tree

angular.json

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,31 @@
1616
"outputPath": "dist/angular-vite-6",
1717
"index": "src/index.html",
1818
"browser": "src/main.ts",
19-
"polyfills": [
20-
"zone.js"
21-
],
19+
"polyfills": ["zone.js"],
2220
"tsConfig": "tsconfig.app.json",
2321
"assets": [
2422
{
2523
"glob": "**/*",
2624
"input": "public"
25+
},
26+
{
27+
"glob": "openjphjs.wasm",
28+
"input": "node_modules/@cornerstonejs/codec-openjph/dist/"
29+
},
30+
{
31+
"glob": "openjpegwasm_decode.wasm",
32+
"input": "node_modules/@cornerstonejs/codec-openjpeg/dist/"
33+
},
34+
{
35+
"glob": "libjpegturbowasm_decode.wasm",
36+
"input": "node_modules/@cornerstonejs/codec-libjpeg-turbo-8bit/dist/"
37+
},
38+
{
39+
"glob": "charlswasm_decode.wasm",
40+
"input": "node_modules/@cornerstonejs/codec-charls/dist"
2741
}
2842
],
29-
"styles": [
30-
"src/styles.css"
31-
],
43+
"styles": ["src/styles.css"],
3244
"scripts": []
3345
},
3446
"configurations": {
@@ -37,7 +49,7 @@
3749
{
3850
"type": "initial",
3951
"maximumWarning": "500kB",
40-
"maximumError": "1MB"
52+
"maximumError": "2MB"
4153
},
4254
{
4355
"type": "anyComponentStyle",
@@ -73,20 +85,15 @@
7385
"test": {
7486
"builder": "@angular-devkit/build-angular:karma",
7587
"options": {
76-
"polyfills": [
77-
"zone.js",
78-
"zone.js/testing"
79-
],
88+
"polyfills": ["zone.js", "zone.js/testing"],
8089
"tsConfig": "tsconfig.spec.json",
8190
"assets": [
8291
{
8392
"glob": "**/*",
8493
"input": "public"
8594
}
8695
],
87-
"styles": [
88-
"src/styles.css"
89-
],
96+
"styles": ["src/styles.css"],
9097
"scripts": []
9198
}
9299
}

src/app/cornerstone-viewport/cornerstone-viewport.component.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class CornerstoneViewportComponent implements OnInit {
9797

9898
cornerstoneDICOMImageLoader.wadors.metaDataManager.add(
9999
imageId,
100-
instanceMetaData
100+
instanceMetaData,
101101
);
102102
return imageId;
103103
});
@@ -110,7 +110,20 @@ export class CornerstoneViewportComponent implements OnInit {
110110

111111
await csRenderInit();
112112
await csToolsInit();
113-
dicomImageLoaderInit({ maxWebWorkers: 1 });
113+
dicomImageLoaderInit({
114+
maxWebWorkers: 1,
115+
/**
116+
* Customise the paths to the required WASM files. These paths are
117+
* determined by your output path for these files in `angular.json`. @see
118+
* file://../../../angular.json or see the README for more details.
119+
*/
120+
decodeConfig: {
121+
wasmUrlCodecCharls: './charlswasm_decode.wasm',
122+
wasmUrlCodecLibJpegTurbo8bit: './libjpegturbowasm_decode.wasm',
123+
wasmUrlCodecOpenJpeg: './openjpegwasm_decode.wasm',
124+
wasmUrlCodecOpenJph: './openjphjs.wasm',
125+
},
126+
});
114127

115128
const imageIds = await createImageIdsAndCacheMetaData({
116129
StudyInstanceUID:
@@ -136,7 +149,7 @@ export class CornerstoneViewportComponent implements OnInit {
136149
renderingEngine.enableElement(viewportInput);
137150

138151
const viewport = renderingEngine.getViewport(
139-
viewportId
152+
viewportId,
140153
) as Types.IVolumeViewport;
141154

142155
const volumeId = 'myVolume';

0 commit comments

Comments
 (0)