UNPKG

@phoria/phoria-vue

Version:

Use Vue with Phoria Islands for dotnet.

34 lines (33 loc) 1.08 kB
import { importComponent as c, registerSsrService as p } from "@phoria/phoria"; import { framework as t } from "./main.js"; import { createSSRApp as m } from "vue"; import { renderToString as s, renderToWebStream as d } from "vue/server-renderer"; const k = (r, n) => { const e = m(r.component, n); return s(e, {}); }, i = async (r, n) => { const e = m(r.component, n); return d(e, {}); }; function x(r) { return r.framework === t.name; } const f = { render: async (r, n, e) => { if (r.framework !== t.name) throw new Error(`${t.name} cannot render the ${r.framework} component named "${r.name}".`); const o = await c(r), a = await ((e == null ? void 0 : e.renderComponent) ?? i)(o, n); return { framework: t.name, // With Vue, we could also get the component path from `ctx.modules`, but then it'd be inconsistent with other frameworks that don't expose that componentPath: o.componentPath, html: a }; } }; p(t.name, f); export { x as isVueIsland, i as renderComponentToStream, k as renderComponentToString };