@loaders.gl/scientific 5.0.0-beta.4 → 5.0.0-beta.5

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 (62) hide show
  1. package/README.md +6 -2
  2. package/dist/index.cjs +48 -4
  3. package/dist/index.cjs.map +4 -4
  4. package/dist/index.d.ts +4 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +3 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/netcdf/netcdf-loader.cjs +1 -1
  9. package/dist/netcdf/netcdf-loader.js +1 -1
  10. package/dist/netcdf/netcdf-source-loader-types.js +1 -1
  11. package/dist/netcdf/netcdf-source-loader.js +1 -1
  12. package/dist/netcdf.min.js +2 -2
  13. package/dist/npy-loader-types.cjs +1 -1
  14. package/dist/npy-loader-types.js +1 -1
  15. package/dist/npy-loader.cjs +1 -1
  16. package/dist/npy-worker.js +239 -11
  17. package/dist/nrrd/parse-nrrd.d.ts +22 -0
  18. package/dist/nrrd/parse-nrrd.d.ts.map +1 -0
  19. package/dist/nrrd/parse-nrrd.js +228 -0
  20. package/dist/nrrd/parse-nrrd.js.map +1 -0
  21. package/dist/nrrd-loader-types.cjs +58 -0
  22. package/dist/nrrd-loader-types.cjs.map +7 -0
  23. package/dist/nrrd-loader-types.d.ts +31 -0
  24. package/dist/nrrd-loader-types.d.ts.map +1 -0
  25. package/dist/nrrd-loader-types.js +25 -0
  26. package/dist/nrrd-loader-types.js.map +1 -0
  27. package/dist/nrrd-loader.cjs +252 -0
  28. package/dist/nrrd-loader.cjs.map +6 -0
  29. package/dist/nrrd-loader.d.ts +16 -0
  30. package/dist/nrrd-loader.d.ts.map +1 -0
  31. package/dist/nrrd-loader.js +8 -0
  32. package/dist/nrrd-loader.js.map +1 -0
  33. package/dist/vtk/index.cjs +26 -3
  34. package/dist/vtk/index.cjs.map +2 -2
  35. package/dist/vtk/vtk.d.ts.map +1 -1
  36. package/dist/vtk/vtk.js +19 -1
  37. package/dist/vtk/vtk.js.map +1 -1
  38. package/dist/vtk-loader-types.cjs +58 -0
  39. package/dist/vtk-loader-types.cjs.map +7 -0
  40. package/dist/vtk-loader-types.d.ts +34 -0
  41. package/dist/vtk-loader-types.d.ts.map +1 -0
  42. package/dist/vtk-loader-types.js +25 -0
  43. package/dist/vtk-loader-types.js.map +1 -0
  44. package/dist/vtk-loader.cjs +384 -0
  45. package/dist/vtk-loader.cjs.map +6 -0
  46. package/dist/vtk-loader.d.ts +21 -0
  47. package/dist/vtk-loader.d.ts.map +1 -0
  48. package/dist/vtk-loader.js +21 -0
  49. package/dist/vtk-loader.js.map +1 -0
  50. package/dist/zarr/geo-zarr-source-loader.js +1 -1
  51. package/dist/zarr/ome-zarr-source-loader.js +1 -1
  52. package/dist/zarr/zarr-loader-types.cjs +1 -1
  53. package/dist/zarr/zarr-loader-types.js +1 -1
  54. package/dist/zarr.min.js +3 -3
  55. package/package.json +19 -7
  56. package/src/index.ts +7 -1
  57. package/src/nrrd/parse-nrrd.ts +267 -0
  58. package/src/nrrd-loader-types.ts +25 -0
  59. package/src/nrrd-loader.ts +7 -0
  60. package/src/vtk/vtk.ts +28 -1
  61. package/src/vtk-loader-types.ts +25 -0
  62. package/src/vtk-loader.ts +19 -0
