@qds.dev/tools 0.11.1 → 0.13.0

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.
Files changed (85) hide show
  1. package/lib/linter/qds-internal.d.ts +210 -0
  2. package/lib/linter/qds.d.ts +59 -0
  3. package/{lib-types/tools → lib}/linter/rule-tester.d.ts +23 -1
  4. package/{lib-types/tools → lib}/playground/prop-extraction.d.ts +6 -1
  5. package/lib/playground/prop-extraction.qwik.mjs +68 -9
  6. package/lib/playground/scenario-injection.qwik.mjs +41 -8
  7. package/lib/rolldown/as-child.d.ts +16 -0
  8. package/lib/rolldown/as-child.qwik.mjs +52 -91
  9. package/lib/rolldown/icons.d.ts +21 -0
  10. package/{lib-types/tools → lib}/rolldown/index.d.ts +4 -2
  11. package/lib/rolldown/index.qwik.mjs +3 -3
  12. package/lib/rolldown/inject-component-types.d.ts +2 -0
  13. package/lib/rolldown/inject-component-types.qwik.mjs +138 -0
  14. package/lib/rolldown/inline-asset.qwik.mjs +6 -6
  15. package/lib/rolldown/inline-css.d.ts +2 -0
  16. package/lib/rolldown/inline-css.qwik.mjs +1 -1
  17. package/lib/rolldown/qds-types.d.ts +41 -0
  18. package/lib/rolldown/qds.d.ts +5 -0
  19. package/lib/rolldown/qds.qwik.mjs +147 -0
  20. package/lib/rolldown/qwik-rolldown.d.ts +6 -0
  21. package/lib/rolldown/ui-types.d.ts +42 -0
  22. package/lib/rolldown/ui.d.ts +12 -0
  23. package/lib/rolldown/ui.qwik.mjs +445 -0
  24. package/lib/utils/icons/naming.unit.d.ts +1 -0
  25. package/{lib-types/tools → lib}/utils/icons/transform/mdx.d.ts +3 -11
  26. package/lib/utils/icons/transform/mdx.qwik.mjs +14 -20
  27. package/{lib-types/tools → lib}/utils/icons/transform/tsx.d.ts +3 -12
  28. package/lib/utils/icons/transform/tsx.qwik.mjs +28 -37
  29. package/lib/utils/index.qwik.mjs +5 -5
  30. package/{lib-types/tools → lib}/utils/transform-dts.d.ts +4 -3
  31. package/lib/utils/transform-dts.qwik.mjs +18 -23
  32. package/lib/utils/transform-dts.unit.d.ts +1 -0
  33. package/{lib-types/tools → lib}/vite/index.d.ts +2 -2
  34. package/lib/vite/index.qwik.mjs +2 -3
  35. package/lib/vite/minify-content.qwik.mjs +1 -1
  36. package/lib/vite/minify-content.unit.d.ts +1 -0
  37. package/linter/qds-internal.ts +707 -0
  38. package/linter/qds-internal.unit.ts +399 -0
  39. package/linter/qds.ts +300 -0
  40. package/linter/qds.unit.ts +158 -0
  41. package/linter/rule-tester.ts +395 -0
  42. package/package.json +17 -18
  43. package/lib/rolldown/icons.qwik.mjs +0 -112
  44. package/lib-types/components/src/icons-runtime.d.ts +0 -223
  45. package/lib-types/tools/linter/qds-internal.d.ts +0 -7
  46. package/lib-types/tools/rolldown/as-child.d.ts +0 -24
  47. package/lib-types/tools/rolldown/icons.d.ts +0 -45
  48. package/lib-types/tools/rolldown/inline-css.d.ts +0 -26
  49. package/lib-types/tools/rolldown/qwik-rolldown.d.ts +0 -9
  50. /package/{lib-types/tools → lib}/linter/qds-internal.unit.d.ts +0 -0
  51. /package/{lib-types/tools/playground/generate-metadata.d.ts → lib/linter/qds.unit.d.ts} +0 -0
  52. /package/{lib-types/tools/playground/generate-metadata.unit.d.ts → lib/playground/generate-metadata.d.ts} +0 -0
  53. /package/{lib-types/tools/playground/prop-extraction.unit.d.ts → lib/playground/generate-metadata.unit.d.ts} +0 -0
  54. /package/{lib-types/tools → lib}/playground/index.d.ts +0 -0
  55. /package/{lib-types/tools/playground/scenario-injection.unit.d.ts → lib/playground/prop-extraction.unit.d.ts} +0 -0
  56. /package/{lib-types/tools → lib}/playground/scenario-injection.d.ts +0 -0
  57. /package/{lib-types/tools/rolldown/as-child.unit.d.ts → lib/playground/scenario-injection.unit.d.ts} +0 -0
  58. /package/{lib-types/tools/rolldown/icons.unit.d.ts → lib/rolldown/as-child.unit.d.ts} +0 -0
  59. /package/{lib-types/tools/rolldown/inline-asset.unit.d.ts → lib/rolldown/icons.unit.d.ts} +0 -0
  60. /package/{lib-types/tools/src/generate/icon-types.unit.d.ts → lib/rolldown/inject-component-types.unit.d.ts} +0 -0
  61. /package/{lib-types/tools → lib}/rolldown/inline-asset.d.ts +0 -0
  62. /package/{lib-types/tools/utils/icons/ast/expressions.unit.d.ts → lib/rolldown/inline-asset.unit.d.ts} +0 -0
  63. /package/{lib-types/tools/utils/icons/ast/jsx.unit.d.ts → lib/rolldown/qds.unit.d.ts} +0 -0
  64. /package/{lib-types/tools/utils/icons/naming.unit.d.ts → lib/rolldown/ui.unit.d.ts} +0 -0
  65. /package/{lib-types/tools → lib}/src/generate/icon-types.d.ts +0 -0
  66. /package/{lib-types/tools → lib}/src/index.d.ts +0 -0
  67. /package/{lib-types/tools → lib}/src/vite.d.ts +0 -0
  68. /package/{lib-types/tools → lib}/utils/ast/core.d.ts +0 -0
  69. /package/{lib-types/tools → lib}/utils/ast/imports.d.ts +0 -0
  70. /package/{lib-types/tools → lib}/utils/ast/jsx-helpers.d.ts +0 -0
  71. /package/{lib-types/tools → lib}/utils/ast/qwik.d.ts +0 -0
  72. /package/{lib-types/tools → lib}/utils/fs-mock.d.ts +0 -0
  73. /package/{lib-types/tools → lib}/utils/fs.d.ts +0 -0
  74. /package/{lib-types/tools → lib}/utils/icons/ast/expressions.d.ts +0 -0
  75. /package/{lib-types/tools/utils/transform-dts.unit.d.ts → lib/utils/icons/ast/expressions.unit.d.ts} +0 -0
  76. /package/{lib-types/tools → lib}/utils/icons/ast/jsx.d.ts +0 -0
  77. /package/{lib-types/tools/vite/minify-content.unit.d.ts → lib/utils/icons/ast/jsx.unit.d.ts} +0 -0
  78. /package/{lib-types/tools → lib}/utils/icons/collections/loader.d.ts +0 -0
  79. /package/{lib-types/tools → lib}/utils/icons/import-resolver.d.ts +0 -0
  80. /package/{lib-types/tools → lib}/utils/icons/naming.d.ts +0 -0
  81. /package/{lib-types/tools → lib}/utils/icons/transform/shared.d.ts +0 -0
  82. /package/{lib-types/tools → lib}/utils/icons/types/mdx-ast.d.ts +0 -0
  83. /package/{lib-types/tools → lib}/utils/index.d.ts +0 -0
  84. /package/{lib-types/tools → lib}/utils/package-json.d.ts +0 -0
  85. /package/{lib-types/tools → lib}/vite/minify-content.d.ts +0 -0
