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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a1 as N,a2 as j,a3 as A,a4 as O,a5 as U,a6 as k,a7 as B,a8 as F,a9 as W,aa as z,ab as q,ac as H,ad as $,ae as Z,af as Q,ag as Y,ah as J,ai as K,aj as X,ak as M,al as E,am as C,an as ee,ao as ae,ap as x,aq as te,ar as T,as as se,at as oe,au as Oe,av as ne,aw as ie,ax as re,ay as me,az as de,aA as ge,aB as ce,aC as le,aD as ue,aE as pe,aF as Ie,aG as he,aH as be,aI as De,aJ as Ve,aK as fe,aL as we,aM as Pe,aN as Ge,aO as Se,aP as ve,aQ as Re,aR as Me,aS as Ee}from"./index-CkA8WclG.js";import{aT as $e,aU as Ze,aV as Qe,aW as Ye,aX as Je,aY as Ke,aZ as Xe,a_ as ea,a$ as aa,b0 as ta,b1 as sa,b2 as oa,b3 as na,b4 as ia,b5 as ra,b6 as ma,b7 as da,b8 as ga,b9 as ca,ba as la,bb as ua,bc as pa,bd as Ia,be as ha,bf as ba,bg as Da,bh as Va,bi as fa,bj as wa,bk as Pa,bl as Ga,bm as Sa,bn as va,bo as Ra,bp as Ma,bq as Ea,br as Ca,bs as xa,bt as Ta,bu as _a,bv as La,bw as ya,bx as Na,by as ja,bz as Aa,bA as Oa,bB as Ua,bC as ka,bD as Ba,bE as Fa,bF as Wa,bG as za,bH as qa,bz as Ha,bI as $a,bJ as Za,bK as Qa,bL as Ya,bM as Ja,bN as Ka,bO as Xa,bP as et,bQ as at,bR as tt,bS as st,bT as ot,bU as nt,bV as it,bW as rt}from"./index-CkA8WclG.js";function Ue(s,e,a){for(const o of a){const t=s.getViewport(o);if(!t)throw new Error(`Viewport with Id ${o} does not exist`);if(!t.addImages){console.warn(`Viewport with Id ${o} does not have addImages. Cannot add image segmentation to this viewport.`);return}}a.forEach(o=>{s.getViewport(o).addImages(e)})}const Ce={adapter:j,getSnapshot:N},xe={adapter:O,getSnapshot:A},Te={adapter:Z,getSnapshot:$,getZoom:H,getScale:q,getPan:z,resolveICamera:W,derivePresentation:F,applyToRenderer:B,createImageSliceBasis:k,createVolumeSliceBasis:U},_e={adapter:Y,getSnapshot:Q},Le={adapter:K,getSnapshot:J},ke="5.0.13";class ye extends X{constructor(e,a){super(e,a),this._dimensionGroupNumber=1,this._loadedDimensionGroups=new Set,this._getImageIdRequests=(n,r)=>this.getImageIdsRequests(n,r),this.getImageLoadRequests=n=>{const r=this.getImageIdsToLoad();return this._getImageIdRequests(r,n)};const{imageIdGroups:o,splittingTag:t}=e;this._splittingTag=t,this._imageIdGroups=o,this.numDimensionGroups=this._imageIdGroups.length}_getImageIdsToLoad(){const e=this._imageIdGroups,a=this._dimensionGroupNumber-1,o=[...e[a]];let t=a-1,n=a+1;for(;t>=0||n<e.length;)t>=0&&o.push(...e[t--]),n<e.length&&o.push(...e[n++]);return o}getImageIdsToLoad(){return this._getImageIdsToLoad()}get dimensionGroupNumber(){return this._dimensionGroupNumber}set dimensionGroupNumber(e){this._dimensionGroupNumber!==e&&(this._dimensionGroupNumber=e,this.voxelManager.setDimensionGroupNumber(e),this.invalidateVolume(!0),M(C,E.DYNAMIC_VOLUME_DIMENSION_GROUP_CHANGED,{volumeId:this.volumeId,dimensionGroupNumber:e,numDimensionGroups:this.numDimensionGroups,imageIdGroupIndex:e-1,numImageIdGroups:this.numDimensionGroups,splittingTag:this.splittingTag}))}scroll(e){const a=this._dimensionGroupNumber+e;a<1?this.dimensionGroupNumber=this.numDimensionGroups:a>this.numDimensionGroups?this.dimensionGroupNumber=1:this.dimensionGroupNumber=a}getCurrentDimensionGroupImageIds(){return this._imageIdGroups[this._dimensionGroupNumber-1]}flatImageIdIndexToDimensionGroupNumber(e){return Math.floor(e/this._imageIdGroups[0].length)+1}flatImageIdIndexToImageIdIndex(e){return e%this._imageIdGroups[0].length}get splittingTag(){return this._splittingTag}isDimensionGroupLoaded(e){return this._loadedDimensionGroups.has(e)}markDimensionGroupAsLoaded(e){this._loadedDimensionGroups.add(e),M(C,E.DYNAMIC_VOLUME_DIMENSION_GROUP_LOADED,{volumeId:this.volumeId,dimensionGroupNumber:e})}checkDimensionGroupCompletion(e){const a=this.flatImageIdIndexToDimensionGroupNumber(e);this._imageIdGroups[a-1].every(n=>{const r=this.getImageIdIndex(n);return this.cachedFrames[r]===ee.FULL_RESOLUTION})&&!this.isDimensionGroupLoaded(a)&&this.markDimensionGroupAsLoaded(a)}}function Ne(s,e,a){return e.reduce((o,t)=>t.apply(o,a),s)}const je={name:"InPlaneDecimationModifier",apply(s,e){const[a=1,o=a]=e.options.ijkDecimation??[],t=Math.max(1,Math.floor(a)),n=Math.max(1,Math.floor(o));if(t===1&&n===1)return s;const[r,m]=s.dimensions,g=Math.max(1,Math.floor(r/t)),u=Math.max(1,Math.floor(m/n)),p=[g,u,s.dimensions[2]],c=[s.spacing[0]*t,s.spacing[1]*n,s.spacing[2]],b={...s.metadata,Columns:g,Rows:u,PixelSpacing:[c[1],c[0]]};return{...s,dimensions:p,spacing:c,metadata:b}}};function Be(s,e){if(!e||!e.imageIds||!e.imageIds.length)throw new Error("ImageIds must be provided to create a streaming image volume ");const[a=1,o=a,t=1]=e.ijkDecimation??[],n=Math.max(1,Math.floor(a)),r=o>1?Math.max(1,Math.floor(o)):n,m=Math.max(1,Math.floor(t)),g=n>1||r>1,u={ijkDecimation:[n,r,m]},p=[je];function c(i,d){return d===1?i:`${i}#decimation=${d}`}const b=Math.floor(e.imageIds.length/m),f=m>1&&e.imageIds.length<=b+1;if(m>1&&!f){const i=ae(e.imageIds,m),d=Array.isArray(i)&&i.length&&typeof i[0]=="number"?i.map(V=>e.imageIds[V]):i;e.imageIds=d}n>1&&(e.imageIds=e.imageIds.map(i=>c(i,n)));async function w(){const i=x(e.imageIds,s),d={volumeId:s,imageIds:e.imageIds,options:u},V=Ne(i,p,d),{dimensions:I,spacing:P,origin:G,direction:_,metadata:L,imageIds:S,dataType:y,numberOfComponents:v}=V,l=new te({volumeId:s,metadata:L,dimensions:I,spacing:P,origin:G,direction:_,imageIds:S,dataType:y,numberOfComponents:v},{imageIds:S,loadStatus:{loaded:!1,loading:!1,cancelled:!1,cachedFrames:[],callbacks:[]}});if(g){const h=l.imageData;h&&(h.setDimensions(l.dimensions),h.setSpacing(l.spacing),h.modified());const R=T.createImageVolumeVoxelManager({dimensions:l.dimensions,imageIds:l.imageIds,numberOfComponents:v});l.voxelManager=R,h&&h.set({voxelManager:R})}return l}const D=w();return{promise:D,decache:()=>{D.then(i=>{i.destroy(),i=null})},cancel:()=>{D.then(i=>{i.cancelLoading()})}}}function Fe(s,e){if(!e||!e.imageIds||!e.imageIds.length)throw new Error("ImageIds must be provided to create a 4D streaming image volume");const{imageIds:a}=e,{splittingTag:o,imageIdGroups:t}=se(a),n=Math.floor(t.length/2),r=x(t[n],s),{metadata:m,dimensions:g,spacing:u,direction:p,sizeInBytes:c,origin:b,numberOfComponents:f,dataType:w}=r,D=p.slice(6,9),i=t.map(P=>oe(P,D).sortedImageIds),d=i.flat(),V=T.createScalarDynamicVolumeVoxelManager({dimensions:g,imageIdGroups:i,dimensionGroupNumber:1,numberOfComponents:f});let I=new ye({volumeId:s,metadata:m,dimensions:g,spacing:u,origin:b,direction:p,sizeInBytes:c,imageIds:d,imageIdGroups:i,splittingTag:o,voxelManager:V,numberOfComponents:f,dataType:w},{imageIds:d,loadStatus:{loaded:!1,loading:!1,cancelled:!1,cachedFrames:[],callbacks:[]}});return{promise:Promise.resolve(I),decache:()=>{I.destroy(),I=null},cancel:()=>{I.cancelLoading()}}}const We={GenericViewport:Ee,DefaultRenderPathResolver:Me,defaultRenderPathResolver:Re,ECGGenericViewport:ve,createDefaultECGRenderPaths:Se,createECGRenderPathResolver:Ge,DefaultECGDataProvider:Pe,ecgProjection:Ce,VideoGenericViewport:we,createDefaultVideoRenderPaths:fe,createVideoRenderPathResolver:Ve,DefaultVideoDataProvider:De,videoProjection:xe,PlanarViewport:be,createDefaultPlanarRenderPaths:he,createPlanarRenderPathResolver:Ie,DefaultPlanarDataProvider:pe,planarProjection:Te,VolumeViewport3D:ue,createDefaultVolume3DRenderPaths:le,createVolume3DRenderPathResolver:ce,DefaultVolume3DDataProvider:ge,volume3DProjection:_e,WSIGenericViewport:de,createDefaultWSIRenderPaths:me,createWSIRenderPathResolver:re,DefaultWSIDataProvider:ie,wsiProjection:Le},ze=ne;export{$e as ActorRenderMode,Ze as BaseRenderingEngine,Qe as BaseVolumeViewport,Ye as CONSTANTS,Je as ContextPoolRenderingEngine,Pe as DefaultECGDataProvider,pe as DefaultPlanarDataProvider,Me as DefaultRenderPathResolver,De as DefaultVideoDataProvider,ge as DefaultVolume3DDataProvider,ie as DefaultWSIDataProvider,ve as ECGGenericViewport,Ke as ECGViewport,Xe as EPSILON,E as EVENTS,ea as Enums,Ee as GenericViewport,ue as GenericVolumeViewport3D,aa as ImageVolume,ze as LegacyVolumeViewport3D,be as PlanarViewport,ta as ProgressiveRetrieveImages,sa as RenderingEngine,oa as Settings,na as StackViewport,ye as StreamingDynamicImageVolume,te as StreamingImageVolume,ia as Surface,ra as TiledRenderingEngine,we as VideoGenericViewport,ma as VideoViewport,da as Viewport,ga as ViewportProjectionService,ca as VolumeViewport,ne as VolumeViewport3D,de as WSIGenericViewport,la as WSIViewport,Ue as addImageSlicesToViewports,ua as addVolumesToViewports,pa as cache,Ia as canRenderFloatTextures,ha as convertColorArrayToRgbString,ba as convertMapperToNotSharedMapper,Da as cornerstoneMeshLoader,Fe as cornerstoneStreamingDynamicImageVolumeLoader,Va as cornerstoneStreamingImageVolumeLoader,fa as createCanvas,Se as createDefaultECGRenderPaths,he as createDefaultPlanarRenderPaths,fe as createDefaultVideoRenderPaths,le as createDefaultVolume3DRenderPaths,me as createDefaultWSIRenderPaths,Ge as createECGRenderPathResolver,Ie as createPlanarRenderPathResolver,Ve as createVideoRenderPathResolver,wa as createViewportElement,ce as createVolume3DRenderPathResolver,Pa as createVolumeActor,Ga as createVolumeMapper,re as createWSIRenderPathResolver,Be as decimatedVolumeLoader,Re as defaultRenderPathResolver,Ce as ecgProjection,C as eventTarget,Sa as geometryLoader,va as getConfiguration,Ra as getEnabledElement,Ma as getEnabledElementByIds,Ea as getEnabledElementByViewportId,Ca as getEnabledElements,xa as getOrCreateCanvas,Ta as getProjectionScaleMatrix,_a as getRenderingEngine,La as getRenderingEngines,ya as getShouldUseCPURendering,Na as getUseGenericViewport,ja as getWebWorkerManager,Aa as imageLoadPoolManager,Oa as imageLoader,Ua as imageRetrievalPoolManager,ka as init,Ba as isCornerstoneInitialized,Fa as isRegisteredViewportType,Oe as metaData,Wa as peerImport,Te as planarProjection,za as registerImageLoader,qa as registerViewportType,We as renderingEngineExportsV2,Ha as requestPoolManager,$a as resetInitialization,Za as resetUseCPURendering,Qa as setCanvasCreator,Ya as setConfiguration,Ja as setPreferSizeOverAccuracy,Ka as setUseCPURendering,Xa as setVolumesForViewports,M as triggerEvent,et as updateCanvasSizeAndAspectRatio,at as utilities,ke as version,xe as videoProjection,tt as viewportHasCanvasWorldTransform,st as viewportHasFrameOfReferenceUID,ot as viewportHasPan,nt as viewportHasZoom,it as viewportProjection,_e as volume3DProjection,rt as volumeLoader,Le as wsiProjection};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as e,s as a,a as S,x as P,w as I,u as s,p as R,l as O,b as t,c as L,d as C,e as i,f as o,h as N,i as A,j as G,k as l,m as n,n as r,o as M,q as d,r as T,t as J,v as c,y as H,z as D,A as g,B,C as F,D as m,E as u,F as p,G as x,H as V,I as y,J as U,K as v,L as z,M as $,N as X,O as f,P as Y,Q as b,R as h,S as q,T as w,U as j,V as K,W as k,X as W,Y as Q,Z,_ as E0,$ as _0,a0 as e0}from"./index-CkA8WclG.js";const a0={xhrRequest:P,streamRequest:S,setOptions:a,getOptions:e},S0={getImagePixelModule:J,getLUTs:T,getModalityLUTOutputPixelRepresentation:d,getNumberValues:M,metaDataProvider:r,metadataForDataset:n},P0={metaData:S0,dataSetCacheManager:l,fileManager:G,getEncapsulatedImageFrame:A,getUncompressedImageFrame:N,loadFileRequest:o,loadImageFromPromise:i,getLoaderForScheme:C,getPixelData:L,loadImage:t,loadImageFromNaturalizedMetadata:O,parseImageId:R,unpackBinaryFrame:s,register:I};function I0(E,_){if(_=_||E.transferSyntax,E.bitsAllocated===8&&_==="1.2.840.10008.1.2.4.50"&&(E.samplesPerPixel===3||E.samplesPerPixel===4))return!0}const s0={IMPLICIT_VR_LITTLE_ENDIAN:"1.2.840.10008.1.2",EXPLICIT_VR_LITTLE_ENDIAN:"1.2.840.10008.1.2.1",DEFLATED_EXPLICIT_VR_LITTLE_ENDIAN:"1.2.840.10008.1.2.1.99",EXPLICIT_VR_BIG_ENDIAN:"1.2.840.10008.1.2.2",JPEG_BASELINE_PROCESS_1:"1.2.840.10008.1.2.4.50",JPEG_EXTENDED_PROCESS_2_4:"1.2.840.10008.1.2.4.51",JPEG_EXTENDED_PROCESSES_3_5:"1.2.840.10008.1.2.4.52",JPEG_SPECTRAL_SELECTION_NONHIERARCHICAL_PROCESSES_6_8:"1.2.840.10008.1.2.4.53",JPEG_SPECTRAL_SELECTION_NONHIERARCHICAL_PROCESSES_7_9:"1.2.840.10008.1.2.4.54",JPEG_FULL_PROGRESSION_NONHIERARCHICAL_PROCESSES_10_12:"1.2.840.10008.1.2.4.55",JPEG_FULL_PROGRESSION_NONHIERARCHICAL_PROCESSES_11_13:"1.2.840.10008.1.2.4.56",JPEG_LOSSLESS_NONHIERARCHICAL_PROCESS_14:"1.2.840.10008.1.2.4.57",JPEG_LOSSLESS_NONHIERARCHICAL_PROCESS_15:"1.2.840.10008.1.2.4.58",JPEG_EXTENDED_HIERARCHICAL_PROCESSES_16_18:"1.2.840.10008.1.2.4.59",JPEG_EXTENDED_HIERARCHICAL_PROCESSES_17_19:"1.2.840.10008.1.2.4.60",JPEG_SPECTRAL_SELECTION_HIERARCHICAL_PROCESSES_20_22:"1.2.840.10008.1.2.4.61",JPEG_SPECTRAL_SELECTION_HIERARCHICAL_PROCESSES_21_23:"1.2.840.10008.1.2.4.62",JPEG_FULL_PROGRESSION_HIERARCHICAL_PROCESSES_24_26:"1.2.840.10008.1.2.4.63",JPEG_FULL_PROGRESSION_HIERARCHICAL_PROCESSES_25_27:"1.2.840.10008.1.2.4.64",JPEG_LOSSLESS_NONHIERARCHICAL_PROCESS_28:"1.2.840.10008.1.2.4.65",JPEG_LOSSLESS_NONHIERARCHICAL_PROCESS_29:"1.2.840.10008.1.2.4.66",JPEG_LOSSLESS_NONHIERARCHICAL_FIRST_ORDER_PREDICTION_PROCESS_14:"1.2.840.10008.1.2.4.70",JPEG_LS_LOSSLESS_IMAGE_COMPRESSION:"1.2.840.10008.1.2.4.80",JPEG_LS_LOSSY_NEAR_LOSSLESS_IMAGE_COMPRESSION:"1.2.840.10008.1.2.4.81",JPEG_2000_IMAGE_COMPRESSION_LOSSLESS_ONLY:"1.2.840.10008.1.2.4.90",JPEG_2000_IMAGE_COMPRESSION:"1.2.840.10008.1.2.4.91",JPEG_2000_PART_2_MULTICOMPONENT_IMAGE_COMPRESSION_LOSSLESS_ONLY:"1.2.840.10008.1.2.4.92",JPEG_2000_PART_2_MULTICOMPONENT_IMAGE_COMPRESSION:"1.2.840.10008.1.2.4.93",JPIP_REFERENCED:"1.2.840.10008.1.2.4.94",JPIP_REFERENCED_DEFLATE:"1.2.840.10008.1.2.4.95",MPEG2_MAIN_PROFILE_MAIN_LEVEL:"1.2.840.10008.1.2.4.100",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_1:"1.2.840.10008.1.2.4.101",MPEG4_AVC_H264_BD_COMPATIBLE_HIGH_PROFILE_LEVEL_4_1:"1.2.840.10008.1.2.4.102",MPEG4_AVC_H264_HIGH_PROFILE_FOR_2D_VIDEO:"1.2.840.10008.1.2.4.103",MPEG4_AVC_H264_HIGH_PROFILE_FOR_3D_VIDEO:"1.2.840.10008.1.2.4.104",JPIP_LOSSLESS:"1.2.840.10008.1.2.4.96",JPIP_PART2_MULTICOMPONENT_IMAGE_COMPRESSION:"1.2.840.10008.1.2.4.97",RFC_2557_MIME_ENCAPSULATION:"1.2.840.10008.1.2.6.1",JPEG_XR_IMAGE_COMPRESSION:"1.2.840.10008.1.2.6.2",JPEG_2000_IMAGE_COMPRESSION_LOSSLESS_ONLY_RETIRED:"1.2.840.10008.1.2.4.90R",JPEG_2000_IMAGE_COMPRESSION_RETIRED:"1.2.840.10008.1.2.4.91R",JPEG_2000_PART_2_MULTICOMPONENT_IMAGE_COMPRESSION_LOSSLESS_ONLY_RETIRED:"1.2.840.10008.1.2.4.92R",JPEG_2000_PART_2_MULTICOMPONENT_IMAGE_COMPRESSION_RETIRED:"1.2.840.10008.1.2.4.93R"},R0=Object.freeze(Object.defineProperty({__proto__:null,transferSyntaxes:s0},Symbol.toStringTag,{value:"Module"})),O0={HTJ2K:z,JPEG2000:v,JPEGLS:U,JPEGBaseline12Bit:y,JPEGLossless:V,JPEGBaseline8Bit:x},t0={HTJ2K:p,JPEG2000:u,JPEGLS:m,JPEGBaseline12Bit:F,JPEGLossless:B,JPEGBaseline8Bit:g,BigEndian:D,LittleEndian:H,RLE:c},C0={constants:R0,convertRGBColorByPixel:e0,convertRGBColorByPlane:_0,convertYBRFullByPixel:E0,convertYBRFullByPlane:Z,convertPaletteColor:Q,convertPaletteColorWithFetch:W,wadouri:P0,wadors:k,init:K,convertColorSpace:j,createImage:w,decodeJPEGBaseline8BitColor:q,getImageFrame:h,getPixelData:b,getMinMax:Y,isColorImage:f,isJPEGBaseline8BitColor:I0,internal:a0,decodeImageFrame:X,postProcessDecodedPixels:$,initializers:O0,decoders:t0};export{R0 as constants,j as convertColorSpace,Q as convertPaletteColor,W as convertPaletteColorWithFetch,e0 as convertRGBColorByPixel,_0 as convertRGBColorByPlane,E0 as convertYBRFullByPixel,Z as convertYBRFullByPlane,w as createImage,X as decodeImageFrame,q as decodeJPEGBaseline8BitColor,t0 as decoders,C0 as default,h as getImageFrame,Y as getMinMax,b as getPixelData,K as init,O0 as initializers,a0 as internal,f as isColorImage,I0 as isJPEGBaseline8BitColor,$ as postProcessDecodedPixels,k as wadors,P0 as wadouri};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _={Grayscale:1,AdobeRGB:2,RGB:3,CYMK:4},$=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),ee=4017,re=799,ne=3406,ae=2276,ie=1567,fe=3784,R=5793,se=2896;function ce(g,s){for(var e=0,P=[],h,r,c=16;c>0&&!g[c-1];)c--;P.push({children:[],index:0});var t=P[0],n;for(h=0;h<c;h++){for(r=0;r<g[h];r++){for(t=P.pop(),t.children[t.index]=s[e];t.index>0;)t=P.pop();for(t.index++,P.push(t);P.length<=h;)P.push(n={children:[],index:0}),t.children[t.index]=n.children,t=n;e++}h+1<c&&(P.push(n={children:[],index:0}),t.children[t.index]=n.children,t=n)}return P[0].children}function j(g,s,e){return 64*((g.blocksPerLine+1)*s+e)}function he(g,s,e,P,h,r,c,t,n){e.precision,e.samplesPerLine,e.scanLines;var d=e.mcusPerLine,v=e.progressive;e.maxH,e.maxV;var x=s,a=0,l=0;function i(){if(l>0)return l--,a>>l&1;if(a=g[s++],a==255){var o=g[s++];if(o)throw"unexpected marker: "+(a<<8|o).toString(16)}return l=7,a>>>7}function f(o){for(var b=o,m;(m=i())!==null;){if(b=b[m],typeof b=="number")return b;if(typeof b!="object")throw"invalid huffman sequence"}return null}function G(o){for(var b=0;o>0;){var m=i();if(m===null)return;b=b<<1|m,o--}return b}function u(o){var b=G(o);return b>=1<<o-1?b:b+(-1<<o)+1}function V(o,b){var m=f(o.huffmanTableDC),O=m===0?0:u(m);o.blockData[b]=o.pred+=O;for(var A=1;A<64;){var k=f(o.huffmanTableAC),M=k&15,q=k>>4;if(M===0){if(q<15)break;A+=16;continue}A+=q;var Q=$[A];o.blockData[b+Q]=u(M),A++}}function D(o,b){var m=f(o.huffmanTableDC),O=m===0?0:u(m)<<n;o.blockData[b]=o.pred+=O}function L(o,b){o.blockData[b]|=i()<<n}var T=0;function S(o,b){if(T>0){T--;return}for(var m=r,O=c;m<=O;){var A=f(o.huffmanTableAC),k=A&15,M=A>>4;if(k===0){if(M<15){T=G(M)+(1<<M)-1;break}m+=16;continue}m+=M;var q=$[m];o.blockData[b+q]=u(k)*(1<<n),m++}}var y=0,X;function K(o,b){for(var m=r,O=c,A=0;m<=O;){var k=$[m];switch(y){case 0:var M=f(o.huffmanTableAC),q=M&15;if(A=M>>4,q===0)A<15?(T=G(A)+(1<<A),y=4):(A=16,y=1);else{if(q!==1)throw"invalid ACn encoding";X=u(q),y=A?2:3}continue;case 1:case 2:o.blockData[b+k]?o.blockData[b+k]+=i()<<n:(A--,A===0&&(y=y==2?3:0));break;case 3:o.blockData[b+k]?o.blockData[b+k]+=i()<<n:(o.blockData[b+k]=X<<n,y=0);break;case 4:o.blockData[b+k]&&(o.blockData[b+k]+=i()<<n);break}m++}y===4&&(T--,T===0&&(y=0))}function Z(o,b,m,O,A){var k=m/d|0,M=m%d,q=k*o.v+O,Q=M*o.h+A,ve=j(o,q,Q);b(o,ve)}function E(o,b,m){var O=m/o.blocksPerLine|0,A=m%o.blocksPerLine,k=j(o,O,A);b(o,k)}var B=P.length,U,Y,w,z,I,H;v?r===0?H=t===0?D:L:H=t===0?S:K:H=V;var F=0,N,J;B==1?J=P[0].blocksPerLine*P[0].blocksPerColumn:J=d*e.mcusPerColumn,h||(h=J);for(var C,p;F<J;){for(Y=0;Y<B;Y++)P[Y].pred=0;if(T=0,B==1)for(U=P[0],I=0;I<h;I++)E(U,H,F),F++;else for(I=0;I<h;I++){for(Y=0;Y<B;Y++)for(U=P[Y],C=U.h,p=U.v,w=0;w<p;w++)for(z=0;z<C;z++)Z(U,H,F,w,z);F++}if(l=0,N=g[s]<<8|g[s+1],N<=65280)throw"marker was not found";if(N>=65488&&N<=65495)s+=2;else break}return s-x}function be(g,s,e){var P=g.quantizationTable,h,r,c,t,n,d,v,x,a,l;for(l=0;l<64;l++)e[l]=g.blockData[s+l]*P[l];for(l=0;l<8;++l){var i=8*l;if(e[1+i]===0&&e[2+i]===0&&e[3+i]===0&&e[4+i]===0&&e[5+i]===0&&e[6+i]===0&&e[7+i]===0){a=R*e[0+i]+512>>10,e[0+i]=a,e[1+i]=a,e[2+i]=a,e[3+i]=a,e[4+i]=a,e[5+i]=a,e[6+i]=a,e[7+i]=a;continue}h=R*e[0+i]+128>>8,r=R*e[4+i]+128>>8,c=e[2+i],t=e[6+i],n=se*(e[1+i]-e[7+i])+128>>8,x=se*(e[1+i]+e[7+i])+128>>8,d=e[3+i]<<4,v=e[5+i]<<4,a=h-r+1>>1,h=h+r+1>>1,r=a,a=c*fe+t*ie+128>>8,c=c*ie-t*fe+128>>8,t=a,a=n-v+1>>1,n=n+v+1>>1,v=a,a=x+d+1>>1,d=x-d+1>>1,x=a,a=h-t+1>>1,h=h+t+1>>1,t=a,a=r-c+1>>1,r=r+c+1>>1,c=a,a=n*ae+x*ne+2048>>12,n=n*ne-x*ae+2048>>12,x=a,a=d*re+v*ee+2048>>12,d=d*ee-v*re+2048>>12,v=a,e[0+i]=h+x,e[7+i]=h-x,e[1+i]=r+v,e[6+i]=r-v,e[2+i]=c+d,e[5+i]=c-d,e[3+i]=t+n,e[4+i]=t-n}for(l=0;l<8;++l){var f=l;if(e[1*8+f]===0&&e[2*8+f]===0&&e[3*8+f]===0&&e[4*8+f]===0&&e[5*8+f]===0&&e[6*8+f]===0&&e[7*8+f]===0){a=R*e[l+0]+8192>>14,e[0*8+f]=a,e[1*8+f]=a,e[2*8+f]=a,e[3*8+f]=a,e[4*8+f]=a,e[5*8+f]=a,e[6*8+f]=a,e[7*8+f]=a;continue}h=R*e[0*8+f]+2048>>12,r=R*e[4*8+f]+2048>>12,c=e[2*8+f],t=e[6*8+f],n=se*(e[1*8+f]-e[7*8+f])+2048>>12,x=se*(e[1*8+f]+e[7*8+f])+2048>>12,d=e[3*8+f],v=e[5*8+f],a=h-r+1>>1,h=h+r+1>>1,r=a,a=c*fe+t*ie+2048>>12,c=c*ie-t*fe+2048>>12,t=a,a=n-v+1>>1,n=n+v+1>>1,v=a,a=x+d+1>>1,d=x-d+1>>1,x=a,a=h-t+1>>1,h=h+t+1>>1,t=a,a=r-c+1>>1,r=r+c+1>>1,c=a,a=n*ae+x*ne+2048>>12,n=n*ne-x*ae+2048>>12,x=a,a=d*re+v*ee+2048>>12,d=d*ee-v*re+2048>>12,v=a,e[0*8+f]=h+x,e[7*8+f]=h-x,e[1*8+f]=r+v,e[6*8+f]=r-v,e[2*8+f]=c+d,e[5*8+f]=c-d,e[3*8+f]=t+n,e[4*8+f]=t-n}for(l=0;l<64;++l){var G=s+l,u=e[l];u=u<=-2056/g.bitConversion?0:u>=2024/g.bitConversion?255/g.bitConversion:u+2056/g.bitConversion>>4,g.blockData[G]=u}}function de(g,s){for(var e=s.blocksPerLine,P=s.blocksPerColumn,h=new Int32Array(64),r=0;r<P;r++)for(var c=0;c<e;c++){var t=j(s,r,c);be(s,t,h)}return s.blockData}function W(g){return g<=0?0:g>=255?255:g|0}class xe{constructor(){}load(s){var e=(function(n){this.parse(n),this.onload&&this.onload()}).bind(this);if(s.indexOf("data:")>-1){for(var P=s.indexOf("base64,")+7,h=atob(s.substring(P)),r=new Uint8Array(h.length),c=h.length-1;c>=0;c--)r[c]=h.charCodeAt(c);e(h)}else{var t=new XMLHttpRequest;t.open("GET",s,!0),t.responseType="arraybuffer",t.onload=(function(){var n=new Uint8Array(t.response);e(n)}).bind(this),t.send(null)}}parse(s){function e(){var k=s[r]<<8|s[r+1];return r+=2,k}function P(){var k=e(),M=s.subarray(r,r+k-2);return r+=M.length,M}function h(k){for(var M=Math.ceil(k.samplesPerLine/8/k.maxH),q=Math.ceil(k.scanLines/8/k.maxV),Q=0;Q<k.components.length;Q++){C=k.components[Q];var ve=Math.ceil(Math.ceil(k.samplesPerLine/8)*C.h/k.maxH),te=Math.ceil(Math.ceil(k.scanLines/8)*C.v/k.maxV),oe=M*C.h,le=q*C.v,ue=64*le*(oe+1);C.blockData=new Int16Array(ue),C.blocksPerLine=ve,C.blocksPerColumn=te}k.mcusPerLine=M,k.mcusPerColumn=q}var r=0;s.length;var c=null,t=null,n,d,v=[],x=[],a=[],l=e();if(l!=65496)throw"SOI not found";for(l=e();l!=65497;){var i,f,G;switch(l){case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var u=P();l===65504&&u[0]===74&&u[1]===70&&u[2]===73&&u[3]===70&&u[4]===0&&(c={version:{major:u[5],minor:u[6]},densityUnits:u[7],xDensity:u[8]<<8|u[9],yDensity:u[10]<<8|u[11],thumbWidth:u[12],thumbHeight:u[13],thumbData:u.subarray(14,14+3*u[12]*u[13])}),l===65518&&u[0]===65&&u[1]===100&&u[2]===111&&u[3]===98&&u[4]===101&&u[5]===0&&(t={version:u[6],flags0:u[7]<<8|u[8],flags1:u[9]<<8|u[10],transformCode:u[11]});break;case 65499:for(var V=e(),D=V+r-2;r<D;){var L=s[r++],T=new Int32Array(64);if(L>>4)if(L>>4===1)for(f=0;f<64;f++){var y=$[f];T[y]=e()}else throw"DQT: invalid table spec";else for(f=0;f<64;f++){var S=$[f];T[S]=s[r++]}v[L&15]=T}break;case 65472:case 65473:case 65474:if(n)throw"Only single frame JPEGs supported";e(),n={},n.extended=l===65473,n.progressive=l===65474,n.precision=s[r++],n.scanLines=e(),n.samplesPerLine=e(),n.components=[],n.componentIds={};var X=s[r++],K,Z=0,E=0;for(i=0;i<X;i++){K=s[r];var B=s[r+1]>>4,U=s[r+1]&15;Z<B&&(Z=B),E<U&&(E=U);var Y=s[r+2];G=n.components.push({h:B,v:U,quantizationTable:v[Y],quantizationTableId:Y,bitConversion:255/((1<<n.precision)-1)}),n.componentIds[K]=G-1,r+=3}n.maxH=Z,n.maxV=E,h(n);break;case 65476:var w=e();for(i=2;i<w;){var z=s[r++],I=new Uint8Array(16),H=0;for(f=0;f<16;f++,r++)H+=I[f]=s[r];var F=new Uint8Array(H);for(f=0;f<H;f++,r++)F[f]=s[r];i+=17+H,(z>>4?x:a)[z&15]=ce(I,F)}break;case 65501:e(),d=e();break;case 65498:e();var N=s[r++],J=[],C;for(i=0;i<N;i++){var p=n.componentIds[s[r++]];C=n.components[p];var o=s[r++];C.huffmanTableDC=a[o>>4],C.huffmanTableAC=x[o&15],J.push(C)}var b=s[r++],m=s[r++],O=s[r++],A=he(s,r,n,J,d,b,m,O>>4,O&15);r+=A;break;case 65535:s[r]!==255&&r--;break;default:if(s[r-3]==255&&s[r-2]>=192&&s[r-2]<=254){r-=3;break}throw"unknown JPEG marker "+l.toString(16)}l=e()}switch(this.width=n.samplesPerLine,this.height=n.scanLines,this.jfif=c,this.adobe=t,this.components=[],n.components.length){case 1:this.colorspace=_.Grayscale;break;case 3:this.adobe?this.colorspace=_.AdobeRGB:this.colorspace=_.RGB;break;case 4:this.colorspace=_.CYMK;break;default:this.colorspace=_.Unknown}for(var i=0;i<n.components.length;i++){var C=n.components[i];!C.quantizationTable&&C.quantizationTableId!==null&&(C.quantizationTable=v[C.quantizationTableId]),this.components.push({output:de(n,C),scaleX:C.h/n.maxH,scaleY:C.v/n.maxV,blocksPerLine:C.blocksPerLine,blocksPerColumn:C.blocksPerColumn,bitConversion:C.bitConversion})}}getData16(s,e){if(this.components.length!==1)throw"Unsupported color mode";var P=this.width/s,h=this.height/e,r,c,t,n,d,v,x=0,a=this.components.length,l=s*e*a,i=new Uint16Array(l),f=new Uint16Array((this.components[0].blocksPerLine<<3)*this.components[0].blocksPerColumn*8);for(v=0;v<a;v++){r=this.components[v];for(var G=r.blocksPerLine,u=r.blocksPerColumn,V=G<<3,D,L,T=0,S=0;S<u;S++)for(var y=S<<3,X=0;X<G;X++){var K=j(r,S,X),x=0,Z=X<<3;for(D=0;D<8;D++){var T=(y+D)*V;for(L=0;L<8;L++)f[T+Z+L]=r.output[K+x++]}}c=r.scaleX*P,t=r.scaleY*h,x=v;var E,B,U;for(d=0;d<e;d++)for(n=0;n<s;n++)B=0|d*t,E=0|n*c,U=B*V+E,i[x]=f[U],x+=a}return i}getData(s,e){var P=this.width/s,h=this.height/e,r,c,t,n,d,v,x=0,a,l,i,f,G,u,V,D,L,T=this.components.length,S=s*e*T,y=new Uint8Array(S),X=new Uint8Array((this.components[0].blocksPerLine<<3)*this.components[0].blocksPerColumn*8);for(v=0;v<T;v++){r=this.components[v];for(var K=r.blocksPerLine,Z=r.blocksPerColumn,E=K<<3,B,U,Y=0,w=0;w<Z;w++)for(var z=w<<3,I=0;I<K;I++){var H=j(r,w,I),x=0,F=I<<3;for(B=0;B<8;B++){var Y=(z+B)*E;for(U=0;U<8;U++)X[Y+F+U]=r.output[H+x++]*r.bitConversion}}c=r.scaleX*P,t=r.scaleY*h,x=v;var N,J,C;for(d=0;d<e;d++)for(n=0;n<s;n++)J=0|d*t,N=0|n*c,C=J*E+N,y[x]=X[C],x+=T}switch(T){case 1:case 2:break;case 3:if(L=!0,this.adobe&&this.adobe.transformCode?L=!0:typeof this.colorTransform<"u"&&(L=!!this.colorTransform),L)for(v=0;v<S;v+=T)a=y[v],l=y[v+1],i=y[v+2],u=W(a-179.456+1.402*i),V=W(a+135.459-.344*l-.714*i),D=W(a-226.816+1.772*l),y[v]=u,y[v+1]=V,y[v+2]=D;break;case 4:if(!this.adobe)throw"Unsupported color mode (4 components)";if(L=!1,this.adobe&&this.adobe.transformCode?L=!0:typeof this.colorTransform<"u"&&(L=!!this.colorTransform),L)for(v=0;v<S;v+=T)a=y[v],l=y[v+1],i=y[v+2],f=W(434.456-a-1.402*i),G=W(119.541-a+.344*l+.714*i),a=W(481.816-a-1.772*l),y[v]=f,y[v+1]=G,y[v+2]=a;break;default:throw"Unsupported color mode"}return y}}export{xe as default};
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var b=Object.defineProperty;var k=(a,t,e)=>t in a?b(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var h=(a,t,e)=>k(a,typeof t!="symbol"?t+"":t,e);var y=Object.defineProperty,D=(a,t)=>{for(var e in t)y(a,e,{get:t[e],enumerable:!0})},L={hSamp:0,quantTableSel:0,vSamp:0},v=class{constructor(a,t,e){h(this,"buffer");h(this,"index");this.buffer=new Uint8Array(a,t,e),this.index=0}get16(){const a=(this.buffer[this.index]<<8)+this.buffer[this.index+1];return this.index+=2,a}get8(){const a=this.buffer[this.index];return this.index+=1,a}},S=class{constructor(){h(this,"dimX",0);h(this,"dimY",0);h(this,"numComp",0);h(this,"precision",0);h(this,"components",[])}read(a){let t=0,e;const r=a.get16();t+=2,this.precision=a.get8(),t+=1,this.dimY=a.get16(),t+=2,this.dimX=a.get16(),t+=2,this.numComp=a.get8(),t+=1;for(let n=1;n<=this.numComp;n+=1){if(t>r)throw new Error("ERROR: frame format error");const s=a.get8();if(t+=1,t>=r)throw new Error("ERROR: frame format error [c>=Lf]");e=a.get8(),t+=1,this.components[s]||(this.components[s]={...L}),this.components[s].hSamp=e>>4,this.components[s].vSamp=e&15,this.components[s].quantTableSel=a.get8(),t+=1}if(t!==r)throw new Error("ERROR: frame format error [Lf!=count]");return 1}},x={};D(x,{crc32:()=>I,crcTable:()=>T,createArray:()=>w,makeCRCTable:()=>E});var w=(...a)=>{if(a.length>1){const t=a[0],e=a.slice(1),r=[];for(let n=0;n<t;n++)r[n]=w(...e);return r}else return Array(a[0]).fill(void 0)},E=function(){let a;const t=[];for(let e=0;e<256;e++){a=e;for(let r=0;r<8;r++)a=a&1?3988292384^a>>>1:a>>>1;t[e]=a}return t},T=E(),I=function(a){const t=new Uint8Array(a);let e=-1;for(let r=0;r<t.length;r++)e=e>>>8^T[(e^t[r])&255];return(e^-1)>>>0},R,C=(R=class{constructor(){h(this,"l");h(this,"th");h(this,"v");h(this,"tc");this.l=w(4,2,16),this.th=[0,0,0,0],this.v=w(4,2,16,200),this.tc=[[0,0],[0,0],[0,0],[0,0]]}read(t,e){let r=0,n,s,o,i,c;const f=t.get16();for(r+=2;r<f;){if(n=t.get8(),r+=1,s=n&15,s>3)throw new Error("ERROR: Huffman table ID > 3");if(o=n>>4,o>2)throw new Error("ERROR: Huffman table [Table class > 2 ]");for(this.th[s]=1,this.tc[s][o]=1,i=0;i<16;i+=1)this.l[s][o][i]=t.get8(),r+=1;for(i=0;i<16;i+=1)for(c=0;c<this.l[s][o][i];c+=1){if(r>f)throw new Error("ERROR: Huffman table format error [count>Lh]");this.v[s][o][i][c]=t.get8(),r+=1}}if(r!==f)throw new Error("ERROR: Huffman table format error [count!=Lf]");for(i=0;i<4;i+=1)for(c=0;c<2;c+=1)this.tc[i][c]!==0&&this.buildHuffTable(e[i][c],this.l[i][c],this.v[i][c]);return 1}buildHuffTable(t,e,r){let n,s,o,i,c;for(s=0,o=0;o<8;o+=1)for(i=0;i<e[o];i+=1)for(c=0;c<256>>o+1;c+=1)t[s]=r[o][i]|o+1<<8,s+=1;for(o=1;s<256;o+=1,s+=1)t[s]=o|R.MSB;for(n=1,s=0,o=8;o<16;o+=1)for(i=0;i<e[o];i+=1){for(c=0;c<256>>o-7;c+=1)t[n*256+s]=r[o][i]|o+1<<8,s+=1;if(s>=256){if(s>256)throw new Error("ERROR: Huffman table error(1)!");s=0,n+=1}}}},h(R,"MSB",2147483648),R),p,B=(p=class{constructor(){h(this,"precision",[]);h(this,"tq",[0,0,0,0]);h(this,"quantTables",w(4,64))}read(t,e){let r=0,n,s,o;const i=t.get16();for(r+=2;r<i;){if(n=t.get8(),r+=1,s=n&15,s>3)throw new Error("ERROR: Quantization table ID > 3");if(this.precision[s]=n>>4,this.precision[s]===0)this.precision[s]=8;else if(this.precision[s]===1)this.precision[s]=16;else throw new Error("ERROR: Quantization table precision error");if(this.tq[s]=1,this.precision[s]===8){for(o=0;o<64;o+=1){if(r>i)throw new Error("ERROR: Quantization table format error");this.quantTables[s][o]=t.get8(),r+=1}p.enhanceQuantizationTable(this.quantTables[s],e)}else{for(o=0;o<64;o+=1){if(r>i)throw new Error("ERROR: Quantization table format error");this.quantTables[s][o]=t.get16(),r+=2}p.enhanceQuantizationTable(this.quantTables[s],e)}}if(r!==i)throw new Error("ERROR: Quantization table error [count!=Lq]");return 1}},h(p,"enhanceQuantizationTable",function(t,e){for(let r=0;r<8;r+=1)t[e[0*8+r]]*=90,t[e[4*8+r]]*=90,t[e[2*8+r]]*=118,t[e[6*8+r]]*=49,t[e[5*8+r]]*=71,t[e[1*8+r]]*=126,t[e[7*8+r]]*=25,t[e[3*8+r]]*=106;for(let r=0;r<8;r+=1)t[e[0+8*r]]*=90,t[e[4+8*r]]*=90,t[e[2+8*r]]*=118,t[e[6+8*r]]*=49,t[e[5+8*r]]*=71,t[e[1+8*r]]*=126,t[e[7+8*r]]*=25,t[e[3+8*r]]*=106;for(let r=0;r<64;r+=1)t[r]>>=6}),p),A={acTabSel:0,dcTabSel:0,scanCompSel:0},P=class{constructor(){h(this,"ah",0);h(this,"al",0);h(this,"numComp",0);h(this,"selection",0);h(this,"spectralEnd",0);h(this,"components",[])}read(a){let t=0,e,r;const n=a.get16();for(t+=2,this.numComp=a.get8(),t+=1,e=0;e<this.numComp;e+=1){if(this.components[e]={...A},t>n)throw new Error("ERROR: scan header format error");this.components[e].scanCompSel=a.get8(),t+=1,r=a.get8(),t+=1,this.components[e].dcTabSel=r>>4,this.components[e].acTabSel=r&15}if(this.selection=a.get8(),t+=1,this.spectralEnd=a.get8(),t+=1,r=a.get8(),this.ah=r>>4,this.al=r&15,t+=1,t!==n)throw new Error("ERROR: scan header format error [count!=Ns]");return 1}},d=function(){const a=new ArrayBuffer(2);return new DataView(a).setInt16(0,256,!0),new Int16Array(a)[0]===256}(),l,_=(l=class{constructor(t,e){h(this,"buffer",null);h(this,"stream",null);h(this,"frame",new S);h(this,"huffTable",new C);h(this,"quantTable",new B);h(this,"scan",new P);h(this,"DU",w(10,4,64));h(this,"HuffTab",w(4,2,50*256));h(this,"IDCT_Source",[]);h(this,"nBlock",[]);h(this,"acTab",w(10,1));h(this,"dcTab",w(10,1));h(this,"qTab",w(10,1));h(this,"marker",0);h(this,"markerIndex",0);h(this,"numComp",0);h(this,"restartInterval",0);h(this,"selection",0);h(this,"xDim",0);h(this,"yDim",0);h(this,"xLoc",0);h(this,"yLoc",0);h(this,"outputData",null);h(this,"restarting",!1);h(this,"mask",0);h(this,"numBytes",0);h(this,"precision");h(this,"components",[]);h(this,"getter",null);h(this,"setter",null);h(this,"output",null);h(this,"selector",null);this.buffer=t??null,this.numBytes=e??0}decompress(t,e,r){return this.decode(t,e,r).buffer}decode(t,e,r,n){let s=0;const o=[];let i,c;const f=[],g=[];let m;t&&(this.buffer=t),n!==void 0&&(this.numBytes=n),this.stream=new v(this.buffer,e,r),this.buffer=null,this.xLoc=0,this.yLoc=0;let u=this.stream.get16();if(u!==65496)throw new Error("Not a JPEG file");for(u=this.stream.get16();u>>4!==4092||u===65476;){switch(u){case 65476:this.huffTable.read(this.stream,this.HuffTab);break;case 65484:throw new Error("Program doesn't support arithmetic coding. (format throw new IOException)");case 65499:this.quantTable.read(this.stream,l.TABLE);break;case 65501:this.restartInterval=this.readNumber()??0;break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:this.readApp();break;case 65534:this.readComment();break;default:if(u>>8!==255)throw new Error("ERROR: format throw new IOException! (decode)")}u=this.stream.get16()}if(u<65472||u>65479)throw new Error("ERROR: could not handle arithmetic code!");this.frame.read(this.stream),u=this.stream.get16();do{for(;u!==65498;){switch(u){case 65476:this.huffTable.read(this.stream,this.HuffTab);break;case 65484:throw new Error("Program doesn't support arithmetic coding. (format throw new IOException)");case 65499:this.quantTable.read(this.stream,l.TABLE);break;case 65501:this.restartInterval=this.readNumber()??0;break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:this.readApp();break;case 65534:this.readComment();break;default:if(u>>8!==255)throw new Error("ERROR: format throw new IOException! (Parser.decode)")}u=this.stream.get16()}switch(this.precision=this.frame.precision,this.components=this.frame.components,this.numBytes||(this.numBytes=Math.round(Math.ceil(this.precision/8))),this.numBytes===1?this.mask=255:this.mask=65535,this.scan.read(this.stream),this.numComp=this.scan.numComp,this.selection=this.scan.selection,this.numBytes===1?this.numComp===3?(this.getter=this.getValueRGB,this.setter=this.setValueRGB,this.output=this.outputRGB):(this.getter=this.getValue8,this.setter=this.setValue8,this.output=this.outputSingle):(this.getter=this.getValue8,this.setter=this.setValue8,this.output=this.outputSingle),this.selection){case 2:this.selector=this.select2;break;case 3:this.selector=this.select3;break;case 4:this.selector=this.select4;break;case 5:this.selector=this.select5;break;case 6:this.selector=this.select6;break;case 7:this.selector=this.select7;break;default:this.selector=this.select1;break}for(i=0;i<this.numComp;i+=1)c=this.scan.components[i].scanCompSel,this.qTab[i]=this.quantTable.quantTables[this.components[c].quantTableSel],this.nBlock[i]=this.components[c].vSamp*this.components[c].hSamp,this.dcTab[i]=this.HuffTab[this.scan.components[i].dcTabSel][0],this.acTab[i]=this.HuffTab[this.scan.components[i].acTabSel][1];for(this.xDim=this.frame.dimX,this.yDim=this.frame.dimY,this.numBytes===1?this.outputData=new Uint8Array(new ArrayBuffer(this.xDim*this.yDim*this.numBytes*this.numComp)):this.outputData=new Uint16Array(new ArrayBuffer(this.xDim*this.yDim*this.numBytes*this.numComp)),s+=1;;){for(f[0]=0,g[0]=0,i=0;i<10;i+=1)o[i]=1<<this.precision-1;if(this.restartInterval===0){for(u=this.decodeUnit(o,f,g);u===0&&this.xLoc<this.xDim&&this.yLoc<this.yDim;)this.output(o),u=this.decodeUnit(o,f,g);break}for(m=0;m<this.restartInterval&&(this.restarting=m===0,u=this.decodeUnit(o,f,g),this.output(o),u===0);m+=1);if(u===0&&(this.markerIndex!==0?(u=65280|this.marker,this.markerIndex=0):u=this.stream.get16()),!(u>=l.RESTART_MARKER_BEGIN&&u<=l.RESTART_MARKER_END))break}u===65500&&s===1&&(this.readNumber(),u=this.stream.get16())}while(u!==65497&&this.xLoc<this.xDim&&this.yLoc<this.yDim&&s===0);return this.outputData}decodeUnit(t,e,r){return this.numComp===1?this.decodeSingle(t,e,r):this.numComp===3?this.decodeRGB(t,e,r):-1}select1(t){return this.getPreviousX(t)}select2(t){return this.getPreviousY(t)}select3(t){return this.getPreviousXY(t)}select4(t){return this.getPreviousX(t)+this.getPreviousY(t)-this.getPreviousXY(t)}select5(t){return this.getPreviousX(t)+(this.getPreviousY(t)-this.getPreviousXY(t)>>1)}select6(t){return this.getPreviousY(t)+(this.getPreviousX(t)-this.getPreviousXY(t)>>1)}select7(t){return(this.getPreviousX(t)+this.getPreviousY(t))/2}decodeRGB(t,e,r){if(this.selector===null)throw new Error("decode hasn't run yet");let n,s,o,i,c,f,g;for(t[0]=this.selector(0),t[1]=this.selector(1),t[2]=this.selector(2),i=0;i<this.numComp;i+=1)for(o=this.qTab[i],n=this.acTab[i],s=this.dcTab[i],c=0;c<this.nBlock[i];c+=1){for(f=0;f<this.IDCT_Source.length;f+=1)this.IDCT_Source[f]=0;let m=this.getHuffmanValue(s,e,r);if(m>=65280)return m;for(t[i]=this.IDCT_Source[0]=t[i]+this.getn(r,m,e,r),this.IDCT_Source[0]*=o[0],g=1;g<64;g+=1){if(m=this.getHuffmanValue(n,e,r),m>=65280)return m;if(g+=m>>4,m&15)this.IDCT_Source[l.IDCT_P[g]]=this.getn(r,m&15,e,r)*o[g];else if(!(m>>4))break}}return 0}decodeSingle(t,e,r){if(this.selector===null)throw new Error("decode hasn't run yet");let n,s,o,i;for(this.restarting?(this.restarting=!1,t[0]=1<<this.frame.precision-1):t[0]=this.selector(),s=0;s<this.nBlock[0];s+=1){if(n=this.getHuffmanValue(this.dcTab[0],e,r),n>=65280)return n;if(o=this.getn(t,n,e,r),i=o>>8,i>=l.RESTART_MARKER_BEGIN&&i<=l.RESTART_MARKER_END)return i;t[0]+=o}return 0}getHuffmanValue(t,e,r){let n,s;if(!this.stream)throw new Error("stream not initialized");if(r[0]<8?(e[0]<<=8,s=this.stream.get8(),s===255&&(this.marker=this.stream.get8(),this.marker!==0&&(this.markerIndex=9)),e[0]|=s):r[0]-=8,n=t[e[0]>>r[0]],n&l.MSB){if(this.markerIndex!==0)return this.markerIndex=0,65280|this.marker;e[0]&=65535>>16-r[0],e[0]<<=8,s=this.stream.get8(),s===255&&(this.marker=this.stream.get8(),this.marker!==0&&(this.markerIndex=9)),e[0]|=s,n=t[(n&255)*256+(e[0]>>r[0])],r[0]+=8}if(r[0]+=8-(n>>8),r[0]<0)throw new Error("index="+r[0]+" temp="+e[0]+" code="+n+" in HuffmanValue()");return r[0]<this.markerIndex?(this.markerIndex=0,65280|this.marker):(e[0]&=65535>>16-r[0],n&255)}getn(t,e,r,n){let s,o;if(this.stream===null)throw new Error("stream not initialized");if(e===0)return 0;if(e===16)return t[0]>=0?-32768:32768;if(n[0]-=e,n[0]>=0){if(n[0]<this.markerIndex&&!this.isLastPixel())return this.markerIndex=0,(65280|this.marker)<<8;s=r[0]>>n[0],r[0]&=65535>>16-n[0]}else{if(r[0]<<=8,o=this.stream.get8(),o===255&&(this.marker=this.stream.get8(),this.marker!==0&&(this.markerIndex=9)),r[0]|=o,n[0]+=8,n[0]<0){if(this.markerIndex!==0)return this.markerIndex=0,(65280|this.marker)<<8;r[0]<<=8,o=this.stream.get8(),o===255&&(this.marker=this.stream.get8(),this.marker!==0&&(this.markerIndex=9)),r[0]|=o,n[0]+=8}if(n[0]<0)throw new Error("index="+n[0]+" in getn()");if(n[0]<this.markerIndex)return this.markerIndex=0,(65280|this.marker)<<8;s=r[0]>>n[0],r[0]&=65535>>16-n[0]}return s<1<<e-1&&(s+=(-1<<e)+1),s}getPreviousX(t=0){if(this.getter===null)throw new Error("decode hasn't run yet");return this.xLoc>0?this.getter(this.yLoc*this.xDim+this.xLoc-1,t):this.yLoc>0?this.getPreviousY(t):1<<this.frame.precision-1}getPreviousXY(t=0){if(this.getter===null)throw new Error("decode hasn't run yet");return this.xLoc>0&&this.yLoc>0?this.getter((this.yLoc-1)*this.xDim+this.xLoc-1,t):this.getPreviousY(t)}getPreviousY(t=0){if(this.getter===null)throw new Error("decode hasn't run yet");return this.yLoc>0?this.getter((this.yLoc-1)*this.xDim+this.xLoc,t):this.getPreviousX(t)}isLastPixel(){return this.xLoc===this.xDim-1&&this.yLoc===this.yDim-1}outputSingle(t){if(this.setter===null)throw new Error("decode hasn't run yet");this.xLoc<this.xDim&&this.yLoc<this.yDim&&(this.setter(this.yLoc*this.xDim+this.xLoc,this.mask&t[0]),this.xLoc+=1,this.xLoc>=this.xDim&&(this.yLoc+=1,this.xLoc=0))}outputRGB(t){if(this.setter===null)throw new Error("decode hasn't run yet");const e=this.yLoc*this.xDim+this.xLoc;this.xLoc<this.xDim&&this.yLoc<this.yDim&&(this.setter(e,t[0],0),this.setter(e,t[1],1),this.setter(e,t[2],2),this.xLoc+=1,this.xLoc>=this.xDim&&(this.yLoc+=1,this.xLoc=0))}setValue8(t,e){if(!this.outputData)throw new Error("output data not ready");d?this.outputData[t]=e:this.outputData[t]=(e&255)<<8|e>>8&255}getValue8(t){if(this.outputData===null)throw new Error("output data not ready");if(d)return this.outputData[t];{const e=this.outputData[t];return(e&255)<<8|e>>8&255}}setValueRGB(t,e,r=0){this.outputData!==null&&(this.outputData[t*3+r]=e)}getValueRGB(t,e){if(this.outputData===null)throw new Error("output data not ready");return this.outputData[t*3+e]}readApp(){if(this.stream===null)return null;let t=0;const e=this.stream.get16();for(t+=2;t<e;)this.stream.get8(),t+=1;return e}readComment(){if(this.stream===null)return null;let t="",e=0;const r=this.stream.get16();for(e+=2;e<r;)t+=this.stream.get8(),e+=1;return t}readNumber(){if(this.stream===null)return null;if(this.stream.get16()!==4)throw new Error("ERROR: Define number format throw new IOException [Ld!=4]");return this.stream.get16()}},h(l,"IDCT_P",[0,5,40,16,45,2,7,42,21,56,8,61,18,47,1,4,41,23,58,13,32,24,37,10,63,17,44,3,6,43,20,57,15,34,29,48,53,26,39,9,60,19,46,22,59,12,33,31,50,55,25,36,11,62,14,35,28,49,52,27,38,30,51,54]),h(l,"TABLE",[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63]),h(l,"MAX_HUFFMAN_SUBTREE",50),h(l,"MSB",2147483648),h(l,"RESTART_MARKER_BEGIN",65488),h(l,"RESTART_MARKER_END",65495),l);export{L as ComponentSpec,v as DataStream,_ as Decoder,S as FrameHeader,C as HuffmanTable,B as QuantizationTable,A as ScanComponent,P as ScanHeader,x as Utils};
|
|
Binary file
|
|
Binary file
|
package/public/config.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Runtime configuration for OrbiDICOM (loaded before the app).
|
|
2
|
+
//
|
|
3
|
+
// This default ships an empty config for local development and static hosting.
|
|
4
|
+
// The container image regenerates this file at startup from environment
|
|
5
|
+
// variables (ORBIDICOM_PACS_URL, ORBIDICOM_STUDY_UID), so one image works
|
|
6
|
+
// against any PACS without rebuilding. Edit freely for static hosting.
|
|
7
|
+
window.__ORBIDICOM_CONFIG__ = {
|
|
8
|
+
// DICOMweb base the browser calls. "" = local-file-only.
|
|
9
|
+
// With the bundled nginx reverse proxy, set this to "/dicom-web".
|
|
10
|
+
pacsUrl: "",
|
|
11
|
+
// Optional Study Instance UID to auto-open on load.
|
|
12
|
+
studyUid: "",
|
|
13
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
|
6
|
+
<title>OrbiDICOM</title>
|
|
7
|
+
<script type="module" crossorigin src="./assets/index-CkA8WclG.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="./assets/index-6485mdZB.css">
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="app"></div>
|
|
12
|
+
<!-- Runtime config (PACS URL etc.); regenerated from env at container start. -->
|
|
13
|
+
<script src="./config.js"></script>
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|