@@ -108,7 +108,7 @@
108
108
  "src/npy-loader-types.ts"() {
109
109
  "use strict";
110
110
  init_npy_format();
111
- VERSION = true ? "5.0.0-beta.4" : "latest";
111
+ VERSION = true ? "5.0.0-beta.5" : "latest";
112
112
  NPY_MAGIC_NUMBER = new Uint8Array([147, 78, 85, 77, 80, 89]);
113
113
  NPYLoader = {
114
114
  ...NPYFormat,
@@ -180,10 +180,10 @@
180
180
  // src/workers/npy-worker.ts
181
181
  init_npy_loader();
182
182
 
183
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/node/worker_threads-browser.js
183
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js
184
184
  var parentPort = globalThis.process?.getBuiltinModule?.("node:worker_threads")?.parentPort ?? null;
185
185
 
186
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-utils/get-transfer-list.js
186
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js
187
187
  function getTransferList(object, recursive = true, transfers) {
188
188
  const transfersSet = transfers || /* @__PURE__ */ new Set();
189
189
  const seen = /* @__PURE__ */ new Set();
@@ -234,7 +234,7 @@
234
234
  return false;
235
235
  }
236
236
 
237
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-farm/worker-body.js
237
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-body.js
238
238
  async function getParentPort() {
239
239
  return parentPort;
240
240
  }
@@ -321,7 +321,7 @@
321
321
  return messageData && typeof messageData.source === "string" && messageData.source.startsWith("loaders.gl") ? messageData : null;
322
322
  }
323
323
 
324
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/async-queue/async-queue.js
324
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js
325
325
  var AsyncQueue = class {
326
326
  constructor() {
327
327
  this._values = [];
@@ -388,7 +388,7 @@
388
388
  }
389
389
  };
390
390
 
391
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/shared-state.js
391
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js
392
392
  var SharedWorkerState = class {
393
393
  constructor(buffer) {
394
394
  if (typeof SharedArrayBuffer === "undefined" || !(buffer instanceof SharedArrayBuffer) || buffer.byteLength !== 16)
@@ -427,14 +427,14 @@
427
427
  }
428
428
  };
429
429
 
430
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/validate-output-ownership.js
430
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js
431
431
  function validateOutputOwnership(ownership) {
432
432
  if (ownership !== void 0 && ownership !== "copy" && ownership !== "transfer") {
433
433
  throw new Error("Invalid worker output ownership");
434
434
  }
435
435
  }
436
436
 
437
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/create-worker.js
437
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/create-worker.js
438
438
  var requestId = 0;
439
439
  var activeController = null;
440
440
  var activeInputBatches = null;
@@ -642,12 +642,12 @@
642
642
  };
643
643
  }
644
644
 
645
- // ../../node_modules/@math.gl/core/dist/worker-utils/index.js
645
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/index.js
646
646
  var import_meta = {};
647
647
  var path = typeof __filename === "string" ? __filename.replace(/\\/g, "/") : "";
648
648
  var moduleUrl = path ? `file://${path.startsWith("/") ? "" : "/"}${encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F")}` : import_meta.url;
649
649
 
650
- // ../../node_modules/@math.gl/core/dist/tasks/task-preload.js
650
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js
651
651
  var pending = /* @__PURE__ */ new WeakMap();
652
652
  var loaded = /* @__PURE__ */ new WeakSet();
653
653
  function preloadTaskCode(task, signal) {
@@ -684,17 +684,182 @@
684
684
  });
685
685
  }
686
686
 