@@ -1,15 +1,15 @@
1
+ import { getNodeText, isCallExpressionWithName, isIdentifierWithName } from "./ast/core.qwik.mjs";
2
+ import { getJSXElementName, isJSXElementWithName } from "./ast/jsx-helpers.qwik.mjs";
1
3
  import { extractChildren, extractFromElement, extractFromNode, extractJSXMemberExpressionName, extractProps, getAttributeValue, getLineNumber, isJSXElement, isJSXExpressionContainer, isJSXText, propsObjectToAttributes } from "./icons/ast/jsx.qwik.mjs";
2
4
  import { handleCallExpression, handleConditionalExpression, handleExpression, handleIdentifierExpression, handleLogicalExpression, handleMemberExpression, isSupportedExpressionType } from "./icons/ast/expressions.qwik.mjs";
3
5
  import { discoverAllIconifyCollections, generateImportVar, getAvailableCollections, resolveIconNames, sanitizeIconName, toKebabCase, toPascalCase } from "./icons/naming.qwik.mjs";
4
6
  import { CollectionLoader } from "./icons/collections/loader.qwik.mjs";
5
7
  import { extractMDXImportAliases, mapImportToPack, resolveImportAliases } from "./icons/import-resolver.qwik.mjs";
6
8
  import { buildSVGElement, generateIconImport } from "./icons/transform/shared.qwik.mjs";
