Merge upstream #40
3 changed files with 7 additions and 3 deletions
|
@ -61,7 +61,6 @@ export class DownloadService {
|
||||||
request: operationTimeout, // whole operation timeout
|
request: operationTimeout, // whole operation timeout
|
||||||
},
|
},
|
||||||
agent: {
|
agent: {
|
||||||
http: this.httpRequestService.httpAgent,
|
|
||||||
https: this.httpRequestService.httpsAgent,
|
https: this.httpRequestService.httpsAgent,
|
||||||
},
|
},
|
||||||
http2: false, // default
|
http2: false, // default
|
||||||
|
|
|
@ -118,7 +118,6 @@ export class UrlPreviewService {
|
||||||
private fetchSummary(url: string, meta: MiMeta, lang?: string): Promise<SummalyResult> {
|
private fetchSummary(url: string, meta: MiMeta, lang?: string): Promise<SummalyResult> {
|
||||||
const agent = this.config.proxy
|
const agent = this.config.proxy
|
||||||
? {
|
? {
|
||||||
http: this.httpRequestService.httpAgent,
|
|
||||||
https: this.httpRequestService.httpsAgent,
|
https: this.httpRequestService.httpsAgent,
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
|
@ -43,7 +43,7 @@ async function cacheWithFallback(cache, paths) {
|
||||||
globalThis.addEventListener('install', (ev) => {
|
globalThis.addEventListener('install', (ev) => {
|
||||||
ev.waitUntil((async () => {
|
ev.waitUntil((async () => {
|
||||||
const storage = await requestStorage();
|
const storage = await requestStorage();
|
||||||
registerFetchHandler(storage);
|
await registerFetchHandler(storage);
|
||||||
const cache = await caches.open(STATIC_CACHE_NAME);
|
const cache = await caches.open(STATIC_CACHE_NAME);
|
||||||
await cacheWithFallback(cache, PATHS_TO_CACHE);
|
await cacheWithFallback(cache, PATHS_TO_CACHE);
|
||||||
await globalThis.skipWaiting();
|
await globalThis.skipWaiting();
|
||||||
|
@ -75,6 +75,12 @@ async function offlineContentHTML() {
|
||||||
|
|
||||||
async function registerFetchHandler(root: FileSystemDirectoryHandle | null) {
|
async function registerFetchHandler(root: FileSystemDirectoryHandle | null) {
|
||||||
console.debug('rootfs:', root);
|
console.debug('rootfs:', root);
|
||||||
|
const state = await root?.getFileHandle('state.json', { create: true })
|
||||||
|
await state?.createWritable().then(async writable => {
|
||||||
|
await writable.write(JSON.stringify({ started: Date.now() }));
|
||||||
|
await writable.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
globalThis.addEventListener('fetch', ev => {
|
globalThis.addEventListener('fetch', ev => {
|
||||||
const shouldCache = PATHS_TO_CACHE.some(path => ev.request.url.includes(path));
|
const shouldCache = PATHS_TO_CACHE.some(path => ev.request.url.includes(path));
|
||||||
|
|
Loading…
Reference in a new issue