typedserver/ts_interfaces/serviceworker.ts
2024-05-11 12:51:20 +02:00

127 lines
3.0 KiB
TypeScript

import * as plugins from './plugins.js';
export interface CacheStorage {
keys: () => Promise<string[]>;
match: any;
open: any;
delete: any;
}
export declare var caches: CacheStorage;
// =============================
// Interfaces for communication
// =============================
export interface IMessage_Serviceworker_Client_UpdateInfo
extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IMessage_Serviceworker_Client_UpdateInfo
> {
method: 'serviceworker_newVersion';
request: {
appVersion: string;
appHash: string;
};
response: {};
}
export interface IMessage_Serviceworker_Client_RequestReload
extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IMessage_Serviceworker_Client_RequestReload
> {
method: 'serviceworker_requestReload';
request: {};
response: {};
}
export interface IRequest_Serviceworker_Backend_VersionInfo
extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IRequest_Serviceworker_Backend_VersionInfo
> {
method: 'serviceworker_versionInfo';
request: {};
response: {
appHash: string;
appSemVer: string;
};
}
// ===============
// web
// ===============
/**
* purges the service workers cache
*/
export interface IRequest_PurgeServiceWorkerCache extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IRequest_PurgeServiceWorkerCache
> {
method: 'purgeServiceWorkerCache';
request: {};
response: {};
}
/**
* updates the info in all connected tabs
*/
export interface IMessage_Serviceworker_Client_UpdateInfo
extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IMessage_Serviceworker_Client_UpdateInfo
> {
method: 'serviceworker_newVersion';
request: {
appVersion: string;
appHash: string;
};
response: {};
}
/**
* requests all clients to reload
*/
export interface IMessage_Serviceworker_Client_RequestReload
extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IMessage_Serviceworker_Client_RequestReload
> {
method: 'serviceworker_requestReload';
request: {};
response: {};
}
/**
* updates version infos
*/
export interface IRequest_Serviceworker_Backend_VersionInfo
extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IRequest_Serviceworker_Backend_VersionInfo
> {
method: 'serviceworker_versionInfo';
request: {};
response: {
appHash: string;
appSemVer: string;
};
}
/**
* ensures a stable connection between clients and the serviceworker
*/
export interface IRequest_Client_Serviceworker_ConnectionPolling
extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IRequest_Client_Serviceworker_ConnectionPolling
> {
method: 'broadcastConnectionPolling',
request: {
tabId: string;
},
response: {
serviceworkerId: string;
}
}