@monogrid/gainmap-js 3.0.6 → 3.2.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 (57) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/CODE_OF_CONDUCT.md +1 -1
  3. package/CONTRIBUTING.md +1 -1
  4. package/README.md +106 -2
  5. package/dist/Loader-BZcKUVaX.js +424 -0
  6. package/dist/{QuadRenderer-B3h-sJtp.js → QuadRenderer-Y5tm-R3m.js} +39 -30
  7. package/dist/{_commonjsHelpers-UqyNh5ZN.js → _commonjsHelpers-CuGYGi_5.js} +2 -2
  8. package/dist/{compress-CAiPfiRr.js → compress-BaKKOAXI.js} +2 -3
  9. package/dist/core/QuadRenderer.d.ts +2 -2
  10. package/dist/core/get-data-texture.d.ts +4 -3
  11. package/dist/core/types.d.ts +2 -1
  12. package/dist/decode/index.d.ts +1 -11
  13. package/dist/decode/shared/Loader.d.ts +59 -0
  14. package/dist/decode/shared/decode.d.ts +24 -0
  15. package/dist/decode/{extract.d.ts → shared/extract.d.ts} +4 -4
  16. package/dist/decode/shared/index.d.ts +8 -0
  17. package/dist/decode/shared/types.d.ts +53 -0
  18. package/dist/decode/{utils → shared/utils}/MPFExtractor.d.ts +1 -1
  19. package/dist/decode/shared/utils/extractXMP.d.ts +2 -0
  20. package/dist/decode/{decode.d.ts → webgl/decode.d.ts} +6 -6
  21. package/dist/decode/webgl/index.d.ts +8 -0
  22. package/dist/decode/{loaders → webgl/loaders}/GainMapLoader.d.ts +5 -6
  23. package/dist/decode/{loaders → webgl/loaders}/HDRJPGLoader.d.ts +6 -7
  24. package/dist/decode/webgl/loaders/LoaderBaseWebGL.d.ts +20 -0
  25. package/dist/decode/{materials → webgl/materials}/GainMapDecoderMaterial.d.ts +2 -2
  26. package/dist/decode/webgpu/core/QuadRenderer.d.ts +153 -0
  27. package/dist/decode/webgpu/decode.d.ts +60 -0
  28. package/dist/decode/webgpu/index.d.ts +8 -0
  29. package/dist/decode/webgpu/loaders/GainMapLoader.d.ts +69 -0
  30. package/dist/decode/webgpu/loaders/HDRJPGLoader.d.ts +65 -0
  31. package/dist/decode/webgpu/loaders/LoaderBaseWebGPU.d.ts +20 -0
  32. package/dist/decode/webgpu/materials/GainMapDecoderMaterial.d.ts +78 -0
  33. package/dist/decode.js +45 -442
  34. package/dist/decode.umd.cjs +388 -358
  35. package/dist/decode.webgpu.js +814 -0
  36. package/dist/decode.webgpu.umd.cjs +1244 -0
  37. package/dist/encode/encode-and-compress.d.ts +3 -3
  38. package/dist/encode/encode.d.ts +3 -3
  39. package/dist/encode/find-texture-min-max.d.ts +4 -3
  40. package/dist/encode/types.d.ts +4 -3
  41. package/dist/encode.js +32 -11
  42. package/dist/encode.umd.cjs +67 -38
  43. package/dist/libultrahdr/decode-jpeg-metadata.d.ts +0 -3
  44. package/dist/libultrahdr/encode-jpeg-metadata.d.ts +2 -2
  45. package/dist/libultrahdr.js +42 -75
  46. package/dist/libultrahdr.umd.cjs +46 -79
  47. package/dist/worker-interface.js +74 -64
  48. package/dist/worker-interface.umd.cjs +73 -63
  49. package/dist/worker.js +103 -88
  50. package/dist/worker.umd.cjs +103 -89
  51. package/package.json +79 -72
  52. package/dist/decode/loaders/LoaderBase.d.ts +0 -45
  53. package/dist/decode/types.d.ts +0 -42
  54. package/dist/decode/utils/extractXMP.d.ts +0 -7
  55. /package/dist/decode/{errors → shared/errors}/GainMapNotFoundError.d.ts +0 -0
  56. /package/dist/decode/{errors → shared/errors}/XMPMetadataNotFoundError.d.ts +0 -0
  57. /package/dist/decode/{utils → shared/utils}/get-html-image-from-blob.d.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @monogrid/gainmap-js v3.0.6
