diff --git a/index.html b/index.html
index b02bfc0..f49fe99 100644
--- a/index.html
+++ b/index.html
@@ -8,12 +8,17 @@
Nebula
+
+
diff --git a/package.json b/package.json
index 90f2215..321f6f9 100644
--- a/package.json
+++ b/package.json
@@ -27,7 +27,8 @@
"react-helmet": "^6.1.0",
"react-i18next": "^13.5.0",
"react-icons": "^4.12.0",
- "tsx": "^4.7.0"
+ "tsx": "^4.7.0",
+ "dynamic-npm": "github:notplayingallday383/dynamic-npm"
},
"devDependencies": {
"@preact/preset-vite": "^2.5.0",
diff --git a/public/dynamic/dynamic.config.js b/public/dynamic/dynamic.config.js
new file mode 100644
index 0000000..132c571
--- /dev/null
+++ b/public/dynamic/dynamic.config.js
@@ -0,0 +1,28 @@
+self.__dynamic$config = {
+ prefix: '/dyn/',
+ encoding: 'xor',
+ mode: 'production',
+ logLevel: 0,
+ bare: {
+ version: 3,
+ path: '/bare/',
+ },
+ tab: {
+ title: 'Service',
+ icon: null,
+ ua: null,
+ },
+ assets: {
+ prefix: '/dynamic/',
+ files: {
+ handler: 'dynamic.handler.js',
+ client: 'dynamic.client.js',
+ worker: 'dynamic.worker.js',
+ config: 'dynamic.config.js',
+ inject: null,
+ }
+ },
+ block: [
+
+ ]
+};
\ No newline at end of file
diff --git a/public/dynsw.js b/public/dynsw.js
new file mode 100644
index 0000000..0260d8c
--- /dev/null
+++ b/public/dynsw.js
@@ -0,0 +1,19 @@
+importScripts('/dynamic/dynamic.config.js');
+importScripts('/dynamic/dynamic.worker.js');
+
+const sw = new UVServiceWorker();
+const dynamic = new Dynamic();
+self.dynamic = dynamic;
+self.addEventListener('fetch',
+ event => {
+ event.respondWith(
+ (async function() {
+ if (await dynamic.route(event)) {
+ return await dynamic.fetch(event);
+ }
+
+ return await fetch(event.request);
+ })()
+ );
+ }
+);
\ No newline at end of file
diff --git a/public/sw.js b/public/sw.js
index 3082bb9..0df4b72 100644
--- a/public/sw.js
+++ b/public/sw.js
@@ -2,6 +2,4 @@ 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)));
diff --git a/vite.config.ts b/vite.config.ts
index e04660d..7a14077 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -3,16 +3,21 @@ import { defineConfig } from "vite";
import preact from "@preact/preset-vite";
import { viteStaticCopy } from "vite-plugin-static-copy";
import { uvPath } from "@titaniumnetwork-dev/ultraviolet";
+import { dynPath } from "dynamic-npm";
export default defineConfig({
plugins: [
viteStaticCopy({
targets: [
{
- // .replace fixes weird paths on Windows
src: `${uvPath}/uv.*.js`.replace(/\\/g, "/"),
dest: "uv",
overwrite: false
+ },
+ {
+ src: `${dynPath}/dynamic.*.js`.replace(/\\/g, "/"),
+ dest: "dynamic",
+ overwrite: false
}
]
}),