@monogrid/gainmap-js 1.0.2 → 1.1.1

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +103 -19
  3. package/dist/LoaderBase-eee19701.js +382 -0
  4. package/dist/_commonjsHelpers-1789f0cf.js +1 -1
  5. package/dist/compress-a4b59cab.js +1 -1
  6. package/dist/decode.d.ts +25 -6
  7. package/dist/encode-utils/get-sdr-rendition.d.ts +2 -2
  8. package/dist/encode.d.ts +3 -3
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.js +189 -258
  11. package/dist/index.umd.js +331 -27
  12. package/dist/libultrahdr/decode-jpeg-metadata.d.ts +31 -0
  13. package/dist/libultrahdr/encode-jpeg-metadata.d.ts +83 -0
  14. package/dist/libultrahdr/library.d.ts +9 -0
  15. package/dist/libultrahdr-esm.wasm +0 -0
  16. package/dist/libultrahdr.d.ts +4 -128
  17. package/dist/libultrahdr.js +322 -278
  18. package/dist/libultrahdr.umd.js +687 -271
  19. package/dist/loaders/GainMapLoader.d.ts +68 -0
  20. package/dist/loaders/JPEGRLoader.d.ts +60 -0
  21. package/dist/loaders/LoaderBase.d.ts +27 -0
  22. package/dist/materials/GainMapDecoderMaterial.d.ts +44 -1
  23. package/dist/materials/GainMapEncoderMaterial.d.ts +29 -2
  24. package/dist/types.d.ts +26 -6
  25. package/dist/utils/QuadRenderer.d.ts +8 -1
  26. package/dist/worker-interface.js +1 -1
  27. package/dist/worker-interface.umd.js +1 -1
  28. package/dist/worker-types.d.ts +1 -1
  29. package/dist/worker.js +1 -1
  30. package/dist/worker.umd.js +1 -1
  31. package/libultrahdr-wasm/build/libultrahdr-debug.js +156 -182
  32. package/libultrahdr-wasm/build/libultrahdr-debug.wasm +0 -0
  33. package/libultrahdr-wasm/build/libultrahdr-esm.js +153 -182
  34. package/libultrahdr-wasm/build/libultrahdr-esm.wasm +0 -0
  35. package/libultrahdr-wasm/build/libultrahdr.js +151 -180
  36. package/libultrahdr-wasm/build/libultrahdr.wasm +0 -0
  37. package/package.json +1 -1
  38. package/examples/README.md +0 -3
  39. package/examples/compress.ts +0 -43
  40. package/examples/decode-from-jpeg.ts +0 -40
  41. package/examples/decode-from-separate-data.ts +0 -41
  42. package/examples/decode-to-datatexture.ts +0 -65
  43. package/examples/encode-and-compress.ts +0 -29
  44. package/examples/encode-jpeg-metadata.ts +0 -57
  45. package/examples/encode.ts +0 -28
  46. package/examples/globals.d.ts +0 -6
  47. package/examples/worker.ts +0 -41
  48. package/reports/eslint-examples.json +0 -1
  49. package/reports/eslint-src.json +0 -1
  50. package/reports/eslint-tests.json +0 -1
  51. package/reports/junit.xml +0 -35
  52. package/reports/typecheck-examples.log +0 -0
  53. package/reports/typecheck-tests.log +0 -0
  54. package/reports/typecheck.log +0 -0
@@ -1,8 +1,11 @@
1
1
  /**
2
- * @monogrid/gainmap-js v1.0.1
2
+ * @monogrid/gainmap-js v1.1.0
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
6
+ import { FileLoader } from 'three';
7
+ import { L as LoaderBase } from './LoaderBase-eee19701.js';
8
+
6
9
  var Module = (() => {
7
10
  var _scriptDir = import.meta.url;
8
11
 
@@ -31,7 +34,7 @@ Module['ready'] = new Promise((resolve, reject) => {
31
34
  readyPromiseResolve = resolve;
32
35
  readyPromiseReject = reject;
33
36
  });
34
- ["_main","_memory","___indirect_function_table","__embind_initialize_bindings","_fflush","onRuntimeInitialized"].forEach((prop) => {
37
+ ["_main","_memory","___indirect_function_table","_fflush","onRuntimeInitialized"].forEach((prop) => {
35
38
  if (!Object.getOwnPropertyDescriptor(Module['ready'], prop)) {
36
39
  Object.defineProperty(Module['ready'], prop, {
37
40
  get: () => abort('You are getting ' + prop + ' on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js'),
@@ -349,7 +352,7 @@ assert(!ENVIRONMENT_IS_SHELL, "shell environment detected but not enabled at bui
349
352
  // An online HTML version (which may be of a different version of Emscripten)
350
353
  // is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
351
354
 
352
- var wasmBinary;
355
+ var wasmBinary;
353
356
  if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];legacyModuleProp('wasmBinary', 'wasmBinary');
354
357
 
355
358
  if (typeof WebAssembly != 'object') {
@@ -373,6 +376,10 @@ var ABORT = false;
373
376
  // but only when noExitRuntime is false.
374
377
  var EXITSTATUS;
375
378
 
379
+ // In STRICT mode, we only define assert() when ASSERTIONS is set. i.e. we
380
+ // don't define it at all in release modes. This matches the behaviour of
381
+ // MINIMAL_RUNTIME.
382
+ // TODO(sbc): Make this the default even without STRICT enabled.
376
383
  /** @type {function(*, string=)} */