3
- * With ❤️, by MONOGRID <rnd@monogrid.com>
2
+ * @monogrid/gainmap-js v3.2.0
3
+ * With ❤️, by MONOGRID <gainmap@monogrid.com>
4
4
  */
5
5
 
6
6
  (function (global, factory) {
@@ -11,7 +11,7 @@
11
11
 
12
12
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
13
13
  var Module = (() => {
14
- var _scriptDir = (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.src || new URL('libultrahdr.umd.cjs', document.baseURI).href));
14
+ var _scriptDir = (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('libultrahdr.umd.cjs', document.baseURI).href));
15
15
 
16
16
  return (
17
17
  async function(moduleArg = {}) {
@@ -107,7 +107,7 @@
107
107
  // TODO: Swap all `require()`'s with `import()`'s?
108
108
  const { createRequire } = await import('module');
109
109
  /** @suppress{duplicate} */
110
- var require$1 = createRequire((typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.src || new URL('libultrahdr.umd.cjs', document.baseURI).href)));
110
+ var require$1 = createRequire((typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('libultrahdr.umd.cjs', document.baseURI).href)));
111
111
  // These modules will usually be used on Node.js. Load them eagerly to avoid
112
112
  // the complexity of lazy-loading.
113
113
  var fs = require$1('fs');
@@ -119,7 +119,7 @@
119
119
  // EXPORT_ES6 + ENVIRONMENT_IS_NODE always requires use of import.meta.url,
120
120
  // since there's no way getting the current absolute path of the module when
121
121
  // support for that is not available.
122
- scriptDirectory = require$1('url').fileURLToPath(new URL('./', (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.src || new URL('libultrahdr.umd.cjs', document.baseURI).href)))); // includes trailing slash
122
+ scriptDirectory = require$1('url').fileURLToPath(new URL('./', (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('libultrahdr.umd.cjs', document.baseURI).href)))); // includes trailing slash
123
123
  }
124
124
 
125
125
  // include: node_shell_read.js
@@ -709,7 +709,7 @@
709
709
  }
710
710
  } else {
711
711
  // Use bundler-friendly `new URL(..., import.meta.url)` pattern; works in browsers too.
712
- wasmBinaryFile = new URL('libultrahdr-esm.wasm', (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.src || new URL('libultrahdr.umd.cjs', document.baseURI).href))).href;
712
+ wasmBinaryFile = new URL('libultrahdr-esm.wasm', (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('libultrahdr.umd.cjs', document.baseURI).href))).href;
713
713
  }
714
714
 
715
715
  function getBinarySync(file) {
@@ -993,7 +993,7 @@
993
993
  }
994
994
  };
995
995
 
996
- var noExitRuntime = Module['noExitRuntime'] || true;
996
+ Module['noExitRuntime'] || true;
997
997
 
998
998
  var ptrToString = (ptr) => {
999
999
  assert(typeof ptr === 'number');
@@ -1509,7 +1509,7 @@
1509
1509
 
1510
1510
  assert(!isAsync, 'Async bindings are only supported with JSPI.');
1511
1511
 
1512
- var isClassMethodFunc = (argTypes[1] !== null && classType !== null);
1512
+ (argTypes[1] !== null && classType !== null);
1513
1513
 
1514
1514
  // Free functions with signature "void function()" do not need an invoker that marshalls between wire types.
1515
1515
  // TODO: This omits argument count check - enable only at -O3 or similar.
@@ -1551,27 +1551,19 @@
1551
1551
  var args1 = ["throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"];
1552
1552
  var args2 = [throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]];
