@master/css-compiler 2.0.0-rc.73 → 2.0.0-rc.75
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/LICENSE +21 -0
- package/dist/browser.d.ts +23 -19
- package/dist/browser.js +42 -0
- package/dist/core.d.ts +43 -41
- package/dist/core.js +1639 -0
- package/dist/css-transform.d.ts +10 -6
- package/dist/css-transform.js +17 -0
- package/dist/diagnostics.d.ts +11 -0
- package/dist/diagnostics.js +12 -0
- package/dist/index.d.ts +41 -38
- package/dist/index.js +330 -0
- package/dist/lexer/imports.d.ts +16 -12
- package/dist/lexer/imports.js +38 -0
- package/dist/lexer/source.d.ts +6 -3
- package/dist/lexer/source.js +8 -0
- package/dist/lexer/standalone-master.d.ts +23 -19
- package/dist/lexer/standalone-master.js +219 -0
- package/dist/lower-css-directives.d.ts +18 -13
- package/dist/lower-css-directives.js +753 -0
- package/dist/master-css-manifest.d.ts +18 -12
- package/dist/master-css-manifest.js +546 -0
- package/dist/native-declaration.d.ts +6 -2
- package/dist/native-declaration.js +23 -0
- package/dist/utils/selectors.d.ts +6 -3
- package/dist/utils/selectors.js +49 -0
- package/dist/utils/unquote.d.ts +4 -1
- package/dist/utils/unquote.js +9 -0
- package/dist/utils/wrap-at-rules.d.ts +4 -1
- package/dist/utils/wrap-at-rules.js +11 -0
- package/package.json +69 -1
- package/dist/browser.mjs +0 -47
- package/dist/core.mjs +0 -2146
- package/dist/css-transform.mjs +0 -18
- package/dist/index.mjs +0 -395
- package/dist/lexer/imports.mjs +0 -44
- package/dist/lexer/source.mjs +0 -9
- package/dist/lexer/standalone-master.mjs +0 -233
- package/dist/lower-css-directives.mjs +0 -969
- package/dist/master-css-manifest.mjs +0 -760
- package/dist/native-declaration.mjs +0 -25
- package/dist/utils/selectors.mjs +0 -55
- package/dist/utils/unquote.mjs +0 -10
- package/dist/utils/wrap-at-rules.mjs +0 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Aoyue Design LLC.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import init from
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
export type * from
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import init from "lightningcss-wasm";
|
|
2
|
+
import { MasterCSSManifest } from "@master/css-schema/manifest";
|
|
3
|
+
import { CompileCSSOptions, CompileCSSResult } from "./core.js";
|
|
4
|
+
export type * from "./core.js";
|
|
5
|
+
|
|
6
|
+
//#region src/browser.d.ts
|
|
7
|
+
type CompileCSSManifestSourceOptions = CompileCSSOptions & {
|
|
8
|
+
baseManifest?: MasterCSSManifest;
|
|
7
9
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
interface CompileCSSManifestResult extends Omit<CompileCSSResult, 'manifestInput'> {
|
|
11
|
+
manifest: MasterCSSManifest;
|
|
12
|
+
directives: CompileCSSResult;
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
declare function initCSSCompiler(input?: Parameters<typeof init>[0]): Promise<void>;
|
|
15
|
+
declare function compileCSS(source: string, options?: CompileCSSOptions): Promise<CompileCSSResult>;
|
|
16
|
+
declare function compileCSSManifest(source: string, options?: CompileCSSManifestSourceOptions): Promise<CompileCSSManifestResult>;
|
|
17
|
+
declare function parseDirectives(source: string, options?: CompileCSSOptions): Promise<{
|
|
18
|
+
styleDefinitions?: import("@master/css-schema/css-directives").CSSDirectiveStyleDefinition[] | undefined;
|
|
19
|
+
manifestInput: import("@master/css-schema/css-directives").CSSDirectiveManifestInput;
|
|
20
|
+
extractionPolicy: import("@master/css-schema/css-directives").CSSDirectiveExtractionPolicy;
|
|
21
|
+
classNames: string[];
|
|
22
|
+
nativeClassNames: string[];
|
|
23
|
+
warnings: string[];
|
|
22
24
|
}>;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { CompileCSSManifestResult, CompileCSSManifestSourceOptions, compileCSS, compileCSSManifest, initCSSCompiler, parseDirectives };
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { setCSSTransform } from "./css-transform.js";
|
|
2
|
+
import { compileCSS as compileCSS$1, parseDirectives as parseDirectives$1 } from "./core.js";
|
|
3
|
+
import lowerCSSDirectives from "./lower-css-directives.js";
|
|
4
|
+
import init, { transform } from "lightningcss-wasm";
|
|
5
|
+
//#region src/browser.ts
|
|
6
|
+
let initPromise;
|
|
7
|
+
async function initCSSCompiler(input) {
|
|
8
|
+
initPromise ??= init(input).then(() => {
|
|
9
|
+
setCSSTransform(transform);
|
|
10
|
+
});
|
|
11
|
+
await initPromise;
|
|
12
|
+
}
|
|
13
|
+
async function compileCSS(source, options = {}) {
|
|
14
|
+
await initCSSCompiler();
|
|
15
|
+
return compileCSS$1(source, options);
|
|
16
|
+
}
|
|
17
|
+
async function compileCSSManifest(source, options = {}) {
|
|
18
|
+
const result = await compileCSS(source, options);
|
|
19
|
+
if (result.references?.length) throw new Error("Browser compileCSSManifest cannot resolve @reference directives. Inline referenced CSS or compile the stylesheet in a Node environment.");
|
|
20
|
+
const { manifestInput: _manifestInput, ...directiveData } = result;
|
|
21
|
+
const lowerResult = lowerCSSDirectives(result, {
|
|
22
|
+
baseManifest: options.baseManifest,
|
|
23
|
+
onWarning: options.onWarning
|
|
24
|
+
});
|
|
25
|
+
const generatedCSS = lowerResult.generatedCSS || "";
|
|
26
|
+
const css = [result.nativeCSS, generatedCSS].filter(Boolean).join("\n");
|
|
27
|
+
return {
|
|
28
|
+
...directiveData,
|
|
29
|
+
dependencies: [],
|
|
30
|
+
manifest: lowerResult.manifest,
|
|
31
|
+
warnings: lowerResult.warnings,
|
|
32
|
+
generatedCSS,
|
|
33
|
+
css,
|
|
34
|
+
directives: result
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
async function parseDirectives(source, options = {}) {
|
|
38
|
+
await initCSSCompiler();
|
|
39
|
+
return parseDirectives$1(source, options);
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { compileCSS, compileCSSManifest, initCSSCompiler, parseDirectives };
|
package/dist/core.d.ts
CHANGED
|
@@ -1,48 +1,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { collectStandaloneCSSDirectiveExtractionPolicy, createCSSDirectiveExtractionPolicy, findStandaloneCSSDirectiveStatements, findStandaloneMasterDirectiveStatements, mergeCSSDirectiveExtractionPolicy, removeStandaloneCSSDirectives, removeStandaloneMasterDirectives
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { CSSDirectiveManifestInput, CSSDirectiveReference, CSSDirectiveResult, CSSDirectiveStyleDefinition } from "@master/css-schema/css-directives";
|
|
2
|
+
import { CSSDirectiveRuleRange, createSourceLocationResolver } from "@master/css-lexer";
|
|
3
|
+
import { CSSTransform, setCSSTransform } from "./css-transform.js";
|
|
4
|
+
import { StandaloneCSSDirectiveStatement, StandaloneMasterDirectiveStatement, collectStandaloneCSSDirectiveExtractionPolicy, createCSSDirectiveExtractionPolicy, findStandaloneCSSDirectiveStatements, findStandaloneMasterDirectiveStatements, mergeCSSDirectiveExtractionPolicy, removeStandaloneCSSDirectives, removeStandaloneMasterDirectives } from "./lexer/standalone-master.js";
|
|
5
|
+
|
|
6
|
+
//#region src/core.d.ts
|
|
7
|
+
interface CompileCSSOptions {
|
|
8
|
+
classes?: string[];
|
|
9
|
+
from?: string;
|
|
10
|
+
preserveNativeCSS?: boolean;
|
|
11
|
+
onWarning?: (warning: string) => void;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
interface CompileCSSFileOptions extends CompileCSSOptions {
|
|
14
|
+
root?: string;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
type CompileCSSResult = CSSDirectiveResult;
|
|
17
|
+
interface ResolvedCSSImportGraph {
|
|
18
|
+
source: string;
|
|
19
|
+
dependencies: string[];
|
|
20
|
+
references?: CSSDirectiveReference[];
|
|
21
21
|
}
|
|
22
22
|
type ParsedStyleDefinition = CSSDirectiveStyleDefinition;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
interface ParsedDirectives extends Pick<CompileCSSResult, 'manifestInput' | 'extractionPolicy' | 'classNames' | 'nativeClassNames' | 'warnings'> {
|
|
24
|
+
styleDefinitions?: ParsedStyleDefinition[];
|
|
25
|
+
styleOrder?: number;
|
|
26
|
+
source?: string;
|
|
27
|
+
filename?: string;
|
|
28
|
+
composeRanges?: CSSDirectiveRuleRange[];
|
|
29
|
+
composeRangeIndex?: number;
|
|
30
|
+
sourceLocationResolver?: ReturnType<typeof createSourceLocationResolver>;
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
interface CSSReferenceStatement extends CSSDirectiveReference {
|
|
33
|
+
start: number;
|
|
34
|
+
end: number;
|
|
35
|
+
statement: string;
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
declare function findCSSReferenceStatements(source: string, filename?: string): CSSReferenceStatement[];
|
|
38
|
+
declare function removeCSSReferenceStatements(source: string, filename?: string): string;
|
|
39
|
+
declare function maskManagedPatternEntryNames(source: string): string;
|
|
40
|
+
declare function compileCSS(source: string, options?: CompileCSSOptions): CompileCSSResult;
|
|
41
|
+
declare function parseDirectives(source: string, options?: CompileCSSOptions): {
|
|
42
|
+
styleDefinitions?: CSSDirectiveStyleDefinition[] | undefined;
|
|
43
|
+
manifestInput: CSSDirectiveManifestInput;
|
|
44
|
+
extractionPolicy: import("@master/css-schema/css-directives").CSSDirectiveExtractionPolicy;
|
|
45
|
+
classNames: string[];
|
|
46
|
+
nativeClassNames: string[];
|
|
47
|
+
warnings: string[];
|
|
48
48
|
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { CSSReferenceStatement, type CSSTransform, CompileCSSFileOptions, CompileCSSOptions, CompileCSSResult, ParsedDirectives, ResolvedCSSImportGraph, type StandaloneCSSDirectiveStatement, type StandaloneMasterDirectiveStatement, collectStandaloneCSSDirectiveExtractionPolicy, compileCSS, createCSSDirectiveExtractionPolicy, findCSSReferenceStatements, findStandaloneCSSDirectiveStatements, findStandaloneMasterDirectiveStatements, maskManagedPatternEntryNames, mergeCSSDirectiveExtractionPolicy, parseDirectives, removeCSSReferenceStatements, removeStandaloneCSSDirectives, removeStandaloneMasterDirectives, setCSSTransform };
|