@monogrid/gainmap-js 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +103 -19
  3. package/dist/LoaderBase-aa4842c4.js +373 -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/index.d.ts +1 -1
  8. package/dist/index.js +173 -246
  9. package/dist/index.umd.js +305 -14
  10. package/dist/libultrahdr-esm.wasm +0 -0
  11. package/dist/libultrahdr.d.ts +14 -19
  12. package/dist/libultrahdr.js +245 -203
  13. package/dist/libultrahdr.umd.js +611 -206
  14. package/dist/loaders/GainMapLoader.d.ts +68 -0
  15. package/dist/loaders/JPEGRLoader.d.ts +60 -0
  16. package/dist/loaders/LoaderBase.d.ts +27 -0
  17. package/dist/materials/GainMapDecoderMaterial.d.ts +44 -1
  18. package/dist/materials/GainMapEncoderMaterial.d.ts +29 -2
  19. package/dist/types.d.ts +10 -0
  20. package/dist/utils/QuadRenderer.d.ts +2 -1
  21. package/dist/worker-interface.js +1 -1
  22. package/dist/worker-interface.umd.js +1 -1
  23. package/dist/worker.js +1 -1
  24. package/dist/worker.umd.js +1 -1
  25. package/libultrahdr-wasm/build/libultrahdr-debug.js +156 -182
  26. package/libultrahdr-wasm/build/libultrahdr-debug.wasm +0 -0
  27. package/libultrahdr-wasm/build/libultrahdr-esm.js +153 -182
  28. package/libultrahdr-wasm/build/libultrahdr-esm.wasm +0 -0
  29. package/libultrahdr-wasm/build/libultrahdr.js +151 -180
  30. package/libultrahdr-wasm/build/libultrahdr.wasm +0 -0
  31. package/package.json +1 -1
  32. package/examples/README.md +0 -3
  33. package/examples/compress.ts +0 -43
  34. package/examples/decode-from-jpeg.ts +0 -40
  35. package/examples/decode-from-separate-data.ts +0 -41
  36. package/examples/decode-to-datatexture.ts +0 -65
  37. package/examples/encode-and-compress.ts +0 -29
  38. package/examples/encode-jpeg-metadata.ts +0 -57
  39. package/examples/encode.ts +0 -28
  40. package/examples/globals.d.ts +0 -6
  41. package/examples/worker.ts +0 -41
  42. package/reports/eslint-examples.json +0 -1
  43. package/reports/eslint-src.json +0 -1
  44. package/reports/eslint-tests.json +0 -1
  45. package/reports/junit.xml +0 -35
  46. package/reports/typecheck-examples.log +0 -0
  47. package/reports/typecheck-tests.log +0 -0
  48. package/reports/typecheck.log +0 -0
@@ -1,8 +1,11 @@
1
1
  /**
2
- * @monogrid/gainmap-js v1.0.1
2
+ * @monogrid/gainmap-js v1.0.2
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-aa4842c4.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,11 +6499,84 @@ run();
6524
6499
 
6525
6500
  return moduleArg.ready
6526
6501
  }
6527
-
6528
6502
  );
6529
6503
  })();
6530
6504
  var libultrahdr = Module;
6531
6505
 
6506
+ /**
6507
+ * A Three.js Loader for a JPEG with embedded gainmap metadata.
6508
+ *
6509
+ * @category Loaders
6510
+ * @group Loaders
6511
+ *
6512
+ * @example
6513
+ * import { JPEGRLoader } from '@monogrid/gainmap-js/libultrahdr'
6514
+ * import {
6515
+ * EquirectangularReflectionMapping,
6516
+ * LinearFilter,
6517
+ * Mesh,
6518
+ * MeshBasicMaterial,
6519
+ * PerspectiveCamera,
6520
+ * PlaneGeometry,
6521
+ * Scene,
6522
+ * WebGLRenderer
6523
+ * } from 'three'
6524
+ *
6525
+ * const renderer = new WebGLRenderer()
6526
+ *
6527
+ * const loader = new JPEGRLoader(renderer)
6528
+ *
6529
+ * const result = loader.load('gainmap.jpeg')
6530
+ * // `result` can be used to populate a Texture
6531
+ *
6532
+ * const scene = new Scene()
6533
+ * const mesh = new Mesh(
6534
+ * new PlaneGeometry(),
6535
+ * new MeshBasicMaterial({ map: result.renderTarget.texture })
6536
+ * )
6537
+ * scene.add(mesh)
6538
+ * renderer.render(scene, new PerspectiveCamera())
6539
+ *
6540
+ * // `result.renderTarget.texture` must be
6541
+ * // converted to `DataTexture` in order
6542
+ * // to use it as Equirectanmgular scene background
6543
+ * // if needed
6544
+ *
6545
+ * scene.background = result.toDataTexture()
6546
+ * scene.background.mapping = EquirectangularReflectionMapping
6547
+ * scene.background.minFilter = LinearFilter
6548
+
6549
+ *
6550
+ */
6551
+ class JPEGRLoader extends LoaderBase {
6552
+ /**
6553
+ *
6554
+ * @param url
6555
+ * @param onLoad
6556
+ * @param onProgress
6557
+ * @param onError
6558
+ * @returns
6559
+ */
6560
+ load(url, onLoad, onProgress, onError) {
6561
+ const quadRenderer = this.prepareQuadRenderer();
6562
+ const loader = new FileLoader(this.manager);
6563
+ loader.setResponseType('arraybuffer');
6564
+ loader.setRequestHeader(this.requestHeader);
6565
+ loader.setPath(this.path);
6566
+ loader.setWithCredentials(this.withCredentials);
6567
+ loader.load(url, async (jpeg) => {
6568
+ if (typeof jpeg === 'string')
6569
+ throw new Error('Invalid buffer');
6570
+ const { gainMap: gainMapJPEG, parsedMetadata } = await decodeJPEGMetadata(new Uint8Array(jpeg));
6571
+ await this.render(quadRenderer, gainMapJPEG, jpeg, parsedMetadata);
6572
+ if (typeof onLoad === 'function')
6573
+ onLoad(quadRenderer);
6574
+ quadRenderer.dispose();
6575
+ }, onProgress, onError);
6576
+ return quadRenderer;
6577
+ }
6578
+ }
6579
+
6532
6580
  // @ts-expect-error untyped
