@pluot/react 0.1.2 → 0.1.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.
- package/dist/index.js +1029 -934
- package/dist-tsc/Pluot.d.ts.map +1 -1
- package/dist-tsc/Pluot.js +36 -27
- package/package.json +3 -3
- package/src/Pluot.jsx +54 -34
- package/dist/C059-BdIta.ttf-Bdc938Uh.js +0 -4
- package/dist/C059-Bold.ttf-D54yVEIG.js +0 -4
- package/dist/C059-Italic.ttf-DLWXDpX2.js +0 -4
- package/dist/C059-Roman.ttf-B_4E2VG-.js +0 -4
- package/dist/D050000L.ttf-DThw2vhA.js +0 -4
- package/dist/NimbusMonoPS-Bold.ttf-DaeY0qBr.js +0 -4
- package/dist/NimbusMonoPS-BoldItalic.ttf-BWf8L4h2.js +0 -4
- package/dist/NimbusMonoPS-Italic.ttf-B6sVyRe1.js +0 -4
- package/dist/NimbusMonoPS-Regular.ttf-4U95hi4W.js +0 -4
- package/dist/NimbusRoman-Bold.ttf-CYfJBZ-D.js +0 -4
- package/dist/NimbusRoman-BoldItalic.ttf-IKgFHn3u.js +0 -4
- package/dist/NimbusRoman-Italic.ttf-DphHuaaV.js +0 -4
- package/dist/NimbusRoman-Regular.ttf-CyDfJ_2L.js +0 -4
- package/dist/NimbusSans-Bold.ttf-BgToHb0k.js +0 -4
- package/dist/NimbusSans-BoldItalic.ttf-DBTyNZML.js +0 -4
- package/dist/NimbusSans-BoldOblique.ttf-BsmbX-RQ.js +0 -4
- package/dist/NimbusSans-Italic.ttf-DXn1aKmU.js +0 -4
- package/dist/NimbusSans-Oblique.ttf-BnOkISci.js +0 -4
- package/dist/NimbusSans-Regular.ttf-BPUWfSNR.js +0 -4
- package/dist/NimbusSansNarrow-BdOblique.ttf-pMMXNfDW.js +0 -4
- package/dist/NimbusSansNarrow-Bold.ttf-CTqrnZ6z.js +0 -4
- package/dist/NimbusSansNarrow-BoldOblique.ttf-CDZKzRWR.js +0 -4
- package/dist/NimbusSansNarrow-Oblique.ttf-CmqouKBN.js +0 -4
- package/dist/NimbusSansNarrow-Regular.ttf-DOZi8TRM.js +0 -4
- package/dist/P052-Bold.ttf-F7VVlUHU.js +0 -4
- package/dist/P052-BoldItalic.ttf-CTaOaPJC.js +0 -4
- package/dist/P052-Italic.ttf-CfqenRHn.js +0 -4
- package/dist/P052-Roman.ttf-B-tZ3T0p.js +0 -4
- package/dist/StandardSymbolsPS.ttf-DQ9k8vPT.js +0 -4
- package/dist/URWBookman-Demi.ttf-gvfD6bGd.js +0 -4
- package/dist/URWBookman-DemiItalic.ttf-CTYueWh5.js +0 -4
- package/dist/URWBookman-Light.ttf-DK879rFB.js +0 -4
- package/dist/URWBookman-LightItalic.ttf-BWVZJTZv.js +0 -4
- package/dist/URWGothic-Book.ttf-BjKm3X4s.js +0 -4
- package/dist/URWGothic-BookOblique.ttf-UGkGTKkJ.js +0 -4
- package/dist/URWGothic-Demi.ttf-CUhEK02w.js +0 -4
- package/dist/URWGothic-DemiOblique.ttf-CP_D_bVd.js +0 -4
- package/dist/Z003-MediumItalic.ttf-BXc6HvHA.js +0 -4
- package/dist-tsc/3d-view-controls.d.ts +0 -17
- package/dist-tsc/3d-view-controls.d.ts.map +0 -1
- package/dist-tsc/3d-view-controls.js +0 -223
- package/dist-tsc/dom-2d-camera.d.ts +0 -26
- package/dist-tsc/dom-2d-camera.d.ts.map +0 -1
- package/dist-tsc/dom-2d-camera.js +0 -303
- package/dist-tsc/feature-detection.d.ts +0 -5
- package/dist-tsc/feature-detection.d.ts.map +0 -1
- package/dist-tsc/feature-detection.js +0 -6
- package/dist-tsc/lru-store.d.ts +0 -4
- package/dist-tsc/lru-store.d.ts.map +0 -1
- package/dist-tsc/lru-store.js +0 -137
package/dist-tsc/lru-store.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import QuickLRU from "quick-lru";
|
|
2
|
-
function normalizeKey(key, range) {
|
|
3
|
-
if (!range)
|
|
4
|
-
return key;
|
|
5
|
-
if ("suffixLength" in range)
|
|
6
|
-
return `${key}:-${range.suffixLength}`;
|
|
7
|
-
return `${key}:${range.offset}:${range.offset + range.length - 1}`;
|
|
8
|
-
}
|
|
9
|
-
// Provides a blanket implementation of getRange that can be used with any AsyncReadable store,
|
|
10
|
-
// even if it doesn't define a getRange method.
|
|
11
|
-
// If the store does have a native getRange method, we use that instead.
|
|
12
|
-
// Reference: https://github.com/vitessce/vitessce/blob/main/packages/utils/zarr-utils/src/base-getrange.ts
|
|
13
|
-
export function createGetRange(store) {
|
|
14
|
-
// TODO: support options param for getRange?
|
|
15
|
-
return async (...args) => {
|
|
16
|
-
const [key, range, opts] = args;
|
|
17
|
-
if (typeof store.getRange === 'function') {
|
|
18
|
-
return store.getRange(key, range, opts);
|
|
19
|
-
}
|
|
20
|
-
// Store does not have a native getRange method; falling back to get. This may be inefficient for large data.
|
|
21
|
-
const arr = await store.get(key, opts);
|
|
22
|
-
if (!arr)
|
|
23
|
-
return undefined;
|
|
24
|
-
const { buffer } = arr;
|
|
25
|
-
if ('suffixLength' in range) {
|
|
26
|
-
const { suffixLength } = range;
|
|
27
|
-
return new Uint8Array(buffer, buffer.byteLength - suffixLength, suffixLength);
|
|
28
|
-
}
|
|
29
|
-
if ('offset' in range && 'length' in range) {
|
|
30
|
-
const { offset, length } = range;
|
|
31
|
-
return new Uint8Array(buffer, offset, length);
|
|
32
|
-
}
|
|
33
|
-
throw new Error('Invalid rangeQuery value.');
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
// A class-based version of the proxy-based lru() function from vizarr.
|
|
37
|
-
// Reference: https://github.com/hms-dbmi/vizarr/blob/862745c1c7c095748bbe97475da61807d5b49189/src/lru-store.ts
|
|
38
|
-
class LruStore {
|
|
39
|
-
#inner_store;
|
|
40
|
-
#cache;
|
|
41
|
-
// We need a way to synchronously peek at the promise state (a-la Bun's peek or Effect's Deferred.poll).
|
|
42
|
-
// We can probably do something more sophisticated but will try this first.
|
|
43
|
-
#promise_states;
|
|
44
|
-
constructor(store, maxSize = 100) {
|
|
45
|
-
this.#inner_store = store;
|
|
46
|
-
this.#promise_states = new Map();
|
|
47
|
-
this.#cache = new QuickLRU({
|
|
48
|
-
maxSize,
|
|
49
|
-
onEviction: (key, _value) => {
|
|
50
|
-
this.#promise_states.delete(key);
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
async get(...args) {
|
|
55
|
-
const [key, opts] = args;
|
|
56
|
-
// console.log(`LRU get: ${key}`);
|
|
57
|
-
const cacheKey = normalizeKey(key);
|
|
58
|
-
const cached = this.#cache.get(cacheKey);
|
|
59
|
-
if (cached) {
|
|
60
|
-
return cached[0];
|
|
61
|
-
}
|
|
62
|
-
const controller = new AbortController();
|
|
63
|
-
let getResult = this.#inner_store.get(key, {
|
|
64
|
-
signal: controller.signal,
|
|
65
|
-
...(opts ?? {})
|
|
66
|
-
});
|
|
67
|
-
const getResultPromise = Promise.resolve(getResult);
|
|
68
|
-
this.#promise_states.set(cacheKey, 'pending');
|
|
69
|
-
const result = getResultPromise.then((val) => {
|
|
70
|
-
this.#promise_states.set(cacheKey, 'fulfilled');
|
|
71
|
-
return val;
|
|
72
|
-
}).catch((err) => {
|
|
73
|
-
this.#promise_states.set(cacheKey, 'rejected');
|
|
74
|
-
this.#cache.delete(cacheKey);
|
|
75
|
-
throw err;
|
|
76
|
-
});
|
|
77
|
-
this.#cache.set(cacheKey, [result, controller]);
|
|
78
|
-
return result;
|
|
79
|
-
}
|
|
80
|
-
// Synchronously peek at the promise state.
|
|
81
|
-
getPeek(...args) {
|
|
82
|
-
this.get(...args); // Kick off the promise but do not await. TODO: do we want to do this here?
|
|
83
|
-
const [key, opts] = args;
|
|
84
|
-
// console.log(`LRU getPeek: ${key}`);
|
|
85
|
-
const cacheKey = normalizeKey(key);
|
|
86
|
-
return this.#promise_states.get(cacheKey);
|
|
87
|
-
}
|
|
88
|
-
async getRange(...args) {
|
|
89
|
-
const [key, range, opts] = args;
|
|
90
|
-
const cacheKey = normalizeKey(key, range);
|
|
91
|
-
const cached = this.#cache.get(cacheKey);
|
|
92
|
-
if (cached) {
|
|
93
|
-
return cached[0];
|
|
94
|
-
}
|
|
95
|
-
const _getRange = typeof this.#inner_store.getRange === 'function'
|
|
96
|
-
? this.#inner_store.getRange.bind(this.#inner_store)
|
|
97
|
-
: createGetRange(this.#inner_store);
|
|
98
|
-
const controller = new AbortController();
|
|
99
|
-
// @ts-expect-error
|
|
100
|
-
let getRangeResult = _getRange(key, range, {
|
|
101
|
-
signal: controller.signal,
|
|
102
|
-
...(opts ?? {})
|
|
103
|
-
});
|
|
104
|
-
const getRangeResultPromise = Promise.resolve(getRangeResult);
|
|
105
|
-
this.#promise_states.set(cacheKey, 'pending');
|
|
106
|
-
const result = getRangeResultPromise.then((val) => {
|
|
107
|
-
this.#promise_states.set(cacheKey, 'fulfilled');
|
|
108
|
-
return val;
|
|
109
|
-
}).catch((err) => {
|
|
110
|
-
this.#promise_states.set(cacheKey, 'rejected');
|
|
111
|
-
this.#cache.delete(cacheKey);
|
|
112
|
-
throw err;
|
|
113
|
-
});
|
|
114
|
-
this.#cache.set(cacheKey, [result, controller]);
|
|
115
|
-
return result;
|
|
116
|
-
}
|
|
117
|
-
// Synchronously peek at the promise state.
|
|
118
|
-
getRangePeek(...args) {
|
|
119
|
-
this.getRange(...args); // Kick off the promise but do not await. TODO: do we want to do this here?
|
|
120
|
-
const [key, range, opts] = args;
|
|
121
|
-
const cacheKey = normalizeKey(key, range);
|
|
122
|
-
return this.#promise_states.get(cacheKey);
|
|
123
|
-
}
|
|
124
|
-
clearCache() {
|
|
125
|
-
// Use AbortSignal in clearCache for promises that have not yet been resolved.
|
|
126
|
-
this.#cache.forEach(([promise, controller]) => {
|
|
127
|
-
// TODO: check if promise is still pending before aborting? Or just always abort?
|
|
128
|
-
// TODO: verify that this aborting is actually working
|
|
129
|
-
controller.abort();
|
|
130
|
-
});
|
|
131
|
-
this.#cache.clear();
|
|
132
|
-
this.#promise_states = new Map();
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
export function lru(inner_store, maxSize = 100) {
|
|
136
|
-
return new LruStore(inner_store, maxSize);
|
|
137
|
-
}
|