@genome-spy/app 0.78.0 → 0.79.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/dist/agentApi.es.js +4918 -2499
  2. package/dist/agentShared.es.js +20 -22
  3. package/dist/{blosc-DL1kZHdE.js → blosc-JROzDOnd.js} +1 -1
  4. package/dist/{chunk-INHXZS53-DwEV9sMh.js → chunk-INHXZS53-CsrPGdTf.js} +1 -1
  5. package/dist/{componentStyles-CIXoKEp0.js → componentStyles-BGy033io.js} +2 -2
  6. package/dist/dialog.es.js +3 -3
  7. package/dist/{esm-D2-C5ZzN.js → esm-80V4xF_D.js} +226 -212
  8. package/dist/esm-B8j57WO7.js +441 -0
  9. package/dist/{esm-BkagIzhP.js → esm-BEHZgiVL.js} +30 -30
  10. package/dist/esm-BNd2PfFt.js +1367 -0
  11. package/dist/esm-BdLYkz-m.js +248 -0
  12. package/dist/{esm-id9DWBZW.js → esm-BdT7qUL-.js} +51 -31
  13. package/dist/esm-Bn4VTHqw.js +128 -0
  14. package/dist/{esm-C_XrKaCY.js → esm-C3k-CPce.js} +51 -31
  15. package/dist/{esm-CHVYSGF2.js → esm-CPzTvCZH.js} +226 -212
  16. package/dist/{esm-CPufCnsG.js → esm-CWd6i_cL.js} +30 -30
  17. package/dist/{esm-BgpwI2cq.js → esm-Cx-EbkOj.js} +13 -13
  18. package/dist/esm-D-iG_TIX.js +441 -0
  19. package/dist/esm-WxH0jQt4.js +128 -0
  20. package/dist/esm-cvhwoclu.js +1367 -0
  21. package/dist/{esm-BL9SNSnj.js → esm-k9p3oHkt.js} +133 -158
  22. package/dist/index.es.js +41477 -11008
  23. package/dist/index.js +579 -662
  24. package/dist/{lit-ymUSmGBw.js → lit-ByuJ0FJ4.js} +1 -1
  25. package/dist/{lz4-Csz5aoFA.js → lz4-CUYSbVey.js} +1 -1
  26. package/dist/{parquetRead-C33mgLEo.js → parquetRead-CBUyqZwZ.js} +473 -399
  27. package/dist/{chunk-CPXzm0be.js → rolldown-runtime-DF993M8W.js} +1 -1
  28. package/dist/schema.json +20018 -6213
  29. package/dist/{viewUtils-B7-F_Ae-.js → viewUtils-BBRWguwj.js} +4947 -4127
  30. package/dist/{zstd-dJuUp1fl.js → zstd-YMzMcush.js} +1 -1
  31. package/package.json +6 -4
  32. package/src/appTypes.d.ts +0 -1
  33. package/src/sampleView/state/payloadTypes.d.ts +9 -2
  34. package/src/spec/sampleView.d.ts +53 -0
  35. package/dist/AbortablePromiseCache-beUIcZcW.js +0 -96
  36. package/dist/agentApi-BwbEWjvl.js +0 -27118
  37. package/dist/blosc-BX4BJ8sR.js +0 -692
  38. package/dist/chunk-INHXZS53-Dx2aFznx.js +0 -13
  39. package/dist/esm-BHjeb8gt.js +0 -1426
  40. package/dist/esm-BI-plmf6.js +0 -121
  41. package/dist/esm-BwW--bVV.js +0 -369
  42. package/dist/esm-COzpU5N8.js +0 -1221
  43. package/dist/esm-CZvS2Ldm.js +0 -155
  44. package/dist/esm-D-y0Ce1M.js +0 -573
  45. package/dist/esm-D2_c7lXY.js +0 -298
  46. package/dist/esm-Daho46bY.js +0 -121
  47. package/dist/esm-DjF6pKy5.js +0 -369
  48. package/dist/esm-sPWfZg9X.js +0 -1426
  49. package/dist/esm-s_SlArJ8.js +0 -298
  50. package/dist/lz4-BSYl80V8.js +0 -626
  51. package/dist/parquetRead-m8-8_SpH.js +0 -1609
  52. package/dist/zstd-BAfRM3IH.js +0 -583
  53. /package/dist/{AbortablePromiseCache-BDH1cqFl.js → AbortablePromiseCache-BTmAcN-t.js} +0 -0
  54. /package/dist/{esm-Bz_92nH0.js → esm-VvpZ9hsq.js} +0 -0
