feat: add service worker support
This commit is contained in:
parent
45e6b6d390
commit
1524ff5c57
|
@ -45,6 +45,7 @@ interface OpenQuery {
|
||||||
dest: Worker;
|
dest: Worker;
|
||||||
nonce: string;
|
nonce: string;
|
||||||
origin: string;
|
origin: string;
|
||||||
|
sw?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OpenQueryResponse {
|
export interface OpenQueryResponse {
|
||||||
|
@ -52,6 +53,7 @@ export interface OpenQueryResponse {
|
||||||
method: string;
|
method: string;
|
||||||
data: any;
|
data: any;
|
||||||
err?: any;
|
err?: any;
|
||||||
|
sw?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the stateful variables for managing the modules. We track the set of
|
// Define the stateful variables for managing the modules. We track the set of
|
||||||
|
@ -464,6 +466,7 @@ async function handleModuleCall(
|
||||||
dest: worker,
|
dest: worker,
|
||||||
nonce: event.data.nonce,
|
nonce: event.data.nonce,
|
||||||
origin: event.origin,
|
origin: event.origin,
|
||||||
|
sw: event.data.sw,
|
||||||
} as OpenQuery;
|
} as OpenQuery;
|
||||||
|
|
||||||
// Send the message to the worker to start the query.
|
// Send the message to the worker to start the query.
|
||||||
|
@ -667,6 +670,7 @@ function handleModuleResponse(
|
||||||
nonce: sourceNonce,
|
nonce: sourceNonce,
|
||||||
method: event.data.method,
|
method: event.data.method,
|
||||||
data: event.data.data,
|
data: event.data.data,
|
||||||
|
sw: event.data.sw,
|
||||||
};
|
};
|
||||||
// For responses only, set an error and close out the query by deleting it
|
// For responses only, set an error and close out the query by deleting it
|
||||||
// from the query map.
|
// from the query map.
|
||||||
|
@ -701,6 +705,7 @@ function handleQueryUpdate(event: MessageEvent) {
|
||||||
nonce: event.data.nonce,
|
nonce: event.data.nonce,
|
||||||
method: event.data.method,
|
method: event.data.method,
|
||||||
data: event.data.data,
|
data: event.data.data,
|
||||||
|
sw: event.data.sw,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue