@component-compass/cli 0.0.2 → 0.0.4
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/dist/cli.js +5 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/init.js +1 -3
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/scan.d.ts +13 -1
- package/dist/commands/scan.js +192 -72
- package/dist/commands/scan.js.map +1 -1
- package/dist/composition-rollup.d.ts +16 -14
- package/dist/composition-rollup.js +33 -43
- package/dist/composition-rollup.js.map +1 -1
- package/dist/config/loader.js +5 -9
- package/dist/config/loader.js.map +1 -1
- package/dist/config/schema.d.ts +2 -15
- package/dist/config/schema.js.map +1 -1
- package/dist/envelope/index.d.ts +0 -9
- package/dist/envelope/index.js +1 -46
- package/dist/envelope/index.js.map +1 -1
- package/dist/identity.d.ts +19 -17
- package/dist/identity.js +42 -21
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/local-index/detect-react.d.ts +2 -1
- package/dist/local-index/detect-react.js +269 -72
- package/dist/local-index/detect-react.js.map +1 -1
- package/dist/local-index/detect-vue.d.ts +15 -1
- package/dist/local-index/detect-vue.js +130 -107
- package/dist/local-index/detect-vue.js.map +1 -1
- package/dist/local-index/detect-wc.d.ts +7 -1
- package/dist/local-index/detect-wc.js +56 -60
- package/dist/local-index/detect-wc.js.map +1 -1
- package/dist/local-index/index.d.ts +12 -4
- package/dist/local-index/index.js +40 -25
- package/dist/local-index/index.js.map +1 -1
- package/dist/manifest/barrel-parser.d.ts +10 -0
- package/dist/manifest/barrel-parser.js +11 -0
- package/dist/manifest/barrel-parser.js.map +1 -1
- package/dist/manifest/derived-manifest-stub.d.ts +16 -7
- package/dist/manifest/derived-manifest-stub.js +43 -7
- package/dist/manifest/derived-manifest-stub.js.map +1 -1
- package/dist/manifest/lazy-resolver.d.ts +52 -34
- package/dist/manifest/lazy-resolver.js +269 -69
- package/dist/manifest/lazy-resolver.js.map +1 -1
- package/dist/occurrences.d.ts +4 -4
- package/dist/occurrences.js +49 -9
- package/dist/occurrences.js.map +1 -1
- package/dist/parse-by-ext.d.ts +21 -0
- package/dist/parse-by-ext.js +53 -0
- package/dist/parse-by-ext.js.map +1 -0
- package/dist/reporter/index.d.ts +27 -28
- package/dist/reporter/index.js +99 -58
- package/dist/reporter/index.js.map +1 -1
- package/dist/reporter/stdout.js +4 -4
- package/dist/reporter/stdout.js.map +1 -1
- package/dist/rollup.d.ts +13 -6
- package/dist/rollup.js +9 -6
- package/dist/rollup.js.map +1 -1
- package/dist/scan/cem-index.d.ts +38 -0
- package/dist/scan/cem-index.js +139 -0
- package/dist/scan/cem-index.js.map +1 -0
- package/dist/scan/git-mtime.d.ts +2 -0
- package/dist/scan/git-mtime.js +22 -0
- package/dist/scan/git-mtime.js.map +1 -0
- package/dist/scan/meta.d.ts +5 -0
- package/dist/scan/meta.js +58 -0
- package/dist/scan/meta.js.map +1 -0
- package/dist/scan/stamp-deprecated.d.ts +16 -0
- package/dist/scan/stamp-deprecated.js +33 -0
- package/dist/scan/stamp-deprecated.js.map +1 -0
- package/dist/scan/stamp-version.d.ts +18 -0
- package/dist/scan/stamp-version.js +94 -0
- package/dist/scan/stamp-version.js.map +1 -0
- package/dist/seeds.d.ts +20 -19
- package/dist/seeds.js +136 -68
- package/dist/seeds.js.map +1 -1
- package/dist/types.d.ts +2 -5
- package/dist/util/git.d.ts +8 -0
- package/dist/util/git.js +73 -0
- package/dist/util/git.js.map +1 -1
- package/dist/util/progress.d.ts +21 -0
- package/dist/util/progress.js +54 -0
- package/dist/util/progress.js.map +1 -0
- package/dist/walker/files.d.ts +1 -0
- package/dist/walker/files.js +11 -5
- package/dist/walker/files.js.map +1 -1
- package/dist/workspace/build-graph.d.ts +2 -0
- package/dist/workspace/build-graph.js +117 -0
- package/dist/workspace/build-graph.js.map +1 -0
- package/dist/workspace/declared-deps.d.ts +5 -0
- package/dist/workspace/declared-deps.js +42 -0
- package/dist/workspace/declared-deps.js.map +1 -0
- package/dist/workspace/find-owning-package.d.ts +8 -0
- package/dist/workspace/find-owning-package.js +69 -0
- package/dist/workspace/find-owning-package.js.map +1 -0
- package/dist/workspace/index.d.ts +4 -0
- package/dist/workspace/index.js +4 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/types.d.ts +46 -0
- package/dist/workspace/types.js +13 -0
- package/dist/workspace/types.js.map +1 -0
- package/package.json +15 -7
- package/schema/config.schema.json +2 -24
- package/dist/config/tag-rules.d.ts +0 -2
- package/dist/config/tag-rules.js +0 -34
- package/dist/config/tag-rules.js.map +0 -1
- package/dist/local-index/walker.d.ts +0 -11
- package/dist/local-index/walker.js +0 -47
- package/dist/local-index/walker.js.map +0 -1
- package/dist/manifest/diagnostic-filter.d.ts +0 -12
- package/dist/manifest/diagnostic-filter.js +0 -23
- package/dist/manifest/diagnostic-filter.js.map +0 -1
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { parse as parseScript } from "@babel/parser";
|
|
3
|
-
import { traverse } from "@component-compass/ast-utils";
|
|
1
|
+
import { parseSync } from "oxc-parser";
|
|
4
2
|
import { basename, extname } from "node:path";
|
|
5
|
-
export function detectVueComponents(
|
|
6
|
-
if (
|
|
7
|
-
const def = detectSfc(
|
|
3
|
+
export function detectVueComponents(input, filePath) {
|
|
4
|
+
if (input.kind === "sfc") {
|
|
5
|
+
const def = detectSfc(input.wrapper, filePath);
|
|
8
6
|
return def ? [def] : [];
|
|
9
7
|
}
|
|
10
|
-
|
|
11
|
-
return detectScriptDefineComponent(source, filePath);
|
|
12
|
-
return [];
|
|
8
|
+
return detectScriptDefineComponent(input.program, input.source, filePath);
|
|
13
9
|
}
|
|
14
|
-
function detectSfc(
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
descriptor = parseSfc(source).descriptor;
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
const exportName = resolveSfcName(descriptor, filePath);
|
|
10
|
+
function detectSfc(wrapper, filePath) {
|
|
11
|
+
const exportName = resolveSfcName(wrapper, filePath);
|
|
23
12
|
return {
|
|
24
13
|
componentId: {
|
|
25
14
|
kind: "vue-component",
|
|
@@ -31,81 +20,102 @@ function detectSfc(source, filePath) {
|
|
|
31
20
|
detector: "vue-sfc",
|
|
32
21
|
};
|
|
33
22
|
}
|
|
34
|
-
function resolveSfcName(
|
|
35
|
-
const
|
|
23
|
+
function resolveSfcName(wrapper, filePath) {
|
|
24
|
+
const { descriptor, scriptProgram } = wrapper;
|
|
25
|
+
// parseByExt prefers scriptSetup.content for scriptProgram; reuse it for the
|
|
26
|
+
// defineOptions probe (scriptSetup-only API). If scriptSetup is absent,
|
|
27
|
+
// scriptProgram came from `script` and is reusable for the options-object probe.
|
|
28
|
+
const hasScriptSetup = descriptor.scriptSetup != null;
|
|
29
|
+
const setupSrc = descriptor.scriptSetup?.content ?? "";
|
|
36
30
|
const scriptSrc = descriptor.script?.content ?? "";
|
|
37
|
-
const fromDefineOptions =
|
|
31
|
+
const fromDefineOptions = hasScriptSetup
|
|
32
|
+
? extractDefineOptionsFromProgramOrSrc(scriptProgram, setupSrc)
|
|
33
|
+
: null;
|
|
38
34
|
if (fromDefineOptions)
|
|
39
35
|
return fromDefineOptions;
|
|
40
|
-
|
|
36
|
+
// Options-object form only lives in the plain `script` block. If scriptProgram
|
|
37
|
+
// came from scriptSetup, we still need to parse `script.content` separately.
|
|
38
|
+
const optionsProgram = hasScriptSetup ? undefined : scriptProgram;
|
|
39
|
+
const fromOptionsObject = extractOptionsObjectFromProgramOrSrc(optionsProgram, scriptSrc);
|
|
41
40
|
if (fromOptionsObject)
|
|
42
41
|
return fromOptionsObject;
|
|
43
42
|
return pascalFromFilename(filePath);
|
|
44
43
|
}
|
|
45
|
-
function
|
|
44
|
+
function extractDefineOptionsFromProgramOrSrc(program, src) {
|
|
45
|
+
if (program)
|
|
46
|
+
return extractDefineOptionsFromProgram(program);
|
|
46
47
|
if (!src.includes("defineOptions"))
|
|
47
48
|
return null;
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
return null;
|
|
51
|
-
let found = null;
|
|
52
|
-
traverse(ast, {
|
|
53
|
-
CallExpression(path) {
|
|
54
|
-
if (found)
|
|
55
|
-
return;
|
|
56
|
-
const { callee, arguments: args } = path.node;
|
|
57
|
-
if (callee.type !== "Identifier" || callee.name !== "defineOptions")
|
|
58
|
-
return;
|
|
59
|
-
const arg = args[0];
|
|
60
|
-
if (!arg || arg.type !== "ObjectExpression")
|
|
61
|
-
return;
|
|
62
|
-
found = readNameProperty(arg);
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
return found;
|
|
49
|
+
const parsed = tryParseOxc(src);
|
|
50
|
+
return parsed ? extractDefineOptionsFromProgram(parsed) : null;
|
|
66
51
|
}
|
|
67
|
-
function
|
|
52
|
+
function extractDefineOptionsFromProgram(program) {
|
|
53
|
+
for (const stmt of program.body) {
|
|
54
|
+
const expr = stmt.type === "ExpressionStatement" ? stmt.expression : null;
|
|
55
|
+
if (!expr)
|
|
56
|
+
continue;
|
|
57
|
+
const call = unwrapParens(expr);
|
|
58
|
+
if (call.type !== "CallExpression" ||
|
|
59
|
+
call.callee.type !== "Identifier" ||
|
|
60
|
+
call.callee.name !== "defineOptions")
|
|
61
|
+
continue;
|
|
62
|
+
const arg = call.arguments[0];
|
|
63
|
+
if (!arg || arg.type !== "ObjectExpression")
|
|
64
|
+
continue;
|
|
65
|
+
const name = readNameProperty(arg);
|
|
66
|
+
if (name)
|
|
67
|
+
return name;
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
function extractOptionsObjectFromProgramOrSrc(program, src) {
|
|
72
|
+
if (program)
|
|
73
|
+
return extractOptionsObjectFromProgram(program);
|
|
68
74
|
if (!src)
|
|
69
75
|
return null;
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
ExportDefaultDeclaration
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
const parsed = tryParseOxc(src);
|
|
77
|
+
return parsed ? extractOptionsObjectFromProgram(parsed) : null;
|
|
78
|
+
}
|
|
79
|
+
function extractOptionsObjectFromProgram(program) {
|
|
80
|
+
for (const stmt of program.body) {
|
|
81
|
+
if (stmt.type !== "ExportDefaultDeclaration")
|
|
82
|
+
continue;
|
|
83
|
+
const decl = unwrapParens(stmt.declaration);
|
|
84
|
+
if (decl.type === "ObjectExpression") {
|
|
85
|
+
return readNameProperty(decl);
|
|
86
|
+
}
|
|
87
|
+
if (decl.type === "CallExpression" &&
|
|
88
|
+
decl.callee.type === "Identifier" &&
|
|
89
|
+
decl.callee.name === "defineComponent") {
|
|
90
|
+
const arg = decl.arguments[0];
|
|
91
|
+
if (arg && arg.type === "ObjectExpression") {
|
|
92
|
+
return readNameProperty(arg);
|
|
87
93
|
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
91
97
|
}
|
|
92
98
|
function readNameProperty(obj) {
|
|
93
99
|
for (const p of obj.properties) {
|
|
94
|
-
|
|
95
|
-
if (
|
|
100
|
+
// In oxc, ObjectProperty has type: "Property" (interface name: ObjectProperty)
|
|
101
|
+
if (p.type !== "Property")
|
|
96
102
|
continue;
|
|
97
|
-
|
|
103
|
+
const prop = p;
|
|
104
|
+
if (prop.key.type !== "Identifier" || prop.key.name !== "name")
|
|
98
105
|
continue;
|
|
99
|
-
|
|
106
|
+
const val = unwrapParens(prop.value);
|
|
107
|
+
if (val.type !== "Literal")
|
|
100
108
|
continue;
|
|
101
|
-
if (typeof
|
|
102
|
-
return
|
|
109
|
+
if (typeof val.value === "string") {
|
|
110
|
+
return val.value;
|
|
111
|
+
}
|
|
103
112
|
}
|
|
104
113
|
return null;
|
|
105
114
|
}
|
|
106
|
-
function
|
|
115
|
+
function tryParseOxc(src) {
|
|
107
116
|
try {
|
|
108
|
-
|
|
117
|
+
const result = parseSync("inline.ts", src);
|
|
118
|
+
return result.program;
|
|
109
119
|
}
|
|
110
120
|
catch {
|
|
111
121
|
return null;
|
|
@@ -115,50 +125,63 @@ function pascalFromFilename(filePath) {
|
|
|
115
125
|
const stem = basename(filePath, extname(filePath));
|
|
116
126
|
return stem.replace(/(^|[-_])(.)/g, (_, _sep, c) => c.toUpperCase());
|
|
117
127
|
}
|
|
118
|
-
function detectScriptDefineComponent(source, filePath) {
|
|
119
|
-
const ast = tryParse(source);
|
|
120
|
-
if (!ast)
|
|
121
|
-
return [];
|
|
128
|
+
function detectScriptDefineComponent(program, source, filePath) {
|
|
122
129
|
const out = [];
|
|
123
|
-
|
|
124
|
-
ExportDefaultDeclaration
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
130
|
+
for (const stmt of program.body) {
|
|
131
|
+
if (stmt.type !== "ExportDefaultDeclaration")
|
|
132
|
+
continue;
|
|
133
|
+
const decl = unwrapParens(stmt.declaration);
|
|
134
|
+
if (decl.type === "CallExpression" &&
|
|
135
|
+
decl.callee.type === "Identifier" &&
|
|
136
|
+
decl.callee.name === "defineComponent") {
|
|
137
|
+
out.push({
|
|
138
|
+
componentId: {
|
|
139
|
+
kind: "vue-component",
|
|
140
|
+
export: pascalFromFilename(filePath),
|
|
141
|
+
source: { type: "local", filePath },
|
|
142
|
+
},
|
|
143
|
+
exportName: pascalFromFilename(filePath),
|
|
144
|
+
isDefault: true,
|
|
145
|
+
detector: "vue-define-component",
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
if (decl.type === "ObjectExpression" &&
|
|
149
|
+
hasSetupOrRender(decl)) {
|
|
150
|
+
out.push({
|
|
151
|
+
componentId: {
|
|
152
|
+
kind: "vue-component",
|
|
153
|
+
export: pascalFromFilename(filePath),
|
|
154
|
+
source: { type: "local", filePath },
|
|
155
|
+
},
|
|
156
|
+
exportName: pascalFromFilename(filePath),
|
|
157
|
+
isDefault: true,
|
|
158
|
+
detector: "vue-functional",
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
152
162
|
return out;
|
|
153
163
|
}
|
|
154
164
|
function hasSetupOrRender(obj) {
|
|
155
165
|
return obj.properties.some((p) => {
|
|
156
|
-
|
|
157
|
-
if (
|
|
166
|
+
// oxc uses `Property` (ObjectProperty interface) for object properties and method shorthands
|
|
167
|
+
if (p.type !== "Property")
|
|
158
168
|
return false;
|
|
159
|
-
|
|
169
|
+
const prop = p;
|
|
170
|
+
if (prop.key.type !== "Identifier")
|
|
160
171
|
return false;
|
|
161
|
-
|
|
172
|
+
const name = prop.key.name;
|
|
173
|
+
return name === "setup" || name === "render";
|
|
162
174
|
});
|
|
163
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* oxc preserves ParenthesizedExpression as a distinct node type.
|
|
178
|
+
* Unwrap any number of wrapping parens to reach the inner expression.
|
|
179
|
+
*/
|
|
180
|
+
function unwrapParens(node) {
|
|
181
|
+
let current = node;
|
|
182
|
+
while (current.type === "ParenthesizedExpression") {
|
|
183
|
+
current = current.expression;
|
|
184
|
+
}
|
|
185
|
+
return current;
|
|
186
|
+
}
|
|
164
187
|
//# sourceMappingURL=detect-vue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect-vue.js","sourceRoot":"","sources":["../../src/local-index/detect-vue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"detect-vue.js","sourceRoot":"","sources":["../../src/local-index/detect-vue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgB9C,MAAM,UAAU,mBAAmB,CAAC,KAAuB,EAAE,QAAgB;IAC3E,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC/C,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1B,CAAC;IACD,OAAO,2BAA2B,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC5E,CAAC;AAED,SAAS,SAAS,CAAC,OAAwB,EAAE,QAAgB;IAC3D,MAAM,UAAU,GAAG,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACrD,OAAO;QACL,WAAW,EAAE;YACX,IAAI,EAAE,eAAe;YACrB,MAAM,EAAE,UAAU;YAClB,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE;SACpC;QACD,UAAU;QACV,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,SAAS;KACpB,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,OAAwB,EAAE,QAAgB;IAChE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAC9C,6EAA6E;IAC7E,wEAAwE;IACxE,iFAAiF;IACjF,MAAM,cAAc,GAAG,UAAU,CAAC,WAAW,IAAI,IAAI,CAAC;IACtD,MAAM,QAAQ,GAAG,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QAAQ,EAAE,gBAAgB;aAC3B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAqB;IAC7C,OAAO,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;QAC/B,6FAA6F;QAC7F,IAAI,CAAC,CAAC,IAAI,KAAK,UAAU;YAAE,OAAO,KAAK,CAAC;QACxC,MAAM,IAAI,GAAG,CAAmB,CAAC;QACjC,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,YAAY;YAAE,OAAO,KAAK,CAAC;QACjD,MAAM,IAAI,GAAI,IAAI,CAAC,GAAwB,CAAC,IAAI,CAAC;QACjD,OAAO,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,SAAS,YAAY,CAAC,IAAU;IAC9B,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,OAAO,OAAO,CAAC,IAAI,KAAK,yBAAyB,EAAE,CAAC;QAClD,OAAO,GAAI,OAAgC,CAAC,UAAU,CAAC;IACzD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
import type { Program } from "@oxc-project/types";
|
|
1
2
|
import type { LocalDefinition } from "./types.js";
|
|
2
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Detect local custom-element class definitions. Looks for two patterns:
|
|
5
|
+
* 1. @customElement("tag-name") class Foo extends HTMLElement {}
|
|
6
|
+
* 2. customElements.define("tag-name", MyButton)
|
|
7
|
+
*/
|
|
8
|
+
export declare function detectWebComponents(program: Program, filePath: string): LocalDefinition[];
|
|
@@ -1,67 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
try {
|
|
9
|
-
return parse(source, {
|
|
10
|
-
sourceType: "module",
|
|
11
|
-
plugins: ["typescript", "decorators-legacy", "classProperties"],
|
|
12
|
-
errorRecovery: true,
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
catch {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
})();
|
|
19
|
-
if (!ast)
|
|
20
|
-
return [];
|
|
1
|
+
import { walk } from "oxc-walker";
|
|
2
|
+
/**
|
|
3
|
+
* Detect local custom-element class definitions. Looks for two patterns:
|
|
4
|
+
* 1. @customElement("tag-name") class Foo extends HTMLElement {}
|
|
5
|
+
* 2. customElements.define("tag-name", MyButton)
|
|
6
|
+
*/
|
|
7
|
+
export function detectWebComponents(program, filePath) {
|
|
21
8
|
const out = [];
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
out.push({
|
|
37
|
-
componentId: { kind: "custom-element", tagName: tag, source: { type: "local", filePath } },
|
|
38
|
-
exportName: path.node.id?.name ?? tag,
|
|
39
|
-
isDefault: false,
|
|
40
|
-
detector: "wc-decorator",
|
|
41
|
-
});
|
|
9
|
+
walk(program, {
|
|
10
|
+
enter(node) {
|
|
11
|
+
// Pattern 1: @customElement("…") class Foo …
|
|
12
|
+
if (node.type === "ClassDeclaration") {
|
|
13
|
+
for (const decorator of node.decorators) {
|
|
14
|
+
const tag = extractCustomElementTag(decorator.expression);
|
|
15
|
+
if (tag && node.id) {
|
|
16
|
+
out.push({
|
|
17
|
+
componentId: { kind: "custom-element", tagName: tag, source: { type: "local", filePath } },
|
|
18
|
+
exportName: node.id.name,
|
|
19
|
+
isDefault: false,
|
|
20
|
+
detector: "wc-decorator",
|
|
21
|
+
});
|
|
22
|
+
}
|
|
42
23
|
}
|
|
43
24
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (tagArg?.type === "StringLiteral" &&
|
|
56
|
-
typeof tagArg.value === "string" &&
|
|
57
|
-
tagArg.value.includes("-")) {
|
|
58
|
-
const exportName = classArg?.type === "Identifier" ? classArg.name : tagArg.value;
|
|
25
|
+
// Pattern 2: customElements.define("…", MyButton)
|
|
26
|
+
if (node.type === "CallExpression") {
|
|
27
|
+
if (!isCustomElementsDefine(node))
|
|
28
|
+
return;
|
|
29
|
+
const [tagArg, classArg] = node.arguments;
|
|
30
|
+
if (!tagArg || tagArg.type !== "Literal" || typeof tagArg.value !== "string")
|
|
31
|
+
return;
|
|
32
|
+
const tag = tagArg.value;
|
|
33
|
+
if (!tag.includes("-"))
|
|
34
|
+
return;
|
|
35
|
+
const exportName = classArg?.type === "Identifier" ? classArg.name : tag;
|
|
59
36
|
out.push({
|
|
60
|
-
componentId: {
|
|
61
|
-
kind: "custom-element",
|
|
62
|
-
tagName: tagArg.value,
|
|
63
|
-
source: { type: "local", filePath },
|
|
64
|
-
},
|
|
37
|
+
componentId: { kind: "custom-element", tagName: tag, source: { type: "local", filePath } },
|
|
65
38
|
exportName,
|
|
66
39
|
isDefault: false,
|
|
67
40
|
detector: "wc-customelements-define",
|
|
@@ -71,4 +44,27 @@ export function detectWebComponents(source, filePath, extension) {
|
|
|
71
44
|
});
|
|
72
45
|
return out;
|
|
73
46
|
}
|
|
47
|
+
// ── Helpers ────────────────────────────────────────────────────────────────
|
|
48
|
+
/** Return the tag string from a @customElement("tag-name") decorator expression, or null. */
|
|
49
|
+
function extractCustomElementTag(expr) {
|
|
50
|
+
if (expr.type !== "CallExpression")
|
|
51
|
+
return null;
|
|
52
|
+
const callee = expr.callee;
|
|
53
|
+
if (callee.type !== "Identifier" || callee.name !== "customElement")
|
|
54
|
+
return null;
|
|
55
|
+
const arg = expr.arguments[0];
|
|
56
|
+
if (!arg || arg.type !== "Literal" || typeof arg.value !== "string")
|
|
57
|
+
return null;
|
|
58
|
+
const tag = arg.value;
|
|
59
|
+
return tag.includes("-") ? tag : null;
|
|
60
|
+
}
|
|
61
|
+
/** Return true when the node is a `customElements.define(…)` call. */
|
|
62
|
+
function isCustomElementsDefine(node) {
|
|
63
|
+
const callee = node.callee;
|
|
64
|
+
return (callee.type === "MemberExpression" &&
|
|
65
|
+
callee.object.type === "Identifier" &&
|
|
66
|
+
callee.object.name === "customElements" &&
|
|
67
|
+
callee.property.type === "Identifier" &&
|
|
68
|
+
callee.property.name === "define");
|
|
69
|
+
}
|
|
74
70
|
//# sourceMappingURL=detect-wc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect-wc.js","sourceRoot":"","sources":["../../src/local-index/detect-wc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"detect-wc.js","sourceRoot":"","sources":["../../src/local-index/detect-wc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIlC;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAgB,EAChB,QAAgB;IAEhB,MAAM,GAAG,GAAsB,EAAE,CAAC;IAElC,IAAI,CAAC,OAAO,EAAE;QACZ,KAAK,CAAC,IAAU;YACd,6CAA6C;YAC7C,IAAI,IAAI,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;gBACrC,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;oBACxC,MAAM,GAAG,GAAG,uBAAuB,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;oBAC1D,IAAI,GAAG,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;wBACnB,GAAG,CAAC,IAAI,CAAC;4BACP,WAAW,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,E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AgB;QAAE,OAAO,IAAI,CAAC;IAChD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,IAAI,MAAM,CAAC,IAAI,KAAK,YAAY,IAAI,MAAM,CAAC,IAAI,KAAK,eAAe;QAAE,OAAO,IAAI,CAAC;IACjF,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC9B,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACjF,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC;IACtB,OAAO,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AACxC,CAAC;AAED,sEAAsE;AACtE,SAAS,sBAAsB,CAAC,IAAuC;IACrE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,OAAO,CACL,MAAM,CAAC,IAAI,KAAK,kBAAkB;QAClC,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY;QACnC,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,gBAAgB;QACvC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY;QACrC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAClC,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { LocalDefinition, LocalDefinitionIndex } from "./types.js";
|
|
2
|
+
import type { DiagnosticCollector } from "@component-compass/plugin-core";
|
|
3
|
+
/**
|
|
4
|
+
* Pure fold: builds the byPath / byTag indices from a flat LocalDefinition[]
|
|
5
|
+
* stream. No filesystem walk, no parsing — the caller (scan.ts phase 1) owns
|
|
6
|
+
* file IO and detector dispatch, then hands the resulting definitions here.
|
|
7
|
+
*
|
|
8
|
+
* Duplicate-tag policy: first registration wins. Subsequent custom-element
|
|
9
|
+
* definitions sharing the same tagName are dropped and surfaced via
|
|
10
|
+
* `local-index-duplicate-tag` on the collector.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildLocalIndex(definitions: LocalDefinition[], collector?: DiagnosticCollector): LocalDefinitionIndex;
|
|
5
13
|
export type { LocalDefinition, LocalDefinitionIndex, DetectorId } from "./types.js";
|
|
6
14
|
export { emptyLocalIndex } from "./types.js";
|
|
@@ -1,31 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Pure fold: builds the byPath / byTag indices from a flat LocalDefinition[]
|
|
3
|
+
* stream. No filesystem walk, no parsing — the caller (scan.ts phase 1) owns
|
|
4
|
+
* file IO and detector dispatch, then hands the resulting definitions here.
|
|
5
|
+
*
|
|
6
|
+
* Duplicate-tag policy: first registration wins. Subsequent custom-element
|
|
7
|
+
* definitions sharing the same tagName are dropped and surfaced via
|
|
8
|
+
* `local-index-duplicate-tag` on the collector.
|
|
9
|
+
*/
|
|
10
|
+
export function buildLocalIndex(definitions, collector) {
|
|
11
|
+
const byPath = new Map();
|
|
12
|
+
const byTag = new Map();
|
|
13
|
+
for (const def of definitions) {
|
|
14
|
+
// byPath: every definition contributes, grouped by its source filePath.
|
|
15
|
+
if (def.componentId.source.type === "local") {
|
|
16
|
+
const filePath = def.componentId.source.filePath;
|
|
17
|
+
const existing = byPath.get(filePath);
|
|
18
|
+
if (existing)
|
|
19
|
+
existing.push(def);
|
|
20
|
+
else
|
|
21
|
+
byPath.set(filePath, [def]);
|
|
22
|
+
}
|
|
23
|
+
// byTag: only custom-element definitions; first-wins on collision.
|
|
24
|
+
if (def.componentId.kind !== "custom-element")
|
|
25
|
+
continue;
|
|
26
|
+
const existing = byTag.get(def.componentId.tagName);
|
|
27
|
+
if (existing &&
|
|
28
|
+
existing.componentId.kind === "custom-element" &&
|
|
29
|
+
existing.componentId.source.type === "local" &&
|
|
30
|
+
def.componentId.source.type === "local" &&
|
|
31
|
+
existing.componentId.source.filePath !== def.componentId.source.filePath) {
|
|
32
|
+
collector?.emit({
|
|
33
|
+
code: "local-index-duplicate-tag",
|
|
34
|
+
severity: "warning",
|
|
35
|
+
filePath: def.componentId.source.filePath,
|
|
36
|
+
tagName: def.componentId.tagName,
|
|
37
|
+
conflictsWith: existing.componentId.source.filePath,
|
|
38
|
+
});
|
|
15
39
|
continue;
|
|
16
|
-
index.byPath.set(file.filePath, found);
|
|
17
|
-
for (const def of found) {
|
|
18
|
-
if (def.componentId.kind === "custom-element") {
|
|
19
|
-
const existing = index.byTag.get(def.componentId.tagName);
|
|
20
|
-
if (existing && existing.componentId.kind === "custom-element" && existing.componentId.source.type === "local" && existing.componentId.source.filePath !== file.filePath) {
|
|
21
|
-
console.warn(`[component-compass] duplicate local custom-element <${def.componentId.tagName}> in ${file.filePath} (already registered from ${existing.componentId.source.filePath}); keeping first.`);
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
index.byTag.set(def.componentId.tagName, def);
|
|
25
|
-
}
|
|
26
40
|
}
|
|
41
|
+
byTag.set(def.componentId.tagName, def);
|
|
27
42
|
}
|
|
28
|
-
return
|
|
43
|
+
return { byPath, byTag };
|
|
29
44
|
}
|
|
30
45
|
export { emptyLocalIndex } from "./types.js";
|
|
31
46
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/local-index/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/local-index/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG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AO,EAAE,GAAG,CAAC,WAAW,CAAC,OAAO;gBAChC,aAAa,EAAE,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ;aACpD,CAAC,CAAC;YACH,SAAS;QACX,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AAC3B,CAAC;AAGD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { File as BabelFile } from "@babel/types";
|
|
1
2
|
export type BarrelReExport = {
|
|
2
3
|
kind: "star";
|
|
3
4
|
from: string;
|
|
@@ -40,3 +41,12 @@ export type BarrelParseResult = {
|
|
|
40
41
|
* throwing.
|
|
41
42
|
*/
|
|
42
43
|
export declare function parseBarrelTopLevelDetailed(source: string): BarrelParseResult;
|
|
44
|
+
/**
|
|
45
|
+
* AST-taking variant of {@link parseBarrelTopLevelDetailed}. Lets callers
|
|
46
|
+
* that already hold a parsed `BabelFile` reuse it across passes (the lazy
|
|
47
|
+
* resolver caches barrel ASTs to avoid re-parsing the same file once per
|
|
48
|
+
* import resolution).
|
|
49
|
+
*
|
|
50
|
+
* Performs the same top-level analysis on `ast.program` — never re-parses.
|
|
51
|
+
*/
|
|
52
|
+
export declare function parseBarrelTopLevelDetailedFromAst(ast: BabelFile): BarrelParseResult;
|