@immense/vue-pom-generator 1.0.82 → 1.0.83
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.
- package/RELEASE_NOTES.md +31 -53
- package/dist/index.cjs +17 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +17 -15
- package/dist/index.mjs.map +1 -1
- package/dist/plugin/runtime/annotator/client.d.ts +13 -0
- package/dist/plugin/runtime/annotator/client.d.ts.map +1 -1
- package/dist/plugin/runtime/annotator/format.d.ts.map +1 -1
- package/dist/plugin/runtime/annotator/plugin.d.ts +16 -0
- package/dist/plugin/runtime/annotator/plugin.d.ts.map +1 -1
- package/dist/plugin/runtime/annotator/text-utils.d.ts +15 -0
- package/dist/plugin/runtime/annotator/text-utils.d.ts.map +1 -0
- package/dist/plugin/runtime/annotator/vue-detector.d.ts +49 -0
- package/dist/plugin/runtime/annotator/vue-detector.d.ts.map +1 -1
- package/dist/pom-discoverability.d.ts.map +1 -1
- package/package.json +1 -1
- package/plugin/runtime/annotator/client.ts +24 -12
- package/plugin/runtime/annotator/format.ts +5 -7
- package/plugin/runtime/annotator/plugin.ts +24 -6
- package/plugin/runtime/annotator/text-utils.ts +23 -0
- package/plugin/runtime/annotator/vue-detector.ts +56 -0
|
@@ -5,6 +5,16 @@ export interface AnnotatorClientOptions extends VueDetectorOptions {
|
|
|
5
5
|
copyToClipboard: boolean;
|
|
6
6
|
showComponentTree: boolean;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* The primary side of a Floating UI placement token (e.g. `"top"` from
|
|
10
|
+
* `"top-start"`). Used to derive the static side opposite the arrow. This
|
|
11
|
+
* splits a CSS placement token on its separator, not source code.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* placementPrimarySide("top-start") // "top"
|
|
15
|
+
* placementPrimarySide("right") // "right"
|
|
16
|
+
*/
|
|
17
|
+
declare function placementPrimarySide(placement: string): string;
|
|
8
18
|
declare class AnnotatorRuntime {
|
|
9
19
|
private readonly options;
|
|
10
20
|
private readonly settings;
|
|
@@ -63,5 +73,8 @@ declare class AnnotatorRuntime {
|
|
|
63
73
|
private showToast;
|
|
64
74
|
}
|
|
65
75
|
export declare function mountAnnotatorClient(options: AnnotatorClientOptions): AnnotatorRuntime;
|
|
76
|
+
export declare const __internal: {
|
|
77
|
+
placementPrimarySide: typeof placementPrimarySide;
|
|
78
|
+
};
|
|
66
79
|
export {};
|
|
67
80
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../plugin/runtime/annotator/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAA8E,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../plugin/runtime/annotator/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAA8E,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAGzH,OAAO,EAA2B,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAElF,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAgJD;;;;;;;;GAQG;AACH,iBAAS,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAIvD;AA2FD,cAAM,gBAAgB;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IACjD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoB;IAC7C,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,cAAc,CAAwB;IAC9C,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,iBAAiB,CAAiC;IAC1D,OAAO,CAAC,mBAAmB,CAAuB;IAClD,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,aAAa,CAAkC;IACvD,OAAO,CAAC,cAAc,CAAkC;IACxD,OAAO,CAAC,mBAAmB,CAA6B;IACxD,OAAO,CAAC,cAAc,CAA4B;IAClD,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,eAAe,CAAgC;gBAE3C,OAAO,EAAE,sBAAsB;IAO3C,KAAK;IAQL,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,YAAY;IAgCpB,OAAO,CAAC,aAAa;IAwCrB,OAAO,CAAC,aAAa;IAmBrB,OAAO,CAAC,qBAAqB;IAW7B,OAAO,CAAC,YAAY;IAmBpB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,eAAe;IAiBvB,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,mBAAmB;IAiB3B,OAAO,CAAC,mBAAmB;IAa3B,OAAO,CAAC,oBAAoB;IAa5B,OAAO,CAAC,oBAAoB;IAiB5B,OAAO,CAAC,iBAAiB;IAsCzB,OAAO,CAAC,eAAe;IA+DvB,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,gCAAgC;IAQxC,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,iBAAiB;IAyBzB,OAAO,CAAC,aAAa;IAmBrB,OAAO,CAAC,oBAAoB;IAiB5B,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,cAAc;IAqCtB,OAAO,CAAC,iBAAiB;IAkEzB,OAAO,CAAC,8BAA8B;IAMtC,OAAO,CAAC,WAAW;IAqBnB,OAAO,CAAC,YAAY;IA2EpB,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,SAAS;IAqBjB,OAAO,CAAC,UAAU;IAMlB,OAAO,CAAC,gBAAgB;YAUV,eAAe;IAgB7B,OAAO,CAAC,SAAS;CAmBlB;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,sBAAsB,oBAUnE;AAGD,eAAO,MAAM,UAAU;;CAEtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../../plugin/runtime/annotator/format.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../../plugin/runtime/annotator/format.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,UAAU,CAAC;AAEnD,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,mBAAmB,EAAE,EAClC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,MAAM,GACd,MAAM,CA8CR;AAED,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,mBAAmB,EAC/B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,MAAM,GACd,MAAM,CAOR"}
|
|
@@ -8,5 +8,21 @@ export interface ResolvedAnnotatorUiOptions {
|
|
|
8
8
|
copyToClipboard: boolean;
|
|
9
9
|
showComponentTree: boolean;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Normalize Windows backslash path separators to POSIX forward slashes.
|
|
13
|
+
*
|
|
14
|
+
* Used to build Vite `/@fs/` import URLs and to compare entry-path suffixes
|
|
15
|
+
* consistently across platforms. This is path-separator normalization, not
|
|
16
|
+
* source-code parsing.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* normalizePathSeparators("src\\widgets\\Item.vue") // "src/widgets/Item.vue"
|
|
20
|
+
* normalizePathSeparators("src/widgets/Item.vue") // "src/widgets/Item.vue"
|
|
21
|
+
*/
|
|
22
|
+
declare function normalizePathSeparators(filePath: string): string;
|
|
11
23
|
export declare function createAnnotatorUiPlugin(options: ResolvedAnnotatorUiOptions): Plugin;
|
|
24
|
+
export declare const __internal: {
|
|
25
|
+
normalizePathSeparators: typeof normalizePathSeparators;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
12
28
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../plugin/runtime/annotator/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAqB,MAAM,EAAE,MAAM,MAAM,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,uBAAuB,EAAE,MAAM,CAAC;IAChC,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;CAC5B;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../plugin/runtime/annotator/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAqB,MAAM,EAAE,MAAM,MAAM,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,uBAAuB,EAAE,MAAM,CAAC;IAChC,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAYD;;;;;;;;;;GAUG;AACH,iBAAS,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIzD;AAmBD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,0BAA0B,GAAG,MAAM,CAgEnF;AAGD,eAAO,MAAM,UAAU;;CAEtB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize a UI display string: collapse whitespace runs to single spaces,
|
|
3
|
+
* trim the ends, and return `undefined` for blank input.
|
|
4
|
+
*
|
|
5
|
+
* Returns `undefined` when `value` is itself `undefined` or collapses to empty,
|
|
6
|
+
* so callers can use a simple truthiness check to decide whether to render a
|
|
7
|
+
* line. This is display-text normalization, not source-code parsing.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* normalizeInlineText(" foo\n bar ") // "foo bar"
|
|
11
|
+
* normalizeInlineText(" ") // undefined
|
|
12
|
+
* normalizeInlineText(undefined) // undefined
|
|
13
|
+
*/
|
|
14
|
+
export declare function normalizeInlineText(value: string | undefined): string | undefined;
|
|
15
|
+
//# sourceMappingURL=text-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-utils.d.ts","sourceRoot":"","sources":["../../../../plugin/runtime/annotator/text-utils.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAKjF"}
|
|
@@ -7,6 +7,55 @@ export interface ResolvedVueComponentInfo {
|
|
|
7
7
|
source?: string;
|
|
8
8
|
formatted?: string;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Strip a trailing `:line:column` position from a component file path (e.g.
|
|
12
|
+
* `src/Foo.vue:12:3` → `src/Foo.vue`). Operates on a runtime file-path string,
|
|
13
|
+
* not source code.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* stripSourcePosition("src/Foo.vue:12:3") // "src/Foo.vue"
|
|
17
|
+
* stripSourcePosition("src/Foo.vue") // "src/Foo.vue"
|
|
18
|
+
*/
|
|
19
|
+
declare function stripSourcePosition(sourcePath: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Derive a component name from its file path, or `null` when none can be
|
|
22
|
+
* determined. Operates on a runtime file-path string, not source code.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* inferNameFromFile("src/widgets/Item.vue") // "Item"
|
|
26
|
+
* inferNameFromFile("src/widgets/Item.vue:4:2") // "Item"
|
|
27
|
+
* inferNameFromFile("") // null
|
|
28
|
+
*/
|
|
29
|
+
declare function inferNameFromFile(filePath: string): string | null;
|
|
30
|
+
/**
|
|
31
|
+
* Whether a runtime component tag looks like a real Vue component — PascalCase
|
|
32
|
+
* or kebab-case — rather than a plain HTML element. Operates on a runtime tag
|
|
33
|
+
* string, not source code.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* isComponentLikeSourceTag("UserCard") // true
|
|
37
|
+
* isComponentLikeSourceTag("my-button") // true
|
|
38
|
+
* isComponentLikeSourceTag("div") // false
|
|
39
|
+
*/
|
|
40
|
+
declare function isComponentLikeSourceTag(tag: string | null | undefined): tag is string;
|
|
41
|
+
/**
|
|
42
|
+
* Format a component source path for display, optionally keeping its
|
|
43
|
+
* `:line:column` position and trimming it to the `frontend/src/...` portion
|
|
44
|
+
* when present. Operates on a runtime file-path string for display, not source
|
|
45
|
+
* code.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* formatSourceLabel("/x/frontend/src/Foo.vue:4:2") // "src/Foo.vue:4:2"
|
|
49
|
+
* formatSourceLabel("/x/frontend/src/Foo.vue:4:2", false) // "src/Foo.vue"
|
|
50
|
+
* formatSourceLabel("src/Foo.vue") // "src/Foo.vue"
|
|
51
|
+
*/
|
|
10
52
|
export declare function formatSourceLabel(sourcePath: string, includePosition?: boolean): string;
|
|
11
53
|
export declare function resolveVueComponentInfo(element: Element, options: VueDetectorOptions): ResolvedVueComponentInfo | undefined;
|
|
54
|
+
export declare const __internal: {
|
|
55
|
+
ignoredComponentNamePattern: RegExp;
|
|
56
|
+
stripSourcePosition: typeof stripSourcePosition;
|
|
57
|
+
inferNameFromFile: typeof inferNameFromFile;
|
|
58
|
+
isComponentLikeSourceTag: typeof isComponentLikeSourceTag;
|
|
59
|
+
};
|
|
60
|
+
export {};
|
|
12
61
|
//# sourceMappingURL=vue-detector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue-detector.d.ts","sourceRoot":"","sources":["../../../../plugin/runtime/annotator/vue-detector.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,uBAAuB,EAAE,MAAM,CAAC;CACjC;AAUD,MAAM,WAAW,wBAAwB;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"vue-detector.d.ts","sourceRoot":"","sources":["../../../../plugin/runtime/annotator/vue-detector.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,uBAAuB,EAAE,MAAM,CAAC;CACjC;AAUD,MAAM,WAAW,wBAAwB;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA+BD;;;;;;;;GAQG;AACH,iBAAS,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAIvD;AAED;;;;;;;;GAQG;AACH,iBAAS,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAU1D;AAMD;;;;;;;;;GASG;AACH,iBAAS,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,GAAG,IAAI,MAAM,CAI/E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,eAAe,UAAO,GAAG,MAAM,CAmBpF;AA8GD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB,GAAG,wBAAwB,GAAG,SAAS,CAiC3H;AAGD,eAAO,MAAM,UAAU;;;;;CAKtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pom-discoverability.d.ts","sourceRoot":"","sources":["../pom-discoverability.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pom-discoverability.d.ts","sourceRoot":"","sources":["../pom-discoverability.ts"],"names":[],"mappings":"AAsFA,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAQ/D;AAED,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAMhE;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAeT"}
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import { arrow, autoPlacement, autoUpdate, computePosition, offset, shift, type
|
|
|
2
2
|
|
|
3
3
|
import { formatAnnotations, formatSingleAnnotationPreview, type FormattedAnnotation, type OutputDetail } from "./format";
|
|
4
4
|
import { ANNOTATOR_ROOT_ATTR, ANNOTATOR_STYLES } from "./styles";
|
|
5
|
+
import { normalizeInlineText } from "./text-utils";
|
|
5
6
|
import { resolveVueComponentInfo, type VueDetectorOptions } from "./vue-detector";
|
|
6
7
|
|
|
7
8
|
export interface AnnotatorClientOptions extends VueDetectorOptions {
|
|
@@ -63,13 +64,6 @@ const SHORTCUT_LABELS = {
|
|
|
63
64
|
cancel: "Esc",
|
|
64
65
|
} as const;
|
|
65
66
|
|
|
66
|
-
function normalizeText(value: string | undefined): string | undefined {
|
|
67
|
-
/* eslint-disable no-restricted-syntax -- collapsing whitespace in UI display text, not parsing source code */
|
|
68
|
-
const normalized = value?.replace(/\s+/g, " ").trim();
|
|
69
|
-
/* eslint-enable no-restricted-syntax */
|
|
70
|
-
return normalized || undefined;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
67
|
function formatShortcutTitle(label: string, shortcut: string | undefined): string {
|
|
74
68
|
return shortcut ? `${label} (${shortcut})` : label;
|
|
75
69
|
}
|
|
@@ -121,12 +115,12 @@ function getElementPath(element: Element): string {
|
|
|
121
115
|
}
|
|
122
116
|
|
|
123
117
|
function getNearbyText(element: Element): string | undefined {
|
|
124
|
-
const ownText =
|
|
118
|
+
const ownText = normalizeInlineText(element.textContent || undefined);
|
|
125
119
|
if (ownText && ownText.length >= 2) {
|
|
126
120
|
return ownText.length > 160 ? `${ownText.slice(0, 160)}...` : ownText;
|
|
127
121
|
}
|
|
128
122
|
|
|
129
|
-
const parentText =
|
|
123
|
+
const parentText = normalizeInlineText(element.parentElement?.textContent || undefined);
|
|
130
124
|
if (parentText) {
|
|
131
125
|
return parentText.length > 160 ? `${parentText.slice(0, 160)}...` : parentText;
|
|
132
126
|
}
|
|
@@ -159,6 +153,21 @@ function toCssPixels(value: number): string {
|
|
|
159
153
|
return `${Math.round(value)}px`;
|
|
160
154
|
}
|
|
161
155
|
|
|
156
|
+
/**
|
|
157
|
+
* The primary side of a Floating UI placement token (e.g. `"top"` from
|
|
158
|
+
* `"top-start"`). Used to derive the static side opposite the arrow. This
|
|
159
|
+
* splits a CSS placement token on its separator, not source code.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* placementPrimarySide("top-start") // "top"
|
|
163
|
+
* placementPrimarySide("right") // "right"
|
|
164
|
+
*/
|
|
165
|
+
function placementPrimarySide(placement: string): string {
|
|
166
|
+
/* eslint-disable no-restricted-syntax -- splitting a CSS placement token on its separator, not parsing source code */
|
|
167
|
+
return placement.split("-")[0];
|
|
168
|
+
/* eslint-enable no-restricted-syntax */
|
|
169
|
+
}
|
|
170
|
+
|
|
162
171
|
function clamp(value: number, min: number, max: number): number {
|
|
163
172
|
return Math.min(Math.max(value, min), max);
|
|
164
173
|
}
|
|
@@ -727,9 +736,7 @@ class AnnotatorRuntime {
|
|
|
727
736
|
panel.style.visibility = "visible";
|
|
728
737
|
|
|
729
738
|
const arrowData = result.middlewareData.arrow;
|
|
730
|
-
|
|
731
|
-
const side = result.placement.split("-")[0];
|
|
732
|
-
/* eslint-enable no-restricted-syntax */
|
|
739
|
+
const side = placementPrimarySide(result.placement);
|
|
733
740
|
const staticSide = side === "top" ? "bottom" : side === "bottom" ? "top" : side === "left" ? "right" : "left";
|
|
734
741
|
arrowEl.style.removeProperty("top");
|
|
735
742
|
arrowEl.style.removeProperty("right");
|
|
@@ -1007,3 +1014,8 @@ export function mountAnnotatorClient(options: AnnotatorClientOptions) {
|
|
|
1007
1014
|
runtimeWindow[RUNTIME_GUARD] = runtime;
|
|
1008
1015
|
return runtime;
|
|
1009
1016
|
}
|
|
1017
|
+
|
|
1018
|
+
// Exposed for unit tests. Pure helper (no DOM access).
|
|
1019
|
+
export const __internal = {
|
|
1020
|
+
placementPrimarySide,
|
|
1021
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { normalizeInlineText } from "./text-utils";
|
|
2
|
+
|
|
1
3
|
export type OutputDetail = "standard" | "forensic";
|
|
2
4
|
|
|
3
5
|
export interface FormattedAnnotation {
|
|
@@ -10,13 +12,6 @@ export interface FormattedAnnotation {
|
|
|
10
12
|
domHint?: string;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
function normalizeInlineText(value: string | undefined): string | undefined {
|
|
14
|
-
/* eslint-disable no-restricted-syntax -- collapsing whitespace in UI display text, not parsing source code */
|
|
15
|
-
const normalized = value?.replace(/\s+/g, " ").trim();
|
|
16
|
-
/* eslint-enable no-restricted-syntax */
|
|
17
|
-
return normalized || undefined;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
15
|
export function formatAnnotations(
|
|
21
16
|
annotations: FormattedAnnotation[],
|
|
22
17
|
detail: OutputDetail,
|
|
@@ -76,5 +71,8 @@ export function formatSingleAnnotationPreview(
|
|
|
76
71
|
): string {
|
|
77
72
|
const formatted = formatAnnotations([annotation], detail, pageUrl);
|
|
78
73
|
const headingIndex = formatted.indexOf("### 1.");
|
|
74
|
+
// reason: `formatAnnotations` is always called with a single-element array, so it
|
|
75
|
+
// always emits a `### 1.` heading; the false branch of this ternary is unreachable.
|
|
76
|
+
/* c8 ignore next */
|
|
79
77
|
return headingIndex >= 0 ? formatted.slice(headingIndex).trim() : formatted.trim();
|
|
80
78
|
}
|
|
@@ -25,12 +25,27 @@ const DEFAULT_ENTRY_SUFFIXES = [
|
|
|
25
25
|
"/src/main.jsx",
|
|
26
26
|
];
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Normalize Windows backslash path separators to POSIX forward slashes.
|
|
30
|
+
*
|
|
31
|
+
* Used to build Vite `/@fs/` import URLs and to compare entry-path suffixes
|
|
32
|
+
* consistently across platforms. This is path-separator normalization, not
|
|
33
|
+
* source-code parsing.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* normalizePathSeparators("src\\widgets\\Item.vue") // "src/widgets/Item.vue"
|
|
37
|
+
* normalizePathSeparators("src/widgets/Item.vue") // "src/widgets/Item.vue"
|
|
38
|
+
*/
|
|
39
|
+
function normalizePathSeparators(filePath: string): string {
|
|
40
|
+
/* eslint-disable no-restricted-syntax -- normalizing path separators, not parsing source code */
|
|
41
|
+
return filePath.replace(/\\/g, "/");
|
|
31
42
|
/* eslint-enable no-restricted-syntax */
|
|
32
43
|
}
|
|
33
44
|
|
|
45
|
+
function toFsImportPath(filePath: string): string {
|
|
46
|
+
return `/@fs/${normalizePathSeparators(filePath)}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
34
49
|
function resolveAnnotatorClientPath(): string {
|
|
35
50
|
const candidates = [
|
|
36
51
|
fileURLToPath(new URL("./client.ts", import.meta.url)),
|
|
@@ -79,9 +94,7 @@ export function createAnnotatorUiPlugin(options: ResolvedAnnotatorUiOptions): Pl
|
|
|
79
94
|
return null;
|
|
80
95
|
}
|
|
81
96
|
|
|
82
|
-
|
|
83
|
-
const normalizedId = id.replace(/\\/g, "/");
|
|
84
|
-
/* eslint-enable no-restricted-syntax */
|
|
97
|
+
const normalizedId = normalizePathSeparators(id);
|
|
85
98
|
if (!DEFAULT_ENTRY_SUFFIXES.some(suffix => normalizedId.endsWith(suffix))) {
|
|
86
99
|
return null;
|
|
87
100
|
}
|
|
@@ -111,3 +124,8 @@ export function createAnnotatorUiPlugin(options: ResolvedAnnotatorUiOptions): Pl
|
|
|
111
124
|
},
|
|
112
125
|
};
|
|
113
126
|
}
|
|
127
|
+
|
|
128
|
+
// Exposed for unit tests. Pure helper (no I/O).
|
|
129
|
+
export const __internal = {
|
|
130
|
+
normalizePathSeparators,
|
|
131
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Display-text helpers for the annotator runtime. These normalize text
|
|
2
|
+
// captured from the DOM (collapsing whitespace, trimming) for readable UI
|
|
3
|
+
// labels — not source code — so whitespace regexes are the appropriate tool.
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Normalize a UI display string: collapse whitespace runs to single spaces,
|
|
7
|
+
* trim the ends, and return `undefined` for blank input.
|
|
8
|
+
*
|
|
9
|
+
* Returns `undefined` when `value` is itself `undefined` or collapses to empty,
|
|
10
|
+
* so callers can use a simple truthiness check to decide whether to render a
|
|
11
|
+
* line. This is display-text normalization, not source-code parsing.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* normalizeInlineText(" foo\n bar ") // "foo bar"
|
|
15
|
+
* normalizeInlineText(" ") // undefined
|
|
16
|
+
* normalizeInlineText(undefined) // undefined
|
|
17
|
+
*/
|
|
18
|
+
export function normalizeInlineText(value: string | undefined): string | undefined {
|
|
19
|
+
/* eslint-disable no-restricted-syntax -- collapsing whitespace runs in display text, not parsing source code */
|
|
20
|
+
const normalized = value?.replace(/\s+/g, " ").trim();
|
|
21
|
+
/* eslint-enable no-restricted-syntax */
|
|
22
|
+
return normalized || undefined;
|
|
23
|
+
}
|
|
@@ -17,6 +17,15 @@ export interface ResolvedVueComponentInfo {
|
|
|
17
17
|
formatted?: string;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Matches well-known synthetic component names Vue's runtime emits that carry no
|
|
22
|
+
* useful component identity (e.g. `template`, `slot`, `transition`). These come
|
|
23
|
+
* from Vue's runtime registry, not source code, so a regex test is appropriate.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ignoredComponentNamePattern.test("template") // true
|
|
27
|
+
* ignoredComponentNamePattern.test("UserCard") // false
|
|
28
|
+
*/
|
|
20
29
|
/* eslint-disable no-restricted-syntax -- matching well-known synthetic component names from Vue's runtime (not source-code parsing) */
|
|
21
30
|
const ignoredComponentNamePattern = /^(?:items\[\d+\]\.template|template|anonymous|slot|transition|transition-group)$/i;
|
|
22
31
|
/* eslint-enable no-restricted-syntax */
|
|
@@ -37,12 +46,30 @@ function getDirectVueInstances(element: Element): VueInstance[] {
|
|
|
37
46
|
return instances;
|
|
38
47
|
}
|
|
39
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Strip a trailing `:line:column` position from a component file path (e.g.
|
|
51
|
+
* `src/Foo.vue:12:3` → `src/Foo.vue`). Operates on a runtime file-path string,
|
|
52
|
+
* not source code.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* stripSourcePosition("src/Foo.vue:12:3") // "src/Foo.vue"
|
|
56
|
+
* stripSourcePosition("src/Foo.vue") // "src/Foo.vue"
|
|
57
|
+
*/
|
|
40
58
|
function stripSourcePosition(sourcePath: string): string {
|
|
41
59
|
/* eslint-disable no-restricted-syntax -- stripping a trailing line:column position from a file path string, not parsing source code */
|
|
42
60
|
return sourcePath.replace(/:\d+:\d+$/, "");
|
|
43
61
|
/* eslint-enable no-restricted-syntax */
|
|
44
62
|
}
|
|
45
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Derive a component name from its file path, or `null` when none can be
|
|
66
|
+
* determined. Operates on a runtime file-path string, not source code.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* inferNameFromFile("src/widgets/Item.vue") // "Item"
|
|
70
|
+
* inferNameFromFile("src/widgets/Item.vue:4:2") // "Item"
|
|
71
|
+
* inferNameFromFile("") // null
|
|
72
|
+
*/
|
|
46
73
|
function inferNameFromFile(filePath: string): string | null {
|
|
47
74
|
/* eslint-disable no-restricted-syntax -- deriving a component name from a file path string, not parsing source code */
|
|
48
75
|
const fileName = stripSourcePosition(filePath).split("/").pop();
|
|
@@ -59,12 +86,33 @@ function isMeaningfulComponentName(name: string | null | undefined): name is str
|
|
|
59
86
|
return !!name && !ignoredComponentNamePattern.test(name.trim());
|
|
60
87
|
}
|
|
61
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Whether a runtime component tag looks like a real Vue component — PascalCase
|
|
91
|
+
* or kebab-case — rather than a plain HTML element. Operates on a runtime tag
|
|
92
|
+
* string, not source code.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* isComponentLikeSourceTag("UserCard") // true
|
|
96
|
+
* isComponentLikeSourceTag("my-button") // true
|
|
97
|
+
* isComponentLikeSourceTag("div") // false
|
|
98
|
+
*/
|
|
62
99
|
function isComponentLikeSourceTag(tag: string | null | undefined): tag is string {
|
|
63
100
|
/* eslint-disable no-restricted-syntax -- checking whether a runtime component tag looks like a Vue component (PascalCase or kebab), not parsing source code */
|
|
64
101
|
return !!tag && (/[A-Z]/.test(tag.trim()) || tag.includes("-"));
|
|
65
102
|
/* eslint-enable no-restricted-syntax */
|
|
66
103
|
}
|
|
67
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Format a component source path for display, optionally keeping its
|
|
107
|
+
* `:line:column` position and trimming it to the `frontend/src/...` portion
|
|
108
|
+
* when present. Operates on a runtime file-path string for display, not source
|
|
109
|
+
* code.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* formatSourceLabel("/x/frontend/src/Foo.vue:4:2") // "src/Foo.vue:4:2"
|
|
113
|
+
* formatSourceLabel("/x/frontend/src/Foo.vue:4:2", false) // "src/Foo.vue"
|
|
114
|
+
* formatSourceLabel("src/Foo.vue") // "src/Foo.vue"
|
|
115
|
+
*/
|
|
68
116
|
export function formatSourceLabel(sourcePath: string, includePosition = true): string {
|
|
69
117
|
/* eslint-disable no-restricted-syntax -- parsing a file-path-with-optional-position string for display, not parsing source code */
|
|
70
118
|
const match = sourcePath.match(/^(.*?)(?::(\d+):(\d+))?$/);
|
|
@@ -228,3 +276,11 @@ export function resolveVueComponentInfo(element: Element, options: VueDetectorOp
|
|
|
228
276
|
|
|
229
277
|
return bestInfo;
|
|
230
278
|
}
|
|
279
|
+
|
|
280
|
+
// Exposed for unit tests. These are pure string helpers (no DOM access).
|
|
281
|
+
export const __internal = {
|
|
282
|
+
ignoredComponentNamePattern,
|
|
283
|
+
stripSourcePosition,
|
|
284
|
+
inferNameFromFile,
|
|
285
|
+
isComponentLikeSourceTag,
|
|
286
|
+
};
|