@jbrowse/core 4.0.3 → 4.1.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.
Files changed (52) hide show
  1. package/esm/BaseFeatureWidget/BaseFeatureDetail/ArrayValue.js +10 -1
  2. package/esm/PluginLoader.js +11 -9
  3. package/esm/pluggableElementTypes/RpcMethodType.d.ts +1 -0
  4. package/esm/pluggableElementTypes/RpcMethodType.js +49 -5
  5. package/esm/pluggableElementTypes/RpcMethodTypeWithFiltersAndRenameRegions.js +1 -0
  6. package/esm/pluggableElementTypes/models/BaseDisplayModel.d.ts +3 -0
  7. package/esm/pluggableElementTypes/models/BaseDisplayModel.js +4 -1
  8. package/esm/pluggableElementTypes/models/saveTrackFileTypes/bed.js +5 -2
  9. package/esm/pluggableElementTypes/models/saveTrackFileTypes/genbank.js +57 -26
  10. package/esm/pluggableElementTypes/models/saveTrackFileTypes/gff3.js +35 -16
  11. package/esm/pluggableElementTypes/renderers/LayoutSession.js +6 -3
  12. package/esm/pluggableElementTypes/renderers/ServerSideRendererType.js +4 -1
  13. package/esm/pluggableElementTypes/renderers/util/serializableFilterChain.d.ts +2 -1
  14. package/esm/pluggableElementTypes/renderers/util/serializableFilterChain.js +2 -2
  15. package/esm/rpc/methods/CoreRender.js +7 -2
  16. package/esm/ui/CascadingMenu.js +10 -2
  17. package/esm/ui/FileSelector/FileSelector.d.ts +0 -1
  18. package/esm/ui/FileSelector/FileSelector.js +19 -31
  19. package/esm/ui/FileSelector/LocalFileChooser.js +90 -26
  20. package/esm/ui/FileSelector/SourceTypeSelector.js +18 -33
  21. package/esm/ui/FileSelector/util.d.ts +8 -0
  22. package/esm/ui/FileSelector/util.js +34 -0
  23. package/esm/ui/HoverMenu.d.ts +1 -1
  24. package/esm/ui/SnackbarContents.js +4 -4
  25. package/esm/ui/SnackbarModel.d.ts +4 -4
  26. package/esm/ui/SnackbarModel.js +18 -7
  27. package/esm/ui/index.d.ts +1 -1
  28. package/esm/ui/index.js +1 -1
  29. package/esm/util/IntervalTree.d.ts +42 -0
  30. package/esm/util/IntervalTree.js +257 -0
  31. package/esm/util/colord.d.ts +22 -8
  32. package/esm/util/colord.js +227 -10
  33. package/esm/util/crypto.d.ts +7 -0
  34. package/esm/util/crypto.js +536 -0
  35. package/esm/util/fileHandleStore.d.ts +6 -0
  36. package/esm/util/fileHandleStore.js +68 -0
  37. package/esm/util/idMaker.js +9 -1
  38. package/esm/util/index.d.ts +3 -0
  39. package/esm/util/index.js +3 -0
  40. package/esm/util/io/index.js +11 -1
  41. package/esm/util/jexl.js +1 -0
  42. package/esm/util/tracks.d.ts +41 -7
  43. package/esm/util/tracks.js +141 -9
  44. package/esm/util/types/ElementId.d.ts +1 -0
  45. package/esm/util/types/ElementId.js +4 -1
  46. package/esm/util/types/index.d.ts +11 -4
  47. package/esm/util/types/index.js +6 -0
  48. package/esm/util/types/mst.d.ts +18 -1
  49. package/esm/util/types/mst.js +11 -3
  50. package/package.json +356 -21
  51. package/esm/ui/FileSelector/index.d.ts +0 -1
  52. package/esm/ui/FileSelector/index.js +0 -1