6533
6581
  let library;
6534
6582
  /**
@@ -6570,9 +6618,17 @@ const getLibrary = async () => {
6570
6618
  * })
6571
6619
  *
6572
6620
  * // obtain the RAW RGBA SDR buffer and create an ImageData
6573
- * const sdrImageData = new ImageData(encodingResult.sdr.toArray(), encodingResult.sdr.width, encodingResult.sdr.height)
6621
+ * const sdrImageData = new ImageData(
6622
+ * encodingResult.sdr.toArray(),
6623
+ * encodingResult.sdr.width,
6624
+ * encodingResult.sdr.height
6625
+ * )
6574
6626
  * // 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)
6627
+ * const gainMapImageData = new ImageData(
6628
+ * encodingResult.gainMap.toArray(),
6629
+ * encodingResult.gainMap.width,
6630
+ * encodingResult.gainMap.height
6631
+ * )
6576
6632
  *
6577
6633
  * // parallel compress the RAW buffers into the specified mimeType
6578
6634
  * const mimeType = 'image/jpeg'
@@ -6663,27 +6719,13 @@ const getAttribute = (description, name, defaultValue) => {
6663
6719
  * @group Decoding
6664
6720
  *
6665
6721
  * @example
6666
- * import { decode } from '@monogrid/gainmap-js'
6667
6722
  * import { decodeJPEGMetadata } from '@monogrid/gainmap-js/libultrahdr'
6668
- * import { Mesh, MeshBasicMaterial, PlaneGeometry } from 'three'
6723
+ *
6669
6724
  * // fetch a JPEG image containing a gainmap as ArrayBuffer
6670
- * const gainmap = await (await fetch('gainmap.jpeg')).arrayBuffer()
6725
+ * const gainmap = new Uint8Array(await (await fetch('gainmap.jpeg')).arrayBuffer())
6671
6726
  *
6672
6727
  * // extract data from the JPEG
6673
- * const { sdr, gainMap, parsedMetadata } = await decodeJPEGMetadata(new Uint8Array(gainmap))
6674
- *
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
- * })
6683
- *
6684
- * // result can be used to populate a Texture
6685
- * const mesh = new Mesh(new PlaneGeometry(), new MeshBasicMaterial({ map: result.renderTarget.texture }))
6686
- *
6728
+ * const { gainMap, sdr, parsedMetadata } = await decodeJPEGMetadata(gainmap)
6687
6729
  *
6688
6730
  * @param file A Jpeg file Uint8Array.
6689
6731
  * @returns The decoded data
@@ -6725,4 +6767,4 @@ const decodeJPEGMetadata = async (file) => {
6725
6767
  parsedMetadata });
6726
6768
  };
6727
6769
 
6728
- export { decodeJPEGMetadata, encodeJPEGMetadata, getLibrary };
6770
+ export { JPEGRLoader, decodeJPEGMetadata, encodeJPEGMetadata, getLibrary };