@revealui/core 0.3.0 → 0.5.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 (155) hide show
  1. package/dist/client/admin/components/AdminDashboard.d.ts.map +1 -1
  2. package/dist/client/admin/components/AdminDashboard.js +20 -3
  3. package/dist/client/richtext/index.d.ts.map +1 -1
  4. package/dist/client/richtext/plugins/FloatingToolbarPlugin.js +1 -3
  5. package/dist/collections/operations/create.d.ts +2 -1
  6. package/dist/collections/operations/create.d.ts.map +1 -1
  7. package/dist/collections/operations/create.js +28 -1
  8. package/dist/database/type-adapter.d.ts.map +1 -1
  9. package/dist/features.d.ts +7 -3
  10. package/dist/features.d.ts.map +1 -1
  11. package/dist/features.js +2 -0
  12. package/dist/globals/GlobalOperations.d.ts.map +1 -1
  13. package/dist/globals/GlobalOperations.js +12 -2
  14. package/dist/index.d.ts +11 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +11 -1
  17. package/dist/license.d.ts +6 -0
  18. package/dist/license.d.ts.map +1 -1
  19. package/dist/license.js +14 -1
  20. package/dist/monitoring/alerts.d.ts +4 -4
  21. package/dist/monitoring/alerts.d.ts.map +1 -1
  22. package/dist/plugins/nested-docs.d.ts.map +1 -1
  23. package/dist/plugins/nested-docs.js +0 -1
  24. package/dist/queries/queryBuilder.d.ts.map +1 -1
  25. package/dist/queries/queryBuilder.js +4 -3
  26. package/dist/richtext/index.d.ts.map +1 -1
  27. package/dist/storage/vercel-blob.d.ts.map +1 -1
  28. package/dist/storage/vercel-blob.js +3 -0
  29. package/dist/types/api.d.ts.map +1 -1
  30. package/dist/types/config.d.ts.map +1 -1
  31. package/dist/types/core.d.ts +1 -1
  32. package/dist/types/core.d.ts.map +1 -1
  33. package/dist/types/extensions.d.ts.map +1 -1
  34. package/dist/types/frontend.d.ts.map +1 -1
  35. package/dist/types/legacy.d.ts.map +1 -1
  36. package/dist/types/query.d.ts.map +1 -1
  37. package/dist/types/runtime.d.ts +1 -0
  38. package/dist/types/runtime.d.ts.map +1 -1
  39. package/dist/utils/error-responses.d.ts.map +1 -1
  40. package/dist/utils/error-responses.js +2 -3
  41. package/package.json +23 -23
  42. package/dist/caching/app-cache.d.ts +0 -242
  43. package/dist/caching/app-cache.d.ts.map +0 -1
  44. package/dist/caching/app-cache.js +0 -438
  45. package/dist/caching/cdn-config.d.ts +0 -155
  46. package/dist/caching/cdn-config.d.ts.map +0 -1
  47. package/dist/caching/cdn-config.js +0 -415
  48. package/dist/caching/edge-cache.d.ts +0 -177
  49. package/dist/caching/edge-cache.d.ts.map +0 -1
  50. package/dist/caching/edge-cache.js +0 -414
  51. package/dist/caching/service-worker.d.ts +0 -157
  52. package/dist/caching/service-worker.d.ts.map +0 -1
  53. package/dist/caching/service-worker.js +0 -438
  54. package/dist/client/admin/utils/auth.d.ts +0 -23
  55. package/dist/client/admin/utils/auth.d.ts.map +0 -1
  56. package/dist/client/admin/utils/auth.js +0 -52
  57. package/dist/client/http/client.d.ts +0 -15
  58. package/dist/client/http/client.d.ts.map +0 -1
  59. package/dist/client/http/client.js +0 -49
  60. package/dist/client/http/fetchBanner.d.ts +0 -18
  61. package/dist/client/http/fetchBanner.d.ts.map +0 -1
  62. package/dist/client/http/fetchBanner.js +0 -44
  63. package/dist/client/http/fetchCard.d.ts +0 -18
  64. package/dist/client/http/fetchCard.d.ts.map +0 -1
  65. package/dist/client/http/fetchCard.js +0 -46
  66. package/dist/client/http/fetchEvents.d.ts +0 -18
  67. package/dist/client/http/fetchEvents.d.ts.map +0 -1
  68. package/dist/client/http/fetchEvents.js +0 -44
  69. package/dist/client/http/fetchHero.d.ts +0 -17
  70. package/dist/client/http/fetchHero.d.ts.map +0 -1
  71. package/dist/client/http/fetchHero.js +0 -55
  72. package/dist/client/http/fetchMainInfos.d.ts +0 -17
  73. package/dist/client/http/fetchMainInfos.d.ts.map +0 -1
  74. package/dist/client/http/fetchMainInfos.js +0 -44
  75. package/dist/client/http/fetchVideos.d.ts +0 -13
  76. package/dist/client/http/fetchVideos.d.ts.map +0 -1
  77. package/dist/client/http/fetchVideos.js +0 -36
  78. package/dist/client/http/index.d.ts +0 -19
  79. package/dist/client/http/index.d.ts.map +0 -1
  80. package/dist/client/http/index.js +0 -11
  81. package/dist/error-handling/circuit-breaker.d.ts +0 -262
  82. package/dist/error-handling/circuit-breaker.d.ts.map +0 -1
  83. package/dist/error-handling/circuit-breaker.js +0 -550
  84. package/dist/error-handling/retry.d.ts +0 -194
  85. package/dist/error-handling/retry.d.ts.map +0 -1
  86. package/dist/error-handling/retry.js +0 -455
  87. package/dist/errors/index.d.ts +0 -23
  88. package/dist/errors/index.d.ts.map +0 -1
  89. package/dist/errors/index.js +0 -40
  90. package/dist/generated/agents/index.d.ts +0 -8
  91. package/dist/generated/agents/index.d.ts.map +0 -1
  92. package/dist/generated/agents/index.js +0 -7
  93. package/dist/generated/components/index.d.ts +0 -8
  94. package/dist/generated/components/index.d.ts.map +0 -1
  95. package/dist/generated/components/index.js +0 -7
  96. package/dist/generated/functions/index.d.ts +0 -8
  97. package/dist/generated/functions/index.d.ts.map +0 -1
  98. package/dist/generated/functions/index.js +0 -7
  99. package/dist/generated/hooks/index.d.ts +0 -8
  100. package/dist/generated/hooks/index.d.ts.map +0 -1
  101. package/dist/generated/hooks/index.js +0 -7
  102. package/dist/generated/plans/index.d.ts +0 -8
  103. package/dist/generated/plans/index.d.ts.map +0 -1
  104. package/dist/generated/plans/index.js +0 -7
  105. package/dist/generated/prompts/index.d.ts +0 -8
  106. package/dist/generated/prompts/index.d.ts.map +0 -1
  107. package/dist/generated/prompts/index.js +0 -7
  108. package/dist/generated/tools/index.d.ts +0 -8
  109. package/dist/generated/tools/index.d.ts.map +0 -1
  110. package/dist/generated/tools/index.js +0 -7
  111. package/dist/generated/types/supabase.d.ts +0 -193
  112. package/dist/generated/types/supabase.d.ts.map +0 -1
  113. package/dist/generated/types/supabase.js +0 -5
  114. package/dist/optimization/asset-optimizer.d.ts +0 -206
  115. package/dist/optimization/asset-optimizer.d.ts.map +0 -1
  116. package/dist/optimization/asset-optimizer.js +0 -336
  117. package/dist/optimization/build-optimizer.d.ts +0 -202
  118. package/dist/optimization/build-optimizer.d.ts.map +0 -1
  119. package/dist/optimization/build-optimizer.js +0 -271
  120. package/dist/optimization/bundle-analyzer.d.ts +0 -98
  121. package/dist/optimization/bundle-analyzer.d.ts.map +0 -1
  122. package/dist/optimization/bundle-analyzer.js +0 -346
  123. package/dist/optimization/code-splitting.d.ts +0 -121
  124. package/dist/optimization/code-splitting.d.ts.map +0 -1
  125. package/dist/optimization/code-splitting.js +0 -261
  126. package/dist/plugin/index.d.ts +0 -12
  127. package/dist/plugin/index.d.ts.map +0 -1
  128. package/dist/plugin/index.js +0 -4
  129. package/dist/security/audit.d.ts +0 -188
  130. package/dist/security/audit.d.ts.map +0 -1
  131. package/dist/security/audit.js +0 -433
  132. package/dist/security/auth.d.ts +0 -110
  133. package/dist/security/auth.d.ts.map +0 -1
  134. package/dist/security/auth.js +0 -257
  135. package/dist/security/authorization.d.ts +0 -211
  136. package/dist/security/authorization.d.ts.map +0 -1
  137. package/dist/security/authorization.js +0 -492
  138. package/dist/security/encryption.d.ts +0 -226
  139. package/dist/security/encryption.d.ts.map +0 -1
  140. package/dist/security/encryption.js +0 -534
  141. package/dist/security/gdpr-storage.d.ts +0 -102
  142. package/dist/security/gdpr-storage.d.ts.map +0 -1
  143. package/dist/security/gdpr-storage.js +0 -65
  144. package/dist/security/gdpr.d.ts +0 -320
  145. package/dist/security/gdpr.d.ts.map +0 -1
  146. package/dist/security/gdpr.js +0 -531
  147. package/dist/security/headers.d.ts +0 -184
  148. package/dist/security/headers.d.ts.map +0 -1
  149. package/dist/security/headers.js +0 -420
  150. package/dist/utils/jwt-validation.d.ts +0 -14
  151. package/dist/utils/jwt-validation.d.ts.map +0 -1
  152. package/dist/utils/jwt-validation.js +0 -36
  153. package/dist/utils/request-headers.d.ts +0 -15
  154. package/dist/utils/request-headers.d.ts.map +0 -1
  155. package/dist/utils/request-headers.js +0 -31
