@immense/vue-pom-generator 1.0.65 → 1.0.67
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/AGENTS.md +21 -0
- package/README.md +1 -0
- package/RELEASE_NOTES.md +84 -21
- package/class-generation/index.ts +23 -9
- package/dist/class-generation/index.d.ts.map +1 -1
- package/dist/compiler-metadata-utils.d.ts.map +1 -1
- package/dist/index.cjs +261 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +261 -82
- package/dist/index.mjs.map +1 -1
- package/dist/manifest-generator.d.ts +2 -0
- package/dist/manifest-generator.d.ts.map +1 -1
- package/dist/metadata-collector.d.ts +2 -0
- package/dist/metadata-collector.d.ts.map +1 -1
- package/dist/plugin/create-vue-pom-generator-plugins.d.ts.map +1 -1
- package/dist/plugin/internal/build-plugin.d.ts.map +1 -0
- package/dist/plugin/internal/dev-plugin.d.ts.map +1 -0
- package/dist/plugin/internal/virtual-modules.d.ts.map +1 -0
- package/dist/plugin/{support-plugins.d.ts → internal-plugins.d.ts} +14 -3
- package/dist/plugin/internal-plugins.d.ts.map +1 -0
- package/dist/plugin/runtime/annotator/client.d.ts +67 -0
- package/dist/plugin/runtime/annotator/client.d.ts.map +1 -0
- package/dist/plugin/runtime/annotator/format.d.ts +13 -0
- package/dist/plugin/runtime/annotator/format.d.ts.map +1 -0
- package/dist/plugin/runtime/annotator/plugin.d.ts +12 -0
- package/dist/plugin/runtime/annotator/plugin.d.ts.map +1 -0
- package/dist/plugin/runtime/annotator/styles.d.ts +3 -0
- package/dist/plugin/runtime/annotator/styles.d.ts.map +1 -0
- package/dist/plugin/runtime/annotator/vue-detector.d.ts +12 -0
- package/dist/plugin/runtime/annotator/vue-detector.d.ts.map +1 -0
- package/dist/plugin/types.d.ts +58 -3
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/vue-plugin.d.ts +4 -0
- package/dist/plugin/vue-plugin.d.ts.map +1 -1
- package/dist/transform.d.ts +4 -0
- package/dist/transform.d.ts.map +1 -1
- package/dist/utils.d.ts +19 -0
- package/dist/utils.d.ts.map +1 -1
- package/package.json +3 -1
- package/plugin/runtime/annotator/client.ts +1005 -0
- package/plugin/runtime/annotator/format.ts +76 -0
- package/plugin/runtime/annotator/plugin.ts +109 -0
- package/plugin/runtime/annotator/styles.ts +379 -0
- package/plugin/runtime/annotator/vue-detector.ts +216 -0
- package/dist/plugin/support/build-plugin.d.ts.map +0 -1
- package/dist/plugin/support/dev-plugin.d.ts.map +0 -1
- package/dist/plugin/support/virtual-modules.d.ts.map +0 -1
- package/dist/plugin/support-plugins.d.ts.map +0 -1
- /package/dist/plugin/{support → internal}/build-plugin.d.ts +0 -0
- /package/dist/plugin/{support → internal}/dev-plugin.d.ts +0 -0
- /package/dist/plugin/{support → internal}/virtual-modules.d.ts +0 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
export interface VueDetectorOptions {
|
|
2
|
+
sourceAttribute: string;
|
|
3
|
+
metadataAttributePrefix: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
interface VueInstance {
|
|
7
|
+
parent?: VueInstance;
|
|
8
|
+
type?: { name?: string; __name?: string; __file?: string };
|
|
9
|
+
vnode?: { props?: Record<string, unknown> };
|
|
10
|
+
$parent?: VueInstance;
|
|
11
|
+
$options?: { name?: string; _componentTag?: string; __file?: string };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ResolvedVueComponentInfo {
|
|
15
|
+
component?: string;
|
|
16
|
+
source?: string;
|
|
17
|
+
formatted?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const ignoredComponentNamePattern = /^(?:items\[\d+\]\.template|template|anonymous|slot|transition|transition-group)$/i;
|
|
21
|
+
|
|
22
|
+
function getDirectVueInstances(element: Element): VueInstance[] {
|
|
23
|
+
const instances: VueInstance[] = [];
|
|
24
|
+
const vue2Instance = (element as Element & { __vue__?: VueInstance }).__vue__;
|
|
25
|
+
const vue3Instance = (element as Element & { __vueParentComponent?: VueInstance }).__vueParentComponent;
|
|
26
|
+
|
|
27
|
+
if (vue2Instance) {
|
|
28
|
+
instances.push(vue2Instance);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (vue3Instance && vue3Instance !== vue2Instance) {
|
|
32
|
+
instances.push(vue3Instance);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return instances;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function stripSourcePosition(sourcePath: string): string {
|
|
39
|
+
return sourcePath.replace(/:\d+:\d+$/, "");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function inferNameFromFile(filePath: string): string | null {
|
|
43
|
+
const fileName = stripSourcePosition(filePath).split("/").pop();
|
|
44
|
+
if (!fileName) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return fileName.replace(/\.vue$/, "");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function isMeaningfulComponentName(name: string | null | undefined): name is string {
|
|
51
|
+
return !!name && !ignoredComponentNamePattern.test(name.trim());
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function isComponentLikeSourceTag(tag: string | null | undefined): tag is string {
|
|
55
|
+
return !!tag && (/[A-Z]/.test(tag.trim()) || tag.includes("-"));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function formatSourceLabel(sourcePath: string, includePosition = true): string {
|
|
59
|
+
const match = sourcePath.match(/^(.*?)(?::(\d+):(\d+))?$/);
|
|
60
|
+
if (!match) {
|
|
61
|
+
return sourcePath;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const [, rawPath, line, column] = match;
|
|
65
|
+
const frontendPathMatch = rawPath.match(/(?:^|\/)frontend\/(src\/.*)$/);
|
|
66
|
+
const normalizedPath = frontendPathMatch?.[1] ?? rawPath;
|
|
67
|
+
|
|
68
|
+
if (includePosition && line && column) {
|
|
69
|
+
return `${normalizedPath}:${line}:${column}`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return normalizedPath;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function getStringPropValue(props: Record<string, unknown> | undefined, key: string): string | undefined {
|
|
76
|
+
const value = props?.[key];
|
|
77
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function getDisplayComponentName(componentName: string | null | undefined, sourcePath?: string, sourceTag?: string | null): string | undefined {
|
|
81
|
+
if (isComponentLikeSourceTag(sourceTag)) {
|
|
82
|
+
return sourceTag.trim();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const inferredName = sourcePath ? inferNameFromFile(sourcePath) : null;
|
|
86
|
+
if (isMeaningfulComponentName(inferredName)) {
|
|
87
|
+
return inferredName;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (isMeaningfulComponentName(componentName)) {
|
|
91
|
+
return componentName.trim();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function resolveAnnotatedInfo(
|
|
98
|
+
componentName: string | null | undefined,
|
|
99
|
+
sourcePath: string | undefined,
|
|
100
|
+
sourceTag: string | null | undefined,
|
|
101
|
+
): ResolvedVueComponentInfo | undefined {
|
|
102
|
+
const component = getDisplayComponentName(componentName, sourcePath, sourceTag);
|
|
103
|
+
const source = sourcePath ? formatSourceLabel(sourcePath, true) : undefined;
|
|
104
|
+
|
|
105
|
+
if (!component && !source) {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
component,
|
|
111
|
+
source,
|
|
112
|
+
formatted: component
|
|
113
|
+
? source ? `${component} (${source})` : component
|
|
114
|
+
: source,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function getAnnotatedInfoFromElement(element: Element, options: VueDetectorOptions): ResolvedVueComponentInfo | undefined {
|
|
119
|
+
const pomComponentAttribute = `${options.metadataAttributePrefix}-component`;
|
|
120
|
+
const pomTagAttribute = `${options.metadataAttributePrefix}-tag`;
|
|
121
|
+
const annotatedElement = element.closest<HTMLElement>(`[${pomComponentAttribute}], [${options.sourceAttribute}]`);
|
|
122
|
+
if (!annotatedElement) {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return resolveAnnotatedInfo(
|
|
127
|
+
annotatedElement.getAttribute(pomComponentAttribute),
|
|
128
|
+
annotatedElement.getAttribute(options.sourceAttribute) ?? undefined,
|
|
129
|
+
annotatedElement.getAttribute(pomTagAttribute),
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function getAnnotatedInfoFromInstance(instance: VueInstance, options: VueDetectorOptions): ResolvedVueComponentInfo | undefined {
|
|
134
|
+
const pomComponentAttribute = `${options.metadataAttributePrefix}-component`;
|
|
135
|
+
const pomTagAttribute = `${options.metadataAttributePrefix}-tag`;
|
|
136
|
+
return resolveAnnotatedInfo(
|
|
137
|
+
getStringPropValue(instance.vnode?.props, pomComponentAttribute),
|
|
138
|
+
getStringPropValue(instance.vnode?.props, options.sourceAttribute),
|
|
139
|
+
getStringPropValue(instance.vnode?.props, pomTagAttribute),
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function getInstanceName(instance: VueInstance): ResolvedVueComponentInfo | undefined {
|
|
144
|
+
if (instance.$options) {
|
|
145
|
+
const name = instance.$options.name
|
|
146
|
+
?? instance.$options._componentTag
|
|
147
|
+
?? inferNameFromFile(instance.$options.__file ?? "");
|
|
148
|
+
|
|
149
|
+
if (isMeaningfulComponentName(name)) {
|
|
150
|
+
return {
|
|
151
|
+
component: name,
|
|
152
|
+
source: instance.$options.__file ? formatSourceLabel(instance.$options.__file, true) : undefined,
|
|
153
|
+
formatted: instance.$options.__file ? `${name} (${formatSourceLabel(instance.$options.__file, true)})` : name,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (instance.type) {
|
|
159
|
+
const name = instance.type.name
|
|
160
|
+
?? instance.type.__name
|
|
161
|
+
?? inferNameFromFile(instance.type.__file ?? "");
|
|
162
|
+
|
|
163
|
+
if (isMeaningfulComponentName(name)) {
|
|
164
|
+
return {
|
|
165
|
+
component: name,
|
|
166
|
+
source: instance.type.__file ? formatSourceLabel(instance.type.__file, true) : undefined,
|
|
167
|
+
formatted: instance.type.__file ? `${name} (${formatSourceLabel(instance.type.__file, true)})` : name,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return undefined;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function scoreInfo(info: ResolvedVueComponentInfo | undefined): number {
|
|
176
|
+
if (!info) {
|
|
177
|
+
return -1;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return (info.component ? 10 : 0) + (info.source ? 100 : 0);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function resolveVueComponentInfo(element: Element, options: VueDetectorOptions): ResolvedVueComponentInfo | undefined {
|
|
184
|
+
const annotatedElementInfo = getAnnotatedInfoFromElement(element, options);
|
|
185
|
+
if (annotatedElementInfo) {
|
|
186
|
+
return annotatedElementInfo;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const seenInstances = new Set<VueInstance>();
|
|
190
|
+
let bestInfo: ResolvedVueComponentInfo | undefined;
|
|
191
|
+
let bestScore = -1;
|
|
192
|
+
let current: Element | null = element;
|
|
193
|
+
let depth = 0;
|
|
194
|
+
|
|
195
|
+
while (current && current !== document.body && depth < 50) {
|
|
196
|
+
for (const instance of getDirectVueInstances(current)) {
|
|
197
|
+
if (seenInstances.has(instance)) {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
seenInstances.add(instance);
|
|
202
|
+
const annotatedInstanceInfo = getAnnotatedInfoFromInstance(instance, options);
|
|
203
|
+
const candidate = annotatedInstanceInfo ?? getInstanceName(instance);
|
|
204
|
+
const score = scoreInfo(candidate);
|
|
205
|
+
if (score > bestScore) {
|
|
206
|
+
bestInfo = candidate;
|
|
207
|
+
bestScore = score;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
current = current.parentElement;
|
|
212
|
+
depth += 1;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return bestInfo;
|
|
216
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-plugin.d.ts","sourceRoot":"","sources":["../../../plugin/support/build-plugin.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAKzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAA6B,MAAM,aAAa,CAAC;AAExG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAEvF,UAAU,qBAAqB;IAC7B,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IAC3D,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,WAAW,EAAE,MAAM,MAAM,EAAE,CAAC;IAC5B,gBAAgB,EAAE,MAAM,MAAM,EAAE,CAAC;IACjC,aAAa,EAAE,MAAM,MAAM,EAAE,CAAC;IAC9B,WAAW,EAAE,MAAM,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,MAAM,EAAE,CAAC;IAE9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,UAAU,EAAE,gCAAgC,CAAC;IAC7C,cAAc,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,uCAAuC;IACvC,cAAc,EAAE,iB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;IAEjD,SAAS,EAAE;QAAE,OAAO,EAAE,qBAAqB,CAAA;KAAE,CAAC;CAC/C;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CA2iBnF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-modules.d.ts","sourceRoot":"","sources":["../../../plugin/support/virtual-modules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAQ1D,wBAAgB,iCAAiC,CAC/C,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,EAC1D,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,GACzD,MAAM,CAgBR"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"support-plugins.d.ts","sourceRoot":"","sources":["../../plugin/support-plugins.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,+BAA+B,CAAC;AAKtF,UAAU,qBAAqB;IAC7B,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IAC3D,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;IAC3D,eAAe,EAAE,GA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