@stacksjs/stx
Version:
A performant UI Framework. Powered by Bun.
52 lines • 1.62 kB
TypeScript
import { } from './workbox-strategies';
import type { StxOptions } from '../types';
/**
* Generate Workbox configuration from stx options
*/
export declare function generateWorkboxConfig(options: StxOptions, outputDir?: string): WorkboxConfig;
/**
* Generate Workbox service worker JavaScript code
*/
export declare function generateWorkboxServiceWorker(options: StxOptions, outputDir?: string): string;
/**
* Check if Workbox mode is enabled in config
*/
export declare function isWorkboxEnabled(options: StxOptions): boolean;
/**
* Get the appropriate service worker generator based on config
*/
export declare function getServiceWorkerGenerator(options: StxOptions): (options: StxOptions, outputDir?: string) => string;
// ============================================================================
// Types
// ============================================================================
export declare interface WorkboxConfig {
mode: 'inject' | 'generate'
modules: WorkboxModule[]
precacheManifest?: PrecacheEntry[]
runtimeCaching?: RuntimeCacheRule[]
skipWaiting?: boolean
clientsClaim?: boolean
offlineFallback?: string
navigationPreload?: boolean
cacheVersion?: string
}
export declare interface WorkboxModule {
name: string
exports: string[]
}
export declare interface PrecacheEntry {
url: string
revision?: string | null
}
export declare interface RuntimeCacheRule {
urlPattern: string | RegExp
handler: string
options?: {
cacheName?: string
expiration?: {
maxEntries?: number
maxAgeSeconds?: number
}
networkTimeoutSeconds?: number
}
}