auklet 0.0.16 → 0.0.17

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 (95) hide show
  1. package/dist/build/bundleConfig.d.ts +1 -4
  2. package/dist/build/bundleConfig.js +59 -71
  3. package/dist/build/cleanOutput.d.ts +2 -8
  4. package/dist/build/cleanOutput.js +7 -7
  5. package/dist/build/moduleConfig.d.ts +1 -3
  6. package/dist/build/moduleConfig.js +21 -40
  7. package/dist/build/runTsdown.d.ts +2 -5
  8. package/dist/build/runTsdown.js +18 -23
  9. package/dist/build/tsdown/common.d.ts +17 -28
  10. package/dist/build/tsdown/common.js +22 -25
  11. package/dist/build/tsdown/context.d.ts +16 -20
  12. package/dist/build/tsdown/context.js +41 -45
  13. package/dist/build/tsdown/define.d.ts +2 -7
  14. package/dist/build/tsdown/define.js +13 -22
  15. package/dist/build/tsdown/dependencies.d.ts +4 -12
  16. package/dist/build/tsdown/dependencies.js +47 -51
  17. package/dist/build/tsdown/entries.d.ts +4 -6
  18. package/dist/build/tsdown/entries.js +39 -38
  19. package/dist/build/tsdown/parseModuleId.d.ts +4 -4
  20. package/dist/build/tsdown/parseModuleId.js +92 -77
  21. package/dist/build/tsdown/types.d.ts +24 -31
  22. package/dist/build/tsdownConfig.js +1 -4
  23. package/dist/config.d.ts +37 -37
  24. package/dist/config.js +38 -41
  25. package/dist/configLoader.d.ts +2 -7
  26. package/dist/configLoader.js +59 -64
  27. package/dist/css/config.js +8 -8
  28. package/dist/css/constants.d.ts +6 -6
  29. package/dist/css/core/resolvers/packageImports.d.ts +1 -5
  30. package/dist/css/core/resolvers/packageImports.js +35 -40
  31. package/dist/css/core/resolvers/relative.d.ts +1 -4
  32. package/dist/css/core/resolvers/relative.js +3 -2
  33. package/dist/css/core/resolvers/tsconfigPaths.d.ts +1 -5
  34. package/dist/css/core/resolvers/tsconfigPaths.js +59 -66
  35. package/dist/css/core/style/dependencies.d.ts +6 -16
  36. package/dist/css/core/style/dependencies.js +35 -38
  37. package/dist/css/core/style/entries.d.ts +35 -58
  38. package/dist/css/core/style/entries.js +20 -31
  39. package/dist/css/core/style/files.d.ts +2 -7
  40. package/dist/css/core/style/files.js +11 -11
  41. package/dist/css/core/style/specifier.d.ts +5 -8
  42. package/dist/css/core/style/specifier.js +21 -18
  43. package/dist/css/core/styleImports/collector.d.ts +17 -25
  44. package/dist/css/core/styleImports/collector.js +162 -201
  45. package/dist/css/core/styleImports/sourceReference.d.ts +8 -16
  46. package/dist/css/core/styleImports/sourceReference.js +153 -173
  47. package/dist/css/core/styleModuleEntryPlanner.d.ts +21 -24
  48. package/dist/css/core/styleModuleEntryPlanner.js +44 -61
  49. package/dist/css/core/stylePackageContext.d.ts +16 -20
  50. package/dist/css/core/stylePackageContext.js +33 -49
  51. package/dist/css/core/styleProcessor.js +105 -104
  52. package/dist/css/core/workspaceStyleResolver.d.ts +9 -15
  53. package/dist/css/core/workspaceStyleResolver.js +62 -72
  54. package/dist/css/production/builder.d.ts +9 -16
  55. package/dist/css/production/builder.js +51 -57
  56. package/dist/css/production/format/componentWriter.js +45 -66
  57. package/dist/css/production/format/entryWriter.js +36 -49
  58. package/dist/css/production/format/externalWriter.js +21 -33
  59. package/dist/css/production/format/moduleWriter.js +23 -26
  60. package/dist/css/production/format/shared.d.ts +8 -15
  61. package/dist/css/production/format/shared.js +5 -6
  62. package/dist/css/production/format/sourceWriter.js +11 -11
  63. package/dist/css/production/format/themeWriter.js +56 -71
  64. package/dist/css/production/moduleOutputWriter.d.ts +18 -21
  65. package/dist/css/production/moduleOutputWriter.js +56 -65
  66. package/dist/css/production/packageEntryWriter.d.ts +12 -15
  67. package/dist/css/production/packageEntryWriter.js +42 -45
  68. package/dist/css/vite/hmr.d.ts +11 -11
  69. package/dist/css/vite/hmr.js +93 -109
  70. package/dist/css/vite/moduleGraph/devDependency.d.ts +7 -12
  71. package/dist/css/vite/moduleGraph/devDependency.js +8 -8
  72. package/dist/css/vite/moduleGraph/graph.d.ts +20 -23
  73. package/dist/css/vite/moduleGraph/graph.js +46 -49
  74. package/dist/css/vite/moduleGraph/loadResult.d.ts +3 -5
  75. package/dist/css/vite/moduleGraph/loadResult.js +7 -9
  76. package/dist/css/vite/moduleGraph/packageSource/monorepo.d.ts +4 -6
  77. package/dist/css/vite/moduleGraph/packageSource/monorepo.js +59 -64
  78. package/dist/css/vite/moduleGraph/packageSource/types.d.ts +7 -7
  79. package/dist/css/vite/moduleGraph/requestCache.d.ts +46 -57
  80. package/dist/css/vite/moduleGraph/requestCache.js +53 -51
  81. package/dist/css/vite/moduleGraph/styleCodeFactory.d.ts +15 -18
  82. package/dist/css/vite/moduleGraph/styleCodeFactory.js +182 -263
  83. package/dist/css/vite/moduleGraph/styleId.d.ts +3 -6
  84. package/dist/css/vite/moduleGraph/styleId.js +12 -11
  85. package/dist/css/vite/moduleGraph/types.d.ts +11 -14
  86. package/dist/css/vite/vitePlugin.d.ts +16 -20
  87. package/dist/css/vite/vitePlugin.js +110 -109
  88. package/dist/css/watch/watcher.d.ts +15 -21
  89. package/dist/css/watch/watcher.js +83 -80
  90. package/dist/index.d.ts +3 -25
  91. package/dist/index.js +2 -9
  92. package/dist/types.d.ts +59 -62
  93. package/dist/utils.d.ts +3 -7
  94. package/dist/utils.js +50 -47
  95. package/package.json +31 -33
