@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
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { pathToFileURL } from "node:url";
|
|
2
|
+
import { isAbsolute } from "node:path";
|
|
3
|
+
// src/stylesheet/source-map-url.ts
|
|
4
|
+
/** Host maps may contain native filesystem paths as well as URL references. */
|
|
5
|
+
function sourceMapURL(source, base) {
|
|
6
|
+
return isAbsolute(source) ? pathToFileURL(source) : new URL(source, base);
|
|
7
|
+
}
|
|
8
|
+
function sourceMapBase(owner, sourceRoot) {
|
|
9
|
+
return sourceMapURL(sourceRoot ? sourceRoot.replace(/\/?$/, "/") : "./", pathToFileURL(owner));
|
|
10
|
+
}
|
|
11
|
+
export { sourceMapBase, sourceMapURL };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
// src/stylesheet/source.ts
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
function defaultLoadSass(projectDir) {
|
|
7
|
+
if (projectDir) try {
|
|
8
|
+
return createRequire(join(projectDir, "package.json"))("sass");
|
|
9
|
+
} catch {}
|
|
10
|
+
return require("sass");
|
|
11
|
+
}
|
|
12
|
+
async function prepareSassSource(id, source, extension, options) {
|
|
13
|
+
options.signal?.throwIfAborted();
|
|
14
|
+
if (id.startsWith("\0") && !options.baseFile) throw new TypeError("Preparing a virtual stylesheet requires a physical baseFile.");
|
|
15
|
+
const baseFile = resolve(options.baseFile ?? id);
|
|
16
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
17
|
+
function addDependency(file) {
|
|
18
|
+
if (dependencies.has(file)) return;
|
|
19
|
+
dependencies.add(file);
|
|
20
|
+
options.onDependency?.(file);
|
|
21
|
+
}
|
|
22
|
+
addDependency(baseFile);
|
|
23
|
+
options.signal?.throwIfAborted();
|
|
24
|
+
if (extension !== ".scss" && extension !== ".sass") return Object.freeze({
|
|
25
|
+
id,
|
|
26
|
+
baseFile,
|
|
27
|
+
source,
|
|
28
|
+
dependencies: Object.freeze([...dependencies])
|
|
29
|
+
});
|
|
30
|
+
const result = await (options.loadSass || defaultLoadSass)(options.projectDir).compileStringAsync(source, {
|
|
31
|
+
url: pathToFileURL(baseFile),
|
|
32
|
+
style: "expanded",
|
|
33
|
+
syntax: extension === ".sass" ? "indented" : "scss",
|
|
34
|
+
sourceMap: true,
|
|
35
|
+
sourceMapIncludeSources: true
|
|
36
|
+
}).catch((error) => {
|
|
37
|
+
const url = error?.span?.url;
|
|
38
|
+
if (url?.protocol === "file:") addDependency(fileURLToPath(url));
|
|
39
|
+
throw error;
|
|
40
|
+
});
|
|
41
|
+
options.signal?.throwIfAborted();
|
|
42
|
+
for (const url of result.loadedUrls ?? []) if (url.protocol === "file:") addDependency(fileURLToPath(url));
|
|
43
|
+
options.signal?.throwIfAborted();
|
|
44
|
+
return Object.freeze({
|
|
45
|
+
id,
|
|
46
|
+
baseFile,
|
|
47
|
+
source: result.css,
|
|
48
|
+
dependencies: Object.freeze([...dependencies]),
|
|
49
|
+
...result.sourceMap ? { sourceMap: JSON.stringify(result.sourceMap) } : {}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export { prepareSassSource };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { MasterCSSManifest } from "@master/css-schema/manifest";
|
|
2
|
+
import { PreparedCSSImportGraph } from "../node-imports.js";
|
|
3
|
+
import { StylesheetDeliveryOptions, StylesheetResourceAsset } from "./delivery.js";
|
|
4
|
+
import { CompileCSSOptions, CompileCSSResult } from "../node-compiler.js";
|
|
5
|
+
import { MasterCSSEmittedGlobals } from "@master/css-schema/emitted-globals";
|
|
6
|
+
import { StylesheetDirectives, StylesheetSourceOptions } from "./directives.js";
|
|
7
|
+
import { StylesheetSourceContext } from "./source-context.js";
|
|
8
|
+
import { RenderCompiledManifestCSSResult } from "./render.js";
|
|
9
|
+
interface SassModule {
|
|
10
|
+
compileStringAsync(source: string, options: {
|
|
11
|
+
url: URL;
|
|
12
|
+
style: 'expanded';
|
|
13
|
+
syntax: 'scss' | 'indented';
|
|
14
|
+
sourceMap?: boolean;
|
|
15
|
+
sourceMapIncludeSources?: boolean;
|
|
16
|
+
}): Promise<{
|
|
17
|
+
css: string;
|
|
18
|
+
loadedUrls?: readonly URL[];
|
|
19
|
+
sourceMap?: object;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
interface StylesheetPreparationOptions {
|
|
23
|
+
readonly projectDir?: string;
|
|
24
|
+
readonly baseFile?: string;
|
|
25
|
+
readonly loadSass?: (projectDir?: string) => SassModule;
|
|
26
|
+
readonly onDependency?: (file: string) => void;
|
|
27
|
+
readonly signal?: AbortSignal;
|
|
28
|
+
}
|
|
29
|
+
interface PreparedStylesheetSource {
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly baseFile: string;
|
|
32
|
+
readonly source: string;
|
|
33
|
+
readonly dependencies: readonly string[];
|
|
34
|
+
/** Serialized Sass source map v3, including original source contents. */
|
|
35
|
+
readonly sourceMap?: string;
|
|
36
|
+
}
|
|
37
|
+
interface CompileStylesheetOptions extends CompileCSSOptions, StylesheetSourceContext {
|
|
38
|
+
/** Absolute definition files supplied by a host, before authored references. */
|
|
39
|
+
readonly referenceFiles?: readonly string[];
|
|
40
|
+
/** Internal metadata retained when source collection removes import directives. */
|
|
41
|
+
references?: CompileCSSResult['references'];
|
|
42
|
+
delivery?: StylesheetDeliveryOptions;
|
|
43
|
+
readonly baseManifest: MasterCSSManifest;
|
|
44
|
+
projectDir?: string;
|
|
45
|
+
loadSass?: (projectDir?: string) => SassModule;
|
|
46
|
+
}
|
|
47
|
+
interface CompileRenderedStylesheetOptions extends CompileStylesheetOptions {
|
|
48
|
+
/** Globals already present outside this render; emit only additional resources. */
|
|
49
|
+
readonly emittedGlobals?: MasterCSSEmittedGlobals;
|
|
50
|
+
}
|
|
51
|
+
interface CompileRenderedStylesheetResult extends CompileCSSResult {
|
|
52
|
+
/** Present with delivery options; publish every returned stylesheet at its href. */
|
|
53
|
+
entry?: string;
|
|
54
|
+
stylesheets?: readonly {
|
|
55
|
+
readonly id: string;
|
|
56
|
+
readonly href: string;
|
|
57
|
+
readonly css: string;
|
|
58
|
+
readonly sourceMap: string;
|
|
59
|
+
}[];
|
|
60
|
+
resources?: readonly StylesheetResourceAsset[];
|
|
61
|
+
emittedGlobals: Required<MasterCSSEmittedGlobals>;
|
|
62
|
+
manifest: MasterCSSManifest;
|
|
63
|
+
renderedCSS: RenderCompiledManifestCSSResult;
|
|
64
|
+
}
|
|
65
|
+
interface TransformLocalStylesheetResult {
|
|
66
|
+
globalStylesheet?: {
|
|
67
|
+
readonly css: string;
|
|
68
|
+
readonly sourceMap?: string;
|
|
69
|
+
};
|
|
70
|
+
stylesheets?: readonly {
|
|
71
|
+
readonly id: string;
|
|
72
|
+
readonly href: string;
|
|
73
|
+
readonly css: string;
|
|
74
|
+
readonly sourceMap?: string;
|
|
75
|
+
}[];
|
|
76
|
+
resources?: readonly StylesheetResourceAsset[];
|
|
77
|
+
code: string;
|
|
78
|
+
dependencies: string[];
|
|
79
|
+
transformed: boolean;
|
|
80
|
+
result?: CompileCSSResult;
|
|
81
|
+
}
|
|
82
|
+
interface TransformLocalStylesheetOptions extends CompileStylesheetOptions {
|
|
83
|
+
preserveUnchangedNativeCSS?: boolean;
|
|
84
|
+
/** Keep generated root/mode resources outside a host's locally scoped CSS. */
|
|
85
|
+
generatedGlobals?: 'inline' | 'separate';
|
|
86
|
+
transformNativeStylesheets?: boolean;
|
|
87
|
+
emittedGlobals?: MasterCSSEmittedGlobals;
|
|
88
|
+
}
|
|
89
|
+
type RegisterStylesheetSourceOptions = CompileStylesheetOptions;
|
|
90
|
+
type CreateStyleEntryEmittedGlobalsOptions = CompileStylesheetOptions;
|
|
91
|
+
interface CreateStyleEntryEmittedGlobalsResult {
|
|
92
|
+
emittedGlobals: Required<MasterCSSEmittedGlobals>;
|
|
93
|
+
dependencies: string[];
|
|
94
|
+
}
|
|
95
|
+
interface CreateExtractedCSSOptions extends CompileStylesheetOptions {
|
|
96
|
+
scanner: ScannerState;
|
|
97
|
+
stylesheetSources?: StylesheetSources;
|
|
98
|
+
manifest?: MasterCSSManifest;
|
|
99
|
+
includeGeneratedCSS?: boolean;
|
|
100
|
+
includeNativeCSS?: boolean;
|
|
101
|
+
includeMasterBaseCSS?: boolean;
|
|
102
|
+
}
|
|
103
|
+
interface CreateExtractedCSSResult {
|
|
104
|
+
stylesheets?: readonly {
|
|
105
|
+
readonly id: string;
|
|
106
|
+
readonly href: string;
|
|
107
|
+
readonly css: string;
|
|
108
|
+
readonly sourceMap?: string;
|
|
109
|
+
}[];
|
|
110
|
+
resources?: readonly StylesheetResourceAsset[];
|
|
111
|
+
dependencies?: readonly string[];
|
|
112
|
+
css: string;
|
|
113
|
+
emittedGlobals: Required<MasterCSSEmittedGlobals>;
|
|
114
|
+
}
|
|
115
|
+
interface ScannerCSSState {
|
|
116
|
+
readonly text: string;
|
|
117
|
+
readonly manifest: MasterCSSManifest;
|
|
118
|
+
}
|
|
119
|
+
interface ScannerClassState extends Iterable<string> {
|
|
120
|
+
readonly size: number;
|
|
121
|
+
has(className: string): boolean;
|
|
122
|
+
}
|
|
123
|
+
interface ScannerState {
|
|
124
|
+
cwd: string;
|
|
125
|
+
options: StylesheetSourceOptions;
|
|
126
|
+
customOptions?: StylesheetSourceOptions & {
|
|
127
|
+
manifest?: MasterCSSManifest;
|
|
128
|
+
};
|
|
129
|
+
css: ScannerCSSState;
|
|
130
|
+
latentClasses: ScannerClassState;
|
|
131
|
+
validClasses: ScannerClassState;
|
|
132
|
+
usedNativeClasses: ScannerClassState;
|
|
133
|
+
nativeClassNames: ScannerClassState;
|
|
134
|
+
registerNativeClasses?: (owner: string, classNames: string[]) => boolean;
|
|
135
|
+
emit?: (event: 'change') => unknown;
|
|
136
|
+
}
|
|
137
|
+
interface StylesheetSource {
|
|
138
|
+
references?: CompileCSSResult['references'];
|
|
139
|
+
graph?: PreparedCSSImportGraph;
|
|
140
|
+
/** Derived from the registered graph's Rust extraction policies. */
|
|
141
|
+
classIndependent?: boolean;
|
|
142
|
+
source: string;
|
|
143
|
+
pruneNativeCSS: boolean;
|
|
144
|
+
masterCSS: boolean;
|
|
145
|
+
directives: StylesheetDirectives;
|
|
146
|
+
dependencies: string[];
|
|
147
|
+
sourceDependencies: string[];
|
|
148
|
+
}
|
|
149
|
+
type StylesheetSources = Map<string, StylesheetSource>;
|
|
150
|
+
interface ResolvedStylesheetSource {
|
|
151
|
+
references?: CompileCSSResult['references'];
|
|
152
|
+
source: string;
|
|
153
|
+
dependencies: string[];
|
|
154
|
+
}
|
|
155
|
+
interface ResolveStylesheetImportGraphOptions {
|
|
156
|
+
expandMasterCSSPackage?: boolean;
|
|
157
|
+
}
|
|
158
|
+
interface CreateStylesheetHostSourceOptions {
|
|
159
|
+
masterImport?: string;
|
|
160
|
+
masterSource?: string;
|
|
161
|
+
}
|
|
162
|
+
export { CompileRenderedStylesheetOptions, CompileRenderedStylesheetResult, CompileStylesheetOptions, CreateExtractedCSSOptions, CreateExtractedCSSResult, CreateStyleEntryEmittedGlobalsOptions, CreateStyleEntryEmittedGlobalsResult, CreateStylesheetHostSourceOptions, PreparedStylesheetSource, RegisterStylesheetSourceOptions, ResolveStylesheetImportGraphOptions, ResolvedStylesheetSource, SassModule, ScannerCSSState, ScannerClassState, ScannerState, StylesheetPreparationOptions, StylesheetSource, StylesheetSources, TransformLocalStylesheetOptions, TransformLocalStylesheetResult };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MasterCSSDiagnostic } from "@master/css-schema";
|
|
2
|
+
import { MasterCSSCompileOptions } from "./index.js";
|
|
3
|
+
import { CSSOutputMapping } from "@master/css-schema/css-directives";
|
|
4
|
+
type OffsetRange = {
|
|
5
|
+
readonly start: number;
|
|
6
|
+
readonly end: number;
|
|
7
|
+
};
|
|
8
|
+
type Origin = Pick<MasterCSSDiagnostic, 'source' | 'range'>;
|
|
9
|
+
interface ValidationSource {
|
|
10
|
+
readonly css: string;
|
|
11
|
+
readonly source?: string;
|
|
12
|
+
readonly mappings?: readonly CSSOutputMapping[];
|
|
13
|
+
readonly sources?: Readonly<Record<string, string>>;
|
|
14
|
+
readonly locate?: (range: OffsetRange) => Origin | undefined;
|
|
15
|
+
}
|
|
16
|
+
declare function assertValidationOptions(options: object): void;
|
|
17
|
+
/** Validate the complete emission before a host can publish any of its assets. */
|
|
18
|
+
declare function validateCompiledCSS(sources: readonly ValidationSource[], options?: Pick<MasterCSSCompileOptions, 'validation' | 'onDiagnostic'>): readonly MasterCSSDiagnostic[];
|
|
19
|
+
export { ValidationSource, assertValidationOptions, validateCompiledCSS };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { CSS_SYNTAX_CHECK, CSS_VALUE_CHECK, cssSyntaxStatus, validateRuleDeclarations } from "@master/css-tooling/validator";
|
|
2
|
+
import { MASTER_CSS_DIAGNOSTIC_VERSION, MasterCSSError } from "@master/css-schema";
|
|
3
|
+
// src/value-validation.ts
|
|
4
|
+
function position(text, offset) {
|
|
5
|
+
const lines = text.slice(0, offset).split(/\r\n?|\n/);
|
|
6
|
+
return {
|
|
7
|
+
line: lines.length - 1,
|
|
8
|
+
character: lines[lines.length - 1].length
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function origin(input, range) {
|
|
12
|
+
if (input.locate) return input.locate(range);
|
|
13
|
+
const mapping = input.mappings?.findLast((item) => item.generatedStart <= range.start && (item.generatedEnd === void 0 || range.start < item.generatedEnd));
|
|
14
|
+
if (!mapping) return;
|
|
15
|
+
const source = mapping.source.file ?? input.source;
|
|
16
|
+
const text = source ? input.sources?.[source] : void 0;
|
|
17
|
+
const reference = mapping.source;
|
|
18
|
+
if (text !== void 0) {
|
|
19
|
+
const unchanged = mapping.generatedEnd !== void 0 && text.slice(reference.range.start, reference.range.end) === input.css.slice(mapping.generatedStart, mapping.generatedEnd);
|
|
20
|
+
const start = unchanged ? reference.range.start + range.start - mapping.generatedStart : reference.range.start;
|
|
21
|
+
const end = unchanged ? Math.min(reference.range.end, reference.range.start + range.end - mapping.generatedStart) : reference.range.end;
|
|
22
|
+
return {
|
|
23
|
+
source,
|
|
24
|
+
range: {
|
|
25
|
+
start: position(text, start),
|
|
26
|
+
end: position(text, end)
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
source,
|
|
32
|
+
...reference.loc ? { range: {
|
|
33
|
+
start: {
|
|
34
|
+
line: reference.loc.start.line - 1,
|
|
35
|
+
character: reference.loc.start.column - 1
|
|
36
|
+
},
|
|
37
|
+
end: {
|
|
38
|
+
line: reference.loc.end.line - 1,
|
|
39
|
+
character: reference.loc.end.column - 1
|
|
40
|
+
}
|
|
41
|
+
} } : {}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function assertValidationOptions(options) {
|
|
45
|
+
if ("validation" in options && options.validation !== void 0 && options.validation !== "report" && options.validation !== "error") throw new MasterCSSError({
|
|
46
|
+
code: "INVALID_INPUT",
|
|
47
|
+
domain: "compiler",
|
|
48
|
+
message: "validation must be 'report' or 'error'."
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/** Validate the complete emission before a host can publish any of its assets. */
|
|
52
|
+
function validateCompiledCSS(sources, options = {}) {
|
|
53
|
+
assertValidationOptions(options);
|
|
54
|
+
const diagnostics = [];
|
|
55
|
+
for (const input of sources) {
|
|
56
|
+
const { css, source } = input;
|
|
57
|
+
if (cssSyntaxStatus(css) === "invalid") {
|
|
58
|
+
const diagnostic = Object.freeze({
|
|
59
|
+
version: MASTER_CSS_DIAGNOSTIC_VERSION,
|
|
60
|
+
code: "CSS_PARSE_ERROR",
|
|
61
|
+
domain: "compiler",
|
|
62
|
+
phase: "css-syntax",
|
|
63
|
+
severity: "error",
|
|
64
|
+
message: "Invalid CSS token structure in compiled output",
|
|
65
|
+
source: source ? `${source}#generated` : "<generated-css>",
|
|
66
|
+
notes: [`Checked with ${CSS_SYNTAX_CHECK.name} ${CSS_SYNTAX_CHECK.version}; no authored source offset is available.`]
|
|
67
|
+
});
|
|
68
|
+
diagnostics.push(diagnostic);
|
|
69
|
+
options.onDiagnostic?.(diagnostic);
|
|
70
|
+
}
|
|
71
|
+
for (const declaration of validateRuleDeclarations(css)) {
|
|
72
|
+
if (declaration.status !== "invalid" && declaration.status !== "unknown") continue;
|
|
73
|
+
const authored = declaration.range ? origin(input, declaration.range) : void 0;
|
|
74
|
+
const diagnostic = Object.freeze({
|
|
75
|
+
version: MASTER_CSS_DIAGNOSTIC_VERSION,
|
|
76
|
+
code: declaration.status === "invalid" ? "CSS_VALUE_INVALID" : "CSS_VALUE_UNKNOWN",
|
|
77
|
+
domain: "compiler",
|
|
78
|
+
phase: "css-value",
|
|
79
|
+
severity: declaration.status === "invalid" ? "error" : "information",
|
|
80
|
+
message: `${declaration.status === "invalid" ? "Invalid" : "Unverified"} CSS value: ${declaration.property}:${declaration.value}`,
|
|
81
|
+
...authored ?? { source: source ? `${source}#generated` : "<generated-css>" },
|
|
82
|
+
notes: [`Checked generated CSS with ${CSS_VALUE_CHECK.name} ${CSS_VALUE_CHECK.version}; browser support and computed values were not checked.`]
|
|
83
|
+
});
|
|
84
|
+
diagnostics.push(diagnostic);
|
|
85
|
+
options.onDiagnostic?.(diagnostic);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (options.validation === "error" && diagnostics.some((diagnostic) => diagnostic.severity === "error")) throw new MasterCSSError({
|
|
89
|
+
code: "CSS_VALUE_INVALID",
|
|
90
|
+
domain: "compiler",
|
|
91
|
+
message: "Strict CSS validation failed. No compilation result was published.",
|
|
92
|
+
diagnostics
|
|
93
|
+
});
|
|
94
|
+
return Object.freeze(diagnostics);
|
|
95
|
+
}
|
|
96
|
+
export { assertValidationOptions, validateCompiledCSS };
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@master/css-compiler",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"engines": {
|
|
5
|
+
"node": "^24"
|
|
6
|
+
},
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"description": "Compile Master CSS stylesheet directives",
|
|
9
|
+
"author": "Aoyue Design LLC.",
|
|
10
|
+
"homepage": "https://css.master.co",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/master-co/css/issues"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/master-co/css.git",
|
|
17
|
+
"directory": "packages/compiler"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"compiler",
|
|
21
|
+
"directives",
|
|
22
|
+
"css",
|
|
23
|
+
"mastercss"
|
|
24
|
+
],
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./node": {
|
|
34
|
+
"types": "./dist/node.d.ts",
|
|
35
|
+
"import": "./dist/node.js",
|
|
36
|
+
"default": "./dist/node.js"
|
|
37
|
+
},
|
|
38
|
+
"./project": {
|
|
39
|
+
"types": "./dist/project/manifest.d.ts",
|
|
40
|
+
"import": "./dist/project/manifest.js",
|
|
41
|
+
"default": "./dist/project/manifest.js"
|
|
42
|
+
},
|
|
43
|
+
"./project/sync": {
|
|
44
|
+
"types": "./dist/project/manifest-sync.d.ts",
|
|
45
|
+
"import": "./dist/project/manifest-sync.js",
|
|
46
|
+
"default": "./dist/project/manifest-sync.js"
|
|
47
|
+
},
|
|
48
|
+
"./stylesheet": {
|
|
49
|
+
"types": "./dist/stylesheet/index-public.d.ts",
|
|
50
|
+
"import": "./dist/stylesheet/index-public.js",
|
|
51
|
+
"default": "./dist/stylesheet/index-public.js"
|
|
52
|
+
},
|
|
53
|
+
"./stylesheet/browser": {
|
|
54
|
+
"types": "./dist/stylesheet/browser.d.ts",
|
|
55
|
+
"import": "./dist/stylesheet/browser.js",
|
|
56
|
+
"default": "./dist/stylesheet/browser.js"
|
|
57
|
+
},
|
|
58
|
+
"./diagnostics": {
|
|
59
|
+
"types": "./dist/diagnostics/index.d.ts",
|
|
60
|
+
"import": "./dist/diagnostics/index.js",
|
|
61
|
+
"default": "./dist/diagnostics/index.js"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"files": [
|
|
65
|
+
"dist"
|
|
66
|
+
],
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"access": "public",
|
|
69
|
+
"provenance": true
|
|
70
|
+
},
|
|
71
|
+
"dependencies": {
|
|
72
|
+
"@master/css-binding": "0.0.0-site.1793659883.g69c9aebcf628",
|
|
73
|
+
"@master/css-schema": "0.0.0-site.1793659883.g69c9aebcf628",
|
|
74
|
+
"@master/css-tooling": "0.0.0-site.1793659883.g69c9aebcf628",
|
|
75
|
+
"fast-glob": "^3.3.3"
|
|
76
|
+
},
|
|
77
|
+
"version": "0.0.0-site.1793659883.g69c9aebcf628",
|
|
78
|
+
"gitHead": "69c9aebcf628eb529001b9fa1b3536306f1b139e"
|
|
79
|
+
}
|