@@ -1,414 +0,0 @@
1
- /**
2
- * Edge Caching and ISR (Incremental Static Regeneration)
3
- *
4
- * Utilities for Next.js edge caching, ISR, and on-demand revalidation
5
- */
6
- import { logger } from '../observability/logger.js';
7
- export const ISR_PRESETS = {
8
- // Revalidate every request
9
- always: {
10
- revalidate: 0,
11
- },
12
- // Revalidate every minute
13
- minute: {
14
- revalidate: 60,
15
- },
16
- // Revalidate every 5 minutes
17
- fiveMinutes: {
18
- revalidate: 300,
19
- },
20
- // Revalidate every hour
21
- hourly: {
22
- revalidate: 3600,
23
- },
24
- // Revalidate daily
25
- daily: {
26
- revalidate: 86400,
27
- },
28
- // Never revalidate (static)
29
- never: {
30
- revalidate: false,
31
- },
32
- };
33
- /**
34
- * Generate static params for ISR
35
- */
36
- export async function generateStaticParams(fetchFn, mapFn) {
37
- try {
38
- const items = await fetchFn();
39
- return items.map(mapFn);
40
- }
41
- catch (error) {
42
- logger.error('Failed to generate static params', error instanceof Error ? error : new Error(String(error)));
43
- return [];
44
- }
45
- }
46
- /**
47
- * Revalidate tag
48
- */
49
- export async function revalidateTag(tag, secret) {
50
- const baseUrl = process.env.NEXT_PUBLIC_URL;
51
- if (!baseUrl) {
52
- logger.warn('revalidateTag skipped: NEXT_PUBLIC_URL is not configured', { tag });
53
- return { revalidated: false, error: 'NEXT_PUBLIC_URL is not configured' };
54
- }
55
- try {
56
- const url = new URL('/api/revalidate', baseUrl);
57
- const headers = { 'Content-Type': 'application/json' };
58
- if (secret) {
59
- headers['x-revalidate-secret'] = secret;
60
- }
61
- const response = await fetch(url.toString(), {
62
- method: 'POST',
63
- headers,
64
- body: JSON.stringify({ tag }),
65
- });
66
- const data = await response.json();
67
- if (!response.ok) {
68
- logger.warn('revalidateTag failed', { tag, status: response.status, error: data.error });
69
- }
70
- return {
71
- revalidated: response.ok,
72
- error: data.error,
73
- };
74
- }
75
- catch (error) {
76
- const message = error instanceof Error ? error.message : 'Unknown error';
77
- logger.warn('revalidateTag error', { tag, error: message });
78
- return {
79
- revalidated: false,
80
- error: message,
81
- };
82
- }
83
- }
84
- /**
85
- * Revalidate path
86
- */
87
- export async function revalidatePath(path, secret) {
88
- const baseUrl = process.env.NEXT_PUBLIC_URL;
89
- if (!baseUrl) {
90
- logger.warn('revalidatePath skipped: NEXT_PUBLIC_URL is not configured', { path });
91
- return { revalidated: false, error: 'NEXT_PUBLIC_URL is not configured' };
92
- }
93
- try {
94
- const url = new URL('/api/revalidate', baseUrl);
95
- const headers = { 'Content-Type': 'application/json' };
96
- if (secret) {
97
- headers['x-revalidate-secret'] = secret;
98
- }
99
- const response = await fetch(url.toString(), {
100
- method: 'POST',
101
- headers,
102
- body: JSON.stringify({ path }),
103
- });
104
- const data = await response.json();
105
- return {
106
- revalidated: response.ok,
107
- error: data.error,
108
- };
109
- }
110
- catch (error) {
111
- return {
112
- revalidated: false,
113
- error: error instanceof Error ? error.message : 'Unknown error',
114
- };
115
- }
116
- }
117
- /**
118
- * Revalidate multiple paths
119
- */
120
- export async function revalidatePaths(paths, secret) {
121
- const results = await Promise.allSettled(paths.map((path) => revalidatePath(path, secret)));
122
- let revalidated = 0;
123
- let failed = 0;
124
- const errors = [];
125
- for (let i = 0; i < results.length; i++) {
126
- const result = results[i];
127
- const path = paths[i];
128
- if (!(result && path)) {
129
- continue;
130
- }
131
- if (result.status === 'fulfilled' && result.value.revalidated) {
132
- revalidated++;
133
- }
134
- else {
135
- failed++;
136
- const error = result.status === 'fulfilled'
137
- ? result.value.error || 'Unknown error'
138
- : String(result.reason) || 'Unknown error';
139
- errors.push({ path, error });
140
- }
141
- }
142
- return { revalidated, failed, errors };
143
- }
144
- /**
145
- * Revalidate multiple tags
146
- */
147
- export async function revalidateTags(tags, secret) {
148
- const results = await Promise.allSettled(tags.map((tag) => revalidateTag(tag, secret)));
149
- let revalidated = 0;
150
- let failed = 0;
151
- const errors = [];
152
- for (let i = 0; i < results.length; i++) {
153
- const result = results[i];
154
- const tag = tags[i];
155
- if (!(result && tag)) {
156
- continue;
157
- }
158
- if (result.status === 'fulfilled' && result.value.revalidated) {
159
- revalidated++;
160
- }
161
- else {
162
- failed++;
163
- const error = result.status === 'fulfilled'
164
- ? result.value.error || 'Unknown error'
165
- : String(result.reason) || 'Unknown error';
166
- errors.push({ tag, error });
167
- }
168
- }
169
- return { revalidated, failed, errors };
170
- }
171
- /**
172
- * Create edge cached fetch
173
- */
174
- export function createEdgeCachedFetch(config = {}) {
175
- return async (url, options) => {
176
- const fetchOptions = {
177
- ...options,
178
- ...config,
179
- next: {
180
- ...options?.next,
181
- ...config.next,
182
- },
183
- };
184
- const response = await fetch(url, fetchOptions);
185
- if (!response.ok) {
186
- throw new Error(`Fetch failed: ${response.statusText}`);
187
- }
188
- return response.json();
189
- };
190
- }
191
- /**
192
- * Unstable cache wrapper (Next.js 14+)
193
- */
194
- export function createCachedFunction(fn, options = {}) {
195
- // If revalidation is disabled, bypass cache entirely
196
- if (options.revalidate === false) {
197
- return fn;
198
- }
199
- const ttlMs = (options.revalidate ?? 60) * 1000;
200
- const cache = new Map();
201
- return async (...args) => {
202
- const key = JSON.stringify(args);
203
- const now = Date.now();
204
- const cached = cache.get(key);
205
- if (cached && now < cached.expiresAt) {
206
- return cached.value;
207
- }
208
- const value = await fn(...args);
209
- cache.set(key, { value, expiresAt: now + ttlMs });
210
- return value;
211
- };
212
- }
213
- export class EdgeRateLimiter {
214
- config;
215
- cache = new Map();
216
- constructor(config) {
217
- this.config = config;
218
- }
219
- /**
220
- * Check rate limit
221
- */
222
- check(request) {
223
- const key = this.config.key
224
- ? this.config.key(request)
225
- : request.headers.get('x-forwarded-for') || 'unknown';
226
- const now = Date.now();
227
- let entry = this.cache.get(key);
228
- // Reset if window expired
229
- if (!entry || now > entry.resetTime) {
230
- entry = {
231
- count: 0,
232
- resetTime: now + this.config.window,
233
- };
234
- this.cache.set(key, entry);
235
- }
236
- // Increment count
237
- entry.count++;
238
- const allowed = entry.count <= this.config.limit;
239
- const remaining = Math.max(0, this.config.limit - entry.count);
240
- return {
241
- allowed,
242
- limit: this.config.limit,
243
- remaining,
244
- reset: entry.resetTime,
245
- };
246
- }
247
- /**
248
- * Clean up expired entries
249
- */
250
- cleanup() {
251
- const now = Date.now();
252
- for (const [key, entry] of this.cache.entries()) {
253
- if (now > entry.resetTime) {
254
- this.cache.delete(key);
255
- }
256
- }
257
- }
258
- }
259
- export function getGeoLocation(request) {
260
- // Vercel edge headers
261
- const country = request.headers.get('x-vercel-ip-country');
262
- const region = request.headers.get('x-vercel-ip-country-region');
263
- const city = request.headers.get('x-vercel-ip-city');
264
- const latitude = request.headers.get('x-vercel-ip-latitude');
265
- const longitude = request.headers.get('x-vercel-ip-longitude');
266
- if (!country) {
267
- // Cloudflare headers
268
- const cfCountry = request.headers.get('cf-ipcountry');
269
- if (cfCountry) {
270
- return {
271
- country: cfCountry,
272
- };
273
- }
274
- return null;
275
- }
276
- return {
277
- country: country || undefined,
278
- region: region || undefined,
279
- city: city ? decodeURIComponent(city) : undefined,
280
- latitude: latitude ? parseFloat(latitude) : undefined,
281
- longitude: longitude ? parseFloat(longitude) : undefined,
282
- };
283
- }
284
- /**
285
- * Edge A/B testing with cache
286
- */
287
- export function getABTestVariant(request, testName, variants) {
288
- // Check cookie first
289
- const cookieName = `ab-test-${testName}`;
290
- const cookieVariant = request.cookies.get(cookieName)?.value;
291
- if (cookieVariant && variants.includes(cookieVariant)) {
292
- return cookieVariant;
293
- }
294
- // Assign variant based on IP hash
295
- const ip = request.headers.get('x-forwarded-for') || 'unknown';
296
- const hash = simpleHash(ip + testName);
297
- const variantIndex = hash % variants.length;
298
- const variant = variants[variantIndex];
299
- if (!variant) {
300
- throw new Error('No variant found for A/B test');
301
- }
302
- return variant;
303
- }
304
- /**
305
- * Simple hash function
306
- */
307
- function simpleHash(str) {
308
- let hash = 0;
309
- for (let i = 0; i < str.length; i++) {
310
- const char = str.charCodeAt(i);
311
- hash = (hash << 5) - hash + char;
312
- hash = hash & hash;
313
- }
314
- return Math.abs(hash);
315
- }
316
- export function getPersonalizationConfig(request) {
317
- const userAgent = request.headers.get('user-agent') || '';
318
- const device = getDeviceType(userAgent);
319
- const location = getGeoLocation(request);
320
- return {
321
- userId: request.cookies.get('user-id')?.value,
322
- location: location || undefined,
323
- device,
324
- };
325
- }
326
- /**
327
- * Detect device type
328
- */
329
- function getDeviceType(userAgent) {
330
- if (/mobile/i.test(userAgent) && !/tablet|ipad/i.test(userAgent)) {
331
- return 'mobile';
332
- }
333
- if (/tablet|ipad/i.test(userAgent)) {
334
- return 'tablet';
335
- }
336
- return 'desktop';
337
- }
338
- /**
339
- * Edge cache headers helper
340
- */
341
- export function setEdgeCacheHeaders(response, config) {
342
- const cacheControl = [];
343
- if (config.maxAge !== undefined) {
344
- cacheControl.push(`max-age=${config.maxAge}`);
345
- }
346
- if (config.sMaxAge !== undefined) {
347
- cacheControl.push(`s-maxage=${config.sMaxAge}`);
348
- }
349
- if (config.staleWhileRevalidate !== undefined) {
350
- cacheControl.push(`stale-while-revalidate=${config.staleWhileRevalidate}`);
351
- }
352
- if (cacheControl.length > 0) {
353
- response.headers.set('Cache-Control', cacheControl.join(', '));
354
- }
355
- if (config.tags && config.tags.length > 0) {
356
- response.headers.set('Cache-Tag', config.tags.join(','));
357
- }
358
- return response;
359
- }
360
- /**
361
- * Preload links for critical resources
362
- */
363
- export function addPreloadLinks(response, resources) {
364
- const links = resources.map((resource) => {
365
- const attrs = [`<${resource.href}>`, `rel="preload"`, `as="${resource.as}"`];
366
- if (resource.type) {
367
- attrs.push(`type="${resource.type}"`);
368
- }
369
- if (resource.crossorigin) {
370
- attrs.push('crossorigin');
371
- }
372
- return attrs.join('; ');
373
- });
374
- if (links.length > 0) {
375
- response.headers.set('Link', links.join(', '));
376
- }
377
- return response;
378
- }
379
- /**
380
- * Cache warming for ISR pages
381
- */
382
- export async function warmISRCache(paths, baseURL = process.env.NEXT_PUBLIC_URL || 'http://localhost:3000') {
383
- const results = await Promise.allSettled(paths.map(async (path) => {
384
- const url = new URL(path, baseURL);
385
- const response = await fetch(url.toString());
386
- if (!response.ok) {
387
- throw new Error(`${response.status} ${response.statusText}`);
388
- }
389
- return true;
390
- }));
391
- let warmed = 0;
392
- let failed = 0;
393
- const errors = [];
394
- for (let i = 0; i < results.length; i++) {
395
- const result = results[i];
396
- const path = paths[i];
397
- if (!(result && path)) {
398
- continue;
399
- }
400
- if (result.status === 'fulfilled') {
401
- warmed++;
402
- }
403
- else {
404
- failed++;
405
- errors.push({
406
- path,
407
- error: result.reason instanceof Error
408
- ? result.reason.message
409
- : String(result.reason) || 'Unknown error',
410
- });
411
- }
412
- }
413
- return { warmed, failed, errors };
414
- }
@@ -1,157 +0,0 @@
1
- /**
2
- * Service Worker Utilities
3
- *
4
- * Utilities for service worker registration, caching strategies, and offline support
5
- */
6
- /**
7
- * Service Worker Configuration
8
- */
9
- export interface ServiceWorkerConfig {
10
- scope?: string;
11
- updateViaCache?: 'all' | 'imports' | 'none';
12
- scriptURL?: string;
13
- }
14
- export declare const DEFAULT_SW_CONFIG: ServiceWorkerConfig;
15
- /**
16
- * Register service worker
17
- */
18
- export declare function registerServiceWorker(config?: ServiceWorkerConfig): Promise<ServiceWorkerRegistration | null>;
19
- /**
20
- * Unregister service worker
21
- */
22
- export declare function unregisterServiceWorker(): Promise<boolean>;
23
- /**
24
- * Update service worker
25
- */
26
- export declare function updateServiceWorker(): Promise<void>;
27
- /**
28
- * Skip waiting and activate new service worker
29
- */
30
- export declare function skipWaitingAndActivate(): Promise<void>;
31
- /**
32
- * Cache Strategies
33
- */
34
- export declare const CACHE_STRATEGIES: {
35
- readonly networkFirst: "network-first";
36
- readonly cacheFirst: "cache-first";
37
- readonly networkOnly: "network-only";
38
- readonly cacheOnly: "cache-only";
39
- readonly staleWhileRevalidate: "stale-while-revalidate";
40
- };
41
- export type CacheStrategy = (typeof CACHE_STRATEGIES)[keyof typeof CACHE_STRATEGIES];
42
- /**
43
- * Cache Configuration
44
- */
45
- export interface CacheConfig {
46
- name: string;
47
- version: number;
48
- maxAge?: number;
49
- maxEntries?: number;
50
- strategy?: CacheStrategy;
51
- }
52
- /**
53
- * Default cache configurations
54
- */
55
- export declare const DEFAULT_CACHES: Record<string, CacheConfig>;
56
- /**
57
- * Generate cache name
58
- */
59
- export declare function generateCacheName(config: CacheConfig): string;
60
- /**
61
- * Service worker message types
62
- */
63
- export declare const SW_MESSAGES: {
64
- readonly SKIP_WAITING: "SKIP_WAITING";
65
- readonly CLAIM_CLIENTS: "CLAIM_CLIENTS";
66
- readonly CLEAR_CACHE: "CLEAR_CACHE";
67
- readonly CACHE_URLS: "CACHE_URLS";
68
- readonly DELETE_CACHE: "DELETE_CACHE";
69
- readonly GET_CACHE_SIZE: "GET_CACHE_SIZE";
70
- };
71
- /**
72
- * Post message to service worker
73
- */
74
- export declare function postMessageToSW(type: string, payload?: unknown): Promise<unknown>;
75
- /**
76
- * Clear all caches
77
- */
78
- export declare function clearAllCaches(): Promise<void>;
79
- /**
80
- * Clear specific cache
81
- */
82
- export declare function clearCache(cacheName: string): Promise<void>;
83
- /**
84
- * Precache URLs
85
- */
86
- export declare function precacheURLs(urls: string[]): Promise<void>;
87
- /**
88
- * Get cache size
89
- */
90
- export declare function getCacheSize(): Promise<{
91
- quota: number;
92
- usage: number;
93
- available: number;
94
- }>;
95
- /**
96
- * Check if service worker is supported
97
- */
98
- export declare function isServiceWorkerSupported(): boolean;
99
- /**
100
- * Check if service worker is registered
101
- */
102
- export declare function isServiceWorkerRegistered(): Promise<boolean>;
103
- /**
104
- * Get service worker state
105
- */
106
- export declare function getServiceWorkerState(): Promise<{
107
- registered: boolean;
108
- installing: boolean;
109
- waiting: boolean;
110
- active: boolean;
111
- controller: boolean;
112
- }>;
113
- export interface ServiceWorkerHelper {
114
- register: () => Promise<ServiceWorkerRegistration | null>;
115
- unregister: () => Promise<boolean>;
116
- update: () => Promise<void>;
117
- skipWaitingAndActivate: () => Promise<void>;
118
- state: Promise<{
119
- registered: boolean;
120
- installing: boolean;
121
- waiting: boolean;
122
- active: boolean;
123
- controller: boolean;
124
- }>;
125
- }
126
- /** @deprecated Use `createServiceWorkerHelper` instead */
127
- export type ServiceWorkerHook = ServiceWorkerHelper;
128
- /**
129
- * Create service worker helper with registration, update, and state methods.
130
- * Not a React hook — safe to call conditionally or outside components.
131
- */
132
- export declare function createServiceWorkerHelper(config?: ServiceWorkerConfig): ServiceWorkerHelper;
133
- /**
134
- * Offline detection
135
- */
136
- export declare function isOffline(): boolean;
137
- /**
138
- * Listen for online/offline events
139
- */
140
- export declare function onNetworkChange(callback: (online: boolean) => void): () => void;
141
- /**
142
- * Background sync registration
143
- */
144
- export declare function registerBackgroundSync(tag: string): Promise<void>;
145
- /**
146
- * Push notification permission
147
- */
148
- export declare function requestNotificationPermission(): Promise<NotificationPermission>;
149
- /**
150
- * Subscribe to push notifications
151
- */
152
- export declare function subscribeToPush(vapidPublicKey: string): Promise<PushSubscription | null>;
153
- /**
154
- * Unsubscribe from push notifications
155
- */
156
- export declare function unsubscribeFromPush(): Promise<boolean>;
157
- //# sourceMappingURL=service-worker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"service-worker.d.ts","sourceRoot":"","sources":["../../src/caching/service-worker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,MAAM,CAAA;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,eAAO,MAAM,iBAAiB,EAAE,mBAI/B,CAAA;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,GAAE,mBAAuC,GAC9C,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CA6C3C;AAED;;GAEG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,OAAO,CAAC,CAehE;AAED;;GAEG;AACH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