687
- // ../../node_modules/@math.gl/core/dist/tasks/task-runtime.js
687
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js
688
+ var TaskRequestError = class extends Error {
689
+ };
690
+ var TaskChannel = class {
691
+ constructor(options) {
692
+ this.options = options;
693
+ this.nextId = 1;
694
+ this.pending = /* @__PURE__ */ new Map();
695
+ this.incoming = /* @__PURE__ */ new Map();
696
+ }
697
+ /** Send a request without serializing other in-flight requests. */
698
+ request(operation, value, signal, transfer = []) {
699
+ if (this.failure)
700
+ return Promise.reject(this.failure.reason);
701
+ if (signal?.aborted)
702
+ return Promise.reject(signal.reason);
703
+ const id = this.nextId++;
704
+ return new Promise((resolve, reject) => {
705
+ const abort = () => {
706
+ const pending2 = this.pending.get(id);
707
+ if (!pending2)
708
+ return;
709
+ this.pending.delete(id);
710
+ pending2.cleanup();
711
+ reject(signal?.reason);
712
+ this.send({ source: "math.gl/tasks", kind: "cancel", id });
713
+ };
714
+ this.pending.set(id, {
715
+ resolve,
716
+ reject,
717
+ cleanup: () => signal?.removeEventListener("abort", abort)
718
+ });
719
+ signal?.addEventListener("abort", abort, { once: true });
720
+ this.send({ source: "math.gl/tasks", kind: "request", id, operation, value }, transfer);
721
+ });
722
+ }
723
+ /** Send a one-way notification. */
724
+ emit(operation, value, transfer = []) {
725
+ if (this.failure)
726
+ throw this.failure.reason;
727
+ this.send({ source: "math.gl/tasks", kind: "event", id: 0, operation, value }, transfer);
728
+ }
729
+ /** Dispatch a transport message; unrelated protocols are ignored. */
730
+ receive(message) {
731
+ if (this.failure || message?.source !== "math.gl/tasks")
732
+ return;
733
+ if (message.kind === "failure") {
734
+ const reason = new Error(message.error?.message ?? "Task channel failed");
735
+ this.close(reason);
736
+ this.options.onFailure?.(reason);
737
+ } else if (message.kind === "result" || message.kind === "error") {
738
+ const pending2 = this.pending.get(message.id);
739
+ if (!pending2)
740
+ return;
741
+ this.pending.delete(message.id);
742
+ pending2.cleanup();
743
+ if (message.kind === "result")
744
+ pending2.resolve(message.value);
745
+ else {
746
+ const error = new TaskRequestError(message.error?.message ?? "Task request failed");
747
+ error.name = message.error?.name ?? "Error";
748
+ pending2.reject(error);
749
+ }
750
+ } else if (message.kind === "cancel") {
751
+ this.incoming.get(message.id)?.abort(new DOMException("Task request cancelled", "AbortError"));
752
+ } else if (message.kind === "event") {
753
+ try {
754
+ this.options.handleEvent?.(message.operation, message.value);
755
+ } catch (error) {
756
+ this.fail(error);
757
+ }
758
+ } else if (message.kind === "request") {
759
+ if (this.incoming.has(message.id)) {
760
+ this.fail(new Error("Duplicate task request identifier"));
761
+ return;
762
+ }
763
+ const controller = new AbortController();
764
+ this.incoming.set(message.id, controller);
765
+ void Promise.resolve().then(() => {
766
+ controller.signal.throwIfAborted();
767
+ return this.options.handleRequest(message.operation, message.value, controller.signal);
768
+ }).then((value) => {
769
+ if (!controller.signal.aborted && !this.failure) {
770
+ this.send({ source: "math.gl/tasks", kind: "result", id: message.id, value }, this.options.getResultTransferList?.(value, message.value));
771
+ }
772
+ }).catch((reason) => {
773
+ if (!controller.signal.aborted && !this.failure) {
774
+ this.send({
775
+ source: "math.gl/tasks",
776
+ kind: "error",
777
+ id: message.id,
778
+ error: {
779
+ name: reason instanceof Error ? reason.name : "Error",
780
+ message: reason instanceof Error ? reason.message : String(reason)
781
+ }
782
+ });
783
+ }
784
+ }).finally(() => this.incoming.delete(message.id));
785
+ }
786
+ }
787
+ /** Reject all outstanding calls with a common cause and abort incoming callbacks. */
788
+ close(reason = new Error("Task channel closed")) {
789
+ if (this.failure)
790
+ return;
791
+ this.failure = { reason };
792
+ for (const pending2 of this.pending.values()) {
793
+ pending2.cleanup();
794
+ pending2.reject(reason);
795
+ }
796
+ this.pending.clear();
797
+ for (const controller of this.incoming.values())
798
+ controller.abort(reason);
799
+ this.incoming.clear();
800
+ }
801
+ send(message, transfer = []) {
802
+ if (this.failure)
803
+ return;
804
+ try {
805
+ this.options.send(message, transfer);
806
+ } catch (error) {
807
+ this.fail(error);
808
+ }
809
+ }
810
+ /** Invalidate the channel and notify the peer when the transport still works. */
811
+ fail(reason) {
812
+ if (this.failure)
813
+ return;
814
+ this.close(reason);
815
+ try {
816
+ this.options.send({
817
+ source: "math.gl/tasks",
818
+ kind: "failure",
819
+ id: 0,
820
+ error: {
821
+ name: reason instanceof Error ? reason.name : "Error",
822
+ message: reason instanceof Error ? reason.message : String(reason)
823
+ }
824
+ }, []);
825
+ } catch {
826
+ }
827
+ this.options.onFailure?.(reason);
828
+ }
829
+ };
830
+
831
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js
688
832
  function assertPayload(value) {
689
833
  if (!value || typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype) {
690
834
  throw new TypeError("Task payloads must be plain objects with named fields");
691
835
  }
692
836
  }
