@hkdigital/lib-sveltekit 0.1.74 → 0.1.75

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.
@@ -1,6 +1,5 @@
1
1
 
2
2
  export { default as MemoryResponseCache } from "./MemoryResponseCache.js";
3
- // export { default as PersistentResponseCache } from "./PersistentResponseCache.js";
4
3
  export { default as IndexedDbCache } from "./IndexedDbCache.js";
5
4
 
6
5
  export * from './typedef.js';
@@ -289,7 +289,9 @@ export class PresenterState {
289
289
  }
290
290
 
291
291
  if (slide.name === this.currentSlideName) {
292
- throw new Error(`gotoSlide cannot transition to current slide`);
292
+ //throw new Error(`gotoSlide cannot transition to current slide`);
293
+ console.error(`gotoSlide cannot transition to current slide`);
294
+ return;
293
295
  }
294
296
 
295
297
  this.nextSlideName = slide.name;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-sveltekit",
3
- "version": "0.1.74",
3
+ "version": "0.1.75",
4
4
  "author": {
5
5
  "name": "HKdigital",
6
6
  "url": "https://hkdigital.nl"
@@ -1,45 +0,0 @@
1
- /**
2
- * @typedef {Object} CacheEntry
3
- * @property {Response} response The cached response
4
- * @property {Object} metadata Cache metadata including expiration
5
- * @property {string} url The request URL
6
- * @property {number} timestamp When the entry was cached
7
- * @property {number|null} expires When the entry expires
8
- * @property {string|null} etag ETag for conditional requests
9
- * @property {string|null} lastModified Last-Modified for conditional requests
10
- */
11
-
12
- /**
13
- * Cache Storage Interface
14
- * @interface
15
- */
16
- class CacheStorage {
17
- /**
18
- * Get a cached response for a key
19
- * @param {string} key Cache key
20
- * @returns {Promise<CacheEntry|null>} Cached response or null if not found
21
- */
22
- async get(key) { throw new Error('Not implemented'); }
23
-
24
- /**
25
- * Store a response in the cache
26
- * @param {string} key Cache key
27
- * @param {Response} response Response to cache
28
- * @param {Object} metadata Cache metadata
29
- * @returns {Promise<void>}
30
- */
31
- async set(key, response, metadata) { throw new Error('Not implemented'); }
32
-
33
- /**
34
- * Remove a cached response
35
- * @param {string} key Cache key
36
- * @returns {Promise<boolean>} True if entry was removed
37
- */
38
- async delete(key) { throw new Error('Not implemented'); }
39
-
40
- /**
41
- * Clear all cached responses
42
- * @returns {Promise<void>}
43
- */
44
- async clear() { throw new Error('Not implemented'); }
45
- }
@@ -1,165 +0,0 @@
1
-
2
-
3
- /**
4
- * ReponseCache
5
- * Using IndexedDB for persistent storage
6
- */
7
- export default class ResponseCache {
8
- /**
9
- * Create a new IndexedDB cache storage
10
- * @param {string} dbName Database name
11
- * @param {string} storeName Store name
12
- */
13
- constructor(dbName = 'http-cache', storeName = 'responses') {
14
- this.dbName = dbName;
15
- this.storeName = storeName;
16
- this.dbPromise = this._openDatabase();
17
- }
18
-
19
- /**
20
- * Open the IndexedDB database
21
- * @private
22
- * @returns {Promise<IDBDatabase>}
23
- */
24
- async _openDatabase() {
25
- return new Promise((resolve, reject) => {
26
- const request = indexedDB.open(this.dbName, 1);
27
-
28
- request.onerror = () => reject(request.error);
29
- request.onsuccess = () => resolve(request.result);
30
-
31
- request.onupgradeneeded = (event) => {
32
- const db = event.target.result;
33
- if (!db.objectStoreNames.contains(this.storeName)) {
34
- db.createObjectStore(this.storeName, { keyPath: 'key' });
35
- }
36
- };
37
- });
38
- }
39
-
40
- /**
41
- * Get a cached response
42
- * @param {string} key Cache key
43
- * @returns {Promise<import('./typedef').CacheEntry|null>}
44
- */
45
- async get(key) {
46
- const db = await this.dbPromise;
47
-
48
- return new Promise((resolve, reject) => {
49
- const transaction = db.transaction(this.storeName, 'readonly');
50
- const store = transaction.objectStore(this.storeName);
51
- const request = store.get(key);
52
-
53
- request.onerror = () => reject(request.error);
54
- request.onsuccess = () => {
55
- const entry = request.result;
56
-
57
- if (!entry) {
58
- resolve(null);
59
- return;
60
- }
61
-
62
- // Check if expired
63
- if (entry.expires && Date.now() > entry.expires) {
64
- // Delete expired entry
65
- this.delete(key).catch(console.error);
66
- resolve(null);
67
- return;
68
- }
69
-
70
- // Deserialize the response
71
- const response = new Response(entry.body, {
72
- status: entry.status,
73
- statusText: entry.statusText,
74
- headers: new Headers(entry.headers)
75
- });
76
-
77
- resolve({
78
- response,
79
- metadata: entry.metadata,
80
- url: entry.url,
81
- timestamp: entry.timestamp,
82
- expires: entry.expires,
83
- etag: entry.etag,
84
- lastModified: entry.lastModified
85
- });
86
- };
87
- });
88
- }
89
-
90
- /**
91
- * Store a response in the cache
92
- * @param {string} key Cache key
93
- * @param {Response} response Response to cache
94
- * @param {Object} metadata Cache metadata
95
- * @returns {Promise<void>}
96
- */
97
- async set(key, response, metadata) {
98
- const db = await this.dbPromise;
99
-
100
- // Clone the response to avoid consuming it
101
- const clonedResponse = response.clone();
102
-
103
- // Extract response data
104
- const body = await clonedResponse.blob();
105
- const headers = Array.from(clonedResponse.headers.entries());
106
-
107
- const entry = {
108
- key,
109
- url: clonedResponse.url,
110
- status: clonedResponse.status,
111
- statusText: clonedResponse.statusText,
112
- headers,
113
- body,
114
- metadata,
115
- timestamp: Date.now(),
116
- expires: metadata.expires || null,
117
- etag: clonedResponse.headers.get('ETag'),
118
- lastModified: clonedResponse.headers.get('Last-Modified')
119
- };
120
-
121
- return new Promise((resolve, reject) => {
122
- const transaction = db.transaction(this.storeName, 'readwrite');
123
- const store = transaction.objectStore(this.storeName);
124
- const request = store.put(entry);
125
-
126
- request.onerror = () => reject(request.error);
127
- request.onsuccess = () => resolve();
128
- });
129
- }
130
-
131
- /**
132
- * Delete a cached response
133
- * @param {string} key Cache key
134
- * @returns {Promise<boolean>}
135
- */
136
- async delete(key) {
137
- const db = await this.dbPromise;
138
-
139
- return new Promise((resolve, reject) => {
140
- const transaction = db.transaction(this.storeName, 'readwrite');
141
- const store = transaction.objectStore(this.storeName);
142
- const request = store.delete(key);
143
-
144
- request.onerror = () => reject(request.error);
145
- request.onsuccess = () => resolve(true);
146
- });
147
- }
148
-
149
- /**
150
- * Clear all cached responses
151
- * @returns {Promise<void>}
152
- */
153
- async clear() {
154
- const db = await this.dbPromise;
155
-
156
- return new Promise((resolve, reject) => {
157
- const transaction = db.transaction(this.storeName, 'readwrite');
158
- const store = transaction.objectStore(this.storeName);
159
- const request = store.clear();
160
-
161
- request.onerror = () => reject(request.error);
162
- request.onsuccess = () => resolve();
163
- });
164
- }
165
- }