1553
1553
 
1554
- if (isClassMethodFunc) {
1555
- invokerFnBody += "var thisWired = classParam.toWireType("+dtorStack+", this);\n";
1556
- }
1557
-
1558
1554
  for (var i = 0; i < argCount - 2; ++i) {
1559
1555
  invokerFnBody += "var arg"+i+"Wired = argType"+i+".toWireType("+dtorStack+", arg"+i+"); // "+argTypes[i+2].name+"\n";
1560
1556
  args1.push("argType"+i);
1561
1557
  args2.push(argTypes[i+2]);
1562
1558
  }
1563
1559
 
1564
- if (isClassMethodFunc) {
1565
- argsListWired = "thisWired" + (argsListWired.length > 0 ? ", " : "") + argsListWired;
1566
- }
1567
-
1568
1560
  invokerFnBody +=
1569
1561
  (returns || isAsync ? "var rv = ":"") + "invoker(fn"+(argsListWired.length>0?", ":"")+argsListWired+");\n";
1570
1562
 
1571
1563
  if (needsDestructorStack) {
1572
1564
  invokerFnBody += "runDestructors(destructors);\n";
1573
1565
  } else {
1574
- for (var i = isClassMethodFunc?1:2; i < argTypes.length; ++i) { // Skip return value at index 0 - it's not deleted here. Also skip class type if not a method.
1566
+ for (var i = 2; i < argTypes.length; ++i) { // Skip return value at index 0 - it's not deleted here. Also skip class type if not a method.
1575
1567
  var paramName = (i === 1 ? "thisWired" : ("arg"+(i - 2)+"Wired"));
1576
1568
  if (argTypes[i].destructorFunction !== null) {
1577
1569
  invokerFnBody += paramName+"_dtor("+paramName+"); // "+argTypes[i].name+"\n";
@@ -4240,7 +4232,7 @@
4240
4232
  throw new FS.ErrnoError(63);
4241
4233
  }
4242
4234
  node.node_ops.setattr(node, {
4243
- mode: (mode & 4095) | (node.mode & ~4095),
4235
+ mode: (mode & 4095) | (node.mode & -4096),
4244
4236
  timestamp: Date.now()
4245
4237
  });
4246
4238
  },
@@ -4361,7 +4353,7 @@
4361
4353
  }
4362
4354
  // can't truncate a device
4363
4355
  if (FS.isChrdev(node.mode)) {
4364
- flags &= ~512;
4356
+ flags &= -513;
4365
4357
  }
4366
4358
  // if asked only for a directory, then this must be one
4367
4359
  if ((flags & 65536) && !FS.isDir(node.mode)) {
@@ -4381,7 +4373,7 @@
4381
4373
  FS.truncate(node, 0);
4382
4374
  }
4383
4375
  // we've already handled these, don't pass down to the underlying vfs
4384
- flags &= ~(128 | 512 | 131072);
4376
+ flags &= -131713;
4385
4377
 
4386
4378
  // register the stream with the filesystem
4387
4379
  var stream = FS.createStream({
@@ -5217,14 +5209,9 @@
5217
5209
 
5218
5210
 
5219
5211
  var runtimeKeepaliveCounter = 0;
5220
- var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
5221
5212
 
5222
5213
  var _proc_exit = (code) => {
5223
5214
  EXITSTATUS = code;
5224
- if (!keepRuntimeAlive()) {
5225
- if (Module['onExit']) Module['onExit'](code);
5226
- ABORT = true;
5227
- }
5228
5215
  quit_(code, new ExitStatus(code));
5229
5216
  };
5230
5217
 
@@ -5236,7 +5223,7 @@
5236
5223
  checkUnflushedContent();
5237
5224
 
5238
5225
  // if exit() was called explicitly, warn the user if the runtime isn't actually being shut down
5239
- if (keepRuntimeAlive() && !implicit) {
5226
+ if (!implicit) {
5240
5227
  var msg = `program exited (with status: ${status}), but keepRuntimeAlive() is set (counter=${runtimeKeepaliveCounter}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`;
5241
5228
  readyPromiseReject(msg);
5242
5229
  err(msg);
@@ -6540,46 +6527,12 @@
6540
6527
  */
6541
6528
  const getLibrary = async () => {
6542
6529
  if (!library) {
6530
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
6543
6531
  library = await Module();
6544
6532
  }
6545
6533
  return library;
6546
6534
  };
6547
6535
 
6548
- /**
6549
- * @deprecated
6550
- * @param description
6551
- * @param name
6552
- * @param defaultValue
6553
- * @returns
6554
- */
6555
- /* istanbul ignore next */
6556
- const getAttribute = (description, name, defaultValue) => {
6557
- var _a;
6558
- let returnValue;
6559
- const parsedValue = (_a = description.attributes.getNamedItem(name)) === null || _a === void 0 ? void 0 : _a.nodeValue;
6560
- if (!parsedValue) {
6561
- const node = description.getElementsByTagName(name)[0];
6562
- if (node) {
6563
- const values = node.getElementsByTagName('rdf:li');
6564
- if (values.length === 3) {
6565
- returnValue = Array.from(values).map(v => v.innerHTML);
6566
- }
6567
- else {
6568
- throw new Error(`Gainmap metadata contains an array of items for ${name} but its length is not 3`);
6569
- }
6570
- }
6571
- else {
6572
- if (defaultValue)
6573
- return defaultValue;
6574
- else
6575
- throw new Error(`Can't find ${name} in gainmap metadata`);
6576
- }
6577
- }
6578
- else {
6579
- returnValue = parsedValue;
6580
- }
6581
- return returnValue;
6582
- };
6583
6536
  /**
6584
6537
  * Decodes a JPEG file with an embedded Gainmap and XMP Metadata (aka JPEG-R)
6585
6538
  *
@@ -6601,25 +6554,42 @@
6601
6554
  */
6602
6555
  /* istanbul ignore next */
6603
6556
  const decodeJPEGMetadata = async (file) => {
6604
- var _a, _b;
6605
6557
  const lib = await getLibrary();
6606
6558
  const result = lib.extractJpegR(file, file.length);
6607
6559
  if (!result.success)
6608
6560
  throw new Error(`${result.errorMessage}`);
6609
- const parser = new DOMParser();
6610
- const xmlDocument = parser.parseFromString(result.metadata, 'text/xml');
6611
- const description = xmlDocument.getElementsByTagName('rdf:Description')[0];
6612
- const gainMapMin = getAttribute(description, 'hdrgm:GainMapMin', '0');
6613
- const gainMapMax = getAttribute(description, 'hdrgm:GainMapMax');
6614
- const gamma = getAttribute(description, 'hdrgm:Gamma', '1');
6615
- const offsetSDR = getAttribute(description, 'hdrgm:OffsetSDR', '0.015625');
6616
- const offsetHDR = getAttribute(description, 'hdrgm:OffsetHDR', '0.015625');
6617
- let hdrCapacityMin = (_a = description.attributes.getNamedItem('hdrgm:HDRCapacityMin')) === null || _a === void 0 ? void 0 : _a.nodeValue;
6618
- if (!hdrCapacityMin)
6619
- hdrCapacityMin = '0';
6620
- const hdrCapacityMax = (_b = description.attributes.getNamedItem('hdrgm:HDRCapacityMax')) === null || _b === void 0 ? void 0 : _b.nodeValue;
6621
- if (!hdrCapacityMax)
6561
+ const getXMLValue = (xml, tag, defaultValue) => {
6562
+ // Check for attribute format first: tag="value"
6563
+ const attributeMatch = new RegExp(`${tag}="([^"]*)"`, 'i').exec(xml);
6564
+ if (attributeMatch)
6565
+ return attributeMatch[1];
6566
+ // Check for tag format: <tag>value</tag> or <tag><rdf:li>value</rdf:li>...</tag>
6567
+ const tagMatch = new RegExp(`<${tag}[^>]*>([\\s\\S]*?)</${tag}>`, 'i').exec(xml);
6568
+ if (tagMatch) {
6569
+ // Check if it contains rdf:li elements
6570
+ const liValues = tagMatch[1].match(/<rdf:li>([^<]*)<\/rdf:li>/g);
6571
+ if (liValues && liValues.length === 3) {
6572
+ return liValues.map(v => v.replace(/<\/?rdf:li>/g, ''));
6573
+ }
6574
+ return tagMatch[1].trim();
6575
+ }
6576
+ if (defaultValue !== undefined)
6577
+ return defaultValue;
6578
+ throw new Error(`Can't find ${tag} in gainmap metadata`);
6579
+ };
6580
+ const metadata = result.metadata;
6581
+ const gainMapMin = getXMLValue(metadata, 'hdrgm:GainMapMin', '0');
6582
+ const gainMapMax = getXMLValue(metadata, 'hdrgm:GainMapMax');
6583
+ const gamma = getXMLValue(metadata, 'hdrgm:Gamma', '1');
6584
+ const offsetSDR = getXMLValue(metadata, 'hdrgm:OffsetSDR', '0.015625');
6585
+ const offsetHDR = getXMLValue(metadata, 'hdrgm:OffsetHDR', '0.015625');
6586
+ // These are always attributes, so we can use a simpler regex
6587
+ const hdrCapacityMinMatch = /hdrgm:HDRCapacityMin="([^"]*)"/.exec(metadata);
6588
+ const hdrCapacityMin = hdrCapacityMinMatch ? hdrCapacityMinMatch[1] : '0';
6589
+ const hdrCapacityMaxMatch = /hdrgm:HDRCapacityMax="([^"]*)"/.exec(metadata);
6590
+ if (!hdrCapacityMaxMatch)
6622
6591
  throw new Error('Incomplete gainmap metadata');
6592
+ const hdrCapacityMax = hdrCapacityMaxMatch[1];
6623
6593
  const parsedMetadata = {
6624
6594
  gainMapMin: Array.isArray(gainMapMin) ? gainMapMin.map(v => parseFloat(v)) : [parseFloat(gainMapMin), parseFloat(gainMapMin), parseFloat(gainMapMin)],
6625
6595
  gainMapMax: Array.isArray(gainMapMax) ? gainMapMax.map(v => parseFloat(v)) : [parseFloat(gainMapMax), parseFloat(gainMapMax), parseFloat(gainMapMax)],
@@ -6631,9 +6601,6 @@
6631
6601
  };
6632
6602
  return {
6633
6603
  ...result,
6634
- /**
6635
- * Parsed metadata
6636
- */
6637
6604
  parsedMetadata
6638
6605
  };
6639
6606
  };
@@ -6655,7 +6622,7 @@
6655
6622
  * const image = await loader.loadAsync('image.exr')
6656
6623
  *
6657
6624
  * // find RAW RGB Max value of a texture
6658
- * const textureMax = await findTextureMinMax(image)
6625
+ * const textureMax = findTextureMinMax(image)
6659
6626
  *
6660
6627
  * // Encode the gainmap
6661
6628
  * const encodingResult = encode({
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @monogrid/gainmap-js v3.0.6
3
- * With ❤️, by MONOGRID <rnd@monogrid.com>
2
+ * @monogrid/gainmap-js v3.2.0
3
+ * With ❤️, by MONOGRID <gainmap@monogrid.com>
4
4
  */
5
5
 
6
- import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-UqyNh5ZN.js';
6
+ import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-CuGYGi_5.js';
7
7
 
8
8
  var lib$1;
9
9
  var hasRequiredLib$1;
@@ -392,79 +392,89 @@ function requireLib () {
392
392
  return lib;
393
393
  }
394
394
 
395
- /* istanbul ignore next */
396
- var MyPromise = typeof Promise !== 'undefined' ? Promise : requireLib();
395
+ var promiseWorkerTransferable;
396
+ var hasRequiredPromiseWorkerTransferable;
397
+
398
+ function requirePromiseWorkerTransferable () {
399
+ if (hasRequiredPromiseWorkerTransferable) return promiseWorkerTransferable;
400
+ hasRequiredPromiseWorkerTransferable = 1;
401
+
402
+ /* istanbul ignore next */
403
+ var MyPromise = typeof Promise !== 'undefined' ? Promise : requireLib();
397
404
 
398
- var messageIds = 0;
405
+ var messageIds = 0;
399
406
 
400
- function onMessage(self, e) {
401
- var message = e.data;
402
- if (!Array.isArray(message) || message.length < 2) {
403
- // Ignore - this message is not for us.
404
- return;
405
- }
406
- var messageId = message[0];
407
- var error = message[1];
408
- var result = message[2];
407
+ function onMessage(self, e) {
408
+ var message = e.data;
409
+ if (!Array.isArray(message) || message.length < 2) {
410
+ // Ignore - this message is not for us.
411
+ return;
412
+ }
413
+ var messageId = message[0];
414
+ var error = message[1];
415
+ var result = message[2];
409
416
 
410
- var callback = self._callbacks[messageId];
417
+ var callback = self._callbacks[messageId];
411
418
 
412
- if (!callback) {
413
- // Ignore - user might have created multiple PromiseWorkers.
414
- // This message is not for us.
415
- return;
416
- }
419
+ if (!callback) {
420
+ // Ignore - user might have created multiple PromiseWorkers.
421
+ // This message is not for us.
422
+ return;
423
+ }
417
424
 
418
- delete self._callbacks[messageId];
419
- callback(error, result);
420
- }
425
+ delete self._callbacks[messageId];
426
+ callback(error, result);
427
+ }
421
428
 
422
- function PromiseWorker(worker) {
423
- var self = this;
424
- self._worker = worker;
425
- self._callbacks = {};
429
+ function PromiseWorker(worker) {
430
+ var self = this;
431
+ self._worker = worker;
432
+ self._callbacks = {};
426
433
 
427
- worker.addEventListener('message', function (e) {
428
- onMessage(self, e);
429
- });
430
- }
434
+ worker.addEventListener('message', function (e) {
435
+ onMessage(self, e);
436
+ });
437
+ }
431
438
 
432
- PromiseWorker.prototype.postMessage = function (userMessage, transferList) {
433
- var self = this;
434
- var messageId = messageIds++;
439
+ PromiseWorker.prototype.postMessage = function (userMessage, transferList) {
440
+ var self = this;
441
+ var messageId = messageIds++;
435
442
 
436
- var messageToSend = [messageId, userMessage];
443
+ var messageToSend = [messageId, userMessage];
437
444
 
438
- return new MyPromise(function (resolve, reject) {
439
- self._callbacks[messageId] = function (error, result) {
440
- if (error) {
441
- return reject(new Error(error.message));
442
- }
443
- resolve(result);
444
- };
445
- /* istanbul ignore if */
446
- if (typeof self._worker.controller !== 'undefined') {
447
- // service worker, use MessageChannels because e.source is broken in Chrome < 51:
448
- // https://bugs.chromium.org/p/chromium/issues/detail?id=543198
449
- var channel = new MessageChannel();
450
- channel.port1.onmessage = function (e) {
451
- onMessage(self, e);
452
- };
453
- self._worker.controller.postMessage(messageToSend, [channel.port2].concat(transferList));
454
- } else {
455
- // web worker
456
- self._worker.postMessage(messageToSend, transferList);
457
- }
458
- });
459
- };
445
+ return new MyPromise(function (resolve, reject) {
446
+ self._callbacks[messageId] = function (error, result) {
447
+ if (error) {
448
+ return reject(new Error(error.message));
449
+ }
450
+ resolve(result);
451
+ };
452
+ /* istanbul ignore if */
453
+ if (typeof self._worker.controller !== 'undefined') {
454
+ // service worker, use MessageChannels because e.source is broken in Chrome < 51:
455
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=543198
456
+ var channel = new MessageChannel();
457
+ channel.port1.onmessage = function (e) {
458
+ onMessage(self, e);
459
+ };
460
+ self._worker.controller.postMessage(messageToSend, [channel.port2].concat(transferList));
461
+ } else {
462
+ // web worker
463
+ self._worker.postMessage(messageToSend, transferList);
464
+ }
465
+ });
466
+ };
460
467
 
461
- PromiseWorker.prototype.terminate = function () {
462
- this._worker.terminate();
463
- };
468
+ PromiseWorker.prototype.terminate = function () {
469
+ this._worker.terminate();
470
+ };
464
471
 
465
- var promiseWorkerTransferable = PromiseWorker;
472
+ promiseWorkerTransferable = PromiseWorker;
473
+ return promiseWorkerTransferable;
474
+ }
466
475
 
467
- var PromiseWorker$1 = /*@__PURE__*/getDefaultExportFromCjs(promiseWorkerTransferable);
476
+ var promiseWorkerTransferableExports = requirePromiseWorkerTransferable();
477
+ var PromiseWorker = /*@__PURE__*/getDefaultExportFromCjs(promiseWorkerTransferableExports);
468
478
 
469
479
  // @ts-expect-error untyped lib
470
480
  /**
@@ -475,7 +485,7 @@ var PromiseWorker$1 = /*@__PURE__*/getDefaultExportFromCjs(promiseWorkerTransfer
475
485
  */
476
486
  const getPromiseWorker = (worker) => {
477
487
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call
478
- return new PromiseWorker$1(worker);
488
+ return new PromiseWorker(worker);
479
489
  };
480
490
  /**
481
491
  * Returns an interface where methods of the worker can be called by the host site
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @monogrid/gainmap-js v3.0.6
3
- * With ❤️, by MONOGRID <rnd@monogrid.com>
2
+ * @monogrid/gainmap-js v3.2.0
3
+ * With ❤️, by MONOGRID <gainmap@monogrid.com>
4
4
  */
5
5
 
6
6
  (function (global, factory) {
@@ -402,79 +402,89 @@
402
402
  return lib;
403
403
  }
404
404
 
405
- /* istanbul ignore next */
406
- var MyPromise = typeof Promise !== 'undefined' ? Promise : requireLib();
405
+ var promiseWorkerTransferable;
406
+ var hasRequiredPromiseWorkerTransferable;
407
+
408
+ function requirePromiseWorkerTransferable () {
409
+ if (hasRequiredPromiseWorkerTransferable) return promiseWorkerTransferable;
410
+ hasRequiredPromiseWorkerTransferable = 1;
411
+
412
+ /* istanbul ignore next */
413
+ var MyPromise = typeof Promise !== 'undefined' ? Promise : requireLib();
407
414
 
408
- var messageIds = 0;
415
+ var messageIds = 0;
409
416
 
410
- function onMessage(self, e) {
411
- var message = e.data;
412
- if (!Array.isArray(message) || message.length < 2) {
413
- // Ignore - this message is not for us.
414
- return;
415
- }
416
- var messageId = message[0];
417
- var error = message[1];
418
- var result = message[2];
417
+ function onMessage(self, e) {
418
+ var message = e.data;
419
+ if (!Array.isArray(message) || message.length < 2) {
420
+ // Ignore - this message is not for us.
421
+ return;
422
+ }
423
+ var messageId = message[0];
424
+ var error = message[1];
425
+ var result = message[2];
419
426
 
420
- var callback = self._callbacks[messageId];
427
+ var callback = self._callbacks[messageId];
421
428
 
422
- if (!callback) {
423
- // Ignore - user might have created multiple PromiseWorkers.
424
- // This message is not for us.
425
- return;
426
- }
429
+ if (!callback) {
430
+ // Ignore - user might have created multiple PromiseWorkers.
431
+ // This message is not for us.
432
+ return;
433
+ }
427
434
 
428
- delete self._callbacks[messageId];
429
- callback(error, result);
430
- }
435
+ delete self._callbacks[messageId];
436
+ callback(error, result);
437
+ }
431
438
 
432
- function PromiseWorker(worker) {
433
- var self = this;
434
- self._worker = worker;
435
- self._callbacks = {};
439
+ function PromiseWorker(worker) {
440
+ var self = this;
441
+ self._worker = worker;
442
+ self._callbacks = {};
436
443
 
437
- worker.addEventListener('message', function (e) {
438
- onMessage(self, e);
439
- });
440
- }
444
+ worker.addEventListener('message', function (e) {
445
+ onMessage(self, e);
446
+ });
447
+ }
441
448
 
442
- PromiseWorker.prototype.postMessage = function (userMessage, transferList) {
443
- var self = this;
444
- var messageId = messageIds++;
449
+ PromiseWorker.prototype.postMessage = function (userMessage, transferList) {
450
+ var self = this;
451
+ var messageId = messageIds++;
445
452
 
446
- var messageToSend = [messageId, userMessage];
453
+ var messageToSend = [messageId, userMessage];
447
454
 
448
- return new MyPromise(function (resolve, reject) {
449
- self._callbacks[messageId] = function (error, result) {
450
- if (error) {
451
- return reject(new Error(error.message));
452
- }
453
- resolve(result);
454
- };
455
- /* istanbul ignore if */
456
- if (typeof self._worker.controller !== 'undefined') {
457
- // service worker, use MessageChannels because e.source is broken in Chrome < 51:
458
- // https://bugs.chromium.org/p/chromium/issues/detail?id=543198
459
- var channel = new MessageChannel();
460
- channel.port1.onmessage = function (e) {
461
- onMessage(self, e);
462
- };
463
- self._worker.controller.postMessage(messageToSend, [channel.port2].concat(transferList));
464
- } else {
465
- // web worker
466
- self._worker.postMessage(messageToSend, transferList);
467
- }
468
- });
469
- };
455
+ return new MyPromise(function (resolve, reject) {
456
+ self._callbacks[messageId] = function (error, result) {
457
+ if (error) {
458
+ return reject(new Error(error.message));
459
+ }
460
+ resolve(result);
461
+ };
462
+ /* istanbul ignore if */
463
+ if (typeof self._worker.controller !== 'undefined') {
464
+ // service worker, use MessageChannels because e.source is broken in Chrome < 51:
465
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=543198
466
+ var channel = new MessageChannel();
467
+ channel.port1.onmessage = function (e) {
468
+ onMessage(self, e);
469
+ };
470
+ self._worker.controller.postMessage(messageToSend, [channel.port2].concat(transferList));
471
+ } else {
472
+ // web worker
473
+ self._worker.postMessage(messageToSend, transferList);
474
+ }
475
+ });
476
+ };
470
477
 
471
- PromiseWorker.prototype.terminate = function () {
472
- this._worker.terminate();
473
- };
478
+ PromiseWorker.prototype.terminate = function () {
479
+ this._worker.terminate();
480
+ };
474
481
 
475
- var promiseWorkerTransferable = PromiseWorker;
482
+ promiseWorkerTransferable = PromiseWorker;
483
+ return promiseWorkerTransferable;
484
+ }
476
485
 
477
- var PromiseWorker$1 = /*@__PURE__*/getDefaultExportFromCjs(promiseWorkerTransferable);
486
+ var promiseWorkerTransferableExports = requirePromiseWorkerTransferable();
487
+ var PromiseWorker = /*@__PURE__*/getDefaultExportFromCjs(promiseWorkerTransferableExports);
478
488
 
479
489
  // @ts-expect-error untyped lib
480
490
  /**
@@ -485,7 +495,7 @@
485
495
  */
486
496
  const getPromiseWorker = (worker) => {
487
497
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call
488
- return new PromiseWorker$1(worker);
498
+ return new PromiseWorker(worker);
489
499
  };
490
500
  /**
491
501
  * Returns an interface where methods of the worker can be called by the host site