@vitessce/utils 3.9.9 → 4.0.0-test.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.
- package/package.json +2 -2
- package/dist/index.js +0 -1025
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitessce/utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-test.1",
|
|
4
4
|
"author": "HIDIVE Lab at HMS",
|
|
5
5
|
"homepage": "http://vitessce.io",
|
|
6
6
|
"repository": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"lz-string": "^1.4.4",
|
|
22
22
|
"pluralize": "^8.0.0",
|
|
23
23
|
"d3-array": "^2.4.0",
|
|
24
|
-
"@vitessce/globals": "
|
|
24
|
+
"@vitessce/globals": "4.0.0-test.1"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"bundle": "pnpm exec vite build -c ../../../scripts/vite.config.mjs",
|
package/dist/index.js
DELETED
|
@@ -1,1025 +0,0 @@
|
|
|
1
|
-
function getDefaultExportFromCjs(x) {
|
|
2
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
3
|
-
}
|
|
4
|
-
function commonjsRequire(path) {
|
|
5
|
-
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
6
|
-
}
|
|
7
|
-
var pluralize$2 = { exports: {} };
|
|
8
|
-
var pluralize$1 = pluralize$2.exports;
|
|
9
|
-
var hasRequiredPluralize;
|
|
10
|
-
function requirePluralize() {
|
|
11
|
-
if (hasRequiredPluralize) return pluralize$2.exports;
|
|
12
|
-
hasRequiredPluralize = 1;
|
|
13
|
-
(function(module, exports) {
|
|
14
|
-
(function(root, pluralize2) {
|
|
15
|
-
if (typeof commonjsRequire === "function" && true && true) {
|
|
16
|
-
module.exports = pluralize2();
|
|
17
|
-
} else {
|
|
18
|
-
root.pluralize = pluralize2();
|
|
19
|
-
}
|
|
20
|
-
})(pluralize$1, function() {
|
|
21
|
-
var pluralRules = [];
|
|
22
|
-
var singularRules = [];
|
|
23
|
-
var uncountables = {};
|
|
24
|
-
var irregularPlurals = {};
|
|
25
|
-
var irregularSingles = {};
|
|
26
|
-
function sanitizeRule(rule) {
|
|
27
|
-
if (typeof rule === "string") {
|
|
28
|
-
return new RegExp("^" + rule + "$", "i");
|
|
29
|
-
}
|
|
30
|
-
return rule;
|
|
31
|
-
}
|
|
32
|
-
function restoreCase(word, token) {
|
|
33
|
-
if (word === token) return token;
|
|
34
|
-
if (word === word.toLowerCase()) return token.toLowerCase();
|
|
35
|
-
if (word === word.toUpperCase()) return token.toUpperCase();
|
|
36
|
-
if (word[0] === word[0].toUpperCase()) {
|
|
37
|
-
return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
|
|
38
|
-
}
|
|
39
|
-
return token.toLowerCase();
|
|
40
|
-
}
|
|
41
|
-
function interpolate(str, args) {
|
|
42
|
-
return str.replace(/\$(\d{1,2})/g, function(match, index) {
|
|
43
|
-
return args[index] || "";
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
function replace(word, rule) {
|
|
47
|
-
return word.replace(rule[0], function(match, index) {
|
|
48
|
-
var result = interpolate(rule[1], arguments);
|
|
49
|
-
if (match === "") {
|
|
50
|
-
return restoreCase(word[index - 1], result);
|
|
51
|
-
}
|
|
52
|
-
return restoreCase(match, result);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
function sanitizeWord(token, word, rules) {
|
|
56
|
-
if (!token.length || uncountables.hasOwnProperty(token)) {
|
|
57
|
-
return word;
|
|
58
|
-
}
|
|
59
|
-
var len = rules.length;
|
|
60
|
-
while (len--) {
|
|
61
|
-
var rule = rules[len];
|
|
62
|
-
if (rule[0].test(word)) return replace(word, rule);
|
|
63
|
-
}
|
|
64
|
-
return word;
|
|
65
|
-
}
|
|
66
|
-
function replaceWord(replaceMap, keepMap, rules) {
|
|
67
|
-
return function(word) {
|
|
68
|
-
var token = word.toLowerCase();
|
|
69
|
-
if (keepMap.hasOwnProperty(token)) {
|
|
70
|
-
return restoreCase(word, token);
|
|
71
|
-
}
|
|
72
|
-
if (replaceMap.hasOwnProperty(token)) {
|
|
73
|
-
return restoreCase(word, replaceMap[token]);
|
|
74
|
-
}
|
|
75
|
-
return sanitizeWord(token, word, rules);
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
function checkWord(replaceMap, keepMap, rules, bool) {
|
|
79
|
-
return function(word) {
|
|
80
|
-
var token = word.toLowerCase();
|
|
81
|
-
if (keepMap.hasOwnProperty(token)) return true;
|
|
82
|
-
if (replaceMap.hasOwnProperty(token)) return false;
|
|
83
|
-
return sanitizeWord(token, token, rules) === token;
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
function pluralize2(word, count, inclusive) {
|
|
87
|
-
var pluralized = count === 1 ? pluralize2.singular(word) : pluralize2.plural(word);
|
|
88
|
-
return (inclusive ? count + " " : "") + pluralized;
|
|
89
|
-
}
|
|
90
|
-
pluralize2.plural = replaceWord(
|
|
91
|
-
irregularSingles,
|
|
92
|
-
irregularPlurals,
|
|
93
|
-
pluralRules
|
|
94
|
-
);
|
|
95
|
-
pluralize2.isPlural = checkWord(
|
|
96
|
-
irregularSingles,
|
|
97
|
-
irregularPlurals,
|
|
98
|
-
pluralRules
|
|
99
|
-
);
|
|
100
|
-
pluralize2.singular = replaceWord(
|
|
101
|
-
irregularPlurals,
|
|
102
|
-
irregularSingles,
|
|
103
|
-
singularRules
|
|
104
|
-
);
|
|
105
|
-
pluralize2.isSingular = checkWord(
|
|
106
|
-
irregularPlurals,
|
|
107
|
-
irregularSingles,
|
|
108
|
-
singularRules
|
|
109
|
-
);
|
|
110
|
-
pluralize2.addPluralRule = function(rule, replacement) {
|
|
111
|
-
pluralRules.push([sanitizeRule(rule), replacement]);
|
|
112
|
-
};
|
|
113
|
-
pluralize2.addSingularRule = function(rule, replacement) {
|
|
114
|
-
singularRules.push([sanitizeRule(rule), replacement]);
|
|
115
|
-
};
|
|
116
|
-
pluralize2.addUncountableRule = function(word) {
|
|
117
|
-
if (typeof word === "string") {
|
|
118
|
-
uncountables[word.toLowerCase()] = true;
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
pluralize2.addPluralRule(word, "$0");
|
|
122
|
-
pluralize2.addSingularRule(word, "$0");
|
|
123
|
-
};
|
|
124
|
-
pluralize2.addIrregularRule = function(single, plural) {
|
|
125
|
-
plural = plural.toLowerCase();
|
|
126
|
-
single = single.toLowerCase();
|
|
127
|
-
irregularSingles[single] = plural;
|
|
128
|
-
irregularPlurals[plural] = single;
|
|
129
|
-
};
|
|
130
|
-
[
|
|
131
|
-
// Pronouns.
|
|
132
|
-
["I", "we"],
|
|
133
|
-
["me", "us"],
|
|
134
|
-
["he", "they"],
|
|
135
|
-
["she", "they"],
|
|
136
|
-
["them", "them"],
|
|
137
|
-
["myself", "ourselves"],
|
|
138
|
-
["yourself", "yourselves"],
|
|
139
|
-
["itself", "themselves"],
|
|
140
|
-
["herself", "themselves"],
|
|
141
|
-
["himself", "themselves"],
|
|
142
|
-
["themself", "themselves"],
|
|
143
|
-
["is", "are"],
|
|
144
|
-
["was", "were"],
|
|
145
|
-
["has", "have"],
|
|
146
|
-
["this", "these"],
|
|
147
|
-
["that", "those"],
|
|
148
|
-
// Words ending in with a consonant and `o`.
|
|
149
|
-
["echo", "echoes"],
|
|
150
|
-
["dingo", "dingoes"],
|
|
151
|
-
["volcano", "volcanoes"],
|
|
152
|
-
["tornado", "tornadoes"],
|
|
153
|
-
["torpedo", "torpedoes"],
|
|
154
|
-
// Ends with `us`.
|
|
155
|
-
["genus", "genera"],
|
|
156
|
-
["viscus", "viscera"],
|
|
157
|
-
// Ends with `ma`.
|
|
158
|
-
["stigma", "stigmata"],
|
|
159
|
-
["stoma", "stomata"],
|
|
160
|
-
["dogma", "dogmata"],
|
|
161
|
-
["lemma", "lemmata"],
|
|
162
|
-
["schema", "schemata"],
|
|
163
|
-
["anathema", "anathemata"],
|
|
164
|
-
// Other irregular rules.
|
|
165
|
-
["ox", "oxen"],
|
|
166
|
-
["axe", "axes"],
|
|
167
|
-
["die", "dice"],
|
|
168
|
-
["yes", "yeses"],
|
|
169
|
-
["foot", "feet"],
|
|
170
|
-
["eave", "eaves"],
|
|
171
|
-
["goose", "geese"],
|
|
172
|
-
["tooth", "teeth"],
|
|
173
|
-
["quiz", "quizzes"],
|
|
174
|
-
["human", "humans"],
|
|
175
|
-
["proof", "proofs"],
|
|
176
|
-
["carve", "carves"],
|
|
177
|
-
["valve", "valves"],
|
|
178
|
-
["looey", "looies"],
|
|
179
|
-
["thief", "thieves"],
|
|
180
|
-
["groove", "grooves"],
|
|
181
|
-
["pickaxe", "pickaxes"],
|
|
182
|
-
["passerby", "passersby"]
|
|
183
|
-
].forEach(function(rule) {
|
|
184
|
-
return pluralize2.addIrregularRule(rule[0], rule[1]);
|
|
185
|
-
});
|
|
186
|
-
[
|
|
187
|
-
[/s?$/i, "s"],
|
|
188
|
-
[/[^\u0000-\u007F]$/i, "$0"],
|
|
189
|
-
[/([^aeiou]ese)$/i, "$1"],
|
|
190
|
-
[/(ax|test)is$/i, "$1es"],
|
|
191
|
-
[/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
|
|
192
|
-
[/(e[mn]u)s?$/i, "$1s"],
|
|
193
|
-
[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
|
|
194
|
-
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1i"],
|
|
195
|
-
[/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
|
|
196
|
-
[/(seraph|cherub)(?:im)?$/i, "$1im"],
|
|
197
|
-
[/(her|at|gr)o$/i, "$1oes"],
|
|
198
|
-
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, "$1a"],
|
|
199
|
-
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, "$1a"],
|
|
200
|
-
[/sis$/i, "ses"],
|
|
201
|
-
[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
|
|
202
|
-
[/([^aeiouy]|qu)y$/i, "$1ies"],
|
|
203
|
-
[/([^ch][ieo][ln])ey$/i, "$1ies"],
|
|
204
|
-
[/(x|ch|ss|sh|zz)$/i, "$1es"],
|
|
205
|
-
[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
|
|
206
|
-
[/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
|
|
207
|
-
[/(pe)(?:rson|ople)$/i, "$1ople"],
|
|
208
|
-
[/(child)(?:ren)?$/i, "$1ren"],
|
|
209
|
-
[/eaux$/i, "$0"],
|
|
210
|
-
[/m[ae]n$/i, "men"],
|
|
211
|
-
["thou", "you"]
|
|
212
|
-
].forEach(function(rule) {
|
|
213
|
-
return pluralize2.addPluralRule(rule[0], rule[1]);
|
|
214
|
-
});
|
|
215
|
-
[
|
|
216
|
-
[/s$/i, ""],
|
|
217
|
-
[/(ss)$/i, "$1"],
|
|
218
|
-
[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
|
|
219
|
-
[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
|
|
220
|
-
[/ies$/i, "y"],
|
|
221
|
-
[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, "$1ie"],
|
|
222
|
-
[/\b(mon|smil)ies$/i, "$1ey"],
|
|
223
|
-
[/\b((?:tit)?m|l)ice$/i, "$1ouse"],
|
|
224
|
-
[/(seraph|cherub)im$/i, "$1"],
|
|
225
|
-
[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, "$1"],
|
|
226
|
-
[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, "$1sis"],
|
|
227
|
-
[/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
|
|
228
|
-
[/(test)(?:is|es)$/i, "$1is"],
|
|
229
|
-
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1us"],
|
|
230
|
-
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, "$1um"],
|
|
231
|
-
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1on"],
|
|
232
|
-
[/(alumn|alg|vertebr)ae$/i, "$1a"],
|
|
233
|
-
[/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
|
|
234
|
-
[/(matr|append)ices$/i, "$1ix"],
|
|
235
|
-
[/(pe)(rson|ople)$/i, "$1rson"],
|
|
236
|
-
[/(child)ren$/i, "$1"],
|
|
237
|
-
[/(eau)x?$/i, "$1"],
|
|
238
|
-
[/men$/i, "man"]
|
|
239
|
-
].forEach(function(rule) {
|
|
240
|
-
return pluralize2.addSingularRule(rule[0], rule[1]);
|
|
241
|
-
});
|
|
242
|
-
[
|
|
243
|
-
// Singular words with no plurals.
|
|
244
|
-
"adulthood",
|
|
245
|
-
"advice",
|
|
246
|
-
"agenda",
|
|
247
|
-
"aid",
|
|
248
|
-
"aircraft",
|
|
249
|
-
"alcohol",
|
|
250
|
-
"ammo",
|
|
251
|
-
"analytics",
|
|
252
|
-
"anime",
|
|
253
|
-
"athletics",
|
|
254
|
-
"audio",
|
|
255
|
-
"bison",
|
|
256
|
-
"blood",
|
|
257
|
-
"bream",
|
|
258
|
-
"buffalo",
|
|
259
|
-
"butter",
|
|
260
|
-
"carp",
|
|
261
|
-
"cash",
|
|
262
|
-
"chassis",
|
|
263
|
-
"chess",
|
|
264
|
-
"clothing",
|
|
265
|
-
"cod",
|
|
266
|
-
"commerce",
|
|
267
|
-
"cooperation",
|
|
268
|
-
"corps",
|
|
269
|
-
"debris",
|
|
270
|
-
"diabetes",
|
|
271
|
-
"digestion",
|
|
272
|
-
"elk",
|
|
273
|
-
"energy",
|
|
274
|
-
"equipment",
|
|
275
|
-
"excretion",
|
|
276
|
-
"expertise",
|
|
277
|
-
"firmware",
|
|
278
|
-
"flounder",
|
|
279
|
-
"fun",
|
|
280
|
-
"gallows",
|
|
281
|
-
"garbage",
|
|
282
|
-
"graffiti",
|
|
283
|
-
"hardware",
|
|
284
|
-
"headquarters",
|
|
285
|
-
"health",
|
|
286
|
-
"herpes",
|
|
287
|
-
"highjinks",
|
|
288
|
-
"homework",
|
|
289
|
-
"housework",
|
|
290
|
-
"information",
|
|
291
|
-
"jeans",
|
|
292
|
-
"justice",
|
|
293
|
-
"kudos",
|
|
294
|
-
"labour",
|
|
295
|
-
"literature",
|
|
296
|
-
"machinery",
|
|
297
|
-
"mackerel",
|
|
298
|
-
"mail",
|
|
299
|
-
"media",
|
|
300
|
-
"mews",
|
|
301
|
-
"moose",
|
|
302
|
-
"music",
|
|
303
|
-
"mud",
|
|
304
|
-
"manga",
|
|
305
|
-
"news",
|
|
306
|
-
"only",
|
|
307
|
-
"personnel",
|
|
308
|
-
"pike",
|
|
309
|
-
"plankton",
|
|
310
|
-
"pliers",
|
|
311
|
-
"police",
|
|
312
|
-
"pollution",
|
|
313
|
-
"premises",
|
|
314
|
-
"rain",
|
|
315
|
-
"research",
|
|
316
|
-
"rice",
|
|
317
|
-
"salmon",
|
|
318
|
-
"scissors",
|
|
319
|
-
"series",
|
|
320
|
-
"sewage",
|
|
321
|
-
"shambles",
|
|
322
|
-
"shrimp",
|
|
323
|
-
"software",
|
|
324
|
-
"species",
|
|
325
|
-
"staff",
|
|
326
|
-
"swine",
|
|
327
|
-
"tennis",
|
|
328
|
-
"traffic",
|
|
329
|
-
"transportation",
|
|
330
|
-
"trout",
|
|
331
|
-
"tuna",
|
|
332
|
-
"wealth",
|
|
333
|
-
"welfare",
|
|
334
|
-
"whiting",
|
|
335
|
-
"wildebeest",
|
|
336
|
-
"wildlife",
|
|
337
|
-
"you",
|
|
338
|
-
/pok[eé]mon$/i,
|
|
339
|
-
// Regexes.
|
|
340
|
-
/[^aeiou]ese$/i,
|
|
341
|
-
// "chinese", "japanese"
|
|
342
|
-
/deer$/i,
|
|
343
|
-
// "deer", "reindeer"
|
|
344
|
-
/fish$/i,
|
|
345
|
-
// "fish", "blowfish", "angelfish"
|
|
346
|
-
/measles$/i,
|
|
347
|
-
/o[iu]s$/i,
|
|
348
|
-
// "carnivorous"
|
|
349
|
-
/pox$/i,
|
|
350
|
-
// "chickpox", "smallpox"
|
|
351
|
-
/sheep$/i
|
|
352
|
-
].forEach(pluralize2.addUncountableRule);
|
|
353
|
-
return pluralize2;
|
|
354
|
-
});
|
|
355
|
-
})(pluralize$2);
|
|
356
|
-
return pluralize$2.exports;
|
|
357
|
-
}
|
|
358
|
-
var pluralizeExports = requirePluralize();
|
|
359
|
-
const plur = /* @__PURE__ */ getDefaultExportFromCjs(pluralizeExports);
|
|
360
|
-
plur.addPluralRule("glomerulus", "glomeruli");
|
|
361
|
-
plur.addPluralRule("interstitium", "interstitia");
|
|
362
|
-
function commaNumber(n) {
|
|
363
|
-
const nf = new Intl.NumberFormat("en-US");
|
|
364
|
-
return nf.format(n);
|
|
365
|
-
}
|
|
366
|
-
function capitalize(word) {
|
|
367
|
-
return word ? word.charAt(0).toUpperCase() + word.slice(1) : "";
|
|
368
|
-
}
|
|
369
|
-
function pluralize(word, count = null) {
|
|
370
|
-
return plur(word, count);
|
|
371
|
-
}
|
|
372
|
-
function getLongestString(strings) {
|
|
373
|
-
return strings.reduce(
|
|
374
|
-
(prevLongest, currentValue) => prevLongest.length > currentValue.length ? prevLongest : currentValue
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
|
-
function cleanFeatureId(featureName) {
|
|
378
|
-
if (featureName.startsWith("ENSG")) {
|
|
379
|
-
return featureName.split(".")[0];
|
|
380
|
-
}
|
|
381
|
-
return featureName;
|
|
382
|
-
}
|
|
383
|
-
function getNextScope(prevScopes) {
|
|
384
|
-
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
385
|
-
const nextCharIndices = [0];
|
|
386
|
-
function next() {
|
|
387
|
-
const r = [];
|
|
388
|
-
nextCharIndices.forEach((charIndex) => {
|
|
389
|
-
r.unshift(chars[charIndex]);
|
|
390
|
-
});
|
|
391
|
-
let increment = true;
|
|
392
|
-
for (let i = 0; i < nextCharIndices.length; i++) {
|
|
393
|
-
const val = ++nextCharIndices[i];
|
|
394
|
-
if (val >= chars.length) {
|
|
395
|
-
nextCharIndices[i] = 0;
|
|
396
|
-
} else {
|
|
397
|
-
increment = false;
|
|
398
|
-
break;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
if (increment) {
|
|
402
|
-
nextCharIndices.push(0);
|
|
403
|
-
}
|
|
404
|
-
return r.join("");
|
|
405
|
-
}
|
|
406
|
-
let nextScope;
|
|
407
|
-
do {
|
|
408
|
-
nextScope = next();
|
|
409
|
-
} while (prevScopes.includes(nextScope));
|
|
410
|
-
return nextScope;
|
|
411
|
-
}
|
|
412
|
-
function getNextScopeNumeric(prevScopes) {
|
|
413
|
-
let nextScopeInt = 0;
|
|
414
|
-
let nextScopeStr;
|
|
415
|
-
do {
|
|
416
|
-
nextScopeStr = `${nextScopeInt}`;
|
|
417
|
-
nextScopeInt += 1;
|
|
418
|
-
} while (prevScopes.includes(nextScopeStr));
|
|
419
|
-
return nextScopeStr;
|
|
420
|
-
}
|
|
421
|
-
function createPrefixedGetNextScopeNumeric(prefix) {
|
|
422
|
-
return (prevScopes) => {
|
|
423
|
-
let nextScopeInt = 0;
|
|
424
|
-
let nextScopeStr;
|
|
425
|
-
do {
|
|
426
|
-
nextScopeStr = `${prefix}${nextScopeInt}`;
|
|
427
|
-
nextScopeInt += 1;
|
|
428
|
-
} while (prevScopes.includes(nextScopeStr));
|
|
429
|
-
return nextScopeStr;
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
function getInitialCoordinationScopePrefix(datasetUid, dataType) {
|
|
433
|
-
return `init_${datasetUid}_${dataType}_`;
|
|
434
|
-
}
|
|
435
|
-
function getInitialCoordinationScopeName(datasetUid, dataType, i = null) {
|
|
436
|
-
const prefix = getInitialCoordinationScopePrefix(datasetUid, dataType);
|
|
437
|
-
return `${prefix}${i === null ? 0 : i}`;
|
|
438
|
-
}
|
|
439
|
-
const identityFunc = (d) => d;
|
|
440
|
-
function unnestMap(map, keys, aggFunc) {
|
|
441
|
-
if (keys.length < 2) {
|
|
442
|
-
throw new Error("Insufficient number of keys passed to flattenInternMap");
|
|
443
|
-
}
|
|
444
|
-
const aggFuncToUse = !aggFunc ? identityFunc : aggFunc;
|
|
445
|
-
return Array.from(map.entries()).flatMap(([k, v]) => {
|
|
446
|
-
if (v instanceof Map) {
|
|
447
|
-
const keysWithoutFirst = [...keys];
|
|
448
|
-
keysWithoutFirst.splice(0, 1);
|
|
449
|
-
return unnestMap(v, keysWithoutFirst, aggFuncToUse).map((childObj) => ({
|
|
450
|
-
[keys[0]]: k,
|
|
451
|
-
...childObj
|
|
452
|
-
}));
|
|
453
|
-
}
|
|
454
|
-
return {
|
|
455
|
-
[keys[0]]: k,
|
|
456
|
-
[keys[1]]: aggFuncToUse(v)
|
|
457
|
-
};
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
var loglevel$1 = { exports: {} };
|
|
461
|
-
var loglevel = loglevel$1.exports;
|
|
462
|
-
var hasRequiredLoglevel;
|
|
463
|
-
function requireLoglevel() {
|
|
464
|
-
if (hasRequiredLoglevel) return loglevel$1.exports;
|
|
465
|
-
hasRequiredLoglevel = 1;
|
|
466
|
-
(function(module) {
|
|
467
|
-
(function(root, definition) {
|
|
468
|
-
if (module.exports) {
|
|
469
|
-
module.exports = definition();
|
|
470
|
-
} else {
|
|
471
|
-
root.log = definition();
|
|
472
|
-
}
|
|
473
|
-
})(loglevel, function() {
|
|
474
|
-
var noop = function() {
|
|
475
|
-
};
|
|
476
|
-
var undefinedType = "undefined";
|
|
477
|
-
var isIE = typeof window !== undefinedType && typeof window.navigator !== undefinedType && /Trident\/|MSIE /.test(window.navigator.userAgent);
|
|
478
|
-
var logMethods = [
|
|
479
|
-
"trace",
|
|
480
|
-
"debug",
|
|
481
|
-
"info",
|
|
482
|
-
"warn",
|
|
483
|
-
"error"
|
|
484
|
-
];
|
|
485
|
-
var _loggersByName = {};
|
|
486
|
-
var defaultLogger = null;
|
|
487
|
-
function bindMethod(obj, methodName) {
|
|
488
|
-
var method = obj[methodName];
|
|
489
|
-
if (typeof method.bind === "function") {
|
|
490
|
-
return method.bind(obj);
|
|
491
|
-
} else {
|
|
492
|
-
try {
|
|
493
|
-
return Function.prototype.bind.call(method, obj);
|
|
494
|
-
} catch (e) {
|
|
495
|
-
return function() {
|
|
496
|
-
return Function.prototype.apply.apply(method, [obj, arguments]);
|
|
497
|
-
};
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
function traceForIE() {
|
|
502
|
-
if (console.log) {
|
|
503
|
-
if (console.log.apply) {
|
|
504
|
-
console.log.apply(console, arguments);
|
|
505
|
-
} else {
|
|
506
|
-
Function.prototype.apply.apply(console.log, [console, arguments]);
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
if (console.trace) console.trace();
|
|
510
|
-
}
|
|
511
|
-
function realMethod(methodName) {
|
|
512
|
-
if (methodName === "debug") {
|
|
513
|
-
methodName = "log";
|
|
514
|
-
}
|
|
515
|
-
if (typeof console === undefinedType) {
|
|
516
|
-
return false;
|
|
517
|
-
} else if (methodName === "trace" && isIE) {
|
|
518
|
-
return traceForIE;
|
|
519
|
-
} else if (console[methodName] !== void 0) {
|
|
520
|
-
return bindMethod(console, methodName);
|
|
521
|
-
} else if (console.log !== void 0) {
|
|
522
|
-
return bindMethod(console, "log");
|
|
523
|
-
} else {
|
|
524
|
-
return noop;
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
function replaceLoggingMethods() {
|
|
528
|
-
var level = this.getLevel();
|
|
529
|
-
for (var i = 0; i < logMethods.length; i++) {
|
|
530
|
-
var methodName = logMethods[i];
|
|
531
|
-
this[methodName] = i < level ? noop : this.methodFactory(methodName, level, this.name);
|
|
532
|
-
}
|
|
533
|
-
this.log = this.debug;
|
|
534
|
-
if (typeof console === undefinedType && level < this.levels.SILENT) {
|
|
535
|
-
return "No console available for logging";
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
function enableLoggingWhenConsoleArrives(methodName) {
|
|
539
|
-
return function() {
|
|
540
|
-
if (typeof console !== undefinedType) {
|
|
541
|
-
replaceLoggingMethods.call(this);
|
|
542
|
-
this[methodName].apply(this, arguments);
|
|
543
|
-
}
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
function defaultMethodFactory(methodName, _level, _loggerName) {
|
|
547
|
-
return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
|
|
548
|
-
}
|
|
549
|
-
function Logger(name, factory) {
|
|
550
|
-
var self = this;
|
|
551
|
-
var inheritedLevel;
|
|
552
|
-
var defaultLevel;
|
|
553
|
-
var userLevel;
|
|
554
|
-
var storageKey = "loglevel";
|
|
555
|
-
if (typeof name === "string") {
|
|
556
|
-
storageKey += ":" + name;
|
|
557
|
-
} else if (typeof name === "symbol") {
|
|
558
|
-
storageKey = void 0;
|
|
559
|
-
}
|
|
560
|
-
function persistLevelIfPossible(levelNum) {
|
|
561
|
-
var levelName = (logMethods[levelNum] || "silent").toUpperCase();
|
|
562
|
-
if (typeof window === undefinedType || !storageKey) return;
|
|
563
|
-
try {
|
|
564
|
-
window.localStorage[storageKey] = levelName;
|
|
565
|
-
return;
|
|
566
|
-
} catch (ignore) {
|
|
567
|
-
}
|
|
568
|
-
try {
|
|
569
|
-
window.document.cookie = encodeURIComponent(storageKey) + "=" + levelName + ";";
|
|
570
|
-
} catch (ignore) {
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
function getPersistedLevel() {
|
|
574
|
-
var storedLevel;
|
|
575
|
-
if (typeof window === undefinedType || !storageKey) return;
|
|
576
|
-
try {
|
|
577
|
-
storedLevel = window.localStorage[storageKey];
|
|
578
|
-
} catch (ignore) {
|
|
579
|
-
}
|
|
580
|
-
if (typeof storedLevel === undefinedType) {
|
|
581
|
-
try {
|
|
582
|
-
var cookie = window.document.cookie;
|
|
583
|
-
var cookieName = encodeURIComponent(storageKey);
|
|
584
|
-
var location = cookie.indexOf(cookieName + "=");
|
|
585
|
-
if (location !== -1) {
|
|
586
|
-
storedLevel = /^([^;]+)/.exec(
|
|
587
|
-
cookie.slice(location + cookieName.length + 1)
|
|
588
|
-
)[1];
|
|
589
|
-
}
|
|
590
|
-
} catch (ignore) {
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
if (self.levels[storedLevel] === void 0) {
|
|
594
|
-
storedLevel = void 0;
|
|
595
|
-
}
|
|
596
|
-
return storedLevel;
|
|
597
|
-
}
|
|
598
|
-
function clearPersistedLevel() {
|
|
599
|
-
if (typeof window === undefinedType || !storageKey) return;
|
|
600
|
-
try {
|
|
601
|
-
window.localStorage.removeItem(storageKey);
|
|
602
|
-
} catch (ignore) {
|
|
603
|
-
}
|
|
604
|
-
try {
|
|
605
|
-
window.document.cookie = encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
|
|
606
|
-
} catch (ignore) {
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
function normalizeLevel(input) {
|
|
610
|
-
var level = input;
|
|
611
|
-
if (typeof level === "string" && self.levels[level.toUpperCase()] !== void 0) {
|
|
612
|
-
level = self.levels[level.toUpperCase()];
|
|
613
|
-
}
|
|
614
|
-
if (typeof level === "number" && level >= 0 && level <= self.levels.SILENT) {
|
|
615
|
-
return level;
|
|
616
|
-
} else {
|
|
617
|
-
throw new TypeError("log.setLevel() called with invalid level: " + input);
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
self.name = name;
|
|
621
|
-
self.levels = {
|
|
622
|
-
"TRACE": 0,
|
|
623
|
-
"DEBUG": 1,
|
|
624
|
-
"INFO": 2,
|
|
625
|
-
"WARN": 3,
|
|
626
|
-
"ERROR": 4,
|
|
627
|
-
"SILENT": 5
|
|
628
|
-
};
|
|
629
|
-
self.methodFactory = factory || defaultMethodFactory;
|
|
630
|
-
self.getLevel = function() {
|
|
631
|
-
if (userLevel != null) {
|
|
632
|
-
return userLevel;
|
|
633
|
-
} else if (defaultLevel != null) {
|
|
634
|
-
return defaultLevel;
|
|
635
|
-
} else {
|
|
636
|
-
return inheritedLevel;
|
|
637
|
-
}
|
|
638
|
-
};
|
|
639
|
-
self.setLevel = function(level, persist) {
|
|
640
|
-
userLevel = normalizeLevel(level);
|
|
641
|
-
if (persist !== false) {
|
|
642
|
-
persistLevelIfPossible(userLevel);
|
|
643
|
-
}
|
|
644
|
-
return replaceLoggingMethods.call(self);
|
|
645
|
-
};
|
|
646
|
-
self.setDefaultLevel = function(level) {
|
|
647
|
-
defaultLevel = normalizeLevel(level);
|
|
648
|
-
if (!getPersistedLevel()) {
|
|
649
|
-
self.setLevel(level, false);
|
|
650
|
-
}
|
|
651
|
-
};
|
|
652
|
-
self.resetLevel = function() {
|
|
653
|
-
userLevel = null;
|
|
654
|
-
clearPersistedLevel();
|
|
655
|
-
replaceLoggingMethods.call(self);
|
|
656
|
-
};
|
|
657
|
-
self.enableAll = function(persist) {
|
|
658
|
-
self.setLevel(self.levels.TRACE, persist);
|
|
659
|
-
};
|
|
660
|
-
self.disableAll = function(persist) {
|
|
661
|
-
self.setLevel(self.levels.SILENT, persist);
|
|
662
|
-
};
|
|
663
|
-
self.rebuild = function() {
|
|
664
|
-
if (defaultLogger !== self) {
|
|
665
|
-
inheritedLevel = normalizeLevel(defaultLogger.getLevel());
|
|
666
|
-
}
|
|
667
|
-
replaceLoggingMethods.call(self);
|
|
668
|
-
if (defaultLogger === self) {
|
|
669
|
-
for (var childName in _loggersByName) {
|
|
670
|
-
_loggersByName[childName].rebuild();
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
};
|
|
674
|
-
inheritedLevel = normalizeLevel(
|
|
675
|
-
defaultLogger ? defaultLogger.getLevel() : "WARN"
|
|
676
|
-
);
|
|
677
|
-
var initialLevel = getPersistedLevel();
|
|
678
|
-
if (initialLevel != null) {
|
|
679
|
-
userLevel = normalizeLevel(initialLevel);
|
|
680
|
-
}
|
|
681
|
-
replaceLoggingMethods.call(self);
|
|
682
|
-
}
|
|
683
|
-
defaultLogger = new Logger();
|
|
684
|
-
defaultLogger.getLogger = function getLogger(name) {
|
|
685
|
-
if (typeof name !== "symbol" && typeof name !== "string" || name === "") {
|
|
686
|
-
throw new TypeError("You must supply a name when creating a logger.");
|
|
687
|
-
}
|
|
688
|
-
var logger = _loggersByName[name];
|
|
689
|
-
if (!logger) {
|
|
690
|
-
logger = _loggersByName[name] = new Logger(
|
|
691
|
-
name,
|
|
692
|
-
defaultLogger.methodFactory
|
|
693
|
-
);
|
|
694
|
-
}
|
|
695
|
-
return logger;
|
|
696
|
-
};
|
|
697
|
-
var _log = typeof window !== undefinedType ? window.log : void 0;
|
|
698
|
-
defaultLogger.noConflict = function() {
|
|
699
|
-
if (typeof window !== undefinedType && window.log === defaultLogger) {
|
|
700
|
-
window.log = _log;
|
|
701
|
-
}
|
|
702
|
-
return defaultLogger;
|
|
703
|
-
};
|
|
704
|
-
defaultLogger.getLoggers = function getLoggers() {
|
|
705
|
-
return _loggersByName;
|
|
706
|
-
};
|
|
707
|
-
defaultLogger["default"] = defaultLogger;
|
|
708
|
-
return defaultLogger;
|
|
709
|
-
});
|
|
710
|
-
})(loglevel$1);
|
|
711
|
-
return loglevel$1.exports;
|
|
712
|
-
}
|
|
713
|
-
var loglevelExports = requireLoglevel();
|
|
714
|
-
const log = /* @__PURE__ */ getDefaultExportFromCjs(loglevelExports);
|
|
715
|
-
const DEFAULT_DARK_COLOR = [50, 50, 50];
|
|
716
|
-
const DEFAULT_LIGHT_COLOR = [200, 200, 200];
|
|
717
|
-
const DEFAULT_LIGHT2_COLOR = [235, 235, 235];
|
|
718
|
-
function getDefaultColor(theme) {
|
|
719
|
-
return theme === "dark" ? DEFAULT_DARK_COLOR : theme === "light" ? DEFAULT_LIGHT_COLOR : DEFAULT_LIGHT2_COLOR;
|
|
720
|
-
}
|
|
721
|
-
function getDefaultForegroundColor(theme) {
|
|
722
|
-
return theme === "dark" ? DEFAULT_LIGHT2_COLOR : DEFAULT_DARK_COLOR;
|
|
723
|
-
}
|
|
724
|
-
const PALETTE = [
|
|
725
|
-
[68, 119, 170],
|
|
726
|
-
[136, 204, 238],
|
|
727
|
-
[68, 170, 153],
|
|
728
|
-
[17, 119, 51],
|
|
729
|
-
[153, 153, 51],
|
|
730
|
-
[221, 204, 119],
|
|
731
|
-
[204, 102, 119],
|
|
732
|
-
[136, 34, 85],
|
|
733
|
-
[170, 68, 153]
|
|
734
|
-
];
|
|
735
|
-
const VIEWER_PALETTE = [
|
|
736
|
-
[0, 0, 255],
|
|
737
|
-
[0, 255, 0],
|
|
738
|
-
[255, 0, 255],
|
|
739
|
-
[255, 255, 0],
|
|
740
|
-
[0, 255, 255],
|
|
741
|
-
[255, 255, 255],
|
|
742
|
-
[255, 128, 0],
|
|
743
|
-
[255, 0, 0]
|
|
744
|
-
];
|
|
745
|
-
const PATHOLOGY_PALETTE = [
|
|
746
|
-
[0, 0, 0],
|
|
747
|
-
[228, 158, 37],
|
|
748
|
-
[91, 181, 231],
|
|
749
|
-
[22, 157, 116],
|
|
750
|
-
[239, 226, 82],
|
|
751
|
-
[16, 115, 176],
|
|
752
|
-
[211, 94, 26],
|
|
753
|
-
[202, 122, 166]
|
|
754
|
-
];
|
|
755
|
-
const LARGE_PATHOLOGY_PALETTE = [
|
|
756
|
-
[0, 0, 0],
|
|
757
|
-
[0, 73, 73],
|
|
758
|
-
[0, 146, 146],
|
|
759
|
-
[255, 109, 182],
|
|
760
|
-
[255, 182, 219],
|
|
761
|
-
[73, 0, 146],
|
|
762
|
-
[0, 109, 219],
|
|
763
|
-
[182, 109, 255],
|
|
764
|
-
[109, 182, 255],
|
|
765
|
-
[182, 219, 255],
|
|
766
|
-
[146, 0, 0],
|
|
767
|
-
[146, 72, 0],
|
|
768
|
-
[219, 109, 0],
|
|
769
|
-
[36, 255, 36],
|
|
770
|
-
[255, 255, 109],
|
|
771
|
-
[255, 255, 255]
|
|
772
|
-
];
|
|
773
|
-
const COLORMAP_OPTIONS = [
|
|
774
|
-
"viridis",
|
|
775
|
-
"greys",
|
|
776
|
-
"magma",
|
|
777
|
-
"jet",
|
|
778
|
-
"hot",
|
|
779
|
-
"bone",
|
|
780
|
-
"copper",
|
|
781
|
-
"summer",
|
|
782
|
-
"density",
|
|
783
|
-
"inferno"
|
|
784
|
-
];
|
|
785
|
-
const DEFAULT_GL_OPTIONS = { webgl2: true };
|
|
786
|
-
function createDefaultUpdateStatus(componentName) {
|
|
787
|
-
return (message) => log.warn(`${componentName} updateStatus: ${message}`);
|
|
788
|
-
}
|
|
789
|
-
function createDefaultUpdateCellsSelection(componentName) {
|
|
790
|
-
return (cellsSelection) => log.warn(`${componentName} updateCellsSelection: ${cellsSelection}`);
|
|
791
|
-
}
|
|
792
|
-
function createDefaultUpdateCellsHover(componentName) {
|
|
793
|
-
return (hoverInfo) => log.warn(`${componentName} updateCellsHover: ${hoverInfo.cellId}`);
|
|
794
|
-
}
|
|
795
|
-
function createDefaultUpdateGenesHover(componentName) {
|
|
796
|
-
return (hoverInfo) => log.warn(`${componentName} updateGenesHover: ${hoverInfo.geneId}`);
|
|
797
|
-
}
|
|
798
|
-
function createDefaultUpdateTracksHover(componentName) {
|
|
799
|
-
return (hoverInfo) => log.warn(`${componentName} updateTracksHover: ${hoverInfo}`);
|
|
800
|
-
}
|
|
801
|
-
function createDefaultUpdateViewInfo(componentName) {
|
|
802
|
-
return (viewInfo) => log.warn(`${componentName} updateViewInfo: ${viewInfo}`);
|
|
803
|
-
}
|
|
804
|
-
function createDefaultClearPleaseWait() {
|
|
805
|
-
return () => {
|
|
806
|
-
};
|
|
807
|
-
}
|
|
808
|
-
function copyUint8Array(arr) {
|
|
809
|
-
const newBuffer = new ArrayBuffer(arr.buffer.byteLength);
|
|
810
|
-
const newArr = new Uint8Array(newBuffer);
|
|
811
|
-
newArr.set(arr);
|
|
812
|
-
return newArr;
|
|
813
|
-
}
|
|
814
|
-
function asEsModule(component) {
|
|
815
|
-
return {
|
|
816
|
-
__esModule: true,
|
|
817
|
-
default: component
|
|
818
|
-
};
|
|
819
|
-
}
|
|
820
|
-
function formatBytes(bytes, decimals = 2) {
|
|
821
|
-
if (bytes === 0) return "0 Bytes";
|
|
822
|
-
const k = 1024;
|
|
823
|
-
const dm = decimals < 0 ? 0 : decimals;
|
|
824
|
-
const sizes = ["Bytes", "KB", "MB", "GB"];
|
|
825
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
826
|
-
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
|
827
|
-
}
|
|
828
|
-
const VALUE_TRANSFORM_OPTIONS = [
|
|
829
|
-
{ name: "None", value: null },
|
|
830
|
-
{ name: "Log", value: "log1p" },
|
|
831
|
-
{ name: "ArcSinh", value: "arcsinh" }
|
|
832
|
-
];
|
|
833
|
-
function getValueTransformFunction(featureValueTransform, coefficient) {
|
|
834
|
-
let transformFunction;
|
|
835
|
-
switch (featureValueTransform) {
|
|
836
|
-
case "log1p":
|
|
837
|
-
transformFunction = (v) => Math.log(1 + v * coefficient);
|
|
838
|
-
break;
|
|
839
|
-
case "arcsinh":
|
|
840
|
-
transformFunction = (v) => Math.asinh(v * coefficient);
|
|
841
|
-
break;
|
|
842
|
-
default:
|
|
843
|
-
transformFunction = (v) => v;
|
|
844
|
-
}
|
|
845
|
-
return transformFunction;
|
|
846
|
-
}
|
|
847
|
-
const defaultPoolSize = typeof navigator !== "undefined" ? navigator.hardwareConcurrency || 4 : 1;
|
|
848
|
-
class Pool {
|
|
849
|
-
workers;
|
|
850
|
-
idleWorkers;
|
|
851
|
-
waitQueue;
|
|
852
|
-
/**
|
|
853
|
-
* @constructor
|
|
854
|
-
* @param {object} Worker The worker class to be used for processing.
|
|
855
|
-
*/
|
|
856
|
-
constructor(createWorker) {
|
|
857
|
-
this.workers = [];
|
|
858
|
-
this.idleWorkers = [];
|
|
859
|
-
this.waitQueue = [];
|
|
860
|
-
for (let i = 0; i < defaultPoolSize; ++i) {
|
|
861
|
-
const w = createWorker();
|
|
862
|
-
this.workers.push(w);
|
|
863
|
-
this.idleWorkers.push(w);
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
// eslint-disable-next-line class-methods-use-this
|
|
867
|
-
async process() {
|
|
868
|
-
throw new Error('Pool needs to implement "process" method');
|
|
869
|
-
}
|
|
870
|
-
async waitForWorker() {
|
|
871
|
-
const idleWorker = this.idleWorkers.pop();
|
|
872
|
-
if (idleWorker) {
|
|
873
|
-
return idleWorker;
|
|
874
|
-
}
|
|
875
|
-
const waiter = {};
|
|
876
|
-
const promise = new Promise((resolve) => {
|
|
877
|
-
waiter.resolve = resolve;
|
|
878
|
-
});
|
|
879
|
-
this.waitQueue.push(waiter);
|
|
880
|
-
return promise;
|
|
881
|
-
}
|
|
882
|
-
async finishTask(currentWorker) {
|
|
883
|
-
const waiter = this.waitQueue.pop();
|
|
884
|
-
if (waiter && waiter.resolve) {
|
|
885
|
-
waiter.resolve(currentWorker);
|
|
886
|
-
} else {
|
|
887
|
-
this.idleWorkers.push(currentWorker);
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
destroy() {
|
|
891
|
-
for (let i = 0; i < this.workers.length; ++i) {
|
|
892
|
-
this.workers[i].terminate();
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
function extent(values, valueof) {
|
|
897
|
-
let min;
|
|
898
|
-
let max;
|
|
899
|
-
{
|
|
900
|
-
for (const value of values) {
|
|
901
|
-
if (value != null) {
|
|
902
|
-
if (min === void 0) {
|
|
903
|
-
if (value >= value) min = max = value;
|
|
904
|
-
} else {
|
|
905
|
-
if (min > value) min = value;
|
|
906
|
-
if (max < value) max = value;
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
return [min, max];
|
|
912
|
-
}
|
|
913
|
-
function aggregateFeatureArrays(arrays, strategy) {
|
|
914
|
-
if (!arrays || arrays.length === 0) return null;
|
|
915
|
-
let targetArray;
|
|
916
|
-
if (strategy === "first" || typeof strategy === "number" && strategy === 0) {
|
|
917
|
-
targetArray = arrays[0];
|
|
918
|
-
} else if (strategy === "last") {
|
|
919
|
-
targetArray = arrays[arrays.length - 1];
|
|
920
|
-
} else if (typeof strategy === "number") {
|
|
921
|
-
if (strategy >= 0 && strategy < arrays.length) {
|
|
922
|
-
targetArray = arrays[strategy];
|
|
923
|
-
} else {
|
|
924
|
-
throw new Error(`Array index out of bounds: ${strategy}`);
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
if (targetArray) {
|
|
928
|
-
return targetArray;
|
|
929
|
-
}
|
|
930
|
-
const numArrays = arrays.length;
|
|
931
|
-
const firstArrayLength = arrays[0].length;
|
|
932
|
-
if (arrays.some((arr) => arr.length !== firstArrayLength)) {
|
|
933
|
-
throw new Error("All arrays must have the same length for aggregation.");
|
|
934
|
-
}
|
|
935
|
-
if (strategy === "sum" || strategy === "mean") {
|
|
936
|
-
const resultArray = new Float64Array(firstArrayLength);
|
|
937
|
-
for (let i = 0; i < numArrays; i++) {
|
|
938
|
-
const arr = arrays[i];
|
|
939
|
-
for (let j = 0; j < firstArrayLength; j++) {
|
|
940
|
-
resultArray[j] += arr[j];
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
if (strategy === "mean") {
|
|
944
|
-
for (let i = 0; i < firstArrayLength; i++) {
|
|
945
|
-
resultArray[i] /= numArrays;
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
return Array.from(resultArray);
|
|
949
|
-
}
|
|
950
|
-
if (strategy === "difference") {
|
|
951
|
-
if (numArrays !== 2) {
|
|
952
|
-
console.warn("Difference strategy requires exactly 2 arrays.");
|
|
953
|
-
return arrays[0];
|
|
954
|
-
}
|
|
955
|
-
const arr0 = arrays[0];
|
|
956
|
-
const arr1 = arrays[1];
|
|
957
|
-
const resultArray = new Float64Array(firstArrayLength);
|
|
958
|
-
for (let i = 0; i < firstArrayLength; i++) {
|
|
959
|
-
resultArray[i] = arr0[i] - arr1[i];
|
|
960
|
-
}
|
|
961
|
-
return Array.from(resultArray);
|
|
962
|
-
}
|
|
963
|
-
throw new Error(`Unknown aggregation strategy: ${strategy}`);
|
|
964
|
-
}
|
|
965
|
-
function normalizeAggregatedFeatureArray(values) {
|
|
966
|
-
if (!values || values.length === 0) {
|
|
967
|
-
return null;
|
|
968
|
-
}
|
|
969
|
-
const [min, max] = extent(values);
|
|
970
|
-
if (min == null || max == null) {
|
|
971
|
-
return null;
|
|
972
|
-
}
|
|
973
|
-
const ratio = max > min ? 255 / (max - min) : 1;
|
|
974
|
-
const normData = new Uint8Array(values.length);
|
|
975
|
-
for (let i = 0; i < values.length; i += 1) {
|
|
976
|
-
const normalized = max > min ? Math.floor((values[i] - min) * ratio) : 0;
|
|
977
|
-
normData[i] = Number.isFinite(normalized) ? Math.max(0, Math.min(255, normalized)) : 0;
|
|
978
|
-
}
|
|
979
|
-
return { normData, extent: [min, max] };
|
|
980
|
-
}
|
|
981
|
-
function filterValidExpressionArrays(arrays) {
|
|
982
|
-
if (!arrays) {
|
|
983
|
-
return [];
|
|
984
|
-
}
|
|
985
|
-
return arrays.filter((arr) => arr && (Array.isArray(arr) || ArrayBuffer.isView(arr)) && arr.length > 0);
|
|
986
|
-
}
|
|
987
|
-
export {
|
|
988
|
-
COLORMAP_OPTIONS,
|
|
989
|
-
DEFAULT_DARK_COLOR,
|
|
990
|
-
DEFAULT_GL_OPTIONS,
|
|
991
|
-
DEFAULT_LIGHT_COLOR,
|
|
992
|
-
LARGE_PATHOLOGY_PALETTE,
|
|
993
|
-
PALETTE,
|
|
994
|
-
PATHOLOGY_PALETTE,
|
|
995
|
-
Pool,
|
|
996
|
-
VALUE_TRANSFORM_OPTIONS,
|
|
997
|
-
VIEWER_PALETTE,
|
|
998
|
-
aggregateFeatureArrays,
|
|
999
|
-
asEsModule,
|
|
1000
|
-
capitalize,
|
|
1001
|
-
cleanFeatureId,
|
|
1002
|
-
commaNumber,
|
|
1003
|
-
copyUint8Array,
|
|
1004
|
-
createDefaultClearPleaseWait,
|
|
1005
|
-
createDefaultUpdateCellsHover,
|
|
1006
|
-
createDefaultUpdateCellsSelection,
|
|
1007
|
-
createDefaultUpdateGenesHover,
|
|
1008
|
-
createDefaultUpdateStatus,
|
|
1009
|
-
createDefaultUpdateTracksHover,
|
|
1010
|
-
createDefaultUpdateViewInfo,
|
|
1011
|
-
createPrefixedGetNextScopeNumeric,
|
|
1012
|
-
filterValidExpressionArrays,
|
|
1013
|
-
formatBytes,
|
|
1014
|
-
getDefaultColor,
|
|
1015
|
-
getDefaultForegroundColor,
|
|
1016
|
-
getInitialCoordinationScopeName,
|
|
1017
|
-
getInitialCoordinationScopePrefix,
|
|
1018
|
-
getLongestString,
|
|
1019
|
-
getNextScope,
|
|
1020
|
-
getNextScopeNumeric,
|
|
1021
|
-
getValueTransformFunction,
|
|
1022
|
-
normalizeAggregatedFeatureArray,
|
|
1023
|
-
pluralize,
|
|
1024
|
-
unnestMap
|
|
1025
|
-
};
|