@@ -1,9 +1,23 @@
1
- import { colord as colordOriginal } from 'colord';
2
- import type { AnyColor, Colord as ColordBase } from 'colord';
3
- export interface Colord extends ColordBase {
4
- mix(color2: AnyColor | Colord, ratio?: number): Colord;
5
- tints(count?: number): Colord[];
6
- shades(count?: number): Colord[];
7
- tones(count?: number): Colord[];
1
+ interface HSLA {
2
+ h: number;
3
+ s: number;
4
+ l: number;
5
+ a: number;
8
6
  }
9
- export declare function colord(input: Parameters<typeof colordOriginal>[0]): Colord;
7
+ export interface Colord {
8
+ alpha(): number;
9
+ alpha(value: number): Colord;
10
+ toHex(): string;
11
+ toRgbString(): string;
12
+ toHsl(): HSLA;
13
+ toHslString(): string;
14
+ mix(color: Colord | string, ratio?: number): Colord;
15
+ darken(amount?: number): Colord;
16
+ lighten(amount?: number): Colord;
17
+ }
18
+ export declare function colord(input: string | {
19
+ h: number;
20
+ s: number;
21
+ l: number;
22
+ }): Colord;
23
+ export {};
@@ -1,14 +1,231 @@
1
- import { colord as colordOriginal, extend } from 'colord';
2
- import mix from 'colord/plugins/mix';
3
- import names from 'colord/plugins/names';
4
- let initialized = false;
5
- function ensurePlugins() {
6
- if (!initialized) {
7
- extend([mix, names]);
8
- initialized = true;
1
+ import { namedColorToHex } from "./color/cssColorsLevel4.js";
2
+ function clamp(value, min, max) {
3
+ return Math.max(min, Math.min(max, value));
4
+ }
5
+ function round(value, precision = 0) {
6
+ const mult = 10 ** precision;
7
+ return Math.round(value * mult) / mult;
8
+ }
9
+ function parseHex(hex) {
10
+ const match = /^#([0-9a-f]{3,8})$/i.exec(hex);
11
+ if (!match) {
12
+ return null;
13
+ }
14
+ const hexStr = match[1];
15
+ if (hexStr.length === 3) {
16
+ return {
17
+ r: parseInt(hexStr[0] + hexStr[0], 16),
18
+ g: parseInt(hexStr[1] + hexStr[1], 16),
19
+ b: parseInt(hexStr[2] + hexStr[2], 16),
20
+ a: 1,
21
+ };
22
+ }
23
+ if (hexStr.length === 4) {
24
+ return {
25
+ r: parseInt(hexStr[0] + hexStr[0], 16),
26
+ g: parseInt(hexStr[1] + hexStr[1], 16),
27
+ b: parseInt(hexStr[2] + hexStr[2], 16),
28
+ a: parseInt(hexStr[3] + hexStr[3], 16) / 255,
29
+ };
30
+ }
31
+ if (hexStr.length === 6) {
32
+ return {
33
+ r: parseInt(hexStr.slice(0, 2), 16),
34
+ g: parseInt(hexStr.slice(2, 4), 16),
35
+ b: parseInt(hexStr.slice(4, 6), 16),
36
+ a: 1,
37
+ };
38
+ }
39
+ if (hexStr.length === 8) {
40
+ return {
41
+ r: parseInt(hexStr.slice(0, 2), 16),
42
+ g: parseInt(hexStr.slice(2, 4), 16),
43
+ b: parseInt(hexStr.slice(4, 6), 16),
44
+ a: parseInt(hexStr.slice(6, 8), 16) / 255,
45
+ };
46
+ }
47
+ return null;
48
+ }
49
+ function parseRgb(str) {
50
+ const match = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/i.exec(str);
51
+ if (match) {
52
+ return {
53
+ r: parseInt(match[1], 10),
54
+ g: parseInt(match[2], 10),
55
+ b: parseInt(match[3], 10),
56
+ a: match[4] ? parseFloat(match[4]) : 1,
57
+ };
58
+ }
59
+ return null;
60
+ }
61
+ function parseHsl(str) {
62
+ const match = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%\s*(?:,\s*([\d.]+)\s*)?\)$/i.exec(str);
63
+ if (match) {
64
+ const h = parseFloat(match[1]);
65
+ const s = parseFloat(match[2]) / 100;
66
+ const l = parseFloat(match[3]) / 100;
67
+ const a = match[4] ? parseFloat(match[4]) : 1;
68
+ return { ...hslToRgb(h, s, l), a };
69
+ }
70
+ return null;
71
+ }
72
+ function hslToRgb(h, s, l) {
73
+ h = ((h % 360) + 360) % 360;
74
+ const c = (1 - Math.abs(2 * l - 1)) * s;
75
+ const x = c * (1 - Math.abs(((h / 60) % 2) - 1));
76
+ const m = l - c / 2;
77
+ let r = 0;
78
+ let g = 0;
79
+ let b = 0;
80
+ if (h < 60) {
81
+ r = c;
82
+ g = x;
83
+ }
84
+ else if (h < 120) {
85
+ r = x;
86
+ g = c;
87
+ }
88
+ else if (h < 180) {
89
+ g = c;
90
+ b = x;
91
+ }
92
+ else if (h < 240) {
93
+ g = x;
94
+ b = c;
95
+ }
96
+ else if (h < 300) {
97
+ r = x;
98
+ b = c;
9
99
  }
100
+ else {
101
+ r = c;
102
+ b = x;
103
+ }
104
+ return {
105
+ r: Math.round((r + m) * 255),
106
+ g: Math.round((g + m) * 255),
107
+ b: Math.round((b + m) * 255),
108
+ };
109
+ }
110
+ function rgbToHsl(r, g, b) {
111
+ r /= 255;
112
+ g /= 255;
113
+ b /= 255;
114
+ const max = Math.max(r, g, b);
115
+ const min = Math.min(r, g, b);
116
+ const l = (max + min) / 2;
117
+ if (max === min) {
118
+ return { h: 0, s: 0, l };
119
+ }
120
+ const d = max - min;
121
+ const s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
122
+ let h = 0;
123
+ if (max === r) {
124
+ h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
125
+ }
126
+ else if (max === g) {
127
+ h = ((b - r) / d + 2) / 6;
128
+ }
129
+ else {
130
+ h = ((r - g) / d + 4) / 6;
131
+ }
132
+ return { h: h * 360, s, l };
133
+ }
134
+ function parseColor(input) {
135
+ if (typeof input === 'object') {
136
+ const { h, s, l } = input;
137
+ return { ...hslToRgb(h, s / 100, l / 100), a: 1 };
138
+ }
139
+ const str = input.trim().toLowerCase();
140
+ const namedHex = namedColorToHex(str);
141
+ if (namedHex) {
142
+ return parseHex(namedHex);
143
+ }
144
+ if (str === 'transparent') {
145
+ return { r: 0, g: 0, b: 0, a: 0 };
146
+ }
147
+ const hex = parseHex(str);
148
+ if (hex) {
149
+ return hex;
150
+ }
151
+ const rgb = parseRgb(str);
152
+ if (rgb) {
153
+ return rgb;
154
+ }
155
+ const hsl = parseHsl(str);
156
+ if (hsl) {
157
+ return hsl;
158
+ }
159
+ return { r: 0, g: 0, b: 0, a: 1 };
160
+ }
161
+ function toHex2(n) {
162
+ return Math.round(clamp(n, 0, 255))
163
+ .toString(16)
164
+ .padStart(2, '0');
165
+ }
166
+ function createColord(rgba) {
167
+ const obj = {
168
+ alpha(value) {
169
+ if (value === undefined) {
170
+ return rgba.a;
171
+ }
172
+ return createColord({ ...rgba, a: clamp(value, 0, 1) });
173
+ },
174
+ toHex() {
175
+ const { r, g, b, a } = rgba;
176
+ if (a < 1) {
177
+ return `#${toHex2(r)}${toHex2(g)}${toHex2(b)}${toHex2(a * 255)}`;
178
+ }
179
+ return `#${toHex2(r)}${toHex2(g)}${toHex2(b)}`;
180
+ },
181
+ toRgbString() {
182
+ const { r, g, b, a } = rgba;
183
+ if (a < 1) {
184
+ return `rgba(${Math.round(r)}, ${Math.round(g)}, ${Math.round(b)}, ${round(a, 3)})`;
185
+ }
186
+ return `rgb(${Math.round(r)}, ${Math.round(g)}, ${Math.round(b)})`;
187
+ },
188
+ toHsl() {
189
+ const { h, s, l } = rgbToHsl(rgba.r, rgba.g, rgba.b);
190
+ return {
191
+ h: round(h, 1),
192
+ s: round(s * 100, 1),
193
+ l: round(l * 100, 1),
194
+ a: rgba.a,
195
+ };
196
+ },
197
+ toHslString() {
198
+ const { h, s, l } = rgbToHsl(rgba.r, rgba.g, rgba.b);
199
+ if (rgba.a < 1) {
200
+ return `hsla(${round(h, 1)}, ${round(s * 100, 1)}%, ${round(l * 100, 1)}%, ${round(rgba.a, 3)})`;
201
+ }
202
+ return `hsl(${round(h, 1)}, ${round(s * 100, 1)}%, ${round(l * 100, 1)}%)`;
203
+ },
204
+ mix(color2, ratio = 0.5) {
205
+ const c2 = typeof color2 === 'string'
206
+ ? parseColor(color2)
207
+ : parseColor(color2.toHex());
208
+ const r = rgba.r + (c2.r - rgba.r) * ratio;
209
+ const g = rgba.g + (c2.g - rgba.g) * ratio;
210
+ const b = rgba.b + (c2.b - rgba.b) * ratio;
211
+ const a = rgba.a + (c2.a - rgba.a) * ratio;
212
+ return createColord({ r, g, b, a });
213
+ },
214
+ darken(amount = 0.1) {
215
+ const { h, s, l } = rgbToHsl(rgba.r, rgba.g, rgba.b);
216
+ const newL = clamp(l - amount, 0, 1);
217
+ const rgb = hslToRgb(h, s, newL);
218
+ return createColord({ ...rgb, a: rgba.a });
219
+ },
220
+ lighten(amount = 0.1) {
221
+ const { h, s, l } = rgbToHsl(rgba.r, rgba.g, rgba.b);
222
+ const newL = clamp(l + amount, 0, 1);
223
+ const rgb = hslToRgb(h, s, newL);
224
+ return createColord({ ...rgb, a: rgba.a });
225
+ },
226
+ };
227
+ return obj;
10
228
  }
11
229
  export function colord(input) {
12
- ensurePlugins();
13
- return colordOriginal(input);
230
+ return createColord(parseColor(input));
14
231
  }
@@ -0,0 +1,7 @@
1
+ export declare function aesEncrypt(plaintext: string, password: string): Promise<string>;
2
+ export declare function aesDecrypt(ciphertext: string, password: string): Promise<string>;
3
+ export declare function sha256(data: string): Promise<Uint8Array>;
4
+ export declare function toBase64(data: Uint8Array): string;
5
+ export declare function toBase64Url(data: Uint8Array): string;
6
+ export declare function sha256Base64(data: string): Promise<string>;
7
+ export declare function sha256Base64Url(data: string): Promise<string>;