@blqke/vgentation 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ export interface ModuleOptions {
2
+ /**
3
+ * Auto-import CSS styles.
4
+ * @default true
5
+ */
6
+ css?: boolean;
7
+ }
8
+ declare const _default: NuxtModule<TOptions, TOptions, false>;
9
+ export default _default;
package/dist/nuxt.cjs ADDED
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ const kit = require("@nuxt/kit");
3
+ const module$1 = kit.defineNuxtModule({
4
+ meta: {
5
+ name: "vgentation",
6
+ configKey: "vgentation",
7
+ compatibility: {
8
+ nuxt: ">=3.0.0"
9
+ }
10
+ },
11
+ defaults: {
12
+ css: true
13
+ },
14
+ setup(options, nuxt) {
15
+ if (options.css) {
16
+ nuxt.options.css.push("vgentation/style.css");
17
+ }
18
+ kit.addImports({
19
+ name: "useVgentation",
20
+ from: "vgentation"
21
+ });
22
+ kit.addComponent({
23
+ name: "Vgentation",
24
+ filePath: "vgentation",
25
+ export: "Vgentation",
26
+ mode: "client"
27
+ });
28
+ kit.addTemplate({
29
+ filename: "vgentation-plugin.client.ts",
30
+ write: true,
31
+ getContents: () => `
32
+ import { defineNuxtPlugin } from '#app'
33
+ import { VgentationKey, createVgentationContext } from 'vgentation'
34
+
35
+ export default defineNuxtPlugin((nuxtApp) => {
36
+ const context = createVgentationContext()
37
+ nuxtApp.vueApp.provide(VgentationKey, context)
38
+ })
39
+ `
40
+ });
41
+ kit.addPlugin({
42
+ src: "#build/vgentation-plugin.client",
43
+ mode: "client"
44
+ });
45
+ }
46
+ });
47
+ module.exports = module$1;
package/dist/nuxt.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export {}
2
+ import Vgentation from './nuxt/module'
3
+ export default Vgentation
4
+ export {}
package/dist/nuxt.mjs ADDED
@@ -0,0 +1,48 @@
1
+ import { defineNuxtModule, addImports, addComponent, addTemplate, addPlugin } from "@nuxt/kit";
2
+ const module$1 = defineNuxtModule({
3
+ meta: {
4
+ name: "vgentation",
5
+ configKey: "vgentation",
6
+ compatibility: {
7
+ nuxt: ">=3.0.0"
8
+ }
9
+ },
10
+ defaults: {
11
+ css: true
12
+ },
13
+ setup(options, nuxt) {
14
+ if (options.css) {
15
+ nuxt.options.css.push("vgentation/style.css");
16
+ }
17
+ addImports({
18
+ name: "useVgentation",
19
+ from: "vgentation"
20
+ });
21
+ addComponent({
22
+ name: "Vgentation",
23
+ filePath: "vgentation",
24
+ export: "Vgentation",
25
+ mode: "client"
26
+ });
27
+ addTemplate({
28
+ filename: "vgentation-plugin.client.ts",
29
+ write: true,
30
+ getContents: () => `
31
+ import { defineNuxtPlugin } from '#app'
32
+ import { VgentationKey, createVgentationContext } from 'vgentation'
33
+
34
+ export default defineNuxtPlugin((nuxtApp) => {
35
+ const context = createVgentationContext()
36
+ nuxtApp.vueApp.provide(VgentationKey, context)
37
+ })
38
+ `
39
+ });
40
+ addPlugin({
41
+ src: "#build/vgentation-plugin.client",
42
+ mode: "client"
43
+ });
44
+ }
45
+ });
46
+ export {
47
+ module$1 as default
48
+ };
@@ -0,0 +1,3 @@
1
+ import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
2
+ declare const _default: DefineComponent<{}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, HTMLDivElement>;
3
+ export default _default;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
1
+ import { Plugin } from 'vue';
2
+ export interface VgentationPluginOptions {
3
+ /**
4
+ * Register the Vgentation component globally.
5
+ * @default true
6
+ */
7
+ registerComponent?: boolean;
8
+ }
9
+ /**
10
+ * Vue plugin for Vgentation.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { createApp } from 'vue'
15
+ * import { VgentationPlugin } from 'vgentation'
16
+ * import 'vgentation/style.css'
17
+ *
18
+ * const app = createApp(App)
19
+ * app.use(VgentationPlugin)
20
+ * app.mount('#app')
21
+ * ```
22
+ *
23
+ * Then use anywhere:
24
+ * ```vue
25
+ * <template>
26
+ * <Vgentation />
27
+ * <button @click="toggle">Toggle</button>
28
+ * </template>
29
+ *
30
+ * <script setup>
31
+ * import { useVgentation } from 'vgentation'
32
+ * const { toggle } = useVgentation()
33
+ * </script>
34
+ * ```
35
+ */
36
+ export declare const VgentationPlugin: Plugin<VgentationPluginOptions>;
37
+ export default VgentationPlugin;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Source location for "Open in Editor" feature
3
+ */
4
+ export interface SourceLocation {
5
+ file: string;
6
+ line: number;
7
+ column: number;
8
+ }
9
+ /**
10
+ * Component tree node with optional file path and type indicators
11
+ */
12
+ export interface ComponentTreeNode {
13
+ name: string;
14
+ filePath?: string;
15
+ isPage?: boolean;
16
+ isLayout?: boolean;
17
+ }
18
+ export type Annotation = {
19
+ id: string;
20
+ x: number;
21
+ y: number;
22
+ comment: string;
23
+ element: string;
24
+ elementPath: string;
25
+ timestamp: number;
26
+ selectedText?: string;
27
+ boundingBox?: {
28
+ x: number;
29
+ y: number;
30
+ width: number;
31
+ height: number;
32
+ };
33
+ nearbyText?: string;
34
+ cssClasses?: string;
35
+ nearbyElements?: string;
36
+ computedStyles?: string;
37
+ fullPath?: string;
38
+ accessibility?: string;
39
+ isMultiSelect?: boolean;
40
+ isFixed?: boolean;
41
+ vueComponent?: string;
42
+ vueComponentPath?: string;
43
+ vueProps?: Record<string, unknown>;
44
+ vueComponentTree?: ComponentTreeNode[];
45
+ vueSourceLocation?: SourceLocation;
46
+ vueComponentFile?: string;
47
+ nuxtRoute?: string;
48
+ nuxtRouteName?: string;
49
+ nuxtPage?: string;
50
+ nuxtLayout?: string;
51
+ nuxtPageFile?: string;
52
+ nuxtLayoutFile?: string;
53
+ devToolsEnhanced?: boolean;
54
+ };
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Configuration Module for Annotation Picker
3
+ *
4
+ * Manages user preferences for:
5
+ * - Editor integration (VS Code, WebStorm, etc.)
6
+ * - Component tree display limits
7
+ * - Hover tooltip display modes
8
+ * - Output field toggles
9
+ */
10
+ export type HoverDisplayMode = 'path' | 'file' | 'both';
11
+ /**
12
+ * Output field toggles - controls which fields are included in copied output
13
+ */
14
+ export interface OutputFieldsConfig {
15
+ location: boolean;
16
+ selectedText: boolean;
17
+ componentName: boolean;
18
+ componentFile: boolean;
19
+ componentTree: boolean;
20
+ props: boolean;
21
+ routePath: boolean;
22
+ routeName: boolean;
23
+ pageName: boolean;
24
+ layoutName: boolean;
25
+ cssClasses: boolean;
26
+ position: boolean;
27
+ context: boolean;
28
+ fullDomPath: boolean;
29
+ computedStyles: boolean;
30
+ accessibility: boolean;
31
+ nearbyElements: boolean;
32
+ }
33
+ export type OutputPreset = 'minimal' | 'standard' | 'full' | 'custom';
34
+ export interface PickerConfig {
35
+ /**
36
+ * Editor protocol for "Open in Editor" feature
37
+ * @default 'vscode'
38
+ */
39
+ editorProtocol: string;
40
+ /**
41
+ * Maximum number of components to show in tree before "show more"
42
+ * @default 5
43
+ */
44
+ componentTreeLimit: number;
45
+ /**
46
+ * How to display component info in hover tooltip
47
+ * - 'path': Show component ancestry (App > Layout > Component)
48
+ * - 'file': Show component name + file (Component.vue:42)
49
+ * - 'both': Show both path and file info
50
+ * @default 'both'
51
+ */
52
+ hoverDisplayMode: HoverDisplayMode;
53
+ /**
54
+ * Output field toggles - controls which fields appear in copied output
55
+ */
56
+ outputFields: OutputFieldsConfig;
57
+ }
58
+ export declare const OUTPUT_PRESETS: Record<Exclude<OutputPreset, 'custom'>, OutputFieldsConfig>;
59
+ export declare const DEFAULT_OUTPUT_FIELDS: OutputFieldsConfig;
60
+ export declare const DEFAULT_CONFIG: PickerConfig;
61
+ /**
62
+ * Load configuration from localStorage, merging with defaults
63
+ */
64
+ export declare function loadConfig(): PickerConfig;
65
+ /**
66
+ * Save configuration to localStorage
67
+ */
68
+ export declare function saveConfig(config: Partial<PickerConfig>): void;
69
+ /**
70
+ * Reset configuration to defaults
71
+ */
72
+ export declare function resetConfig(): void;
73
+ /**
74
+ * Get available editor options for UI dropdown
75
+ */
76
+ export declare function getEditorOptions(): Array<{
77
+ value: string;
78
+ label: string;
79
+ }>;
80
+ export declare const HOVER_DISPLAY_OPTIONS: Array<{
81
+ value: HoverDisplayMode;
82
+ label: string;
83
+ }>;
84
+ /**
85
+ * Get available hover display mode options for UI dropdown
86
+ */
87
+ export declare function getHoverDisplayOptions(): Array<{
88
+ value: HoverDisplayMode;
89
+ label: string;
90
+ }>;
91
+ /**
92
+ * Detect which preset matches the current config (or 'custom' if none match)
93
+ */
94
+ export declare function detectPreset(config: OutputFieldsConfig): OutputPreset;
95
+ /**
96
+ * Get the output fields config for a preset
97
+ */
98
+ export declare function getPresetConfig(preset: Exclude<OutputPreset, 'custom'>): OutputFieldsConfig;
@@ -0,0 +1,190 @@
1
+ /**
2
+ * DevTools Integration Module
3
+ *
4
+ * Provides integration with Vue DevTools and Nuxt DevTools global hooks
5
+ * for enhanced component detection and "Open in Editor" functionality.
6
+ *
7
+ * All features are optional - gracefully falls back when DevTools not available.
8
+ */
9
+ declare global {
10
+ interface Window {
11
+ /**
12
+ * Vue DevTools Global Hook
13
+ * Available when Vue DevTools browser extension is installed
14
+ */
15
+ __VUE_DEVTOOLS_GLOBAL_HOOK__?: {
16
+ apps: Map<number, {
17
+ app: VueAppRecord;
18
+ version: string;
19
+ }>;
20
+ on(event: string, fn: (...args: unknown[]) => void): void;
21
+ off(event: string, fn: (...args: unknown[]) => void): void;
22
+ emit(event: string, ...args: unknown[]): void;
23
+ };
24
+ /**
25
+ * Vue Inspector
26
+ * Available when vite-plugin-vue-inspector or similar is installed
27
+ */
28
+ __VUE_INSPECTOR__?: {
29
+ enabled: boolean;
30
+ linkParams: {
31
+ file: string;
32
+ line: number;
33
+ column: number;
34
+ };
35
+ openInEditor(baseUrl: string, file: string, line: number, column: number): void;
36
+ enable(): void;
37
+ disable(): void;
38
+ };
39
+ /**
40
+ * Nuxt DevTools Host Client
41
+ * Available when @nuxt/devtools is installed and running
42
+ */
43
+ __NUXT_DEVTOOLS_HOST__?: {
44
+ nuxt: NuxtAppInstance;
45
+ devtools: {
46
+ open(): void;
47
+ close(): void;
48
+ toggle(): void;
49
+ navigate(path: string): void;
50
+ };
51
+ app: {
52
+ reload(): void;
53
+ navigate(path: string, hard?: boolean): void;
54
+ };
55
+ };
56
+ }
57
+ }
58
+ interface VueAppRecord {
59
+ _component?: {
60
+ name?: string;
61
+ };
62
+ _instance?: VueComponentInstanceInternal;
63
+ }
64
+ interface VueComponentInstanceInternal {
65
+ type?: {
66
+ name?: string;
67
+ displayName?: string;
68
+ __name?: string;
69
+ __file?: string;
70
+ __hmrId?: string;
71
+ _componentTag?: string;
72
+ __VUE_DEVTOOLS_COMPONENT_GUSSED_NAME__?: string;
73
+ components?: Record<string, unknown>;
74
+ };
75
+ parent?: VueComponentInstanceInternal;
76
+ appContext?: {
77
+ components?: Record<string, unknown>;
78
+ app?: {
79
+ __VUE_DEVTOOLS_NEXT_APP_RECORD_ID__?: number;
80
+ };
81
+ };
82
+ root?: VueComponentInstanceInternal;
83
+ uid?: number;
84
+ }
85
+ interface NuxtAppInstance {
86
+ $route?: {
87
+ path: string;
88
+ name?: string;
89
+ fullPath: string;
90
+ meta?: Record<string, unknown>;
91
+ matched?: Array<{
92
+ path: string;
93
+ name?: string;
94
+ components?: Record<string, {
95
+ __file?: string;
96
+ }>;
97
+ }>;
98
+ params?: Record<string, string>;
99
+ query?: Record<string, string>;
100
+ };
101
+ $router?: {
102
+ currentRoute: {
103
+ value: NuxtAppInstance['$route'];
104
+ };
105
+ };
106
+ _route?: NuxtAppInstance['$route'];
107
+ }
108
+ export interface SourceLocation {
109
+ file: string;
110
+ line: number;
111
+ column: number;
112
+ }
113
+ export interface DevToolsStatus {
114
+ vueDevTools: boolean;
115
+ vueInspector: boolean;
116
+ nuxtDevTools: boolean;
117
+ }
118
+ export declare const EDITOR_PROTOCOLS: Record<string, string>;
119
+ export declare const EDITOR_OPTIONS: {
120
+ value: string;
121
+ label: string;
122
+ }[];
123
+ /**
124
+ * Check if Vue DevTools global hook is available
125
+ */
126
+ export declare function isVueDevToolsAvailable(): boolean;
127
+ /**
128
+ * Check if Vue Inspector (vite-plugin-vue-inspector) is available
129
+ */
130
+ export declare function isVueInspectorAvailable(): boolean;
131
+ /**
132
+ * Check if Nuxt DevTools host client is available
133
+ */
134
+ export declare function isNuxtDevToolsAvailable(): boolean;
135
+ /**
136
+ * Get combined DevTools availability status
137
+ */
138
+ export declare function getDevToolsStatus(): DevToolsStatus;
139
+ /**
140
+ * Get component name using DevTools-style resolution with multiple fallbacks.
141
+ * This mirrors the logic used by Vue DevTools for consistent naming.
142
+ *
143
+ * Resolution order:
144
+ * 1. displayName
145
+ * 2. name
146
+ * 3. __name (SFC compiler)
147
+ * 4. __VUE_DEVTOOLS_COMPONENT_GUSSED_NAME__ (cached guess)
148
+ * 5. _componentTag
149
+ * 6. Filename from __file
150
+ * 7. Parent component lookup
151
+ * 8. 'Anonymous'
152
+ */
153
+ export declare function getInstanceNameEnhanced(instance: unknown): string;
154
+ /**
155
+ * Extract source location from a Vue component instance
156
+ */
157
+ export declare function getSourceLocationFromInstance(instance: unknown): SourceLocation | null;
158
+ /**
159
+ * Get current source location from Vue Inspector if available and enabled
160
+ */
161
+ export declare function getInspectorSourceLocation(): SourceLocation | null;
162
+ /**
163
+ * Build editor URL from protocol pattern and source location
164
+ */
165
+ export declare function buildEditorUrl(protocol: string, loc: SourceLocation): string;
166
+ /**
167
+ * Open a file in the configured editor
168
+ */
169
+ export declare function openInEditor(loc: SourceLocation, protocol?: string): void;
170
+ /**
171
+ * Get Nuxt app instance from DevTools host client
172
+ */
173
+ export declare function getNuxtAppFromDevTools(): NuxtAppInstance | null;
174
+ /**
175
+ * Get current route from Nuxt DevTools
176
+ */
177
+ export declare function getRouteFromNuxtDevTools(): NuxtAppInstance['$route'] | null;
178
+ /**
179
+ * Get page file path from matched route
180
+ */
181
+ export declare function getPageFileFromRoute(): string | null;
182
+ /**
183
+ * Format a file path for display (show filename only)
184
+ */
185
+ export declare function formatFilePath(fullPath: string): string;
186
+ /**
187
+ * Format a file path showing last N segments
188
+ */
189
+ export declare function formatFilePathWithContext(fullPath: string, segments?: number): string;
190
+ export {};
@@ -0,0 +1,72 @@
1
+ import { VueDetectionResult } from './vue-detection';
2
+ import { NuxtDetectionResult } from './nuxt-detection';
3
+ import { SourceLocation, ComponentTreeNode } from '../types';
4
+ export interface FrameworkContext {
5
+ vue?: VueDetectionResult;
6
+ nuxt?: NuxtDetectionResult;
7
+ }
8
+ /**
9
+ * Detect Vue and Nuxt context for an element
10
+ */
11
+ export declare function detectFrameworkContext(element: HTMLElement): FrameworkContext;
12
+ /**
13
+ * Get annotation-ready framework context (flattened strings + enhanced data)
14
+ */
15
+ export declare function getFrameworkAnnotationData(element: HTMLElement): {
16
+ vueComponent?: string;
17
+ vueComponentPath?: string;
18
+ vueProps?: Record<string, unknown>;
19
+ nuxtRoute?: string;
20
+ nuxtPage?: string;
21
+ nuxtLayout?: string;
22
+ vueComponentTree?: ComponentTreeNode[];
23
+ vueSourceLocation?: SourceLocation;
24
+ vueComponentFile?: string;
25
+ nuxtRouteName?: string;
26
+ nuxtPageFile?: string;
27
+ nuxtLayoutFile?: string;
28
+ devToolsEnhanced?: boolean;
29
+ };
30
+ /**
31
+ * Gets a readable path for an element (e.g., "article > section > p")
32
+ */
33
+ export declare function getElementPath(target: HTMLElement, maxDepth?: number): string;
34
+ /**
35
+ * Identifies an element and returns a human-readable name + path
36
+ */
37
+ export declare function identifyElement(target: HTMLElement): {
38
+ name: string;
39
+ path: string;
40
+ };
41
+ /**
42
+ * Gets text content from element and siblings for context
43
+ */
44
+ export declare function getNearbyText(element: HTMLElement): string;
45
+ /**
46
+ * Simplified element identifier for animation feedback (less verbose)
47
+ */
48
+ export declare function identifyAnimationElement(target: HTMLElement): string;
49
+ /**
50
+ * Gets nearby sibling elements for structural context
51
+ */
52
+ export declare function getNearbyElements(element: HTMLElement): string;
53
+ /**
54
+ * Gets CSS class names from an element (cleaned of module hashes)
55
+ */
56
+ export declare function getElementClasses(target: HTMLElement): string;
57
+ /**
58
+ * Gets key computed styles for an element (useful for styling issues)
59
+ */
60
+ export declare function getComputedStylesSnapshot(target: HTMLElement): string;
61
+ /**
62
+ * Gets detailed computed styles for forensic-level debugging
63
+ */
64
+ export declare function getDetailedComputedStyles(target: HTMLElement): Record<string, string>;
65
+ /**
66
+ * Gets accessibility information for an element
67
+ */
68
+ export declare function getAccessibilityInfo(target: HTMLElement): string;
69
+ /**
70
+ * Gets full DOM ancestry path (for forensic mode)
71
+ */
72
+ export declare function getFullElementPath(target: HTMLElement): string;
@@ -0,0 +1,90 @@
1
+ import { VueComponentInfo } from './vue-detection';
2
+ /**
3
+ * Nuxt app instance interface (partial)
4
+ */
5
+ interface NuxtApp {
6
+ vueApp?: {
7
+ _context?: {
8
+ components?: Record<string, unknown>;
9
+ };
10
+ };
11
+ $router?: {
12
+ currentRoute?: {
13
+ value?: RouteInfo;
14
+ };
15
+ };
16
+ _route?: RouteInfo;
17
+ }
18
+ interface RouteInfo {
19
+ path?: string;
20
+ name?: string | symbol;
21
+ fullPath?: string;
22
+ params?: Record<string, string | string[]>;
23
+ query?: Record<string, string | string[] | undefined>;
24
+ meta?: Record<string, unknown>;
25
+ matched?: Array<{
26
+ name?: string | symbol;
27
+ path?: string;
28
+ components?: Record<string, unknown>;
29
+ }>;
30
+ }
31
+ export interface NuxtRouteInfo {
32
+ path: string;
33
+ name?: string;
34
+ fullPath?: string;
35
+ params?: Record<string, string | string[]>;
36
+ }
37
+ export interface NuxtPageInfo {
38
+ name: string;
39
+ filePath?: string;
40
+ }
41
+ export interface NuxtDetectionResult {
42
+ isNuxt: boolean;
43
+ route?: NuxtRouteInfo;
44
+ page?: NuxtPageInfo;
45
+ layout?: string;
46
+ layoutFile?: string;
47
+ pageFile?: string;
48
+ devToolsEnhanced?: boolean;
49
+ }
50
+ /**
51
+ * Get the Nuxt app instance
52
+ */
53
+ export declare function getNuxtApp(): NuxtApp | null;
54
+ /**
55
+ * Check if we're in a Nuxt application
56
+ */
57
+ export declare function isNuxtApp(): boolean;
58
+ /**
59
+ * Get current route information
60
+ */
61
+ export declare function getCurrentRoute(): NuxtRouteInfo | null;
62
+ /**
63
+ * Get current page component info
64
+ */
65
+ export declare function getCurrentPage(): NuxtPageInfo | null;
66
+ /**
67
+ * Get current layout name
68
+ */
69
+ export declare function getCurrentLayout(): string | null;
70
+ /**
71
+ * Detect if a component is a Nuxt-specific component
72
+ */
73
+ export declare function isNuxtComponent(componentName: string): boolean;
74
+ /**
75
+ * Detect if a component is a layout component
76
+ */
77
+ export declare function isLayoutComponent(component: VueComponentInfo): boolean;
78
+ /**
79
+ * Detect if a component is a page component
80
+ */
81
+ export declare function isPageComponent(component: VueComponentInfo): boolean;
82
+ /**
83
+ * Main detection function - gets Nuxt context for an element
84
+ */
85
+ export declare function detectNuxtContext(element: HTMLElement): NuxtDetectionResult;
86
+ /**
87
+ * Format route for display
88
+ */
89
+ export declare function formatRoute(route: NuxtRouteInfo): string;
90
+ export {};
@@ -0,0 +1,5 @@
1
+ import { Annotation } from '../types';
2
+ export declare function getStorageKey(pathname: string): string;
3
+ export declare function loadAnnotations<T = Annotation>(pathname: string): T[];
4
+ export declare function saveAnnotations<T = Annotation>(pathname: string, annotations: T[]): void;
5
+ export declare function clearAnnotations(pathname: string): void;