@qds.dev/tools 0.6.2 → 0.7.5
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/lib/{vite → rolldown}/as-child.qwik.mjs +21 -18
- package/lib/{vite → rolldown}/icons.qwik.mjs +55 -44
- package/lib/rolldown/index.qwik.mjs +3 -2
- package/lib/rolldown/inline-css.qwik.mjs +25 -17
- package/lib/vite/index.qwik.mjs +5 -3
- package/lib/vite/minify-content.qwik.mjs +57 -0
- package/lib-types/tools/rolldown/as-child.d.ts +24 -0
- package/lib-types/tools/rolldown/icons.d.ts +47 -0
- package/lib-types/tools/rolldown/index.d.ts +4 -1
- package/lib-types/tools/rolldown/inline-css.d.ts +15 -5
- package/lib-types/tools/utils/icons/import-resolver.d.ts +1 -1
- package/lib-types/tools/utils/icons/transform/mdx.d.ts +1 -1
- package/lib-types/tools/utils/icons/transform/shared.d.ts +1 -1
- package/lib-types/tools/utils/icons/transform/tsx.d.ts +1 -1
- package/lib-types/tools/vite/index.d.ts +3 -3
- package/lib-types/tools/vite/minify-content.d.ts +9 -0
- package/package.json +9 -6
- package/lib/docs/component-props.qwik.mjs +0 -481
- package/lib/docs/index.qwik.mjs +0 -3
- package/lib/rolldown/qds-transform.qwik.mjs +0 -111
- package/lib/vite/component-props.qwik.mjs +0 -315
- package/lib-types/docs/component-props.d.ts +0 -25
- package/lib-types/docs/index.d.ts +0 -2
- package/lib-types/linter/qds-internal.d.ts +0 -7
- package/lib-types/linter/qds-internal.unit.d.ts +0 -1
- package/lib-types/linter/rule-tester.d.ts +0 -100
- package/lib-types/rolldown/index.d.ts +0 -3
- package/lib-types/rolldown/inline-css.d.ts +0 -16
- package/lib-types/rolldown/qds-transform.d.ts +0 -11
- package/lib-types/rolldown/qds-transform.unit.d.ts +0 -1
- package/lib-types/rolldown/qwik-rolldown.d.ts +0 -9
- package/lib-types/src/generate/icon-types.d.ts +0 -25
- package/lib-types/src/index.d.ts +0 -1
- package/lib-types/src/vite.d.ts +0 -1
- package/lib-types/tools/rolldown/qds-transform.d.ts +0 -11
- package/lib-types/tools/rolldown/qds-transform.unit.d.ts +0 -1
- package/lib-types/tools/vite/as-child.d.ts +0 -13
- package/lib-types/tools/vite/icons.d.ts +0 -19
- package/lib-types/utils/ast/core.d.ts +0 -4
- package/lib-types/utils/ast/imports.d.ts +0 -19
- package/lib-types/utils/ast/jsx-helpers.d.ts +0 -3
- package/lib-types/utils/ast/qwik.d.ts +0 -13
- package/lib-types/utils/fs.d.ts +0 -4
- package/lib-types/utils/icons/ast/expressions.d.ts +0 -50
- package/lib-types/utils/icons/ast/expressions.unit.d.ts +0 -1
- package/lib-types/utils/icons/ast/jsx.d.ts +0 -81
- package/lib-types/utils/icons/ast/jsx.unit.d.ts +0 -1
- package/lib-types/utils/icons/collections/loader.d.ts +0 -38
- package/lib-types/utils/icons/import-resolver.d.ts +0 -37
- package/lib-types/utils/icons/naming.d.ts +0 -46
- package/lib-types/utils/icons/transform/mdx.d.ts +0 -28
- package/lib-types/utils/icons/transform/shared.d.ts +0 -31
- package/lib-types/utils/icons/transform/tsx.d.ts +0 -51
- package/lib-types/utils/icons/types/mdx-ast.d.ts +0 -74
- package/lib-types/utils/index.d.ts +0 -13
- package/lib-types/utils/package-json.d.ts +0 -13
- package/lib-types/utils/transform-dts.d.ts +0 -15
- package/lib-types/utils/transform-dts.unit.d.ts +0 -1
- package/lib-types/vite/as-child.d.ts +0 -13
- package/lib-types/vite/as-child.unit.d.ts +0 -1
- package/lib-types/vite/component-props.d.ts +0 -24
- package/lib-types/vite/icons.d.ts +0 -19
- package/lib-types/vite/icons.unit.d.ts +0 -1
- package/lib-types/vite/index.d.ts +0 -3
- /package/lib-types/tools/{vite → rolldown}/as-child.unit.d.ts +0 -0
- /package/lib-types/tools/{vite → rolldown}/icons.unit.d.ts +0 -0
- /package/lib-types/{docs/component-props.unit.d.ts → tools/vite/minify-content.unit.d.ts} +0 -0
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
import { parseSync } from "oxc-parser";
|
|
2
|
-
import { walk } from "oxc-walker";
|
|
3
|
-
import { existsSync } from "node:fs";
|
|
4
|
-
import { dirname, join, relative } from "node:path";
|
|
5
|
-
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
6
|
-
|
|
7
|
-
//#region vite/component-props.ts
|
|
8
|
-
/**
|
|
9
|
-
* Vite plugin that extracts component prop types and generates metadata JSON files
|
|
10
|
-
*/ const componentProps = (options) => {
|
|
11
|
-
const { componentsDir, outputDir } = options;
|
|
12
|
-
return {
|
|
13
|
-
name: "vite-plugin-qds-component-props",
|
|
14
|
-
enforce: "pre",
|
|
15
|
-
async buildStart() {
|
|
16
|
-
await generateAllComponentMetadata(componentsDir, outputDir);
|
|
17
|
-
},
|
|
18
|
-
async handleHotUpdate(ctx) {
|
|
19
|
-
if (ctx.file.includes(componentsDir) && ctx.file.endsWith(".tsx")) {
|
|
20
|
-
const componentName = extractComponentName(ctx.file, componentsDir);
|
|
21
|
-
if (componentName) await generateComponentMetadata(componentName, componentsDir, outputDir);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Generate metadata for all components
|
|
28
|
-
*/ async function generateAllComponentMetadata(componentsDir, outputDir) {
|
|
29
|
-
const componentDirs = await findComponentDirs(componentsDir);
|
|
30
|
-
for (const componentName of componentDirs) await generateComponentMetadata(componentName, componentsDir, outputDir);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Generate metadata for a single component
|
|
34
|
-
*/ async function generateComponentMetadata(componentName, componentsDir, outputDir) {
|
|
35
|
-
try {
|
|
36
|
-
const metadata = {
|
|
37
|
-
componentName,
|
|
38
|
-
pieces: await parseComponentPieces(componentName, componentsDir)
|
|
39
|
-
};
|
|
40
|
-
const outputPath = join(outputDir, `${componentName}.json`);
|
|
41
|
-
await mkdir(dirname(outputPath), { recursive: true });
|
|
42
|
-
await writeFile(outputPath, JSON.stringify(metadata, null, 2), "utf-8");
|
|
43
|
-
} catch (error) {
|
|
44
|
-
console.error(`Error generating metadata for ${componentName}:`, error);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Parse all component pieces for a component
|
|
49
|
-
*/ async function parseComponentPieces(componentName, componentsDir) {
|
|
50
|
-
const pieces = [];
|
|
51
|
-
const componentPath = join(componentsDir, componentName);
|
|
52
|
-
const rootPath = join(componentPath, `${componentName}-root.tsx`);
|
|
53
|
-
if (existsSync(rootPath)) {
|
|
54
|
-
const rootProps = await parseComponentFile(rootPath, "Root");
|
|
55
|
-
if (rootProps.length > 0) pieces.push({
|
|
56
|
-
name: "Root",
|
|
57
|
-
props: rootProps
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
const pieceFiles = [
|
|
61
|
-
{
|
|
62
|
-
file: `${componentName}-trigger.tsx`,
|
|
63
|
-
name: "Trigger"
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
file: `${componentName}-label.tsx`,
|
|
67
|
-
name: "Label"
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
file: `${componentName}-indicator.tsx`,
|
|
71
|
-
name: "Indicator"
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
file: `${componentName}-description.tsx`,
|
|
75
|
-
name: "Description"
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
file: `${componentName}-error.tsx`,
|
|
79
|
-
name: "Error"
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
file: `${componentName}-input.tsx`,
|
|
83
|
-
name: "Input"
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
file: `${componentName}-content.tsx`,
|
|
87
|
-
name: "Content"
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
file: `${componentName}-item.tsx`,
|
|
91
|
-
name: "Item"
|
|
92
|
-
}
|
|
93
|
-
];
|
|
94
|
-
for (const { file, name } of pieceFiles) {
|
|
95
|
-
const filePath = join(componentPath, file);
|
|
96
|
-
if (existsSync(filePath)) {
|
|
97
|
-
const props = await parseComponentFile(filePath, name);
|
|
98
|
-
if (props.length > 0) pieces.push({
|
|
99
|
-
name,
|
|
100
|
-
props
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return pieces;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Parse a component file and extract prop types
|
|
108
|
-
*/ async function parseComponentFile(filePath, pieceName) {
|
|
109
|
-
const source = await readFile(filePath, "utf-8");
|
|
110
|
-
const ast = parseSync(filePath, source);
|
|
111
|
-
if (ast.errors.length > 0) {
|
|
112
|
-
console.warn(`Parse errors in ${filePath}:`, ast.errors);
|
|
113
|
-
return [];
|
|
114
|
-
}
|
|
115
|
-
const props = [];
|
|
116
|
-
let bindableProps = /* @__PURE__ */ new Set();
|
|
117
|
-
const publicPropsType = findPublicPropsType(ast.program, source);
|
|
118
|
-
if (!publicPropsType) return props;
|
|
119
|
-
bindableProps = findBindableProps(ast.program, source);
|
|
120
|
-
extractPropsFromType(publicPropsType, source, bindableProps, props);
|
|
121
|
-
return props;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Find Public*Props type definition
|
|
125
|
-
*/ function findPublicPropsType(program, source) {
|
|
126
|
-
let foundType = null;
|
|
127
|
-
walk(program, { enter(node) {
|
|
128
|
-
if (node.type === "TSTypeAliasDeclaration") {
|
|
129
|
-
const typeName = "id" in node && "name" in node.id ? node.id.name : "";
|
|
130
|
-
if (typeName.startsWith("Public") && typeName.endsWith("Props")) {
|
|
131
|
-
if ("typeAnnotation" in node && node.typeAnnotation) {
|
|
132
|
-
const typeAnnotation = node.typeAnnotation;
|
|
133
|
-
if (typeAnnotation.type === "TSTypeLiteral") foundType = typeAnnotation;
|
|
134
|
-
else if (typeAnnotation.type === "TSIntersectionType" && "types" in typeAnnotation) {
|
|
135
|
-
for (const type of typeAnnotation.types) if (type.type === "TSTypeLiteral") {
|
|
136
|
-
foundType = type;
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
} });
|
|
144
|
-
return foundType;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Find BindableProps and extract bindable prop names
|
|
148
|
-
*/ function findBindableProps(program, source) {
|
|
149
|
-
const bindableProps = /* @__PURE__ */ new Set();
|
|
150
|
-
let bindableTypeName = null;
|
|
151
|
-
walk(program, { enter(node) {
|
|
152
|
-
if (node.type === "TSTypeAliasDeclaration") {
|
|
153
|
-
const typeName = "id" in node && "name" in node.id ? node.id.name : "";
|
|
154
|
-
if (typeName.startsWith("Public") && typeName.endsWith("Props")) {
|
|
155
|
-
const typeAnnotation = "typeAnnotation" in node ? node.typeAnnotation : null;
|
|
156
|
-
if (typeAnnotation && typeAnnotation.type === "TSIntersectionType") {
|
|
157
|
-
const types = "types" in typeAnnotation ? typeAnnotation.types : [];
|
|
158
|
-
for (const type of types) if (type.type === "TSTypeReference") {
|
|
159
|
-
const typeNameNode = "typeName" in type ? type.typeName : null;
|
|
160
|
-
if (typeNameNode && "name" in typeNameNode && typeNameNode.name === "BindableProps") {
|
|
161
|
-
const typeParams = "typeParameters" in type && type.typeParameters && typeof type.typeParameters === "object" && "params" in type.typeParameters && Array.isArray(type.typeParameters.params) ? type.typeParameters.params : [];
|
|
162
|
-
if (typeParams.length > 0 && typeParams[0].type === "TSTypeReference") {
|
|
163
|
-
const refTypeName = "typeName" in typeParams[0] ? typeParams[0].typeName : null;
|
|
164
|
-
if (refTypeName && "name" in refTypeName) bindableTypeName = refTypeName.name;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
} });
|
|
172
|
-
if (bindableTypeName) walk(program, { enter(node) {
|
|
173
|
-
if (node.type === "TSTypeAliasDeclaration") {
|
|
174
|
-
if (("id" in node && "name" in node.id ? node.id.name : "") === bindableTypeName) {
|
|
175
|
-
const typeAnnotation = "typeAnnotation" in node ? node.typeAnnotation : null;
|
|
176
|
-
if (typeAnnotation && typeAnnotation.type === "TSTypeLiteral") extractPropNames(typeAnnotation, bindableProps);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
} });
|
|
180
|
-
return bindableProps;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Extract prop names from a TSTypeLiteral
|
|
184
|
-
*/ function extractPropNames(typeLiteral, props) {
|
|
185
|
-
if (!("members" in typeLiteral)) return;
|
|
186
|
-
for (const member of typeLiteral.members) if (member.type === "TSPropertySignature") {
|
|
187
|
-
const keyNode = "key" in member ? member.key : null;
|
|
188
|
-
const key = keyNode && "name" in keyNode ? typeof keyNode.name === "string" ? keyNode.name : keyNode.name.name : null;
|
|
189
|
-
if (key) props.add(key);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Extract props from a TSTypeLiteral
|
|
194
|
-
*/ function extractPropsFromType(typeLiteral, source, bindableProps, props) {
|
|
195
|
-
if (!("members" in typeLiteral)) return;
|
|
196
|
-
for (const member of typeLiteral.members) if (member.type === "TSPropertySignature") {
|
|
197
|
-
const prop = extractPropFromSignature(member, source, bindableProps);
|
|
198
|
-
if (prop) props.push(prop);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Extract a single prop from a TSPropertySignature
|
|
203
|
-
*/ function extractPropFromSignature(signature, source, bindableProps) {
|
|
204
|
-
const keyNode = "key" in signature ? signature.key : null;
|
|
205
|
-
const key = keyNode && "name" in keyNode ? typeof keyNode.name === "string" ? keyNode.name : keyNode.name.name : null;
|
|
206
|
-
if (!key) return null;
|
|
207
|
-
if (key.endsWith("$") || key === "onChange$") return null;
|
|
208
|
-
const typeAnnotation = "typeAnnotation" in signature ? signature.typeAnnotation : null;
|
|
209
|
-
if (!typeAnnotation) return null;
|
|
210
|
-
const type = typeAnnotation.typeAnnotation;
|
|
211
|
-
signature.optional;
|
|
212
|
-
const comment = extractComment(signature, source);
|
|
213
|
-
const propType = parseType(type, source);
|
|
214
|
-
return {
|
|
215
|
-
name: key,
|
|
216
|
-
type: propType.type,
|
|
217
|
-
unionValues: propType.unionValues,
|
|
218
|
-
isBindable: bindableProps.has(key),
|
|
219
|
-
defaultValue: propType.defaultValue,
|
|
220
|
-
comment: comment || void 0
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Extract JSDoc comment from a node
|
|
225
|
-
*/ function extractComment(node, source) {
|
|
226
|
-
if (!("leadingComments" in node) || !node.leadingComments || !Array.isArray(node.leadingComments)) return null;
|
|
227
|
-
for (const comment of node.leadingComments) if (comment.type === "CommentBlock" && comment.value.startsWith("*")) return comment.value.split("\n").map((line) => line.replace(/^\s*\*\s?/, "").trim()).filter((line) => line && !line.startsWith("@")).join(" ").trim() || null;
|
|
228
|
-
return null;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Parse a TypeScript type into our PropType format
|
|
232
|
-
*/ function parseType(type, source) {
|
|
233
|
-
if (type.type === "TSUnionType") {
|
|
234
|
-
const unionTypes = "types" in type ? type.types : [];
|
|
235
|
-
const stringLiterals = [];
|
|
236
|
-
for (const unionType of unionTypes) if (unionType.type === "TSLiteralType" && "literal" in unionType) {
|
|
237
|
-
const literal = unionType.literal;
|
|
238
|
-
if (literal && typeof literal === "object" && "type" in literal && "value" in literal) {
|
|
239
|
-
if (literal.type === "StringLiteral") {
|
|
240
|
-
const value = typeof literal.value === "string" ? literal.value : null;
|
|
241
|
-
if (value) stringLiterals.push(value);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
const hasBoolean = unionTypes.some((t) => t.type === "TSBooleanKeyword" || t.type === "TSLiteralType" && "literal" in t && "value" in t.literal && typeof t.literal.value === "boolean");
|
|
246
|
-
if (stringLiterals.length > 0) return {
|
|
247
|
-
type: "union",
|
|
248
|
-
unionValues: stringLiterals
|
|
249
|
-
};
|
|
250
|
-
if (hasBoolean && unionTypes.length === 2) return {
|
|
251
|
-
type: "union",
|
|
252
|
-
unionValues: [
|
|
253
|
-
"false",
|
|
254
|
-
"true",
|
|
255
|
-
...stringLiterals
|
|
256
|
-
]
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
if (type.type === "TSBooleanKeyword") return {
|
|
260
|
-
type: "boolean",
|
|
261
|
-
defaultValue: false
|
|
262
|
-
};
|
|
263
|
-
if (type.type === "TSStringKeyword") return {
|
|
264
|
-
type: "string",
|
|
265
|
-
defaultValue: ""
|
|
266
|
-
};
|
|
267
|
-
if (type.type === "TSNumberKeyword") return {
|
|
268
|
-
type: "number",
|
|
269
|
-
defaultValue: 0
|
|
270
|
-
};
|
|
271
|
-
if (type.type === "TSLiteralType") {
|
|
272
|
-
const literal = "literal" in type ? type.literal : null;
|
|
273
|
-
if (literal && typeof literal === "object" && "type" in literal && "value" in literal) {
|
|
274
|
-
const literalType = literal.type;
|
|
275
|
-
if (literalType === "StringLiteral") return {
|
|
276
|
-
type: "union",
|
|
277
|
-
unionValues: [typeof literal.value === "string" ? literal.value : ""]
|
|
278
|
-
};
|
|
279
|
-
if (literalType === "BooleanLiteral") return {
|
|
280
|
-
type: "boolean",
|
|
281
|
-
defaultValue: typeof literal.value === "boolean" ? literal.value : false
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
return { type: "unknown" };
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Extract component name from file path
|
|
289
|
-
*/ function extractComponentName(filePath, componentsDir) {
|
|
290
|
-
const match = relative(componentsDir, filePath).match(/^([^/]+)\//);
|
|
291
|
-
return match ? match[1] : null;
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Find all component directories
|
|
295
|
-
*/ async function findComponentDirs(componentsDir) {
|
|
296
|
-
const commonComponents = [
|
|
297
|
-
"checkbox",
|
|
298
|
-
"switch",
|
|
299
|
-
"toggle",
|
|
300
|
-
"field",
|
|
301
|
-
"button",
|
|
302
|
-
"input",
|
|
303
|
-
"select",
|
|
304
|
-
"menu",
|
|
305
|
-
"modal",
|
|
306
|
-
"tabs",
|
|
307
|
-
"carousel"
|
|
308
|
-
];
|
|
309
|
-
const components = [];
|
|
310
|
-
for (const name of commonComponents) if (existsSync(join(componentsDir, name))) components.push(name);
|
|
311
|
-
return components;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
//#endregion
|
|
315
|
-
export { componentProps };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { Plugin as VitePlugin } from "vite";
|
|
2
|
-
export type PropType = {
|
|
3
|
-
name: string;
|
|
4
|
-
type: "boolean" | "string" | "number" | "union" | "function" | "unknown";
|
|
5
|
-
unionValues?: string[];
|
|
6
|
-
isBindable: boolean;
|
|
7
|
-
isFunction?: boolean;
|
|
8
|
-
initialValue?: unknown;
|
|
9
|
-
comment?: string;
|
|
10
|
-
};
|
|
11
|
-
export type ComponentPiece = {
|
|
12
|
-
name: string;
|
|
13
|
-
props: PropType[];
|
|
14
|
-
};
|
|
15
|
-
export type ComponentMetadata = {
|
|
16
|
-
componentName: string;
|
|
17
|
-
pieces: ComponentPiece[];
|
|
18
|
-
};
|
|
19
|
-
export type ComponentPropsPluginOptions = {
|
|
20
|
-
componentsDir: string;
|
|
21
|
-
outputDir: string;
|
|
22
|
-
debug?: boolean;
|
|
23
|
-
};
|
|
24
|
-
export declare const componentProps: (options: ComponentPropsPluginOptions) => VitePlugin;
|
|
25
|
-
export declare function generateComponentMetadata(componentName: string, componentsDir: string, outputDir: string, debug: (message: string, ...data: unknown[]) => void): Promise<void>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import type { Ranged, Rule } from "oxlint";
|
|
2
|
-
export interface ValidTestCase {
|
|
3
|
-
/** The code that should not trigger any errors */
|
|
4
|
-
code: string;
|
|
5
|
-
/** Optional filename (defaults to test.tsx) */
|
|
6
|
-
filename?: string;
|
|
7
|
-
/** Optional description for the test case */
|
|
8
|
-
description?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface InvalidTestCase {
|
|
11
|
-
/** The code that should trigger errors */
|
|
12
|
-
code: string;
|
|
13
|
-
/** Expected error messages or count */
|
|
14
|
-
errors: number | string[] | Array<string | {
|
|
15
|
-
message: string;
|
|
16
|
-
line?: number;
|
|
17
|
-
column?: number;
|
|
18
|
-
} | {
|
|
19
|
-
messageId: string;
|
|
20
|
-
data?: Record<string, string>;
|
|
21
|
-
}>;
|
|
22
|
-
/** Optional filename (defaults to test.tsx) */
|
|
23
|
-
filename?: string;
|
|
24
|
-
/** Optional description for the test case */
|
|
25
|
-
description?: string;
|
|
26
|
-
}
|
|
27
|
-
export interface RuleTesterConfig {
|
|
28
|
-
/** Default filename for test cases */
|
|
29
|
-
filename?: string;
|
|
30
|
-
}
|
|
31
|
-
interface ReportedError {
|
|
32
|
-
node: Ranged;
|
|
33
|
-
messageId?: string;
|
|
34
|
-
message?: string;
|
|
35
|
-
data?: Record<string, string>;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* RuleTester - Test utility for oxlint rules
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```ts
|
|
42
|
-
* import { RuleTester } from './rule-tester';
|
|
43
|
-
* import myRule from './my-rule';
|
|
44
|
-
*
|
|
45
|
-
* const ruleTester = new RuleTester();
|
|
46
|
-
*
|
|
47
|
-
* ruleTester.run('my-rule', myRule, {
|
|
48
|
-
* valid: [
|
|
49
|
-
* 'const x = 1;',
|
|
50
|
-
* { code: 'const y = 2;', filename: 'test.ts' }
|
|
51
|
-
* ],
|
|
52
|
-
* invalid: [
|
|
53
|
-
* {
|
|
54
|
-
* code: 'var x = 1;',
|
|
55
|
-
* errors: ['Use const instead of var']
|
|
56
|
-
* }
|
|
57
|
-
* ]
|
|
58
|
-
* });
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
export declare class RuleTester {
|
|
62
|
-
private config;
|
|
63
|
-
constructor(config?: RuleTesterConfig);
|
|
64
|
-
run(ruleName: string, rule: Rule, tests: {
|
|
65
|
-
valid?: Array<string | ValidTestCase>;
|
|
66
|
-
invalid?: Array<string | InvalidTestCase>;
|
|
67
|
-
}): void;
|
|
68
|
-
private runRule;
|
|
69
|
-
private createMockContext;
|
|
70
|
-
private normalizeValidTestCase;
|
|
71
|
-
private formatErrorMessage;
|
|
72
|
-
private validateStringArrayErrors;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Creates explicit test helpers for better DX
|
|
76
|
-
* Inspired by eslint-vitest-rule-tester but with our intuitive error format
|
|
77
|
-
*/
|
|
78
|
-
export declare function createRuleTester(options: {
|
|
79
|
-
name: string;
|
|
80
|
-
rule: Rule;
|
|
81
|
-
filename?: string;
|
|
82
|
-
}): {
|
|
83
|
-
valid: (code: string | ValidTestCase) => void;
|
|
84
|
-
invalid: (testCase: string | {
|
|
85
|
-
code: string;
|
|
86
|
-
errors: number | string[] | Array<string | {
|
|
87
|
-
message: string;
|
|
88
|
-
line?: number;
|
|
89
|
-
column?: number;
|
|
90
|
-
} | {
|
|
91
|
-
messageId: string;
|
|
92
|
-
data?: Record<string, string>;
|
|
93
|
-
}>;
|
|
94
|
-
filename?: string;
|
|
95
|
-
output?: string;
|
|
96
|
-
}) => {
|
|
97
|
-
errors: ReportedError[];
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rolldown plugin to handle CSS imports with ?inline query parameter
|
|
3
|
-
* Mimics Vite's ?inline behavior by returning CSS content as a string
|
|
4
|
-
*/
|
|
5
|
-
interface PluginContext {
|
|
6
|
-
error: (msg: string) => void;
|
|
7
|
-
}
|
|
8
|
-
export declare function inlineCssPlugin(): {
|
|
9
|
-
name: string;
|
|
10
|
-
resolveId(source: string, _importer?: string, _options?: unknown): null;
|
|
11
|
-
load(this: PluginContext, id: string): {
|
|
12
|
-
code: string;
|
|
13
|
-
map: null;
|
|
14
|
-
} | null;
|
|
15
|
-
};
|
|
16
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This plugin transforms hooks and patterns used in our libraries to improve developer experience.
|
|
3
|
-
*/
|
|
4
|
-
export declare function qdsTransformPlugin(): {
|
|
5
|
-
name: string;
|
|
6
|
-
enforce: "pre";
|
|
7
|
-
transform(code: string, id: string): {
|
|
8
|
-
code: string;
|
|
9
|
-
map: import("magic-string").SourceMap;
|
|
10
|
-
} | null;
|
|
11
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { OutputOptions } from "rolldown";
|
|
2
|
-
/**
|
|
3
|
-
* Plugin to ensure .qwik.mjs extension and correct output dir
|
|
4
|
-
* Runs after qwikRollup to override its settings
|
|
5
|
-
*/
|
|
6
|
-
export declare function qwikRolldown(): {
|
|
7
|
-
name: string;
|
|
8
|
-
outputOptions(outputOpts: OutputOptions): OutputOptions;
|
|
9
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
export { sanitizeIconName, generateIconTypes, generateRuntimeProxies };
|
|
3
|
-
import { discoverAllIconifyCollections, toPascalCase } from "../../utils/icons/naming.ts";
|
|
4
|
-
export { discoverAllIconifyCollections, toPascalCase };
|
|
5
|
-
/**
|
|
6
|
-
* Sanitize icon name (handle leading digits, etc.)
|
|
7
|
-
* @param name - Icon name in kebab-case
|
|
8
|
-
* @returns Sanitized PascalCase name
|
|
9
|
-
*/
|
|
10
|
-
declare function sanitizeIconName(name: string): string;
|
|
11
|
-
/**
|
|
12
|
-
* Generate type declarations for all icons in configured packs
|
|
13
|
-
* @param packs - Icon packs to generate types for (defaults to all discovered packs)
|
|
14
|
-
*/
|
|
15
|
-
declare function generateIconTypes(packs?: Record<string, {
|
|
16
|
-
iconifyPrefix: string;
|
|
17
|
-
}>): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* Generate runtime proxy exports for all icon packs
|
|
20
|
-
* @param outputPath - Path to write the generated file
|
|
21
|
-
* @param packs - Icon packs to generate proxies for (defaults to all discovered packs)
|
|
22
|
-
*/
|
|
23
|
-
declare function generateRuntimeProxies(outputPath?: string, packs?: Record<string, {
|
|
24
|
-
iconifyPrefix: string;
|
|
25
|
-
}>): Promise<void>;
|
package/lib-types/src/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type { AsChildTypes } from "../vite";
|
package/lib-types/src/vite.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type { AsChildTypes } from "../vite";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This plugin transforms hooks and patterns used in our libraries to improve developer experience.
|
|
3
|
-
*/
|
|
4
|
-
export declare function qdsTransformPlugin(): {
|
|
5
|
-
name: string;
|
|
6
|
-
enforce: "pre";
|
|
7
|
-
transform(code: string, id: string): {
|
|
8
|
-
code: string;
|
|
9
|
-
map: import("magic-string").SourceMap;
|
|
10
|
-
} | null;
|
|
11
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Plugin as VitePlugin } from "vite";
|
|
2
|
-
export type AsChildTypes = {
|
|
3
|
-
asChild?: true;
|
|
4
|
-
};
|
|
5
|
-
export type AsChildPluginOptions = {
|
|
6
|
-
debug?: boolean;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Vite plugin that transforms JSX elements with asChild prop by moving child element props to the parent
|
|
10
|
-
* @param options - Plugin configuration options
|
|
11
|
-
* @returns Vite plugin object
|
|
12
|
-
*/
|
|
13
|
-
export declare const asChild: (options?: AsChildPluginOptions) => VitePlugin;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Plugin as VitePlugin } from "vite";
|
|
2
|
-
export type PacksMap = Record<string, {
|
|
3
|
-
iconifyPrefix: string;
|
|
4
|
-
sanitizeIcon?: (pascal: string) => string;
|
|
5
|
-
}>;
|
|
6
|
-
export type IconsPluginOptions = {
|
|
7
|
-
debug?: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* The sources to scan for imports. By default this includes QDS, you can also add your own when creating library wrappers.
|
|
10
|
-
*/
|
|
11
|
-
importSources?: string[];
|
|
12
|
-
packs?: PacksMap;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Vite plugin that transforms icon JSX elements to direct <svg /> calls
|
|
16
|
-
* @param options - Plugin configuration options
|
|
17
|
-
* @returns Vite plugin object
|
|
18
|
-
*/
|
|
19
|
-
export declare const icons: (options?: IconsPluginOptions) => VitePlugin;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Node } from "@oxc-project/types";
|
|
2
|
-
export declare function getNodeText(node: Node, source: string): string;
|
|
3
|
-
export declare function isCallExpressionWithName(node: Node, source: string, name: string): boolean;
|
|
4
|
-
export declare function isIdentifierWithName(node: Node, source: string, name: string): boolean;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ImportDeclaration, Node } from "@oxc-project/types";
|
|
2
|
-
import type MagicString from "magic-string";
|
|
3
|
-
import type { parseSync } from "oxc-parser";
|
|
4
|
-
export declare function getImportSource(importNode: ImportDeclaration, source: string): string;
|
|
5
|
-
export declare function findImportBySource(ast: ReturnType<typeof parseSync>, source: string, importSource: string): Node | null;
|
|
6
|
-
/**
|
|
7
|
-
* Checks if a type import specifier exists in an import declaration
|
|
8
|
-
*/
|
|
9
|
-
export declare function hasImportSpecifier(importDecl: ImportDeclaration, specifierName: string): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Injects a type import specifier into an existing import or creates a new import statement
|
|
12
|
-
*/
|
|
13
|
-
export declare function injectTypeImport(options: {
|
|
14
|
-
ast: ReturnType<typeof parseSync>;
|
|
15
|
-
magicString: MagicString;
|
|
16
|
-
importSource: string;
|
|
17
|
-
specifierName: string;
|
|
18
|
-
existingImportNode?: Node | null;
|
|
19
|
-
}): void;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Node } from "@oxc-project/types";
|
|
2
|
-
/**
|
|
3
|
-
* Checks if a node is a Render JSX element
|
|
4
|
-
*/
|
|
5
|
-
export declare function isRenderElement(node: Node, code: string): boolean;
|
|
6
|
-
/**
|
|
7
|
-
* Checks if a callback function returns a Render component
|
|
8
|
-
*/
|
|
9
|
-
export declare function returnsRenderComponent(callback: Node, code: string): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Detects if the source code uses the Render component pattern within a component$
|
|
12
|
-
*/
|
|
13
|
-
export declare function detectsRenderComponentUsage(sourceCode: string): boolean;
|
package/lib-types/utils/fs.d.ts
DELETED