@classic-homes/offline-core 0.1.3 → 0.1.4
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/cache/index.d.ts +19 -2
- package/dist/cache/index.js +5 -1
- package/dist/{chunk-K7USXDTP.js → chunk-ZDXEYCDZ.js} +125 -7
- package/dist/drafts/index.d.ts +3 -3
- package/dist/files/index.d.ts +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -101
- package/dist/storage/index.d.ts +1 -1
- package/dist/sync/index.d.ts +2 -2
- package/dist/{types-CWuauHAr.d.ts → types-DDhQm0hc.d.ts} +1 -1
- package/dist/{types-B2FJpQuN.d.ts → types-Ho1JiLQR.d.ts} +1 -1
- package/package.json +4 -4
package/dist/cache/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as StorageAdapter } from '../types-
|
|
1
|
+
import { S as StorageAdapter } from '../types-DDhQm0hc.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Types for cache service
|
|
@@ -139,6 +139,7 @@ declare class CacheService {
|
|
|
139
139
|
set<T>(key: string, value: T, options?: CacheOptions): Promise<void>;
|
|
140
140
|
/**
|
|
141
141
|
* Enforce cache size limits using LRU eviction
|
|
142
|
+
* @param newKey - Key being added (skip count check if it already exists)
|
|
142
143
|
*/
|
|
143
144
|
private enforceLimit;
|
|
144
145
|
/**
|
|
@@ -195,4 +196,20 @@ declare class CacheService {
|
|
|
195
196
|
*/
|
|
196
197
|
declare function createCacheService(adapter: StorageAdapter): CacheService;
|
|
197
198
|
|
|
198
|
-
|
|
199
|
+
/**
|
|
200
|
+
* Cache helper utilities that work with the offline storage singleton.
|
|
201
|
+
*/
|
|
202
|
+
/**
|
|
203
|
+
* Invalidate cache entries by tag.
|
|
204
|
+
*
|
|
205
|
+
* Returns 0 when offline storage has not been initialized.
|
|
206
|
+
*/
|
|
207
|
+
declare function invalidateCacheByTag(tag: string): Promise<number>;
|
|
208
|
+
/**
|
|
209
|
+
* Invalidate all cache entries.
|
|
210
|
+
*
|
|
211
|
+
* Returns 0 when offline storage has not been initialized.
|
|
212
|
+
*/
|
|
213
|
+
declare function invalidateAllCache(): Promise<number>;
|
|
214
|
+
|
|
215
|
+
export { CACHE_PREFIX, type CacheEntry, type CacheGetResult, type CacheOptions, CacheService, type CacheStats, type GetOrSetOptions, createCacheService, getCacheKey, getOriginalKey, invalidateAllCache, invalidateCacheByTag };
|
package/dist/cache/index.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export { CACHE_PREFIX, CacheService, createCacheService, getCacheKey, getOriginalKey } from '../chunk-
|
|
1
|
+
export { CACHE_PREFIX, CacheService, createCacheService, getCacheKey, getOriginalKey, invalidateAllCache, invalidateCacheByTag } from '../chunk-ZDXEYCDZ.js';
|
|
2
|
+
import '../chunk-IDRYBB6Z.js';
|
|
3
|
+
import '../chunk-U27TKOYZ.js';
|
|
4
|
+
import '../chunk-IIG4QLLN.js';
|
|
5
|
+
import '../chunk-4QWZX3LM.js';
|
|
2
6
|
import '../chunk-ZC7F2HDV.js';
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createAdapter, OfflineStorageError } from './chunk-IDRYBB6Z.js';
|
|
2
|
+
import { createFileStorageService } from './chunk-U27TKOYZ.js';
|
|
3
|
+
import { createDraftStorageService } from './chunk-IIG4QLLN.js';
|
|
4
|
+
import { createDraftManagerService } from './chunk-4QWZX3LM.js';
|
|
5
|
+
import { DEFAULT_EXPIRATIONS, CleanupScheduler } from './chunk-ZC7F2HDV.js';
|
|
2
6
|
|
|
3
7
|
// src/cache/types.ts
|
|
4
8
|
var CACHE_PREFIX = "cache:";
|
|
@@ -65,6 +69,7 @@ var CacheService = class {
|
|
|
65
69
|
const isExpired = cached.expiresAt !== null && now > cached.expiresAt;
|
|
66
70
|
if (isExpired) {
|
|
67
71
|
this.stats.staleHits++;
|
|
72
|
+
this.accessOrder.set(key, now);
|
|
68
73
|
return {
|
|
69
74
|
value: cached.data,
|
|
70
75
|
hit: true,
|
|
@@ -94,7 +99,7 @@ var CacheService = class {
|
|
|
94
99
|
expiresAt: ttl > 0 ? now + ttl : null,
|
|
95
100
|
tags: options.tags
|
|
96
101
|
};
|
|
97
|
-
await this.enforceLimit();
|
|
102
|
+
await this.enforceLimit(key);
|
|
98
103
|
await this.adapter.storeJSON(storageKey, entry, {
|
|
99
104
|
tags: options.tags ? [...options.tags, "cache"] : ["cache"]
|
|
100
105
|
});
|
|
@@ -102,10 +107,12 @@ var CacheService = class {
|
|
|
102
107
|
}
|
|
103
108
|
/**
|
|
104
109
|
* Enforce cache size limits using LRU eviction
|
|
110
|
+
* @param newKey - Key being added (skip count check if it already exists)
|
|
105
111
|
*/
|
|
106
|
-
async enforceLimit() {
|
|
112
|
+
async enforceLimit(newKey) {
|
|
107
113
|
const keys = await this.keys();
|
|
108
|
-
|
|
114
|
+
const isNewEntry = newKey ? !keys.includes(newKey) : true;
|
|
115
|
+
if (isNewEntry && keys.length >= this.maxEntries) {
|
|
109
116
|
const evictCount = Math.max(1, Math.floor(this.maxEntries * 0.1));
|
|
110
117
|
await this.evictLRU(keys, evictCount);
|
|
111
118
|
}
|
|
@@ -155,8 +162,8 @@ var CacheService = class {
|
|
|
155
162
|
const entry = result.data;
|
|
156
163
|
const staleThreshold = staleTime ?? ttl;
|
|
157
164
|
const now = Date.now();
|
|
158
|
-
const age =
|
|
159
|
-
if (age < staleThreshold) {
|
|
165
|
+
const age = now - entry.createdAt;
|
|
166
|
+
if (age < (entry.expiresAt !== null ? entry.expiresAt - entry.createdAt : 0) + staleThreshold) {
|
|
160
167
|
void this.revalidateInBackground(key, fetcher, { ttl, tags });
|
|
161
168
|
return cached.value;
|
|
162
169
|
}
|
|
@@ -211,6 +218,7 @@ var CacheService = class {
|
|
|
211
218
|
* Invalidate a cached value
|
|
212
219
|
*/
|
|
213
220
|
async invalidate(key) {
|
|
221
|
+
this.cleanupStaleInFlight();
|
|
214
222
|
const storageKey = getCacheKey(key);
|
|
215
223
|
await this.adapter.deleteJSON(storageKey);
|
|
216
224
|
this.accessOrder.delete(key);
|
|
@@ -219,12 +227,14 @@ var CacheService = class {
|
|
|
219
227
|
* Invalidate all entries with a specific tag
|
|
220
228
|
*/
|
|
221
229
|
async invalidateByTag(tag) {
|
|
230
|
+
this.cleanupStaleInFlight();
|
|
222
231
|
return this.adapter.deleteJSONByTag(tag);
|
|
223
232
|
}
|
|
224
233
|
/**
|
|
225
234
|
* Invalidate all cached values
|
|
226
235
|
*/
|
|
227
236
|
async invalidateAll() {
|
|
237
|
+
this.cleanupStaleInFlight();
|
|
228
238
|
const count = await this.adapter.deleteJSONByTag("cache");
|
|
229
239
|
this.accessOrder.clear();
|
|
230
240
|
return count;
|
|
@@ -293,4 +303,112 @@ function createCacheService(adapter) {
|
|
|
293
303
|
return new CacheService(adapter);
|
|
294
304
|
}
|
|
295
305
|
|
|
296
|
-
|
|
306
|
+
// src/init.ts
|
|
307
|
+
var instance = null;
|
|
308
|
+
var initPromise = null;
|
|
309
|
+
var DEFAULT_OPTIONS = {
|
|
310
|
+
preferredAdapters: ["opfs", "indexeddb", "memory"],
|
|
311
|
+
dbName: "classic-offline",
|
|
312
|
+
autoCleanup: true,
|
|
313
|
+
cleanupIntervalMs: 6e4
|
|
314
|
+
// 1 minute
|
|
315
|
+
};
|
|
316
|
+
async function initOfflineStorage(options) {
|
|
317
|
+
if (instance) {
|
|
318
|
+
return instance;
|
|
319
|
+
}
|
|
320
|
+
if (initPromise) {
|
|
321
|
+
return initPromise;
|
|
322
|
+
}
|
|
323
|
+
initPromise = doInitialize(options);
|
|
324
|
+
try {
|
|
325
|
+
instance = await initPromise;
|
|
326
|
+
return instance;
|
|
327
|
+
} finally {
|
|
328
|
+
initPromise = null;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
async function doInitialize(options) {
|
|
332
|
+
const mergedOptions = { ...DEFAULT_OPTIONS, ...options };
|
|
333
|
+
const { adapter, adapterName } = await createAdapter({
|
|
334
|
+
preferredAdapters: mergedOptions.preferredAdapters,
|
|
335
|
+
dbName: mergedOptions.dbName
|
|
336
|
+
});
|
|
337
|
+
await adapter.initialize();
|
|
338
|
+
const files = createFileStorageService(adapter);
|
|
339
|
+
const drafts = createDraftStorageService(adapter);
|
|
340
|
+
const draftManager = createDraftManagerService(adapter);
|
|
341
|
+
const cache = createCacheService(adapter);
|
|
342
|
+
const cleanup = new CleanupScheduler(mergedOptions.cleanupIntervalMs);
|
|
343
|
+
cleanup.registerAdapter(adapter);
|
|
344
|
+
if (mergedOptions.autoCleanup && mergedOptions.cleanupIntervalMs > 0) {
|
|
345
|
+
cleanup.start();
|
|
346
|
+
}
|
|
347
|
+
const config = {
|
|
348
|
+
adapterName,
|
|
349
|
+
dbName: mergedOptions.dbName,
|
|
350
|
+
autoCleanup: mergedOptions.autoCleanup,
|
|
351
|
+
cleanupIntervalMs: mergedOptions.cleanupIntervalMs
|
|
352
|
+
};
|
|
353
|
+
return {
|
|
354
|
+
adapter,
|
|
355
|
+
config,
|
|
356
|
+
files,
|
|
357
|
+
drafts,
|
|
358
|
+
draftManager,
|
|
359
|
+
cache,
|
|
360
|
+
cleanup,
|
|
361
|
+
async dispose() {
|
|
362
|
+
cleanup.stop();
|
|
363
|
+
await adapter.dispose();
|
|
364
|
+
instance = null;
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
function getOfflineStorage() {
|
|
369
|
+
if (!instance) {
|
|
370
|
+
throw OfflineStorageError.notInitialized();
|
|
371
|
+
}
|
|
372
|
+
return instance;
|
|
373
|
+
}
|
|
374
|
+
function isOfflineStorageInitialized() {
|
|
375
|
+
return instance !== null;
|
|
376
|
+
}
|
|
377
|
+
function getOfflineStorageOrNull() {
|
|
378
|
+
return instance;
|
|
379
|
+
}
|
|
380
|
+
async function resetOfflineStorage() {
|
|
381
|
+
if (instance) {
|
|
382
|
+
await instance.dispose();
|
|
383
|
+
instance = null;
|
|
384
|
+
}
|
|
385
|
+
initPromise = null;
|
|
386
|
+
}
|
|
387
|
+
async function detectStorageAdapter(preferredAdapters) {
|
|
388
|
+
const { adapterName, unavailable } = await createAdapter({
|
|
389
|
+
preferredAdapters
|
|
390
|
+
});
|
|
391
|
+
const available = [];
|
|
392
|
+
if (!unavailable.includes("opfs")) available.push("opfs");
|
|
393
|
+
if (!unavailable.includes("indexeddb")) available.push("indexeddb");
|
|
394
|
+
available.push("memory");
|
|
395
|
+
return { adapterName, available, unavailable };
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// src/cache/helpers.ts
|
|
399
|
+
async function invalidateCacheByTag(tag) {
|
|
400
|
+
const storage = getOfflineStorageOrNull();
|
|
401
|
+
if (!storage) {
|
|
402
|
+
return 0;
|
|
403
|
+
}
|
|
404
|
+
return storage.cache.invalidateByTag(tag);
|
|
405
|
+
}
|
|
406
|
+
async function invalidateAllCache() {
|
|
407
|
+
const storage = getOfflineStorageOrNull();
|
|
408
|
+
if (!storage) {
|
|
409
|
+
return 0;
|
|
410
|
+
}
|
|
411
|
+
return storage.cache.invalidateAll();
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
export { CACHE_PREFIX, CacheService, createCacheService, detectStorageAdapter, getCacheKey, getOfflineStorage, getOfflineStorageOrNull, getOriginalKey, initOfflineStorage, invalidateAllCache, invalidateCacheByTag, isOfflineStorageInitialized, resetOfflineStorage };
|
package/dist/drafts/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { j as CURRENT_DRAFT_PREFIX, D as DRAFT_PREFIX,
|
|
3
|
-
import { S as StorageAdapter } from '../types-
|
|
1
|
+
import { S as SaveDraftOptions, d as LoadDraftOptions, e as LoadDraftResult, C as CreateDraftOptions, b as DraftMetadata, g as StoredDraftV2, L as ListDraftsOptions, c as DraftSyncStatus } from '../types-Ho1JiLQR.js';
|
|
2
|
+
export { j as CURRENT_DRAFT_PREFIX, D as DRAFT_PREFIX, a as DRAFT_V2_PREFIX, f as StoredDraft, h as generateDraftId, k as getCurrentDraftKey, l as getDraftKey, m as getDraftV2Key, n as getFormKeyFromDraftKey, i as getOrCreateDeviceId, o as isDraftV2Key, p as isLegacyDraftKey, q as parseDraftV2Key } from '../types-Ho1JiLQR.js';
|
|
3
|
+
import { S as StorageAdapter } from '../types-DDhQm0hc.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Form draft persistence service
|
package/dist/files/index.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { S as StorageAdapter, O as OfflineStorageConfig, a as
|
|
2
|
-
export { B as BlobMetadata,
|
|
1
|
+
import { S as StorageAdapter, O as OfflineStorageConfig, a as StorageAdapterName, b as OfflineStorageOptions } from './types-DDhQm0hc.js';
|
|
2
|
+
export { B as BlobMetadata, c as BlobWithMetadata, C as CleanupResult, J as JSONEntry, d as StorageAdapterOptions, e as StorageQuota, f as StoreJSONOptions } from './types-DDhQm0hc.js';
|
|
3
3
|
import { FileStorageService } from './files/index.js';
|
|
4
4
|
export { DeleteFilesResult, FileConstraints, FileValidationError, GetFilesOptions, PersistedFile, StoreFileOptions, StoredFile, createFileStorageService } from './files/index.js';
|
|
5
5
|
import { DraftStorageService, DraftManagerService } from './drafts/index.js';
|
|
6
6
|
export { createDraftManagerService, createDraftStorageService } from './drafts/index.js';
|
|
7
7
|
import { CacheService } from './cache/index.js';
|
|
8
|
-
export { CACHE_PREFIX, CacheEntry, CacheGetResult, CacheOptions, CacheStats, GetOrSetOptions, createCacheService } from './cache/index.js';
|
|
8
|
+
export { CACHE_PREFIX, CacheEntry, CacheGetResult, CacheOptions, CacheStats, GetOrSetOptions, createCacheService, invalidateAllCache, invalidateCacheByTag } from './cache/index.js';
|
|
9
9
|
export { CreateAdapterOptions, CreateAdapterResult, createAdapter, detectAvailableAdapters } from './storage/index.js';
|
|
10
|
-
export { C as CreateDraftOptions, D as DRAFT_PREFIX,
|
|
10
|
+
export { C as CreateDraftOptions, D as DRAFT_PREFIX, a as DRAFT_V2_PREFIX, b as DraftMetadata, c as DraftSyncStatus, L as ListDraftsOptions, d as LoadDraftOptions, e as LoadDraftResult, S as SaveDraftOptions, f as StoredDraft, g as StoredDraftV2, h as generateDraftId, i as getOrCreateDeviceId } from './types-Ho1JiLQR.js';
|
|
11
11
|
export { ConflictResolution, ConnectivityMonitor, ConnectivityState, DraftConflict, DraftPayload, PendingSyncOperation, RemoteDraft, SyncAdapter, SyncConfig, SyncEvent, SyncEventListener, SyncEventType, SyncQueue, SyncQueueState, SyncRequest, SyncResponse, SyncResult, SyncService, applyResolution, compareDrafts, createConnectivityMonitor, createSyncQueue, createSyncService, detectConflict } from './sync/index.js';
|
|
12
12
|
|
|
13
13
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,107 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
export { CACHE_PREFIX, CacheService, createCacheService, detectStorageAdapter, getOfflineStorage, getOfflineStorageOrNull, initOfflineStorage, invalidateAllCache, invalidateCacheByTag, isOfflineStorageInitialized, resetOfflineStorage } from './chunk-ZDXEYCDZ.js';
|
|
2
2
|
export { OfflineStorageError, createAdapter, detectAvailableAdapters, detectBrowser, isBrowser, isSSR, isWorker, supportsIndexedDB, supportsLocalStorage, supportsOPFS } from './chunk-IDRYBB6Z.js';
|
|
3
|
-
import { createFileStorageService } from './chunk-U27TKOYZ.js';
|
|
4
3
|
export { FileStorageService, createFileStorageService } from './chunk-U27TKOYZ.js';
|
|
5
|
-
import { createDraftStorageService } from './chunk-IIG4QLLN.js';
|
|
6
4
|
export { DraftStorageService, createDraftStorageService } from './chunk-IIG4QLLN.js';
|
|
7
|
-
import { createCacheService } from './chunk-K7USXDTP.js';
|
|
8
|
-
export { CACHE_PREFIX, CacheService, createCacheService } from './chunk-K7USXDTP.js';
|
|
9
5
|
export { ConnectivityMonitor, SyncQueue, SyncService, applyResolution, compareDrafts, createConnectivityMonitor, createSyncQueue, createSyncService, detectConflict } from './chunk-XHMX3BYT.js';
|
|
10
|
-
import { createDraftManagerService } from './chunk-4QWZX3LM.js';
|
|
11
6
|
export { DRAFT_PREFIX, DRAFT_V2_PREFIX, DraftManagerService, createDraftManagerService, generateDraftId, getOrCreateDeviceId } from './chunk-4QWZX3LM.js';
|
|
12
|
-
import { CleanupScheduler } from './chunk-ZC7F2HDV.js';
|
|
13
7
|
export { CleanupScheduler, DEFAULT_EXPIRATIONS, calculateExpiration, isExpired } from './chunk-ZC7F2HDV.js';
|
|
14
|
-
|
|
15
|
-
// src/init.ts
|
|
16
|
-
var instance = null;
|
|
17
|
-
var initPromise = null;
|
|
18
|
-
var DEFAULT_OPTIONS = {
|
|
19
|
-
preferredAdapters: ["opfs", "indexeddb", "memory"],
|
|
20
|
-
dbName: "classic-offline",
|
|
21
|
-
autoCleanup: true,
|
|
22
|
-
cleanupIntervalMs: 6e4
|
|
23
|
-
// 1 minute
|
|
24
|
-
};
|
|
25
|
-
async function initOfflineStorage(options) {
|
|
26
|
-
if (instance) {
|
|
27
|
-
return instance;
|
|
28
|
-
}
|
|
29
|
-
if (initPromise) {
|
|
30
|
-
return initPromise;
|
|
31
|
-
}
|
|
32
|
-
initPromise = doInitialize(options);
|
|
33
|
-
try {
|
|
34
|
-
instance = await initPromise;
|
|
35
|
-
return instance;
|
|
36
|
-
} finally {
|
|
37
|
-
initPromise = null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async function doInitialize(options) {
|
|
41
|
-
const mergedOptions = { ...DEFAULT_OPTIONS, ...options };
|
|
42
|
-
const { adapter, adapterName } = await createAdapter({
|
|
43
|
-
preferredAdapters: mergedOptions.preferredAdapters,
|
|
44
|
-
dbName: mergedOptions.dbName
|
|
45
|
-
});
|
|
46
|
-
await adapter.initialize();
|
|
47
|
-
const files = createFileStorageService(adapter);
|
|
48
|
-
const drafts = createDraftStorageService(adapter);
|
|
49
|
-
const draftManager = createDraftManagerService(adapter);
|
|
50
|
-
const cache = createCacheService(adapter);
|
|
51
|
-
const cleanup = new CleanupScheduler(mergedOptions.cleanupIntervalMs);
|
|
52
|
-
cleanup.registerAdapter(adapter);
|
|
53
|
-
if (mergedOptions.autoCleanup && mergedOptions.cleanupIntervalMs > 0) {
|
|
54
|
-
cleanup.start();
|
|
55
|
-
}
|
|
56
|
-
const config = {
|
|
57
|
-
adapterName,
|
|
58
|
-
dbName: mergedOptions.dbName,
|
|
59
|
-
autoCleanup: mergedOptions.autoCleanup,
|
|
60
|
-
cleanupIntervalMs: mergedOptions.cleanupIntervalMs
|
|
61
|
-
};
|
|
62
|
-
return {
|
|
63
|
-
adapter,
|
|
64
|
-
config,
|
|
65
|
-
files,
|
|
66
|
-
drafts,
|
|
67
|
-
draftManager,
|
|
68
|
-
cache,
|
|
69
|
-
cleanup,
|
|
70
|
-
async dispose() {
|
|
71
|
-
cleanup.stop();
|
|
72
|
-
await adapter.dispose();
|
|
73
|
-
instance = null;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
function getOfflineStorage() {
|
|
78
|
-
if (!instance) {
|
|
79
|
-
throw OfflineStorageError.notInitialized();
|
|
80
|
-
}
|
|
81
|
-
return instance;
|
|
82
|
-
}
|
|
83
|
-
function isOfflineStorageInitialized() {
|
|
84
|
-
return instance !== null;
|
|
85
|
-
}
|
|
86
|
-
function getOfflineStorageOrNull() {
|
|
87
|
-
return instance;
|
|
88
|
-
}
|
|
89
|
-
async function resetOfflineStorage() {
|
|
90
|
-
if (instance) {
|
|
91
|
-
await instance.dispose();
|
|
92
|
-
instance = null;
|
|
93
|
-
}
|
|
94
|
-
initPromise = null;
|
|
95
|
-
}
|
|
96
|
-
async function detectStorageAdapter(preferredAdapters) {
|
|
97
|
-
const { adapterName, unavailable } = await createAdapter({
|
|
98
|
-
preferredAdapters
|
|
99
|
-
});
|
|
100
|
-
const available = [];
|
|
101
|
-
if (!unavailable.includes("opfs")) available.push("opfs");
|
|
102
|
-
if (!unavailable.includes("indexeddb")) available.push("indexeddb");
|
|
103
|
-
available.push("memory");
|
|
104
|
-
return { adapterName, available, unavailable };
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export { detectStorageAdapter, getOfflineStorage, getOfflineStorageOrNull, initOfflineStorage, isOfflineStorageInitialized, resetOfflineStorage };
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as StorageAdapter,
|
|
1
|
+
import { S as StorageAdapter, d as StorageAdapterOptions, B as BlobMetadata, c as BlobWithMetadata, f as StoreJSONOptions, J as JSONEntry, C as CleanupResult, e as StorageQuota, a as StorageAdapterName } from '../types-DDhQm0hc.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Memory storage adapter
|
package/dist/sync/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { S as StorageAdapter } from '../types-
|
|
1
|
+
import { g as StoredDraftV2 } from '../types-Ho1JiLQR.js';
|
|
2
|
+
import { S as StorageAdapter } from '../types-DDhQm0hc.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Types for cloud sync functionality
|
|
@@ -201,4 +201,4 @@ interface StorageAdapterOptions {
|
|
|
201
201
|
dbName?: string;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
export type { BlobMetadata as B, CleanupResult as C, JSONEntry as J, OfflineStorageConfig as O, StorageAdapter as S,
|
|
204
|
+
export type { BlobMetadata as B, CleanupResult as C, JSONEntry as J, OfflineStorageConfig as O, StorageAdapter as S, StorageAdapterName as a, OfflineStorageOptions as b, BlobWithMetadata as c, StorageAdapterOptions as d, StorageQuota as e, StoreJSONOptions as f };
|
|
@@ -176,4 +176,4 @@ declare function isLegacyDraftKey(key: string): boolean;
|
|
|
176
176
|
*/
|
|
177
177
|
declare function isDraftV2Key(key: string): boolean;
|
|
178
178
|
|
|
179
|
-
export { type CreateDraftOptions as C, DRAFT_PREFIX as D, type
|
|
179
|
+
export { type CreateDraftOptions as C, DRAFT_PREFIX as D, type ListDraftsOptions as L, type SaveDraftOptions as S, DRAFT_V2_PREFIX as a, type DraftMetadata as b, type DraftSyncStatus as c, type LoadDraftOptions as d, type LoadDraftResult as e, type StoredDraft as f, type StoredDraftV2 as g, generateDraftId as h, getOrCreateDeviceId as i, CURRENT_DRAFT_PREFIX as j, getCurrentDraftKey as k, getDraftKey as l, getDraftV2Key as m, getFormKeyFromDraftKey as n, isDraftV2Key as o, isLegacyDraftKey as p, parseDraftV2Key as q };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@classic-homes/offline-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Framework-agnostic offline persistence and caching for Classic Theme",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "tsup",
|
|
41
41
|
"dev": "tsup --watch",
|
|
42
|
-
"clean": "rm
|
|
42
|
+
"clean": "node ../../scripts/rm.mjs dist",
|
|
43
43
|
"typecheck": "tsc --noEmit",
|
|
44
44
|
"test": "vitest run",
|
|
45
45
|
"test:watch": "vitest",
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
"idb": "^8.0.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@vitest/coverage-v8": "^
|
|
70
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
71
71
|
"fake-indexeddb": "^6.0.0",
|
|
72
72
|
"jsdom": "^25.0.0",
|
|
73
73
|
"tsup": "^8.0.0",
|
|
74
74
|
"typescript": "^5.3.0",
|
|
75
|
-
"vitest": "^
|
|
75
|
+
"vitest": "^4.1.10"
|
|
76
76
|
}
|
|
77
77
|
}
|