7
- import { extractMDXAttributes, transformMDXFile } from "./icons/transform/mdx.qwik.mjs";
8
- import { findIconElements, isIconElement, transformIconElement, transformTSXFile } from "./icons/transform/tsx.qwik.mjs";
9
- import { getNodeText, isCallExpressionWithName, isIdentifierWithName } from "./ast/core.qwik.mjs";
9
+ import { findIconElements, isIconElement, transformIconElement, transformTSXFile, transformTSXFileCore } from "./icons/transform/tsx.qwik.mjs";
10
+ import { extractMDXAttributes, transformMDXFile, transformMDXFileCore } from "./icons/transform/mdx.qwik.mjs";
10
11
  import { findImportBySource, getImportSource, hasImportSpecifier, injectTypeImport } from "./ast/imports.qwik.mjs";
11
- import { getJSXElementName, isJSXElementWithName } from "./ast/jsx-helpers.qwik.mjs";
12
12
  import { readPackageJson } from "./package-json.qwik.mjs";
13
13
  import { injectAsChildTypesImport, injectAsChildTypesIntoComponent, transformTypeFile } from "./transform-dts.qwik.mjs";
14
14
 
15
- export { CollectionLoader, buildSVGElement, discoverAllIconifyCollections, extractChildren, extractFromElement, extractFromNode, extractJSXMemberExpressionName, extractMDXAttributes, extractMDXImportAliases, extractProps, findIconElements, findImportBySource, generateIconImport, generateImportVar, getAttributeValue, getAvailableCollections, getImportSource, getJSXElementName, getLineNumber, getNodeText, handleCallExpression, handleConditionalExpression, handleExpression, handleIdentifierExpression, handleLogicalExpression, handleMemberExpression, hasImportSpecifier, injectAsChildTypesImport, injectAsChildTypesIntoComponent, injectTypeImport, isCallExpressionWithName, isIconElement, isIdentifierWithName, isJSXElement, isJSXElementWithName, isJSXExpressionContainer, isJSXText, isSupportedExpressionType, mapImportToPack, propsObjectToAttributes, readPackageJson, resolveIconNames, resolveImportAliases, sanitizeIconName, toKebabCase, toPascalCase, transformIconElement, transformMDXFile, transformTSXFile, transformTypeFile };
15
+ export { CollectionLoader, buildSVGElement, discoverAllIconifyCollections, extractChildren, extractFromElement, extractFromNode, extractJSXMemberExpressionName, extractMDXAttributes, extractMDXImportAliases, extractProps, findIconElements, findImportBySource, generateIconImport, generateImportVar, getAttributeValue, getAvailableCollections, getImportSource, getJSXElementName, getLineNumber, getNodeText, handleCallExpression, handleConditionalExpression, handleExpression, handleIdentifierExpression, handleLogicalExpression, handleMemberExpression, hasImportSpecifier, injectAsChildTypesImport, injectAsChildTypesIntoComponent, injectTypeImport, isCallExpressionWithName, isIconElement, isIdentifierWithName, isJSXElement, isJSXElementWithName, isJSXExpressionContainer, isJSXText, isSupportedExpressionType, mapImportToPack, propsObjectToAttributes, readPackageJson, resolveIconNames, resolveImportAliases, sanitizeIconName, toKebabCase, toPascalCase, transformIconElement, transformMDXFile, transformMDXFileCore, transformTSXFile, transformTSXFileCore, transformTypeFile };
@@ -4,12 +4,13 @@ import MagicString from "magic-string";
4
4
  import { parseSync } from "oxc-parser";
