@asterisk-labs/rumi 0.27.0-alpha.1 → 0.27.0-alpha.2
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/package.json +2 -2
- package/src/reader.js +16 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asterisk-labs/rumi",
|
|
3
|
-
"version": "0.27.0-alpha.
|
|
3
|
+
"version": "0.27.0-alpha.2",
|
|
4
4
|
"description": "Range-based Rumi Image and Cube reader for browsers and Node.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"playground": "node playground/server.mjs"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@asterisk-labs/geozl": "0.20.0-alpha.
|
|
34
|
+
"@asterisk-labs/geozl": "0.20.0-alpha.2"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
package/src/reader.js
CHANGED
|
@@ -146,12 +146,20 @@ function decoderFunction(decoder) {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
function defaultDecoder(options) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
149
|
+
let decoder;
|
|
150
|
+
return () => {
|
|
151
|
+
if (options === undefined && sharedDecoder) return sharedDecoder;
|
|
152
|
+
if (decoder) return decoder;
|
|
153
|
+
const pending = import("@asterisk-labs/geozl")
|
|
154
|
+
.then(({ createGeoZL }) => createGeoZL(options));
|
|
155
|
+
decoder = pending;
|
|
156
|
+
if (options === undefined) sharedDecoder = pending;
|
|
157
|
+
pending.catch(() => {
|
|
158
|
+
if (decoder === pending) decoder = undefined;
|
|
159
|
+
if (sharedDecoder === pending) sharedDecoder = undefined;
|
|
160
|
+
});
|
|
161
|
+
return pending;
|
|
162
|
+
};
|
|
155
163
|
}
|
|
156
164
|
|
|
157
165
|
async function decodedBytes(decode, compressed, expected, verify) {
|
|
@@ -255,7 +263,7 @@ export class RumiDataset {
|
|
|
255
263
|
}
|
|
256
264
|
const output = new Uint8Array(outputBytes);
|
|
257
265
|
const groups = frameGroups(this.header, request);
|
|
258
|
-
const decode = decoderFunction(await this.decoder);
|
|
266
|
+
const decode = decoderFunction(await this.decoder());
|
|
259
267
|
const pixelStep = unitPixelStep(this.header);
|
|
260
268
|
const bytesPerSample = this.header.dtype.bytes;
|
|
261
269
|
const [windowY, windowX] = request.window;
|
|
@@ -355,6 +363,6 @@ export async function openRumi(value, options = {}) {
|
|
|
355
363
|
const header = parseHeader(rebuilt.header, { maxFrameBytes });
|
|
356
364
|
const decoder = options.decoder === undefined
|
|
357
365
|
? defaultDecoder(options.geozl)
|
|
358
|
-
: Promise.resolve(options.decoder);
|
|
366
|
+
: () => Promise.resolve(options.decoder);
|
|
359
367
|
return new RumiDataset(source, header, decoder, maxOutputBytes, rebuilt.metadata);
|
|
360
368
|
}
|