This commit is contained in:
proudparrot2
2024-04-22 09:39:55 -05:00
commit be1599a8cb
50 changed files with 4276 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
export interface Item {
title: string
image: string
url: string
}
+32
View File
@@ -0,0 +1,32 @@
import { type ClassValue, clsx } from 'clsx'
import { twMerge } from 'tailwind-merge'
import { useRouter } from 'next/navigation'
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
export const fetcher = (url: string) => fetch(url).then((res) => res.json())
export function encodeXor(str: string) {
if (!str) return str
return encodeURIComponent(
str
.toString()
.split('')
.map((char, ind) => (ind % 2 ? String.fromCharCode(char.charCodeAt(NaN) ^ 2) : char))
.join('')
)
}
export function formatSearch(input: string): string {
try {
return new URL(input).toString()
} catch (e) {}
try {
const url = new URL(`http://${input}`)
if (url.hostname.includes('.')) return url.toString()
} catch (e) {}
return new URL(`https://google.com/search?q=${input}`).toString()
}
+14
View File
@@ -0,0 +1,14 @@
/*global UVServiceWorker,__uv$config*/
/*
* Stock service worker script.
* Users can provide their own sw.js if they need to extend the functionality of the service worker.
* Ideally, this will be registered under the scope in uv.config.js so it will not need to be modified.
* However, if a user changes the location of uv.bundle.js/uv.config.js or sw.js is not relative to them, they will need to modify this script locally.
*/
importScripts('/uv/uv.bundle.js');
importScripts('/uv/uv.config.js');
importScripts(__uv$config.sw || '/uv/uv.sw.js');
const sw = new UVServiceWorker();
self.addEventListener('fetch', (event) => event.respondWith(sw.fetch(event)));
+12
View File
@@ -0,0 +1,12 @@
/*global Ultraviolet*/
self.__uv$config = {
prefix: '/uv/service/',
bare: '/api/bare/',
encodeUrl: Ultraviolet.codec.xor.encode,
decodeUrl: Ultraviolet.codec.xor.decode,
handler: '/uv/uv.handler.js',
client: '/uv/uv.client.js',
bundle: '/uv/uv.bundle.js',
config: '/uv/uv.config.js',
sw: '/uv/uv.sw.js',
};