@@ -1,75 +1,52 @@
1
1
  import type { StylePackageContext } from '#auklet/css/core/stylePackageContext';
2
2
  import type { NormalizedAukletConfig } from '#auklet/types';
3
3
  type StyleModulePart = {
4
- type: 'module';
4
+ type: 'module';
5
5
  };
6
6
  type StyleThemesPart = {
7
- type: 'themes';
8
- themeNames: Array<string>;
7
+ type: 'themes';
8
+ themeNames: Array<string>;
9
9
  };
10
10
  type DependenciesPart = {
11
- type: 'dependencies';
12
- specifiers: Array<string>;
11
+ type: 'dependencies';
12
+ specifiers: Array<string>;
13
13
  };
14
14
  type ThemePart = {
15
- type: 'theme';
16
- themeName: string;
15
+ type: 'theme';
16
+ themeName: string;
17
17
  };
18
18
  export type ExternalEntryPart = DependenciesPart;
19
19
  export type ThemeEntryPart = DependenciesPart | ThemePart;
20
- export type StyleEntryPart =
21
- | DependenciesPart
22
- | StyleThemesPart
23
- | StyleModulePart;
24
- export declare function createStyleEntryParts(config: NormalizedAukletConfig): (
25
- | {
26
- type: 'dependencies';
27
- specifiers: string[];
28
- }
29
- | {
30
- type: 'themes';
31
- themeNames: string[];
32
- }
33
- | {
34
- type: 'module';
35
- themeNames?: undefined;
36
- }
37
- )[];
38
- export declare function createThemeEntryParts(
39
- config: NormalizedAukletConfig,
40
- themeName: string,
41
- options?: {
20
+ export type StyleEntryPart = DependenciesPart | StyleThemesPart | StyleModulePart;
21
+ export declare function createStyleEntryParts(config: NormalizedAukletConfig): ({
22
+ type: "dependencies";
23
+ specifiers: string[];
24
+ } | {
25
+ type: "themes";
26
+ themeNames: string[];
27
+ } | {
28
+ type: "module";
29
+ themeNames?: undefined;
30
+ })[];
31
+ export declare function createThemeEntryParts(config: NormalizedAukletConfig, themeName: string, options?: {
42
32
  includeDependencies?: boolean;
43
- },
44
- ): (
45
- | ThemePart
46
- | {
47
- type: 'dependencies';
48
- specifiers: string[];
49
- }
50
- )[];
51
- export declare function createExternalEntryParts(
52
- config: NormalizedAukletConfig,
53
- ): {
54
- type: 'dependencies';
55
- specifiers: string[];
33
+ }): (ThemePart | {
34
+ type: "dependencies";
35
+ specifiers: string[];
36
+ })[];
37
+ export declare function createExternalEntryParts(config: NormalizedAukletConfig): {
38
+ type: "dependencies";
39
+ specifiers: string[];
56
40
  }[];
57
- export declare function collectModuleStyleImports(
58
- packageContext: StylePackageContext,
59
- ): Map<string, string[]>;
60
- export declare function createComponentStyleEntryPlan(
61
- packageContext: StylePackageContext,
62
- sourceDir: string,
63
- ): {
64
- sourceDir: string;
65
- moduleStyleImports: string[];
66
- ownStyleFiles: string[];
41
+ export declare function collectModuleStyleImports(packageContext: StylePackageContext): Map<string, string[]>;
42
+ export declare function createComponentStyleEntryPlan(packageContext: StylePackageContext, sourceDir: string): {
43
+ sourceDir: string;
44
+ moduleStyleImports: string[];
45
+ ownStyleFiles: string[];
67
46
  };
68
- export declare function createComponentStyleEntryPlans(
69
- packageContext: StylePackageContext,
70
- ): {
71
- sourceDir: string;
72
- moduleStyleImports: string[];
73
- ownStyleFiles: string[];
47
+ export declare function createComponentStyleEntryPlans(packageContext: StylePackageContext): {
48
+ sourceDir: string;
49
+ moduleStyleImports: string[];
50
+ ownStyleFiles: string[];
74
51
  }[];
75
52
  export {};
@@ -1,46 +1,35 @@
1
- import {
2
- getExternalStyleDependencies,
3
- getGlobalStyleDependencies,
4
- getThemeNames,
5
- getThemeStyleDependencies,
6
- } from '#auklet/css/core/style/dependencies';
1
+ import { getExternalStyleDependencies, getGlobalStyleDependencies, getThemeNames, getThemeStyleDependencies, } from '#auklet/css/core/style/dependencies';
7
2
  import { StyleModuleEntryPlanner } from '#auklet/css/core/styleModuleEntryPlanner';
8
3
  const dependenciesPart = (specifiers) => ({ type: 'dependencies', specifiers });
9
4
  // 环境无关的 style entry graph。production writer 和 Vite/dev renderer 都从这里取入口语义。
10
5
  export function createStyleEntryParts(config) {
11
- return [
12
- dependenciesPart(getGlobalStyleDependencies(config)),
13
- { type: 'themes', themeNames: getThemeNames(config) },
14
- { type: 'module' },
15
- ];
6
+ return [
7
+ dependenciesPart(getGlobalStyleDependencies(config)),
8
+ { type: 'themes', themeNames: getThemeNames(config) },
9
+ { type: 'module' },
10
+ ];
16
11
  }
17
12
  export function createThemeEntryParts(config, themeName, options = {}) {
18
- const themePart = { type: 'theme', themeName };
19
- if (options.includeDependencies === false) {
20
- return [themePart];
21
- }
22
- return [
23
- dependenciesPart(getThemeStyleDependencies(config, themeName)),
24
- themePart,
25
- ];
13
+ const themePart = { type: 'theme', themeName };
14
+ if (options.includeDependencies === false) {
15
+ return [themePart];
16
+ }
17
+ return [
18
+ dependenciesPart(getThemeStyleDependencies(config, themeName)),
19
+ themePart,
20
+ ];
26
21
  }
27
22
  export function createExternalEntryParts(config) {
28
- return [dependenciesPart(getExternalStyleDependencies(config))];
23
+ return [
24
+ dependenciesPart(getExternalStyleDependencies(config)),
25
+ ];
29
26
  }
30
27
  export function collectModuleStyleImports(packageContext) {
31
- return packageContext.importCollector.collect(
32
- packageContext.sourceFiles,
33
- packageContext.normalizedConfig,
34
- );
28
+ return packageContext.importCollector.collect(packageContext.sourceFiles, packageContext.normalizedConfig);
35
29
  }
36
30
  export function createComponentStyleEntryPlan(packageContext, sourceDir) {
37
- return new StyleModuleEntryPlanner(packageContext).createEntry(
38
- sourceDir,
39
- collectModuleStyleImports(packageContext),
40
- );
31
+ return new StyleModuleEntryPlanner(packageContext).createEntry(sourceDir, collectModuleStyleImports(packageContext));
41
32
  }
42
33
  export function createComponentStyleEntryPlans(packageContext) {
43
- return new StyleModuleEntryPlanner(packageContext).createEntries(
44
- collectModuleStyleImports(packageContext),
45
- );
34
+ return new StyleModuleEntryPlanner(packageContext).createEntries(collectModuleStyleImports(packageContext));
46
35
  }
@@ -1,8 +1,3 @@
1
- export declare function groupStyleFilesByDir(
2
- sourceRoot: string,
3
- styleFiles: Array<string>,
4
- ): Map<string, string[]>;
5
- export declare function createStyleFileKeySet(
6
- styleFiles: Iterable<string>,
7
- ): Set<string>;
1
+ export declare function groupStyleFilesByDir(sourceRoot: string, styleFiles: Array<string>): Map<string, string[]>;
2
+ export declare function createStyleFileKeySet(styleFiles: Iterable<string>): Set<string>;
8
3
  export declare function createStyleFileKey(styleFile: string): string;
@@ -1,19 +1,19 @@
1
1
  import path from 'node:path';
2
2
  import { getSourceModuleDir, normalizeFileKey } from '#auklet/utils';
3
3
  export function groupStyleFilesByDir(sourceRoot, styleFiles) {
4
- const styleFilesByDir = new Map();
5
- for (const styleFile of styleFiles) {
6
- const sourceRelative = path.relative(sourceRoot, styleFile);
7
- const sourceDir = getSourceModuleDir(sourceRelative);
8
- const values = styleFilesByDir.get(sourceDir) ?? [];
9
- values.push(styleFile);
10
- styleFilesByDir.set(sourceDir, values);
11
- }
12
- return styleFilesByDir;
4
+ const styleFilesByDir = new Map();
5
+ for (const styleFile of styleFiles) {
6
+ const sourceRelative = path.relative(sourceRoot, styleFile);
7
+ const sourceDir = getSourceModuleDir(sourceRelative);
8
+ const values = styleFilesByDir.get(sourceDir) ?? [];
9
+ values.push(styleFile);
10
+ styleFilesByDir.set(sourceDir, values);
11
+ }
12
+ return styleFilesByDir;
13
13
  }
14
14
  export function createStyleFileKeySet(styleFiles) {
15
- return new Set(Array.from(styleFiles, normalizeFileKey));
15
+ return new Set(Array.from(styleFiles, normalizeFileKey));
16
16
  }
17
17
  export function createStyleFileKey(styleFile) {
18
- return normalizeFileKey(styleFile);
18
+ return normalizeFileKey(styleFile);
19
19
  }
@@ -1,14 +1,11 @@
1
1
  export type PackageStyleSpecifier = {
2
- packageName: string;
3
- stylePath: string;
2
+ packageName: string;
3
+ stylePath: string;
4
4
  };
5
5
  export declare function parsePackageStyleSpecifier(specifier: string): {
6
- packageName: string;
7
- stylePath: string;
6
+ packageName: string;
7
+ stylePath: string;
8
8
  } | null;
9
- export declare function joinDependencySpecifier(
10
- packageName: string,
11
- dependencyPath: string,
12
- ): string;
9
+ export declare function joinDependencySpecifier(packageName: string, dependencyPath: string): string;
13
10
  export declare function createImportCode(specifiers: Array<string>): string;
14
11
  export declare function removeStyleExtension(stylePath: string): string;
@@ -1,27 +1,30 @@
1
1
  import path from 'node:path';
2
2
  export function parsePackageStyleSpecifier(specifier) {
3
- if (specifier.startsWith('.')) return null;
4
- const parts = specifier.split('/');
5
- const packageName = specifier.startsWith('@')
6
- ? `${parts.shift() ?? ''}/${parts.shift() ?? ''}`
7
- : parts.shift() ?? '';
8
- if (!packageName) return null;
9
- return {
10
- packageName,
11
- stylePath: parts.join('/'),
12
- };
3
+ if (specifier.startsWith('.'))
4
+ return null;
5
+ const parts = specifier.split('/');
6
+ const packageName = specifier.startsWith('@')
7
+ ? `${parts.shift() ?? ''}/${parts.shift() ?? ''}`
8
+ : (parts.shift() ?? '');
9
+ if (!packageName)
10
+ return null;
11
+ return {
12
+ packageName,
13
+ stylePath: parts.join('/'),
14
+ };
13
15
  }
14
16
  export function joinDependencySpecifier(packageName, dependencyPath) {
15
- if (!dependencyPath) return packageName;
16
- return dependencyPath.startsWith('/')
17
- ? `${packageName}${dependencyPath}`
18
- : `${packageName}/${dependencyPath}`;
17
+ if (!dependencyPath)
18
+ return packageName;
19
+ return dependencyPath.startsWith('/')
20
+ ? `${packageName}${dependencyPath}`
21
+ : `${packageName}/${dependencyPath}`;
19
22
  }
20
23
  export function createImportCode(specifiers) {
21
- return Array.from(new Set(specifiers))
22
- .map((specifier) => `@import "${specifier}";`)
23
- .join('\n');
24
+ return Array.from(new Set(specifiers))
25
+ .map((specifier) => `@import "${specifier}";`)
26
+ .join('\n');
24
27
  }
25
28
  export function removeStyleExtension(stylePath) {
26
- return stylePath.slice(0, -path.extname(stylePath).length);
29
+ return stylePath.slice(0, -path.extname(stylePath).length);
27
30
  }
@@ -1,29 +1,21 @@
1
1
  import type { NormalizedAukletConfig } from '#auklet/types';
2
2
  import type { WorkspaceStyleResolver } from '#auklet/css/core/workspaceStyleResolver';
3
3
  export declare class ModuleStyleImportCollector {
4
- private readonly srcRoot;
5
- private readonly packageRoot;
6
- private readonly resolver;
7
- private readonly styleExtensions;
8
- constructor(
9
- srcRoot: string,
10
- packageRoot: string,
11
- resolver: WorkspaceStyleResolver,
12
- styleExtensions?: Array<string>,
13
- );
14
- collect(
15
- files: Array<string>,
16
- config: NormalizedAukletConfig,
17
- ): Map<string, string[]>;
18
- private collectSourceImportStyle;
19
- private resolveSourceImportStyleEntry;
20
- private isInsideSourceRoot;
21
- private resolveSourceImportPaths;
22
- private toSourceBase;
23
- private toRelativeSpecifier;
24
- private createAutoImportRules;
25
- private matchAutoImportRules;
26
- private getImportPathValues;
27
- private createStyleSpecifier;
28
- private createDirectStyleSpecifier;
4
+ private readonly srcRoot;
5
+ private readonly packageRoot;
6
+ private readonly resolver;
7
+ private readonly styleExtensions;
8
+ constructor(srcRoot: string, packageRoot: string, resolver: WorkspaceStyleResolver, styleExtensions?: Array<string>);
9
+ collect(files: Array<string>, config: NormalizedAukletConfig): Map<string, string[]>;
10
+ private collectSourceImportStyle;
11
+ private resolveSourceImportStyleEntry;
12
+ private isInsideSourceRoot;
13
+ private resolveSourceImportPaths;
14
+ private toSourceBase;
15
+ private toRelativeSpecifier;
16
+ private createAutoImportRules;
17
+ private matchAutoImportRules;
18
+ private getImportPathValues;
19
+ private createStyleSpecifier;
20
+ private createDirectStyleSpecifier;
29
21
  }