5
5
  declare function injectAsChildTypesIntoComponent(node: Node, content: string, s: MagicString): boolean;
6
6
  /**
7
- * Injects AsChildTypes import into the declaration file
7
+ * Injects AsChildTypes import using a relative path to the local as-child-types file
8
8
  */
9
9
  declare function injectAsChildTypesImport(options: {
10
10
  ast: ReturnType<typeof parseSync>;
11
11
  magicString: MagicString;
12
- toolsImportNode: Node | null;
12
+ dtsPath: string;
13
+ declDir: string;
13
14
  }): void;
14
- declare function transformTypeFile(dtsPath: string, sourcePath: string): Promise<boolean>;
15
+ declare function transformTypeFile(dtsPath: string, sourcePath: string, declDir: string): Promise<boolean>;
15
16
  export { injectAsChildTypesImport, injectAsChildTypesIntoComponent, transformTypeFile };
@@ -1,10 +1,10 @@
1
- import { findImportBySource, hasImportSpecifier, injectTypeImport } from "./ast/imports.qwik.mjs";
2
1
  import { detectsRenderComponentUsage } from "./ast/qwik.qwik.mjs";
2
+ import { injectTypeImport } from "./ast/imports.qwik.mjs";
3
3
  import { walkFiles } from "./fs.qwik.mjs";
4
+ import { dirname, join, relative } from "node:path";
4
5
  import MagicString from "magic-string";
5
6
  import { parseSync } from "oxc-parser";
6
7
  import { walk } from "oxc-walker";
7
- import { join, relative } from "node:path";
8
8
  import { readFile, stat, writeFile } from "node:fs/promises";
9
9
 
10
10
  //#region utils/transform-dts.ts
@@ -36,27 +36,21 @@ function injectAsChildTypesIntoComponent(node, content, s) {
36
36
  return hasChanges;
37
37
  }
38
38
  /**
39
- * Injects AsChildTypes import into the declaration file
39
+ * Injects AsChildTypes import using a relative path to the local as-child-types file
40
40
  */ function injectAsChildTypesImport(options) {
41
+ const asChildTypesTarget = join(options.declDir, "types");
42
+ let relImport = relative(dirname(options.dtsPath), asChildTypesTarget);
43
+ if (!relImport.startsWith(".")) relImport = "./" + relImport;
41
44
  injectTypeImport({
42
45
  ast: options.ast,
43
46
  magicString: options.magicString,
44
- importSource: "@qds.dev/tools",
45
- specifierName: "AsChildTypes",
46
- existingImportNode: options.toolsImportNode
47
+ importSource: relImport,
48
+ specifierName: "AsChildTypes"
47
49
  });
48
50
  }
