auklet 0.0.15 → 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.
- package/bin/entry.cjs +4 -6
- 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.d.ts +2 -6
- 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 +6 -6
- 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 +20 -31
- 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 +5 -8
- package/dist/css/core/style/specifier.js +21 -18
- package/dist/css/core/styleImports/collector.d.ts +17 -25
- package/dist/css/core/styleImports/collector.js +162 -201
- package/dist/css/core/styleImports/sourceReference.d.ts +8 -16
- package/dist/css/core/styleImports/sourceReference.js +153 -173
- package/dist/css/core/styleModuleEntryPlanner.d.ts +21 -24
- package/dist/css/core/styleModuleEntryPlanner.js +44 -61
- package/dist/css/core/stylePackageContext.d.ts +16 -20
- package/dist/css/core/stylePackageContext.js +33 -49
- package/dist/css/core/styleProcessor.d.ts +12 -12
- package/dist/css/core/styleProcessor.js +105 -104
- package/dist/css/core/workspaceStyleResolver.d.ts +9 -15
- package/dist/css/core/workspaceStyleResolver.js +62 -72
- package/dist/css/production/builder.d.ts +9 -16
- package/dist/css/production/builder.js +51 -57
- package/dist/css/production/format/componentWriter.d.ts +8 -8
- package/dist/css/production/format/componentWriter.js +45 -66
- package/dist/css/production/format/entryWriter.d.ts +5 -9
- package/dist/css/production/format/entryWriter.js +36 -49
- package/dist/css/production/format/externalWriter.d.ts +6 -6
- package/dist/css/production/format/externalWriter.js +21 -33
- package/dist/css/production/format/moduleWriter.d.ts +5 -5
- 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 +5 -6
- package/dist/css/production/format/sourceWriter.d.ts +3 -3
- package/dist/css/production/format/sourceWriter.js +11 -11
- package/dist/css/production/format/themeWriter.d.ts +8 -14
- package/dist/css/production/format/themeWriter.js +56 -71
- package/dist/css/production/moduleOutputWriter.d.ts +18 -21
- package/dist/css/production/moduleOutputWriter.js +56 -65
- 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 -24
- package/dist/css/vite/moduleGraph/graph.js +49 -64
- 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 +7 -0
- package/dist/css/vite/moduleGraph/packageSource/monorepo.js +72 -0
- package/dist/css/vite/moduleGraph/packageSource/types.d.ts +11 -0
- package/dist/css/vite/moduleGraph/packageSource/types.js +0 -0
- package/dist/css/vite/moduleGraph/requestCache.d.ts +47 -61
- package/dist/css/vite/moduleGraph/requestCache.js +51 -84
- package/dist/css/vite/moduleGraph/styleCodeFactory.d.ts +15 -18
- package/dist/css/vite/moduleGraph/styleCodeFactory.js +182 -263
- 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 -13
- package/dist/css/vite/vitePlugin.d.ts +16 -20
- package/dist/css/vite/vitePlugin.js +111 -110
- package/dist/css/watch/watcher.d.ts +15 -21
- package/dist/css/watch/watcher.js +83 -80
- 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 -32
|
@@ -1,71 +1,50 @@
|
|
|
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
|
import { toPosixPath } from '#auklet/utils';
|
|
4
4
|
export class ComponentStyleEntryWriter {
|
|
5
|
-
|
|
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
|
-
outputs.push(target);
|
|
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) => {
|
|
40
|
+
if (specifier.startsWith('.'))
|
|
41
|
+
return specifier;
|
|
42
|
+
if (!path.isAbsolute(specifier))
|
|
43
|
+
return specifier;
|
|
44
|
+
return toPosixPath(path.relative(styleDir, specifier));
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
getOwnStyleSpecifiers(ownStyleFiles, styleDir, outRoot) {
|
|
48
|
+
return ownStyleFiles.map((styleFile) => toPosixPath(path.relative(styleDir, path.join(outRoot, path.relative(this.sourceRoot, styleFile)))));
|
|
51
49
|
}
|
|
52
|
-
return outputs;
|
|
53
|
-
}
|
|
54
|
-
getModuleStyleSpecifiers(specifiers, styleDir) {
|
|
55
|
-
return specifiers.map((specifier) => {
|
|
56
|
-
if (specifier.startsWith('.')) return specifier;
|
|
57
|
-
if (!path.isAbsolute(specifier)) return specifier;
|
|
58
|
-
return toPosixPath(path.relative(styleDir, specifier));
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
getOwnStyleSpecifiers(ownStyleFiles, styleDir, outRoot) {
|
|
62
|
-
return ownStyleFiles.map((styleFile) =>
|
|
63
|
-
toPosixPath(
|
|
64
|
-
path.relative(
|
|
65
|
-
styleDir,
|
|
66
|
-
path.join(outRoot, path.relative(this.sourceRoot, styleFile)),
|
|
67
|
-
),
|
|
68
|
-
),
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
50
|
}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { type FormatWriterOptions } from '#auklet/css/production/format/shared';
|
|
2
2
|
export declare class StyleEntryWriter {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
outRoot: string,
|
|
9
|
-
themeStyles: Map<string, string>,
|
|
10
|
-
moduleStyle: string | null,
|
|
11
|
-
): string | null;
|
|
3
|
+
private readonly config;
|
|
4
|
+
private readonly packageContext;
|
|
5
|
+
private readonly styleProcessor;
|
|
6
|
+
constructor(options: FormatWriterOptions);
|
|
7
|
+
write(outRoot: string, themeStyles: Map<string, string>, moduleStyle: string | null): string | null;
|
|
12
8
|
}
|
|
@@ -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,9 +1,9 @@
|
|
|
1
1
|
import { type FormatWriterOptions } from '#auklet/css/production/format/shared';
|
|
2
2
|
export declare class ExternalStyleWriter {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
private readonly config;
|
|
4
|
+
private readonly packageContext;
|
|
5
|
+
private readonly resolver;
|
|
6
|
+
private readonly styleProcessor;
|
|
7
|
+
constructor(options: FormatWriterOptions);
|
|
8
|
+
write(outRoot: string): string;
|
|
9
9
|
}
|
|
@@ -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,8 +1,8 @@
|
|
|
1
1
|
import { type FormatWriterOptions } from '#auklet/css/production/format/shared';
|
|
2
2
|
export declare class ModuleStyleWriter {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
private readonly config;
|
|
4
|
+
private readonly packageContext;
|
|
5
|
+
private readonly styleProcessor;
|
|
6
|
+
constructor(options: FormatWriterOptions);
|
|
7
|
+
write(outRoot: string): string | null;
|
|
8
8
|
}
|
|
@@ -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
|
-
import type {
|
|
3
|
-
|
|
4
|
-
ResolvedModuleStyleBuildContext,
|
|
5
|
-
} from '#auklet/types';
|
|
6
|
-
export declare const emptyStyleFileComment =
|
|
7
|
-
'/* Empty style file kept so automated tooling can resolve this CSS path. */\n';
|
|
2
|
+
import type { ModuleStyleBuildConfig, ResolvedModuleStyleBuildContext } from '#auklet/types';
|
|
3
|
+
export declare const emptyStyleFileComment = "/* Empty style file kept so automated tooling can resolve this CSS path. */\n";
|
|
8
4
|
export type FormatWriterOptions = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
config: ModuleStyleBuildConfig;
|
|
6
|
+
context: ResolvedModuleStyleBuildContext;
|
|
7
|
+
packageContext: StylePackageContext;
|
|
12
8
|
};
|
|
13
9
|
export type ThemeStyleOutput = {
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
themeName: string;
|
|
11
|
+
file: string;
|
|
16
12
|
};
|
|
17
|
-
export declare function toRelativeImportSpecifier(
|
|
18
|
-
fromDir: string,
|
|
19
|
-
file: string,
|
|
20
|
-
): string;
|
|
13
|
+
export declare function toRelativeImportSpecifier(fromDir: string, file: string): string;
|
|
21
14
|
export declare function writeStyleFile(file: string, code: string): void;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { toPosixPath } from '#auklet/utils';
|
|
4
|
-
export const emptyStyleFileComment =
|
|
5
|
-
'/* Empty style file kept so automated tooling can resolve this CSS path. */\n';
|
|
4
|
+
export const emptyStyleFileComment = '/* Empty style file kept so automated tooling can resolve this CSS path. */\n';
|
|
6
5
|
export function toRelativeImportSpecifier(fromDir, file) {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const relative = toPosixPath(path.relative(fromDir, file));
|
|
7
|
+
return relative.startsWith('.') ? relative : `./${relative}`;
|
|
9
8
|
}
|
|
10
9
|
export function writeStyleFile(file, code) {
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
11
|
+
fs.writeFileSync(file, code.trim() ? code : emptyStyleFileComment);
|
|
13
12
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type FormatWriterOptions } from '#auklet/css/production/format/shared';
|
|
2
2
|
export declare class SourceStyleFileWriter {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
private readonly sourceRoot;
|
|
4
|
+
constructor(options: FormatWriterOptions);
|
|
5
|
+
copy(files: Array<string>, outRoot: string): void;
|
|
6
6
|
}
|
|
@@ -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
|
}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type FormatWriterOptions,
|
|
3
|
-
type ThemeStyleOutput,
|
|
4
|
-
} from '#auklet/css/production/format/shared';
|
|
1
|
+
import { type FormatWriterOptions, type ThemeStyleOutput } from '#auklet/css/production/format/shared';
|
|
5
2
|
export declare class ThemeStyleWriter {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
themeStyles: Map<string, string>,
|
|
14
|
-
outRoot: string,
|
|
15
|
-
): string[];
|
|
3
|
+
private readonly config;
|
|
4
|
+
private readonly packageContext;
|
|
5
|
+
private readonly styleProcessor;
|
|
6
|
+
constructor(options: FormatWriterOptions);
|
|
7
|
+
clean(outRoot: string): void;
|
|
8
|
+
writeThemeStyles(outRoot: string): ThemeStyleOutput[];
|
|
9
|
+
writeThemeEntries(themeStyles: Map<string, string>, outRoot: string): string[];
|
|
16
10
|
}
|
|
@@ -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
|
}
|