@@ -0,0 +1,248 @@
1
+ //#region ../../node_modules/gff-nostream/esm/util.js
2
+ var e = {};
3
+ for (let t = 0; t < 256; t++) {
4
+ let n = t.toString(16).toUpperCase().padStart(2, "0");
5
+ e[n] = String.fromCharCode(t), e[n.toLowerCase()] = String.fromCharCode(t);
6
+ }
7
+ function t(t) {
8
+ let n = t.indexOf("%");
9
+ if (n === -1) return t;
10
+ let r = "", i = 0, a = n;
11
+ for (; a < t.length;) if (t[a] === "%" && a + 2 < t.length) {
12
+ r += t.slice(i, a);
13
+ let n = e[t.slice(a + 1, a + 3)];
14
+ n === void 0 ? r += t.slice(a, a + 3) : r += n, a += 3, i = a;
15
+ } else a++;
16
+ return r + t.slice(i);
17
+ }
18
+ function n(e, n) {
19
+ if (e.length === 0 || e === ".") return {};
20
+ let r = {}, i = e.length;
21
+ e[i - 1] === "\n" && (i = e[i - 2] === "\r" ? i - 2 : i - 1, e = e.slice(0, i));
22
+ let a = 0;
23
+ for (; a < i;) {
24
+ let o = e.indexOf(";", a);
25
+ if (o === -1 && (o = i), o > a) {
26
+ let i = e.indexOf("=", a);
27
+ if (i !== -1 && i < o && i + 1 < o) {
28
+ let s = e.slice(a, i), c = r[s];
29
+ c || (c = [], r[s] = c);
30
+ let l = i + 1;
31
+ for (; l < o;) {
32
+ let r = e.indexOf(",", l);
33
+ if ((r === -1 || r > o) && (r = o), r > l) {
34
+ let i = e.slice(l, r);
35
+ c.push(n ? t(i) : i);
36
+ }
37
+ l = r + 1;
38
+ }
39
+ }
40
+ }
41
+ a = o + 1;
42
+ }
43
+ return r;
44
+ }
45
+ function r(e) {
46
+ return e.length === 0 || e === ".";
47
+ }
48
+ function i(e, n, i) {
49
+ return r(e) ? i : n ? t(e) : e;
50
+ }
51
+ function a(e) {
52
+ return r(e) ? null : +e;
53
+ }
54
+ function o(e, t) {
55
+ let o = e.split(" "), s = o[8];
56
+ return {
57
+ seq_id: i(o[0], t, null),
58
+ source: i(o[1], t, null),
59
+ type: i(o[2], t, null),
60
+ start: a(o[3]),
61
+ end: a(o[4]),
62
+ score: a(o[5]),
63
+ strand: i(o[6], !1, null),
64
+ phase: i(o[7], !1, null),
65
+ attributes: r(s) ? null : n(s, t)
66
+ };
67
+ }
68
+ function s(e) {
69
+ return o(e, !0);
70
+ }
71
+ function c(e) {
72
+ return o(e, !1);
73
+ }
74
+ var l = /* @__PURE__ */ new Set([
75
+ "start",
76
+ "end",
77
+ "seq_id",
78
+ "score",
79
+ "type",
80
+ "source",
81
+ "phase",
82
+ "strand"
83
+ ]), u = {
84
+ ID: "id",
85
+ Name: "name",
86
+ Parent: "parent",
87
+ Note: "note",
88
+ Dbxref: "dbxref",
89
+ Ontology_term: "ontology_term",
90
+ Is_circular: "is_circular",
91
+ Alias: "alias",
92
+ Target: "target",
93
+ Gap: "gap",
94
+ Derives_from: "derives_from",
95
+ id: "id",
96
+ name: "name",
97
+ parent: "parent",
98
+ note: "note",
99
+ dbxref: "dbxref",
100
+ alias: "alias",
101
+ target: "target",
102
+ gap: "gap"
103
+ };
104
+ function d(e, n, r) {
105
+ if (e.length === 0 || e === ".") return;
106
+ let i = e.length;
107
+ e[i - 1] === "\n" && (i = e[i - 2] === "\r" ? i - 2 : i - 1, e = e.slice(0, i));
108
+ let a = 0;
109
+ for (; a < i;) {
110
+ let o = e.indexOf(";", a);
111
+ if (o === -1 && (o = i), o > a) {
112
+ let i = e.indexOf("=", a);
113
+ if (i !== -1 && i < o && i + 1 < o) {
114
+ let s = e.slice(a, i), c = u[s];
115
+ c === void 0 && (c = s.toLowerCase(), l.has(c) && (c += "2"));
116
+ let d = [], f = i + 1;
117
+ for (; f < o;) {
118
+ let n = e.indexOf(",", f);
119
+ if ((n === -1 || n > o) && (n = o), n > f) {
120
+ let i = e.slice(f, n);
121
+ d.push(r ? t(i) : i);
122
+ }
123
+ f = n + 1;
124
+ }
125
+ n[c] = d.length === 1 ? d[0] : d;
126
+ }
127
+ }
128
+ a = o + 1;
129
+ }
130
+ }
131
+ var f = {
132
+ "+": 1,
133
+ "-": -1,
134
+ ".": 0
135
+ };
136
+ function p(e, t) {
137
+ let n = e.split(" "), a = n[3], o = n[4], s = n[5], c = n[7], l = n[8], u = {
138
+ refName: i(n[0], t, ""),
139
+ source: i(n[1], t, null),
140
+ type: i(n[2], t, null),
141
+ start: r(a) ? 0 : a - 1,
142
+ end: r(o) ? 0 : +o,
143
+ score: r(s) ? void 0 : +s,
144
+ strand: f[n[6]],
145
+ phase: r(c) ? void 0 : +c,
146
+ subfeatures: []
147
+ };
148
+ return d(l, u, t), u;
149
+ }
150
+ function m(e) {
151
+ return p(e, !0);
152
+ }
153
+ function h(e) {
154
+ return p(e, !1);
155
+ }
156
+ //#endregion
157
+ //#region ../../node_modules/gff-nostream/esm/api.js
158
+ function g(e) {
159
+ let t = e.indexOf(" "), n = e.indexOf(" ", t + 1), r = e.indexOf(" ", n + 1);
160
+ return e.slice(n + 1, r);
161
+ }
162
+ function _(e, t, n) {
163
+ let r = e.get(t);
164
+ r ? r.push(n) : e.set(t, [n]);
165
+ }
166
+ function v(e) {
167
+ let t = Array.isArray(e) ? e[0] : e;
168
+ return typeof t == "string" ? t : void 0;
169
+ }
170
+ function y(e) {
171
+ return Array.isArray(e) ? e.filter((e) => typeof e == "string") : typeof e == "string" ? [e] : [];
172
+ }
173
+ function b(e) {
174
+ return C(S(e));
175
+ }
176
+ function x(e) {
177
+ return w(S(e));
178
+ }
179
+ function S(e) {
180
+ let t = e.split(/\r?\n/), n = [];
181
+ for (let e of t) {
182
+ if (e.startsWith("##FASTA") || e.startsWith(">")) break;
183
+ e.length === 0 || e.startsWith("#") || n.push({
184
+ line: e,
185
+ hasEscapes: e.includes("%")
186
+ });
187
+ }
188
+ return n;
189
+ }
190
+ function C(e) {
191
+ let t = [], n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
192
+ for (let i of e) {
193
+ let e = {
194
+ ...i.hasEscapes ? s(i.line) : c(i.line),
195
+ child_features: [],
196
+ derived_features: []
197
+ };
198
+ i.lineHash !== void 0 && (e.attributes ??= {}, e.attributes._lineHash = [String(i.lineHash)]);
199
+ let a = e.attributes, o = a?.ID, l = a?.Parent;
200
+ if (!o && !l) t.push([e]);
201
+ else {
202
+ let i;
203
+ if (o) {
204
+ let a = o[0], s = n.get(a);
205
+ if (s) e.child_features = s[0].child_features, e.derived_features = s[0].derived_features, s.push(e), i = s;
206
+ else {
207
+ i = [e], l || t.push(i), n.set(a, i);
208
+ let o = r.get(a);
209
+ if (o) {
210
+ for (let t of o) e.child_features.push(t);
211
+ r.delete(a);
212
+ }
213
+ }
214
+ } else i = [e];
215
+ if (l) for (let e of l) {
216
+ let t = n.get(e);
217
+ t ? t[0].child_features.push(i) : _(r, e, i);
218
+ }
219
+ }
220
+ }
221
+ return t;
222
+ }
223
+ function w(e) {
224
+ let t = [], n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
225
+ for (let i of e) {
226
+ let e = i.hasEscapes ? m(i.line) : h(i.line);
227
+ i.lineHash !== void 0 && (e._lineHash = String(i.lineHash));
228
+ let a = v(e.id), o = y(e.parent);
229
+ if (!a && o.length === 0) t.push(e);
230
+ else {
231
+ if (o.length === 0 && t.push(e), a && !n.has(a)) {
232
+ n.set(a, e);
233
+ let t = r.get(a);
234
+ if (t) {
235
+ for (let n of t) e.subfeatures.push(n);
236
+ r.delete(a);
237
+ }
238
+ }
239
+ for (let t of o) {
240
+ let i = n.get(t);
241
+ i ? i.subfeatures.push(e) : _(r, t, e);
242
+ }
243
+ }
244
+ }
245
+ return t;
246
+ }
247
+ //#endregion
248
+ export { g as extractType, C as parseRecords, w as parseRecordsJBrowse, b as parseStringSync, x as parseStringSyncJBrowse };
@@ -1,17 +1,37 @@
1
- import { n as e, t } from "./chunk-CPXzm0be.js";
1
+ import { n as e, t } from "./rolldown-runtime-DF993M8W.js";
2
2
  //#region ../../node_modules/generic-filehandle2/esm/util.js
