"scripts": "import { createCommentVNode as _createCommentVNode, createElementVNode as _createElementVNode, withModifiers as _withModifiers, normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, openBlock as _openBlock, createElementBlock as _createElementBlock } from \"/node_modules/.vite/deps/vue.js?v=browserHash\"\n\nconst _hoisted_1 = {\n id: \"vueInspectorControl\",\n ref: \"target\",\n src: \"https://github.com/webfansplz/vite-plugin-vue-inspector/blob/main/docs/images/logo.png?raw=true\",\n alt: \"logo\",\n draggable: \"false\"\n}\nconst _hoisted_2 = /*#__PURE__*/_createTextVNode(\" file: \")\nconst _hoisted_3 = /*#__PURE__*/_createTextVNode(\" line: \")\nconst _hoisted_4 = /*#__PURE__*/_createTextVNode(\" column: \")\n\nexport function render(_ctx, _cache) {\n return (_openBlock(), _createElementBlock(\"div\", null, [\n _createCommentVNode(\" switch control \"),\n _createElementVNode(\"div\", {\n class: _normalizeClass([\"vue-inspector-control\", {disabled: _ctx.disabled}]),\n style: _normalizeStyle(_ctx.controlStyle),\n onClick: _cache[0] || (_cache[0] = _withModifiers((...args) => (_ctx.toggleControl && _ctx.toggleControl(...args)), [\"stop\"]))\n }, [\n _createElementVNode(\"img\", _hoisted_1, null, 512 /* NEED_PATCH */)\n ], 6 /* CLASS, STYLE */),\n _createCommentVNode(\" overlay \"),\n (_ctx.overlayVisible)\n ? (_openBlock(), _createElementBlock(\"ul\", {\n key: 0,\n ref: \"overlayTarget\",\n class: \"vue-inspector-overlay\",\n style: _normalizeStyle(_ctx.overlayStyle)\n }, [\n _createElementVNode(\"li\", null, [\n _hoisted_2,\n _createElementVNode(\"em\", null, _toDisplayString(`<${_ctx.navigationParams.title}>`), 1 /* TEXT */)\n ]),\n _createElementVNode(\"li\", null, [\n _hoisted_3,\n _createElementVNode(\"em\", null, _toDisplayString(_ctx.navigationParams.line), 1 /* TEXT */)\n ]),\n _createElementVNode(\"li\", null, [\n _hoisted_4,\n _createElementVNode(\"em\", null, _toDisplayString(_ctx.navigationParams.column), 1 /* TEXT */)\n ])\n ], 4 /* STYLE */))\n : _createCommentVNode(\"v-if\", true)\n ]))\n}\nconst isClient = typeof window !== \"undefined\"\nconst App = {\n props: {\n enabled: {\n type: Boolean,\n default: true,\n },\n },\n data() {\n return {\n target: null,\n overlayTarget: null,\n disabled: isClient ? !(window.__VUE_INSPECTOR_INITIAL_ENABLED__) : !this.enabled,\n overlayVisible: false,\n\n navigationParams: {\n file: \"\",\n line: 0,\n column: 0,\n },\n position: {\n x: 0,\n y: 0,\n },\n\n // drag control\n controlPosition: {\n x: 0,\n y: 0,\n },\n pressedDelta: undefined,\n }\n },\n computed: {\n controlStyle() {\n if (!isClient) return \"\"\n const left = this.controlPosition.x || window.clientWidth\n const top = this.controlPosition.y || 20\n return `left:${left}px;top:${top}px;`\n },\n overlayStyle() {\n return {\n left: `${\n this.position.x - this.$refs.overlayTarget?.clientWidth / 2 || 0\n }px`,\n top: `${this.position.y + 20}px`,\n }\n },\n },\n mounted() {\n this.$refs.target?.addEventListener(\"pointerdown\", this.dragStart, true)\n window.addEventListener(\"pointermove\", this.dragMove, true)\n window.addEventListener(\"pointerup\", this.dragEnd, true)\n\n window.addEventListener(\"click\", this.onFetch)\n window.addEventListener(\"mousemove\", this.onMouseMove)\n },\n methods: {\n dragStart(e) {\n e.stopPropagation()\n if (e.target !== this.$refs.target) return\n const rect = this.$refs.target?.getBoundingClientRect()\n const pos = {\n x: e.pageX - rect.left,\n y: e.pageY - rect.top,\n }\n this.pressedDelta = pos\n },\n dragMove(e) {\n if (!this.pressedDelta) return\n this.controlPosition = {\n x: e.pageX - this.pressedDelta.x,\n y: e.pageY - this.pressedDelta.y,\n }\n },\n dragEnd() {\n if (!this.pressedDelta) return\n this.pressedDelta = undefined\n },\n\n toggleControl() {\n this.disabled = !this.disabled\n },\n getTargetNode(e) {\n const path = e.path ?? e.composedPath()\n const targetNode = path?.find(node => node?.hasAttribute?.(\"data-v-inspector-file\"))\n if (targetNode?.id === \"vueInspectorControl\") {\n return {\n targetNode: null,\n params: null,\n }\n }\n return {\n targetNode,\n params: targetNode\n ? {\n file: targetNode?.getAttribute?.(\"data-v-inspector-file\"),\n line: targetNode?.getAttribute?.(\"data-v-inspector-line\"),\n column: targetNode?.getAttribute?.(\"data-v-inspector-column\"),\n title: targetNode?.getAttribute?.(\"data-v-inspector-title\"),\n }\n : null,\n }\n },\n onFetch(e) {\n if (this.disabled) return\n e.preventDefault()\n const { targetNode, params } = this.getTargetNode(e)\n if (!targetNode) return\n const { file, line, column } = params\n fetch(\n `/__open-stack-frame-in-editor?file=${file}&line=${line}&column=${column}`,\n )\n this.overlayVisible = false\n },\n onMouseMove(e) {\n if (this.disabled) return\n const { targetNode, params } = this.getTargetNode(e)\n if (targetNode) {\n this.position.x = e.clientX\n this.position.y = e.clientY\n this.overlayVisible = true\n this.navigationParams = params\n }\n else {\n this.overlayVisible = false\n this.navigationParams = {\n file: \"\",\n line: 0,\n column: 0,\n }\n }\n },\n },\n}\nApp.render = render\n import { createApp } from \"/node_modules/.vite/deps/vue.js?v=browserHash\"\n createApp(App).mount('#vite_vue_inspector_overlay_container')\n ",
0 commit comments