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
@@ -4,81 +4,76 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
4
4
  import ts from 'typescript';
5
5
  import { aukletConfigFile } from '#auklet/config';
6
6
  const importAukletConfigModule = async (configPath, href) => {
7
- try {
8
- return await import(href);
9
- } catch (error) {
10
- if (!isUnknownTsExtensionError(error) || !configPath.endsWith('.ts')) {
11
- throw error;
7
+ try {
8
+ return (await import(href));
9
+ }
10
+ catch (error) {
11
+ if (!isUnknownTsExtensionError(error) || !configPath.endsWith('.ts')) {
12
+ throw error;
13
+ }
14
+ return importTsOptionsModule(href);
12
15
  }
13
- return importTsOptionsModule(href);
14
- }
15
16
  };
16
17
  const importTsOptionsModule = async (href) => {
17
- const configPath = fileURLToPath(href);
18
- const source = fs.readFileSync(configPath, 'utf8');
19
- const output = ts.transpileModule(source, {
20
- compilerOptions: {
21
- esModuleInterop: true,
22
- module: ts.ModuleKind.ESNext,
23
- target: ts.ScriptTarget.ES2020,
24
- },
25
- fileName: configPath,
26
- });
27
- const tempFile = path.join(
28
- path.dirname(configPath),
29
- `.auklet.config.${process.pid}.${Date.now()}.mjs`,
30
- );
31
- fs.writeFileSync(tempFile, output.outputText);
32
- try {
33
- return await import(pathToFileURL(tempFile).href);
34
- } finally {
35
- fs.rmSync(tempFile, { force: true });
36
- }
18
+ const configPath = fileURLToPath(href);
19
+ const source = fs.readFileSync(configPath, 'utf8');
20
+ const output = ts.transpileModule(source, {
21
+ compilerOptions: {
22
+ esModuleInterop: true,
23
+ module: ts.ModuleKind.ESNext,
24
+ target: ts.ScriptTarget.ES2020,
25
+ },
26
+ fileName: configPath,
27
+ });
28
+ const tempFile = path.join(path.dirname(configPath), `.auklet.config.${process.pid}.${Date.now()}.mjs`);
29
+ fs.writeFileSync(tempFile, output.outputText);
30
+ try {
31
+ return (await import(pathToFileURL(tempFile).href));
32
+ }
33
+ finally {
34
+ fs.rmSync(tempFile, { force: true });
35
+ }
37
36
  };
38
37
  const isUnknownTsExtensionError = (error) => {
39
- return (
40
- error instanceof TypeError &&
41
- 'code' in error &&
42
- error.code === 'ERR_UNKNOWN_FILE_EXTENSION'
43
- );
38
+ return (error instanceof TypeError &&
39
+ 'code' in error &&
40
+ error.code === 'ERR_UNKNOWN_FILE_EXTENSION');
44
41
  };
45
42
  const asRecord = (value) => {
46
- if (!value || typeof value !== 'object' || Array.isArray(value)) {
47
- return null;
48
- }
49
- return value;
43
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
44
+ return null;
45
+ }
46
+ return value;
50
47
  };
51
48
  export function resolveAukletConfigModule(module) {
52
- const candidates = [
53
- module,
54
- asRecord(module.default),
55
- asRecord(module['module.exports']),
56
- ];
57
- for (const candidate of candidates) {
58
- if (!candidate) continue;
59
- const config = asRecord(candidate.config);
60
- if (config) {
61
- return config;
49
+ const candidates = [
50
+ module,
51
+ asRecord(module.default),
52
+ asRecord(module['module.exports']),
53
+ ];
54
+ for (const candidate of candidates) {
55
+ if (!candidate)
56
+ continue;
57
+ const config = asRecord(candidate.config);
58
+ if (config) {
59
+ return config;
60
+ }
62
61
  }
63
- }
64
- return {};
62
+ return {};
65
63
  }
66
64
  export async function loadAukletConfig(packageRoot, options = {}) {
67
- const configPath = path.join(
68
- packageRoot,
69
- options.configFile ?? aukletConfigFile,
70
- );
71
- if (!fs.existsSync(configPath)) {
72
- return {};
73
- }
74
- const url = pathToFileURL(configPath);
75
- if (options.cacheBust) {
76
- url.searchParams.set('t', Date.now().toString());
77
- }
78
- if (configPath.endsWith('.ts')) {
79
- const module = await importTsOptionsModule(url.href);
65
+ const configPath = path.join(packageRoot, options.configFile ?? aukletConfigFile);
66
+ if (!fs.existsSync(configPath)) {
67
+ return {};
68
+ }
69
+ const url = pathToFileURL(configPath);
70
+ if (options.cacheBust) {
71
+ url.searchParams.set('t', Date.now().toString());
72
+ }
73
+ if (configPath.endsWith('.ts')) {
74
+ const module = await importTsOptionsModule(url.href);
75
+ return resolveAukletConfigModule(module);
76
+ }
77
+ const module = await importAukletConfigModule(configPath, url.href);
80
78
  return resolveAukletConfigModule(module);
81
- }
82
- const module = await importAukletConfigModule(configPath, url.href);
83
- return resolveAukletConfigModule(module);
84
79
  }
@@ -1,10 +1,10 @@
1
1
  export const moduleStyleBuildConfig = {
2
- styleExtensions: ['.css'],
3
- output: {
4
- styleDir: 'style',
5
- indexStyleFile: 'index.css',
6
- moduleStyleFile: 'module.css',
7
- externalStyleFile: 'external.css',
8
- outputFormats: ['es', 'lib'],
9
- },
2
+ styleExtensions: ['.css'],
3
+ output: {
4
+ styleDir: 'style',
5
+ indexStyleFile: 'index.css',
6
+ moduleStyleFile: 'module.css',
7
+ externalStyleFile: 'external.css',
8
+ outputFormats: ['es', 'lib'],
9
+ },
10
10
  };
@@ -1,7 +1,7 @@
1
- export declare const NODE_MODULES_DIR = 'node_modules';
1
+ export declare const NODE_MODULES_DIR = "node_modules";
2
2
  export declare const SOURCE_COMPONENT_MODULE_RE: RegExp;
3
- export declare const THEMES_DIR = 'themes';
4
- export declare const THEMES_ENTRY_PREFIX = 'themes/';
5
- export declare const STYLE_ENTRY = 'style.css';
6
- export declare const MODULE_ENTRY = 'module.css';
7
- export declare const EXTERNAL_ENTRY = 'external.css';
3
+ export declare const THEMES_DIR = "themes";
4
+ export declare const THEMES_ENTRY_PREFIX = "themes/";
5
+ export declare const STYLE_ENTRY = "style.css";
6
+ export declare const MODULE_ENTRY = "module.css";
7
+ export declare const EXTERNAL_ENTRY = "external.css";
@@ -1,5 +1 @@
1
- export declare function resolvePackageImportsSourceImport(
2
- packageRoot: string,
3
- sourceRoot: string,
4
- importPath: string,
5
- ): string[];
1
+ export declare function resolvePackageImportsSourceImport(packageRoot: string, sourceRoot: string, importPath: string): string[];
@@ -5,49 +5,44 @@ import { POSIX_SEPARATOR, toPosixPath } from '#auklet/utils';
5
5
  const conditions = ['source', 'import', 'default'];
6
6
  const sourceExtensions = /\.(?:[cm]?[jt]s|[jt]sx)$/;
7
7
  const readPackageImports = (packageRoot) => {
8
- const packageJsonPath = path.join(packageRoot, 'package.json');
9
- if (!fs.existsSync(packageJsonPath)) return {};
10
- try {
11
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
12
- return packageJson.imports ?? {};
13
- } catch {
14
- return {};
15
- }
8
+ const packageJsonPath = path.join(packageRoot, 'package.json');
9
+ if (!fs.existsSync(packageJsonPath))
10
+ return {};
11
+ try {
12
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
13
+ return packageJson.imports ?? {};
14
+ }
15
+ catch {
16
+ return {};
17
+ }
16
18
  };
17
19
  const trimSourceExtension = (value) => {
18
- return value.replace(sourceExtensions, '');
20
+ return value.replace(sourceExtensions, '');
19
21
  };
20
22
  const toSourceRelativePath = (packageRoot, sourceRoot, target) => {
21
- if (!target.startsWith('.')) return null;
22
- const file = path.resolve(packageRoot, target);
23
- const relative = path.relative(sourceRoot, file);
24
- if (relative.startsWith('..') || path.isAbsolute(relative)) return null;
25
- return trimSourceExtension(toPosixPath(relative));
23
+ if (!target.startsWith('.'))
24
+ return null;
25
+ const file = path.resolve(packageRoot, target);
26
+ const relative = path.relative(sourceRoot, file);
27
+ if (relative.startsWith('..') || path.isAbsolute(relative))
28
+ return null;
29
+ return trimSourceExtension(toPosixPath(relative));
26
30
  };
27
- export function resolvePackageImportsSourceImport(
28
- packageRoot,
29
- sourceRoot,
30
- importPath,
31
- ) {
32
- if (!importPath.startsWith('#')) return [];
33
- const resolved = (() => {
34
- try {
35
- return findPathInImports(
36
- importPath,
37
- readPackageImports(packageRoot),
38
- conditions,
39
- );
40
- } catch {
41
- return null;
42
- }
43
- })();
44
- if (!resolved) return [];
45
- const sourceRelativePath = toSourceRelativePath(
46
- packageRoot,
47
- sourceRoot,
48
- resolved,
49
- );
50
- return sourceRelativePath
51
- ? [sourceRelativePath.split(POSIX_SEPARATOR).join(path.sep)]
52
- : [];
31
+ export function resolvePackageImportsSourceImport(packageRoot, sourceRoot, importPath) {
32
+ if (!importPath.startsWith('#'))
33
+ return [];
34
+ const resolved = (() => {
35
+ try {
36
+ return findPathInImports(importPath, readPackageImports(packageRoot), conditions);
37
+ }
38
+ catch {
39
+ return null;
40
+ }
41
+ })();
42
+ if (!resolved)
43
+ return [];
44
+ const sourceRelativePath = toSourceRelativePath(packageRoot, sourceRoot, resolved);
45
+ return sourceRelativePath
46
+ ? [sourceRelativePath.split(POSIX_SEPARATOR).join(path.sep)]
47
+ : [];
53
48
  }
@@ -1,4 +1 @@
1
- export declare function resolveRelativeSourceImport(
2
- sourceDir: string,
3
- importPath: string,
4
- ): string[];
1
+ export declare function resolveRelativeSourceImport(sourceDir: string, importPath: string): string[];
@@ -1,5 +1,6 @@
1
1
  import path from 'node:path';
2
2
  export function resolveRelativeSourceImport(sourceDir, importPath) {
3
- if (!importPath.startsWith('.')) return [];
4
- return [path.normalize(path.join(sourceDir, importPath))];
3
+ if (!importPath.startsWith('.'))
4
+ return [];
5
+ return [path.normalize(path.join(sourceDir, importPath))];
5
6
  }
@@ -1,5 +1 @@
1
- export declare function resolveTsconfigPathsSourceImport(
2
- packageRoot: string,
3
- sourceRoot: string,
4
- importPath: string,
5
- ): string[];
1
+ export declare function resolveTsconfigPathsSourceImport(packageRoot: string, sourceRoot: string, importPath: string): string[];
@@ -4,82 +4,75 @@ import ts from 'typescript';
4
4
  import { POSIX_SEPARATOR, toPosixPath } from '#auklet/utils';
5
5
  const sourceExtensions = /\.(?:[cm]?[jt]s|[jt]sx)$/;
6
6
  const findTsconfig = (packageRoot) => {
7
- let current = packageRoot;
8
- while (true) {
9
- const tsconfig = path.join(current, 'tsconfig.json');
10
- if (fs.existsSync(tsconfig)) return tsconfig;
11
- const parent = path.dirname(current);
12
- if (parent === current) return null;
13
- current = parent;
14
- }
7
+ let current = packageRoot;
8
+ while (true) {
9
+ const tsconfig = path.join(current, 'tsconfig.json');
10
+ if (fs.existsSync(tsconfig))
11
+ return tsconfig;
12
+ const parent = path.dirname(current);
13
+ if (parent === current)
14
+ return null;
15
+ current = parent;
16
+ }
15
17
  };
16
18
  const readTsconfigPaths = (packageRoot) => {
17
- const tsconfig = findTsconfig(packageRoot);
18
- if (!tsconfig) return null;
19
- const loaded = ts.readConfigFile(tsconfig, ts.sys.readFile);
20
- if (loaded.error) return null;
21
- const parsed = ts.parseJsonConfigFileContent(
22
- loaded.config,
23
- ts.sys,
24
- path.dirname(tsconfig),
25
- {},
26
- tsconfig,
27
- );
28
- return {
29
- baseUrl: parsed.options.baseUrl ?? path.dirname(tsconfig),
30
- paths: parsed.options.paths ?? {},
31
- };
19
+ const tsconfig = findTsconfig(packageRoot);
20
+ if (!tsconfig)
21
+ return null;
22
+ const loaded = ts.readConfigFile(tsconfig, ts.sys.readFile);
23
+ if (loaded.error)
24
+ return null;
25
+ const parsed = ts.parseJsonConfigFileContent(loaded.config, ts.sys, path.dirname(tsconfig), {}, tsconfig);
26
+ return {
27
+ baseUrl: parsed.options.baseUrl ?? path.dirname(tsconfig),
28
+ paths: parsed.options.paths ?? {},
29
+ };
32
30
  };
33
31
  const resolvePattern = (pattern, target, importPath) => {
34
- const wildcardIndex = pattern.indexOf('*');
35
- if (wildcardIndex < 0) return pattern === importPath ? target : null;
36
- const prefix = pattern.slice(0, wildcardIndex);
37
- const suffix = pattern.slice(wildcardIndex + 1);
38
- if (!importPath.startsWith(prefix) || !importPath.endsWith(suffix)) {
39
- return null;
40
- }
41
- const value = importPath.slice(
42
- prefix.length,
43
- importPath.length - suffix.length,
44
- );
45
- return target.replace(/\*/g, value);
32
+ const wildcardIndex = pattern.indexOf('*');
33
+ if (wildcardIndex < 0)
34
+ return pattern === importPath ? target : null;
35
+ const prefix = pattern.slice(0, wildcardIndex);
36
+ const suffix = pattern.slice(wildcardIndex + 1);
37
+ if (!importPath.startsWith(prefix) || !importPath.endsWith(suffix)) {
38
+ return null;
39
+ }
40
+ const value = importPath.slice(prefix.length, importPath.length - suffix.length);
41
+ return target.replace(/\*/g, value);
46
42
  };
47
43
  const getPatternScore = (pattern) => {
48
- const wildcardIndex = pattern.indexOf('*');
49
- if (wildcardIndex < 0) return Number.MAX_SAFE_INTEGER;
50
- return pattern.slice(0, wildcardIndex).length;
44
+ const wildcardIndex = pattern.indexOf('*');
45
+ if (wildcardIndex < 0)
46
+ return Number.MAX_SAFE_INTEGER;
47
+ return pattern.slice(0, wildcardIndex).length;
51
48
  };
52
49
  const trimSourceExtension = (value) => {
53
- return value.replace(sourceExtensions, '');
50
+ return value.replace(sourceExtensions, '');
54
51
  };
55
52
  const toSourceRelativePath = (sourceRoot, file) => {
56
- const relative = path.relative(sourceRoot, file);
57
- if (relative.startsWith('..') || path.isAbsolute(relative)) return null;
58
- return trimSourceExtension(toPosixPath(relative));
53
+ const relative = path.relative(sourceRoot, file);
54
+ if (relative.startsWith('..') || path.isAbsolute(relative))
55
+ return null;
56
+ return trimSourceExtension(toPosixPath(relative));
59
57
  };
60
- export function resolveTsconfigPathsSourceImport(
61
- packageRoot,
62
- sourceRoot,
63
- importPath,
64
- ) {
65
- const config = readTsconfigPaths(packageRoot);
66
- if (!config) return [];
67
- const matches = [];
68
- for (const [pattern, targets] of Object.entries(config.paths)) {
69
- for (const target of targets) {
70
- const resolved = resolvePattern(pattern, target, importPath);
71
- if (!resolved) continue;
72
- const sourceRelativePath = toSourceRelativePath(
73
- sourceRoot,
74
- path.resolve(config.baseUrl, resolved),
75
- );
76
- if (sourceRelativePath) {
77
- matches.push({
78
- path: sourceRelativePath.split(POSIX_SEPARATOR).join(path.sep),
79
- score: getPatternScore(pattern),
80
- });
81
- }
58
+ export function resolveTsconfigPathsSourceImport(packageRoot, sourceRoot, importPath) {
59
+ const config = readTsconfigPaths(packageRoot);
60
+ if (!config)
61
+ return [];
62
+ const matches = [];
63
+ for (const [pattern, targets] of Object.entries(config.paths)) {
64
+ for (const target of targets) {
65
+ const resolved = resolvePattern(pattern, target, importPath);
66
+ if (!resolved)
67
+ continue;
68
+ const sourceRelativePath = toSourceRelativePath(sourceRoot, path.resolve(config.baseUrl, resolved));
69
+ if (sourceRelativePath) {
70
+ matches.push({
71
+ path: sourceRelativePath.split(POSIX_SEPARATOR).join(path.sep),
72
+ score: getPatternScore(pattern),
73
+ });
74
+ }
75
+ }
82
76
  }
83
- }
84
- return matches.sort((a, b) => b.score - a.score).map((match) => match.path);
77
+ return matches.sort((a, b) => b.score - a.score).map((match) => match.path);
85
78
  }
@@ -1,20 +1,10 @@
1
1
  import type { NormalizedAukletConfig } from '#auklet/types';
2
- export declare function getGlobalStyleDependencies(
3
- config: NormalizedAukletConfig,
4
- ): string[];
5
- export declare function getExternalStyleDependencies(
6
- config: NormalizedAukletConfig,
7
- ): string[];
8
- export declare function getThemeStyleDependencies(
9
- config: NormalizedAukletConfig,
10
- themeName: string,
11
- ): string[];
2
+ export declare function getGlobalStyleDependencies(config: NormalizedAukletConfig): string[];
3
+ export declare function getExternalStyleDependencies(config: NormalizedAukletConfig): string[];
4
+ export declare function getThemeStyleDependencies(config: NormalizedAukletConfig, themeName: string): string[];
12
5
  export declare function getThemeNames(config: NormalizedAukletConfig): string[];
13
6
  export declare function getThemeStyleEntries(config: NormalizedAukletConfig): {
14
- themeName: string;
15
- file: string;
7
+ themeName: string;
8
+ file: string;
16
9
  }[];
17
- export declare function resolveThemeStyleFiles(
18
- config: NormalizedAukletConfig,
19
- packageRoot: string,
20
- ): Map<string, string>;
10
+ export declare function resolveThemeStyleFiles(config: NormalizedAukletConfig, packageRoot: string): Map<string, string>;
@@ -2,54 +2,51 @@ import path from 'node:path';
2
2
  import { isArray } from 'aidly';
3
3
  import { joinDependencySpecifier } from '#auklet/css/core/style/specifier';
4
4
  export function getGlobalStyleDependencies(config) {
5
- const dependencies = [];
6
- for (const [packageName, dependency] of Object.entries(
7
- config.styles.dependencies,
8
- )) {
9
- const globalDependencies = isArray(dependency.entry)
10
- ? dependency.entry
11
- : dependency.entry
12
- ? [dependency.entry]
13
- : [];
14
- for (const globalDependency of globalDependencies) {
15
- dependencies.push(joinDependencySpecifier(packageName, globalDependency));
5
+ const dependencies = [];
6
+ for (const [packageName, dependency] of Object.entries(config.styles.dependencies)) {
7
+ const globalDependencies = isArray(dependency.entry)
8
+ ? dependency.entry
9
+ : dependency.entry
10
+ ? [dependency.entry]
11
+ : [];
12
+ for (const globalDependency of globalDependencies) {
13
+ dependencies.push(joinDependencySpecifier(packageName, globalDependency));
14
+ }
16
15
  }
17
- }
18
- return dependencies;
16
+ return dependencies;
19
17
  }
20
18
  export function getExternalStyleDependencies(config) {
21
- return getGlobalStyleDependencies(config);
19
+ return getGlobalStyleDependencies(config);
22
20
  }
23
21
  export function getThemeStyleDependencies(config, themeName) {
24
- const dependencies = [];
25
- for (const [packageName, dependency] of Object.entries(
26
- config.styles.dependencies,
27
- )) {
28
- const themeDependency = dependency.themes?.[themeName];
29
- if (!themeDependency) continue;
30
- dependencies.push(joinDependencySpecifier(packageName, themeDependency));
31
- }
32
- return dependencies;
22
+ const dependencies = [];
23
+ for (const [packageName, dependency] of Object.entries(config.styles.dependencies)) {
24
+ const themeDependency = dependency.themes?.[themeName];
25
+ if (!themeDependency)
26
+ continue;
27
+ dependencies.push(joinDependencySpecifier(packageName, themeDependency));
28
+ }
29
+ return dependencies;
33
30
  }
34
31
  export function getThemeNames(config) {
35
- const names = new Set(Object.keys(config.styles.themes));
36
- for (const dependency of Object.values(config.styles.dependencies)) {
37
- for (const themeName of Object.keys(dependency.themes ?? {})) {
38
- names.add(themeName);
32
+ const names = new Set(Object.keys(config.styles.themes));
33
+ for (const dependency of Object.values(config.styles.dependencies)) {
34
+ for (const themeName of Object.keys(dependency.themes ?? {})) {
35
+ names.add(themeName);
36
+ }
39
37
  }
40
- }
41
- return [...names];
38
+ return [...names];
42
39
  }
43
40
  export function getThemeStyleEntries(config) {
44
- return Object.entries(config.styles.themes).map(([themeName, file]) => ({
45
- themeName,
46
- file,
47
- }));
41
+ return Object.entries(config.styles.themes).map(([themeName, file]) => ({
42
+ themeName,
43
+ file,
44
+ }));
48
45
  }
49
46
  export function resolveThemeStyleFiles(config, packageRoot) {
50
- const themeFiles = new Map();
51
- for (const { themeName, file } of getThemeStyleEntries(config)) {
52
- themeFiles.set(themeName, path.resolve(packageRoot, file));
53
- }
54
- return themeFiles;
47
+ const themeFiles = new Map();
48
+ for (const { themeName, file } of getThemeStyleEntries(config)) {
49
+ themeFiles.set(themeName, path.resolve(packageRoot, file));
50
+ }
51
+ return themeFiles;
55
52
  }