auklet 0.0.16 → 0.0.18
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/README.md +37 -1
- package/dist/build/bundleConfig.d.ts +1 -4
- package/dist/build/bundleConfig.js +59 -71
- package/dist/build/cleanOutput.d.ts +2 -8
- package/dist/build/cleanOutput.js +7 -7
- package/dist/build/moduleConfig.d.ts +1 -3
- package/dist/build/moduleConfig.js +21 -40
- package/dist/build/runTsdown.d.ts +2 -5
- package/dist/build/runTsdown.js +18 -23
- package/dist/build/tsdown/common.d.ts +17 -28
- package/dist/build/tsdown/common.js +22 -25
- package/dist/build/tsdown/context.d.ts +16 -20
- package/dist/build/tsdown/context.js +41 -45
- package/dist/build/tsdown/define.d.ts +2 -7
- package/dist/build/tsdown/define.js +13 -22
- package/dist/build/tsdown/dependencies.d.ts +4 -12
- package/dist/build/tsdown/dependencies.js +47 -51
- package/dist/build/tsdown/entries.d.ts +4 -6
- package/dist/build/tsdown/entries.js +39 -38
- package/dist/build/tsdown/parseModuleId.d.ts +4 -4
- package/dist/build/tsdown/parseModuleId.js +92 -77
- package/dist/build/tsdown/types.d.ts +24 -31
- package/dist/build/tsdownConfig.js +1 -4
- package/dist/config.d.ts +37 -37
- package/dist/config.js +38 -41
- package/dist/configLoader.d.ts +2 -7
- package/dist/configLoader.js +59 -64
- package/dist/css/config.js +8 -8
- package/dist/css/constants.d.ts +7 -7
- package/dist/css/constants.js +1 -1
- package/dist/css/core/resolvers/packageImports.d.ts +1 -5
- package/dist/css/core/resolvers/packageImports.js +35 -40
- package/dist/css/core/resolvers/relative.d.ts +1 -4
- package/dist/css/core/resolvers/relative.js +3 -2
- package/dist/css/core/resolvers/tsconfigPaths.d.ts +1 -5
- package/dist/css/core/resolvers/tsconfigPaths.js +59 -66
- package/dist/css/core/style/dependencies.d.ts +6 -16
- package/dist/css/core/style/dependencies.js +35 -38
- package/dist/css/core/style/entries.d.ts +35 -58
- package/dist/css/core/style/entries.js +22 -33
- package/dist/css/core/style/files.d.ts +2 -7
- package/dist/css/core/style/files.js +11 -11
- package/dist/css/core/style/specifier.d.ts +41 -8
- package/dist/css/core/style/specifier.js +107 -18
- package/dist/css/core/styleImports/autoImportRules.d.ts +13 -0
- package/dist/css/core/styleImports/autoImportRules.js +68 -0
- package/dist/css/core/styleImports/collector.d.ts +12 -25
- package/dist/css/core/styleImports/collector.js +101 -206
- package/dist/css/core/styleImports/sourceImportExportAnalyzer.d.ts +11 -0
- package/dist/css/core/styleImports/sourceImportExportAnalyzer.js +173 -0
- package/dist/css/core/styleModuleEntryPlanner.d.ts +21 -24
- package/dist/css/core/styleModuleEntryPlanner.js +45 -62
- package/dist/css/core/stylePackageContext.d.ts +16 -20
- package/dist/css/core/stylePackageContext.js +33 -49
- package/dist/css/core/styleProcessor.js +105 -104
- package/dist/css/core/workspaceStyleResolver.d.ts +8 -15
- package/dist/css/core/workspaceStyleResolver.js +34 -76
- package/dist/css/production/builder.d.ts +9 -16
- package/dist/css/production/builder.js +51 -57
- package/dist/css/production/format/entryWriter.js +36 -49
- package/dist/css/production/format/externalWriter.js +21 -33
- package/dist/css/production/format/{componentWriter.d.ts → moduleEntryWriter.d.ts} +1 -1
- package/dist/css/production/format/moduleEntryWriter.js +48 -0
- package/dist/css/production/format/moduleWriter.js +23 -26
- package/dist/css/production/format/shared.d.ts +8 -15
- package/dist/css/production/format/shared.js +4 -9
- package/dist/css/production/format/sourceWriter.js +11 -11
- package/dist/css/production/format/themeWriter.js +56 -71
- package/dist/css/production/moduleOutputWriter.d.ts +18 -21
- package/dist/css/production/moduleOutputWriter.js +58 -67
- package/dist/css/production/packageEntryWriter.d.ts +12 -15
- package/dist/css/production/packageEntryWriter.js +42 -45
- package/dist/css/vite/hmr.d.ts +11 -11
- package/dist/css/vite/hmr.js +93 -109
- package/dist/css/vite/moduleGraph/devDependency.d.ts +7 -12
- package/dist/css/vite/moduleGraph/devDependency.js +8 -8
- package/dist/css/vite/moduleGraph/graph.d.ts +20 -23
- package/dist/css/vite/moduleGraph/graph.js +51 -50
- package/dist/css/vite/moduleGraph/loadResult.d.ts +3 -5
- package/dist/css/vite/moduleGraph/loadResult.js +7 -9
- package/dist/css/vite/moduleGraph/packageSource/monorepo.d.ts +16 -7
- package/dist/css/vite/moduleGraph/packageSource/monorepo.js +60 -68
- package/dist/css/vite/moduleGraph/packageSource/singlePackage.d.ts +21 -0
- package/dist/css/vite/moduleGraph/packageSource/singlePackage.js +63 -0
- package/dist/css/vite/moduleGraph/packageSource/types.d.ts +7 -7
- package/dist/css/vite/moduleGraph/requestCache.d.ts +46 -57
- package/dist/css/vite/moduleGraph/requestCache.js +53 -51
- package/dist/css/vite/moduleGraph/styleCodeFactory.d.ts +15 -18
- package/dist/css/vite/moduleGraph/styleCodeFactory.js +173 -264
- package/dist/css/vite/moduleGraph/styleId.d.ts +3 -6
- package/dist/css/vite/moduleGraph/styleId.js +12 -11
- package/dist/css/vite/moduleGraph/types.d.ts +11 -14
- package/dist/css/vite/vitePlugin.d.ts +16 -20
- package/dist/css/vite/vitePlugin.js +117 -109
- package/dist/css/watch/watcher.d.ts +15 -21
- package/dist/css/watch/watcher.js +84 -81
- package/dist/index.d.ts +3 -25
- package/dist/index.js +2 -9
- package/dist/types.d.ts +59 -62
- package/dist/utils.d.ts +3 -7
- package/dist/utils.js +50 -47
- package/package.json +31 -33
- package/dist/css/core/styleImports/sourceReference.d.ts +0 -19
- package/dist/css/core/styleImports/sourceReference.js +0 -193
- package/dist/css/production/format/componentWriter.js +0 -71
|
@@ -5,57 +5,58 @@ import { moduleStyleBuildConfig } from '#auklet/css/config';
|
|
|
5
5
|
import { parsePackageStyleId } from '#auklet/css/vite/moduleGraph/styleId';
|
|
6
6
|
import { StyleCodeFactory } from '#auklet/css/vite/moduleGraph/styleCodeFactory';
|
|
7
7
|
import { ModuleStyleGraphRequestCache } from '#auklet/css/vite/moduleGraph/requestCache';
|
|
8
|
-
import {
|
|
8
|
+
import { MonorepoPackageSource } from '#auklet/css/vite/moduleGraph/packageSource/monorepo';
|
|
9
|
+
import { SinglePackageSource } from '#auklet/css/vite/moduleGraph/packageSource/singlePackage';
|
|
9
10
|
import { normalizeFileKey } from '#auklet/utils';
|
|
10
11
|
// package style graph 的对外门面,负责 package source、watch 边界和请求分发。
|
|
11
12
|
export class ModuleStyleGraph {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
13
|
+
config;
|
|
14
|
+
packageSource;
|
|
15
|
+
styleCodeFactory;
|
|
16
|
+
loadAukletConfig;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.config = options.config ?? moduleStyleBuildConfig;
|
|
19
|
+
this.styleCodeFactory = new StyleCodeFactory(this.config);
|
|
20
|
+
this.loadAukletConfig = options.loadAukletConfig ?? loadAukletConfig;
|
|
21
|
+
this.packageSource =
|
|
22
|
+
(options.mode ?? 'package') === 'monorepo'
|
|
23
|
+
? new MonorepoPackageSource({
|
|
24
|
+
root: normalizeFileKey(options.root),
|
|
25
|
+
packagesDir: options.packagesDir ?? 'packages',
|
|
26
|
+
styleExtensions: this.config.styleExtensions,
|
|
27
|
+
})
|
|
28
|
+
: new SinglePackageSource({
|
|
29
|
+
root: normalizeFileKey(options.root),
|
|
30
|
+
styleExtensions: this.config.styleExtensions,
|
|
31
|
+
loadAukletConfig: this.loadAukletConfig,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
parsePackageStyleId(id) {
|
|
35
|
+
return parsePackageStyleId(id, this.getPackageNames());
|
|
36
|
+
}
|
|
37
|
+
isSourceGraphFile(file) {
|
|
38
|
+
return this.packageSource.isSourceGraphFile(file);
|
|
39
|
+
}
|
|
40
|
+
isStyleConfigFile(file) {
|
|
41
|
+
return normalizeFileKey(file).endsWith(aukletConfigFile);
|
|
42
|
+
}
|
|
43
|
+
isStyleFile(file) {
|
|
44
|
+
return this.config.styleExtensions.includes(path.extname(file));
|
|
45
|
+
}
|
|
46
|
+
getPackageNames() {
|
|
47
|
+
return this.packageSource.getPackageNames();
|
|
48
|
+
}
|
|
49
|
+
getWatchRoots() {
|
|
50
|
+
return this.packageSource.getWatchRoots();
|
|
51
|
+
}
|
|
52
|
+
createPackageStyleCode(parsed) {
|
|
53
|
+
return this.styleCodeFactory.createPackageStyleCode(parsed, this.createRequestCache());
|
|
54
|
+
}
|
|
55
|
+
createRequestCache() {
|
|
56
|
+
return new ModuleStyleGraphRequestCache({
|
|
57
|
+
packageSource: this.packageSource,
|
|
58
|
+
config: this.config,
|
|
59
|
+
loadAukletConfig: this.loadAukletConfig,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
61
62
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { PackageStyleLoadResult } from '#auklet/css/vite/moduleGraph/types';
|
|
2
|
-
export declare function mergeLoadResults(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
code: string;
|
|
6
|
-
watchFiles: string[];
|
|
2
|
+
export declare function mergeLoadResults(...results: Array<PackageStyleLoadResult>): {
|
|
3
|
+
code: string;
|
|
4
|
+
watchFiles: string[];
|
|
7
5
|
};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
// 合并递归 style graph 加载结果,同时保留 CSS 顺序并去重 watch files。
|
|
2
2
|
export function mergeLoadResults(...results) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
),
|
|
11
|
-
};
|
|
3
|
+
return {
|
|
4
|
+
code: results
|
|
5
|
+
.map((result) => result.code)
|
|
6
|
+
.filter((code) => code.trim())
|
|
7
|
+
.join('\n'),
|
|
8
|
+
watchFiles: Array.from(new Set(results.flatMap((result) => result.watchFiles))),
|
|
9
|
+
};
|
|
12
10
|
}
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import type { StylePackageSource } from '#auklet/css/vite/moduleGraph/packageSource/types';
|
|
1
|
+
import type { StylePackageInfo, StylePackageSource } from '#auklet/css/vite/moduleGraph/packageSource/types';
|
|
2
2
|
export type MonorepoPackageSourceOptions = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
root: string;
|
|
4
|
+
packagesDir: string;
|
|
5
|
+
styleExtensions: Array<string>;
|
|
6
6
|
};
|
|
7
|
-
export declare
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export declare class MonorepoPackageSource implements StylePackageSource {
|
|
8
|
+
private readonly options;
|
|
9
|
+
private packages?;
|
|
10
|
+
private packageNames?;
|
|
11
|
+
private readonly root;
|
|
12
|
+
constructor(options: MonorepoPackageSourceOptions);
|
|
13
|
+
getPackages(): StylePackageInfo[];
|
|
14
|
+
getPackageNames(): string[];
|
|
15
|
+
isKnownPackageName(packageName: string): boolean;
|
|
16
|
+
isSourceGraphFile(file: string): boolean;
|
|
17
|
+
getWatchRoots(): Promise<string[]>;
|
|
18
|
+
}
|
|
@@ -1,77 +1,69 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { aukletConfigFile } from '#auklet/config';
|
|
4
|
-
import {
|
|
4
|
+
import { SOURCE_MODULE_RE } from '#auklet/css/constants';
|
|
5
5
|
import { normalizeFileKey, toWatchPath } from '#auklet/utils';
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
6
|
+
export class MonorepoPackageSource {
|
|
7
|
+
options;
|
|
8
|
+
packages;
|
|
9
|
+
packageNames;
|
|
10
|
+
root;
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.options = options;
|
|
13
|
+
this.root = normalizeFileKey(options.root);
|
|
14
|
+
}
|
|
15
|
+
getPackages() {
|
|
16
|
+
if (this.packages)
|
|
17
|
+
return this.packages;
|
|
18
|
+
const packagesRoot = path.join(this.root, this.options.packagesDir);
|
|
19
|
+
if (!fs.existsSync(packagesRoot)) {
|
|
20
|
+
this.packages = [];
|
|
21
|
+
return this.packages;
|
|
22
|
+
}
|
|
23
|
+
this.packages = fs
|
|
24
|
+
.readdirSync(packagesRoot, { withFileTypes: true })
|
|
25
|
+
.filter((entry) => entry.isDirectory())
|
|
26
|
+
.flatMap((entry) => {
|
|
27
|
+
const packageRoot = path.join(packagesRoot, entry.name);
|
|
28
|
+
const packageJsonPath = path.join(packageRoot, 'package.json');
|
|
29
|
+
if (!fs.existsSync(packageJsonPath))
|
|
30
|
+
return [];
|
|
31
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
32
|
+
if (!pkg.name)
|
|
33
|
+
return [];
|
|
34
|
+
return [
|
|
35
|
+
{
|
|
36
|
+
packageName: pkg.name,
|
|
37
|
+
packageRoot,
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
});
|
|
41
|
+
return this.packages;
|
|
42
|
+
}
|
|
43
|
+
getPackageNames() {
|
|
44
|
+
this.packageNames ??= this.getPackages().map((item) => item.packageName);
|
|
45
|
+
return this.packageNames;
|
|
46
|
+
}
|
|
47
|
+
isKnownPackageName(packageName) {
|
|
48
|
+
return this.getPackageNames().includes(packageName);
|
|
49
|
+
}
|
|
50
|
+
isSourceGraphFile(file) {
|
|
51
|
+
const normalizedFile = normalizeFileKey(file);
|
|
52
|
+
const packagesRoot = normalizeFileKey(path.join(this.root, this.options.packagesDir));
|
|
53
|
+
if (!normalizedFile.startsWith(`${packagesRoot}/`)) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if (normalizedFile.endsWith(aukletConfigFile))
|
|
57
|
+
return true;
|
|
58
|
+
if (SOURCE_MODULE_RE.test(normalizedFile))
|
|
59
|
+
return true;
|
|
60
|
+
return this.options.styleExtensions.some((extension) => normalizedFile.endsWith(extension));
|
|
27
61
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
.filter((entry) => entry.isDirectory())
|
|
31
|
-
.flatMap((entry) => {
|
|
32
|
-
const packageRoot = path.join(packagesRoot, entry.name);
|
|
33
|
-
const packageJsonPath = path.join(packageRoot, 'package.json');
|
|
34
|
-
if (!fs.existsSync(packageJsonPath)) return [];
|
|
35
|
-
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
36
|
-
if (!pkg.name) return [];
|
|
62
|
+
async getWatchRoots() {
|
|
63
|
+
const packagesRoot = path.join(this.root, this.options.packagesDir);
|
|
37
64
|
return [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
packageRoot,
|
|
41
|
-
},
|
|
65
|
+
toWatchPath(packagesRoot, '*', 'src'),
|
|
66
|
+
toWatchPath(packagesRoot, '*', aukletConfigFile),
|
|
42
67
|
];
|
|
43
|
-
});
|
|
44
|
-
return this.packages;
|
|
45
|
-
}
|
|
46
|
-
getPackageNames() {
|
|
47
|
-
this.packageNames ??= this.getPackages().map((item) => item.packageName);
|
|
48
|
-
return this.packageNames;
|
|
49
|
-
}
|
|
50
|
-
isKnownPackageName(packageName) {
|
|
51
|
-
return this.getPackageNames().includes(packageName);
|
|
52
|
-
}
|
|
53
|
-
isSourceGraphFile(file) {
|
|
54
|
-
const normalizedFile = normalizeFileKey(file);
|
|
55
|
-
const packagesRoot = normalizeFileKey(
|
|
56
|
-
path.join(this.workspaceRoot, this.options.packagesDir),
|
|
57
|
-
);
|
|
58
|
-
if (!normalizedFile.startsWith(`${packagesRoot}/`)) {
|
|
59
|
-
return false;
|
|
60
68
|
}
|
|
61
|
-
if (normalizedFile.endsWith(aukletConfigFile)) return true;
|
|
62
|
-
if (SOURCE_COMPONENT_MODULE_RE.test(normalizedFile)) return true;
|
|
63
|
-
return this.options.styleExtensions.some((extension) =>
|
|
64
|
-
normalizedFile.endsWith(extension),
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
getWatchRoots() {
|
|
68
|
-
const packagesRoot = path.join(
|
|
69
|
-
this.workspaceRoot,
|
|
70
|
-
this.options.packagesDir,
|
|
71
|
-
);
|
|
72
|
-
return [
|
|
73
|
-
toWatchPath(packagesRoot, '*', 'src'),
|
|
74
|
-
toWatchPath(packagesRoot, '*', aukletConfigFile),
|
|
75
|
-
];
|
|
76
|
-
}
|
|
77
69
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { StylePackageInfo, StylePackageSource } from '#auklet/css/vite/moduleGraph/packageSource/types';
|
|
2
|
+
import type { LoadAukletConfig } from '#auklet/css/vite/moduleGraph/types';
|
|
3
|
+
export type SinglePackageSourceOptions = {
|
|
4
|
+
root: string;
|
|
5
|
+
styleExtensions: Array<string>;
|
|
6
|
+
loadAukletConfig?: LoadAukletConfig;
|
|
7
|
+
};
|
|
8
|
+
export declare class SinglePackageSource implements StylePackageSource {
|
|
9
|
+
private readonly options;
|
|
10
|
+
private packageInfo?;
|
|
11
|
+
private readonly root;
|
|
12
|
+
private readonly loadAukletConfig;
|
|
13
|
+
constructor(options: SinglePackageSourceOptions);
|
|
14
|
+
getPackages(): StylePackageInfo[];
|
|
15
|
+
getPackageNames(): string[];
|
|
16
|
+
isKnownPackageName(packageName: string): boolean;
|
|
17
|
+
isSourceGraphFile(file: string): boolean;
|
|
18
|
+
getWatchRoots(): Promise<string[]>;
|
|
19
|
+
private getPackageInfo;
|
|
20
|
+
private isInsidePackage;
|
|
21
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { aukletConfigFile, normalizeAukletConfig } from '#auklet/config';
|
|
4
|
+
import { loadAukletConfig } from '#auklet/configLoader';
|
|
5
|
+
import { SOURCE_MODULE_RE } from '#auklet/css/constants';
|
|
6
|
+
import { normalizeFileKey, toWatchPath } from '#auklet/utils';
|
|
7
|
+
export class SinglePackageSource {
|
|
8
|
+
options;
|
|
9
|
+
packageInfo;
|
|
10
|
+
root;
|
|
11
|
+
loadAukletConfig;
|
|
12
|
+
constructor(options) {
|
|
13
|
+
this.options = options;
|
|
14
|
+
this.root = normalizeFileKey(options.root);
|
|
15
|
+
this.loadAukletConfig = options.loadAukletConfig ?? loadAukletConfig;
|
|
16
|
+
}
|
|
17
|
+
getPackages() {
|
|
18
|
+
return [this.getPackageInfo()];
|
|
19
|
+
}
|
|
20
|
+
getPackageNames() {
|
|
21
|
+
return [this.getPackageInfo().packageName];
|
|
22
|
+
}
|
|
23
|
+
isKnownPackageName(packageName) {
|
|
24
|
+
return packageName === this.getPackageInfo().packageName;
|
|
25
|
+
}
|
|
26
|
+
isSourceGraphFile(file) {
|
|
27
|
+
const normalizedFile = normalizeFileKey(file);
|
|
28
|
+
if (!this.isInsidePackage(normalizedFile))
|
|
29
|
+
return false;
|
|
30
|
+
if (normalizedFile.endsWith(aukletConfigFile))
|
|
31
|
+
return true;
|
|
32
|
+
if (SOURCE_MODULE_RE.test(normalizedFile))
|
|
33
|
+
return true;
|
|
34
|
+
return this.options.styleExtensions.some((extension) => normalizedFile.endsWith(extension));
|
|
35
|
+
}
|
|
36
|
+
async getWatchRoots() {
|
|
37
|
+
const normalizedConfig = normalizeAukletConfig(await this.loadAukletConfig(this.root, { cacheBust: true }));
|
|
38
|
+
return [
|
|
39
|
+
toWatchPath(this.root, normalizedConfig.source),
|
|
40
|
+
toWatchPath(this.root, aukletConfigFile),
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
getPackageInfo() {
|
|
44
|
+
if (this.packageInfo)
|
|
45
|
+
return this.packageInfo;
|
|
46
|
+
const packageJsonPath = path.join(this.root, 'package.json');
|
|
47
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
48
|
+
throw new Error(`[auklet:css] package mode requires a package.json at ${this.root}.`);
|
|
49
|
+
}
|
|
50
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
51
|
+
if (!pkg.name) {
|
|
52
|
+
throw new Error(`[auklet:css] package mode requires package.json#name at ${this.root}.`);
|
|
53
|
+
}
|
|
54
|
+
this.packageInfo = {
|
|
55
|
+
packageName: pkg.name,
|
|
56
|
+
packageRoot: this.root,
|
|
57
|
+
};
|
|
58
|
+
return this.packageInfo;
|
|
59
|
+
}
|
|
60
|
+
isInsidePackage(file) {
|
|
61
|
+
return file === this.root || file.startsWith(`${this.root}/`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export type StylePackageInfo = {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
packageName: string;
|
|
3
|
+
packageRoot: string;
|
|
4
4
|
};
|
|
5
5
|
export interface StylePackageSource {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
getPackages(): Array<StylePackageInfo>;
|
|
7
|
+
getPackageNames(): Array<string>;
|
|
8
|
+
isKnownPackageName(packageName: string): boolean;
|
|
9
|
+
isSourceGraphFile(file: string): boolean;
|
|
10
|
+
getWatchRoots(): Promise<Array<string>>;
|
|
11
11
|
}
|
|
@@ -1,67 +1,58 @@
|
|
|
1
1
|
import { StylePackageContext } from '#auklet/css/core/stylePackageContext';
|
|
2
|
-
import type {
|
|
3
|
-
ModuleStyleBuildConfig,
|
|
4
|
-
NormalizedAukletConfig,
|
|
5
|
-
ResolvedModuleStyleBuildContext,
|
|
6
|
-
} from '#auklet/types';
|
|
2
|
+
import type { ModuleStyleBuildConfig, NormalizedAukletConfig, ResolvedModuleStyleBuildContext } from '#auklet/types';
|
|
7
3
|
import type { StyleProcessor } from '#auklet/css/core/styleProcessor';
|
|
8
4
|
import type { WorkspaceStyleResolver } from '#auklet/css/core/workspaceStyleResolver';
|
|
9
5
|
import type { StylePackageSource } from '#auklet/css/vite/moduleGraph/packageSource/types';
|
|
10
|
-
import type {
|
|
11
|
-
LoadAukletConfig,
|
|
12
|
-
PackageStyleId,
|
|
13
|
-
} from '#auklet/css/vite/moduleGraph/types';
|
|
6
|
+
import type { LoadAukletConfig, PackageStyleId } from '#auklet/css/vite/moduleGraph/types';
|
|
14
7
|
export type PackageStyleContext = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
normalizedConfig: NormalizedAukletConfig;
|
|
9
|
+
context: ResolvedModuleStyleBuildContext;
|
|
10
|
+
packageContext: StylePackageContext;
|
|
11
|
+
packageName: string;
|
|
12
|
+
configPath: string;
|
|
13
|
+
resolver: WorkspaceStyleResolver;
|
|
14
|
+
sourceRoot: string;
|
|
15
|
+
styleProcessor: StyleProcessor;
|
|
23
16
|
};
|
|
24
17
|
export type ModuleStyleGraphRequestCacheOptions = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
packageSource: StylePackageSource;
|
|
19
|
+
config: ModuleStyleBuildConfig;
|
|
20
|
+
loadAukletConfig?: LoadAukletConfig;
|
|
28
21
|
};
|
|
29
22
|
export declare class ModuleStyleGraphRequestCache {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
| PackageStyleContext
|
|
38
|
-
| {
|
|
23
|
+
private readonly options;
|
|
24
|
+
private readonly contexts;
|
|
25
|
+
private readonly loadAukletConfig;
|
|
26
|
+
constructor(options: ModuleStyleGraphRequestCacheOptions);
|
|
27
|
+
getPackageNames(): string[];
|
|
28
|
+
isKnownPackageName(packageName: string): boolean;
|
|
29
|
+
getContext(parsed: PackageStyleId): Promise<PackageStyleContext | {
|
|
39
30
|
normalizedConfig: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
31
|
+
source: string;
|
|
32
|
+
output: string;
|
|
33
|
+
modules: boolean;
|
|
34
|
+
build: {
|
|
35
|
+
formats: Array<import("#auklet/types").PackageBuildFormat>;
|
|
36
|
+
target: import("#auklet/types").PackageBuildTarget;
|
|
37
|
+
platform: import("#auklet/types").PackageBuildPlatform;
|
|
38
|
+
banner?: string;
|
|
39
|
+
externals?: Array<string>;
|
|
40
|
+
alias?: Record<string, string>;
|
|
41
|
+
mainFields?: Array<string>;
|
|
42
|
+
globals?: Record<string, string>;
|
|
43
|
+
configureTsdown?: import("#auklet/types").ConfigureTsdown;
|
|
44
|
+
tsconfig?: string;
|
|
45
|
+
};
|
|
46
|
+
styles: {
|
|
47
|
+
themes: {};
|
|
48
|
+
dependencies: {
|
|
49
|
+
[k: string]: {
|
|
50
|
+
entry: string | string[] | undefined;
|
|
51
|
+
themes: Record<string, string> | undefined;
|
|
52
|
+
components: string | string[] | undefined;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
63
55
|
};
|
|
64
|
-
};
|
|
65
56
|
};
|
|
66
57
|
context: ResolvedModuleStyleBuildContext;
|
|
67
58
|
packageContext: StylePackageContext;
|
|
@@ -70,8 +61,6 @@ export declare class ModuleStyleGraphRequestCache {
|
|
|
70
61
|
resolver: WorkspaceStyleResolver;
|
|
71
62
|
sourceRoot: string;
|
|
72
63
|
styleProcessor: StyleProcessor;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
>;
|
|
76
|
-
private createContext;
|
|
64
|
+
} | null>;
|
|
65
|
+
private createContext;
|
|
77
66
|
}
|
|
@@ -3,55 +3,57 @@ import { aukletConfigFile, normalizeAukletConfig } from '#auklet/config';
|
|
|
3
3
|
import { loadAukletConfig } from '#auklet/configLoader';
|
|
4
4
|
import { StylePackageContext } from '#auklet/css/core/stylePackageContext';
|
|
5
5
|
export class ModuleStyleGraphRequestCache {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
6
|
+
options;
|
|
7
|
+
contexts = new Map();
|
|
8
|
+
loadAukletConfig;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.options = options;
|
|
11
|
+
this.loadAukletConfig = options.loadAukletConfig ?? loadAukletConfig;
|
|
12
|
+
}
|
|
13
|
+
getPackageNames() {
|
|
14
|
+
return this.options.packageSource.getPackageNames();
|
|
15
|
+
}
|
|
16
|
+
isKnownPackageName(packageName) {
|
|
17
|
+
return this.options.packageSource.isKnownPackageName(packageName);
|
|
18
|
+
}
|
|
19
|
+
async getContext(parsed) {
|
|
20
|
+
const cachedContext = this.contexts.get(parsed.packageName);
|
|
21
|
+
if (cachedContext)
|
|
22
|
+
return cachedContext;
|
|
23
|
+
const context = this.createContext(parsed);
|
|
24
|
+
this.contexts.set(parsed.packageName, context);
|
|
25
|
+
return context;
|
|
26
|
+
}
|
|
27
|
+
async createContext(parsed) {
|
|
28
|
+
const stylePackage = this.options.packageSource
|
|
29
|
+
.getPackages()
|
|
30
|
+
.find((item) => item.packageName === parsed.packageName);
|
|
31
|
+
if (!stylePackage)
|
|
32
|
+
return null;
|
|
33
|
+
const packageRoot = stylePackage.packageRoot;
|
|
34
|
+
const rawConfig = await this.loadAukletConfig(packageRoot, {
|
|
35
|
+
cacheBust: true,
|
|
36
|
+
});
|
|
37
|
+
const normalizedConfig = normalizeAukletConfig(rawConfig);
|
|
38
|
+
const context = {
|
|
39
|
+
packageRoot,
|
|
40
|
+
sourceDir: normalizedConfig.source,
|
|
41
|
+
outputDir: normalizedConfig.output,
|
|
42
|
+
};
|
|
43
|
+
const packageContext = new StylePackageContext({
|
|
44
|
+
config: this.options.config,
|
|
45
|
+
context,
|
|
46
|
+
normalizedConfig,
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
normalizedConfig,
|
|
50
|
+
context,
|
|
51
|
+
packageContext,
|
|
52
|
+
packageName: parsed.packageName,
|
|
53
|
+
configPath: path.join(packageRoot, aukletConfigFile),
|
|
54
|
+
resolver: packageContext.resolver,
|
|
55
|
+
sourceRoot: packageContext.sourceRoot,
|
|
56
|
+
styleProcessor: packageContext.styleProcessor,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
57
59
|
}
|