-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
159 additions
and
562 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,3 @@ dist | |
docs/.vitepress/dist | ||
docs/.vitepress/cache | ||
.vitepress | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
import react from "@vitejs/plugin-react"; | ||
import unocss from "unocss/vite"; | ||
import { config } from "vinxi/plugins/config"; | ||
|
||
import { fileURLToPath } from "node:url"; | ||
|
||
import unocssConfig from "./uno.config.js"; | ||
|
||
/** @returns {import('vinxi').RouterSchemaInput} */ | ||
export const devtoolsClientDev = () => { | ||
return { | ||
name: "devtools-client", | ||
mode: "spa", | ||
handler: fileURLToPath(new URL("./index.html.js", import.meta.url)), | ||
target: "browser", | ||
base: "/__devtools/client", | ||
plugins: () => [unocss(unocssConfig), react()], | ||
plugins: () => [ | ||
unocss(unocssConfig), | ||
react(), | ||
{ | ||
name: "remove-vinxi-inject", | ||
config(config) { | ||
return { | ||
plugins: config.plugins | ||
.flat() | ||
.filter((plugin) => plugin?.name !== "vinxi:inject-client"), | ||
}; | ||
}, | ||
}, | ||
], | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,72 @@ | ||
/** | ||
* | ||
* @returns {import("../vite-dev.d.ts").Plugin} | ||
* @returns {import("../vite-dev.d.ts").Plugin[]} | ||
*/ | ||
export function manifest() { | ||
/** @type {import("../router-mode.js").Router | undefined} */ | ||
let router; | ||
/** @type {import("../app.js").App | undefined} */ | ||
let app; | ||
|
||
return { | ||
name: "vinxi:manifest", | ||
config(config) { | ||
router = config.router; | ||
app = config.app; | ||
return [ | ||
{ | ||
name: "vinxi:manifest", | ||
config(config) { | ||
router = config.router; | ||
app = config.app; | ||
|
||
if (!router || !app) { | ||
throw new Error("Missing router or app"); | ||
} | ||
return { | ||
define: { | ||
"import.meta.env.MANIFEST": `globalThis.MANIFEST`, | ||
"import.meta.env.ROUTER_NAME": JSON.stringify(router.name), | ||
"import.meta.env.ROUTER_HANDLER": JSON.stringify(router.handler), | ||
"import.meta.env.CWD": JSON.stringify(router.root), | ||
"import.meta.env.ROUTERS": JSON.stringify( | ||
app.config.routers.map((router) => router.name), | ||
), | ||
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV), | ||
"import.meta.env.DEVTOOLS": config.dev?.devtools | ||
? JSON.stringify(config.dev.devtools) | ||
: `false`, | ||
}, | ||
}; | ||
}, | ||
transformIndexHtml(html) { | ||
return [ | ||
{ | ||
tag: "script", | ||
attrs: { | ||
type: "module", | ||
src: `/@fs${process.cwd()}/node_modules/vinxi/runtime/client.js`, | ||
}, | ||
}, | ||
]; | ||
}, | ||
async load(id) { | ||
if (id.startsWith("/@manifest")) { | ||
if (!router || !app) { | ||
throw new Error("Missing router or app"); | ||
} | ||
return { | ||
define: { | ||
"import.meta.env.MANIFEST": `globalThis.MANIFEST`, | ||
"import.meta.env.ROUTER_NAME": JSON.stringify(router.name), | ||
"import.meta.env.ROUTER_HANDLER": JSON.stringify(router.handler), | ||
"import.meta.env.CWD": JSON.stringify(router.root), | ||
"import.meta.env.ROUTERS": JSON.stringify( | ||
app.config.routers.map((router) => router.name), | ||
), | ||
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV), | ||
"import.meta.env.DEVTOOLS": config.dev?.devtools | ||
? JSON.stringify(config.dev.devtools) | ||
: `false`, | ||
}, | ||
}; | ||
}, | ||
async load(id) { | ||
if (id.startsWith("/@manifest")) { | ||
if (!router || !app) { | ||
throw new Error("Missing router or app"); | ||
} | ||
|
||
const [path, query] = id.split("?"); | ||
const params = new URLSearchParams(query); | ||
if (path.endsWith("assets")) { | ||
const id = params.get("id"); | ||
if (!id) { | ||
throw new Error("Missing id to get assets."); | ||
const [path, query] = id.split("?"); | ||
const params = new URLSearchParams(query); | ||
if (path.endsWith("assets")) { | ||
const id = params.get("id"); | ||
if (!id) { | ||
throw new Error("Missing id to get assets."); | ||
} | ||
return `export default ${JSON.stringify( | ||
await globalThis.MANIFEST[router.name].inputs[id].assets(), | ||
)}`; | ||
} | ||
return `export default ${JSON.stringify( | ||
await globalThis.MANIFEST[router.name].inputs[id].assets(), | ||
)}`; | ||
} | ||
} | ||
}, | ||
}, | ||
{ | ||
name: "vinxi:inject-client", | ||
transformIndexHtml(html) { | ||
return [ | ||
{ | ||
tag: "script", | ||
attrs: { | ||
type: "module", | ||
src: `/@fs${process.cwd()}/node_modules/vinxi/runtime/client.js`, | ||
}, | ||
}, | ||
]; | ||
}, | ||
}, | ||
}; | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.