mirror of
https://github.com/titaniumnetwork-dev/Ultraviolet.git
synced 2025-05-16 13:00:01 -04:00
Almost done!
This commit is contained in:
parent
da5c0c88b1
commit
355e87dd21
13 changed files with 262 additions and 38 deletions
14
lib/uv.sw.js
14
lib/uv.sw.js
|
@ -1,4 +1,5 @@
|
|||
importScripts('/uv.bundle.js');
|
||||
importScripts('/uv.config.js')
|
||||
|
||||
const csp = [
|
||||
'cross-origin-embedder-policy',
|
||||
|
@ -63,11 +64,7 @@ const statusCode = {
|
|||
],
|
||||
};
|
||||
|
||||
const handler = UVServiceWorker('/bare/', {
|
||||
prefix: '/sw/',
|
||||
encodeUrl: Ultraviolet.codec.xor.encode,
|
||||
decodeUrl: Ultraviolet.codec.xor.decode,
|
||||
});
|
||||
const handler = UVServiceWorker(__uv$config.bare, __uv$config);
|
||||
|
||||
addEventListener('fetch', async event =>
|
||||
event.respondWith(handler(event))
|
||||
|
@ -204,7 +201,7 @@ function UVServiceWorker(bare = '/bare/', options) {
|
|||
switch(request.destination) {
|
||||
case 'script':
|
||||
case 'worker':
|
||||
responseCtx.body = `if (!self.__uv && self.importScripts) importScripts('/uv.bundle.js', '/uv.handler.js');\n`;
|
||||
responseCtx.body = `if (!self.__uv && self.importScripts) importScripts('${__uv$config.bundle}', '${__uv$config.config}', '${__uv$config.handler}');\n`;
|
||||
responseCtx.body += uv.js.rewrite(
|
||||
await response.text()
|
||||
);
|
||||
|
@ -222,8 +219,9 @@ function UVServiceWorker(bare = '/bare/', options) {
|
|||
{
|
||||
document: true ,
|
||||
injectHead: uv.createHtmlInject(
|
||||
scripts.handler,
|
||||
scripts.package,
|
||||
options.handler,
|
||||
options.bundle,
|
||||
options.config,
|
||||
uv.cookie.serialize(cookies, uv.meta, true),
|
||||
request.referrer
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue