UNPKG

@scalar/api-client

Version:

the open source API testing client

34 lines (33 loc) 1.18 kB
import { createApp as l } from "vue"; import { createRouter as p, createWebHistory as u, createWebHashHistory as d } from "vue-router"; import f from "../App.vue.js"; /* empty css */ import { createAppState as A } from "../app-state.js"; import { ROUTES as c } from "./routes.js"; import { useCommandPaletteState as h } from "../../command-palette/hooks/use-command-palette-state.js"; const S = (t) => t === "web" ? p({ history: u(), routes: c }) : p({ history: d(), routes: c }), k = async (t, { layout: r = "desktop", plugins: i, customThemes: m, fallbackThemeSlug: n = "default" }) => { const o = S(r), a = await A({ router: o }), s = h(), e = l(f, { layout: r, plugins: i, customThemes: m, fallbackThemeSlug: n, getAppState: () => a, getCommandPaletteState: () => s }); if (e.use(o), !t) { console.error( "[@scalar/api-client-modal] Could not create the API client.", "Invalid HTML element provided.", "Read more: https://github.com/scalar/scalar/tree/main/packages/api-client" ); return; } return e.mount(t), { app: e, state: a }; }; export { k as createApiClientApp, S as createAppRouter };