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
|
@@ -6,63 +6,57 @@ import { ModuleStyleOutputWriter } from '#auklet/css/production/moduleOutputWrit
|
|
|
6
6
|
import { PackageStyleEntryWriter } from '#auklet/css/production/packageEntryWriter';
|
|
7
7
|
import { toPosixPath } from '#auklet/utils';
|
|
8
8
|
export class ModuleStyleBuilder {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
async build(options = {}) {
|
|
23
|
-
const rawConfig = options.aukletConfig ?? this.context.aukletConfig ?? {};
|
|
24
|
-
const normalizedConfig = normalizeAukletConfig(rawConfig);
|
|
25
|
-
const logger = options.logger ?? this.logger;
|
|
26
|
-
const context = this.createBuildContext(normalizedConfig);
|
|
27
|
-
const packageContext = this.createPackageContext(context, normalizedConfig);
|
|
28
|
-
const writerOptions = {
|
|
29
|
-
config: this.config,
|
|
30
|
-
context,
|
|
31
|
-
packageContext,
|
|
32
|
-
};
|
|
33
|
-
const packageWriter = new PackageStyleEntryWriter(writerOptions);
|
|
34
|
-
const packageOutput = packageWriter.write();
|
|
35
|
-
const outputs = packageOutput ? [packageOutput] : [];
|
|
36
|
-
logger?.log?.(`[auklet:css] build ${path.basename(context.packageRoot)}`);
|
|
37
|
-
if (normalizedConfig.modules) {
|
|
38
|
-
outputs.push(...new ModuleStyleOutputWriter(writerOptions).write());
|
|
9
|
+
config;
|
|
10
|
+
context;
|
|
11
|
+
logger;
|
|
12
|
+
constructor(context = {}, config = moduleStyleBuildConfig) {
|
|
13
|
+
this.config = config;
|
|
14
|
+
this.context = {
|
|
15
|
+
packageRoot: process.cwd(),
|
|
16
|
+
source: context.source,
|
|
17
|
+
output: context.output,
|
|
18
|
+
...context,
|
|
19
|
+
};
|
|
20
|
+
this.logger = context.logger;
|
|
39
21
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
22
|
+
async build(options = {}) {
|
|
23
|
+
const rawConfig = options.aukletConfig ?? this.context.aukletConfig ?? {};
|
|
24
|
+
const normalizedConfig = normalizeAukletConfig(rawConfig);
|
|
25
|
+
const logger = options.logger ?? this.logger;
|
|
26
|
+
const context = this.createBuildContext(normalizedConfig);
|
|
27
|
+
const packageContext = this.createPackageContext(context, normalizedConfig);
|
|
28
|
+
const writerOptions = {
|
|
29
|
+
config: this.config,
|
|
30
|
+
context,
|
|
31
|
+
packageContext,
|
|
32
|
+
};
|
|
33
|
+
const packageWriter = new PackageStyleEntryWriter(writerOptions);
|
|
34
|
+
const packageOutput = packageWriter.write();
|
|
35
|
+
const outputs = packageOutput ? [packageOutput] : [];
|
|
36
|
+
logger?.log?.(`[auklet:css] build ${path.basename(context.packageRoot)}`);
|
|
37
|
+
if (normalizedConfig.modules) {
|
|
38
|
+
outputs.push(...new ModuleStyleOutputWriter(writerOptions).write());
|
|
39
|
+
}
|
|
40
|
+
this.logOutputs(context, packageContext.styleFiles, outputs, logger);
|
|
41
|
+
}
|
|
42
|
+
logOutputs(context, styleFiles, outputs, logger) {
|
|
43
|
+
logger?.log?.(`[auklet:css] ${styleFiles.length} source style file(s), ${outputs.length} output entry file(s)`);
|
|
44
|
+
for (const output of outputs) {
|
|
45
|
+
logger?.log?.(`[auklet:css] + ${toPosixPath(path.relative(context.packageRoot, output))}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
createBuildContext(config) {
|
|
49
|
+
return {
|
|
50
|
+
packageRoot: this.context.packageRoot,
|
|
51
|
+
sourceDir: this.context.source ?? config.source,
|
|
52
|
+
outputDir: this.context.output ?? config.output,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
createPackageContext(context, normalizedConfig) {
|
|
56
|
+
return new StylePackageContext({
|
|
57
|
+
config: this.config,
|
|
58
|
+
context,
|
|
59
|
+
normalizedConfig,
|
|
60
|
+
});
|
|
52
61
|
}
|
|
53
|
-
}
|
|
54
|
-
createBuildContext(config) {
|
|
55
|
-
return {
|
|
56
|
-
packageRoot: this.context.packageRoot,
|
|
57
|
-
sourceDir: this.context.source ?? config.source,
|
|
58
|
-
outputDir: this.context.output ?? config.output,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
createPackageContext(context, normalizedConfig) {
|
|
62
|
-
return new StylePackageContext({
|
|
63
|
-
config: this.config,
|
|
64
|
-
context,
|
|
65
|
-
normalizedConfig,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
62
|
}
|
|
@@ -1,55 +1,42 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { createStyleEntryParts } from '#auklet/css/core/style/entries';
|
|
3
|
-
import {
|
|
4
|
-
writeStyleFile,
|
|
5
|
-
toRelativeImportSpecifier,
|
|
6
|
-
} from '#auklet/css/production/format/shared';
|
|
3
|
+
import { writeStyleFile, toRelativeImportSpecifier, } from '#auklet/css/production/format/shared';
|
|
7
4
|
export class StyleEntryWriter {
|
|
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
|
-
toRelativeImportSpecifier(styleDir, themeStyle),
|
|
40
|
-
);
|
|
5
|
+
config;
|
|
6
|
+
packageContext;
|
|
7
|
+
styleProcessor;
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.config = options.config;
|
|
10
|
+
this.packageContext = options.packageContext;
|
|
11
|
+
this.styleProcessor = options.packageContext.styleProcessor;
|
|
12
|
+
}
|
|
13
|
+
write(outRoot, themeStyles, moduleStyle) {
|
|
14
|
+
const target = path.join(outRoot, this.config.output.styleDir, this.config.output.indexStyleFile);
|
|
15
|
+
const root = this.styleProcessor.createRoot();
|
|
16
|
+
const styleDir = path.dirname(target);
|
|
17
|
+
for (const part of createStyleEntryParts(this.packageContext.normalizedConfig)) {
|
|
18
|
+
if (part.type === 'dependencies') {
|
|
19
|
+
for (const specifier of part.specifiers) {
|
|
20
|
+
this.styleProcessor.appendImportRule(root, specifier);
|
|
21
|
+
}
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (part.type === 'themes') {
|
|
25
|
+
for (const themeName of part.themeNames) {
|
|
26
|
+
const themeStyle = themeStyles.get(themeName);
|
|
27
|
+
if (!themeStyle)
|
|
28
|
+
continue;
|
|
29
|
+
this.styleProcessor.appendImportRule(root, toRelativeImportSpecifier(styleDir, themeStyle));
|
|
30
|
+
}
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (moduleStyle) {
|
|
34
|
+
this.styleProcessor.appendImportRule(root, toRelativeImportSpecifier(styleDir, moduleStyle));
|
|
35
|
+
}
|
|
41
36
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
root,
|
|
47
|
-
toRelativeImportSpecifier(styleDir, moduleStyle),
|
|
48
|
-
);
|
|
49
|
-
}
|
|
37
|
+
if (!root.nodes?.length)
|
|
38
|
+
return null;
|
|
39
|
+
writeStyleFile(target, this.styleProcessor.stringify(root));
|
|
40
|
+
return target;
|
|
50
41
|
}
|
|
51
|
-
if (!root.nodes?.length) return null;
|
|
52
|
-
writeStyleFile(target, this.styleProcessor.stringify(root));
|
|
53
|
-
return target;
|
|
54
|
-
}
|
|
55
42
|
}
|
|
@@ -1,38 +1,26 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { createExternalEntryParts } from '#auklet/css/core/style/entries';
|
|
3
|
-
import { writeStyleFile } from '#auklet/css/production/format/shared';
|
|
3
|
+
import { writeStyleFile, } from '#auklet/css/production/format/shared';
|
|
4
4
|
export class ExternalStyleWriter {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
for (const specifier of part.specifiers) {
|
|
26
|
-
this.styleProcessor.appendImportRule(
|
|
27
|
-
root,
|
|
28
|
-
this.resolver.toExternalStyleSpecifier(specifier, outRoot),
|
|
29
|
-
);
|
|
30
|
-
}
|
|
5
|
+
config;
|
|
6
|
+
packageContext;
|
|
7
|
+
resolver;
|
|
8
|
+
styleProcessor;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.config = options.config;
|
|
11
|
+
this.packageContext = options.packageContext;
|
|
12
|
+
this.resolver = options.packageContext.resolver;
|
|
13
|
+
this.styleProcessor = options.packageContext.styleProcessor;
|
|
14
|
+
}
|
|
15
|
+
write(outRoot) {
|
|
16
|
+
const target = path.join(outRoot, this.config.output.styleDir, this.config.output.externalStyleFile);
|
|
17
|
+
const root = this.styleProcessor.createRoot();
|
|
18
|
+
for (const part of createExternalEntryParts(this.packageContext.normalizedConfig)) {
|
|
19
|
+
for (const specifier of part.specifiers) {
|
|
20
|
+
this.styleProcessor.appendImportRule(root, this.resolver.toExternalStyleSpecifier(specifier, outRoot));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
writeStyleFile(target, root.nodes?.length ? this.styleProcessor.stringify(root) : '');
|
|
24
|
+
return target;
|
|
31
25
|
}
|
|
32
|
-
writeStyleFile(
|
|
33
|
-
target,
|
|
34
|
-
root.nodes?.length ? this.styleProcessor.stringify(root) : '',
|
|
35
|
-
);
|
|
36
|
-
return target;
|
|
37
|
-
}
|
|
38
26
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ModuleStyleEntryPlan } from '#auklet/css/core/styleModuleEntryPlanner';
|
|
2
2
|
import { type FormatWriterOptions } from '#auklet/css/production/format/shared';
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class ModuleStyleEntryWriter {
|
|
4
4
|
private readonly config;
|
|
5
5
|
private readonly sourceRoot;
|
|
6
6
|
private readonly resolver;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { createOutputModuleStyleSpecifier, createOutputOwnStyleSpecifier, } from '#auklet/css/core/style/specifier';
|
|
3
|
+
import { writeStyleFile, } from '#auklet/css/production/format/shared';
|
|
4
|
+
export class ModuleStyleEntryWriter {
|
|
5
|
+
config;
|
|
6
|
+
sourceRoot;
|
|
7
|
+
resolver;
|
|
8
|
+
styleProcessor;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.config = options.config;
|
|
11
|
+
this.sourceRoot = options.packageContext.sourceRoot;
|
|
12
|
+
this.resolver = options.packageContext.resolver;
|
|
13
|
+
this.styleProcessor = options.packageContext.styleProcessor;
|
|
14
|
+
}
|
|
15
|
+
write(outRoot, entries) {
|
|
16
|
+
const outputs = [];
|
|
17
|
+
for (const entry of entries) {
|
|
18
|
+
const styleDir = path.join(outRoot, entry.sourceDir, this.config.output.styleDir);
|
|
19
|
+
const target = path.join(styleDir, this.config.output.indexStyleFile);
|
|
20
|
+
const ownImports = this.styleProcessor.collectStyleImportSpecifiers(entry.ownStyleFiles);
|
|
21
|
+
const sourceStyleSpecifiers = [
|
|
22
|
+
...this.getModuleStyleSpecifiers(entry.moduleStyleImports.filter((specifier) => !ownImports.has(specifier)), styleDir),
|
|
23
|
+
...this.getOwnStyleSpecifiers(entry.ownStyleFiles, styleDir, outRoot),
|
|
24
|
+
];
|
|
25
|
+
const root = this.styleProcessor.createRoot();
|
|
26
|
+
const seen = new Set();
|
|
27
|
+
for (const specifier of sourceStyleSpecifiers) {
|
|
28
|
+
if (seen.has(specifier))
|
|
29
|
+
continue;
|
|
30
|
+
seen.add(specifier);
|
|
31
|
+
this.styleProcessor.appendImportRule(root, this.resolver.toOutputStyleSpecifier(specifier, outRoot));
|
|
32
|
+
}
|
|
33
|
+
writeStyleFile(target, root.nodes?.length ? this.styleProcessor.stringify(root) : '');
|
|
34
|
+
outputs.push(target);
|
|
35
|
+
}
|
|
36
|
+
return outputs;
|
|
37
|
+
}
|
|
38
|
+
getModuleStyleSpecifiers(specifiers, styleDir) {
|
|
39
|
+
return specifiers.map((specifier) => createOutputModuleStyleSpecifier(specifier, styleDir));
|
|
40
|
+
}
|
|
41
|
+
getOwnStyleSpecifiers(ownStyleFiles, styleDir, outRoot) {
|
|
42
|
+
return ownStyleFiles.map((styleFile) => createOutputOwnStyleSpecifier({
|
|
43
|
+
sourceRoot: this.sourceRoot,
|
|
44
|
+
outputRoot: outRoot,
|
|
45
|
+
styleDir,
|
|
46
|
+
}, styleFile));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { writeStyleFile } from '#auklet/css/production/format/shared';
|
|
2
|
+
import { writeStyleFile, } from '#auklet/css/production/format/shared';
|
|
3
3
|
export class ModuleStyleWriter {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
config;
|
|
5
|
+
packageContext;
|
|
6
|
+
styleProcessor;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.config = options.config;
|
|
9
|
+
this.packageContext = options.packageContext;
|
|
10
|
+
this.styleProcessor = options.packageContext.styleProcessor;
|
|
11
|
+
}
|
|
12
|
+
write(outRoot) {
|
|
13
|
+
const target = path.join(outRoot, this.config.output.styleDir, this.config.output.moduleStyleFile);
|
|
14
|
+
const seen = new Set();
|
|
15
|
+
const root = this.styleProcessor.createRoot();
|
|
16
|
+
for (const styleFile of this.packageContext.styleFiles) {
|
|
17
|
+
const content = this.styleProcessor.readStyleFile(styleFile, seen);
|
|
18
|
+
if (content.trim()) {
|
|
19
|
+
this.styleProcessor.appendStyleContent(root, content, styleFile);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (!root.nodes?.length)
|
|
23
|
+
return null;
|
|
24
|
+
writeStyleFile(target, this.styleProcessor.stringify(root));
|
|
25
|
+
return target;
|
|
25
26
|
}
|
|
26
|
-
if (!root.nodes?.length) return null;
|
|
27
|
-
writeStyleFile(target, this.styleProcessor.stringify(root));
|
|
28
|
-
return target;
|
|
29
|
-
}
|
|
30
27
|
}
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
import type { StylePackageContext } from '#auklet/css/core/stylePackageContext';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from '#auklet/types';
|
|
6
|
-
export declare const emptyStyleFileComment =
|
|
7
|
-
'/* Empty style file kept so automated tooling can resolve this CSS path. */\n';
|
|
2
|
+
export { toRelativeImportSpecifier } from '#auklet/css/core/style/specifier';
|
|
3
|
+
import type { ModuleStyleBuildConfig, ResolvedModuleStyleBuildContext } from '#auklet/types';
|
|
4
|
+
export declare const emptyStyleFileComment = "/* Empty style file kept so automated tooling can resolve this CSS path. */\n";
|
|
8
5
|
export type FormatWriterOptions = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
config: ModuleStyleBuildConfig;
|
|
7
|
+
context: ResolvedModuleStyleBuildContext;
|
|
8
|
+
packageContext: StylePackageContext;
|
|
12
9
|
};
|
|
13
10
|
export type ThemeStyleOutput = {
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
themeName: string;
|
|
12
|
+
file: string;
|
|
16
13
|
};
|
|
17
|
-
export declare function toRelativeImportSpecifier(
|
|
18
|
-
fromDir: string,
|
|
19
|
-
file: string,
|
|
20
|
-
): string;
|
|
21
14
|
export declare function writeStyleFile(file: string, code: string): void;
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
|
|
4
|
-
export const emptyStyleFileComment =
|
|
5
|
-
'/* Empty style file kept so automated tooling can resolve this CSS path. */\n';
|
|
6
|
-
export function toRelativeImportSpecifier(fromDir, file) {
|
|
7
|
-
const relative = toPosixPath(path.relative(fromDir, file));
|
|
8
|
-
return relative.startsWith('.') ? relative : `./${relative}`;
|
|
9
|
-
}
|
|
3
|
+
export { toRelativeImportSpecifier } from '#auklet/css/core/style/specifier';
|
|
4
|
+
export const emptyStyleFileComment = '/* Empty style file kept so automated tooling can resolve this CSS path. */\n';
|
|
10
5
|
export function writeStyleFile(file, code) {
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
7
|
+
fs.writeFileSync(file, code.trim() ? code : emptyStyleFileComment);
|
|
13
8
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { writeStyleFile } from '#auklet/css/production/format/shared';
|
|
3
|
+
import { writeStyleFile, } from '#auklet/css/production/format/shared';
|
|
4
4
|
export class SourceStyleFileWriter {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
sourceRoot;
|
|
6
|
+
constructor(options) {
|
|
7
|
+
this.sourceRoot = options.packageContext.sourceRoot;
|
|
8
|
+
}
|
|
9
|
+
copy(files, outRoot) {
|
|
10
|
+
for (const sourceFile of files) {
|
|
11
|
+
const relative = path.relative(this.sourceRoot, sourceFile);
|
|
12
|
+
const target = path.join(outRoot, relative);
|
|
13
|
+
writeStyleFile(target, fs.readFileSync(sourceFile, 'utf8'));
|
|
14
|
+
}
|
|
14
15
|
}
|
|
15
|
-
}
|
|
16
16
|
}
|
|
@@ -2,80 +2,65 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { THEMES_DIR } from '#auklet/css/constants';
|
|
4
4
|
import { createThemeEntryParts } from '#auklet/css/core/style/entries';
|
|
5
|
-
import {
|
|
6
|
-
writeStyleFile,
|
|
7
|
-
toRelativeImportSpecifier,
|
|
8
|
-
} from '#auklet/css/production/format/shared';
|
|
5
|
+
import { writeStyleFile, toRelativeImportSpecifier, } from '#auklet/css/production/format/shared';
|
|
9
6
|
export class ThemeStyleWriter {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
clean(outRoot) {
|
|
19
|
-
fs.rmSync(path.join(outRoot, THEMES_DIR), {
|
|
20
|
-
recursive: true,
|
|
21
|
-
force: true,
|
|
22
|
-
});
|
|
23
|
-
fs.rmSync(path.join(outRoot, this.config.output.styleDir, THEMES_DIR), {
|
|
24
|
-
recursive: true,
|
|
25
|
-
force: true,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
writeThemeStyles(outRoot) {
|
|
29
|
-
const outputs = [];
|
|
30
|
-
const themesDir = path.join(
|
|
31
|
-
outRoot,
|
|
32
|
-
this.config.output.styleDir,
|
|
33
|
-
THEMES_DIR,
|
|
34
|
-
);
|
|
35
|
-
for (const [themeName, stylePath] of this.packageContext.themeFiles) {
|
|
36
|
-
const root = this.styleProcessor.createRoot();
|
|
37
|
-
const content = this.styleProcessor.readStyleFile(stylePath);
|
|
38
|
-
if (content.trim()) {
|
|
39
|
-
this.styleProcessor.appendStyleContent(root, content, stylePath);
|
|
40
|
-
}
|
|
41
|
-
const target = path.join(themesDir, `${themeName}.css`);
|
|
42
|
-
writeStyleFile(
|
|
43
|
-
target,
|
|
44
|
-
root.nodes?.length ? this.styleProcessor.stringify(root) : '',
|
|
45
|
-
);
|
|
46
|
-
outputs.push({ themeName, file: target });
|
|
7
|
+
config;
|
|
8
|
+
packageContext;
|
|
9
|
+
styleProcessor;
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.config = options.config;
|
|
12
|
+
this.packageContext = options.packageContext;
|
|
13
|
+
this.styleProcessor = options.packageContext.styleProcessor;
|
|
47
14
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
15
|
+
clean(outRoot) {
|
|
16
|
+
fs.rmSync(path.join(outRoot, THEMES_DIR), {
|
|
17
|
+
recursive: true,
|
|
18
|
+
force: true,
|
|
19
|
+
});
|
|
20
|
+
fs.rmSync(path.join(outRoot, this.config.output.styleDir, THEMES_DIR), {
|
|
21
|
+
recursive: true,
|
|
22
|
+
force: true,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
writeThemeStyles(outRoot) {
|
|
26
|
+
const outputs = [];
|
|
27
|
+
const themesDir = path.join(outRoot, this.config.output.styleDir, THEMES_DIR);
|
|
28
|
+
for (const [themeName, stylePath] of this.packageContext.themeFiles) {
|
|
29
|
+
const root = this.styleProcessor.createRoot();
|
|
30
|
+
const content = this.styleProcessor.readStyleFile(stylePath);
|
|
31
|
+
if (content.trim()) {
|
|
32
|
+
this.styleProcessor.appendStyleContent(root, content, stylePath);
|
|
33
|
+
}
|
|
34
|
+
const target = path.join(themesDir, `${themeName}.css`);
|
|
35
|
+
writeStyleFile(target, root.nodes?.length ? this.styleProcessor.stringify(root) : '');
|
|
36
|
+
outputs.push({ themeName, file: target });
|
|
67
37
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
38
|
+
return outputs;
|
|
39
|
+
}
|
|
40
|
+
writeThemeEntries(themeStyles, outRoot) {
|
|
41
|
+
const outputs = [];
|
|
42
|
+
const themesDir = path.join(outRoot, THEMES_DIR);
|
|
43
|
+
for (const themeName of this.packageContext.themeNames) {
|
|
44
|
+
const target = path.join(themesDir, `${themeName}.css`);
|
|
45
|
+
const root = this.styleProcessor.createRoot();
|
|
46
|
+
const targetDir = path.dirname(target);
|
|
47
|
+
const themeStyle = themeStyles.get(themeName);
|
|
48
|
+
for (const part of createThemeEntryParts(this.packageContext.normalizedConfig, themeName)) {
|
|
49
|
+
if (part.type === 'dependencies') {
|
|
50
|
+
for (const specifier of part.specifiers) {
|
|
51
|
+
this.styleProcessor.appendImportRule(root, specifier);
|
|
52
|
+
}
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (themeStyle) {
|
|
56
|
+
this.styleProcessor.appendImportRule(root, toRelativeImportSpecifier(targetDir, themeStyle));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (!root.nodes?.length)
|
|
60
|
+
continue;
|
|
61
|
+
writeStyleFile(target, this.styleProcessor.stringify(root));
|
|
62
|
+
outputs.push(target);
|
|
73
63
|
}
|
|
74
|
-
|
|
75
|
-
if (!root.nodes?.length) continue;
|
|
76
|
-
writeStyleFile(target, this.styleProcessor.stringify(root));
|
|
77
|
-
outputs.push(target);
|
|
64
|
+
return outputs;
|
|
78
65
|
}
|
|
79
|
-
return outputs;
|
|
80
|
-
}
|
|
81
66
|
}
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import type { StylePackageContext } from '#auklet/css/core/stylePackageContext';
|
|
2
|
-
import type {
|
|
3
|
-
ModuleStyleBuildConfig,
|
|
4
|
-
ResolvedModuleStyleBuildContext,
|
|
5
|
-
} from '#auklet/types';
|
|
2
|
+
import type { ModuleStyleBuildConfig, ResolvedModuleStyleBuildContext } from '#auklet/types';
|
|
6
3
|
export type ModuleStyleOutputWriterOptions = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
config: ModuleStyleBuildConfig;
|
|
5
|
+
context: ResolvedModuleStyleBuildContext;
|
|
6
|
+
packageContext: StylePackageContext;
|
|
10
7
|
};
|
|
11
8
|
export declare class ModuleStyleOutputWriter {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
private readonly config;
|
|
10
|
+
private readonly context;
|
|
11
|
+
private readonly packageContext;
|
|
12
|
+
private readonly sourceWriter;
|
|
13
|
+
private readonly themeWriter;
|
|
14
|
+
private readonly externalWriter;
|
|
15
|
+
private readonly moduleWriter;
|
|
16
|
+
private readonly entryWriter;
|
|
17
|
+
private readonly moduleEntryWriter;
|
|
18
|
+
constructor(options: ModuleStyleOutputWriterOptions);
|
|
19
|
+
write(): string[];
|
|
20
|
+
private get outputRoot();
|
|
21
|
+
private createModuleEntries;
|
|
22
|
+
private writeFormat;
|
|
26
23
|
}
|