@luckydye/calendar 1.1.1 → 1.1.3
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 +1387 -1301
- package/package.json +4 -3
- package/src/ActiveCalendarStore.ts +96 -0
- package/src/CalDAVConfig.ts +1025 -0
- package/src/CalDAVSource.ts +506 -0
- package/src/CalendarIntegration.ts +67 -0
- package/src/CalendarInternal.ts +628 -0
- package/src/CalendarStorage.ts +54 -0
- package/src/CalendarView.ts +5507 -0
- package/src/Color.ts +64 -0
- package/src/GoogleCalendarSource.ts +710 -0
- package/src/ICal.ts +400 -0
- package/src/InMemorySource.ts +74 -0
- package/src/IndexedDBStorage.ts +393 -0
- package/src/InhouseBookingSource.ts +522 -0
- package/src/Keybinds.ts +46 -0
- package/src/NotificationScheduler.ts +91 -0
- package/src/StatusBar.ts +128 -0
- package/src/StatusMessage.ts +122 -0
- package/src/Theme.ts +228 -0
- package/src/app.css +32 -0
- package/src/app.ts +1042 -0
- package/src/lib.ts +4 -0
- package/src/service-worker.js +177 -0
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luckydye/calendar",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"author": "Tim Havlicek",
|
|
5
5
|
"contributors": [],
|
|
6
6
|
"description": "",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"main": "dist/
|
|
9
|
-
"types": "src/
|
|
8
|
+
"main": "dist/calendar.js",
|
|
9
|
+
"types": "src/calendar.ts",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build:app": "APP=true bunx --bun vite build --outDir=dist/calendar --base=./",
|
|
12
12
|
"build": "bunx --bun vite build",
|
|
13
13
|
"dev": "bunx --bun vite dev"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
|
+
"src",
|
|
16
17
|
"dist"
|
|
17
18
|
],
|
|
18
19
|
"dependencies": {},
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { Calendar } from "./CalendarIntegration.js";
|
|
2
|
+
|
|
3
|
+
const STORAGE_KEY = "active-calendar-id";
|
|
4
|
+
|
|
5
|
+
export class ActiveCalendarStore {
|
|
6
|
+
private calendars: Map<string, Calendar> = new Map();
|
|
7
|
+
private activeId: string | null = null;
|
|
8
|
+
private listeners: Set<(id: string | null) => void> = new Set();
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
this.loadFromStorage();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
private loadFromStorage(): void {
|
|
15
|
+
const saved = localStorage.getItem(STORAGE_KEY);
|
|
16
|
+
if (saved) {
|
|
17
|
+
this.activeId = saved;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private saveToStorage(): void {
|
|
22
|
+
if (this.activeId) {
|
|
23
|
+
localStorage.setItem(STORAGE_KEY, this.activeId);
|
|
24
|
+
} else {
|
|
25
|
+
localStorage.removeItem(STORAGE_KEY);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
registerCalendar(calendar: Calendar): void {
|
|
30
|
+
this.calendars.set(calendar.id, calendar);
|
|
31
|
+
|
|
32
|
+
if (!this.activeId) {
|
|
33
|
+
this.setActive(calendar.id);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
unregisterCalendar(id: string): void {
|
|
38
|
+
this.calendars.delete(id);
|
|
39
|
+
|
|
40
|
+
if (this.activeId === id) {
|
|
41
|
+
const firstEnabled = this.getAvailableCalendars()[0];
|
|
42
|
+
this.setActive(firstEnabled?.id ?? null);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
unregisterCalendarsBySource(sourceId: string): void {
|
|
47
|
+
for (const [id, calendar] of this.calendars) {
|
|
48
|
+
if (calendar.sourceId === sourceId) {
|
|
49
|
+
this.calendars.delete(id);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (this.activeId && !this.calendars.has(this.activeId)) {
|
|
54
|
+
const firstEnabled = this.getAvailableCalendars()[0];
|
|
55
|
+
this.setActive(firstEnabled?.id ?? null);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
getAvailableCalendars(): Calendar[] {
|
|
60
|
+
return Array.from(this.calendars.values());
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getActiveCalendar(): Calendar | null {
|
|
64
|
+
if (!this.activeId) return null;
|
|
65
|
+
return this.calendars.get(this.activeId) ?? null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
getActiveId(): string | null {
|
|
69
|
+
return this.activeId;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
setActive(id: string | null): void {
|
|
73
|
+
if (id && !this.calendars.has(id)) {
|
|
74
|
+
throw new Error(`Calendar ${id} not found`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
this.activeId = id;
|
|
78
|
+
this.saveToStorage();
|
|
79
|
+
for (const listener of this.listeners) {
|
|
80
|
+
listener(id);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
subscribe(listener: (id: string | null) => void): () => void {
|
|
85
|
+
this.listeners.add(listener);
|
|
86
|
+
return () => this.listeners.delete(listener);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
clear(): void {
|
|
90
|
+
this.calendars.clear();
|
|
91
|
+
this.activeId = null;
|
|
92
|
+
localStorage.removeItem(STORAGE_KEY);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export const activeCalendarStore = new ActiveCalendarStore();
|