@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,14 +1,15 @@
|
|
|
1
1
|
import { extractFromElement, getLineNumber, isJSXElement, isJSXExpressionContainer, isJSXText } from "../utils/icons/ast/jsx.qwik.mjs";
|
|
2
2
|
import { handleExpression } from "../utils/icons/ast/expressions.qwik.mjs";
|
|
3
|
+
import { anyOf, createRegExp, exactly } from "magic-regexp";
|
|
3
4
|
import MagicString from "magic-string";
|
|
4
5
|
import { parseSync } from "oxc-parser";
|
|
5
6
|
import { walk } from "oxc-walker";
|
|
6
7
|
|
|
7
|
-
//#region
|
|
8
|
+
//#region rolldown/as-child.ts
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
+
* Rolldown plugin that transforms JSX elements with asChild prop by moving child element props to the parent
|
|
10
11
|
* @param options - Plugin configuration options
|
|
11
|
-
* @returns
|
|
12
|
+
* @returns Rolldown-compatible plugin object
|
|
12
13
|
*/ const asChild = (options = {}) => {
|
|
13
14
|
const { debug: isDebugMode = false } = options;
|
|
14
15
|
/**
|
|
@@ -21,21 +22,23 @@ import { walk } from "oxc-walker";
|
|
|
21
22
|
return {
|
|
22
23
|
name: "vite-plugin-as-child",
|
|
23
24
|
enforce: "pre",
|
|
24
|
-
transform
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
transform: {
|
|
26
|
+
filter: { id: createRegExp(exactly(".").and(anyOf("tsx", "jsx")).at.lineEnd()) },
|
|
27
|
+
handler(code, id) {
|
|
28
|
+
debug(`🔧 asChild plugin processing: ${id}`);
|
|
29
|
+
const parsed = parseSync(id, code);
|
|
30
|
+
if (parsed.errors.length > 0) return null;
|
|
31
|
+
const ast = parsed.program;
|
|
32
|
+
const s = new MagicString(code);
|
|
33
|
+
walk(ast, { enter(node) {
|
|
34
|
+
if (isJSXElement(node) && hasAsChild(node.openingElement)) processAsChild(node, s, code);
|
|
35
|
+
} });
|
|
36
|
+
if (s.hasChanged()) return {
|
|
37
|
+
code: s.toString(),
|
|
38
|
+
map: s.generateMap({ hires: true })
|
|
39
|
+
};
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
39
42
|
}
|
|
40
43
|
};
|
|
41
44
|
/**
|
|
@@ -2,13 +2,14 @@ import { CollectionLoader } from "../utils/icons/collections/loader.qwik.mjs";
|
|
|
2
2
|
import { resolveImportAliases } from "../utils/icons/import-resolver.qwik.mjs";
|
|
3
3
|
import { transformMDXFile } from "../utils/icons/transform/mdx.qwik.mjs";
|
|
4
4
|
import { transformTSXFile } from "../utils/icons/transform/tsx.qwik.mjs";
|
|
5
|
+
import { anyOf, createRegExp, exactly } from "magic-regexp";
|
|
5
6
|
import { parseSync } from "oxc-parser";
|
|
6
7
|
|
|
7
|
-
//#region
|
|
8
|
+
//#region rolldown/icons.ts
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
+
* Rolldown plugin that transforms icon JSX elements to direct <svg /> calls
|
|
10
11
|
* @param options - Plugin configuration options
|
|
11
|
-
* @returns
|
|
12
|
+
* @returns Rolldown-compatible plugin object
|
|
12
13
|
*/ const icons = (options = {}) => {
|
|
13
14
|
const importSources = options.importSources ?? ["@qds.dev/ui"];
|
|
14
15
|
const isDebugMode = !!options.debug;
|
|
@@ -36,6 +37,9 @@ import { parseSync } from "oxc-parser";
|
|
|
36
37
|
return null;
|
|
37
38
|
}
|
|
38
39
|
}
|
|
40
|
+
const isTSXJSXOrMDX = createRegExp(exactly(".").and(anyOf("tsx", "jsx", "mdx")).at.lineEnd());
|
|
41
|
+
const isVirtualIconsImport = createRegExp(exactly("virtual:icons/").at.lineStart());
|
|
42
|
+
const isVirtualIconsModule = createRegExp(exactly(String.fromCharCode(0)).and("virtual:icons/"));
|
|
39
43
|
return {
|
|
40
44
|
name: "vite-plugin-qds-icons",
|
|
41
45
|
enforce: "pre",
|
|
@@ -44,54 +48,61 @@ import { parseSync } from "oxc-parser";
|
|
|
44
48
|
collectionLoader.discoverCollections();
|
|
45
49
|
debug(`Plugin ready - ${collectionLoader.getAvailableCollections().size} collections available on-demand`);
|
|
46
50
|
},
|
|
47
|
-
transform
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
transform: {
|
|
52
|
+
filter: { id: isTSXJSXOrMDX },
|
|
53
|
+
handler(code, id) {
|
|
54
|
+
if (collectionLoader.getAvailableCollections().size === 0) collectionLoader.discoverCollections();
|
|
55
|
+
if (id.endsWith(".mdx")) return transformMDXFile(code, id, importSources, collectionLoader.getAvailableCollections(), collectionNames, options.packs, debug);
|
|
56
|
+
debug(`[TRANSFORM] Starting transformation for ${id}`);
|
|
57
|
+
try {
|
|
58
|
+
const ast = parseAndValidateFile(code, id);
|
|
59
|
+
if (!ast) {
|
|
60
|
+
debug(`[TRANSFORM] Failed to parse ${id}`);
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const aliasToPack = resolveImportAliases(ast, importSources, collectionLoader.getAvailableCollections(), collectionNames, options.packs, debug);
|
|
64
|
+
if (aliasToPack.size === 0) {
|
|
65
|
+
debug(`[TRANSFORM] No icon imports found in ${id}`);
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return transformTSXFile(code, id, ast, aliasToPack, collectionNames, collectionLoader.getAvailableCollections(), options.packs, debug);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
debug(`[TRANSFORM] Error during transformation of ${id}:`, error);
|
|
61
71
|
return null;
|
|
62
72
|
}
|
|
63
|
-
return transformTSXFile(code, id, ast, aliasToPack, collectionNames, collectionLoader.getAvailableCollections(), options.packs, debug);
|
|
64
|
-
} catch (error) {
|
|
65
|
-
debug(`[TRANSFORM] Error during transformation of ${id}:`, error);
|
|
66
|
-
return null;
|
|
67
73
|
}
|
|
68
74
|
},
|
|
69
|
-
resolveId
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
async load(id) {
|
|
74
|
-
if (!id.startsWith("\0virtual:icons/")) return null;
|
|
75
|
-
const virtualPath = id.slice(1);
|
|
76
|
-
const parts = virtualPath.split("/");
|
|
77
|
-
const prefix = parts[1];
|
|
78
|
-
const name = parts[2];
|
|
79
|
-
if (!prefix || !name) {
|
|
80
|
-
debug(`Invalid virtual icon path: ${virtualPath}`);
|
|
75
|
+
resolveId: {
|
|
76
|
+
filter: { id: isVirtualIconsImport },
|
|
77
|
+
handler(source) {
|
|
78
|
+
if (source.startsWith("virtual:icons/")) return `\0${source}`;
|
|
81
79
|
return null;
|
|
82
80
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
},
|
|
82
|
+
load: {
|
|
83
|
+
filter: { id: isVirtualIconsModule },
|
|
84
|
+
async handler(id) {
|
|
85
|
+
const virtualPath = id.slice(1);
|
|
86
|
+
const parts = virtualPath.split("/");
|
|
87
|
+
const prefix = parts[1];
|
|
88
|
+
const name = parts[2];
|
|
89
|
+
if (!prefix || !name) {
|
|
90
|
+
debug(`Invalid virtual icon path: ${virtualPath}`);
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
const iconData = await collectionLoader.loadIconDataLazy(prefix, name);
|
|
95
|
+
if (!iconData) {
|
|
96
|
+
debug(`Failed to load icon data for ${prefix}:${name}`);
|
|
97
|
+
return { code: `export default '<path d="M12 2L2 7l10 5 10-5z"/><path d="M2 17l10 5 10-5M2 12l10 5 10-5"/>';\n` };
|
|
98
|
+
}
|
|
99
|
+
const code = `export default \`${iconData.body}\`;`;
|
|
100
|
+
debug(`Generated virtual module for ${prefix}:${name}`);
|
|
101
|
+
return { code };
|
|
102
|
+
} catch (error) {
|
|
103
|
+
debug(`Error loading virtual module ${virtualPath}:`, error);
|
|
104
|
+
return { code: `export default '<circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/>';\n` };
|
|
88
105
|
}
|
|
89
|
-
const code = `export default \`${iconData.body}\`;`;
|
|
90
|
-
debug(`Generated virtual module for ${prefix}:${name}`);
|
|
91
|
-
return { code };
|
|
92
|
-
} catch (error) {
|
|
93
|
-
debug(`Error loading virtual module ${virtualPath}:`, error);
|
|
94
|
-
return { code: `export default '<circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/>';\n` };
|
|
95
106
|
}
|
|
96
107
|
},
|
|
97
108
|
async handleHotUpdate(ctx) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { asChild } from "./as-child.qwik.mjs";
|
|
2
|
+
import { icons } from "./icons.qwik.mjs";
|
|
1
3
|
import { inlineCssPlugin } from "./inline-css.qwik.mjs";
|
|
2
|
-
import { qdsTransformPlugin } from "./qds-transform.qwik.mjs";
|
|
3
4
|
import { qwikRolldown } from "./qwik-rolldown.qwik.mjs";
|
|
4
5
|
|
|
5
|
-
export {
|
|
6
|
+
export { asChild, icons, inlineCssPlugin, qwikRolldown };
|
|
@@ -1,29 +1,37 @@
|
|
|
1
|
+
import { anyOf, charNotIn, createRegExp, exactly, oneOrMore } from "magic-regexp";
|
|
1
2
|
import { readFileSync } from "node:fs";
|
|
2
3
|
|
|
3
4
|
//#region rolldown/inline-css.ts
|
|
4
5
|
function inlineCssPlugin() {
|
|
6
|
+
const isCSSFile = createRegExp(exactly(".").and("css").and(anyOf(exactly("").at.lineEnd(), exactly("?").and(oneOrMore(charNotIn("\n"))))));
|
|
5
7
|
return {
|
|
6
8
|
name: "rolldown-plugin-inline-css",
|
|
7
|
-
resolveId
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
resolveId: {
|
|
10
|
+
filter: { id: isCSSFile },
|
|
11
|
+
handler(source, _importer, _options) {
|
|
12
|
+
if (typeof source === "string" && source.includes("?inline")) return null;
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
10
15
|
},
|
|
11
|
-
load
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
load: {
|
|
17
|
+
filter: { id: isCSSFile },
|
|
18
|
+
handler(id) {
|
|
19
|
+
if (typeof id === "string" && id.includes("?inline")) {
|
|
20
|
+
const filePath = id.split("?")[0];
|
|
21
|
+
if (!filePath) return null;
|
|
22
|
+
try {
|
|
23
|
+
const cssContent = readFileSync(filePath, "utf-8");
|
|
24
|
+
return {
|
|
25
|
+
code: `export default ${JSON.stringify(cssContent)};`,
|
|
26
|
+
map: null
|
|
27
|
+
};
|
|
28
|
+
} catch (error) {
|
|
29
|
+
this.error(`Failed to read CSS file: ${filePath}\n${String(error)}`);
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
24
32
|
}
|
|
33
|
+
return null;
|
|
25
34
|
}
|
|
26
|
-
return null;
|
|
27
35
|
}
|
|
28
36
|
};
|
|
29
37
|
}
|
package/lib/vite/index.qwik.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { asChild } from "
|
|
2
|
-
import { icons } from "
|
|
1
|
+
import { asChild } from "../rolldown/as-child.qwik.mjs";
|
|
2
|
+
import { icons } from "../rolldown/icons.qwik.mjs";
|
|
3
|
+
import "../rolldown/index.qwik.mjs";
|
|
4
|
+
import { minifyContentPlugin } from "./minify-content.qwik.mjs";
|
|
3
5
|
|
|
4
|
-
export { asChild, icons };
|
|
6
|
+
export { asChild, icons, minifyContentPlugin };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { char, createRegExp, exactly, oneOrMore } from "magic-regexp";
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { resolve, sep } from "node:path";
|
|
4
|
+
import { minifySync } from "oxc-minify";
|
|
5
|
+
import { transform } from "oxc-transform";
|
|
6
|
+
|
|
7
|
+
//#region vite/minify-content.ts
|
|
8
|
+
/**
|
|
9
|
+
* This plugin strips types, then minifies the contents of files with the ".script." extension. We watch the components library files and update the injected scripts when the contents change. Useful for dynamic client-only code without waking up the Qwik runtime.
|
|
10
|
+
*/ function minifyContentPlugin(options) {
|
|
11
|
+
const scriptsMap = {};
|
|
12
|
+
const outputFileName = options?.outputFileName || "injected-scripts.ts";
|
|
13
|
+
const outputTsPath = resolve(options?.outputDir || process.cwd(), outputFileName);
|
|
14
|
+
const partString = `.${options?.part || "script"}.`;
|
|
15
|
+
const scriptExtension = createRegExp(exactly(partString).and(oneOrMore(char)).at.lineEnd());
|
|
16
|
+
const processMap = async (id, code) => {
|
|
17
|
+
const basename = id.split(sep).join("/").split("/").pop() || "";
|
|
18
|
+
if (!scriptExtension.test(basename)) return false;
|
|
19
|
+
const [name] = basename.split(partString);
|
|
20
|
+
if (!name) return false;
|
|
21
|
+
try {
|
|
22
|
+
scriptsMap[name] = minifySync(id, (await transform(id, code, { typescript: { onlyRemoveTypeImports: false } })).code, {
|
|
23
|
+
compress: true,
|
|
24
|
+
mangle: { toplevel: true }
|
|
25
|
+
}).code;
|
|
26
|
+
const newFileContent = `export const INJECTED_SCRIPTS = ${JSON.stringify(scriptsMap, null, 2)} as const;`;
|
|
27
|
+
let shouldWrite = true;
|
|
28
|
+
if (existsSync(outputTsPath)) {
|
|
29
|
+
if (readFileSync(outputTsPath, "utf-8") === newFileContent) shouldWrite = false;
|
|
30
|
+
}
|
|
31
|
+
if (shouldWrite) writeFileSync(outputTsPath, newFileContent, "utf-8");
|
|
32
|
+
return true;
|
|
33
|
+
} catch (err) {
|
|
34
|
+
console.error(`[script-injector] Error processing ${id}:`, err);
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
if (!existsSync(outputTsPath)) writeFileSync(outputTsPath, "export const INJECTED_SCRIPTS = {} as const;", "utf-8");
|
|
39
|
+
return {
|
|
40
|
+
name: "vite-plugin-script-injector",
|
|
41
|
+
enforce: "pre",
|
|
42
|
+
async transform(code, id) {
|
|
43
|
+
if (!id.includes(partString)) return null;
|
|
44
|
+
if (await processMap(id, code)) return {
|
|
45
|
+
code: "export default null;",
|
|
46
|
+
map: null
|
|
47
|
+
};
|
|
48
|
+
return null;
|
|
49
|
+
},
|
|
50
|
+
async handleHotUpdate({ file, read }) {
|
|
51
|
+
if (file.includes(partString)) await processMap(file, await read());
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { minifyContentPlugin };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type AsChildTypes = {
|
|
2
|
+
asChild?: true;
|
|
3
|
+
};
|
|
4
|
+
export type AsChildPluginOptions = {
|
|
5
|
+
debug?: boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Rolldown plugin that transforms JSX elements with asChild prop by moving child element props to the parent
|
|
9
|
+
* @param options - Plugin configuration options
|
|
10
|
+
* @returns Rolldown-compatible plugin object
|
|
11
|
+
*/
|
|
12
|
+
export declare const asChild: (options?: AsChildPluginOptions) => {
|
|
13
|
+
name: string;
|
|
14
|
+
enforce: "pre";
|
|
15
|
+
transform: {
|
|
16
|
+
filter: {
|
|
17
|
+
id: import("magic-regexp").MagicRegExp<"/\\.(?:tsx|jsx)$/", never, [], never>;
|
|
18
|
+
};
|
|
19
|
+
handler(code: string, id: string): {
|
|
20
|
+
code: string;
|
|
21
|
+
map: import("magic-string").SourceMap;
|
|
22
|
+
} | null;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { HmrContext } 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
|
+
* Rolldown plugin that transforms icon JSX elements to direct <svg /> calls
|
|
16
|
+
* @param options - Plugin configuration options
|
|
17
|
+
* @returns Rolldown-compatible plugin object
|
|
18
|
+
*/
|
|
19
|
+
export declare const icons: (options?: IconsPluginOptions) => {
|
|
20
|
+
name: string;
|
|
21
|
+
enforce: "pre";
|
|
22
|
+
configResolved(): void;
|
|
23
|
+
transform: {
|
|
24
|
+
filter: {
|
|
25
|
+
id: import("magic-regexp").MagicRegExp<"/\\.(?:tsx|jsx|mdx)$/", never, [], never>;
|
|
26
|
+
};
|
|
27
|
+
handler(code: string, id: string): {
|
|
28
|
+
code: string;
|
|
29
|
+
map: import("magic-string").SourceMap;
|
|
30
|
+
} | null;
|
|
31
|
+
};
|
|
32
|
+
resolveId: {
|
|
33
|
+
filter: {
|
|
34
|
+
id: import("magic-regexp").MagicRegExp<"/^virtual:icons\\//", never, [], never>;
|
|
35
|
+
};
|
|
36
|
+
handler(source: string): string | null;
|
|
37
|
+
};
|
|
38
|
+
load: {
|
|
39
|
+
filter: {
|
|
40
|
+
id: import("magic-regexp").MagicRegExp<`/${string}virtual:icons\\//`, never, [], never>;
|
|
41
|
+
};
|
|
42
|
+
handler(id: string): Promise<{
|
|
43
|
+
code: string;
|
|
44
|
+
} | null>;
|
|
45
|
+
};
|
|
46
|
+
handleHotUpdate(ctx: HmrContext): Promise<never[] | undefined>;
|
|
47
|
+
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export type { AsChildPluginOptions, AsChildTypes } from "./as-child";
|
|
2
|
+
export { asChild } from "./as-child";
|
|
3
|
+
export type { IconsPluginOptions, PacksMap } from "./icons";
|
|
4
|
+
export { icons } from "./icons";
|
|
1
5
|
export { inlineCssPlugin } from "./inline-css";
|
|
2
|
-
export { qdsTransformPlugin } from "./qds-transform";
|
|
3
6
|
export { qwikRolldown } from "./qwik-rolldown";
|
|
@@ -7,10 +7,20 @@ interface PluginContext {
|
|
|
7
7
|
}
|
|
8
8
|
export declare function inlineCssPlugin(): {
|
|
9
9
|
name: string;
|
|
10
|
-
resolveId
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
resolveId: {
|
|
11
|
+
filter: {
|
|
12
|
+
id: import("magic-regexp").MagicRegExp<"/\\.css(?:$|\\?(?:[^\n])+)/", never, any[], never>;
|
|
13
|
+
};
|
|
14
|
+
handler(source: string, _importer?: string, _options?: unknown): null;
|
|
15
|
+
};
|
|
16
|
+
load: {
|
|
17
|
+
filter: {
|
|
18
|
+
id: import("magic-regexp").MagicRegExp<"/\\.css(?:$|\\?(?:[^\n])+)/", never, any[], never>;
|
|
19
|
+
};
|
|
20
|
+
handler(this: PluginContext, id: string): {
|
|
21
|
+
code: string;
|
|
22
|
+
map: null;
|
|
23
|
+
} | null;
|
|
24
|
+
};
|
|
15
25
|
};
|
|
16
26
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Program } from "@oxc-project/types";
|
|
2
|
-
import type { PacksMap } from "../../
|
|
2
|
+
import type { PacksMap } from "../../rolldown/icons";
|
|
3
3
|
/**
|
|
4
4
|
* Map an imported name to a pack and collection name
|
|
5
5
|
* @param importedName - The imported name from the import specifier
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import MagicString from "magic-string";
|
|
2
|
-
import type { PacksMap } from "../../../
|
|
2
|
+
import type { PacksMap } from "../../../rolldown/icons";
|
|
3
3
|
import type { MDXJSXElement } from "../types/mdx-ast";
|
|
4
4
|
/**
|
|
5
5
|
* Extract attributes from MDX JSX node, handling title and description specially
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { JSXElement, Program } from "@oxc-project/types";
|
|
2
2
|
import MagicString from "magic-string";
|
|
3
|
-
import type { PacksMap } from "../../../
|
|
3
|
+
import type { PacksMap } from "../../../rolldown/icons";
|
|
4
4
|
import { type TransformContext } from "./shared";
|
|
5
5
|
/**
|
|
6
6
|
* Check if a JSX element is an icon element based on its structure
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export type { AsChildPluginOptions, AsChildTypes, IconsPluginOptions, PacksMap } from "../rolldown";
|
|
2
|
+
export { asChild, icons } from "../rolldown";
|
|
3
|
+
export { minifyContentPlugin } from "./minify-content";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
/**
|
|
3
|
+
* This plugin strips types, then minifies the contents of files with the ".script." extension. We watch the components library files and update the injected scripts when the contents change. Useful for dynamic client-only code without waking up the Qwik runtime.
|
|
4
|
+
*/
|
|
5
|
+
export declare function minifyContentPlugin(options?: {
|
|
6
|
+
outputDir?: string;
|
|
7
|
+
part?: string;
|
|
8
|
+
outputFileName?: string;
|
|
9
|
+
}): Plugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qds.dev/tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Tools and utilities for Qwik Design System",
|
|
6
6
|
"type": "module",
|
|
@@ -34,14 +34,17 @@
|
|
|
34
34
|
"@iconify/types": "^2",
|
|
35
35
|
"magic-string": "^0.30.17",
|
|
36
36
|
"rolldown": "1.0.0-beta.45",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
37
|
+
"typescript": "5.4.5",
|
|
38
|
+
"vite": "^7.0.6"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@iconify/utils": "^3.0.1",
|
|
42
41
|
"@iconify/json": "^2.2.382",
|
|
43
|
-
"@
|
|
44
|
-
"oxc-
|
|
42
|
+
"@iconify/utils": "^3.0.1",
|
|
43
|
+
"@oxc-project/types": "^0.102.0",
|
|
44
|
+
"magic-regexp": "^0.10.0",
|
|
45
|
+
"oxc-minify": "^0.102.0",
|
|
46
|
+
"oxc-parser": "^0.102.0",
|
|
47
|
+
"oxc-transform": "^0.102.0",
|
|
45
48
|
"oxc-walker": "^0.5.2",
|
|
46
49
|
"remark": "^15.0.1",
|
|
47
50
|
"remark-mdx": "^3.1.1"
|