@luckydye/calendar 1.3.1 → 1.4.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.
- package/dist/calendar.js +2777 -2010
- package/package.json +7 -1
- package/src/ActiveCalendarStore.ts +88 -88
- package/src/CalDAVConfig.ts +611 -514
- package/src/CalDAVSource.ts +561 -433
- package/src/CalendarIntegration.ts +64 -47
- package/src/CalendarInternal.ts +645 -613
- package/src/CalendarLayer.ts +1 -0
- package/src/CalendarStorage.ts +51 -48
- package/src/CalendarView.ts +1085 -505
- package/src/Color.ts +48 -54
- package/src/DescriptionSanitizer.ts +10 -0
- package/src/GoogleCalendarSource.ts +758 -661
- package/src/ICal.ts +420 -343
- package/src/InMemorySource.ts +56 -48
- package/src/IndexedDBStorage.ts +444 -395
- package/src/InhouseBookingSource.ts +614 -522
- package/src/Keybinds.ts +6 -1
- package/src/NotificationScheduler.ts +11 -8
- package/src/StatusBar.ts +12 -8
- package/src/StatusMessage.ts +2 -2
- package/src/Theme.ts +21 -7
- package/src/TimeseriesJson.ts +98 -98
- package/src/app.ts +301 -115
- package/src/layers/EventsLayer.ts +530 -400
- package/src/layers/GridLayer.ts +45 -125
- package/src/layers/TimeseriesHeatmapLayer.ts +123 -120
- package/src/service-worker.js +3 -2
package/src/Color.ts
CHANGED
|
@@ -1,64 +1,58 @@
|
|
|
1
|
-
|
|
2
1
|
function componentToHex(c) {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
const hex = c.toString(16);
|
|
3
|
+
return hex.length === 1 ? `0${hex}` : hex;
|
|
5
4
|
}
|
|
6
5
|
|
|
7
6
|
export function rgbToHex(r, g, b) {
|
|
8
|
-
|
|
7
|
+
return `#${componentToHex(r)}${componentToHex(g)}${componentToHex(b)}`;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
export function hexToRgb(hex: string) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
return [
|
|
12
|
+
Number.parseInt(`${hex[1]}${hex[2]}`, 16),
|
|
13
|
+
Number.parseInt(`${hex[3]}${hex[4]}`, 16),
|
|
14
|
+
Number.parseInt(`${hex[5]}${hex[6]}`, 16),
|
|
15
|
+
] as [number, number, number];
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
export function rgbToHsl([r,g,b]) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// Multiply l and s by 100
|
|
60
|
-
s = +(s * 100).toFixed(1);
|
|
61
|
-
l = +(l * 100).toFixed(1);
|
|
62
|
-
|
|
63
|
-
return [h, s, l];
|
|
18
|
+
export function rgbToHsl([r, g, b]) {
|
|
19
|
+
// Make r, g, and b fractions of 1
|
|
20
|
+
r /= 255;
|
|
21
|
+
g /= 255;
|
|
22
|
+
b /= 255;
|
|
23
|
+
|
|
24
|
+
// Find greatest and smallest channel values
|
|
25
|
+
const cmin = Math.min(r, g, b);
|
|
26
|
+
const cmax = Math.max(r, g, b);
|
|
27
|
+
const delta = cmax - cmin;
|
|
28
|
+
let h = 0;
|
|
29
|
+
let s = 0;
|
|
30
|
+
let l = 0;
|
|
31
|
+
|
|
32
|
+
// Calculate hue
|
|
33
|
+
// No difference
|
|
34
|
+
if (delta === 0) h = 0;
|
|
35
|
+
// Red is max
|
|
36
|
+
else if (cmax === r) h = ((g - b) / delta) % 6;
|
|
37
|
+
// Green is max
|
|
38
|
+
else if (cmax === g) h = (b - r) / delta + 2;
|
|
39
|
+
// Blue is max
|
|
40
|
+
else h = (r - g) / delta + 4;
|
|
41
|
+
|
|
42
|
+
h = Math.round(h * 60);
|
|
43
|
+
|
|
44
|
+
// Make negative hues positive behind 360°
|
|
45
|
+
if (h < 0) h += 360;
|
|
46
|
+
|
|
47
|
+
// Calculate lightness
|
|
48
|
+
l = (cmax + cmin) / 2;
|
|
49
|
+
|
|
50
|
+
// Calculate saturation
|
|
51
|
+
s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
|
|
52
|
+
|
|
53
|
+
// Multiply l and s by 100
|
|
54
|
+
s = +(s * 100).toFixed(1);
|
|
55
|
+
l = +(l * 100).toFixed(1);
|
|
56
|
+
|
|
57
|
+
return [h, s, l];
|
|
64
58
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes transport/tracking links commonly injected by email/calendar clients.
|
|
3
|
+
* First pass intentionally targets angle-bracket URI blobs like
|
|
4
|
+
* <https://...>, <mailto:...>, <tel:...>, <im:...>.
|
|
5
|
+
*/
|
|
6
|
+
export function sanitizeEventDescription(input: string): string {
|
|
7
|
+
if (!input) return input;
|
|
8
|
+
|
|
9
|
+
return input.replace(/<(?:https?|mailto|tel|im):[^>\s]+>/gi, "");
|
|
10
|
+
}
|