@genome-spy/app 0.63.0 → 0.65.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.
@@ -1,7 +1,6 @@
1
- import { g as u } from "./_commonjsHelpers-DjF3Plf2.js";
2
- class f {
1
+ class h {
3
2
  }
4
- class b {
3
+ class d {
5
4
  constructor() {
6
5
  this.signals = /* @__PURE__ */ new Set(), this.abortController = new AbortController();
7
6
  }
@@ -11,7 +10,7 @@ class b {
11
10
  * longer be abortable.
12
11
  */
13
12
  //@ts-ignore
14
- addSignal(t = new f()) {
13
+ addSignal(t = new h()) {
15
14
  if (this.signal.aborted)
16
15
  throw new Error("cannot add a signal, already aborted!");
17
16
  this.signals.add(t), t.aborted ? this.handleAborted(t) : typeof t.addEventListener == "function" && t.addEventListener("abort", () => {
@@ -28,13 +27,13 @@ class b {
28
27
  this.abortController.abort();
29
28
  }
30
29
  }
31
- class g {
30
+ class b {
32
31
  constructor() {
33
32
  this.callbacks = /* @__PURE__ */ new Set();
34
33
  }
35
34
  addCallback(t = () => {
36
35
  }) {
37
- this.callbacks.add(t), t(this.currentMessage);
36
+ this.callbacks.add(t), this.currentMessage && t(this.currentMessage);
38
37
  }
39
38
  callback(t) {
40
39
  this.currentMessage = t;
@@ -42,7 +41,7 @@ class g {
42
41
  e(t);
43
42
  }
44
43
  }
45
- class l {
44
+ class c {
46
45
  constructor({ fill: t, cache: e }) {
47
46
  if (typeof t != "function")
48
47
  throw new TypeError("must pass a fill function");
@@ -65,16 +64,16 @@ class l {
65
64
  evict(t, e) {
66
65
  this.cache.get(t) === e && this.cache.delete(t);
67
66
  }
68
- fill(t, e, r, i) {
69
- const s = new b(), c = new g();
70
- c.addCallback(i);
67
+ fill(t, e, r, s) {
68
+ const o = new d(), i = new b();
69
+ i.addCallback(s);
71
70
  const a = {
72
- aborter: s,
73
- promise: this.fillCallback(e, s.signal, (h) => {
74
- c.callback(h);
71
+ aborter: o,
72
+ promise: this.fillCallback(e, o.signal, (n) => {
73
+ i.callback(n);
75
74
  }),
76
75
  settled: !1,
77
- statusReporter: c,
76
+ statusReporter: i,
78
77
  get aborted() {
79
78
  return this.aborter.signal.aborted;
80
79
  }
@@ -85,8 +84,8 @@ class l {
85
84
  a.settled = !0;
86
85
  }, () => {
87
86
  a.settled = !0, this.evict(t, a);
88
- }).catch((h) => {
89
- throw console.error(h), h;
87
+ }).catch((n) => {
88
+ throw console.error(n), n;
90
89
  }), this.cache.set(t, a);
91
90
  }
92
91
  static checkSinglePromise(t, e) {
@@ -94,8 +93,8 @@ class l {
94
93
  if (e != null && e.aborted)
95
94
  throw Object.assign(new Error("aborted"), { code: "ERR_ABORTED" });
96
95
  }
97
- return t.then((i) => (r(), i), (i) => {
98
- throw r(), i;
96
+ return t.then((s) => (r(), s), (s) => {
97
+ throw r(), s;
99
98
  });
100
99
  }
101
100
  has(t) {
@@ -113,12 +112,12 @@ class l {
113
112
  * @param {AbortSignal} [signal] optional AbortSignal object that aborts the request
114
113
  * @param {statusCallback} a callback to get the current status of a pending async operation
115
114
  */
116
- get(t, e, r, i) {
115
+ get(t, e, r, s) {
117
116
  if (!r && e instanceof AbortSignal)
118
117
  throw new TypeError("second get argument appears to be an AbortSignal, perhaps you meant to pass `null` for the fill data?");
119
- const s = this.cache.get(t);
120
- return s ? s.aborted && !s.settled ? (this.evict(t, s), this.get(t, e, r, i)) : s.settled ? s.promise : (s.aborter.addSignal(r), s.statusReporter.addCallback(i), l.checkSinglePromise(s.promise, r)) : (this.fill(t, e, r, i), l.checkSinglePromise(
121
- //see https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#non-null-assertion-operator-postfix-
118
+ const o = this.cache.get(t);
119
+ return o ? o.aborted && !o.settled ? (this.evict(t, o), this.get(t, e, r, s)) : o.settled ? o.promise : (o.aborter.addSignal(r), o.statusReporter.addCallback(s), c.checkSinglePromise(o.promise, r)) : (this.fill(t, e, r, s), c.checkSinglePromise(
120
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
122
121
  this.cache.get(t).promise,
123
122
  r
124
123
  ));
@@ -145,74 +144,6 @@ class l {
145
144
  return e;
146
145
  }
147
146
  }
148
- var n, d;
149
- function p() {
150
- if (d) return n;
151
- d = 1;
152
- class o {
153
- constructor(e = {}) {
154
- if (!(e.maxSize && e.maxSize > 0))
155
- throw new TypeError("`maxSize` must be a number greater than 0");
156
- this.maxSize = e.maxSize, this.cache = /* @__PURE__ */ new Map(), this.oldCache = /* @__PURE__ */ new Map(), this._size = 0;
157
- }
158
- _set(e, r) {
159
- this.cache.set(e, r), this._size++, this._size >= this.maxSize && (this._size = 0, this.oldCache = this.cache, this.cache = /* @__PURE__ */ new Map());
160
- }
161
- get(e) {
162
- if (this.cache.has(e))
163
- return this.cache.get(e);
164
- if (this.oldCache.has(e)) {
165
- const r = this.oldCache.get(e);
166
- return this.oldCache.delete(e), this._set(e, r), r;
167
- }
168
- }
169
- set(e, r) {
170
- return this.cache.has(e) ? this.cache.set(e, r) : this._set(e, r), this;
171
- }
172
- has(e) {
173
- return this.cache.has(e) || this.oldCache.has(e);
174
- }
175
- peek(e) {
176
- if (this.cache.has(e))
177
- return this.cache.get(e);
178
- if (this.oldCache.has(e))
179
- return this.oldCache.get(e);
180
- }
181
- delete(e) {
182
- const r = this.cache.delete(e);
183
- return r && this._size--, this.oldCache.delete(e) || r;
184
- }
185
- clear() {
186
- this.cache.clear(), this.oldCache.clear(), this._size = 0;
187
- }
188
- *keys() {
189
- for (const [e] of this)
190
- yield e;
191
- }
192
- *values() {
193
- for (const [, e] of this)
194
- yield e;
195
- }
196
- *[Symbol.iterator]() {
197
- for (const e of this.cache)
198
- yield e;
199
- for (const e of this.oldCache) {
200
- const [r] = e;
201
- this.cache.has(r) || (yield e);
202
- }
203
- }
204
- get size() {
205
- let e = 0;
206
- for (const r of this.oldCache.keys())
207
- this.cache.has(r) || e++;
208
- return this._size + e;
209
- }
210
- }
211
- return n = o, n;
212
- }
213
- var m = p();
214
- const C = /* @__PURE__ */ u(m);
215
147
  export {
216
- l as A,
217
- C as L
148
+ c as A
218
149
  };
@@ -0,0 +1,123 @@
1
+ class d {
2
+ constructor(e) {
3
+ this.blob = e, this.size = e.size;
4
+ }
5
+ async read(e, r = 0) {
6
+ if (!e)
7
+ return new Uint8Array(0);
8
+ const t = r, a = t + e;
9
+ return new Uint8Array(await this.blob.slice(t, a).arrayBuffer());
10
+ }
11
+ async readFile(e) {
12
+ const r = typeof e == "string" ? e : e == null ? void 0 : e.encoding;
13
+ if (r === "utf8")
14
+ return this.blob.text();
15
+ if (r)
16
+ throw new Error(`unsupported encoding: ${r}`);
17
+ return new Uint8Array(await this.blob.arrayBuffer());
18
+ }
19
+ async stat() {
20
+ return { size: this.size };
21
+ }
22
+ async close() {
23
+ }
24
+ }
25
+ function h(n) {
26
+ return (typeof n == "object" && n !== null && "message" in n ? n.message : `${n}`).replace(/\.$/, "");
27
+ }
28
+ class u {
29
+ constructor(e, r = {}) {
30
+ this.baseOverrides = {}, this.url = e;
31
+ const t = r.fetch || globalThis.fetch.bind(globalThis);
32
+ r.overrides && (this.baseOverrides = r.overrides), this.fetchImplementation = t;
33
+ }
34
+ async fetch(e, r) {
35
+ let t;
36
+ try {
37
+ t = await this.fetchImplementation(e, r);
38
+ } catch (a) {
39
+ if (`${a}`.includes("Failed to fetch")) {
40
+ console.warn(`generic-filehandle: refetching ${e} to attempt to work around chrome CORS header caching bug`);
41
+ try {
42
+ t = await this.fetchImplementation(e, {
43
+ ...r,
44
+ cache: "reload"
45
+ });
46
+ } catch (i) {
47
+ throw new Error(`${h(i)} fetching ${e}`, { cause: i });
48
+ }
49
+ } else
50
+ throw new Error(`${h(a)} fetching ${e}`, { cause: a });
51
+ }
52
+ return t;
53
+ }
54
+ async read(e, r, t = {}) {
55
+ const { headers: a = {}, signal: i, overrides: c = {} } = t;
56
+ e < 1 / 0 ? a.range = `bytes=${r}-${r + e}` : e === 1 / 0 && r !== 0 && (a.range = `bytes=${r}-`);
57
+ const s = await this.fetch(this.url, {
58
+ ...this.baseOverrides,
59
+ ...c,
60
+ headers: {
61
+ ...a,
62
+ ...c.headers,
63
+ ...this.baseOverrides.headers
64
+ },
65
+ method: "GET",
66
+ redirect: "follow",
67
+ mode: "cors",
68
+ signal: i
69
+ });
70
+ if (!s.ok)
71
+ throw new Error(`HTTP ${s.status} fetching ${this.url}`);
72
+ if (s.status === 200 && r === 0 || s.status === 206) {
73
+ const l = await s.arrayBuffer(), f = s.headers.get("content-range"), o = /\/(\d+)$/.exec(f || "");
74
+ return o != null && o[1] && (this._stat = {
75
+ size: parseInt(o[1], 10)
76
+ }), new Uint8Array(l.slice(0, e));
77
+ }
78
+ throw s.status === 200 ? new Error(`${this.url} fetch returned status 200, expected 206`) : new Error(`HTTP ${s.status} fetching ${this.url}`);
79
+ }
80
+ async readFile(e = {}) {
81
+ let r, t;
82
+ typeof e == "string" ? (r = e, t = {}) : (r = e.encoding, t = e, delete t.encoding);
83
+ const { headers: a = {}, signal: i, overrides: c = {} } = t, s = await this.fetch(this.url, {
84
+ headers: a,
85
+ method: "GET",
86
+ redirect: "follow",
87
+ mode: "cors",
88
+ signal: i,
89
+ ...this.baseOverrides,
90
+ ...c
91
+ });
92
+ if (s.status !== 200)
93
+ throw new Error(`HTTP ${s.status} fetching ${this.url}`);
94
+ if (r === "utf8")
95
+ return s.text();
96
+ if (r)
97
+ throw new Error(`unsupported encoding: ${r}`);
98
+ return new Uint8Array(await s.arrayBuffer());
99
+ }
100
+ async stat() {
101
+ if (!this._stat && (await this.read(10, 0), !this._stat))
102
+ throw new Error(`unable to determine size of file at ${this.url}`);
103
+ return this._stat;
104
+ }
105
+ async close() {
106
+ }
107
+ }
108
+ class w {
109
+ readFile() {
110
+ throw new Error("unimplemented");
111
+ }
112
+ read() {
113
+ throw new Error("unimplemented");
114
+ }
115
+ close() {
116
+ throw new Error("unimplemented");
117
+ }
118
+ }
119
+ export {
120
+ d as BlobFile,
121
+ w as LocalFile,
122
+ u as RemoteFile
123
+ };