377
384
  function assert(condition, text) {
378
385
  if (!condition) {
@@ -1167,10 +1174,7 @@ function unexportedRuntimeSymbol(sym) {
1167
1174
  var setter = field.setter;
1168
1175
  var setterContext = field.setterContext;
1169
1176
  fields[fieldName] = {
1170
- read: (ptr) => {
1171
- return getterReturnType['fromWireType'](
1172
- getter(getterContext, ptr));
1173
- },
1177
+ read: (ptr) => getterReturnType['fromWireType'](getter(getterContext, ptr)),
1174
1178
  write: (ptr, o) => {
1175
1179
  var destructors = [];
1176
1180
  setter(setterContext, ptr, setterArgumentType['toWireType'](destructors, o));
@@ -1436,33 +1440,12 @@ function unexportedRuntimeSymbol(sym) {
1436
1440
  });
1437
1441
  };
1438
1442
 
1439
- var char_0 = 48;
1440
-
1441
- var char_9 = 57;
1442
- var makeLegalFunctionName = (name) => {
1443
- if (undefined === name) {
1444
- return '_unknown';
1445
- }
1446
- name = name.replace(/[^a-zA-Z0-9_]/g, '$');
1447
- var f = name.charCodeAt(0);
1448
- if (f >= char_0 && f <= char_9) {
1449
- return `_${name}`;
1450
- }
1451
- return name;
1452
- };
1443
+ var createNamedFunction = (name, body) => Object.defineProperty(body, 'name', {
1444
+ value: name
1445
+ });
1453
1446
 
1454
1447
 
1455
1448
 
1456
- function createNamedFunction(name, body) {
1457
- name = makeLegalFunctionName(name);
1458
- // Use an abject with a computed property name to create a new function with
1459
- // a name specified at runtime, but without using `new Function` or `eval`.
1460
- return {
1461
- [name]: function() {
1462
- return body.apply(this, arguments);
1463
- }
1464
- }[name];
1465
- }
1466
1449
  function newFunc(constructor, argumentList) {
1467
1450
  if (!(constructor instanceof Function)) {
1468
1451
  throw new TypeError(`new_ called with constructor type ${typeof(constructor)} which is not a function`);
@@ -1531,7 +1514,7 @@ function unexportedRuntimeSymbol(sym) {
1531
1514
  }
1532
1515
 
1533
1516
  var invokerFnBody = `
1534
- return function ${makeLegalFunctionName(humanName)}(${argsList}) {
1517
+ return function (${argsList}) {
1535
1518
  if (arguments.length !== ${argCount - 2}) {
1536
1519
  throwBindingError('function ${humanName} called with ' + arguments.length + ' arguments, expected ${argCount - 2}');
1537
1520
  }`;
@@ -1583,7 +1566,8 @@ function unexportedRuntimeSymbol(sym) {
1583
1566
 
1584
1567
  args1.push(invokerFnBody);
1585
1568
 
1586
- return newFunc(Function, args1).apply(null, args2);
1569
+ var invokerFn = newFunc(Function, args1).apply(null, args2);
1570
+ return createNamedFunction(humanName, invokerFn);
1587
1571
  }
1588
1572
 
1589
1573
  var ensureOverloadTable = (proto, methodName, humanName) => {
@@ -1915,7 +1899,7 @@ function unexportedRuntimeSymbol(sym) {
1915
1899
 
1916
1900
 
1917
1901
  var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
1918
- assert(typeof str === 'string');
1902
+ assert(typeof str === 'string', `stringToUTF8Array expects a string (got ${typeof str})`);
1919
1903
  // Parameter maxBytesToWrite is not optional. Negative values, 0, null,
1920
1904
  // undefined and false each don't write out any bytes.
1921
1905
  if (!(maxBytesToWrite > 0))
@@ -2059,7 +2043,7 @@ function unexportedRuntimeSymbol(sym) {
2059
2043
  * @return {string}
2060
2044
  */
2061
2045
  var UTF8ToString = (ptr, maxBytesToRead) => {
2062
- assert(typeof ptr == 'number');
2046
+ assert(typeof ptr == 'number', `UTF8ToString expects a number (got ${typeof ptr})`);
2063
2047
  return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : '';
2064
2048
  };
2065
2049
  var __embind_register_std_string = (rawType, name) => {
@@ -2432,9 +2416,7 @@ function unexportedRuntimeSymbol(sym) {
2432
2416
  return symbol;
2433
2417
  };
2434
2418
 
2435
- var __emval_new_cstring = (v) => {
2436
- return Emval.toHandle(getStringOrSymbol(v));
2437
- };
2419
+ var __emval_new_cstring = (v) => Emval.toHandle(getStringOrSymbol(v));
2438
2420
 
2439
2421
 
2440
2422
 
@@ -2649,9 +2631,7 @@ function unexportedRuntimeSymbol(sym) {
2649
2631
  var paths = Array.prototype.slice.call(arguments);
2650
2632
  return PATH.normalize(paths.join('/'));
2651
2633
  },
2652
- join2:(l, r) => {
2653
- return PATH.normalize(l + '/' + r);
2654
- },
2634
+ join2:(l, r) => PATH.normalize(l + '/' + r),
2655
2635
  };
2656
2636
 
2657
2637
  var initRandomFill = () => {
@@ -3308,7 +3288,7 @@ function unexportedRuntimeSymbol(sym) {
3308
3288
 
3309
3289
 
3310
3290
  var FS_createDataFile = (parent, name, fileData, canRead, canWrite, canOwn) => {
3311
- return FS.createDataFile(parent, name, fileData, canRead, canWrite, canOwn);
3291
+ FS.createDataFile(parent, name, fileData, canRead, canWrite, canOwn);
3312
3292
  };
3313
3293
 
3314
3294
  var preloadPlugins = Module['preloadPlugins'] || [];
@@ -3505,7 +3485,128 @@ function unexportedRuntimeSymbol(sym) {
3505
3485
  };
3506
3486
 
3507
3487
  var ERRNO_CODES = {
3508
- };
3488
+ 'EPERM': 63,
3489
+ 'ENOENT': 44,
3490
+ 'ESRCH': 71,
3491
+ 'EINTR': 27,
3492
+ 'EIO': 29,
3493
+ 'ENXIO': 60,
3494
+ 'E2BIG': 1,
3495
+ 'ENOEXEC': 45,
3496
+ 'EBADF': 8,
3497
+ 'ECHILD': 12,
3498
+ 'EAGAIN': 6,
3499
+ 'EWOULDBLOCK': 6,
3500
+ 'ENOMEM': 48,
3501
+ 'EACCES': 2,
3502
+ 'EFAULT': 21,
3503
+ 'ENOTBLK': 105,
3504
+ 'EBUSY': 10,
3505
+ 'EEXIST': 20,
3506
+ 'EXDEV': 75,
3507
+ 'ENODEV': 43,
3508
+ 'ENOTDIR': 54,
3509
+ 'EISDIR': 31,
3510
+ 'EINVAL': 28,
3511
+ 'ENFILE': 41,
3512
+ 'EMFILE': 33,
3513
+ 'ENOTTY': 59,
3514
+ 'ETXTBSY': 74,
3515
+ 'EFBIG': 22,
3516
+ 'ENOSPC': 51,
3517
+ 'ESPIPE': 70,
3518
+ 'EROFS': 69,
3519
+ 'EMLINK': 34,
3520
+ 'EPIPE': 64,
3521
+ 'EDOM': 18,
3522
+ 'ERANGE': 68,
3523
+ 'ENOMSG': 49,
3524
+ 'EIDRM': 24,
3525
+ 'ECHRNG': 106,
3526
+ 'EL2NSYNC': 156,
3527
+ 'EL3HLT': 107,
3528
+ 'EL3RST': 108,
3529
+ 'ELNRNG': 109,
3530
+ 'EUNATCH': 110,
3531
+ 'ENOCSI': 111,
3532
+ 'EL2HLT': 112,
3533
+ 'EDEADLK': 16,
3534
+ 'ENOLCK': 46,
3535
+ 'EBADE': 113,
3536
+ 'EBADR': 114,
3537
+ 'EXFULL': 115,
3538
+ 'ENOANO': 104,
3539
+ 'EBADRQC': 103,
3540
+ 'EBADSLT': 102,
3541
+ 'EDEADLOCK': 16,
3542
+ 'EBFONT': 101,
3543
+ 'ENOSTR': 100,
3544
+ 'ENODATA': 116,
3545
+ 'ETIME': 117,
3546
+ 'ENOSR': 118,
3547
+ 'ENONET': 119,
3548
+ 'ENOPKG': 120,
3549
+ 'EREMOTE': 121,
3550
+ 'ENOLINK': 47,
3551
+ 'EADV': 122,
3552
+ 'ESRMNT': 123,
3553
+ 'ECOMM': 124,
3554
+ 'EPROTO': 65,
3555
+ 'EMULTIHOP': 36,
3556
+ 'EDOTDOT': 125,
3557
+ 'EBADMSG': 9,
3558
+ 'ENOTUNIQ': 126,
3559
+ 'EBADFD': 127,
3560
+ 'EREMCHG': 128,
3561
+ 'ELIBACC': 129,
3562
+ 'ELIBBAD': 130,
3563
+ 'ELIBSCN': 131,
3564
+ 'ELIBMAX': 132,
3565
+ 'ELIBEXEC': 133,
3566
+ 'ENOSYS': 52,
3567
+ 'ENOTEMPTY': 55,
3568
+ 'ENAMETOOLONG': 37,
3569
+ 'ELOOP': 32,
3570
+ 'EOPNOTSUPP': 138,
3571
+ 'EPFNOSUPPORT': 139,
3572
+ 'ECONNRESET': 15,
3573
+ 'ENOBUFS': 42,
3574
+ 'EAFNOSUPPORT': 5,
3575
+ 'EPROTOTYPE': 67,
3576
+ 'ENOTSOCK': 57,
3577
+ 'ENOPROTOOPT': 50,
3578
+ 'ESHUTDOWN': 140,
3579
+ 'ECONNREFUSED': 14,
3580
+ 'EADDRINUSE': 3,
3581
+ 'ECONNABORTED': 13,
3582
+ 'ENETUNREACH': 40,
3583
+ 'ENETDOWN': 38,
3584
+ 'ETIMEDOUT': 73,
3585
+ 'EHOSTDOWN': 142,
3586
+ 'EHOSTUNREACH': 23,
3587
+ 'EINPROGRESS': 26,
3588
+ 'EALREADY': 7,
3589
+ 'EDESTADDRREQ': 17,
3590
+ 'EMSGSIZE': 35,
3591
+ 'EPROTONOSUPPORT': 66,
3592
+ 'ESOCKTNOSUPPORT': 137,
3593
+ 'EADDRNOTAVAIL': 4,
3594
+ 'ENETRESET': 39,
3595
+ 'EISCONN': 30,
3596
+ 'ENOTCONN': 53,
3597
+ 'ETOOMANYREFS': 141,
3598
+ 'EUSERS': 136,
3599
+ 'EDQUOT': 19,
3600
+ 'ESTALE': 72,
3601
+ 'ENOTSUP': 138,
3602
+ 'ENOMEDIUM': 148,
3603
+ 'EILSEQ': 25,
3604
+ 'EOVERFLOW': 61,
3605
+ 'ECANCELED': 11,
3606
+ 'ENOTRECOVERABLE': 56,
3607
+ 'EOWNERDEAD': 62,
3608
+ 'ESTRPIPE': 135,
3609
+ };
3509
3610
 
3510
3611
  var demangle = (func) => {
3511
3612
  warnOnce('warning: build with -sDEMANGLE_SUPPORT to link in libcxxabi demangling');
@@ -4844,7 +4945,6 @@ function unexportedRuntimeSymbol(sym) {
4844
4945
  FS.close(stream);
4845
4946
  FS.chmod(node, mode);
4846
4947
  }
4847
- return node;
4848
4948
  },
4849
4949
  createDevice(parent, name, input, output) {
4850
4950
  var path = PATH.join2(typeof parent == 'string' ? parent : FS.getPath(parent), name);
@@ -5143,19 +5243,19 @@ function unexportedRuntimeSymbol(sym) {
5143
5243
  HEAP32[(((buf)+(12))>>2)] = stat.uid;
5144
5244
  HEAP32[(((buf)+(16))>>2)] = stat.gid;
5145
5245
  HEAP32[(((buf)+(20))>>2)] = stat.rdev;
5146
- (tempI64 = [stat.size>>>0,(tempDouble=stat.size,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(24))>>2)] = tempI64[0],HEAP32[(((buf)+(28))>>2)] = tempI64[1]);
5246
+ (tempI64 = [stat.size>>>0,(tempDouble = stat.size,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(24))>>2)] = tempI64[0],HEAP32[(((buf)+(28))>>2)] = tempI64[1]);
5147
5247
  HEAP32[(((buf)+(32))>>2)] = 4096;
5148
5248
  HEAP32[(((buf)+(36))>>2)] = stat.blocks;
5149
5249
  var atime = stat.atime.getTime();
5150
5250
  var mtime = stat.mtime.getTime();
5151
5251
  var ctime = stat.ctime.getTime();
5152
- (tempI64 = [Math.floor(atime / 1000)>>>0,(tempDouble=Math.floor(atime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(40))>>2)] = tempI64[0],HEAP32[(((buf)+(44))>>2)] = tempI64[1]);
5252
+ (tempI64 = [Math.floor(atime / 1000)>>>0,(tempDouble = Math.floor(atime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(40))>>2)] = tempI64[0],HEAP32[(((buf)+(44))>>2)] = tempI64[1]);
5153
5253
  HEAPU32[(((buf)+(48))>>2)] = (atime % 1000) * 1000;
5154
- (tempI64 = [Math.floor(mtime / 1000)>>>0,(tempDouble=Math.floor(mtime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(56))>>2)] = tempI64[0],HEAP32[(((buf)+(60))>>2)] = tempI64[1]);
5254
+ (tempI64 = [Math.floor(mtime / 1000)>>>0,(tempDouble = Math.floor(mtime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(56))>>2)] = tempI64[0],HEAP32[(((buf)+(60))>>2)] = tempI64[1]);
5155
5255
  HEAPU32[(((buf)+(64))>>2)] = (mtime % 1000) * 1000;
5156
- (tempI64 = [Math.floor(ctime / 1000)>>>0,(tempDouble=Math.floor(ctime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(72))>>2)] = tempI64[0],HEAP32[(((buf)+(76))>>2)] = tempI64[1]);
5256
+ (tempI64 = [Math.floor(ctime / 1000)>>>0,(tempDouble = Math.floor(ctime / 1000),(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(72))>>2)] = tempI64[0],HEAP32[(((buf)+(76))>>2)] = tempI64[1]);
5157
5257
  HEAPU32[(((buf)+(80))>>2)] = (ctime % 1000) * 1000;
5158
- (tempI64 = [stat.ino>>>0,(tempDouble=stat.ino,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(88))>>2)] = tempI64[0],HEAP32[(((buf)+(92))>>2)] = tempI64[1]);
5258
+ (tempI64 = [stat.ino>>>0,(tempDouble = stat.ino,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((buf)+(88))>>2)] = tempI64[0],HEAP32[(((buf)+(92))>>2)] = tempI64[1]);
5159
5259
  return 0;
5160
5260
  },
5161
5261
  doMsync(addr, stream, len, flags, offset) {
@@ -5296,7 +5396,7 @@ function unexportedRuntimeSymbol(sym) {
5296
5396
  if (isNaN(offset)) return 61;
5297
5397
  var stream = SYSCALLS.getStreamFromFD(fd);
5298
5398
  FS.llseek(stream, offset, whence);
5299
- (tempI64 = [stream.position>>>0,(tempDouble=stream.position,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[((newOffset)>>2)] = tempI64[0],HEAP32[(((newOffset)+(4))>>2)] = tempI64[1]);
5399
+ (tempI64 = [stream.position>>>0,(tempDouble = stream.position,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[((newOffset)>>2)] = tempI64[0],HEAP32[(((newOffset)+(4))>>2)] = tempI64[1]);
5300
5400
  if (stream.getdents && offset === 0 && whence === 0) stream.getdents = null; // reset readdir state
5301
5401
  return 0;
5302
5402
  } catch (e) {
@@ -5335,9 +5435,7 @@ function unexportedRuntimeSymbol(sym) {
5335
5435
  }
5336
5436
  }
5337
5437
 
5338
- var isLeapYear = (year) => {
5339
- return year%4 === 0 && (year%100 !== 0 || year%400 === 0);
5340
- };
5438
+ var isLeapYear = (year) => year%4 === 0 && (year%100 !== 0 || year%400 === 0);
5341
5439
 
5342
5440
  var arraySum = (array, index) => {
5343
5441
  var sum = 0;
@@ -5709,129 +5807,7 @@ init_emval();UnboundTypeError = Module['UnboundTypeError'] = extendError(Error,
5709
5807
  });
5710
5808
  FS.FSNode = FSNode;
5711
5809
  FS.createPreloadedFile = FS_createPreloadedFile;
5712
- FS.staticInit();ERRNO_CODES = {
5713
- 'EPERM': 63,
5714
- 'ENOENT': 44,
5715
- 'ESRCH': 71,
5716
- 'EINTR': 27,
5717
- 'EIO': 29,
5718
- 'ENXIO': 60,
5719
- 'E2BIG': 1,
5720
- 'ENOEXEC': 45,
5721
- 'EBADF': 8,
5722
- 'ECHILD': 12,
5723
- 'EAGAIN': 6,
5724
- 'EWOULDBLOCK': 6,
5725
- 'ENOMEM': 48,
5726
- 'EACCES': 2,
5727
- 'EFAULT': 21,
5728
- 'ENOTBLK': 105,
5729
- 'EBUSY': 10,
5730
- 'EEXIST': 20,
5731
- 'EXDEV': 75,
5732
- 'ENODEV': 43,
5733
- 'ENOTDIR': 54,
5734
- 'EISDIR': 31,
5735
- 'EINVAL': 28,
5736
- 'ENFILE': 41,
5737
- 'EMFILE': 33,
5738
- 'ENOTTY': 59,
5739
- 'ETXTBSY': 74,
5740
- 'EFBIG': 22,
5741
- 'ENOSPC': 51,
5742
- 'ESPIPE': 70,
5743
- 'EROFS': 69,
5744
- 'EMLINK': 34,
5745
- 'EPIPE': 64,
5746
- 'EDOM': 18,
5747
- 'ERANGE': 68,
5748
- 'ENOMSG': 49,
5749
- 'EIDRM': 24,
5750
- 'ECHRNG': 106,
5751
- 'EL2NSYNC': 156,
5752
- 'EL3HLT': 107,
5753
- 'EL3RST': 108,
5754
- 'ELNRNG': 109,
5755
- 'EUNATCH': 110,
5756
- 'ENOCSI': 111,
5757
- 'EL2HLT': 112,
5758
- 'EDEADLK': 16,
5759
- 'ENOLCK': 46,
5760
- 'EBADE': 113,
5761
- 'EBADR': 114,
5762
- 'EXFULL': 115,
5763
- 'ENOANO': 104,
5764
- 'EBADRQC': 103,
5765
- 'EBADSLT': 102,
5766
- 'EDEADLOCK': 16,
5767
- 'EBFONT': 101,
5768
- 'ENOSTR': 100,
5769
- 'ENODATA': 116,
5770
- 'ETIME': 117,
5771
- 'ENOSR': 118,
5772
- 'ENONET': 119,
5773
- 'ENOPKG': 120,
5774
- 'EREMOTE': 121,
5775
- 'ENOLINK': 47,
5776
- 'EADV': 122,
5777
- 'ESRMNT': 123,
5778
- 'ECOMM': 124,
5779
- 'EPROTO': 65,
5780
- 'EMULTIHOP': 36,
5781
- 'EDOTDOT': 125,
5782
- 'EBADMSG': 9,
5783
- 'ENOTUNIQ': 126,
5784
- 'EBADFD': 127,
5785
- 'EREMCHG': 128,
5786
- 'ELIBACC': 129,
5787
- 'ELIBBAD': 130,
5788
- 'ELIBSCN': 131,
5789
- 'ELIBMAX': 132,
5790
- 'ELIBEXEC': 133,
5791
- 'ENOSYS': 52,
5792
- 'ENOTEMPTY': 55,
5793
- 'ENAMETOOLONG': 37,
5794
- 'ELOOP': 32,
5795
- 'EOPNOTSUPP': 138,
5796
- 'EPFNOSUPPORT': 139,
5797
- 'ECONNRESET': 15,
5798
- 'ENOBUFS': 42,
5799
- 'EAFNOSUPPORT': 5,
5800
- 'EPROTOTYPE': 67,
5801
- 'ENOTSOCK': 57,
5802
- 'ENOPROTOOPT': 50,
5803
- 'ESHUTDOWN': 140,
5804
- 'ECONNREFUSED': 14,
5805
- 'EADDRINUSE': 3,
5806
- 'ECONNABORTED': 13,
5807
- 'ENETUNREACH': 40,
5808
- 'ENETDOWN': 38,
5809
- 'ETIMEDOUT': 73,
5810
- 'EHOSTDOWN': 142,
5811
- 'EHOSTUNREACH': 23,
5812
- 'EINPROGRESS': 26,
5813
- 'EALREADY': 7,
5814
- 'EDESTADDRREQ': 17,
5815
- 'EMSGSIZE': 35,
5816
- 'EPROTONOSUPPORT': 66,
5817
- 'ESOCKTNOSUPPORT': 137,
5818
- 'EADDRNOTAVAIL': 4,
5819
- 'ENETRESET': 39,
5820
- 'EISCONN': 30,
5821
- 'ENOTCONN': 53,
5822
- 'ETOOMANYREFS': 141,
5823
- 'EUSERS': 136,
5824
- 'EDQUOT': 19,
5825
- 'ESTALE': 72,
5826
- 'ENOTSUP': 138,
5827
- 'ENOMEDIUM': 148,
5828
- 'EILSEQ': 25,
5829
- 'EOVERFLOW': 61,
5830
- 'ECANCELED': 11,
5831
- 'ENOTRECOVERABLE': 56,
5832
- 'EOWNERDEAD': 62,
5833
- 'ESTRPIPE': 135,
5834
- };function checkIncomingModuleAPI() {
5810
+ FS.staticInit();function checkIncomingModuleAPI() {
5835
5811
  ignoredModuleProp('fetchSettings');
5836
5812
  }
5837
5813
  var wasmImports = {
@@ -5913,7 +5889,6 @@ var _malloc = createExportWrapper('malloc');
5913
5889
  var _main = Module['_main'] = createExportWrapper('main');
5914
5890
  var _free = createExportWrapper('free');
5915
5891
  var ___getTypeName = createExportWrapper('__getTypeName');
5916
- Module['__embind_initialize_bindings'] = createExportWrapper('_embind_initialize_bindings');
5917
5892
  var _fflush = Module['_fflush'] = createExportWrapper('fflush');
5918
5893
  var _setThrew = createExportWrapper('setThrew');
5919
5894
  var _emscripten_stack_init = () => (_emscripten_stack_init = wasmExports['emscripten_stack_init'])();
@@ -6177,8 +6152,11 @@ var missingLibrarySymbols = [
6177
6152
  'downcastPointer',
6178
6153
  'upcastPointer',
6179
6154
  'validateThis',
6180
- 'craftEmvalAllocator',
6155
+ 'char_0',
6156
+ 'char_9',
6157
+ 'makeLegalFunctionName',
6181
6158
  'emval_get_global',
6159
+ 'emval_returnValue',
6182
6160
  'emval_lookupTypes',
6183
6161
  'emval_addMethodCaller',
6184
6162
  ];
@@ -6359,17 +6337,14 @@ var unexportedSymbols = [
6359
6337
  'detachFinalizer_deps',
6360
6338
  'deletionQueue',
6361
6339
  'delayFunction',
6362
- 'char_0',
6363
- 'char_9',
6364
- 'makeLegalFunctionName',
6365
6340
  'emval_handles',
6366
6341
  'emval_symbols',
6367
6342
  'init_emval',
6368
6343
  'count_emval_handles',
6369
6344
  'getStringOrSymbol',
6370
6345
  'Emval',
6371
- 'emval_newers',
6372
6346
  'emval_methodCallers',
6347
+ 'reflectConstruct',
6373
6348
  ];
6374
6349
  unexportedSymbols.forEach(unexportedRuntimeSymbol);
6375
6350
 
@@ -6524,7 +6499,6 @@ run();
6524
6499
 
6525
6500
  return moduleArg.ready
6526
6501
  }
6527
-
6528
6502
  );
6529
6503
  })();
6530
6504
  var libultrahdr = Module;
@@ -6544,6 +6518,96 @@ const getLibrary = async () => {
6544
6518
  }
6545
6519
  return library;
6546
6520
  };
6521
+
6522
+ /**
6523
+ *
6524
+ * @param description
6525
+ * @param name
6526
+ * @param defaultValue
6527
+ * @returns
6528
+ */
6529
+ const getAttribute = (description, name, defaultValue) => {
6530
+ var _a;
6531
+ let returnValue;
6532
+ const parsedValue = (_a = description.attributes.getNamedItem(name)) === null || _a === void 0 ? void 0 : _a.nodeValue;
6533
+ if (!parsedValue) {
6534
+ const node = description.getElementsByTagName(name)[0];
6535
+ if (node) {
6536
+ const values = node.getElementsByTagName('rdf:li');
6537
+ if (values.length === 3) {
6538
+ returnValue = Array.from(values).map(v => v.innerHTML);
6539
+ }
6540
+ else {
6541
+ throw new Error(`Gainmap metadata contains an array of items for ${name} but its length is not 3`);
6542
+ }
6543
+ }
6544
+ else {
6545
+ if (defaultValue)
6546
+ return defaultValue;
6547
+ else
6548
+ throw new Error(`Can't find ${name} in gainmap metadata`);
6549
+ }
6550
+ }
6551
+ else {
6552
+ returnValue = parsedValue;
6553
+ }
6554
+ return returnValue;
6555
+ };
6556
+ /**
6557
+ * Decodes a JPEG file with an embedded Gainmap and XMP Metadata (aka JPEG-R)
6558
+ *
6559
+ * @category Decoding
6560
+ * @group Decoding
6561
+ *
6562
+ * @example
6563
+ * import { decodeJPEGMetadata } from '@monogrid/gainmap-js/libultrahdr'
6564
+ *
6565
+ * // fetch a JPEG image containing a gainmap as ArrayBuffer
6566
+ * const gainmap = new Uint8Array(await (await fetch('gainmap.jpeg')).arrayBuffer())
6567
+ *
6568
+ * // extract data from the JPEG
6569
+ * const { gainMap, sdr, parsedMetadata } = await decodeJPEGMetadata(gainmap)
6570
+ *
6571
+ * @param file A Jpeg file Uint8Array.
6572
+ * @returns The decoded data
6573
+ * @throws {Error} if the provided file cannot be parsed or does not contain a valid Gainmap
6574
+ */
6575
+ const decodeJPEGMetadata = async (file) => {
6576
+ var _a, _b;
6577
+ const lib = await getLibrary();
6578
+ const result = lib.extractJpegR(file, file.length);
6579
+ if (!result.success)
6580
+ throw new Error(result.errorMessage);
6581
+ const parser = new DOMParser();
6582
+ const xmlDocument = parser.parseFromString(result.metadata, 'text/xml');
6583
+ const description = xmlDocument.getElementsByTagName('rdf:Description')[0];
6584
+ const gainMapMin = getAttribute(description, 'hdrgm:GainMapMin', '0');
6585
+ const gainMapMax = getAttribute(description, 'hdrgm:GainMapMax');
6586
+ const gamma = getAttribute(description, 'hdrgm:Gamma', '1');
6587
+ const offsetSDR = getAttribute(description, 'hdrgm:OffsetSDR', '0.015625');
6588
+ const offsetHDR = getAttribute(description, 'hdrgm:OffsetHDR', '0.015625');
6589
+ let hdrCapacityMin = (_a = description.attributes.getNamedItem('hdrgm:HDRCapacityMin')) === null || _a === void 0 ? void 0 : _a.nodeValue;
6590
+ if (!hdrCapacityMin)
6591
+ hdrCapacityMin = '0';
6592
+ const hdrCapacityMax = (_b = description.attributes.getNamedItem('hdrgm:HDRCapacityMax')) === null || _b === void 0 ? void 0 : _b.nodeValue;
6593
+ if (!hdrCapacityMax)
6594
+ throw new Error('Incomplete gainmap metadata');
6595
+ const parsedMetadata = {
6596
+ gainMapMin: Array.isArray(gainMapMin) ? gainMapMin.map(v => parseFloat(v)) : [parseFloat(gainMapMin), parseFloat(gainMapMin), parseFloat(gainMapMin)],
6597
+ gainMapMax: Array.isArray(gainMapMax) ? gainMapMax.map(v => parseFloat(v)) : [parseFloat(gainMapMax), parseFloat(gainMapMax), parseFloat(gainMapMax)],
6598
+ gamma: Array.isArray(gamma) ? gamma.map(v => parseFloat(v)) : [parseFloat(gamma), parseFloat(gamma), parseFloat(gamma)],
6599
+ offsetSdr: Array.isArray(offsetSDR) ? offsetSDR.map(v => parseFloat(v)) : [parseFloat(offsetSDR), parseFloat(offsetSDR), parseFloat(offsetSDR)],
6600
+ offsetHdr: Array.isArray(offsetHDR) ? offsetHDR.map(v => parseFloat(v)) : [parseFloat(offsetHDR), parseFloat(offsetHDR), parseFloat(offsetHDR)],
6601
+ hdrCapacityMin: parseFloat(hdrCapacityMin),
6602
+ hdrCapacityMax: parseFloat(hdrCapacityMax)
6603
+ };
6604
+ return Object.assign(Object.assign({}, result), {
6605
+ /**
6606
+ * Parsed metadata
6607
+ */
6608
+ parsedMetadata });
6609
+ };
6610
+
6547
6611
  /**
6548
6612
  * Encapsulates a Gainmap into a single JPEG file (aka: JPEG-R) with the base map
6549
6613
  * as the sdr visualization and the gainMap encoded into a MPF (Multi-Picture Format) tag.
@@ -6570,9 +6634,17 @@ const getLibrary = async () => {
6570
6634
  * })
6571
6635
  *
6572
6636
  * // obtain the RAW RGBA SDR buffer and create an ImageData
6573
- * const sdrImageData = new ImageData(encodingResult.sdr.toArray(), encodingResult.sdr.width, encodingResult.sdr.height)
6637
+ * const sdrImageData = new ImageData(
6638
+ * encodingResult.sdr.toArray(),
6639
+ * encodingResult.sdr.width,
6640
+ * encodingResult.sdr.height
6641
+ * )
6574
6642
  * // obtain the RAW RGBA Gain map buffer and create an ImageData
6575
- * const gainMapImageData = new ImageData(encodingResult.gainMap.toArray(), encodingResult.gainMap.width, encodingResult.gainMap.height)
6643
+ * const gainMapImageData = new ImageData(
6644
+ * encodingResult.gainMap.toArray(),
6645
+ * encodingResult.gainMap.width,
6646
+ * encodingResult.gainMap.height
6647
+ * )
6576
6648
  *
6577
6649
  * // parallel compress the RAW buffers into the specified mimeType
6578
6650
  * const mimeType = 'image/jpeg'
@@ -6622,107 +6694,79 @@ const encodeJPEGMetadata = async (encodingResult) => {
6622
6694
  throw new Error('This function expects a GainMap image compressed in jpeg');
6623
6695
  return lib.appendGainMap(encodingResult.sdr.width, encodingResult.sdr.height, encodingResult.sdr.data, encodingResult.sdr.data.length, encodingResult.gainMap.data, encodingResult.gainMap.data.length, encodingResult.gainMapMax.reduce((p, n) => p + n, 0) / encodingResult.gainMapMax.length, encodingResult.gainMapMin.reduce((p, n) => p + n, 0) / encodingResult.gainMapMin.length, encodingResult.gamma.reduce((p, n) => p + n, 0) / encodingResult.gamma.length, encodingResult.offsetSdr.reduce((p, n) => p + n, 0) / encodingResult.offsetSdr.length, encodingResult.offsetHdr.reduce((p, n) => p + n, 0) / encodingResult.offsetHdr.length, encodingResult.hdrCapacityMin, encodingResult.hdrCapacityMax);
6624
6696
  };
6697
+
6625
6698
  /**
6699
+ * A Three.js Loader for a JPEG with embedded gainmap metadata.
6626
6700
  *
6627
- * @param description
6628
- * @param name
6629
- * @param defaultValue
6630
- * @returns
6631
- */
6632
- const getAttribute = (description, name, defaultValue) => {
6633
- var _a;
6634
- let returnValue;
6635
- const parsedValue = (_a = description.attributes.getNamedItem(name)) === null || _a === void 0 ? void 0 : _a.nodeValue;
6636
- if (!parsedValue) {
6637
- const node = description.getElementsByTagName(name)[0];
6638
- if (node) {
6639
- const values = node.getElementsByTagName('rdf:li');
6640
- if (values.length === 3) {
6641
- returnValue = Array.from(values).map(v => v.innerHTML);
6642
- }
6643
- else {
6644
- throw new Error(`Gainmap metadata contains an array of items for ${name} but its length is not 3`);
6645
- }
6646
- }
6647
- else {
6648
- if (defaultValue)
6649
- return defaultValue;
6650
- else
6651
- throw new Error(`Can't find ${name} in gainmap metadata`);
6652
- }
6653
- }
6654
- else {
6655
- returnValue = parsedValue;
6656
- }
6657
- return returnValue;
6658
- };
6659
- /**
6660
- * Decodes a JPEG file with an embedded Gainmap and XMP Metadata (aka JPEG-R)
6661
- *
6662
- * @category Decoding
6663
- * @group Decoding
6701
+ * @category Loaders
6702
+ * @group Loaders
6664
6703
  *
6665
6704
  * @example
6666
- * import { decode } from '@monogrid/gainmap-js'
6667
- * import { decodeJPEGMetadata } from '@monogrid/gainmap-js/libultrahdr'
6668
- * import { Mesh, MeshBasicMaterial, PlaneGeometry } from 'three'
6669
- * // fetch a JPEG image containing a gainmap as ArrayBuffer
6670
- * const gainmap = await (await fetch('gainmap.jpeg')).arrayBuffer()
6705
+ * import { JPEGRLoader } from '@monogrid/gainmap-js/libultrahdr'
6706
+ * import {
6707
+ * EquirectangularReflectionMapping,
6708
+ * LinearFilter,
6709
+ * Mesh,
6710
+ * MeshBasicMaterial,
6711
+ * PerspectiveCamera,
6712
+ * PlaneGeometry,
6713
+ * Scene,
6714
+ * WebGLRenderer
6715
+ * } from 'three'
6671
6716
  *
6672
- * // extract data from the JPEG
6673
- * const { sdr, gainMap, parsedMetadata } = await decodeJPEGMetadata(new Uint8Array(gainmap))
6717
+ * const renderer = new WebGLRenderer()
6674
6718
  *
6675
- * // restore the HDR texture
6676
- * const result = await decode({
6677
- * sdr,
6678
- * gainMap,
6679
- * // this will restore the full HDR range
6680
- * maxDisplayBoost: Math.pow(2, parsedMetadata.hdrCapacityMax),
6681
- * ...parsedMetadata
6682
- * })
6719
+ * const loader = new JPEGRLoader(renderer)
6683
6720
  *
6684
- * // result can be used to populate a Texture
6685
- * const mesh = new Mesh(new PlaneGeometry(), new MeshBasicMaterial({ map: result.renderTarget.texture }))
6721
+ * const result = loader.load('gainmap.jpeg')
6722
+ * // `result` can be used to populate a Texture
6686
6723
  *
6724
+ * const scene = new Scene()
6725
+ * const mesh = new Mesh(
6726
+ * new PlaneGeometry(),
6727
+ * new MeshBasicMaterial({ map: result.renderTarget.texture })
6728
+ * )
6729
+ * scene.add(mesh)
6730
+ * renderer.render(scene, new PerspectiveCamera())
6731
+ *
6732
+ * // `result.renderTarget.texture` must be
6733
+ * // converted to `DataTexture` in order
6734
+ * // to use it as Equirectangular scene background
6735
+ * // if needed
6736
+ *
6737
+ * scene.background = result.toDataTexture()
6738
+ * scene.background.mapping = EquirectangularReflectionMapping
6739
+ * scene.background.minFilter = LinearFilter
6740
+
6687
6741
  *
6688
- * @param file A Jpeg file Uint8Array.
6689
- * @returns The decoded data
6690
- * @throws {Error} if the provided file cannot be parsed or does not contain a valid Gainmap
6691
6742
  */
6692
- const decodeJPEGMetadata = async (file) => {
6693
- var _a, _b;
6694
- const lib = await getLibrary();
6695
- const result = lib.extractJpegR(file, file.length);
6696
- if (!result.success)
6697
- throw new Error(result.errorMessage);
6698
- const parser = new DOMParser();
6699
- const xmldocuemnt = parser.parseFromString(result.metadata, 'text/xml');
6700
- const description = xmldocuemnt.getElementsByTagName('rdf:Description')[0];
6701
- const gainMapMin = getAttribute(description, 'hdrgm:GainMapMin', '0');
6702
- const gainMapMax = getAttribute(description, 'hdrgm:GainMapMax');
6703
- const gamma = getAttribute(description, 'hdrgm:Gamma', '1');
6704
- const offsetSDR = getAttribute(description, 'hdrgm:OffsetSDR', '0.015625');
6705
- const offsetHDR = getAttribute(description, 'hdrgm:OffsetHDR', '0.015625');
6706
- let hdrCapacityMin = (_a = description.attributes.getNamedItem('hdrgm:HDRCapacityMin')) === null || _a === void 0 ? void 0 : _a.nodeValue;
6707
- if (!hdrCapacityMin)
6708
- hdrCapacityMin = '0';
6709
- const hdrCapacityMax = (_b = description.attributes.getNamedItem('hdrgm:HDRCapacityMax')) === null || _b === void 0 ? void 0 : _b.nodeValue;
6710
- if (!hdrCapacityMax)
6711
- throw new Error('Incomplete gainmap metadata');
6712
- const parsedMetadata = {
6713
- gainMapMin: Array.isArray(gainMapMin) ? gainMapMin.map(v => parseFloat(v)) : [parseFloat(gainMapMin), parseFloat(gainMapMin), parseFloat(gainMapMin)],
6714
- gainMapMax: Array.isArray(gainMapMax) ? gainMapMax.map(v => parseFloat(v)) : [parseFloat(gainMapMax), parseFloat(gainMapMax), parseFloat(gainMapMax)],
6715
- gamma: Array.isArray(gamma) ? gamma.map(v => parseFloat(v)) : [parseFloat(gamma), parseFloat(gamma), parseFloat(gamma)],
6716
- offsetSdr: Array.isArray(offsetSDR) ? offsetSDR.map(v => parseFloat(v)) : [parseFloat(offsetSDR), parseFloat(offsetSDR), parseFloat(offsetSDR)],
6717
- offsetHdr: Array.isArray(offsetHDR) ? offsetHDR.map(v => parseFloat(v)) : [parseFloat(offsetHDR), parseFloat(offsetHDR), parseFloat(offsetHDR)],
6718
- hdrCapacityMin: parseFloat(hdrCapacityMin),
6719
- hdrCapacityMax: parseFloat(hdrCapacityMax)
6720
- };
6721
- return Object.assign(Object.assign({}, result), {
6722
- /**
6723
- * Parsed metadata
6724
- */
6725
- parsedMetadata });
6726
- };
6743
+ class JPEGRLoader extends LoaderBase {
6744
+ /**
6745
+ *
6746
+ * @param url
6747
+ * @param onLoad
6748
+ * @param onProgress
6749
+ * @param onError
6750
+ * @returns
6751
+ */
6752
+ load(url, onLoad, onProgress, onError) {
6753
+ const quadRenderer = this.prepareQuadRenderer();
6754
+ const loader = new FileLoader(this.manager);
6755
+ loader.setResponseType('arraybuffer');
6756
+ loader.setRequestHeader(this.requestHeader);
6757
+ loader.setPath(this.path);
6758
+ loader.setWithCredentials(this.withCredentials);
6759
+ loader.load(url, async (jpeg) => {
6760
+ if (typeof jpeg === 'string')
6761
+ throw new Error('Invalid buffer');
6762
+ const { gainMap: gainMapJPEG, parsedMetadata } = await decodeJPEGMetadata(new Uint8Array(jpeg));
6763
+ await this.render(quadRenderer, gainMapJPEG, jpeg, parsedMetadata);
6764
+ if (typeof onLoad === 'function')
6765
+ onLoad(quadRenderer);
6766
+ quadRenderer.dispose();
6767
+ }, onProgress, onError);
6768
+ return quadRenderer;
6769
+ }
6770
+ }
6727
6771
 
6728
- export { decodeJPEGMetadata, encodeJPEGMetadata, getLibrary };
6772
+ export { JPEGRLoader, decodeJPEGMetadata, encodeJPEGMetadata, getLibrary };