3
3
  async function n(e) {
4
4
  return e.bytes ? e.bytes() : new Uint8Array(await e.arrayBuffer());
5
5
  }
6
+ var r = 50;
7
+ async function i(e, t) {
8
+ let i = e.headers.get("content-length"), a = i ? parseInt(i, 10) : void 0, o = e.body;
9
+ if (!o || a === void 0) {
10
+ let r = await n(e);
11
+ return t(r.byteLength, a ?? r.byteLength), r;
12
+ }
13
+ let s = o.getReader(), c = new Uint8Array(a), l = 0, u = 0;
14
+ t(0, a);
15
+ for (let e = await s.read(); !e.done; e = await s.read()) {
16
+ if (l + e.value.byteLength > c.length) {
17
+ let t = new Uint8Array(Math.max(l + e.value.byteLength, c.length * 2));
18
+ t.set(c.subarray(0, l)), c = t;
19
+ }
20
+ c.set(e.value, l), l += e.value.byteLength;
21
+ let n = Date.now();
22
+ n - u >= r && (u = n, t(l, a));
23
+ }
24
+ return t(l, a), l === c.length ? c : c.subarray(0, l);
25
+ }
6
26
  //#endregion
7
27
  //#region ../../node_modules/generic-filehandle2/esm/blobFile.js
