@loaders.gl/scientific 5.0.0-beta.4 → 5.0.0-beta.6
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 +6 -2
- package/dist/hdf5/http-range-reader.d.ts.map +1 -1
- package/dist/hdf5/http-range-reader.js +2 -12
- package/dist/hdf5/http-range-reader.js.map +1 -1
- package/dist/hdf5/index.cjs +2 -11
- package/dist/hdf5/index.cjs.map +2 -2
- package/dist/index.cjs +48 -4
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/netcdf/bundled.cjs +12 -1
- package/dist/netcdf/index.cjs +12 -1
- package/dist/netcdf/index.cjs.map +1 -1
- package/dist/netcdf/netcdf-loader.cjs +1 -1
- package/dist/netcdf/netcdf-loader.js +1 -1
- package/dist/netcdf/netcdf-source-loader-types.js +1 -1
- package/dist/netcdf/netcdf-source-loader.cjs +12 -1
- package/dist/netcdf/netcdf-source-loader.d.ts.map +1 -1
- package/dist/netcdf/netcdf-source-loader.js +19 -2
- package/dist/netcdf/netcdf-source-loader.js.map +1 -1
- package/dist/netcdf/unbundled.cjs +12 -1
- package/dist/netcdf.dev.js +55 -2
- package/dist/netcdf.min.js +3 -3
- package/dist/npy-loader-types.cjs +1 -1
- package/dist/npy-loader-types.js +1 -1
- package/dist/npy-loader.cjs +1 -1
- package/dist/npy-worker.js +239 -11
- package/dist/nrrd/parse-nrrd.d.ts +22 -0
- package/dist/nrrd/parse-nrrd.d.ts.map +1 -0
- package/dist/nrrd/parse-nrrd.js +228 -0
- package/dist/nrrd/parse-nrrd.js.map +1 -0
- package/dist/nrrd-loader-types.cjs +58 -0
- package/dist/nrrd-loader-types.cjs.map +7 -0
- package/dist/nrrd-loader-types.d.ts +31 -0
- package/dist/nrrd-loader-types.d.ts.map +1 -0
- package/dist/nrrd-loader-types.js +25 -0
- package/dist/nrrd-loader-types.js.map +1 -0
- package/dist/nrrd-loader.cjs +252 -0
- package/dist/nrrd-loader.cjs.map +6 -0
- package/dist/nrrd-loader.d.ts +16 -0
- package/dist/nrrd-loader.d.ts.map +1 -0
- package/dist/nrrd-loader.js +8 -0
- package/dist/nrrd-loader.js.map +1 -0
- package/dist/vtk/index.cjs +26 -3
- package/dist/vtk/index.cjs.map +2 -2
- package/dist/vtk/vtk.d.ts.map +1 -1
- package/dist/vtk/vtk.js +19 -1
- package/dist/vtk/vtk.js.map +1 -1
- package/dist/vtk-loader-types.cjs +58 -0
- package/dist/vtk-loader-types.cjs.map +7 -0
- package/dist/vtk-loader-types.d.ts +34 -0
- package/dist/vtk-loader-types.d.ts.map +1 -0
- package/dist/vtk-loader-types.js +25 -0
- package/dist/vtk-loader-types.js.map +1 -0
- package/dist/vtk-loader.cjs +384 -0
- package/dist/vtk-loader.cjs.map +6 -0
- package/dist/vtk-loader.d.ts +21 -0
- package/dist/vtk-loader.d.ts.map +1 -0
- package/dist/vtk-loader.js +21 -0
- package/dist/vtk-loader.js.map +1 -0
- package/dist/zarr/geo-zarr-source-loader.js +1 -1
- package/dist/zarr/index.cjs.map +1 -1
- package/dist/zarr/ome-zarr-source-loader.js +1 -1
- package/dist/zarr/zarr-loader-types.cjs +1 -1
- package/dist/zarr/zarr-loader-types.js +1 -1
- package/dist/zarr.dev.js +43 -1
- package/dist/zarr.min.js +20 -20
- package/package.json +19 -7
- package/src/hdf5/http-range-reader.ts +3 -11
- package/src/index.ts +7 -1
- package/src/netcdf/netcdf-source-loader.ts +24 -1
- package/src/nrrd/parse-nrrd.ts +267 -0
- package/src/nrrd-loader-types.ts +25 -0
- package/src/nrrd-loader.ts +7 -0
- package/src/vtk/vtk.ts +28 -1
- package/src/vtk-loader-types.ts +25 -0
- package/src/vtk-loader.ts +19 -0
package/dist/netcdf.min.js
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['loaders'] = factory();
|
|
6
6
|
else root['loaders'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var Wt=Object.create;var Q=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var Vt=Object.getOwnPropertyNames;var Gt=Object.getPrototypeOf,Qt=Object.prototype.hasOwnProperty;var D=(t,e,r)=>()=>{if(r)throw r[0];try{return t&&(e=t(t=0)),e}catch(n){throw r=[n],n}};var Jt=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},Zt=(t,e)=>{for(var r in e)Q(t,r,{get:e[r],enumerable:!0})},rt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Vt(e))!Qt.call(t,s)&&s!==r&&Q(t,s,{get:()=>e[s],enumerable:!(n=zt(e,s))||n.enumerable});return t};var Yt=(t,e,r)=>(r=t!=null?Wt(Gt(t)):{},rt(e||!t||!t.__esModule?Q(r,"default",{value:t,enumerable:!0}):r,t)),Kt=t=>rt(Q({},"__esModule",{value:!0}),t);var st=Jt((Zr,nt)=>{nt.exports=globalThis.loaders});var te,Dt=D(()=>{"use strict";te=class t{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;textDecoder=new TextDecoder;textEncoder=new TextEncoder;constructor(e=8192,r={}){let n=!1;typeof e=="number"?e=new ArrayBuffer(e):(n=!0,this.lastWrittenByte=e.byteLength);let s=r.offset?r.offset>>>0:0,o=e.byteLength-s,c=s;(ArrayBuffer.isView(e)||e instanceof t)&&(e.byteLength!==e.buffer.byteLength&&(c=e.byteOffset+s),e=e.buffer),n?this.lastWrittenByte=o:this.lastWrittenByte=0,this.buffer=e,this.length=o,this.byteLength=o,this.byteOffset=c,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,c,o),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){let e=this._marks.pop();if(e===void 0)throw new Error("Mark stack empty");return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){let n=(this.offset+e)*2,s=new Uint8Array(n);s.set(new Uint8Array(this.buffer)),this.buffer=s.buffer,this.length=this.byteLength=n,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e=1){let r=new Uint8Array(e);for(let n=0;n<e;n++)r[n]=this.readByte();return r}readInt16(){let e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){let e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){let e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){let e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){let e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){let e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let r="";for(let n=0;n<e;n++)r+=this.readChar();return r}readUtf8(e=1){return this.textDecoder.decode(this.readBytes(e))}writeBoolean(e){return this.writeUint8(e?255:0),this}writeInt8(e){return this.ensureAvailable(1),this._data.setInt8(this.offset++,e),this._updateLastWrittenByte(),this}writeUint8(e){return this.ensureAvailable(1),this._data.setUint8(this.offset++,e),this._updateLastWrittenByte(),this}writeByte(e){return this.writeUint8(e)}writeBytes(e){this.ensureAvailable(e.length);for(let r=0;r<e.length;r++)this._data.setUint8(this.offset++,e[r]);return this._updateLastWrittenByte(),this}writeInt16(e){return this.ensureAvailable(2),this._data.setInt16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(e){return this.ensureAvailable(2),this._data.setUint16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(e){return this.ensureAvailable(4),this._data.setInt32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(e){return this.ensureAvailable(4),this._data.setUint32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(e){return this.ensureAvailable(4),this._data.setFloat32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(e){return this.ensureAvailable(8),this._data.setFloat64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(e){return this.writeUint8(e.charCodeAt(0))}writeChars(e){for(let r=0;r<e.length;r++)this.writeUint8(e.charCodeAt(r));return this}writeUtf8(e){let r=this.textEncoder.encode(e);return this.writeBytes(r)}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}});function V(t,e,r){switch(e){case m.BYTE:return t.readBytes(r);case m.CHAR:return Br(t.readChars(r));case m.SHORT:return re(r,t.readInt16.bind(t));case m.INT:return re(r,t.readInt32.bind(t));case m.FLOAT:return re(r,t.readFloat32.bind(t));case m.DOUBLE:return re(r,t.readFloat64.bind(t));default:throw new Error(`NetCDF: non valid type ${e}`)}}function Ve(t){switch(Number(t)){case m.BYTE:return"byte";case m.CHAR:return"char";case m.SHORT:return"short";case m.INT:return"int";case m.FLOAT:return"float";case m.DOUBLE:return"double";default:return"undefined"}}function It(t){switch(Number(t)){case m.BYTE:return 1;case m.CHAR:return 1;case m.SHORT:return 2;case m.INT:return 4;case m.FLOAT:return 4;case m.DOUBLE:return 8;default:return-1}}function Ge(t){switch(String(t)){case"byte":return m.BYTE;case"char":return m.CHAR;case"short":return m.SHORT;case"int":return m.INT;case"float":return m.FLOAT;case"double":return m.DOUBLE;default:return-1}}function re(t,e){if(t!==1){let r=new Array(t);for(let n=0;n<t;n++)r[n]=e();return r}return e()}function Br(t){return t.charCodeAt(t.length-1)===0?t.substring(0,t.length-1):t}var m,Qe=D(()=>{"use strict";m={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6}});function Ut(t,e){let r=t.readUint32(),n=Dr(t),s=Pt(t),o=Ir(t,n.recordId,e);return{version:e,recordDimension:{length:r,id:n.recordId,name:n.recordName,recordStep:o.recordStep},dimensions:n.dimensions,variables:o.variables,attributes:s}}function Dr(t){let e=t.readUint32();if(e===k){if(t.readUint32()!==k)throw new Error("NetCDF: wrong empty tag for list of dimensions");return{recordId:0,recordName:"",dimensions:[]}}if(e!==Nr)throw new Error("NetCDF: wrong tag for list of dimensions");let r=t.readUint32(),n=new Array(r),s,o;for(let c=0;c<r;c++){let d=Je(t),h=t.readUint32();h===Fr&&(s=c,o=d),n[c]={name:d,size:h}}return{dimensions:n,recordId:s,recordName:o}}function Pt(t){let e=t.readUint32();if(e===k){if(t.readUint32()!==k)throw new Error("NetCDF: wrong empty tag for list of attributes");return[]}if(e!==Lr)throw new Error("NetCDF: wrong tag for list of attributes");let r=t.readUint32(),n=new Array(r);for(let s=0;s<r;s++){let o=Je(t),c=t.readUint32();if(c<1||c>6)throw new Error(`NetCDF: non valid type ${c}`);let d=t.readUint32(),h=V(t,c,d);Ot(t),n[s]={name:o,type:Ve(c),value:h}}return n}function Ir(t,e,r){let n=t.readUint32(),s=0;if(n===k){if(t.readUint32()!==k)throw new Error("NetCDF: wrong empty tag for list of variables");return{recordStep:s,variables:[]}}if(n!==vr)throw new Error("NetCDF: wrong tag for list of variables");let o=t.readUint32(),c=new Array(o);for(let d=0;d<o;d++){let h=Je(t),a=t.readUint32(),l=new Array(a);for(let w=0;w<a;w++)l[w]=t.readUint32();let f=Pt(t),u=t.readUint32();if(u<1&&u>6)throw new Error(`NetCDF: non valid type ${u}`);let g=t.readUint32(),p=t.readUint32();if(r===2){if(p>0)throw new Error("NetCDF: offsets larger than 4GB not supported");p=t.readUint32()}let b=!1;typeof e<"u"&&l[0]===e&&(s+=g,b=!0),c[d]={name:h,dimensions:l,attributes:f,type:Ve(u),size:g,offset:p,record:b}}return{variables:c,recordStep:s}}function Je(t){let e=t.readUint32(),r=t.readChars(e);return Ot(t),r}function Ot(t){t.offset%4!==0&&t.skip(4-t.offset%4)}var k,Nr,vr,Lr,Fr,kt=D(()=>{"use strict";Qe();k=0,Nr=10,vr=11,Lr=12,Fr=0});function jt(t,e){let r=Ge(e.type),n=e.size/It(r),s=new Array(n);for(let o=0;o<n;o++)s[o]=V(t,r,1);return s}function $t(t,e,r,n){let s=Ge(e.type),o=e.dimensions.filter(a=>a!==r.id).reduce((a,l)=>a*n[l].size,1),c=r.length,d=new Array(c),h=r.recordStep;for(let a=0;a<c;a++){let l=t.offset;d[a]=V(t,s,o),t.seek(l+h)}return d}var Ht=D(()=>{"use strict";Qe()});var S,Ze=D(()=>{"use strict";Dt();kt();Ht();S=class{header;buffer;constructor(e){let r=new te(e);r.setBigEndian();let n=r.readChars(3);if(n!=="CDF")throw new Error(`NetCDF: file should start with 'CDF', found ${n}`);let s=r.readByte();if(s>2)throw new Error(`NetCDF: unsupported version ${s}`);this.header=Ut(r,s),this.buffer=r}get version(){return this.header.version===1?"classic format":"64-bit offset format"}get recordDimension(){return this.header.recordDimension}get dimensions(){return this.header.dimensions}get attributes(){return this.header.attributes}get variables(){return this.header.variables}attributeExists(e){return this.attributes.find(n=>n.name===e)!==void 0}getAttribute(e){let r=this.attributes.find(n=>n.name===e);return r?r.value:null}dataVariableExists(e){return this.header.variables.find(function(n){return n.name===e})!==void 0}getDataVariableAsString(e){let r=this.getDataVariable(e);return r?r.join(""):null}getDataVariable(e){let r;if(typeof e=="string"?r=this.header.variables.find(function(n){return n.name===e}):r=e,r===void 0){let n;throw typeof e=="string"?n=e:typeof e=="object"&&(n=JSON.stringify(e)),new Error(`NetCDF: variable not found: ${n}`)}return this.buffer.seek(r.offset),r.record?$t(this.buffer,r,this.header.recordDimension,this.header.dimensions):jt(this.buffer,r)}toString(){let e=[];e.push("DIMENSIONS");for(let n of this.dimensions)e.push(` ${n.name.padEnd(30)} = size: ${n.size}`);e.push(""),e.push("GLOBAL ATTRIBUTES");for(let n of this.attributes)e.push(` ${n.name.padEnd(30)} = ${n.value}`);let r=JSON.parse(JSON.stringify(this.variables));e.push(""),e.push("VARIABLES:");for(let n of r){n.value=this.getDataVariable(n);let s=JSON.stringify(n.value);s.length>50&&(s=s.substring(0,50)),Number.isNaN(n.value.length)||(s+=` (length: ${n.value.length})`),e.push(` ${n.name.padEnd(30)} = ${s}`)}return e.join(`
|
|
8
|
-
`)}}});var G,Ye=D(()=>{"use strict";G={name:"NetCDF",id:"netcdf",module:"netcdf",encoding:"binary",format:"netcdf",extensions:["cdf","nc"],mimeTypes:["application/x-netcdf"],binary:!0}});var Qr={};Zt(Qr,{FetchError:()=>i.FetchError,JSONLoader:()=>He,NetCDFFormat:()=>G,NetCDFReader:()=>S,NetCDFSourceLoader:()=>se,NullLoader:()=>i.NullLoader,NullWorkerLoader:()=>i.NullWorkerLoader,RequestScheduler:()=>O,_BrowserFileSystem:()=>i._BrowserFileSystem,_fetchProgress:()=>i._fetchProgress,_selectSource:()=>i._selectSource,_unregisterLoaders:()=>i._unregisterLoaders,assert:()=>ae,concatenateArrayBuffersAsync:()=>De,coreApi:()=>i.coreApi,createDataSource:()=>i.createDataSource,document:()=>le,encode:()=>i.encode,encodeInBatches:()=>i.encodeInBatches,encodeSync:()=>i.encodeSync,encodeTable:()=>i.encodeTable,encodeTableAsText:()=>i.encodeTableAsText,encodeTableInBatches:()=>i.encodeTableInBatches,encodeText:()=>i.encodeText,encodeTextSync:()=>i.encodeTextSync,encodeURLtoURL:()=>i.encodeURLtoURL,fetchFile:()=>i.fetchFile,forEach:()=>Fe,getLoaderOptions:()=>i.getLoaderOptions,getPathPrefix:()=>$e,global:()=>fe,isAsyncIterable:()=>Se,isBrowser:()=>de,isIterable:()=>Ee,isIterator:()=>Ae,isPromise:()=>Te,isPureObject:()=>q,isReadableStream:()=>Re,isResponse:()=>_e,isWorker:()=>he,isWritableStream:()=>Ce,load:()=>i.load,loadInBatches:()=>i.loadInBatches,makeIterator:()=>i.makeIterator,makeLineIterator:()=>ve,makeNumberedLineIterator:()=>Le,makeStream:()=>i.makeStream,makeTextDecoderIterator:()=>Be,makeTextEncoderIterator:()=>Ne,parse:()=>i.parse,parseFile:()=>i.parseFile,parseInBatches:()=>i.parseInBatches,parseSync:()=>i.parseSync,preload:()=>i.preload,preloadSync:()=>i.preloadSync,readArrayBuffer:()=>i.readArrayBuffer,registerLoaders:()=>i.registerLoaders,resolvePath:()=>W,selectLoader:()=>i.selectLoader,selectLoaderSync:()=>i.selectLoaderSync,self:()=>ce,setLoaderOptions:()=>i.setLoaderOptions,setPathPrefix:()=>je,window:()=>ue});var i=Yt(st(),1);function ae(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var T={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},ce=T.self||T.window||T.global||{},ue=T.window||T.self||T.global||{},fe=T.global||T.self||T.window||{},le=T.document||{};var de=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser),he=typeof importScripts=="function",ot=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Xt=ot&&parseFloat(ot[1])||0;var j=globalThis,er=globalThis.document||{},J=globalThis.process||{},tr=globalThis.console,rr=globalThis.navigator||{};function Z(t){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let e=typeof navigator<"u"&&navigator.userAgent,r=t||e;return!!(r&&r.indexOf("Electron")>=0)}function R(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Z()}var me="5.0.0";function I(t,e){if(!t)throw new Error(e||"Assertion failed")}function Y(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return I(Number.isFinite(e)&&e>=0),e}function pe(t){let{logLevel:e,message:r}=t;t.logLevel=Y(e);let n=t.args?Array.from(t.args):[];for(;n.length&&n.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&n.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let s=typeof t.message;return I(s==="string"||s==="object"),Object.assign(t,{args:n},t.opts)}var C=()=>{},v=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...r){return this._log("warn",0,e,r,{once:!0})}error(e,...r){return this._log("error",0,e,r)}log(e,r,...n){return this._log("log",e,r,n)}info(e,r,...n){return this._log("info",e,r,n)}once(e,r,...n){return this._log("once",e,r,n,{once:!0})}_log(e,r,n,s,o={}){let c=pe({logLevel:r,message:n,args:this._buildArgs(r,n,s),opts:o});return this._createLogFunction(e,c,o)}_buildArgs(e,r,n){return[e,r,...n]}_createLogFunction(e,r,n){if(!this._shouldLog(r.logLevel))return C;let s=this._getOnceTag(n.tag??r.tag??r.message);if((n.once||r.once)&&s!==void 0){if(this._onceCache.has(s))return C;this._onceCache.add(s)}return this._emit(e,r)}_shouldLog(e){return this.getLevel()>=Y(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}};function sr(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var $=class{constructor(e,r,n="sessionStorage"){this.storage=sr(n),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}};function it(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function ge(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var H;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(H||(H={}));var or=10;function at(t){return typeof t!="string"?t:(t=t.toUpperCase(),H[t]||H.WHITE)}function ye(t,e,r){return!R&&typeof t=="string"&&(e&&(t=`\x1B[${at(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${at(r)+or}m${t}\x1B[49m`)),t}function be(t,e=["constructor"]){let r=Object.getPrototypeOf(t),n=Object.getOwnPropertyNames(r),s=t;for(let o of n){let c=s[o];typeof c=="function"&&(e.find(d=>o===d)||(s[o]=c.bind(t)))}}var K=class{getHighResolutionTimer(){let e;if(R()&&j.performance)e=j?.performance?.now?.();else if("hrtime"in J){let r=J?.hrtime?.();e=r[0]*1e3+r[1]/1e6}else e=Date.now();return e}getMemoryUsageMB(){let r=j?.performance?.memory?.usedJSHeapSize;return r==null?null:Math.trunc(r/1024/1024)}},x=new K;globalThis.Probe=K;globalThis.probe=x;var U={debug:R()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},we={enabled:!0,level:0},E=class extends v{constructor({id:e}={id:""}){super({level:0}),this.VERSION=me,this._startTs=x.getHighResolutionTimer(),this._deltaTs=x.getHighResolutionTimer(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new $(`__probe-${this.id}__`,{[this.id]:we}),this.timeStamp(`${this.id} started`),be(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((x.getHighResolutionTimer()-this._startTs).toPrecision(10))}getDelta(){return Number((x.getHighResolutionTimer()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,r){this._updateConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e,...r){return this._log("warn",0,e,r,{method:U.warn,once:!0})}error(e,...r){return this._log("error",0,e,r,{method:U.error})}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r,...n){let s=x.getMemoryUsageMB();if(s!==null){let o=`${s}MB `;typeof r=="function"?r=()=>`${o}${r()}`:typeof r=="string"&&(r=`${o}${r}`)}return this._log("log",e,r,n,{method:U.log,time:!0,once:!0})}log(e,r,...n){return this._log("log",e,r,n,{method:U.debug})}info(e,r,...n){return this._log("info",e,r,n,{method:console.info})}once(e,r,...n){return this._log("once",e,r,n,{method:U.debug||U.info,once:!0})}table(e,r,n){return r?this._log("table",e,r,n&&[n]||[],{method:console.table||C,tag:ar(r)}):C}time(e,r){return this._log("time",e,r,[],{method:console.time?console.time:console.info})}timeEnd(e,r){return this._log("time",e,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,r){return this._log("time",e,r,[],{method:console.timeStamp||C})}group(e,r,n={collapsed:!1}){let s=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,r,[],{method:s})}groupCollapsed(e,r,n={}){return this.group(e,r,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||C})}withGroup(e,r,n){this.group(e,r)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,r){let n=r.method;I(n),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=x.getHighResolutionTimer();let s=ir(this.id,r.message,r);return n.bind(console,s,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(we),this._storage.config[this.id]}_updateConfiguration(e){let r=this._storage.config[this.id]||{...we};this._storage.setConfiguration({[this.id]:{...r,...e}})}};E.VERSION=me;function ir(t,e,r){if(typeof e=="string"){let n=r.time?ge(it(r.total)):"";e=r.time?`${t}: ${n} ${e}`:`${t}: ${e}`,e=ye(e,r.color,r.background)}return e}function ar(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}globalThis.probe||(globalThis.probe=x);var Xn=new E({id:"@probe.gl/log"});var xe="5.0.0-beta.4",cr=xe[0]>="0"&&xe[0]<="9"?`v${xe}`:"";function ur(){let t=new E({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=t,globalThis.loaders.version=cr,globalThis.probe||={},globalThis.probe.loaders=t,t}var ct=ur();var ut=t=>typeof t=="boolean",y=t=>typeof t=="function",B=t=>t!==null&&typeof t=="object",q=t=>B(t)&&t.constructor==={}.constructor;var Te=t=>B(t)&&"then"in t&&y(t.then),Ee=t=>!!t&&y(t[Symbol.iterator]),Se=t=>!!t&&y(t[Symbol.asyncIterator]),Ae=t=>!!t&&y(t.next),_e=t=>typeof Response<"u"&&t instanceof Response||B(t)&&y(t.arrayBuffer)&&y(t.text)&&y(t.json);var ft=t=>B(t)&&y(t.abort)&&y(t.getWriter),lt=t=>typeof ReadableStream<"u"&&t instanceof ReadableStream||B(t)&&y(t.tee)&&y(t.cancel)&&y(t.getReader),dt=t=>B(t)&&y(t.end)&&y(t.write)&&ut(t.writable),ht=t=>B(t)&&y(t.read)&&y(t.pipe)&&ut(t.readable),Re=t=>lt(t)||ht(t),Ce=t=>ft(t)||dt(t);function X(t,e){return mt(t||{},e)}function mt(t,e,r=0){if(r>3)return e;let n={...t};for(let[s,o]of Object.entries(e))q(o)?n[s]=mt(n[s]||{},e[s],r+1):n[s]=e[s];return n}function pt(...t){return fr(t)}function fr(t){let e=t.map(o=>o instanceof ArrayBuffer?new Uint8Array(o):o),r=e.reduce((o,c)=>o+c.byteLength,0),n=new Uint8Array(r),s=0;for(let o of e)n.set(o,s),s+=o.byteLength;return n.buffer}async function*Be(t,e={}){let r=new TextDecoder(void 0,e);for await(let n of t)yield typeof n=="string"?n:r.decode(n,{stream:!0})}async function*Ne(t){let e=new TextEncoder;for await(let r of t)yield typeof r=="string"?e.encode(r).buffer:r}async function*ve(t){let e="";for await(let r of t){e+=r;let n;for(n=e.indexOf(`
|
|
7
|
+
"use strict";var __exports__=(()=>{var Wt=Object.create;var Q=Object.defineProperty;var Vt=Object.getOwnPropertyDescriptor;var Gt=Object.getOwnPropertyNames;var Qt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var F=(t,e,r)=>()=>{if(r)throw r[0];try{return t&&(e=t(t=0)),e}catch(n){throw r=[n],n}};var Zt=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},Yt=(t,e)=>{for(var r in e)Q(t,r,{get:e[r],enumerable:!0})},rt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Gt(e))!Jt.call(t,s)&&s!==r&&Q(t,s,{get:()=>e[s],enumerable:!(n=Vt(e,s))||n.enumerable});return t};var Kt=(t,e,r)=>(r=t!=null?Wt(Qt(t)):{},rt(e||!t||!t.__esModule?Q(r,"default",{value:t,enumerable:!0}):r,t)),Xt=t=>rt(Q({},"__esModule",{value:!0}),t);var st=Zt((Kr,nt)=>{nt.exports=globalThis.loaders});var te,It=F(()=>{"use strict";te=class t{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;textDecoder=new TextDecoder;textEncoder=new TextEncoder;constructor(e=8192,r={}){let n=!1;typeof e=="number"?e=new ArrayBuffer(e):(n=!0,this.lastWrittenByte=e.byteLength);let s=r.offset?r.offset>>>0:0,o=e.byteLength-s,c=s;(ArrayBuffer.isView(e)||e instanceof t)&&(e.byteLength!==e.buffer.byteLength&&(c=e.byteOffset+s),e=e.buffer),n?this.lastWrittenByte=o:this.lastWrittenByte=0,this.buffer=e,this.length=o,this.byteLength=o,this.byteOffset=c,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,c,o),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){let e=this._marks.pop();if(e===void 0)throw new Error("Mark stack empty");return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){let n=(this.offset+e)*2,s=new Uint8Array(n);s.set(new Uint8Array(this.buffer)),this.buffer=s.buffer,this.length=this.byteLength=n,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e=1){let r=new Uint8Array(e);for(let n=0;n<e;n++)r[n]=this.readByte();return r}readInt16(){let e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){let e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){let e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){let e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){let e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){let e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let r="";for(let n=0;n<e;n++)r+=this.readChar();return r}readUtf8(e=1){return this.textDecoder.decode(this.readBytes(e))}writeBoolean(e){return this.writeUint8(e?255:0),this}writeInt8(e){return this.ensureAvailable(1),this._data.setInt8(this.offset++,e),this._updateLastWrittenByte(),this}writeUint8(e){return this.ensureAvailable(1),this._data.setUint8(this.offset++,e),this._updateLastWrittenByte(),this}writeByte(e){return this.writeUint8(e)}writeBytes(e){this.ensureAvailable(e.length);for(let r=0;r<e.length;r++)this._data.setUint8(this.offset++,e[r]);return this._updateLastWrittenByte(),this}writeInt16(e){return this.ensureAvailable(2),this._data.setInt16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(e){return this.ensureAvailable(2),this._data.setUint16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(e){return this.ensureAvailable(4),this._data.setInt32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(e){return this.ensureAvailable(4),this._data.setUint32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(e){return this.ensureAvailable(4),this._data.setFloat32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(e){return this.ensureAvailable(8),this._data.setFloat64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(e){return this.writeUint8(e.charCodeAt(0))}writeChars(e){for(let r=0;r<e.length;r++)this.writeUint8(e.charCodeAt(r));return this}writeUtf8(e){let r=this.textEncoder.encode(e);return this.writeBytes(r)}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}});function V(t,e,r){switch(e){case m.BYTE:return t.readBytes(r);case m.CHAR:return vr(t.readChars(r));case m.SHORT:return re(r,t.readInt16.bind(t));case m.INT:return re(r,t.readInt32.bind(t));case m.FLOAT:return re(r,t.readFloat32.bind(t));case m.DOUBLE:return re(r,t.readFloat64.bind(t));default:throw new Error(`NetCDF: non valid type ${e}`)}}function Ve(t){switch(Number(t)){case m.BYTE:return"byte";case m.CHAR:return"char";case m.SHORT:return"short";case m.INT:return"int";case m.FLOAT:return"float";case m.DOUBLE:return"double";default:return"undefined"}}function Ut(t){switch(Number(t)){case m.BYTE:return 1;case m.CHAR:return 1;case m.SHORT:return 2;case m.INT:return 4;case m.FLOAT:return 4;case m.DOUBLE:return 8;default:return-1}}function Ge(t){switch(String(t)){case"byte":return m.BYTE;case"char":return m.CHAR;case"short":return m.SHORT;case"int":return m.INT;case"float":return m.FLOAT;case"double":return m.DOUBLE;default:return-1}}function re(t,e){if(t!==1){let r=new Array(t);for(let n=0;n<t;n++)r[n]=e();return r}return e()}function vr(t){return t.charCodeAt(t.length-1)===0?t.substring(0,t.length-1):t}var m,Qe=F(()=>{"use strict";m={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6}});function Pt(t,e){let r=t.readUint32(),n=Ur(t),s=Ot(t),o=Pr(t,n.recordId,e);return{version:e,recordDimension:{length:r,id:n.recordId,name:n.recordName,recordStep:o.recordStep},dimensions:n.dimensions,variables:o.variables,attributes:s}}function Ur(t){let e=t.readUint32();if(e===k){if(t.readUint32()!==k)throw new Error("NetCDF: wrong empty tag for list of dimensions");return{recordId:0,recordName:"",dimensions:[]}}if(e!==Lr)throw new Error("NetCDF: wrong tag for list of dimensions");let r=t.readUint32(),n=new Array(r),s,o;for(let c=0;c<r;c++){let l=Je(t),h=t.readUint32();h===Ir&&(s=c,o=l),n[c]={name:l,size:h}}return{dimensions:n,recordId:s,recordName:o}}function Ot(t){let e=t.readUint32();if(e===k){if(t.readUint32()!==k)throw new Error("NetCDF: wrong empty tag for list of attributes");return[]}if(e!==Fr)throw new Error("NetCDF: wrong tag for list of attributes");let r=t.readUint32(),n=new Array(r);for(let s=0;s<r;s++){let o=Je(t),c=t.readUint32();if(c<1||c>6)throw new Error(`NetCDF: non valid type ${c}`);let l=t.readUint32(),h=V(t,c,l);kt(t),n[s]={name:o,type:Ve(c),value:h}}return n}function Pr(t,e,r){let n=t.readUint32(),s=0;if(n===k){if(t.readUint32()!==k)throw new Error("NetCDF: wrong empty tag for list of variables");return{recordStep:s,variables:[]}}if(n!==Dr)throw new Error("NetCDF: wrong tag for list of variables");let o=t.readUint32(),c=new Array(o);for(let l=0;l<o;l++){let h=Je(t),a=t.readUint32(),d=new Array(a);for(let w=0;w<a;w++)d[w]=t.readUint32();let f=Ot(t),u=t.readUint32();if(u<1&&u>6)throw new Error(`NetCDF: non valid type ${u}`);let g=t.readUint32(),p=t.readUint32();if(r===2){if(p>0)throw new Error("NetCDF: offsets larger than 4GB not supported");p=t.readUint32()}let b=!1;typeof e<"u"&&d[0]===e&&(s+=g,b=!0),c[l]={name:h,dimensions:d,attributes:f,type:Ve(u),size:g,offset:p,record:b}}return{variables:c,recordStep:s}}function Je(t){let e=t.readUint32(),r=t.readChars(e);return kt(t),r}function kt(t){t.offset%4!==0&&t.skip(4-t.offset%4)}var k,Lr,Dr,Fr,Ir,jt=F(()=>{"use strict";Qe();k=0,Lr=10,Dr=11,Fr=12,Ir=0});function $t(t,e){let r=Ge(e.type),n=e.size/Ut(r),s=new Array(n);for(let o=0;o<n;o++)s[o]=V(t,r,1);return s}function Ht(t,e,r,n){let s=Ge(e.type),o=e.dimensions.filter(a=>a!==r.id).reduce((a,d)=>a*n[d].size,1),c=r.length,l=new Array(c),h=r.recordStep;for(let a=0;a<c;a++){let d=t.offset;l[a]=V(t,s,o),t.seek(d+h)}return l}var Mt=F(()=>{"use strict";Qe()});var A,Ze=F(()=>{"use strict";It();jt();Mt();A=class{header;buffer;constructor(e){let r=new te(e);r.setBigEndian();let n=r.readChars(3);if(n!=="CDF")throw new Error(`NetCDF: file should start with 'CDF', found ${n}`);let s=r.readByte();if(s>2)throw new Error(`NetCDF: unsupported version ${s}`);this.header=Pt(r,s),this.buffer=r}get version(){return this.header.version===1?"classic format":"64-bit offset format"}get recordDimension(){return this.header.recordDimension}get dimensions(){return this.header.dimensions}get attributes(){return this.header.attributes}get variables(){return this.header.variables}attributeExists(e){return this.attributes.find(n=>n.name===e)!==void 0}getAttribute(e){let r=this.attributes.find(n=>n.name===e);return r?r.value:null}dataVariableExists(e){return this.header.variables.find(function(n){return n.name===e})!==void 0}getDataVariableAsString(e){let r=this.getDataVariable(e);return r?r.join(""):null}getDataVariable(e){let r;if(typeof e=="string"?r=this.header.variables.find(function(n){return n.name===e}):r=e,r===void 0){let n;throw typeof e=="string"?n=e:typeof e=="object"&&(n=JSON.stringify(e)),new Error(`NetCDF: variable not found: ${n}`)}return this.buffer.seek(r.offset),r.record?Ht(this.buffer,r,this.header.recordDimension,this.header.dimensions):$t(this.buffer,r)}toString(){let e=[];e.push("DIMENSIONS");for(let n of this.dimensions)e.push(` ${n.name.padEnd(30)} = size: ${n.size}`);e.push(""),e.push("GLOBAL ATTRIBUTES");for(let n of this.attributes)e.push(` ${n.name.padEnd(30)} = ${n.value}`);let r=JSON.parse(JSON.stringify(this.variables));e.push(""),e.push("VARIABLES:");for(let n of r){n.value=this.getDataVariable(n);let s=JSON.stringify(n.value);s.length>50&&(s=s.substring(0,50)),Number.isNaN(n.value.length)||(s+=` (length: ${n.value.length})`),e.push(` ${n.name.padEnd(30)} = ${s}`)}return e.join(`
|
|
8
|
+
`)}}});var G,Ye=F(()=>{"use strict";G={name:"NetCDF",id:"netcdf",module:"netcdf",encoding:"binary",format:"netcdf",extensions:["cdf","nc"],mimeTypes:["application/x-netcdf"],binary:!0}});var Zr={};Yt(Zr,{FetchError:()=>i.FetchError,JSONLoader:()=>He,NetCDFFormat:()=>G,NetCDFReader:()=>A,NetCDFSourceLoader:()=>se,NullLoader:()=>i.NullLoader,NullWorkerLoader:()=>i.NullWorkerLoader,RequestScheduler:()=>O,_BrowserFileSystem:()=>i._BrowserFileSystem,_fetchProgress:()=>i._fetchProgress,_selectSource:()=>i._selectSource,_unregisterLoaders:()=>i._unregisterLoaders,assert:()=>ae,concatenateArrayBuffersAsync:()=>Fe,coreApi:()=>i.coreApi,createDataSource:()=>i.createDataSource,document:()=>le,encode:()=>i.encode,encodeInBatches:()=>i.encodeInBatches,encodeSync:()=>i.encodeSync,encodeTable:()=>i.encodeTable,encodeTableAsText:()=>i.encodeTableAsText,encodeTableInBatches:()=>i.encodeTableInBatches,encodeText:()=>i.encodeText,encodeTextSync:()=>i.encodeTextSync,encodeURLtoURL:()=>i.encodeURLtoURL,fetchFile:()=>i.fetchFile,forEach:()=>De,getLoaderOptions:()=>i.getLoaderOptions,getPathPrefix:()=>$e,global:()=>fe,isAsyncIterable:()=>Ae,isBrowser:()=>de,isIterable:()=>Ee,isIterator:()=>Se,isPromise:()=>Te,isPureObject:()=>M,isReadableStream:()=>_e,isResponse:()=>Re,isWorker:()=>he,isWritableStream:()=>Ce,load:()=>i.load,loadInBatches:()=>i.loadInBatches,makeIterator:()=>i.makeIterator,makeLineIterator:()=>ve,makeNumberedLineIterator:()=>Le,makeStream:()=>i.makeStream,makeTextDecoderIterator:()=>Ne,makeTextEncoderIterator:()=>Be,parse:()=>i.parse,parseFile:()=>i.parseFile,parseInBatches:()=>i.parseInBatches,parseSync:()=>i.parseSync,preload:()=>i.preload,preloadSync:()=>i.preloadSync,readArrayBuffer:()=>i.readArrayBuffer,registerLoaders:()=>i.registerLoaders,resolvePath:()=>z,selectLoader:()=>i.selectLoader,selectLoaderSync:()=>i.selectLoaderSync,self:()=>ce,setLoaderOptions:()=>i.setLoaderOptions,setPathPrefix:()=>je,window:()=>ue});var i=Kt(st(),1);function ae(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var T={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},ce=T.self||T.window||T.global||{},ue=T.window||T.self||T.global||{},fe=T.global||T.self||T.window||{},le=T.document||{};var de=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser),he=typeof importScripts=="function",ot=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),er=ot&&parseFloat(ot[1])||0;var j=globalThis,tr=globalThis.document||{},J=globalThis.process||{},rr=globalThis.console,nr=globalThis.navigator||{};function Z(t){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let e=typeof navigator<"u"&&navigator.userAgent,r=t||e;return!!(r&&r.indexOf("Electron")>=0)}function _(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Z()}var me="5.0.0";function I(t,e){if(!t)throw new Error(e||"Assertion failed")}function Y(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return I(Number.isFinite(e)&&e>=0),e}function pe(t){let{logLevel:e,message:r}=t;t.logLevel=Y(e);let n=t.args?Array.from(t.args):[];for(;n.length&&n.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&n.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let s=typeof t.message;return I(s==="string"||s==="object"),Object.assign(t,{args:n},t.opts)}var C=()=>{},v=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...r){return this._log("warn",0,e,r,{once:!0})}error(e,...r){return this._log("error",0,e,r)}log(e,r,...n){return this._log("log",e,r,n)}info(e,r,...n){return this._log("info",e,r,n)}once(e,r,...n){return this._log("once",e,r,n,{once:!0})}_log(e,r,n,s,o={}){let c=pe({logLevel:r,message:n,args:this._buildArgs(r,n,s),opts:o});return this._createLogFunction(e,c,o)}_buildArgs(e,r,n){return[e,r,...n]}_createLogFunction(e,r,n){if(!this._shouldLog(r.logLevel))return C;let s=this._getOnceTag(n.tag??r.tag??r.message);if((n.once||r.once)&&s!==void 0){if(this._onceCache.has(s))return C;this._onceCache.add(s)}return this._emit(e,r)}_shouldLog(e){return this.getLevel()>=Y(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}};function or(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var $=class{constructor(e,r,n="sessionStorage"){this.storage=or(n),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}};function it(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function ge(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var H;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(H||(H={}));var ir=10;function at(t){return typeof t!="string"?t:(t=t.toUpperCase(),H[t]||H.WHITE)}function ye(t,e,r){return!_&&typeof t=="string"&&(e&&(t=`\x1B[${at(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${at(r)+ir}m${t}\x1B[49m`)),t}function be(t,e=["constructor"]){let r=Object.getPrototypeOf(t),n=Object.getOwnPropertyNames(r),s=t;for(let o of n){let c=s[o];typeof c=="function"&&(e.find(l=>o===l)||(s[o]=c.bind(t)))}}var K=class{getHighResolutionTimer(){let e;if(_()&&j.performance)e=j?.performance?.now?.();else if("hrtime"in J){let r=J?.hrtime?.();e=r[0]*1e3+r[1]/1e6}else e=Date.now();return e}getMemoryUsageMB(){let r=j?.performance?.memory?.usedJSHeapSize;return r==null?null:Math.trunc(r/1024/1024)}},x=new K;globalThis.Probe=K;globalThis.probe=x;var U={debug:_()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},we={enabled:!0,level:0},E=class extends v{constructor({id:e}={id:""}){super({level:0}),this.VERSION=me,this._startTs=x.getHighResolutionTimer(),this._deltaTs=x.getHighResolutionTimer(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new $(`__probe-${this.id}__`,{[this.id]:we}),this.timeStamp(`${this.id} started`),be(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((x.getHighResolutionTimer()-this._startTs).toPrecision(10))}getDelta(){return Number((x.getHighResolutionTimer()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,r){this._updateConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e,...r){return this._log("warn",0,e,r,{method:U.warn,once:!0})}error(e,...r){return this._log("error",0,e,r,{method:U.error})}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r,...n){let s=x.getMemoryUsageMB();if(s!==null){let o=`${s}MB `;typeof r=="function"?r=()=>`${o}${r()}`:typeof r=="string"&&(r=`${o}${r}`)}return this._log("log",e,r,n,{method:U.log,time:!0,once:!0})}log(e,r,...n){return this._log("log",e,r,n,{method:U.debug})}info(e,r,...n){return this._log("info",e,r,n,{method:console.info})}once(e,r,...n){return this._log("once",e,r,n,{method:U.debug||U.info,once:!0})}table(e,r,n){return r?this._log("table",e,r,n&&[n]||[],{method:console.table||C,tag:cr(r)}):C}time(e,r){return this._log("time",e,r,[],{method:console.time?console.time:console.info})}timeEnd(e,r){return this._log("time",e,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,r){return this._log("time",e,r,[],{method:console.timeStamp||C})}group(e,r,n={collapsed:!1}){let s=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,r,[],{method:s})}groupCollapsed(e,r,n={}){return this.group(e,r,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||C})}withGroup(e,r,n){this.group(e,r)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,r){let n=r.method;I(n),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=x.getHighResolutionTimer();let s=ar(this.id,r.message,r);return n.bind(console,s,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(we),this._storage.config[this.id]}_updateConfiguration(e){let r=this._storage.config[this.id]||{...we};this._storage.setConfiguration({[this.id]:{...r,...e}})}};E.VERSION=me;function ar(t,e,r){if(typeof e=="string"){let n=r.time?ge(it(r.total)):"";e=r.time?`${t}: ${n} ${e}`:`${t}: ${e}`,e=ye(e,r.color,r.background)}return e}function cr(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}globalThis.probe||(globalThis.probe=x);var ts=new E({id:"@probe.gl/log"});var xe="5.0.0-beta.6",ur=xe[0]>="0"&&xe[0]<="9"?`v${xe}`:"";function fr(){let t=new E({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=t,globalThis.loaders.version=ur,globalThis.probe||={},globalThis.probe.loaders=t,t}var ct=fr();var ut=t=>typeof t=="boolean",y=t=>typeof t=="function",N=t=>t!==null&&typeof t=="object",M=t=>N(t)&&t.constructor==={}.constructor;var Te=t=>N(t)&&"then"in t&&y(t.then),Ee=t=>!!t&&y(t[Symbol.iterator]),Ae=t=>!!t&&y(t[Symbol.asyncIterator]),Se=t=>!!t&&y(t.next),Re=t=>typeof Response<"u"&&t instanceof Response||N(t)&&y(t.arrayBuffer)&&y(t.text)&&y(t.json);var ft=t=>N(t)&&y(t.abort)&&y(t.getWriter),lt=t=>typeof ReadableStream<"u"&&t instanceof ReadableStream||N(t)&&y(t.tee)&&y(t.cancel)&&y(t.getReader),dt=t=>N(t)&&y(t.end)&&y(t.write)&&ut(t.writable),ht=t=>N(t)&&y(t.read)&&y(t.pipe)&&ut(t.readable),_e=t=>lt(t)||ht(t),Ce=t=>ft(t)||dt(t);function X(t,e){return mt(t||{},e)}function mt(t,e,r=0){if(r>3)return e;let n={...t};for(let[s,o]of Object.entries(e))M(o)?n[s]=mt(n[s]||{},e[s],r+1):n[s]=e[s];return n}function pt(...t){return lr(t)}function lr(t){let e=t.map(o=>o instanceof ArrayBuffer?new Uint8Array(o):o),r=e.reduce((o,c)=>o+c.byteLength,0),n=new Uint8Array(r),s=0;for(let o of e)n.set(o,s),s+=o.byteLength;return n.buffer}async function*Ne(t,e={}){let r=new TextDecoder(void 0,e);for await(let n of t)yield typeof n=="string"?n:r.decode(n,{stream:!0})}async function*Be(t){let e=new TextEncoder;for await(let r of t)yield typeof r=="string"?e.encode(r).buffer:r}async function*ve(t){let e="";for await(let r of t){e+=r;let n;for(n=e.indexOf(`
|
|
9
9
|
`);n>=0;){let s=e.slice(0,n+1);e=e.slice(n+1),yield s,n=e.indexOf(`
|
|
10
|
-
`)}}e.length>0&&(yield e)}async function*Le(t){let e=1;for await(let r of t)yield{counter:e,line:r},e++}async function Fe(t,e){let r=dr(t);for(;;){let{done:n,value:s}=await r.next();if(n){r.return&&r.return();return}if(e(s))return}}async function De(t){let e=[];for await(let r of t)e.push(lr(r));return pt(...e)}function lr(t){if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t)){let{buffer:e,byteOffset:r,byteLength:n}=t;return gt(e,r,n)}return gt(t)}function gt(t,e=0,r=t.byteLength-e){let n=new Uint8Array(t,e,r),s=new Uint8Array(n.length);return s.set(n),s.buffer}function dr(t){if(typeof t[Symbol.asyncIterator]=="function")return t[Symbol.asyncIterator]();if(typeof t[Symbol.iterator]=="function"){let e=t[Symbol.iterator]();return hr(e)}return t}function hr(t){return{next(e){return Promise.resolve(t.next(e))},return(e){return typeof t.return=="function"?Promise.resolve(t.return(e)):Promise.resolve({done:!0,value:e})},throw(e){return typeof t.throw=="function"?Promise.resolve(t.throw(e)):Promise.reject(e)}}}function M(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var L=class{constructor(e,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=M(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(M()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var P=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:n}=e,s=this.stats[r];return s||(e instanceof L?s=e:s=new L(r,n),this.stats[r]=s),s}};var mr="Queued Requests",pr="Active Requests",gr="Cancelled Requests",yr="Queued Requests Ever",br="Active Requests Ever",wr={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},O=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...wr,...e},this.stats=new P({id:this.props.id}),this.stats.get(mr),this.stats.get(pr),this.stats.get(gr),this.stats.get(yr),this.stats.get(br)}setProps(e){e.throttleRequests!==void 0&&(this.props.throttleRequests=e.throttleRequests),e.maxRequests!==void 0&&(this.props.maxRequests=e.maxRequests),e.debounceTime!==void 0&&(this.props.debounceTime=e.debounceTime)}scheduleRequest(e,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);let n={handle:e,priority:0,getPriority:r},s=new Promise(o=>(n.resolve=o,n));return this.requestQueue.push(n),this.requestMap.set(e,s),this._issueNewRequests(),s}_issueRequest(e){let{handle:r,resolve:n}=e,s=!1,o=()=>{s||(s=!0,this.requestMap.delete(r),this.activeRequestCount--,this.scheduleRefill())};return this.activeRequestCount++,n?n({done:o}):Promise.resolve({done:o})}scheduleRefill(){this.updateTimer===null&&(this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),0))}_issueNewRequests(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=null;let e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(e!==0){this._updateAllRequests();for(let r=0;r<e;++r){let n=this.requestQueue.shift();n&&this._issueRequest(n)}}}_updateAllRequests(){let e=this.requestQueue;for(let r=0;r<e.length;++r){let n=e[r];this._updateRequest(n)||(e.splice(r,1),this.requestMap.delete(n.handle),r--)}e.sort((r,n)=>r.priority-n.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),e.priority<0?(e.resolve(null),!1):!0}};function Ue(t,e=[]){return t.every(Ie)?t:t.map((r,n)=>{if(Ie(r))return r;let s=e.find(c=>c.type===r?.type);if(!s)throw new Error(`No authentication class registered for credential at index ${n}.`);let o;try{o=new s(r)}catch{throw new Error(`Invalid authentication configuration at index ${n}.`)}if(!Ie(o))throw new Error(`Authentication class returned an invalid credential at index ${n}.`);return o})}function Pe(t){if(!t.core?.credentials?.length)return t;let e=Ue(t.core.credentials,t.core.authentications);return e===t.core.credentials?t:{...t,core:{...t.core,credentials:e}}}function Ie(t){return!t||typeof t!="object"||typeof t.id!="string"||!Array.isArray(t.origins)?!1:t.type==="request"?typeof t.authenticate=="function":(t.type==="header"||t.type==="query-parameter")&&typeof t.name=="string"&&(typeof t.token=="string"||typeof t.token=="function")&&Array.isArray(t.refreshStatusCodes)}var yt=Symbol("loaders.gl.authenticated-fetch"),Oe=new WeakMap;function xr(t){let e=t.fetch||((f,u)=>fetch(f,u)),r=e[yt],n=new Map(r?.credentialResolutions),s=Ue(t.credentials.map(f=>n.get(f)||f),t.authentications);if(t.credentials.forEach((f,u)=>{n.set(f,s[u])}),!t.fetchOptions&&(!s.length||r?.credentials.length===s.length&&s.every((f,u)=>f===r.credentials[u])))return e;let o=r?.fetch||e,c=r?[...new Set([...s,...r.credentials])]:s,d=bt(r?.fetchOptions||{},t.fetchOptions),h=c.filter(f=>f.type!=="request"),a=c.filter(f=>f.type==="request");for(let f of a)St(f.origins);let l=async(f,u={})=>{if(u=bt(d,u),u.signal?.throwIfAborted(),!c.length)return o(f,u);let g=Sr(f),p=g?await xt(g,u,h):{url:f,options:u,credentials:[]},b=await wt(p,a,"request"),w=await o(b.url,b.options),oe=[];for(let N of p.credentials){let{credential:_}=N;typeof _.token=="function"&&(ee(u)||_.canReplayRequest?.(f,u))&&(ee(b.options)||_.canReplayRequest?.(b.url,b.options))&&(_.refreshStatusCodes.includes(w.status)||await _.shouldRefresh?.(w))&&oe.push(N)}let et=ee(u)&&ee(b.options)&&b.credentials.some(N=>N.refreshStatusCodes?.includes(w.status));if(!oe.length&&!et)return w;u.signal?.throwIfAborted();let ie=new Map;if(await Promise.all(oe.map(async({credential:N})=>{let _=await Tr(N,f,w);_&&ie.set(N,_)})),!ie.size&&!et)return w;await w.body?.cancel().catch(()=>{}),u.signal?.throwIfAborted();let Mt=g?await xt(g,u,h,ie,p.credentials):{url:f,options:u},tt=await wt(Mt,a,"retry",w);return o(tt.url,tt.options)};return Object.defineProperty(l,yt,{value:{fetch:o,credentials:c,credentialResolutions:n,fetchOptions:d}}),l}function Tt(t={}){let e=t.fetch??t.core?.fetch,r;typeof e=="function"?r=e:r=(s,o)=>fetch(s,o);let n=typeof e=="object"&&e?e:void 0;return xr({fetch:r,fetchOptions:t.signal?{...n,signal:t.signal}:n,credentials:t.core?.credentials||[],authentications:t.core?.authentications})}function bt(t,e){let r={...t,...e};if(t.headers||e?.headers){let n=new Headers(t.headers);new Headers(e?.headers).forEach((s,o)=>n.set(o,s)),r.headers=n}return r}async function wt(t,e,r,n){let s=[],o=t.options.signal;for(let c of e){let d=Et(t.url);if(!d||!St(c.origins).includes(d))continue;o?.throwIfAborted();let h=await c.authenticate({url:t.url,options:{...t.options,headers:new Headers(t.options.headers)},reason:r,response:n?{status:n.status,headers:new Headers(n.headers)}:void 0});if(!h||typeof h.url!="string"||!h.options||typeof h.options!="object")throw new Error("Authentication callback returned an invalid request.");t={url:h.url,options:{...h.options,...o?{signal:o}:{}}},s.push(c)}return o?.throwIfAborted(),{...t,credentials:s}}function Et(t){try{let e=new URL(t);return!e.host||e.username||e.password?null:e.origin!=="null"?e.origin:`${e.protocol}//${e.host}`}catch{return null}}function St(t){if(!t.length)throw new Error("Request authentication requires at least one exact origin.");return t.map(e=>{let r=Et(e),n;try{n=new URL(e)}catch{throw new Error("Invalid request authentication origin.")}if(!r||n.pathname&&n.pathname!=="/"||n.search||n.hash)throw new Error("Invalid request authentication origin.");return r})}async function xt(t,e,r,n=new Map,s=[]){let o=new URL(t),c=new Headers(e.headers),d=[],h=new Map(s.map(({credential:a,token:l})=>[a,l]));for(let a of r){if(!a.origins.includes(o.origin))continue;let l=n.get(a),f=h.get(a),u=a.type==="query-parameter"&&f!==void 0,g=a.type==="header"&&f!==void 0;if(a.type==="query-parameter"&&o.searchParams.has(a.name)&&!u||a.type==="header"&&c.has(a.name)&&!g)continue;let p=l??f??await Er(a.token,{url:t.toString(),reason:"request"});p&&(a.type==="query-parameter"?o.searchParams.set(a.name,p):c.set(a.name,`${a.prefix||""}${p}`),d.push({credential:a,token:p}))}return{url:o.toString(),options:{...e,headers:c},credentials:d}}async function Tr(t,e,r){let n=Oe.get(t);if(n)return n;let s=t.token,o=Promise.resolve(s({url:e,reason:"refresh",response:{status:r.status,headers:r.headers}})).finally(()=>Oe.delete(t));return Oe.set(t,o),o}async function Er(t,e){return typeof t=="function"?t(e):t}function Sr(t){try{let e=new URL(t);return["http:","https:"].includes(e.protocol)?e:null}catch{return null}}function ee(t){let e=(t.method||"GET").toUpperCase();return["GET","HEAD","OPTIONS","PUT","DELETE"].includes(e)?!(t.body&&typeof ReadableStream<"u"&&t.body instanceof ReadableStream):!1}var ke="",At={};function je(t){ke=t}function $e(){return ke}function W(t){for(let e in At)if(t.startsWith(e)){let r=At[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${ke}${t}`),t}var Ar="5.0.0-beta.4",He={dataType:null,batchType:null,name:"JSON",id:"json",module:"json",version:Ar,encoding:"json",format:"json",extensions:["json","geojson"],mimeTypes:["application/json"],category:"json",text:!0,parseTextSync:_t,parse:async t=>_t(new TextDecoder().decode(t)),options:{}};function _t(t){return JSON.parse(t)}var _r={fetchFile:F("fetchFile"),parse:F("parse"),parseFile:F("parseFile"),parseSync:F("parseSync"),parseInBatches:F("parseInBatches"),load:F("load"),loadInBatches:F("loadInBatches")},z=class t{static defaultOptions={core:{type:"auto",attributions:[],loaders:[],onError:void 0}};optionsType;options;data;url;loadOptions;fetch;coreApi;hasCoreApi;_needsRefresh=!0;constructor(e,r,n,s){this.options=X(X(t.defaultOptions,n||{}),r),this.data=e,this.url=typeof e=="string"?W(e):"";let o=Pe(Ct(this.options));this.loadOptions=o;let c=Rt(o);this.coreApi=s||_r,this.hasCoreApi=!!s,this.fetch=c}setProps(e){let r=X(this.options,e),n=Pe(Ct(r));this.options=r,this.loadOptions=n,this.fetch=Rt(n),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(e=!0){let r=this._needsRefresh;return e&&(this._needsRefresh=!1),r}reportError(e,r){let n=Rr(e,r),s=this.options.core?.onError;return s?s(n,this):ct.warn(`${this.constructor.name}: ${n.message}`)(),n}};function Rt(t){return Tt(t)}function Ct(t){if(t.loadOptions!==void 0||t.core?.loadOptions!==void 0)throw new Error("Source loadOptions and core.loadOptions were removed. Use core and root loader namespaces directly.");let e={...t};if(t?.core){e.core={...t.core};let s=e.core;for(let o of["type","attributions","loaders","onError","loadOptions"])delete s[o];Object.keys(s).length===0&&delete e.core}let r=typeof e.baseUri=="string"?e.baseUri:void 0,n=typeof e.baseUrl=="string"?e.baseUrl:void 0;return(r!==void 0||n!==void 0)&&(e.core||={},e.core.baseUrl===void 0&&(e.core.baseUrl=n??r),delete e.baseUri,delete e.baseUrl),e}function Rr(t,e){return t instanceof Error?t:typeof t=="string"?new Error(t):new Error(e)}function F(t){return()=>{throw new Error(`CoreAPI.${t} is unavailable. Use @loaders.gl/core.createDataSource().`)}}function Me(t={}){if(t.coordinateEpoch!==void 0&&!Number.isFinite(t.coordinateEpoch))throw new Error("Spatial reference coordinate epoch must be a finite decimal year");return Object.freeze({crs:Bt(t.crs||{state:"absent",provenance:"unknown"}),vertical:t.vertical?Bt(t.vertical):void 0,coordinateEpoch:t.coordinateEpoch,coordinateFrame:t.coordinateFrame||"unknown",coordinateOrder:Object.freeze([...t.coordinateOrder||[]]),units:t.units?Object.freeze([...t.units]):void 0})}function Bt(t){return t.state==="explicit"||t.state==="default"?Object.freeze({...t,definition:Nt(t.definition),alternatives:t.alternatives?Object.freeze(t.alternatives.map(e=>Object.freeze({...e,definition:Nt(e.definition)}))):void 0}):Object.freeze({...t})}function Nt(t){return typeof t=="string"?t:qe(t)}function qe(t){return Array.isArray(t)?Object.freeze(t.map(e=>qe(e))):t&&typeof t=="object"?Object.freeze(Object.fromEntries(Object.entries(t).map(([e,r])=>[e,qe(r)]))):t}function We(t){Cr(t.queryType,t.execution);let e=Object.freeze({fields:Object.freeze(t.schema.fields.map(n=>Object.freeze({...n,metadata:Object.freeze({...n.metadata})}))),metadata:Object.freeze({...t.schema.metadata})}),r=e.fields.map(n=>Object.freeze({name:n.name,type:n.type,nullable:n.nullable!==!1,role:t.columnRoles?.[n.name]||"attribute",title:vt(n.metadata,"title"),description:vt(n.metadata,"description"),metadata:n.metadata||Object.freeze({})}));return Object.freeze({sourceType:t.sourceType,queryType:t.queryType,execution:Object.freeze({...t.execution}),name:t.name,description:t.description,schema:e,columns:Object.freeze(r),capabilities:Object.freeze({...t.capabilities}),spatial:t.spatial?Object.freeze({...t.spatial,bounds:t.spatial.bounds?Object.freeze({minimum:Object.freeze([...t.spatial.bounds.minimum]),maximum:Object.freeze([...t.spatial.bounds.maximum])}):void 0,coordinateReferenceSystems:t.spatial.coordinateReferenceSystems?Object.freeze([...t.spatial.coordinateReferenceSystems]):void 0,spatialReference:t.spatial.spatialReference?Me(t.spatial.spatialReference):void 0}):void 0,statistics:t.statistics?Object.freeze({...t.statistics}):void 0,levels:t.levels?Object.freeze(t.levels.map(n=>Object.freeze({...n,scale:n.scale?Object.freeze([...n.scale]):void 0}))):void 0})}function Cr(t,e){if(e.status==="metadata-only"){if(!e.reason.trim())throw new Error("Metadata-only scan support requires a concrete reason");return}if(!{table:["read","query"],raster:["getRaster"],"point-cloud":["scan"]}[t].includes(e.method))throw new Error(`Scan execution method "${e.method}" is not valid for ${t} queries`)}function vt(t,e){return t?.[e]||void 0}function ze(t){if(t.width!==void 0&&Lt(t.width,"width"),t.height!==void 0&&Lt(t.height,"height"),t.level!==void 0&&Ft(t.level,"level"),t.bounds)for(let e=0;e<2;e++){let r=t.bounds[0][e],n=t.bounds[1][e];if(!Number.isFinite(r)||!Number.isFinite(n)||r>n)throw new Error("Raster query bounds must contain finite, ordered coordinates.")}for(let e of t.channels||[])Ft(e,"channel");for(let[e,r]of Object.entries(t.slices||{})){if(!e)throw new Error("Raster query slice names must be non-empty.");if(Array.isArray(r)){if(r.length!==2||!r.every(Number.isFinite)||r[0]>r[1])throw new Error(`Raster query slice ${e} must be an ordered finite range.`)}else if(!Number.isFinite(r))throw new Error(`Raster query slice ${e} must be finite.`)}}function Lt(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`Raster query ${e} must be a positive safe integer.`)}function Ft(t,e){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Raster query ${e} must be a non-negative safe integer.`)}Ze();Ye();Ye();Ze();var Ur="5.0.0-beta.4",ne=class t extends z{static HEADER_RANGE_SIZE=64*1024;static MAX_HEADER_RANGE_SIZE=4*1024*1024;headerPromise=null;rasterQueryCapabilities=Object.freeze({bounds:"unsupported",level:"unsupported",variables:"pushdown",slices:"residual",streaming:!1,cancellation:!0});constructor(e,r={}){super(e,r)}async getQueryMetadata(e={}){A(e.signal);let{header:r,byteLength:n}=await this.getHeader(e.signal);A(e.signal);let o={fields:r.variables.map(c=>zr(c,r)),metadata:Vr(r)};return We({sourceType:"netcdf",queryType:"raster",execution:{status:"supported",method:"getRaster"},name:typeof this.data=="string"?this.data.split("/").pop():void 0,schema:o,capabilities:{bounds:"unsupported",levelOfDetail:"unsupported",raster:this.rasterQueryCapabilities},statistics:{byteLength:n,rowCount:r.recordDimension.length||void 0}})}async getRaster(e={}){ze(e),Or(e),A(e.signal);let r=await this.loadReader(e.signal);A(e.signal),jr(r.header,e.slices);let s=kr(r.header,e.variables).map(a=>{A(e.signal);let l=a.dimensions.map(b=>r.header.dimensions[b]?.name||`dimension_${b}`),f=a.dimensions.map(b=>Xe(r.header,b)),u=qt(r.getDataVariable(a)),g=$r(u,l,f,e.slices||{},e.signal),p=Ke(a.type);return{variable:a,dimensionNames:g.dimensionNames,shape:g.shape,data:qr(g.values,p),dtype:p}}),o=s[0];for(let a of s.slice(1))if(a.dtype!==o.dtype||!Wr(a.shape,o.shape))throw new Error("NetCDF raster variables must retain the same shape and numeric type after slicing.");let c=o.shape.at(-1)??1,d=o.shape.length<2?1:o.shape.slice(0,-1).reduce((a,l)=>a*l,1),h=Mr(o.variable);return{data:s.length===1?o.data:s.map(a=>a.data),width:c,height:d,bandCount:s.length,dtype:o.dtype,interleaved:!1,noData:h,metadata:{variables:s.map(a=>a.variable.name),dimensions:o.dimensionNames,shape:o.shape,slices:{...e.slices}}}}async loadReader(e){let r;if(typeof this.data=="string"){let n=await this.fetch(this.url,{signal:e});if(!n.ok)throw new Error(`NetCDF request failed with status ${n.status}.`);r=await n.arrayBuffer()}else r=await this.data.arrayBuffer();return A(e),new S(r)}async getHeader(e){A(e),this.headerPromise||(this.headerPromise=this.loadHeader().catch(n=>{throw this.headerPromise=null,n}));let r=await this.headerPromise;return A(e),r}async loadHeader(){if(typeof this.data!="string"){let o=await this.data.arrayBuffer();return{header:new S(o).header,byteLength:o.byteLength}}let e=t.HEADER_RANGE_SIZE,r=null,n=null,s;for(;e<=t.MAX_HEADER_RANGE_SIZE;){if(r=await this.fetch(this.url,{headers:{Range:`bytes=0-${e-1}`}}),!r.ok)throw new Error(`NetCDF request failed with status ${r.status}.`);n=await r.arrayBuffer();let o=Gr(r,n.byteLength);try{return{header:new S(n).header,byteLength:o}}catch(c){if(s=c,r.status!==206||n.byteLength<e)throw c;e*=2}}throw s||new Error("NetCDF header exceeds the maximum metadata range.")}},se={dataType:null,batchType:null,...G,module:"scientific",name:"NetCDFSourceLoader",version:Ur,type:"netcdf-source",fromUrl:!0,fromBlob:!0,options:{},defaultOptions:{},testURL:t=>/\.(?:cdf|nc)(?:$|[?#])/i.test(t),createDataSource:(t,e)=>new ne(t,e)};function Pr(t){switch(t.toLowerCase()){case"byte":return"int8";case"ubyte":return"uint8";case"short":return"int16";case"ushort":return"uint16";case"int":return"int32";case"uint":return"uint32";case"int64":return"int64";case"uint64":return"uint64";case"float":return"float32";case"double":return"float64";case"char":case"string":return"utf8";default:return"binary"}}function Or(t){if(t.bounds)throw new Error("NetCDF raster bounds are not supported.");if(t.level!==void 0)throw new Error("NetCDF raster levels are not supported.");if(t.width!==void 0||t.height!==void 0)throw new Error("NetCDF raster resampling is not supported.");if(t.channels?.length)throw new Error("NetCDF uses named variables instead of numeric channels.")}function kr(t,e){let r=t.variables.find(s=>s.dimensions.length>0&&Hr(s.type)),n=e?.length?[...e]:r?[r.name]:[];if(n.length===0)throw new Error("NetCDF contains no numeric variables that can be read as raster data.");if(new Set(n).size!==n.length)throw new Error("NetCDF raster variables must not contain duplicates.");return n.map(s=>{let o=t.variables.find(c=>c.name===s);if(!o)throw new Error(`NetCDF variable not found: ${s}`);return Ke(o.type),o})}function jr(t,e){let r=new Set(t.dimensions.map(n=>n.name));for(let n of Object.keys(e||{}))if(!r.has(n))throw new Error(`NetCDF dimension not found: ${n}`)}function $r(t,e,r,n,s){let o=e.map((a,l)=>{let f=r[l],u=n[a];if(u===void 0)return{start:0,stop:f,remove:!1};if(typeof u!="number"){let[g,p]=u;if(!Number.isSafeInteger(g)||!Number.isSafeInteger(p)||g<0||p<g||p>f)throw new Error(`NetCDF slice ${a} must be a valid half-open range within 0..${f}.`);return{start:g,stop:p,remove:!1}}if(!Number.isSafeInteger(u)||u<0||u>=f)throw new Error(`NetCDF slice ${a} must be an index within 0..${f-1}.`);return{start:u,stop:u+1,remove:!0}}),c=r.map((a,l)=>r.slice(l+1).reduce((f,u)=>f*u,1)),d=[],h=(a,l)=>{if(A(s),a===o.length){let u=t[l];if(typeof u!="number")throw new Error("NetCDF raster variables must contain numeric values.");d.push(u);return}let f=o[a];for(let u=f.start;u<f.stop;u++)h(a+1,l+u*c[a])};return h(0,0),{values:d,dimensionNames:e.filter((a,l)=>!o[l].remove),shape:o.map(a=>a.stop-a.start).filter((a,l)=>!o[l].remove)}}function qt(t){return Array.isArray(t)?t.flatMap(qt):ArrayBuffer.isView(t)?Array.from(t):[t]}function Hr(t){try{return Ke(t),!0}catch{return!1}}function Ke(t){switch(t.toLowerCase()){case"byte":return"int8";case"ubyte":return"uint8";case"short":return"int16";case"ushort":return"uint16";case"int":return"int32";case"uint":return"uint32";case"float":return"float32";case"double":return"float64";default:throw new Error(`NetCDF variable type is not supported as raster data: ${t}`)}}function qr(t,e){switch(e){case"int8":return Int8Array.from(t);case"uint8":return Uint8Array.from(t);case"int16":return Int16Array.from(t);case"uint16":return Uint16Array.from(t);case"int32":return Int32Array.from(t);case"uint32":return Uint32Array.from(t);case"float32":return Float32Array.from(t);case"float64":return Float64Array.from(t)}}function Mr(t){let e=t.attributes.find(n=>n.name==="_FillValue"||n.name==="missing_value"),r=Number(e?.value);return e&&Number.isFinite(r)?r:null}function Wr(t,e){return t.length===e.length&&t.every((r,n)=>r===e[n])}function zr(t,e){let n={dimensions:t.dimensions.map(s=>e.dimensions[s]).filter(Boolean).map((s,o)=>`${s.name}[${Xe(e,t.dimensions[o])}]`).join(",")};for(let s of t.attributes)n[s.name]=String(s.value);return{name:t.name,type:Pr(t.type),nullable:!0,metadata:n}}function Vr(t){let e={};for(let[r,n]of t.dimensions.entries())e[`dimension:${n.name}`]=String(Xe(t,r));return e}function Xe(t,e){let r=t.dimensions[e];return e===t.recordDimension.id?t.recordDimension.length:r?.size||0}function Gr(t,e){let n=t.headers.get("content-range")?.match(/\/([0-9]+)$/)?.[1];return Number(n||t.headers.get("content-length")||e)}function A(t){if(t?.aborted)throw new DOMException("The operation was aborted","AbortError")}return Kt(Qr);})();
|
|
10
|
+
`)}}e.length>0&&(yield e)}async function*Le(t){let e=1;for await(let r of t)yield{counter:e,line:r},e++}async function De(t,e){let r=hr(t);for(;;){let{done:n,value:s}=await r.next();if(n){r.return&&r.return();return}if(e(s))return}}async function Fe(t){let e=[];for await(let r of t)e.push(dr(r));return pt(...e)}function dr(t){if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t)){let{buffer:e,byteOffset:r,byteLength:n}=t;return gt(e,r,n)}return gt(t)}function gt(t,e=0,r=t.byteLength-e){let n=new Uint8Array(t,e,r),s=new Uint8Array(n.length);return s.set(n),s.buffer}function hr(t){if(typeof t[Symbol.asyncIterator]=="function")return t[Symbol.asyncIterator]();if(typeof t[Symbol.iterator]=="function"){let e=t[Symbol.iterator]();return mr(e)}return t}function mr(t){return{next(e){return Promise.resolve(t.next(e))},return(e){return typeof t.return=="function"?Promise.resolve(t.return(e)):Promise.resolve({done:!0,value:e})},throw(e){return typeof t.throw=="function"?Promise.resolve(t.throw(e)):Promise.reject(e)}}}function q(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var L=class{constructor(e,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=q(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(q()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var P=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:n}=e,s=this.stats[r];return s||(e instanceof L?s=e:s=new L(r,n),this.stats[r]=s),s}};var pr="Queued Requests",gr="Active Requests",yr="Cancelled Requests",br="Queued Requests Ever",wr="Active Requests Ever",xr={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},O=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...xr,...e},this.stats=new P({id:this.props.id}),this.stats.get(pr),this.stats.get(gr),this.stats.get(yr),this.stats.get(br),this.stats.get(wr)}setProps(e){e.throttleRequests!==void 0&&(this.props.throttleRequests=e.throttleRequests),e.maxRequests!==void 0&&(this.props.maxRequests=e.maxRequests),e.debounceTime!==void 0&&(this.props.debounceTime=e.debounceTime)}scheduleRequest(e,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);let n={handle:e,priority:0,getPriority:r},s=new Promise(o=>(n.resolve=o,n));return this.requestQueue.push(n),this.requestMap.set(e,s),this._issueNewRequests(),s}_issueRequest(e){let{handle:r,resolve:n}=e,s=!1,o=()=>{s||(s=!0,this.requestMap.delete(r),this.activeRequestCount--,this.scheduleRefill())};return this.activeRequestCount++,n?n({done:o}):Promise.resolve({done:o})}scheduleRefill(){this.updateTimer===null&&(this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),0))}_issueNewRequests(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=null;let e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(e!==0){this._updateAllRequests();for(let r=0;r<e;++r){let n=this.requestQueue.shift();n&&this._issueRequest(n)}}}_updateAllRequests(){let e=this.requestQueue;for(let r=0;r<e.length;++r){let n=e[r];this._updateRequest(n)||(e.splice(r,1),this.requestMap.delete(n.handle),r--)}e.sort((r,n)=>r.priority-n.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),e.priority<0?(e.resolve(null),!1):!0}};function Ue(t,e=[]){return t.every(Ie)?t:t.map((r,n)=>{if(Ie(r))return r;let s=e.find(c=>c.type===r?.type);if(!s)throw new Error(`No authentication class registered for credential at index ${n}.`);let o;try{o=new s(r)}catch{throw new Error(`Invalid authentication configuration at index ${n}.`)}if(!Ie(o))throw new Error(`Authentication class returned an invalid credential at index ${n}.`);return o})}function Pe(t){if(!t.core?.credentials?.length)return t;let e=Ue(t.core.credentials,t.core.authentications);return e===t.core.credentials?t:{...t,core:{...t.core,credentials:e}}}function Ie(t){return!t||typeof t!="object"||typeof t.id!="string"||!Array.isArray(t.origins)?!1:t.type==="request"?typeof t.authenticate=="function":(t.type==="header"||t.type==="query-parameter")&&typeof t.name=="string"&&(typeof t.token=="string"||typeof t.token=="function")&&Array.isArray(t.refreshStatusCodes)}var yt=Symbol("loaders.gl.authenticated-fetch"),Oe=new WeakMap;function Tr(t){let e=t.fetch||((f,u)=>fetch(f,u)),r=e[yt],n=new Map(r?.credentialResolutions),s=Ue(t.credentials.map(f=>n.get(f)||f),t.authentications);if(t.credentials.forEach((f,u)=>{n.set(f,s[u])}),!t.fetchOptions&&(!s.length||r?.credentials.length===s.length&&s.every((f,u)=>f===r.credentials[u])))return e;let o=r?.fetch||e,c=r?[...new Set([...s,...r.credentials])]:s,l=bt(r?.fetchOptions||{},t.fetchOptions),h=c.filter(f=>f.type!=="request"),a=c.filter(f=>f.type==="request");for(let f of a)At(f.origins);let d=async(f,u={})=>{if(u=bt(l,u),u.signal?.throwIfAborted(),!c.length)return o(f,u);let g=Sr(f),p=g?await xt(g,u,h):{url:f,options:u,credentials:[]},b=await wt(p,a,"request"),w=await o(b.url,b.options),oe=[];for(let B of p.credentials){let{credential:R}=B;typeof R.token=="function"&&(ee(u)||R.canReplayRequest?.(f,u))&&(ee(b.options)||R.canReplayRequest?.(b.url,b.options))&&(R.refreshStatusCodes.includes(w.status)||await R.shouldRefresh?.(w))&&oe.push(B)}let et=ee(u)&&ee(b.options)&&b.credentials.some(B=>B.refreshStatusCodes?.includes(w.status));if(!oe.length&&!et)return w;u.signal?.throwIfAborted();let ie=new Map;if(await Promise.all(oe.map(async({credential:B})=>{let R=await Er(B,f,w);R&&ie.set(B,R)})),!ie.size&&!et)return w;await w.body?.cancel().catch(()=>{}),u.signal?.throwIfAborted();let zt=g?await xt(g,u,h,ie,p.credentials):{url:f,options:u},tt=await wt(zt,a,"retry",w);return o(tt.url,tt.options)};return Object.defineProperty(d,yt,{value:{fetch:o,credentials:c,credentialResolutions:n,fetchOptions:l}}),d}function Tt(t={}){let e=t.fetch??t.core?.fetch,r;typeof e=="function"?r=e:r=(s,o)=>fetch(s,o);let n=typeof e=="object"&&e?e:void 0;return Tr({fetch:r,fetchOptions:t.signal?{...n,signal:t.signal}:n,credentials:t.core?.credentials||[],authentications:t.core?.authentications})}function bt(t,e){let r={...t,...e};if(t.headers||e?.headers){let n=new Headers(t.headers);new Headers(e?.headers).forEach((s,o)=>n.set(o,s)),r.headers=n}return r}async function wt(t,e,r,n){let s=[],o=t.options.signal;for(let c of e){let l=Et(t.url);if(!l||!At(c.origins).includes(l))continue;o?.throwIfAborted();let h=await c.authenticate({url:t.url,options:{...t.options,headers:new Headers(t.options.headers)},reason:r,response:n?{status:n.status,headers:new Headers(n.headers)}:void 0});if(!h||typeof h.url!="string"||!h.options||typeof h.options!="object")throw new Error("Authentication callback returned an invalid request.");t={url:h.url,options:{...h.options,...o?{signal:o}:{}}},s.push(c)}return o?.throwIfAborted(),{...t,credentials:s}}function Et(t){try{let e=new URL(t);return!e.host||e.username||e.password?null:e.origin!=="null"?e.origin:`${e.protocol}//${e.host}`}catch{return null}}function At(t){if(!t.length)throw new Error("Request authentication requires at least one exact origin.");return t.map(e=>{let r=Et(e),n;try{n=new URL(e)}catch{throw new Error("Invalid request authentication origin.")}if(!r||n.pathname&&n.pathname!=="/"||n.search||n.hash)throw new Error("Invalid request authentication origin.");return r})}async function xt(t,e,r,n=new Map,s=[]){let o=new URL(t),c=new Headers(e.headers),l=[],h=new Map(s.map(({credential:a,token:d})=>[a,d]));for(let a of r){if(!a.origins.includes(o.origin))continue;let d=n.get(a),f=h.get(a),u=a.type==="query-parameter"&&f!==void 0,g=a.type==="header"&&f!==void 0;if(a.type==="query-parameter"&&o.searchParams.has(a.name)&&!u||a.type==="header"&&c.has(a.name)&&!g)continue;let p=d??f??await Ar(a.token,{url:t.toString(),reason:"request"});p&&(a.type==="query-parameter"?o.searchParams.set(a.name,p):c.set(a.name,`${a.prefix||""}${p}`),l.push({credential:a,token:p}))}return{url:o.toString(),options:{...e,headers:c},credentials:l}}async function Er(t,e,r){let n=Oe.get(t);if(n)return n;let s=t.token,o=Promise.resolve(s({url:e,reason:"refresh",response:{status:r.status,headers:r.headers}})).finally(()=>Oe.delete(t));return Oe.set(t,o),o}async function Ar(t,e){return typeof t=="function"?t(e):t}function Sr(t){try{let e=new URL(t);return["http:","https:"].includes(e.protocol)?e:null}catch{return null}}function ee(t){let e=(t.method||"GET").toUpperCase();return["GET","HEAD","OPTIONS","PUT","DELETE"].includes(e)?!(t.body&&typeof ReadableStream<"u"&&t.body instanceof ReadableStream):!1}var ke="",St={};function je(t){ke=t}function $e(){return ke}function z(t){for(let e in St)if(t.startsWith(e)){let r=St[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${ke}${t}`),t}var Rr="5.0.0-beta.6",He={dataType:null,batchType:null,name:"JSON",id:"json",module:"json",version:Rr,encoding:"json",format:"json",extensions:["json","geojson"],mimeTypes:["application/json"],category:"json",text:!0,parseTextSync:Rt,parse:async t=>Rt(new TextDecoder().decode(t)),options:{}};function Rt(t){return JSON.parse(t)}var _r={fetchFile:D("fetchFile"),parse:D("parse"),parseFile:D("parseFile"),parseSync:D("parseSync"),parseInBatches:D("parseInBatches"),load:D("load"),loadInBatches:D("loadInBatches")},W=class t{static defaultOptions={core:{type:"auto",attributions:[],loaders:[],onError:void 0}};optionsType;options;data;url;name;loadOptions;fetch;coreApi;hasCoreApi;_needsRefresh=!0;constructor(e,r,n,s){this.options=X(X(t.defaultOptions,n||{}),r),this.data=e,this.url=typeof e=="string"?z(e):"",this.name=Nr(e,this.options);let o=Pe(Ct(this.options));this.loadOptions=o;let c=_t(o);this.coreApi=s||_r,this.hasCoreApi=!!s,this.fetch=c}setProps(e){if(e.core?.name!==void 0&&e.core.name!==this.name)throw new Error("Data source names are fixed at creation.");let r=X(this.options,e),n=Pe(Ct(r));this.options=r,this.loadOptions=n,this.fetch=_t(n),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(e=!0){let r=this._needsRefresh;return e&&(this._needsRefresh=!1),r}reportError(e,r){let n=Cr(e,r),s=this.options.core?.onError;return s?s(n,this):ct.warn(`${this.constructor.name}: ${n.message}`)(),n}};function _t(t){return Tt(t)}function Ct(t){if(t.loadOptions!==void 0||t.core?.loadOptions!==void 0)throw new Error("Source loadOptions and core.loadOptions were removed. Use core and root loader namespaces directly.");let e={...t};if(t?.core){e.core={...t.core};let s=e.core;for(let o of["type","name","attributions","loaders","onError","loadOptions"])delete s[o];Object.keys(s).length===0&&delete e.core}let r=typeof e.baseUri=="string"?e.baseUri:void 0,n=typeof e.baseUrl=="string"?e.baseUrl:void 0;return(r!==void 0||n!==void 0)&&(e.core||={},e.core.baseUrl===void 0&&(e.core.baseUrl=n??r),delete e.baseUri,delete e.baseUrl),e}function Cr(t,e){return t instanceof Error?t:typeof t=="string"?new Error(t):new Error(e)}function D(t){return()=>{throw new Error(`CoreAPI.${t} is unavailable. Use @loaders.gl/core.createDataSource().`)}}function Nr(t,e){let r=e.core?.name;if(r!==void 0){if(typeof r!="string"||!r.trim())throw new Error("Data source name must be a non-empty string.");return r}if(t&&typeof t=="object"){let n=t;if(typeof n.name=="string"&&n.name.trim())return t instanceof Blob?Nt(n.name):n.name;let s=n.schema?.metadata,o=s instanceof Map?s.get("name"):s?.name;if(typeof o=="string"&&o.trim())return o}if(typeof t=="string")try{let n=new URL(t.replace(/\\/g,"/"),"https://source.invalid/");if(!["data:","blob:"].includes(n.protocol)){let s=n.pathname.split("/").filter(Boolean).pop();if(s){try{s=decodeURIComponent(s)}catch{}return Nt(s)}}}catch{}return e.core?.type&&e.core.type!=="auto"?e.core.type:"source"}function Nt(t){let e=t.lastIndexOf(".");return e>0?t.slice(0,e):t}function qe(t={}){if(t.coordinateEpoch!==void 0&&!Number.isFinite(t.coordinateEpoch))throw new Error("Spatial reference coordinate epoch must be a finite decimal year");return Object.freeze({crs:Bt(t.crs||{state:"absent",provenance:"unknown"}),vertical:t.vertical?Bt(t.vertical):void 0,coordinateEpoch:t.coordinateEpoch,coordinateFrame:t.coordinateFrame||"unknown",coordinateOrder:Object.freeze([...t.coordinateOrder||[]]),units:t.units?Object.freeze([...t.units]):void 0})}function Bt(t){return t.state==="explicit"||t.state==="default"?Object.freeze({...t,definition:vt(t.definition),alternatives:t.alternatives?Object.freeze(t.alternatives.map(e=>Object.freeze({...e,definition:vt(e.definition)}))):void 0}):Object.freeze({...t})}function vt(t){return typeof t=="string"?t:Me(t)}function Me(t){return Array.isArray(t)?Object.freeze(t.map(e=>Me(e))):t&&typeof t=="object"?Object.freeze(Object.fromEntries(Object.entries(t).map(([e,r])=>[e,Me(r)]))):t}function ze(t){Br(t.queryType,t.execution);let e=Object.freeze({fields:Object.freeze(t.schema.fields.map(n=>Object.freeze({...n,metadata:Object.freeze({...n.metadata})}))),metadata:Object.freeze({...t.schema.metadata})}),r=e.fields.map(n=>Object.freeze({name:n.name,type:n.type,nullable:n.nullable!==!1,role:t.columnRoles?.[n.name]||"attribute",title:Lt(n.metadata,"title"),description:Lt(n.metadata,"description"),metadata:n.metadata||Object.freeze({})}));return Object.freeze({sourceType:t.sourceType,queryType:t.queryType,execution:Object.freeze({...t.execution}),name:t.name,description:t.description,schema:e,columns:Object.freeze(r),capabilities:Object.freeze({...t.capabilities}),spatial:t.spatial?Object.freeze({...t.spatial,bounds:t.spatial.bounds?Object.freeze({minimum:Object.freeze([...t.spatial.bounds.minimum]),maximum:Object.freeze([...t.spatial.bounds.maximum])}):void 0,coordinateReferenceSystems:t.spatial.coordinateReferenceSystems?Object.freeze([...t.spatial.coordinateReferenceSystems]):void 0,spatialReference:t.spatial.spatialReference?qe(t.spatial.spatialReference):void 0}):void 0,statistics:t.statistics?Object.freeze({...t.statistics}):void 0,levels:t.levels?Object.freeze(t.levels.map(n=>Object.freeze({...n,scale:n.scale?Object.freeze([...n.scale]):void 0}))):void 0})}function Br(t,e){if(e.status==="metadata-only"){if(!e.reason.trim())throw new Error("Metadata-only scan support requires a concrete reason");return}if(!{table:["read","query"],raster:["getRaster"],"point-cloud":["scan"]}[t].includes(e.method))throw new Error(`Scan execution method "${e.method}" is not valid for ${t} queries`)}function Lt(t,e){return t?.[e]||void 0}function We(t){if(t.width!==void 0&&Dt(t.width,"width"),t.height!==void 0&&Dt(t.height,"height"),t.level!==void 0&&Ft(t.level,"level"),t.bounds)for(let e=0;e<2;e++){let r=t.bounds[0][e],n=t.bounds[1][e];if(!Number.isFinite(r)||!Number.isFinite(n)||r>n)throw new Error("Raster query bounds must contain finite, ordered coordinates.")}for(let e of t.channels||[])Ft(e,"channel");for(let[e,r]of Object.entries(t.slices||{})){if(!e)throw new Error("Raster query slice names must be non-empty.");if(Array.isArray(r)){if(r.length!==2||!r.every(Number.isFinite)||r[0]>r[1])throw new Error(`Raster query slice ${e} must be an ordered finite range.`)}else if(!Number.isFinite(r))throw new Error(`Raster query slice ${e} must be finite.`)}}function Dt(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`Raster query ${e} must be a positive safe integer.`)}function Ft(t,e){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Raster query ${e} must be a non-negative safe integer.`)}Ze();Ye();Ye();Ze();var Or="5.0.0-beta.6",ne=class t extends W{static HEADER_RANGE_SIZE=64*1024;static MAX_HEADER_RANGE_SIZE=4*1024*1024;headerPromise=null;rasterQueryCapabilities=Object.freeze({bounds:"unsupported",level:"unsupported",variables:"pushdown",slices:"residual",streaming:!1,cancellation:!0});constructor(e,r={}){super(e,r)}async getQueryMetadata(e={}){S(e.signal);let{header:r,byteLength:n}=await this.getHeader(e.signal);S(e.signal);let o={fields:r.variables.map(c=>Gr(c,r)),metadata:Qr(r)};return ze({sourceType:"netcdf",queryType:"raster",execution:{status:"supported",method:"getRaster"},name:typeof this.data=="string"?this.data.split("/").pop():void 0,schema:o,capabilities:{bounds:"unsupported",levelOfDetail:"unsupported",raster:this.rasterQueryCapabilities},statistics:{byteLength:n,rowCount:r.recordDimension.length||void 0}})}async getRaster(e={}){We(e),jr(e),S(e.signal);let r=await this.loadReader(e.signal);S(e.signal),Hr(r.header,e.slices);let s=$r(r.header,e.variables).map(a=>{S(e.signal);let d=a.dimensions.map(b=>r.header.dimensions[b]?.name||`dimension_${b}`),f=a.dimensions.map(b=>Xe(r.header,b)),u=qt(r.getDataVariable(a)),g=Mr(u,d,f,e.slices||{},e.signal),p=Ke(a.type);return{variable:a,dimensionNames:g.dimensionNames,shape:g.shape,data:zr(g.values,p),dtype:p}}),o=s[0];for(let a of s.slice(1))if(a.dtype!==o.dtype||!Vr(a.shape,o.shape))throw new Error("NetCDF raster variables must retain the same shape and numeric type after slicing.");let c=o.shape.at(-1)??1,l=o.shape.length<2?1:o.shape.slice(0,-1).reduce((a,d)=>a*d,1),h=Wr(o.variable);return{data:s.length===1?o.data:s.map(a=>a.data),width:c,height:l,bandCount:s.length,dtype:o.dtype,interleaved:!1,noData:h,metadata:{variables:s.map(a=>a.variable.name),dimensions:o.dimensionNames,shape:o.shape,slices:{...e.slices}}}}async loadReader(e){let r;if(typeof this.data=="string"){let n=await this.fetch(this.url,{signal:e});if(!n.ok)throw new Error(`NetCDF request failed with status ${n.status}.`);r=await n.arrayBuffer()}else r=await this.data.arrayBuffer();return S(e),new A(r)}async getHeader(e){S(e),this.headerPromise||(this.headerPromise=this.loadHeader().catch(n=>{throw this.headerPromise=null,n}));let r=await this.headerPromise;return S(e),r}async loadHeader(){if(typeof this.data!="string"){let o=await this.data.arrayBuffer();return{header:new A(o).header,byteLength:o.byteLength}}let e=t.HEADER_RANGE_SIZE,r=null,n=null,s;for(;e<=t.MAX_HEADER_RANGE_SIZE;){if(r=await this.fetch(this.url,{headers:{Range:`bytes=0-${e-1}`}}),!r.ok)throw new Error(`NetCDF request failed with status ${r.status}.`);n=await r.arrayBuffer();let o=Jr(r,n.byteLength);if(r.status===206&&!r.headers.has("Content-Range")&&n.byteLength===e){let c=await this.fetch(this.url,{method:"HEAD"}),l=c.headers.get("Content-Length");if(await c.body?.cancel(),c.status!==200||!l||!/^\d+$/.test(l)||!Number.isSafeInteger(Number(l))||Number(l)<n.byteLength)throw new Error("NetCDF file size unavailable: expose Content-Range or provide HEAD Content-Length");o=Number(l)}try{return{header:new A(n).header,byteLength:o}}catch(c){if(s=c,r.status!==206||n.byteLength<e)throw c;e*=2}}throw s||new Error("NetCDF header exceeds the maximum metadata range.")}},se={dataType:null,batchType:null,...G,module:"scientific",name:"NetCDFSourceLoader",version:Or,type:"netcdf-source",fromUrl:!0,fromBlob:!0,options:{},defaultOptions:{},testURL:t=>/\.(?:cdf|nc)(?:$|[?#])/i.test(t),createDataSource:(t,e)=>new ne(t,e)};function kr(t){switch(t.toLowerCase()){case"byte":return"int8";case"ubyte":return"uint8";case"short":return"int16";case"ushort":return"uint16";case"int":return"int32";case"uint":return"uint32";case"int64":return"int64";case"uint64":return"uint64";case"float":return"float32";case"double":return"float64";case"char":case"string":return"utf8";default:return"binary"}}function jr(t){if(t.bounds)throw new Error("NetCDF raster bounds are not supported.");if(t.level!==void 0)throw new Error("NetCDF raster levels are not supported.");if(t.width!==void 0||t.height!==void 0)throw new Error("NetCDF raster resampling is not supported.");if(t.channels?.length)throw new Error("NetCDF uses named variables instead of numeric channels.")}function $r(t,e){let r=t.variables.find(s=>s.dimensions.length>0&&qr(s.type)),n=e?.length?[...e]:r?[r.name]:[];if(n.length===0)throw new Error("NetCDF contains no numeric variables that can be read as raster data.");if(new Set(n).size!==n.length)throw new Error("NetCDF raster variables must not contain duplicates.");return n.map(s=>{let o=t.variables.find(c=>c.name===s);if(!o)throw new Error(`NetCDF variable not found: ${s}`);return Ke(o.type),o})}function Hr(t,e){let r=new Set(t.dimensions.map(n=>n.name));for(let n of Object.keys(e||{}))if(!r.has(n))throw new Error(`NetCDF dimension not found: ${n}`)}function Mr(t,e,r,n,s){let o=e.map((a,d)=>{let f=r[d],u=n[a];if(u===void 0)return{start:0,stop:f,remove:!1};if(typeof u!="number"){let[g,p]=u;if(!Number.isSafeInteger(g)||!Number.isSafeInteger(p)||g<0||p<g||p>f)throw new Error(`NetCDF slice ${a} must be a valid half-open range within 0..${f}.`);return{start:g,stop:p,remove:!1}}if(!Number.isSafeInteger(u)||u<0||u>=f)throw new Error(`NetCDF slice ${a} must be an index within 0..${f-1}.`);return{start:u,stop:u+1,remove:!0}}),c=r.map((a,d)=>r.slice(d+1).reduce((f,u)=>f*u,1)),l=[],h=(a,d)=>{if(S(s),a===o.length){let u=t[d];if(typeof u!="number")throw new Error("NetCDF raster variables must contain numeric values.");l.push(u);return}let f=o[a];for(let u=f.start;u<f.stop;u++)h(a+1,d+u*c[a])};return h(0,0),{values:l,dimensionNames:e.filter((a,d)=>!o[d].remove),shape:o.map(a=>a.stop-a.start).filter((a,d)=>!o[d].remove)}}function qt(t){return Array.isArray(t)?t.flatMap(qt):ArrayBuffer.isView(t)?Array.from(t):[t]}function qr(t){try{return Ke(t),!0}catch{return!1}}function Ke(t){switch(t.toLowerCase()){case"byte":return"int8";case"ubyte":return"uint8";case"short":return"int16";case"ushort":return"uint16";case"int":return"int32";case"uint":return"uint32";case"float":return"float32";case"double":return"float64";default:throw new Error(`NetCDF variable type is not supported as raster data: ${t}`)}}function zr(t,e){switch(e){case"int8":return Int8Array.from(t);case"uint8":return Uint8Array.from(t);case"int16":return Int16Array.from(t);case"uint16":return Uint16Array.from(t);case"int32":return Int32Array.from(t);case"uint32":return Uint32Array.from(t);case"float32":return Float32Array.from(t);case"float64":return Float64Array.from(t)}}function Wr(t){let e=t.attributes.find(n=>n.name==="_FillValue"||n.name==="missing_value"),r=Number(e?.value);return e&&Number.isFinite(r)?r:null}function Vr(t,e){return t.length===e.length&&t.every((r,n)=>r===e[n])}function Gr(t,e){let n={dimensions:t.dimensions.map(s=>e.dimensions[s]).filter(Boolean).map((s,o)=>`${s.name}[${Xe(e,t.dimensions[o])}]`).join(",")};for(let s of t.attributes)n[s.name]=String(s.value);return{name:t.name,type:kr(t.type),nullable:!0,metadata:n}}function Qr(t){let e={};for(let[r,n]of t.dimensions.entries())e[`dimension:${n.name}`]=String(Xe(t,r));return e}function Xe(t,e){let r=t.dimensions[e];return e===t.recordDimension.id?t.recordDimension.length:r?.size||0}function Jr(t,e){let n=t.headers.get("content-range")?.match(/\/([0-9]+)$/)?.[1];return Number(n||t.headers.get("content-length")||e)}function S(t){if(t?.aborted)throw new DOMException("The operation was aborted","AbortError")}return Xt(Zr);})();
|
|
11
11
|
return __exports__;
|
|
12
12
|
});
|
|
@@ -48,7 +48,7 @@ var NPYFormat = {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
// dist/npy-loader-types.js
|
|
51
|
-
var VERSION = true ? "5.0.0-beta.
|
|
51
|
+
var VERSION = true ? "5.0.0-beta.6" : "latest";
|
|
52
52
|
var NPY_MAGIC_NUMBER = new Uint8Array([147, 78, 85, 77, 80, 89]);
|
|
53
53
|
async function preload() {
|
|
54
54
|
const { NPYLoaderWithParser } = await import("@loaders.gl/scientific/npy-loader");
|
package/dist/npy-loader-types.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { NPYFormat } from "./npy-format.js";
|
|
5
5
|
// @ts-ignore __VERSION__ is injected by the package build.
|
|
6
|
-
const VERSION = typeof "5.0.0-beta.
|
|
6
|
+
const VERSION = typeof "5.0.0-beta.6" !== 'undefined' ? "5.0.0-beta.6" : 'latest';
|
|
7
7
|
// \x93NUMPY
|
|
8
8
|
const NPY_MAGIC_NUMBER = new Uint8Array([147, 78, 85, 77, 80, 89]);
|
|
9
9
|
/** Preloads the parser-bearing NPY loader implementation. */
|
package/dist/npy-loader.cjs
CHANGED
|
@@ -239,7 +239,7 @@ var NPYFormat = {
|
|
|
239
239
|
};
|
|
240
240
|
|
|
241
241
|
// dist/npy-loader-types.js
|
|
242
|
-
var VERSION2 = true ? "5.0.0-beta.
|
|
242
|
+
var VERSION2 = true ? "5.0.0-beta.6" : "latest";
|
|
243
243
|
var NPY_MAGIC_NUMBER2 = new Uint8Array([147, 78, 85, 77, 80, 89]);
|
|
244
244
|
async function preload2() {
|
|
245
245
|
const { NPYLoaderWithParser: NPYLoaderWithParser3 } = await Promise.resolve().then(() => (init_npy_loader(), npy_loader_exports));
|
package/dist/npy-worker.js
CHANGED
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"src/npy-loader-types.ts"() {
|
|
109
109
|
"use strict";
|
|
110
110
|
init_npy_format();
|
|
111
|
-
VERSION = true ? "5.0.0-beta.
|
|
111
|
+
VERSION = true ? "5.0.0-beta.6" : "latest";
|
|
112
112
|
NPY_MAGIC_NUMBER = new Uint8Array([147, 78, 85, 77, 80, 89]);
|
|
113
113
|
NPYLoader = {
|
|
114
114
|
...NPYFormat,
|
|
@@ -180,10 +180,10 @@
|
|
|
180
180
|
// src/workers/npy-worker.ts
|
|
181
181
|
init_npy_loader();
|
|
182
182
|
|
|
183
|
-
// ../../node_modules/@math.gl/
|
|
183
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js
|
|
184
184
|
var parentPort = globalThis.process?.getBuiltinModule?.("node:worker_threads")?.parentPort ?? null;
|
|
185
185
|
|
|
186
|
-
// ../../node_modules/@math.gl/
|
|
186
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js
|
|
187
187
|
function getTransferList(object, recursive = true, transfers) {
|
|
188
188
|
const transfersSet = transfers || /* @__PURE__ */ new Set();
|
|
189
189
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -234,7 +234,7 @@
|
|
|
234
234
|
return false;
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
// ../../node_modules/@math.gl/
|
|
237
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-body.js
|
|
238
238
|
async function getParentPort() {
|
|
239
239
|
return parentPort;
|
|
240
240
|
}
|
|
@@ -321,7 +321,7 @@
|
|
|
321
321
|
return messageData && typeof messageData.source === "string" && messageData.source.startsWith("loaders.gl") ? messageData : null;
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
-
// ../../node_modules/@math.gl/
|
|
324
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js
|
|
325
325
|
var AsyncQueue = class {
|
|
326
326
|
constructor() {
|
|
327
327
|
this._values = [];
|
|
@@ -388,7 +388,7 @@
|
|
|
388
388
|
}
|
|
389
389
|
};
|
|
390
390
|
|
|
391
|
-
// ../../node_modules/@math.gl/
|
|
391
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js
|
|
392
392
|
var SharedWorkerState = class {
|
|
393
393
|
constructor(buffer) {
|
|
394
394
|
if (typeof SharedArrayBuffer === "undefined" || !(buffer instanceof SharedArrayBuffer) || buffer.byteLength !== 16)
|
|
@@ -427,14 +427,14 @@
|
|
|
427
427
|
}
|
|
428
428
|
};
|
|
429
429
|
|
|
430
|
-
// ../../node_modules/@math.gl/
|
|
430
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js
|
|
431
431
|
function validateOutputOwnership(ownership) {
|
|
432
432
|
if (ownership !== void 0 && ownership !== "copy" && ownership !== "transfer") {
|
|
433
433
|
throw new Error("Invalid worker output ownership");
|
|
434
434
|
}
|
|
435
435
|
}
|
|
436
436
|
|
|
437
|
-
// ../../node_modules/@math.gl/
|
|
437
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/create-worker.js
|
|
438
438
|
var requestId = 0;
|
|
439
439
|
var activeController = null;
|
|
440
440
|
var activeInputBatches = null;
|
|
@@ -642,12 +642,12 @@
|
|
|
642
642
|
};
|
|
643
643
|
}
|
|
644
644
|
|
|
645
|
-
// ../../node_modules/@math.gl/
|
|
645
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/index.js
|
|
646
646
|
var import_meta = {};
|
|
647
647
|
var path = typeof __filename === "string" ? __filename.replace(/\\/g, "/") : "";
|
|
648
648
|
var moduleUrl = path ? `file://${path.startsWith("/") ? "" : "/"}${encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F")}` : import_meta.url;
|
|
649
649
|
|
|
650
|
-
// ../../node_modules/@math.gl/
|
|
650
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js
|
|
651
651
|
var pending = /* @__PURE__ */ new WeakMap();
|
|
652
652
|
var loaded = /* @__PURE__ */ new WeakSet();
|
|
653
653
|
function preloadTaskCode(task, signal) {
|
|
@@ -684,17 +684,182 @@
|
|
|
684
684
|
});
|
|
685
685
|
}
|
|
686
686
|
|
|
687
|
-
// ../../node_modules/@math.gl/
|
|
687
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js
|
|
688
|
+
var TaskRequestError = class extends Error {
|
|
689
|
+
};
|
|
690
|
+
var TaskChannel = class {
|
|
691
|
+
constructor(options) {
|
|
692
|
+
this.options = options;
|
|
693
|
+
this.nextId = 1;
|
|
694
|
+
this.pending = /* @__PURE__ */ new Map();
|
|
695
|
+
this.incoming = /* @__PURE__ */ new Map();
|
|
696
|
+
}
|
|
697
|
+
/** Send a request without serializing other in-flight requests. */
|
|
698
|
+
request(operation, value, signal, transfer = []) {
|
|
699
|
+
if (this.failure)
|
|
700
|
+
return Promise.reject(this.failure.reason);
|
|
701
|
+
if (signal?.aborted)
|
|
702
|
+
return Promise.reject(signal.reason);
|
|
703
|
+
const id = this.nextId++;
|
|
704
|
+
return new Promise((resolve, reject) => {
|
|
705
|
+
const abort = () => {
|
|
706
|
+
const pending2 = this.pending.get(id);
|
|
707
|
+
if (!pending2)
|
|
708
|
+
return;
|
|
709
|
+
this.pending.delete(id);
|
|
710
|
+
pending2.cleanup();
|
|
711
|
+
reject(signal?.reason);
|
|
712
|
+
this.send({ source: "math.gl/tasks", kind: "cancel", id });
|
|
713
|
+
};
|
|
714
|
+
this.pending.set(id, {
|
|
715
|
+
resolve,
|
|
716
|
+
reject,
|
|
717
|
+
cleanup: () => signal?.removeEventListener("abort", abort)
|
|
718
|
+
});
|
|
719
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
720
|
+
this.send({ source: "math.gl/tasks", kind: "request", id, operation, value }, transfer);
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
/** Send a one-way notification. */
|
|
724
|
+
emit(operation, value, transfer = []) {
|
|
725
|
+
if (this.failure)
|
|
726
|
+
throw this.failure.reason;
|
|
727
|
+
this.send({ source: "math.gl/tasks", kind: "event", id: 0, operation, value }, transfer);
|
|
728
|
+
}
|
|
729
|
+
/** Dispatch a transport message; unrelated protocols are ignored. */
|
|
730
|
+
receive(message) {
|
|
731
|
+
if (this.failure || message?.source !== "math.gl/tasks")
|
|
732
|
+
return;
|
|
733
|
+
if (message.kind === "failure") {
|
|
734
|
+
const reason = new Error(message.error?.message ?? "Task channel failed");
|
|
735
|
+
this.close(reason);
|
|
736
|
+
this.options.onFailure?.(reason);
|
|
737
|
+
} else if (message.kind === "result" || message.kind === "error") {
|
|
738
|
+
const pending2 = this.pending.get(message.id);
|
|
739
|
+
if (!pending2)
|
|
740
|
+
return;
|
|
741
|
+
this.pending.delete(message.id);
|
|
742
|
+
pending2.cleanup();
|
|
743
|
+
if (message.kind === "result")
|
|
744
|
+
pending2.resolve(message.value);
|
|
745
|
+
else {
|
|
746
|
+
const error = new TaskRequestError(message.error?.message ?? "Task request failed");
|
|
747
|
+
error.name = message.error?.name ?? "Error";
|
|
748
|
+
pending2.reject(error);
|
|
749
|
+
}
|
|
750
|
+
} else if (message.kind === "cancel") {
|
|
751
|
+
this.incoming.get(message.id)?.abort(new DOMException("Task request cancelled", "AbortError"));
|
|
752
|
+
} else if (message.kind === "event") {
|
|
753
|
+
try {
|
|
754
|
+
this.options.handleEvent?.(message.operation, message.value);
|
|
755
|
+
} catch (error) {
|
|
756
|
+
this.fail(error);
|
|
757
|
+
}
|
|
758
|
+
} else if (message.kind === "request") {
|
|
759
|
+
if (this.incoming.has(message.id)) {
|
|
760
|
+
this.fail(new Error("Duplicate task request identifier"));
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
const controller = new AbortController();
|
|
764
|
+
this.incoming.set(message.id, controller);
|
|
765
|
+
void Promise.resolve().then(() => {
|
|
766
|
+
controller.signal.throwIfAborted();
|
|
767
|
+
return this.options.handleRequest(message.operation, message.value, controller.signal);
|
|
768
|
+
}).then((value) => {
|
|
769
|
+
if (!controller.signal.aborted && !this.failure) {
|
|
770
|
+
this.send({ source: "math.gl/tasks", kind: "result", id: message.id, value }, this.options.getResultTransferList?.(value, message.value));
|
|
771
|
+
}
|
|
772
|
+
}).catch((reason) => {
|
|
773
|
+
if (!controller.signal.aborted && !this.failure) {
|
|
774
|
+
this.send({
|
|
775
|
+
source: "math.gl/tasks",
|
|
776
|
+
kind: "error",
|
|
777
|
+
id: message.id,
|
|
778
|
+
error: {
|
|
779
|
+
name: reason instanceof Error ? reason.name : "Error",
|
|
780
|
+
message: reason instanceof Error ? reason.message : String(reason)
|
|
781
|
+
}
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
}).finally(() => this.incoming.delete(message.id));
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
/** Reject all outstanding calls with a common cause and abort incoming callbacks. */
|
|
788
|
+
close(reason = new Error("Task channel closed")) {
|
|
789
|
+
if (this.failure)
|
|
790
|
+
return;
|
|
791
|
+
this.failure = { reason };
|
|
792
|
+
for (const pending2 of this.pending.values()) {
|
|
793
|
+
pending2.cleanup();
|
|
794
|
+
pending2.reject(reason);
|
|
795
|
+
}
|
|
796
|
+
this.pending.clear();
|
|
797
|
+
for (const controller of this.incoming.values())
|
|
798
|
+
controller.abort(reason);
|
|
799
|
+
this.incoming.clear();
|
|
800
|
+
}
|
|
801
|
+
send(message, transfer = []) {
|
|
802
|
+
if (this.failure)
|
|
803
|
+
return;
|
|
804
|
+
try {
|
|
805
|
+
this.options.send(message, transfer);
|
|
806
|
+
} catch (error) {
|
|
807
|
+
this.fail(error);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
/** Invalidate the channel and notify the peer when the transport still works. */
|
|
811
|
+
fail(reason) {
|
|
812
|
+
if (this.failure)
|
|
813
|
+
return;
|
|
814
|
+
this.close(reason);
|
|
815
|
+
try {
|
|
816
|
+
this.options.send({
|
|
817
|
+
source: "math.gl/tasks",
|
|
818
|
+
kind: "failure",
|
|
819
|
+
id: 0,
|
|
820
|
+
error: {
|
|
821
|
+
name: reason instanceof Error ? reason.name : "Error",
|
|
822
|
+
message: reason instanceof Error ? reason.message : String(reason)
|
|
823
|
+
}
|
|
824
|
+
}, []);
|
|
825
|
+
} catch {
|
|
826
|
+
}
|
|
827
|
+
this.options.onFailure?.(reason);
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
|
|
831
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js
|
|
688
832
|
function assertPayload(value) {
|
|
689
833
|
if (!value || typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype) {
|
|
690
834
|
throw new TypeError("Task payloads must be plain objects with named fields");
|
|
691
835
|
}
|
|
692
836
|
}
|
|
837
|
+
function clonePayload(value, ownership = "copy") {
|
|
838
|
+
assertPayload(value);
|
|
839
|
+
if (!["copy", "transfer", "share"].includes(ownership))
|
|
840
|
+
throw new TypeError("Invalid input ownership");
|
|
841
|
+
const transfer = getTransferList(value);
|
|
842
|
+
if (ownership === "share" && transfer.length)
|
|
843
|
+
throw new TypeError("Share requires shared storage");
|
|
844
|
+
return structuredClone(value, {
|
|
845
|
+
transfer: ownership === "transfer" ? transfer : []
|
|
846
|
+
});
|
|
847
|
+
}
|
|
693
848
|
function taskContext(state, context = {}) {
|
|
694
849
|
const signal = context.signal ?? new AbortController().signal;
|
|
695
850
|
return {
|
|
696
851
|
state,
|
|
697
852
|
signal,
|
|
853
|
+
requestHost: async (operation, payload, controls) => {
|
|
854
|
+
signal.throwIfAborted();
|
|
855
|
+
if (!context.requestHost)
|
|
856
|
+
throw new Error("No host request handler configured");
|
|
857
|
+
return context.requestHost(operation, payload, controls);
|
|
858
|
+
},
|
|
859
|
+
emitHost: (operation, payload) => {
|
|
860
|
+
signal.throwIfAborted();
|
|
861
|
+
context.emitHost?.(operation, payload);
|
|
862
|
+
},
|
|
698
863
|
throwIfAborted: () => {
|
|
699
864
|
signal.throwIfAborted();
|
|
700
865
|
context.throwIfAborted?.();
|
|
@@ -759,6 +924,69 @@
|
|
|
759
924
|
throw new Error("A task is already installed in this worker");
|
|
760
925
|
installed = true;
|
|
761
926
|
const runtime = new TaskRuntime(task);
|
|
927
|
+
let channelStream;
|
|
928
|
+
const channel = new TaskChannel({
|
|
929
|
+
getResultTransferList: (value, request) => request.outputOwnership === "transfer" ? getTransferList(value) : [],
|
|
930
|
+
send: (message, transfer) => {
|
|
931
|
+
const snapshot = structuredClone(message, { transfer });
|
|
932
|
+
void WorkerBody.postMessage("task-channel", snapshot).catch((reason) => channel.fail(reason));
|
|
933
|
+
},
|
|
934
|
+
handleRequest: async (operation, value, signal) => {
|
|
935
|
+
const request = value;
|
|
936
|
+
const context = {
|
|
937
|
+
signal,
|
|
938
|
+
reportProgress: (progress) => channel.emit("task:progress", { id: request.progressId, progress }),
|
|
939
|
+
requestHost: (operation2, payload, controls = {}) => {
|
|
940
|
+
const request2 = {
|
|
941
|
+
operation: operation2,
|
|
942
|
+
payload: clonePayload(payload, controls.inputOwnership),
|
|
943
|
+
outputOwnership: controls.outputOwnership ?? "copy"
|
|
944
|
+
};
|
|
945
|
+
return channel.request("task:host-request", request2, signal, getTransferList(request2));
|
|
946
|
+
},
|
|
947
|
+
emitHost: (operation2, payload) => channel.emit("task:host-event", { operation: operation2, payload, id: request.progressId })
|
|
948
|
+
};
|
|
949
|
+
switch (operation) {
|
|
950
|
+
case "initialize":
|
|
951
|
+
return runtime.initialize(request.input, context);
|
|
952
|
+
case "process":
|
|
953
|
+
return runtime.process(request.input, request.options, context);
|
|
954
|
+
case "stream-open": {
|
|
955
|
+
if (channelStream)
|
|
956
|
+
throw new Error("A task stream is already open");
|
|
957
|
+
async function* inputs() {
|
|
958
|
+
while (true) {
|
|
959
|
+
const result = await channel.request("task:next-input", { outputOwnership: "transfer" }, signal);
|
|
960
|
+
if (result.done)
|
|
961
|
+
return;
|
|
962
|
+
yield result.value;
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
channelStream = runtime.stream(inputs(), request.options, context)[Symbol.asyncIterator]();
|
|
966
|
+
return {};
|
|
967
|
+
}
|
|
968
|
+
case "stream-next":
|
|
969
|
+
if (!channelStream)
|
|
970
|
+
throw new Error("No active task stream");
|
|
971
|
+
return channelStream.next();
|
|
972
|
+
case "stream-close":
|
|
973
|
+
try {
|
|
974
|
+
await channelStream?.return?.();
|
|
975
|
+
} finally {
|
|
976
|
+
channelStream = void 0;
|
|
977
|
+
}
|
|
978
|
+
return {};
|
|
979
|
+
case "destroy":
|
|
980
|
+
return runtime.destroy();
|
|
981
|
+
default:
|
|
982
|
+
throw new Error("Unknown task channel operation");
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
});
|
|
986
|
+
await WorkerBody.addEventListener((type, payload) => {
|
|
987
|
+
if (type === "task-channel")
|
|
988
|
+
channel.receive(payload);
|
|
989
|
+
});
|
|
762
990
|
let streamOptions = {};
|
|
763
991
|
return createWorker(async (request, _options, context) => {
|
|
764
992
|
switch (request.operation) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Numeric storage supported by the initial NRRD decoder. */
|
|
2
|
+
export type NRRDArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
|
|
3
|
+
/** Multidimensional NRRD data, preserving file axis order and authored orientation. */
|
|
4
|
+
export type NRRDData = {
|
|
5
|
+
/** Decoded scalar samples. Axis zero varies fastest. */
|
|
6
|
+
data: NRRDArray;
|
|
7
|
+
/** Number of samples on each axis. */
|
|
8
|
+
shape: number[];
|
|
9
|
+
/** Original normalized header fields. */
|
|
10
|
+
fields: Record<string, string>;
|
|
11
|
+
/** Authored custom key/value metadata. */
|
|
12
|
+
metadata: Record<string, string>;
|
|
13
|
+
/** World-space coordinate of the first sample, if authored. */
|
|
14
|
+
origin?: number[];
|
|
15
|
+
/** World-space step vector per array axis; null represents a nonspatial axis. */
|
|
16
|
+
directions?: (number[] | null)[];
|
|
17
|
+
/** Axis kinds, when supplied. */
|
|
18
|
+
kinds?: string[];
|
|
19
|
+
};
|
|
20
|
+
/** Decodes attached raw, ASCII or gzip NRRD without interpreting spatial axes as colors. */
|
|
21
|
+
export declare function parseNRRD(input: ArrayBuffer): Promise<NRRDData>;
|
|
22
|
+
//# sourceMappingURL=parse-nrrd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-nrrd.d.ts","sourceRoot":"","sources":["../../src/nrrd/parse-nrrd.ts"],"names":[],"mappings":"AAEA,6DAA6D;AAC7D,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,UAAU,GACV,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,YAAY,GACZ,YAAY,CAAC;AACjB,uFAAuF;AACvF,MAAM,MAAM,QAAQ,GAAG;IACrB,wDAAwD;IACxD,IAAI,EAAE,SAAS,CAAC;IAChB,sCAAsC;IACtC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,iFAAiF;IACjF,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;IACjC,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAyFF,4FAA4F;AAC5F,wBAAsB,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CA0GrE"}
|