49
- async function transformTypeFile(dtsPath, sourcePath) {
51
+ async function transformTypeFile(dtsPath, sourcePath, declDir) {
50
52
  const content = await readFile(dtsPath, "utf-8");
51
- const hasAsChildTypesUsage = content.includes("AsChildTypes");
52
- if (hasAsChildTypesUsage) try {
53
- const toolsImportNode = findImportBySource(parseSync(dtsPath, content), content, "@qds.dev/tools");
54
- if (toolsImportNode) {
55
- if (hasImportSpecifier(toolsImportNode, "AsChildTypes")) return false;
56
- }
57
- } catch {
58
- return false;
59
- }
53
+ if (content.includes("AsChildTypes")) return false;
60
54
  try {
61
55
  if (!detectsRenderComponentUsage(await readFile(sourcePath, "utf-8"))) return false;
62
56
  } catch {
@@ -69,11 +63,12 @@ async function transformTypeFile(dtsPath, sourcePath) {
69
63
  walk(ast.program, { enter(node) {
70
64
  if (injectAsChildTypesIntoComponent(node, content, s)) hasChanges = true;
71
65
  } });
72
- if (!hasChanges && !hasAsChildTypesUsage) return false;
66
+ if (!hasChanges) return false;
73
67
  injectAsChildTypesImport({
74
68
  ast,
75
69
  magicString: s,
76
- toolsImportNode: findImportBySource(ast, content, "@qds.dev/tools")
70
+ dtsPath,
71
+ declDir
77
72
  });
78
73
  await writeFile(dtsPath, s.toString(), "utf-8");
79
74
  return true;
@@ -84,8 +79,8 @@ async function transformTypeFile(dtsPath, sourcePath) {
84
79
  }
85
80
  async function main() {
86
81
  const sourceDir = process.argv[2] || "./src";
87
- const declDir = process.argv[3] || "./lib-types";
88
- console.log(`🔍 Scanning ${sourceDir} for source files...`);
82
+ const declDir = process.argv[3] || "./lib/src";
83
+ console.log(`Scanning ${sourceDir} for source files...`);
89
84
  let processedCount = 0;
90
85
  let changedCount = 0;
91
86
  for await (const sourcePath of walkFiles(sourceDir, ".tsx")) {
@@ -96,12 +91,12 @@ async function main() {
96
91
  continue;
97
92
  }
98
93
  processedCount++;
99
- if (await transformTypeFile(dtsPath, sourcePath)) {
94
+ if (await transformTypeFile(dtsPath, sourcePath, declDir)) {
100
95
  changedCount++;
101
- console.log(`✓ Transformed ${dtsPath}`);
96
+ console.log(`Transformed ${dtsPath}`);
102
97
  }
103
98
  }
104
- console.log(`\n✨ Processed ${processedCount} files, transformed ${changedCount} files`);
99
+ console.log(`\nProcessed ${processedCount} files, transformed ${changedCount} files`);
105
100
  }
106
101
  if (import.meta.url === `file://${process.argv[1]}`) main().catch((error) => {
107
102
  console.error("Error:", error);
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- export type { AsChildPluginOptions, AsChildTypes, IconsPluginOptions, InlineAssetPluginOptions, PacksMap } from "../rolldown/index";
1
+ export type { AsChildPluginOptions, AsChildTypes, IconsPluginOptions, InlineAssetPluginOptions, PacksMap, QdsOptions, QdsSubPlugin, UiPluginOptions } from "../rolldown/index";
2
2
  export type { Plugin as VitePlugin, PluginOption as VitePluginOption } from "vite";
3
- export { asChild, icons, inlineAsset } from "../rolldown/index";
3
+ export { inlineAsset, qds } from "../rolldown/index";
4
4
  export { minifyContentPlugin } from "./minify-content";
@@ -1,6 +1,5 @@
1
- import { asChild } from "../rolldown/as-child.qwik.mjs";
2
- import { icons } from "../rolldown/icons.qwik.mjs";
3
1
  import { inlineAsset } from "../rolldown/inline-asset.qwik.mjs";
2
+ import { qds } from "../rolldown/qds.qwik.mjs";
4
3
  import { minifyContentPlugin } from "./minify-content.qwik.mjs";
5
4
 
6
- export { asChild, icons, inlineAsset, minifyContentPlugin };
5
+ export { inlineAsset, minifyContentPlugin, qds };
@@ -1,6 +1,6 @@
1
- import { char, createRegExp, exactly, oneOrMore } from "magic-regexp";
2
1
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
3
2
  import { resolve, sep } from "node:path";
3
+ import { char, createRegExp, exactly, oneOrMore } from "magic-regexp";
4
4
  import { minifySync } from "oxc-minify";
5
5
  import { transform } from "oxc-transform";
6
6
 
@@ -0,0 +1 @@
1
+ export {};