@master/css-compiler 0.0.0-site.1793659883.g69c9aebcf628
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 +466 -0
- package/dist/compiler.d.ts +42 -0
- package/dist/compiler.js +248 -0
- package/dist/contracts.d.ts +31 -0
- package/dist/contracts.js +13 -0
- package/dist/diagnostics/contracts.d.ts +119 -0
- package/dist/diagnostics/contracts.js +1 -0
- package/dist/diagnostics/design-system.d.ts +31 -0
- package/dist/diagnostics/design-system.js +75 -0
- package/dist/diagnostics/index.d.ts +28 -0
- package/dist/diagnostics/index.js +304 -0
- package/dist/diagnostics/project-comparison.d.ts +4 -0
- package/dist/diagnostics/project-comparison.js +8 -0
- package/dist/index.d.ts +95 -0
- package/dist/index.js +34 -0
- package/dist/node-compiler.d.ts +133 -0
- package/dist/node-compiler.js +417 -0
- package/dist/node-imports.d.ts +54 -0
- package/dist/node-imports.js +253 -0
- package/dist/node.d.ts +21 -0
- package/dist/node.js +47 -0
- package/dist/notices.d.ts +5 -0
- package/dist/notices.js +29 -0
- package/dist/prepared-graph-cache.d.ts +5 -0
- package/dist/prepared-graph-cache.js +31 -0
- package/dist/project/binding-project.d.ts +29 -0
- package/dist/project/binding-project.js +100 -0
- package/dist/project/entries.d.ts +7 -0
- package/dist/project/entries.js +30 -0
- package/dist/project/manifest-sync.d.ts +5 -0
- package/dist/project/manifest-sync.js +40 -0
- package/dist/project/manifest.d.ts +5 -0
- package/dist/project/manifest.js +49 -0
- package/dist/project/options.d.ts +43 -0
- package/dist/project/options.js +1 -0
- package/dist/pure-css-cache.d.ts +11 -0
- package/dist/pure-css-cache.js +39 -0
- package/dist/session.d.ts +19 -0
- package/dist/session.js +46 -0
- package/dist/stylesheet/browser.d.ts +32 -0
- package/dist/stylesheet/browser.js +71 -0
- package/dist/stylesheet/compiled-source.d.ts +11 -0
- package/dist/stylesheet/compiled-source.js +96 -0
- package/dist/stylesheet/composition-cache.d.ts +18 -0
- package/dist/stylesheet/composition-cache.js +79 -0
- package/dist/stylesheet/delivery.d.ts +103 -0
- package/dist/stylesheet/delivery.js +367 -0
- package/dist/stylesheet/directives.d.ts +31 -0
- package/dist/stylesheet/directives.js +105 -0
- package/dist/stylesheet/index-public.d.ts +3 -0
- package/dist/stylesheet/index-public.js +4 -0
- package/dist/stylesheet/index.d.ts +39 -0
- package/dist/stylesheet/index.js +501 -0
- package/dist/stylesheet/linked-stylesheet.d.ts +10 -0
- package/dist/stylesheet/linked-stylesheet.js +13 -0
- package/dist/stylesheet/output-map.d.ts +20 -0
- package/dist/stylesheet/output-map.js +222 -0
- package/dist/stylesheet/public.d.ts +171 -0
- package/dist/stylesheet/public.js +346 -0
- package/dist/stylesheet/reference-files.d.ts +6 -0
- package/dist/stylesheet/reference-files.js +13 -0
- package/dist/stylesheet/reference-origins.d.ts +4 -0
- package/dist/stylesheet/reference-origins.js +28 -0
- package/dist/stylesheet/render-core.d.ts +35 -0
- package/dist/stylesheet/render-core.js +28 -0
- package/dist/stylesheet/render-delivery.d.ts +4 -0
- package/dist/stylesheet/render-delivery.js +61 -0
- package/dist/stylesheet/render.d.ts +5 -0
- package/dist/stylesheet/render.js +31 -0
- package/dist/stylesheet/source-context.d.ts +8 -0
- package/dist/stylesheet/source-context.js +71 -0
- package/dist/stylesheet/source-map-url.d.ts +4 -0
- package/dist/stylesheet/source-map-url.js +11 -0
- package/dist/stylesheet/source.d.ts +3 -0
- package/dist/stylesheet/source.js +52 -0
- package/dist/stylesheet/types.d.ts +162 -0
- package/dist/stylesheet/types.js +1 -0
- package/dist/value-validation.d.ts +19 -0
- package/dist/value-validation.js +96 -0
- package/package.json +79 -0
package/dist/compiler.js
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { validateCompiledCSS } from "./value-validation.js";
|
|
2
|
+
import { noticeDiagnostics } from "./notices.js";
|
|
3
|
+
import { MASTER_CSS_DIAGNOSTIC_VERSION, MasterCSSError } from "@master/css-schema";
|
|
4
|
+
// src/compiler.ts
|
|
5
|
+
function warningDiagnostic(message) {
|
|
6
|
+
return Object.freeze({
|
|
7
|
+
version: MASTER_CSS_DIAGNOSTIC_VERSION,
|
|
8
|
+
code: "COMPILER_WARNING",
|
|
9
|
+
domain: "compiler",
|
|
10
|
+
phase: "compiler",
|
|
11
|
+
severity: "warning",
|
|
12
|
+
message
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function diagnosticsFor(warnings, onDiagnostic) {
|
|
16
|
+
const diagnostics = Object.freeze(warnings.map(warningDiagnostic));
|
|
17
|
+
for (const diagnostic of diagnostics) onDiagnostic?.(diagnostic);
|
|
18
|
+
return diagnostics;
|
|
19
|
+
}
|
|
20
|
+
function countRecordValue(value) {
|
|
21
|
+
if (Array.isArray(value)) return value.length;
|
|
22
|
+
return value && typeof value === "object" ? Object.keys(value).length : 0;
|
|
23
|
+
}
|
|
24
|
+
function freezeExtractionPolicy(policy) {
|
|
25
|
+
return Object.freeze({
|
|
26
|
+
include: Object.freeze([...policy.include]),
|
|
27
|
+
exclude: Object.freeze([...policy.exclude]),
|
|
28
|
+
safelist: Object.freeze([...policy.safelist]),
|
|
29
|
+
safelistKeyframes: Object.freeze([...policy.safelistKeyframes]),
|
|
30
|
+
blocklist: Object.freeze([...policy.blocklist]),
|
|
31
|
+
preserveNative: policy.preserveNative,
|
|
32
|
+
pruneNative: policy.pruneNative
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function directiveSummary(result) {
|
|
36
|
+
const manifestInput = result.manifestInput;
|
|
37
|
+
const keys = Object.freeze(Object.keys(manifestInput));
|
|
38
|
+
return Object.freeze({
|
|
39
|
+
manifestInput: Object.freeze({
|
|
40
|
+
keys,
|
|
41
|
+
counts: Object.freeze(Object.fromEntries([
|
|
42
|
+
"theme",
|
|
43
|
+
"customMedia",
|
|
44
|
+
"mixins",
|
|
45
|
+
"keyframes"
|
|
46
|
+
].map((key) => [key, countRecordValue(manifestInput[key])])))
|
|
47
|
+
}),
|
|
48
|
+
styleDefinitions: (result.styleDefinitions?.length ?? 0) + [...result.manifestInput.mixins ?? [], ...result.manifestInput.utilities ?? []].reduce((count, definition) => count + (definition.body?.length ?? 0), 0),
|
|
49
|
+
extractionPolicy: freezeExtractionPolicy(result.extractionPolicy)
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/** @internal */
|
|
53
|
+
function toMasterCSSCompileResultInternal(result, onDiagnostic, validation, origin) {
|
|
54
|
+
return Object.freeze({
|
|
55
|
+
css: result.css,
|
|
56
|
+
...result.sourceMap ? { sourceMap: result.sourceMap } : {},
|
|
57
|
+
nativeCSS: result.nativeCSS,
|
|
58
|
+
generatedCSS: result.generatedCSS,
|
|
59
|
+
dependencies: Object.freeze([...result.dependencies]),
|
|
60
|
+
classNames: Object.freeze([...result.classNames]),
|
|
61
|
+
nativeClassNames: Object.freeze([...result.nativeClassNames]),
|
|
62
|
+
diagnostics: Object.freeze([
|
|
63
|
+
...diagnosticsFor(result.warnings, onDiagnostic),
|
|
64
|
+
...noticeDiagnostics(result.notices, onDiagnostic),
|
|
65
|
+
...validateCompiledCSS([{
|
|
66
|
+
css: result.css,
|
|
67
|
+
mappings: result.outputMappings ?? result.nativeMappings,
|
|
68
|
+
...origin
|
|
69
|
+
}], {
|
|
70
|
+
onDiagnostic,
|
|
71
|
+
validation
|
|
72
|
+
})
|
|
73
|
+
]),
|
|
74
|
+
directiveSummary: directiveSummary(result)
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/** @internal */
|
|
78
|
+
function toMasterCSSCompileManifestResultInternal(result, onDiagnostic, validation) {
|
|
79
|
+
return Object.freeze({
|
|
80
|
+
css: result.css,
|
|
81
|
+
nativeCSS: result.nativeCSS,
|
|
82
|
+
generatedCSS: result.generatedCSS,
|
|
83
|
+
dependencies: Object.freeze([...result.dependencies]),
|
|
84
|
+
classNames: Object.freeze([...result.classNames]),
|
|
85
|
+
nativeClassNames: Object.freeze([...result.nativeClassNames]),
|
|
86
|
+
diagnostics: Object.freeze([
|
|
87
|
+
...diagnosticsFor(result.warnings, onDiagnostic),
|
|
88
|
+
...noticeDiagnostics(result.notices, onDiagnostic),
|
|
89
|
+
...validateCompiledCSS([{
|
|
90
|
+
css: result.css,
|
|
91
|
+
mappings: result.outputMappings,
|
|
92
|
+
sources: result.sourceTexts
|
|
93
|
+
}], {
|
|
94
|
+
onDiagnostic,
|
|
95
|
+
validation
|
|
96
|
+
})
|
|
97
|
+
]),
|
|
98
|
+
directiveSummary: directiveSummary(result.directives),
|
|
99
|
+
manifest: Object.freeze(result.manifest),
|
|
100
|
+
directives: toMasterCSSCompileResultInternal(result.directives)
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
let bindCompilerSession;
|
|
104
|
+
var MasterCSSCompiler = class MasterCSSCompiler {
|
|
105
|
+
#session;
|
|
106
|
+
#disposed = false;
|
|
107
|
+
constructor() {}
|
|
108
|
+
get binding() {
|
|
109
|
+
return this.#session.binding;
|
|
110
|
+
}
|
|
111
|
+
inspectCSS(source) {
|
|
112
|
+
this.assertActive();
|
|
113
|
+
const inspection = this.#session.inspectCSS(source);
|
|
114
|
+
return Object.freeze({
|
|
115
|
+
...inspection,
|
|
116
|
+
directives: Object.freeze(inspection.directives.map((directive) => Object.freeze({
|
|
117
|
+
...directive,
|
|
118
|
+
range: Object.freeze({ ...directive.range }),
|
|
119
|
+
preludeRange: Object.freeze({ ...directive.preludeRange })
|
|
120
|
+
})))
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
compileCSS(source, options = {}) {
|
|
124
|
+
this.assertActive();
|
|
125
|
+
return toMasterCSSCompileResultInternal(this.#session.compileCSS(source, options), options.onDiagnostic, options.validation, {
|
|
126
|
+
source: options.from ?? "<stylesheet>",
|
|
127
|
+
sources: { [options.from ?? "<stylesheet>"]: source }
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
compileManifest(source, options) {
|
|
131
|
+
this.assertActive();
|
|
132
|
+
const rawDirectives = this.#session.compileCSS(source, options);
|
|
133
|
+
const origin = {
|
|
134
|
+
source: options.from ?? "<stylesheet>",
|
|
135
|
+
sources: { [options.from ?? "<stylesheet>"]: source }
|
|
136
|
+
};
|
|
137
|
+
const directives = toMasterCSSCompileResultInternal(rawDirectives, void 0, void 0, origin);
|
|
138
|
+
if (rawDirectives.references?.length) throw new MasterCSSError({
|
|
139
|
+
code: "UNRESOLVED_REFERENCE",
|
|
140
|
+
domain: "compiler",
|
|
141
|
+
message: "Universal manifest compilation cannot resolve @reference directives."
|
|
142
|
+
});
|
|
143
|
+
const lowered = this.#session.lowerCSSDirectives({
|
|
144
|
+
manifestInput: rawDirectives.manifestInput,
|
|
145
|
+
definitionSources: rawDirectives.definitionSources || [],
|
|
146
|
+
nativeOutput: rawDirectives.nativeOutput,
|
|
147
|
+
styleDefinitions: rawDirectives.styleDefinitions || [],
|
|
148
|
+
warnings: rawDirectives.warnings
|
|
149
|
+
}, { baseManifest: options.baseManifest }, source);
|
|
150
|
+
const generatedCSS = lowered.generatedCSS || "";
|
|
151
|
+
const css = lowered.css ?? [rawDirectives.nativeCSS, generatedCSS].filter(Boolean).join("\n");
|
|
152
|
+
const diagnostics = Object.freeze([
|
|
153
|
+
...diagnosticsFor(lowered.warnings, options.onDiagnostic),
|
|
154
|
+
...noticeDiagnostics(lowered.notices, options.onDiagnostic),
|
|
155
|
+
...validateCompiledCSS([{
|
|
156
|
+
css,
|
|
157
|
+
mappings: lowered.outputMappings ?? rawDirectives.nativeMappings,
|
|
158
|
+
...origin
|
|
159
|
+
}], options)
|
|
160
|
+
]);
|
|
161
|
+
return Object.freeze({
|
|
162
|
+
css,
|
|
163
|
+
nativeCSS: rawDirectives.nativeCSS,
|
|
164
|
+
generatedCSS,
|
|
165
|
+
classNames: Object.freeze([...rawDirectives.classNames]),
|
|
166
|
+
nativeClassNames: Object.freeze([...rawDirectives.nativeClassNames]),
|
|
167
|
+
diagnostics,
|
|
168
|
+
directiveSummary: directiveSummary(rawDirectives),
|
|
169
|
+
dependencies: Object.freeze([]),
|
|
170
|
+
manifest: Object.freeze(lowered.manifest),
|
|
171
|
+
directives
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
dispose() {
|
|
175
|
+
if (this.#disposed) return;
|
|
176
|
+
this.#session.dispose();
|
|
177
|
+
this.#disposed = true;
|
|
178
|
+
}
|
|
179
|
+
prepareStylesheetBundle(request) {
|
|
180
|
+
this.assertActive();
|
|
181
|
+
const result = this.#session.prepareCSSStylesheetBundle(request);
|
|
182
|
+
return Object.freeze({
|
|
183
|
+
...result,
|
|
184
|
+
graph: Object.freeze({
|
|
185
|
+
...result.graph,
|
|
186
|
+
references: Object.freeze(result.graph.references.map((reference) => Object.freeze({ ...reference }))),
|
|
187
|
+
stylesheets: Object.freeze(result.graph.stylesheets.map((stylesheet) => Object.freeze({
|
|
188
|
+
...stylesheet,
|
|
189
|
+
imports: Object.freeze(stylesheet.imports.map((edge) => Object.freeze({ ...edge })))
|
|
190
|
+
})))
|
|
191
|
+
}),
|
|
192
|
+
sources: Object.freeze(result.sources.map((source) => Object.freeze({
|
|
193
|
+
...source,
|
|
194
|
+
range: Object.freeze({ ...source.range }),
|
|
195
|
+
resources: Object.freeze(source.resources.map((resource) => Object.freeze({ ...resource }))),
|
|
196
|
+
imports: Object.freeze(source.imports.map((resource) => Object.freeze({ ...resource })))
|
|
197
|
+
})))
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
renderStylesheetBundle(request) {
|
|
201
|
+
this.assertActive();
|
|
202
|
+
return Object.freeze(this.#session.renderCSSStylesheetBundle(request).map((asset) => Object.freeze({ ...asset })));
|
|
203
|
+
}
|
|
204
|
+
compareProjectSnapshots(request) {
|
|
205
|
+
this.assertActive();
|
|
206
|
+
return Object.freeze(this.#session.compareProjectSnapshots(request));
|
|
207
|
+
}
|
|
208
|
+
compileStylesheets(request, options = {}) {
|
|
209
|
+
this.assertActive();
|
|
210
|
+
const result = this.#session.compileCSSStylesheetGraph(request);
|
|
211
|
+
const directives = toMasterCSSCompileResultInternal(result.directives);
|
|
212
|
+
return Object.freeze({
|
|
213
|
+
...directives,
|
|
214
|
+
diagnostics: Object.freeze([...directives.diagnostics, ...validateCompiledCSS(result.stylesheets.map((asset) => ({
|
|
215
|
+
css: asset.css,
|
|
216
|
+
source: asset.id,
|
|
217
|
+
mappings: asset.outputMappings,
|
|
218
|
+
sources: request.graph.files
|
|
219
|
+
})), options)]),
|
|
220
|
+
entry: result.entry,
|
|
221
|
+
stylesheets: Object.freeze(result.stylesheets.map((stylesheet) => Object.freeze({ ...stylesheet }))),
|
|
222
|
+
manifest: Object.freeze(result.manifest),
|
|
223
|
+
directives
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
[Symbol.dispose]() {
|
|
227
|
+
this.dispose();
|
|
228
|
+
}
|
|
229
|
+
assertActive() {
|
|
230
|
+
if (this.#disposed) throw new MasterCSSError({
|
|
231
|
+
code: "SESSION_DISPOSED",
|
|
232
|
+
domain: "compiler",
|
|
233
|
+
message: "The Master CSS compiler has been disposed."
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
static {
|
|
237
|
+
bindCompilerSession = (session) => {
|
|
238
|
+
const compiler = new MasterCSSCompiler();
|
|
239
|
+
compiler.#session = session;
|
|
240
|
+
return compiler;
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
/** @internal */
|
|
245
|
+
function bindCompilerSessionInternal(session) {
|
|
246
|
+
return bindCompilerSession(session);
|
|
247
|
+
}
|
|
248
|
+
export { MasterCSSCompiler, bindCompilerSessionInternal, toMasterCSSCompileManifestResultInternal, toMasterCSSCompileResultInternal };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { MasterCSSDiagnostic } from "@master/css-schema";
|
|
2
|
+
import { CSSDirectiveExtractionPolicy, CSSDirectiveReference, CSSDirectiveResult } from "@master/css-schema/css-directives";
|
|
3
|
+
interface CompileCSSOptions {
|
|
4
|
+
readonly classes?: readonly string[];
|
|
5
|
+
readonly from?: string;
|
|
6
|
+
readonly preserveNativeCSS?: boolean;
|
|
7
|
+
/** Opt in to pruning native rules in project-owned files. */
|
|
8
|
+
readonly pruneNativeCSS?: boolean;
|
|
9
|
+
/** Keep untouched native source for host transforms; incompatible with class pruning. */
|
|
10
|
+
readonly preserveNativeSource?: boolean;
|
|
11
|
+
/** Report CSS value errors by default; error rejects the complete output. */
|
|
12
|
+
readonly validation?: 'report' | 'error';
|
|
13
|
+
readonly onDiagnostic?: (diagnostic: MasterCSSDiagnostic) => void;
|
|
14
|
+
}
|
|
15
|
+
interface CompileCSSFileOptions extends CompileCSSOptions {
|
|
16
|
+
root?: string;
|
|
17
|
+
}
|
|
18
|
+
type CompileCSSResult = CSSDirectiveResult;
|
|
19
|
+
interface ResolvedCSSImportGraph {
|
|
20
|
+
sourceMappings?: import('@master/css-schema/css-directives').CSSOutputMapping[];
|
|
21
|
+
source: string;
|
|
22
|
+
dependencies: string[];
|
|
23
|
+
references?: CSSDirectiveReference[];
|
|
24
|
+
}
|
|
25
|
+
type CSSReferenceStatement = CSSDirectiveReference & {
|
|
26
|
+
start: number;
|
|
27
|
+
end: number;
|
|
28
|
+
statement: string;
|
|
29
|
+
};
|
|
30
|
+
declare function emptyExtractionPolicy(): CSSDirectiveExtractionPolicy;
|
|
31
|
+
export { CSSReferenceStatement, CompileCSSFileOptions, CompileCSSOptions, CompileCSSResult, ResolvedCSSImportGraph, emptyExtractionPolicy };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { MasterCSSClassValidation } from "@master/css-tooling/validator";
|
|
2
|
+
import { MasterCSSDiagnostic } from "@master/css-binding/tooling";
|
|
3
|
+
type MasterCSSInspectionDiagnosticSeverity = 'error' | 'warning' | 'info';
|
|
4
|
+
type MasterCSSInspectionDiagnosticCode = 'invalid-scanner-class' | 'missing-css' | 'stylesheet-error' | 'stylesheet-warning' | 'scanner-error' | MasterCSSDiagnostic['code'];
|
|
5
|
+
type MasterCSSInspectionDiagnosticSourceKind = 'scanner' | 'stylesheet' | 'missing-css';
|
|
6
|
+
type MasterCSSMissingCSSStatus = 'present' | 'missing';
|
|
7
|
+
type MasterCSSMissingCSSReason = 'generated' | 'native-css' | 'safelist' | 'invalid' | 'blocklisted' | 'not-detected';
|
|
8
|
+
interface MasterCSSMissingCSSResult {
|
|
9
|
+
readonly className: string;
|
|
10
|
+
readonly status: MasterCSSMissingCSSStatus;
|
|
11
|
+
readonly reason: MasterCSSMissingCSSReason;
|
|
12
|
+
}
|
|
13
|
+
interface MasterCSSInspectionDiagnostic {
|
|
14
|
+
readonly code: MasterCSSInspectionDiagnosticCode;
|
|
15
|
+
readonly phase: MasterCSSDiagnostic['phase'];
|
|
16
|
+
readonly range?: MasterCSSDiagnostic['range'];
|
|
17
|
+
readonly notes?: readonly string[];
|
|
18
|
+
readonly severity: MasterCSSInspectionDiagnosticSeverity;
|
|
19
|
+
readonly message: string;
|
|
20
|
+
readonly source: 'Master CSS';
|
|
21
|
+
readonly sourceKind: MasterCSSInspectionDiagnosticSourceKind;
|
|
22
|
+
readonly filePath?: string;
|
|
23
|
+
readonly data?: Readonly<{
|
|
24
|
+
cwd: string;
|
|
25
|
+
} | {
|
|
26
|
+
className: string;
|
|
27
|
+
} | MasterCSSMissingCSSResult>;
|
|
28
|
+
}
|
|
29
|
+
interface MasterCSSDiscoveredClasses {
|
|
30
|
+
readonly latent: readonly string[];
|
|
31
|
+
readonly valid: readonly string[];
|
|
32
|
+
readonly invalid: readonly string[];
|
|
33
|
+
readonly usedNative: readonly string[];
|
|
34
|
+
}
|
|
35
|
+
interface MasterCSSSourceInspection {
|
|
36
|
+
readonly filePath: string;
|
|
37
|
+
readonly source: string;
|
|
38
|
+
readonly scanned: boolean;
|
|
39
|
+
readonly changed: boolean;
|
|
40
|
+
readonly discovered: MasterCSSDiscoveredClasses;
|
|
41
|
+
}
|
|
42
|
+
interface MasterCSSStylesheetInspection {
|
|
43
|
+
readonly filePath: string;
|
|
44
|
+
readonly masterCSS: boolean;
|
|
45
|
+
readonly pruneNativeCSS: boolean;
|
|
46
|
+
readonly dependencies: readonly string[];
|
|
47
|
+
readonly sourceDependencies: readonly string[];
|
|
48
|
+
readonly warnings: readonly string[];
|
|
49
|
+
readonly errors: readonly string[];
|
|
50
|
+
}
|
|
51
|
+
interface MasterCSSStylesheetError {
|
|
52
|
+
readonly filePath: string;
|
|
53
|
+
readonly message: string;
|
|
54
|
+
}
|
|
55
|
+
interface MasterCSSInspectionReport {
|
|
56
|
+
/** Optional authored CSS analysis from the same resolved project. */
|
|
57
|
+
readonly designSystem?: import('./design-system.js').MasterCSSProjectDesignSystemReport;
|
|
58
|
+
readonly version: 5;
|
|
59
|
+
readonly cwd: string;
|
|
60
|
+
readonly inputs: Readonly<{
|
|
61
|
+
patterns: readonly string[];
|
|
62
|
+
files: readonly string[];
|
|
63
|
+
classes: readonly string[];
|
|
64
|
+
}>;
|
|
65
|
+
readonly scanner: Readonly<{
|
|
66
|
+
counts: Readonly<{
|
|
67
|
+
latent: number;
|
|
68
|
+
valid: number;
|
|
69
|
+
invalid: number;
|
|
70
|
+
native: number;
|
|
71
|
+
usedNative: number;
|
|
72
|
+
safelist: number;
|
|
73
|
+
blocklist: number;
|
|
74
|
+
}>;
|
|
75
|
+
classes: Readonly<{
|
|
76
|
+
latent: readonly string[];
|
|
77
|
+
valid: readonly string[];
|
|
78
|
+
invalid: readonly string[];
|
|
79
|
+
native: readonly string[];
|
|
80
|
+
usedNative: readonly string[];
|
|
81
|
+
safelist: readonly string[];
|
|
82
|
+
blocklist: readonly string[];
|
|
83
|
+
}>;
|
|
84
|
+
resetDependencies: readonly string[];
|
|
85
|
+
}>;
|
|
86
|
+
readonly stylesheets: Readonly<{
|
|
87
|
+
entries: readonly MasterCSSStylesheetInspection[];
|
|
88
|
+
dependencies: readonly string[];
|
|
89
|
+
warnings: readonly string[];
|
|
90
|
+
errors: readonly MasterCSSStylesheetError[];
|
|
91
|
+
}>;
|
|
92
|
+
readonly css: Readonly<{
|
|
93
|
+
bytes: number;
|
|
94
|
+
included: boolean;
|
|
95
|
+
text?: string;
|
|
96
|
+
emittedGlobals: Readonly<{
|
|
97
|
+
variables: number;
|
|
98
|
+
keyframes: number;
|
|
99
|
+
}>;
|
|
100
|
+
}>;
|
|
101
|
+
readonly missingCSS: Readonly<{
|
|
102
|
+
checked: readonly string[];
|
|
103
|
+
present: readonly MasterCSSMissingCSSResult[];
|
|
104
|
+
missing: readonly MasterCSSMissingCSSResult[];
|
|
105
|
+
}>;
|
|
106
|
+
readonly files: readonly MasterCSSSourceInspection[];
|
|
107
|
+
readonly inspections: readonly MasterCSSClassValidation[];
|
|
108
|
+
readonly diagnostics: readonly MasterCSSInspectionDiagnostic[];
|
|
109
|
+
readonly summary: Readonly<{
|
|
110
|
+
files: number;
|
|
111
|
+
stylesheets: number;
|
|
112
|
+
diagnostics: number;
|
|
113
|
+
errors: number;
|
|
114
|
+
warnings: number;
|
|
115
|
+
missingCSS: number;
|
|
116
|
+
invalidClasses: number;
|
|
117
|
+
}>;
|
|
118
|
+
}
|
|
119
|
+
export { MasterCSSDiscoveredClasses, MasterCSSInspectionDiagnostic, MasterCSSInspectionDiagnosticCode, MasterCSSInspectionDiagnosticSeverity, MasterCSSInspectionDiagnosticSourceKind, MasterCSSInspectionReport, MasterCSSMissingCSSReason, MasterCSSMissingCSSResult, MasterCSSMissingCSSStatus, MasterCSSSourceInspection, MasterCSSStylesheetError, MasterCSSStylesheetInspection };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { MasterCSSManifest } from "@master/css-schema/manifest";
|
|
2
|
+
import { MasterCSSDesignSystemOptions, MasterCSSDesignSystemOptions as MasterCSSDesignSystemOptions$1, MasterCSSDesignSystemReport, MasterCSSDesignSystemReport as MasterCSSDesignSystemReport$1 } from "@master/css-tooling/lint";
|
|
3
|
+
import { MasterCSSProjectResult, MasterCSSProjectSourceGraph } from "../project/options.js";
|
|
4
|
+
interface CreateMasterCSSDesignSystemReportOptions {
|
|
5
|
+
readonly manifest: MasterCSSManifest;
|
|
6
|
+
readonly cwd?: string;
|
|
7
|
+
readonly entries?: readonly string[];
|
|
8
|
+
readonly designSystem?: MasterCSSDesignSystemOptions$1;
|
|
9
|
+
/**
|
|
10
|
+
* Route and component stylesheets imported from JavaScript rather than reached from a CSS entry.
|
|
11
|
+
* They resolve against the same project manifest and report no importers.
|
|
12
|
+
*/
|
|
13
|
+
readonly routeStylesheets?: readonly string[];
|
|
14
|
+
readonly resolveExistingFile?: (file: string) => string | Promise<string>;
|
|
15
|
+
readonly onDependency?: (file: string) => void;
|
|
16
|
+
}
|
|
17
|
+
interface MasterCSSProjectDesignSystemReport extends MasterCSSDesignSystemReport$1 {
|
|
18
|
+
readonly project: {
|
|
19
|
+
readonly cwd: string;
|
|
20
|
+
readonly entries: readonly string[];
|
|
21
|
+
readonly files: readonly string[];
|
|
22
|
+
readonly routeStylesheets: readonly string[];
|
|
23
|
+
readonly excluded: readonly string[];
|
|
24
|
+
readonly edges: MasterCSSProjectSourceGraph['edges'];
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** Inspect only project-owned CSS reached from managed entries, preserving authored offsets. */
|
|
28
|
+
declare function createMasterCSSDesignSystemReport(options: CreateMasterCSSDesignSystemReportOptions): Promise<MasterCSSProjectDesignSystemReport>;
|
|
29
|
+
/** Shared orchestration for standalone and combined project inspection. */
|
|
30
|
+
declare function inspectResolvedProjectDesignSystem(project: MasterCSSProjectResult, cwd: string, options: Pick<CreateMasterCSSDesignSystemReportOptions, 'designSystem' | 'routeStylesheets' | 'resolveExistingFile'>): Promise<MasterCSSProjectDesignSystemReport>;
|
|
31
|
+
export { CreateMasterCSSDesignSystemReportOptions, type MasterCSSDesignSystemOptions, type MasterCSSDesignSystemReport, MasterCSSProjectDesignSystemReport, createMasterCSSDesignSystemReport, inspectResolvedProjectDesignSystem };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { loadProjectManifest } from "../project/manifest.js";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
4
|
+
import { createToolingSession } from "@master/css-tooling";
|
|
5
|
+
// src/diagnostics/design-system.ts
|
|
6
|
+
/** Inspect only project-owned CSS reached from managed entries, preserving authored offsets. */
|
|
7
|
+
async function createMasterCSSDesignSystemReport(options) {
|
|
8
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
9
|
+
return inspectResolvedProjectDesignSystem(await loadProjectManifest({
|
|
10
|
+
root: cwd,
|
|
11
|
+
entries: options.entries,
|
|
12
|
+
baseManifest: options.manifest,
|
|
13
|
+
includeSourceGraph: true,
|
|
14
|
+
onDependency: options.onDependency
|
|
15
|
+
}), cwd, options);
|
|
16
|
+
}
|
|
17
|
+
/** Shared orchestration for standalone and combined project inspection. */
|
|
18
|
+
async function inspectResolvedProjectDesignSystem(project, cwd, options) {
|
|
19
|
+
if (!project.entries.length) throw new Error("No project CSS entry was found. Add a stylesheet importing @master/css.");
|
|
20
|
+
const graph = project.sourceGraph;
|
|
21
|
+
if (!graph) throw new Error("The project loader did not return its authored source graph.");
|
|
22
|
+
const importers = /* @__PURE__ */ new Map();
|
|
23
|
+
for (const { from, resolved } of graph.edges) {
|
|
24
|
+
const sources = importers.get(resolved) ?? /* @__PURE__ */ new Set();
|
|
25
|
+
sources.add(from);
|
|
26
|
+
importers.set(resolved, sources);
|
|
27
|
+
}
|
|
28
|
+
const stylesheets = [];
|
|
29
|
+
const excluded = [];
|
|
30
|
+
for (const file of graph.files) {
|
|
31
|
+
if (!file.projectOwned) {
|
|
32
|
+
excluded.push(file.source);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
await options.resolveExistingFile?.(file.source);
|
|
36
|
+
stylesheets.push({
|
|
37
|
+
source: file.source,
|
|
38
|
+
content: file.content,
|
|
39
|
+
importers: [...importers.get(file.source) ?? []]
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const managed = new Set(stylesheets.map((file) => file.source));
|
|
43
|
+
const routeStylesheets = [];
|
|
44
|
+
for (const file of options.routeStylesheets ?? []) {
|
|
45
|
+
const source = path.resolve(cwd, file);
|
|
46
|
+
if (managed.has(source)) continue;
|
|
47
|
+
managed.add(source);
|
|
48
|
+
routeStylesheets.push(source);
|
|
49
|
+
await options.resolveExistingFile?.(source);
|
|
50
|
+
stylesheets.push({
|
|
51
|
+
source,
|
|
52
|
+
content: await readFile(source, "utf8"),
|
|
53
|
+
importers: []
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
using tooling = await createToolingSession({
|
|
57
|
+
manifest: project.manifest,
|
|
58
|
+
nativeClassNames: project.nativeClassNames
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
...tooling.inspectDesignSystem({
|
|
62
|
+
...options.designSystem ?? { version: 1 },
|
|
63
|
+
stylesheets
|
|
64
|
+
}),
|
|
65
|
+
project: {
|
|
66
|
+
cwd,
|
|
67
|
+
entries: project.entries,
|
|
68
|
+
files: stylesheets.map((file) => file.source),
|
|
69
|
+
routeStylesheets,
|
|
70
|
+
excluded,
|
|
71
|
+
edges: graph.edges
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export { createMasterCSSDesignSystemReport, inspectResolvedProjectDesignSystem };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { MasterCSSProjectSnapshot as MasterCSSProjectSnapshot$1 } from "@master/css-binding/compiler";
|
|
2
|
+
import { MasterCSSManifest } from "@master/css-schema/manifest";
|
|
3
|
+
import { MasterCSSProjectComparison, MasterCSSProjectComparisonRequest, MasterCSSProjectSnapshot } from "../index.js";
|
|
4
|
+
import { MasterCSSDiscoveredClasses, MasterCSSInspectionDiagnostic, MasterCSSInspectionDiagnosticCode, MasterCSSInspectionDiagnosticSeverity, MasterCSSInspectionDiagnosticSourceKind, MasterCSSInspectionReport, MasterCSSInspectionReport as MasterCSSInspectionReport$1, MasterCSSMissingCSSReason, MasterCSSMissingCSSResult, MasterCSSMissingCSSStatus, MasterCSSSourceInspection, MasterCSSStylesheetError, MasterCSSStylesheetInspection } from "./contracts.js";
|
|
5
|
+
import { CreateMasterCSSDesignSystemReportOptions, MasterCSSDesignSystemOptions, MasterCSSDesignSystemOptions as MasterCSSDesignSystemOptions$1, MasterCSSDesignSystemReport, MasterCSSProjectDesignSystemReport, createMasterCSSDesignSystemReport } from "./design-system.js";
|
|
6
|
+
import { compareProjectSnapshots } from "./project-comparison.js";
|
|
7
|
+
declare const MASTER_CSS_INSPECTION_REPORT_VERSION: 5;
|
|
8
|
+
interface CreateMasterCSSInspectionReportOptions {
|
|
9
|
+
manifest: MasterCSSManifest;
|
|
10
|
+
cwd?: string;
|
|
11
|
+
patterns?: readonly string[];
|
|
12
|
+
classes?: readonly string[] | string;
|
|
13
|
+
includeCss?: boolean;
|
|
14
|
+
/** Inspect authored CSS using the same project manifest as the class scan. */
|
|
15
|
+
designSystem?: MasterCSSDesignSystemOptions$1;
|
|
16
|
+
/** Route and component stylesheets the design-system inspection adds to the managed CSS graph. */
|
|
17
|
+
routeStylesheets?: readonly string[];
|
|
18
|
+
ignore?: readonly string[];
|
|
19
|
+
resolveExistingFile?: (filePath: string) => string | Promise<string>;
|
|
20
|
+
validatePatterns?: (patterns: readonly string[]) => void;
|
|
21
|
+
}
|
|
22
|
+
declare function createMasterCSSInspectionReport(options: CreateMasterCSSInspectionReportOptions): Promise<MasterCSSInspectionReport$1>;
|
|
23
|
+
/** Capture known project consumers and resolved CSS assets in one inspection session. */
|
|
24
|
+
declare function captureMasterCSSProject(options: CreateMasterCSSInspectionReportOptions): Promise<{
|
|
25
|
+
report: MasterCSSInspectionReport$1;
|
|
26
|
+
snapshot: MasterCSSProjectSnapshot$1;
|
|
27
|
+
}>;
|
|
28
|
+
export { type CreateMasterCSSDesignSystemReportOptions, CreateMasterCSSInspectionReportOptions, MASTER_CSS_INSPECTION_REPORT_VERSION, type MasterCSSDesignSystemOptions, type MasterCSSDesignSystemReport, type MasterCSSDiscoveredClasses, type MasterCSSInspectionDiagnostic, type MasterCSSInspectionDiagnosticCode, type MasterCSSInspectionDiagnosticSeverity, type MasterCSSInspectionDiagnosticSourceKind, type MasterCSSInspectionReport, type MasterCSSMissingCSSReason, type MasterCSSMissingCSSResult, type MasterCSSMissingCSSStatus, type MasterCSSProjectComparison, type MasterCSSProjectComparisonRequest, type MasterCSSProjectDesignSystemReport, type MasterCSSProjectSnapshot, type MasterCSSSourceInspection, type MasterCSSStylesheetError, type MasterCSSStylesheetInspection, captureMasterCSSProject, compareProjectSnapshots, createMasterCSSDesignSystemReport, createMasterCSSInspectionReport };
|