8
- var r = class {
28
+ var a = class {
9
29
  blob;
10
30
  constructor(e) {
11
31
  this.blob = e;
12
32
  }
13
33
  async read(e, t = 0) {
14
- return e === 0 ? new Uint8Array() : n(this.blob.slice(t, t + e));
34
+ return e === 0 ? /* @__PURE__ */ new Uint8Array() : n(this.blob.slice(t, t + e));
15
35
  }
16
36
  async readFile(e) {
17
37
  let t = typeof e == "string" ? e : e?.encoding;
@@ -28,10 +48,10 @@ var r = class {
28
48
  };
29
49
  //#endregion
30
50
  //#region ../../node_modules/generic-filehandle2/esm/remoteFile.js
31
- function i(e) {
51
+ function o(e) {
32
52
  return (typeof e == "object" && e && "message" in e && typeof e.message == "string" ? e.message : `${e}`).replace(/\.$/, "");
33
53
  }
34
- var a = class {
54
+ var s = class {
35
55
  url;
36
56
  _stat;
37
57
  fetchImplementation;
@@ -56,7 +76,7 @@ var a = class {
56
76
  };
57
77
  }
58
78
  async fetch(e, t) {
59
- let n = (t) => Error(`${i(t)} fetching ${e}`, { cause: t }), r;
79
+ let n = (t) => Error(`${o(t)} fetching ${e}`, { cause: t }), r;
60
80
  try {
61
81
  r = await this.fetchImplementation(e, t);
62
82
  } catch (i) {
@@ -75,25 +95,25 @@ var a = class {
75
95
  return r;
76
96
  }
77
97
  async read(e, t, r = {}) {
78
- if (e === 0) return new Uint8Array();
98
+ if (e === 0) return /* @__PURE__ */ new Uint8Array();
79
99
  if (Number.isNaN(e) || Number.isNaN(t)) throw TypeError(`read() called with NaN length or position (length=${e}, position=${t}). The index file may be corrupt.`);
80
- let i = await this.fetch(this.url, this.buildRequest(r, { range: `bytes=${t}-${t + e - 1}` }));
81
- if (i.status === 416) return new Uint8Array();
82
- if (!i.ok) throw Error(`HTTP ${i.status} fetching ${this.url}`);
83
- if (i.status === 200 && t === 0 || i.status === 206) {
84
- let t = i.headers.get("content-range"), r = /\/(\d+)$/.exec(t ?? "");
85
- r?.[1] && (this._stat = { size: parseInt(r[1], 10) });
86
- let a = await n(i);
87
- return !this._stat && i.status === 200 && (this._stat = { size: a.byteLength }), a.byteLength <= e ? a : a.subarray(0, e);
100
+ let a = await this.fetch(this.url, this.buildRequest(r, { range: `bytes=${t}-${t + e - 1}` }));
101
+ if (a.status === 416) return /* @__PURE__ */ new Uint8Array();
102
+ if (!a.ok) throw Error(`HTTP ${a.status} fetching ${this.url}`);
103
+ if (a.status === 200 && t === 0 || a.status === 206) {
104
+ let t = a.headers.get("content-range"), o = /\/(\d+)$/.exec(t ?? "");
105
+ o?.[1] && (this._stat = { size: parseInt(o[1], 10) });
106
+ let s = r.onProgress ? await i(a, r.onProgress) : await n(a);
107
+ return !this._stat && a.status === 200 && (this._stat = { size: s.byteLength }), s.byteLength <= e ? s : s.subarray(0, e);
88
108
  }
89
- throw Error(i.status === 200 ? `${this.url} fetch returned status 200, expected 206` : `HTTP ${i.status} fetching ${this.url}`);
109
+ throw Error(a.status === 200 ? `${this.url} fetch returned status 200, expected 206` : `HTTP ${a.status} fetching ${this.url}`);
90
110
  }
91
111
  async readFile(e = {}) {
92
- let t = typeof e == "string" ? e : e.encoding, r = typeof e == "string" ? {} : e, i = await this.fetch(this.url, this.buildRequest(r));
93
- if (!i.ok) throw Error(`HTTP ${i.status} fetching ${this.url}`);
94
- if (t === "utf8") return i.text();
112
+ let t = typeof e == "string" ? e : e.encoding, r = typeof e == "string" ? {} : e, a = await this.fetch(this.url, this.buildRequest(r));
113
+ if (!a.ok) throw Error(`HTTP ${a.status} fetching ${this.url}`);
114
+ if (t === "utf8") return a.text();
95
115
  if (t) throw Error(`unsupported encoding: ${t}`);
96
- return n(i);
116
+ return r.onProgress ? i(a, r.onProgress) : n(a);
97
117
  }
98
118
  async stat() {
99
119
  return this._stat || await this.read(10, 0), this._stat ?? { size: 0 };
@@ -101,18 +121,18 @@ var a = class {
101
121
  close() {
102
122
  return Promise.resolve();
103
123
  }
104
- }, o = (/* @__PURE__ */ t(((e, t) => {
124
+ }, c = (/* @__PURE__ */ t(((e, t) => {
105
125
  t.exports = {};
106
- })))(), s = class {
126
+ })))(), l = class {
107
127
  filename;
108
128
  constructor(e) {
109
129
  this.filename = e;
110
130
  }
111
131
  async read(e, t = 0) {
112
- if (e === 0) return new Uint8Array();
132
+ if (e === 0) return /* @__PURE__ */ new Uint8Array();
113
133
  let n = new Uint8Array(e), r;
114
134
  try {
115
- r = await (0, o.open)(this.filename, "r");
135
+ r = await (0, c.open)(this.filename, "r");
116
136
  let i = await r.read(n, 0, e, t);
117
137
  return i.buffer.subarray(0, i.bytesRead);
118
138
  } finally {
@@ -122,16 +142,16 @@ var a = class {
122
142
  }
123
143
  }
124
144
  async readFile(e) {
125
- return (0, o.readFile)(this.filename, e);
145
+ return (0, c.readFile)(this.filename, e);
126
146
  }
127
147
  async stat() {
128
- return (0, o.stat)(this.filename);
148
+ return (0, c.stat)(this.filename);
129
149
  }
130
150
  async close() {}
131
- }, c = /* @__PURE__ */ e({
132
- BlobFile: () => r,
133
- LocalFile: () => s,
134
- RemoteFile: () => a
151
+ }, u = /* @__PURE__ */ e({
152
+ BlobFile: () => a,
153
+ LocalFile: () => l,
154
+ RemoteFile: () => s
135
155
  });
136
156
  //#endregion
137
- export { s as n, a as r, c as t };
157
+ export { l as n, s as r, u as t };
@@ -0,0 +1,128 @@
1
+ import { t as e } from "./esm-Cx-EbkOj.js";
2
+ import { n as t } from "./esm-BdT7qUL-.js";
3
+ //#region ../core/node_modules/@gmod/indexedfasta/esm/fetchableSmallFasta.js
4
+ var n = new TextDecoder("utf8");
5
+ function r(e) {
6
+ return e.split(">").filter((e) => /\S/.test(e)).map((e) => {
7
+ let [t, ...n] = e.split("\n"), [r, ...i] = t.split(" "), a = n.join("").replace(/\s/g, "");
8
+ return {
9
+ id: r,
10
+ description: i.join(" "),
11
+ sequence: a
12
+ };
13
+ });
14
+ }
15
+ var i = class {
16
+ data;
17
+ indexed;
18
+ constructor({ fasta: e, path: i }) {
19
+ let a;
20
+ if (e) a = e;
21
+ else if (i) a = new t(i);
22
+ else throw Error("Need to pass fasta or path");
23
+ this.data = a.readFile().then((e) => r(n.decode(e)));
24
+ }
25
+ getIndexed() {
26
+ return this.indexed ??= this.data.then((e) => new Map(e.map((e) => [e.id, e]))), this.indexed;
27
+ }
28
+ async fetch(e, t, n) {
29
+ let r = (await this.getIndexed()).get(e);
30
+ if (!r) throw Error(`no sequence with id ${e} exists`);
31
+ return r.sequence.slice(t, n);
32
+ }
33
+ async getSequenceNames() {
34
+ return (await this.data).map((e) => e.id);
35
+ }
36
+ }, a = new TextDecoder("utf8");
37
+ function o(e, t, n, r) {
38
+ return e + t * Math.floor(r / n) + r % n;
39
+ }
40
+ async function s(e, t = {}) {
41
+ let n = a.decode(await e.readFile(t)), r = /* @__PURE__ */ new Map();
42
+ for (let e of n.split("\n")) {
43
+ let t = e.trim();
44
+ if (!t) continue;
45
+ let n = t.split(" ");
46
+ if (n.length < 5) throw Error(`Malformed FAI line (expected 5 tab-separated columns, got ${String(n.length)}): ${t}`);
47
+ let [i, a, o, s, c] = n;
48
+ if (i.startsWith(">")) throw Error("found > in sequence name, might have supplied FASTA file for the FASTA index");
49
+ let l = +a, u = +s;
50
+ if (l > 0 && u === 0) throw Error(`Invalid FAI index for "${i}": LINEBASES is 0, FASTA likely missing trailing newline; regenerate the .fai index`);
51
+ r.set(i, {
52
+ length: l,
53
+ offset: +o,
54
+ lineLength: u,
55
+ lineBytes: +c
56
+ });
57
+ }
58
+ return r;
59
+ }
60
+ async function c(e, t, n = 0, r, i) {
61
+ if (n < 0) throw TypeError("regionStart cannot be less than 0");
62
+ let s = Math.min(r ?? t.length, t.length);
63
+ if (n >= s) return "";
64
+ let c = o(t.offset, t.lineBytes, t.lineLength, n), l = o(t.offset, t.lineBytes, t.lineLength, s) - c, u = a.decode(await e.read(l, c, i)).replace(/\s+/g, "");
65
+ if (/[^\x20-\x7e]/.test(u.slice(0, 1e3))) throw Error("Non-ASCII bytes in sequence; file may be gzip — use BgzipIndexedFasta or decompress");
66
+ return u;
67
+ }
68
+ var l = class {
69
+ fasta;
70
+ fai;
71
+ indexes;
72
+ constructor({ fasta: e, fai: n, path: r, faiPath: i }) {
73
+ if (e) this.fasta = e;
74
+ else if (r) this.fasta = new t(r);
75
+ else throw Error("Need to pass filehandle for fasta or path to localfile");
76
+ if (n) this.fai = n;
77
+ else if (i) this.fai = new t(i);
78
+ else if (r) this.fai = new t(`${r}.fai`);
79
+ else throw Error("Need to pass filehandle for fai or path to localfile");
80
+ }
81
+ async getIndexes(e) {
82
+ return this.indexes ??= s(this.fai, e).catch((e) => {
83
+ throw this.indexes = void 0, e;
84
+ }), this.indexes;
85
+ }
86
+ async getSequenceNames(e) {
87
+ return [...(await this.getIndexes(e)).keys()];
88
+ }
89
+ async getSequenceSizes(e) {
90
+ let t = {};
91
+ for (let [n, r] of await this.getIndexes(e)) t[n] = r.length;
92
+ return t;
93
+ }
94
+ async getSequenceSize(e, t) {
95
+ return (await this.getIndexes(t)).get(e)?.length;
96
+ }
97
+ async hasReferenceSequence(e, t) {
98
+ return (await this.getIndexes(t)).has(e);
99
+ }
100
+ async getResiduesByName(e, t, n, r) {
101
+ let i = (await this.getIndexes(r)).get(e);
102
+ if (i !== void 0) return c(this.fasta, i, t, n, r);
103
+ }
104
+ async getSequence(e, t, n, r) {
105
+ return this.getResiduesByName(e, t, n, r);
106
+ }
107
+ }, u = class extends l {
108
+ constructor({ fasta: n, path: r, fai: i, faiPath: a, gzi: o, gziPath: s }) {
109
+ let c;
110
+ if (n && o) c = new e({
111
+ filehandle: n,
112
+ gziFilehandle: o
113
+ });
114
+ else if (r && s) c = new e({
115
+ filehandle: new t(r),
116
+ gziFilehandle: new t(s)
117
+ });
118
+ else throw Error("BgzipIndexedFasta requires either {fasta, gzi} or {path, gziPath}");
119
+ super({
120
+ fasta: c,
121
+ fai: i,
122
+ faiPath: a,
123
+ path: r
124
+ });
125
+ }
126
+ };
127
+ //#endregion
128
+ export { u as BgzipIndexedFasta, i as FetchableSmallFasta, l as IndexedFasta, r as parseSmallFasta };
@@ -1,17 +1,37 @@
1
- import { n as e, t } from "./chunk-CPXzm0be.js";
1
+ import { $n as e, Qn as t } from "./viewUtils-BBRWguwj.js";
2
2
  //#region ../../node_modules/generic-filehandle2/esm/util.js
3
3
  async function n(e) {
4
4
  return e.bytes ? e.bytes() : new Uint8Array(await e.arrayBuffer());
5
5
  }
6
+ var r = 50;
7
+ async function i(e, t) {
8
+ let i = e.headers.get("content-length"), a = i ? parseInt(i, 10) : void 0, o = e.body;
9
+ if (!o || a === void 0) {
10
+ let r = await n(e);
11
+ return t(r.byteLength, a ?? r.byteLength), r;
12
+ }
13
+ let s = o.getReader(), c = new Uint8Array(a), l = 0, u = 0;
14
+ t(0, a);
15
+ for (let e = await s.read(); !e.done; e = await s.read()) {
16
+ if (l + e.value.byteLength > c.length) {
17
+ let t = new Uint8Array(Math.max(l + e.value.byteLength, c.length * 2));
18
+ t.set(c.subarray(0, l)), c = t;
19
+ }
20
+ c.set(e.value, l), l += e.value.byteLength;
21
+ let n = Date.now();
22
+ n - u >= r && (u = n, t(l, a));
23
+ }
24
+ return t(l, a), l === c.length ? c : c.subarray(0, l);
25
+ }
6
26
  //#endregion
7
27
  //#region ../../node_modules/generic-filehandle2/esm/blobFile.js
8
- var r = class {
28
+ var a = class {
9
29
  blob;
10
30
  constructor(e) {
11
31
  this.blob = e;
12
32
  }
13
33
  async read(e, t = 0) {
14
- return e === 0 ? new Uint8Array() : n(this.blob.slice(t, t + e));
34
+ return e === 0 ? /* @__PURE__ */ new Uint8Array() : n(this.blob.slice(t, t + e));
15
35
  }
16
36
  async readFile(e) {
17
37
  let t = typeof e == "string" ? e : e?.encoding;
@@ -28,10 +48,10 @@ var r = class {
28
48
  };
29
49
  //#endregion
30
50
  //#region ../../node_modules/generic-filehandle2/esm/remoteFile.js
31
- function i(e) {
51
+ function o(e) {
32
52
  return (typeof e == "object" && e && "message" in e && typeof e.message == "string" ? e.message : `${e}`).replace(/\.$/, "");
33
53
  }
34
- var a = class {
54
+ var s = class {
35
55
  url;
36
56
  _stat;
37
57
  fetchImplementation;
@@ -56,7 +76,7 @@ var a = class {
56
76
  };
57
77
  }
58
78
  async fetch(e, t) {
59
- let n = (t) => Error(`${i(t)} fetching ${e}`, { cause: t }), r;
79
+ let n = (t) => Error(`${o(t)} fetching ${e}`, { cause: t }), r;
60
80
  try {
61
81
  r = await this.fetchImplementation(e, t);
62
82
  } catch (i) {
@@ -75,25 +95,25 @@ var a = class {
75
95
  return r;
76
96
  }
77
97
  async read(e, t, r = {}) {
78
- if (e === 0) return new Uint8Array();
98
+ if (e === 0) return /* @__PURE__ */ new Uint8Array();
79
99
  if (Number.isNaN(e) || Number.isNaN(t)) throw TypeError(`read() called with NaN length or position (length=${e}, position=${t}). The index file may be corrupt.`);
80
- let i = await this.fetch(this.url, this.buildRequest(r, { range: `bytes=${t}-${t + e - 1}` }));
81
- if (i.status === 416) return new Uint8Array();
82
- if (!i.ok) throw Error(`HTTP ${i.status} fetching ${this.url}`);
83
- if (i.status === 200 && t === 0 || i.status === 206) {
84
- let t = i.headers.get("content-range"), r = /\/(\d+)$/.exec(t ?? "");
85
- r?.[1] && (this._stat = { size: parseInt(r[1], 10) });
86
- let a = await n(i);
87
- return !this._stat && i.status === 200 && (this._stat = { size: a.byteLength }), a.byteLength <= e ? a : a.subarray(0, e);
100
+ let a = await this.fetch(this.url, this.buildRequest(r, { range: `bytes=${t}-${t + e - 1}` }));
101
+ if (a.status === 416) return /* @__PURE__ */ new Uint8Array();
102
+ if (!a.ok) throw Error(`HTTP ${a.status} fetching ${this.url}`);
103
+ if (a.status === 200 && t === 0 || a.status === 206) {
104
+ let t = a.headers.get("content-range"), o = /\/(\d+)$/.exec(t ?? "");
105
+ o?.[1] && (this._stat = { size: parseInt(o[1], 10) });
106
+ let s = r.onProgress ? await i(a, r.onProgress) : await n(a);
107
+ return !this._stat && a.status === 200 && (this._stat = { size: s.byteLength }), s.byteLength <= e ? s : s.subarray(0, e);
88
108
  }
89
- throw Error(i.status === 200 ? `${this.url} fetch returned status 200, expected 206` : `HTTP ${i.status} fetching ${this.url}`);
109
+ throw Error(a.status === 200 ? `${this.url} fetch returned status 200, expected 206` : `HTTP ${a.status} fetching ${this.url}`);
90
110
  }
91
111
  async readFile(e = {}) {
92
- let t = typeof e == "string" ? e : e.encoding, r = typeof e == "string" ? {} : e, i = await this.fetch(this.url, this.buildRequest(r));
93
- if (!i.ok) throw Error(`HTTP ${i.status} fetching ${this.url}`);
94
- if (t === "utf8") return i.text();
112
+ let t = typeof e == "string" ? e : e.encoding, r = typeof e == "string" ? {} : e, a = await this.fetch(this.url, this.buildRequest(r));
113
+ if (!a.ok) throw Error(`HTTP ${a.status} fetching ${this.url}`);
114
+ if (t === "utf8") return a.text();
95
115
  if (t) throw Error(`unsupported encoding: ${t}`);
96
- return n(i);
116
+ return r.onProgress ? i(a, r.onProgress) : n(a);
97
117
  }
98
118
  async stat() {
99
119
  return this._stat || await this.read(10, 0), this._stat ?? { size: 0 };
@@ -101,18 +121,18 @@ var a = class {
101
121
  close() {
102
122
  return Promise.resolve();
103
123
  }
104
- }, o = (/* @__PURE__ */ t(((e, t) => {
124
+ }, c = (/* @__PURE__ */ t(((e, t) => {
105
125
  t.exports = {};
106
- })))(), s = class {
126
+ })))(), l = class {
107
127
  filename;
108
128
  constructor(e) {
109
129
  this.filename = e;
110
130
  }
111
131
  async read(e, t = 0) {
112
- if (e === 0) return new Uint8Array();
132
+ if (e === 0) return /* @__PURE__ */ new Uint8Array();
113
133
  let n = new Uint8Array(e), r;
114
134
  try {
115
- r = await (0, o.open)(this.filename, "r");
135
+ r = await (0, c.open)(this.filename, "r");
116
136
  let i = await r.read(n, 0, e, t);
117
137
  return i.buffer.subarray(0, i.bytesRead);
118
138
  } finally {
@@ -122,16 +142,16 @@ var a = class {
122
142
  }
123
143
  }
124
144
  async readFile(e) {
125
- return (0, o.readFile)(this.filename, e);
145
+ return (0, c.readFile)(this.filename, e);
126
146
  }
127
147
  async stat() {
128
- return (0, o.stat)(this.filename);
148
+ return (0, c.stat)(this.filename);
129
149
  }
130
150
  async close() {}
131
- }, c = /* @__PURE__ */ e({
132
- BlobFile: () => r,
133
- LocalFile: () => s,
134
- RemoteFile: () => a
151
+ }, u = /* @__PURE__ */ e({
152
+ BlobFile: () => a,
153
+ LocalFile: () => l,
154
+ RemoteFile: () => s
135
155
  });
136
156
  //#endregion
137
- export { s as n, a as r, c as t };
157
+ export { l as n, s as r, u as t };