UNPKG

@stagewise-plugins/angular

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.

9 lines (7 loc) 3.62 kB
"use client"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const plugin = { mainPlugin: "import { jsxs as s, jsx as i } from \"react/jsx-runtime\";\nfunction d() {\n return /* @__PURE__ */ s(\n \"svg\",\n {\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 960 960\",\n fill: \"currentColor\",\n stroke: \"currentColor\",\n children: [\n /* @__PURE__ */ i(\"title\", { children: \"Angular Logo\" }),\n /* @__PURE__ */ s(\"g\", { children: [\n /* @__PURE__ */ i(\"polygon\", { points: \"562.6,109.8 804.1,629.5 829.2,233.1 \t\" }),\n /* @__PURE__ */ i(\"polygon\", { points: \"624.9,655.9 334.3,655.9 297.2,745.8 479.6,849.8 662,745.8 \t\" }),\n /* @__PURE__ */ i(\"polygon\", { points: \"384.1,539.3 575.2,539.3 479.6,307 \t\" }),\n /* @__PURE__ */ i(\"polygon\", { points: \"396.6,109.8 130,233.1 155.1,629.5 \t\" })\n ] })\n ]\n }\n );\n}\nlet c = !1;\nfunction u() {\n !window.parent.ng && !c && (console.warn(\n \"Angular plugin: No Angular instance (window.ng) detected or Angular is not in development mode. Component detection features will not be available.\"\n ), c = !0);\n}\nfunction f(n) {\n const e = {};\n for (const t of Object.getOwnPropertyNames(n))\n e[t] = n[t];\n return e;\n}\nfunction h(n) {\n const e = f(n);\n return p(e, n);\n}\nfunction w(n) {\n return p(n.ownProperties, null);\n}\nfunction p(n, e) {\n if (!window.parent.ng || !window.parent.ng.getComponent)\n return [];\n const t = [];\n let o = e;\n const l = 3;\n if (o)\n for (; o && t.length < l; ) {\n try {\n const a = window.parent.ng.getComponent(\n o\n );\n if (a) {\n let r = a.constructor.name;\n r.startsWith(\"_\") && (r = r.substring(1)), r && r !== \"Object\" && (t.some((g) => g.name === r) || t.push({ name: r }));\n }\n } catch {\n }\n if (o.parentElement && o.parentElement !== document.body)\n o = o.parentElement;\n else\n break;\n }\n return t;\n}\nfunction m(n) {\n if (u(), !n)\n return { annotation: null };\n const e = h(n);\n return e.length > 0 && e[0] ? {\n annotation: `${e[0].name}`\n } : { annotation: null };\n}\nfunction A(n) {\n if (u(), !n || n.length === 0)\n return null;\n const e = n.map(\n (t) => w(t)\n );\n return e.some((t) => t.length > 0) ? `This is additional information on the elements that the user selected. Use this information to find the correct element in the codebase.\n\n ${e.map((o, l) => {\n const a = o.length === 0 ? \"No Angular component detected for this element\" : `Angular component tree (from closest to farthest, ${o.length} closest element${o.length > 1 ? \"s\" : \"\"}): ${o.map((r) => `{name: ${r.name}}`).join(\" child of \")}`;\n return `\n<element index=\"${l + 1}\">\n ${a}\n</element>\n `;\n }).join(\"\")}\n ` : null;\n}\nconst C = {\n displayName: \"Angular\",\n description: \"This plugin adds additional information and metadata for apps using Angular as a UI framework\",\n iconSvg: /* @__PURE__ */ i(d, {}),\n pluginName: \"angular\",\n onContextElementHover: m,\n onContextElementSelect: m,\n onPromptSend: (n) => {\n const e = A(n.metadata.selectedElements);\n return e ? {\n contextSnippets: [\n {\n promptContextName: \"elements-angular-component-info\",\n content: e\n }\n ]\n } : { contextSnippets: [] };\n }\n};\nexport {\n C as default\n};\n", loader: true } exports.default = plugin;