UNPKG

@stagewise-plugins/vue

Version:

> [!CAUTION] > This package is deprecated. > > There thus will be no further support or assistance with this version. > > Follow the guide in [the stagewise documentation](https://stagewise.io) to upgrade.

118 lines (116 loc) 4.14 kB
import { jsxs as _, jsx as m } from "react/jsx-runtime"; function y() { return /* @__PURE__ */ _( "svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 261.76 226.69", fill: "currentColor", children: [ /* @__PURE__ */ m("title", { children: "Vue Logo" }), /* @__PURE__ */ _( "g", { xmlns: "http://www.w3.org/2000/svg", transform: "matrix(1.3333 0 0 -1.3333 -76.311 313.34)", children: [ /* @__PURE__ */ m("g", { transform: "translate(178.06 235.01)", fillOpacity: "0.5", children: /* @__PURE__ */ m("path", { d: "m0 0-22.669-39.264-22.669 39.264h-75.491l98.16-170.02 98.16 170.02z" }) }), /* @__PURE__ */ m("g", { transform: "translate(178.06 235.01)", "fill-opacity": "1", children: /* @__PURE__ */ m("path", { d: "m0 0-22.669-39.264-22.669 39.264h-36.227l58.896-102.01 58.896 102.01z" }) }) ] } ) ] } ); } let f = !1; function g(n) { const o = {}; for (const e of Object.getOwnPropertyNames(n)) o[e] = n[e]; return o; } function w(n) { const o = g(n); return h(n, o); } function $(n) { return h(null, n.ownProperties); } function h(n, o) { if (!o && !n) return null; const e = [], l = 3, s = o || g(n), p = s.__vueParentComponent; if (p?.type?.__name) { const t = p.type.__name; e.some((r) => r.name === t) || e.push({ name: t, type: "regular" }); } let u = []; s.__vms__ && Array.isArray(s.__vms__) ? u = s.__vms__ : s.__vue__ && (u = [s.__vue__]); for (const t of u) { if (!t || !t.$options) continue; let r = t.$options.name || t.$options.__file || t.$options._componentTag || "AnonymousComponent"; r && typeof r == "string" && r.includes("/") && (r = (String(r).split("/").pop() || "").replace(/\.vue$/, "")), e.some((c) => c.name === r) || e.push({ name: r, type: "regular" }); } if (n && e.length < l) { let t = n.parentElement; for (; t && e.length < l; ) { const r = t.__vueParentComponent; if (r?.type?.__name) { const a = r.type.__name; e.some((i) => i.name === a) || e.push({ name: a, type: "regular" }); } let c = []; t.__vms__ && Array.isArray(t.__vms__) ? c = t.__vms__ : t.__vue__ && (c = [t.__vue__]); for (const a of c) { if (!a || !a.$options) continue; let i = a.$options.name || a.$options.__file || a.$options._componentTag || "AnonymousComponent"; i && typeof i == "string" && i.includes("/") && (i = (String(i).split("/").pop() || "").replace(/\.vue$/, "")), e.some((v) => v.name === i) || e.push({ name: i, type: "regular" }); } t = t.parentElement; } } return e.length === 0 && !f && (console.warn( "[stagewise/vue] No Vue installation detected on the selected element. Make sure you are running in development mode and Vue is available." ), f = !0), e.length > 0 ? e : null; } function d(n) { const o = w(n); return o?.[0] ? { annotation: `${o[0].name}` } : { annotation: null }; } function C(n) { const o = n.map( (e) => $(e) ); return o.some((e) => e && e.length > 0) ? `This is additional information on the elements that the user selected. Use this information to find the correct element in the codebase. ${o.map((l, s) => ` <element index="${s + 1}"> ${l.length === 0 ? "No Vue component as parent detected" : `Vue component tree (from closest to farthest, 3 closest elements): ${l.map((p) => `{name: ${p.name}, type: ${p.type}}`).join(" child of ")}`} </element> `)} ` : null; } const V = { displayName: "Vue", description: "This plugin adds additional information and metadata for apps using Vue as an UI framework", iconSvg: /* @__PURE__ */ m(y, {}), pluginName: "vue", onContextElementHover: d, onContextElementSelect: d, onPromptSend: (n) => { const o = C(n.metadata.selectedElements); return o ? { contextSnippets: [ { promptContextName: "elements-vue-component-info", content: o } ] } : { contextSnippets: [] }; } }; export { V as default };