837
+ function clonePayload(value, ownership = "copy") {
838
+ assertPayload(value);
839
+ if (!["copy", "transfer", "share"].includes(ownership))
840
+ throw new TypeError("Invalid input ownership");
841
+ const transfer = getTransferList(value);
842
+ if (ownership === "share" && transfer.length)
843
+ throw new TypeError("Share requires shared storage");
844
+ return structuredClone(value, {
845
+ transfer: ownership === "transfer" ? transfer : []
846
+ });
847
+ }
693
848
  function taskContext(state, context = {}) {
694
849
  const signal = context.signal ?? new AbortController().signal;
695
850
  return {
696
851
  state,
697
852
  signal,
853
+ requestHost: async (operation, payload, controls) => {
854
+ signal.throwIfAborted();
855
+ if (!context.requestHost)
856
+ throw new Error("No host request handler configured");
857
+ return context.requestHost(operation, payload, controls);
858
+ },
859
+ emitHost: (operation, payload) => {
860
+ signal.throwIfAborted();
861
+ context.emitHost?.(operation, payload);
862
+ },
698
863
  throwIfAborted: () => {
699
864
  signal.throwIfAborted();
700
865
  context.throwIfAborted?.();
@@ -759,6 +924,69 @@
759
924
  throw new Error("A task is already installed in this worker");
760
925
  installed = true;
761
926
  const runtime = new TaskRuntime(task);
927
+ let channelStream;
928
+ const channel = new TaskChannel({
929
+ getResultTransferList: (value, request) => request.outputOwnership === "transfer" ? getTransferList(value) : [],
930
+ send: (message, transfer) => {
931
+ const snapshot = structuredClone(message, { transfer });
932
+ void WorkerBody.postMessage("task-channel", snapshot).catch((reason) => channel.fail(reason));
933
+ },
934
+ handleRequest: async (operation, value, signal) => {
935
+ const request = value;
936
+ const context = {
937
+ signal,
938
+ reportProgress: (progress) => channel.emit("task:progress", { id: request.progressId, progress }),
939
+ requestHost: (operation2, payload, controls = {}) => {
940
+ const request2 = {
941
+ operation: operation2,
942
+ payload: clonePayload(payload, controls.inputOwnership),
943
+ outputOwnership: controls.outputOwnership ?? "copy"
944
+ };
945
+ return channel.request("task:host-request", request2, signal, getTransferList(request2));
946
+ },
947
+ emitHost: (operation2, payload) => channel.emit("task:host-event", { operation: operation2, payload, id: request.progressId })
948
+ };
949
+ switch (operation) {
950
+ case "initialize":
951
+ return runtime.initialize(request.input, context);
952
+ case "process":
953
+ return runtime.process(request.input, request.options, context);
954
+ case "stream-open": {
955
+ if (channelStream)
956
+ throw new Error("A task stream is already open");
957
+ async function* inputs() {
958
+ while (true) {
959
+ const result = await channel.request("task:next-input", { outputOwnership: "transfer" }, signal);
960
+ if (result.done)
961
+ return;
962
+ yield result.value;
963
+ }
964
+ }
965
+ channelStream = runtime.stream(inputs(), request.options, context)[Symbol.asyncIterator]();
966
+ return {};
967
+ }
968
+ case "stream-next":
969
+ if (!channelStream)
970
+ throw new Error("No active task stream");
971
+ return channelStream.next();
972
+ case "stream-close":
973
+ try {
974
+ await channelStream?.return?.();
975
+ } finally {
976
+ channelStream = void 0;
977
+ }
978
+ return {};
979
+ case "destroy":
980
+ return runtime.destroy();
981
+ default:
982
+ throw new Error("Unknown task channel operation");
983
+ }
984
+ }
985
+ });
986
+ await WorkerBody.addEventListener((type, payload) => {
987
+ if (type === "task-channel")
988
+ channel.receive(payload);
989
+ });
762
990
  let streamOptions = {};
763
991
  return createWorker(async (request, _options, context) => {
764
992
  switch (request.operation) {
@@ -0,0 +1,22 @@
1
+ /** Numeric storage supported by the initial NRRD decoder. */
2
+ export type NRRDArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
3
+ /** Multidimensional NRRD data, preserving file axis order and authored orientation. */
4
+ export type NRRDData = {
5
+ /** Decoded scalar samples. Axis zero varies fastest. */
6
+ data: NRRDArray;
7
+ /** Number of samples on each axis. */
8
+ shape: number[];
9
+ /** Original normalized header fields. */
10
+ fields: Record<string, string>;
11
+ /** Authored custom key/value metadata. */
12
+ metadata: Record<string, string>;
13
+ /** World-space coordinate of the first sample, if authored. */
14
+ origin?: number[];
15
+ /** World-space step vector per array axis; null represents a nonspatial axis. */
16
+ directions?: (number[] | null)[];
17
+ /** Axis kinds, when supplied. */
18
+ kinds?: string[];
19
+ };
20
+ /** Decodes attached raw, ASCII or gzip NRRD without interpreting spatial axes as colors. */
21
+ export declare function parseNRRD(input: ArrayBuffer): Promise<NRRDData>;
22
+ //# sourceMappingURL=parse-nrrd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-nrrd.d.ts","sourceRoot":"","sources":["../../src/nrrd/parse-nrrd.ts"],"names":[],"mappings":"AAEA,6DAA6D;AAC7D,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,UAAU,GACV,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,YAAY,GACZ,YAAY,CAAC;AACjB,uFAAuF;AACvF,MAAM,MAAM,QAAQ,GAAG;IACrB,wDAAwD;IACxD,IAAI,EAAE,SAAS,CAAC;IAChB,sCAAsC;IACtC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,iFAAiF;IACjF,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;IACjC,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAyFF,4FAA4F;AAC5F,wBAAsB,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CA0GrE"}
@@ -0,0 +1,228 @@
1
+ const TYPES = [
2
+ [
3
+ ['signed char', 'int8', 'int8_t'],
4
+ {
5
+ construct: count => new Int8Array(count),
6
+ bytes: 1,
7
+ read: (view, offset) => view.getInt8(offset),
8
+ integer: true
9
+ }
10
+ ],
11
+ [
12
+ ['uchar', 'unsigned char', 'uint8', 'uint8_t'],
13
+ {
14
+ construct: count => new Uint8Array(count),
15
+ bytes: 1,
16
+ read: (view, offset) => view.getUint8(offset),
17
+ integer: true
18
+ }
19
+ ],
20
+ [
21
+ ['short', 'short int', 'signed short', 'signed short int', 'int16', 'int16_t'],
22
+ {
23
+ construct: count => new Int16Array(count),
24
+ bytes: 2,
25
+ read: (view, offset, little) => view.getInt16(offset, little),
26
+ integer: true
27
+ }
28
+ ],
29
+ [
30
+ ['ushort', 'unsigned short', 'unsigned short int', 'uint16', 'uint16_t'],
31
+ {
32
+ construct: count => new Uint16Array(count),
33
+ bytes: 2,
34
+ read: (view, offset, little) => view.getUint16(offset, little),
35
+ integer: true
36
+ }
37
+ ],
38
+ [
39
+ ['int', 'signed int', 'int32', 'int32_t'],
40
+ {
41
+ construct: count => new Int32Array(count),
42
+ bytes: 4,
43
+ read: (view, offset, little) => view.getInt32(offset, little),
44
+ integer: true
45
+ }
46
+ ],
47
+ [
48
+ ['uint', 'unsigned int', 'uint32', 'uint32_t'],
49
+ {
50
+ construct: count => new Uint32Array(count),
51
+ bytes: 4,
52
+ read: (view, offset, little) => view.getUint32(offset, little),
53
+ integer: true
54
+ }
55
+ ],
56
+ [
57
+ ['float'],
58
+ {
59
+ construct: count => new Float32Array(count),
60
+ bytes: 4,
61
+ read: (view, offset, little) => view.getFloat32(offset, little),
62
+ integer: false
63
+ }
64
+ ],
65
+ [
66
+ ['double'],
67
+ {
68
+ construct: count => new Float64Array(count),
69
+ bytes: 8,
70
+ read: (view, offset, little) => view.getFloat64(offset, little),
71
+ integer: false
72
+ }
73
+ ]
74
+ ];
75
+ /** Decodes attached raw, ASCII or gzip NRRD without interpreting spatial axes as colors. */
76
+ export async function parseNRRD(input) {
77
+ const bytes = new Uint8Array(input);
78
+ let headerEnd = -1;
79
+ for (let index = 0; index < Math.min(bytes.length, 1024 * 1024); index++) {
80
+ if (bytes[index] === 10 && bytes[index + 1] === 10) {
81
+ headerEnd = index + 2;
82
+ break;
83
+ }
84
+ if (bytes[index] === 13 &&
85
+ bytes[index + 1] === 10 &&
86
+ bytes[index + 2] === 13 &&
87
+ bytes[index + 3] === 10) {
88
+ headerEnd = index + 4;
89
+ break;
90
+ }
91
+ }
92
+ if (headerEnd < 0)
93
+ throw new Error('NRRD: missing or oversized attached header');
94
+ const lines = new TextDecoder().decode(bytes.subarray(0, headerEnd)).split(/\r?\n/);
95
+ if (!/^NRRD000[1-5]$/.test(lines.shift() || ''))
96
+ throw new Error('NRRD: unsupported signature');
97
+ const fields = Object.create(null);
98
+ const metadata = Object.create(null);
99
+ for (const line of lines) {
100
+ if (!line || line.startsWith('#'))
101
+ continue;
102
+ const separator = line.indexOf(':');
103
+ if (separator <= 0)
104
+ throw new Error('NRRD: malformed header field');
105
+ const name = line.slice(0, separator);
106
+ if (line[separator + 1] === '=') {
107
+ metadata[name] = line.slice(separator + 2);
108
+ continue;
109
+ }
110
+ const key = name.toLowerCase();
111
+ if (key in fields)
112
+ throw new Error('NRRD: duplicate header field');
113
+ fields[key] = line.slice(separator + 1).trim();
114
+ }
115
+ if ('data file' in fields ||
116
+ 'datafile' in fields ||
117
+ Number(fields['byte skip'] || 0) !== 0 ||
118
+ Number(fields.byteskip || 0) !== 0 ||
119
+ Number(fields['line skip'] || 0) !== 0 ||
120
+ Number(fields.lineskip || 0) !== 0)
121
+ throw new Error('NRRD: detached data and skip directives are unsupported');
122
+ const dimension = Number(fields.dimension);
123
+ const shape = (fields.sizes || '').split(/\s+/).map(Number);
124
+ if (!Number.isInteger(dimension) ||
125
+ dimension < 1 ||
126
+ dimension > 16 ||
127
+ shape.length !== dimension ||
128
+ shape.some(size => !Number.isSafeInteger(size) || size < 1))
129
+ throw new Error('NRRD: invalid dimensions');
130
+ const scalar = TYPES.find(([names]) => names.includes((fields.type || '').toLowerCase()))?.[1];
131
+ if (!scalar)
132
+ throw new Error('NRRD: unsupported scalar type');
133
+ const count = shape.reduce((product, size) => product * size, 1);
134
+ const byteLength = count * scalar.bytes;
135
+ if (!Number.isSafeInteger(byteLength) || byteLength > 256 * 1024 * 1024)
136
+ throw new Error('NRRD: decoded size exceeds 256 MiB limit');
137
+ const encoding = (fields.encoding || '').toLowerCase();
138
+ const ascii = ['ascii', 'text', 'txt'].includes(encoding);
139
+ if (!ascii &&
140
+ scalar.bytes > 1 &&
141
+ !['little', 'big'].includes((fields.endian || '').toLowerCase()))
142
+ throw new Error('NRRD: binary multibyte data requires endian');
143
+ let payload = bytes.slice(headerEnd);
144
+ if (encoding === 'gzip' || encoding === 'gz')
145
+ payload = await decompressGzip(payload, byteLength);
146
+ else if (!ascii && encoding !== 'raw')
147
+ throw new Error('NRRD: unsupported encoding');
148
+ const data = scalar.construct(count);
149
+ if (ascii) {
150
+ const tokens = new TextDecoder().decode(payload).trim().split(/\s+/);
151
+ if (tokens.length !== count)
152
+ throw new Error('NRRD: ASCII sample count mismatch');
153
+ for (let index = 0; index < count; index++) {
154
+ if (!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(tokens[index]))
155
+ throw new Error('NRRD: invalid ASCII sample');
156
+ const value = Number(tokens[index]);
157
+ data[index] = value;
158
+ if (!Number.isFinite(data[index]) || (scalar.integer && data[index] !== value))
159
+ throw new Error('NRRD: scalar value out of range');
160
+ }
161
+ }
162
+ else {
163
+ if (payload.byteLength !== byteLength)
164
+ throw new Error('NRRD: payload size mismatch');
165
+ const view = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
166
+ for (let index = 0; index < count; index++)
167
+ data[index] = scalar.read(view, index * scalar.bytes, fields.endian?.toLowerCase() !== 'big');
168
+ }
169
+ const origin = fields['space origin'] ? parseVector(fields['space origin']) : undefined;
170
+ const directions = fields['space directions']
171
+ ?.match(/none|\([^()]*\)/gi)
172
+ ?.map(value => (value.toLowerCase() === 'none' ? null : parseVector(value)));
173
+ if (fields['space directions']) {
174
+ const residue = fields['space directions'].replace(/none|\([^()]*\)/gi, '').trim();
175
+ if (!directions || directions.length !== dimension || residue)
176
+ throw new Error('NRRD: invalid space directions');
177
+ }
178
+ const spatialDimension = origin?.length || Number(fields['space dimension']) || directions?.find(value => value)?.length;
179
+ if (directions?.some(value => value && value.length !== spatialDimension))
180
+ throw new Error('NRRD: inconsistent spatial dimension');
181
+ const kinds = fields.kinds?.split(/\s+/);
182
+ if (kinds && kinds.length !== dimension)
183
+ throw new Error('NRRD: invalid kinds count');
184
+ return { data, shape, fields, metadata, origin, directions, kinds };
185
+ }
186
+ /** Parses one finite world-space vector. */
187
+ function parseVector(text) {
188
+ if (!/^\([^()]+\)$/.test(text.trim()))
189
+ throw new Error('NRRD: invalid spatial vector');
190
+ const values = text
191
+ .trim()
192
+ .slice(1, -1)
193
+ .split(',')
194
+ .map(value => {
195
+ if (!value.trim())
196
+ throw new Error('NRRD: empty spatial vector component');
197
+ return Number(value.trim());
198
+ });
199
+ if (!values.length || values.some(value => !Number.isFinite(value)))
200
+ throw new Error('NRRD: invalid spatial vector');
201
+ return values;
202
+ }
203
+ /** Decompresses gzip incrementally, enforcing the declared decoded length. */
204
+ async function decompressGzip(payload, expectedLength) {
205
+ const stream = new Blob([payload]).stream().pipeThrough(new DecompressionStream('gzip'));
206
+ const reader = stream.getReader();
207
+ const result = new Uint8Array(expectedLength);
208
+ let offset = 0;
209
+ try {
210
+ while (true) {
211
+ const { done, value } = await reader.read();
212
+ if (done)
213
+ break;
214
+ if (offset + value.length > expectedLength)
215
+ throw new Error('NRRD: gzip exceeds declared size');
216
+ result.set(value, offset);
217
+ offset += value.length;
218
+ }
219
+ }
220
+ finally {
221
+ await reader.cancel();
222
+ reader.releaseLock();
223
+ }
224
+ if (offset !== expectedLength)
225
+ throw new Error('NRRD: gzip sample count mismatch');
226
+ return result;
227
+ }
228
+ //# sourceMappingURL=parse-nrrd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-nrrd.js","sourceRoot":"","sources":["../../src/nrrd/parse-nrrd.ts"],"names":[],"mappings":"AA0CA,MAAM,KAAK,GAA6B;IACtC;QACE,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,CAAC;QACjC;YACE,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,IAA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AAc;QAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACnF,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // dist/nrrd-loader-types.js
31
+ var nrrd_loader_types_exports = {};
32
+ __export(nrrd_loader_types_exports, {
33
+ NRRDLoader: () => NRRDLoader
34
+ });
35
+ module.exports = __toCommonJS(nrrd_loader_types_exports);
36
+ var VERSION = true ? "5.0.0-beta.5" : "latest";
37
+ async function preload() {
38
+ const { NRRDLoaderWithParser } = await import("@loaders.gl/scientific/nrrd-loader");
39
+ return NRRDLoaderWithParser;
40
+ }
41
+ var NRRDLoader = {
42
+ name: "NRRD",
43
+ id: "nrrd",
44
+ module: "scientific",
45
+ version: VERSION,
46
+ extensions: ["nrrd"],
47
+ mimeTypes: ["application/x-nrrd"],
48
+ binary: true,
49
+ dataType: null,
50
+ batchType: null,
51
+ options: {},
52
+ preload
53
+ };
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ NRRDLoader
57
+ });
58
+ //# sourceMappingURL=nrrd-loader-types.cjs.map