@master/css-compiler 2.0.0-rc.72 → 2.0.0-rc.74

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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/dist/browser.d.ts +23 -19
  3. package/dist/browser.js +42 -0
  4. package/dist/core.d.ts +43 -41
  5. package/dist/core.js +1639 -0
  6. package/dist/css-transform.d.ts +10 -6
  7. package/dist/css-transform.js +17 -0
  8. package/dist/diagnostics.d.ts +11 -0
  9. package/dist/diagnostics.js +12 -0
  10. package/dist/index.d.ts +41 -38
  11. package/dist/index.js +330 -0
  12. package/dist/lexer/imports.d.ts +16 -12
  13. package/dist/lexer/imports.js +38 -0
  14. package/dist/lexer/source.d.ts +6 -3
  15. package/dist/lexer/source.js +8 -0
  16. package/dist/lexer/standalone-master.d.ts +23 -19
  17. package/dist/lexer/standalone-master.js +219 -0
  18. package/dist/lower-css-directives.d.ts +18 -13
  19. package/dist/lower-css-directives.js +753 -0
  20. package/dist/master-css-manifest.d.ts +18 -12
  21. package/dist/master-css-manifest.js +546 -0
  22. package/dist/native-declaration.d.ts +6 -2
  23. package/dist/native-declaration.js +23 -0
  24. package/dist/utils/selectors.d.ts +6 -3
  25. package/dist/utils/selectors.js +49 -0
  26. package/dist/utils/unquote.d.ts +4 -1
  27. package/dist/utils/unquote.js +9 -0
  28. package/dist/utils/wrap-at-rules.d.ts +4 -1
  29. package/dist/utils/wrap-at-rules.js +11 -0
  30. package/package.json +69 -1
  31. package/dist/browser.mjs +0 -47
  32. package/dist/core.mjs +0 -2146
  33. package/dist/css-transform.mjs +0 -18
  34. package/dist/index.mjs +0 -395
  35. package/dist/lexer/imports.mjs +0 -44
  36. package/dist/lexer/source.mjs +0 -9
  37. package/dist/lexer/standalone-master.mjs +0 -233
  38. package/dist/lower-css-directives.mjs +0 -969
  39. package/dist/master-css-manifest.mjs +0 -760
  40. package/dist/native-declaration.mjs +0 -25
  41. package/dist/utils/selectors.mjs +0 -55
  42. package/dist/utils/unquote.mjs +0 -10
  43. 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 'lightningcss-wasm';
2
- import type { MasterCSSManifest } from '@master/css-schema/manifest';
3
- import { type CompileCSSOptions, type CompileCSSResult } from './core';
4
- export type * from './core';
5
- export type CompileCSSManifestSourceOptions = CompileCSSOptions & {
6
- baseManifest?: MasterCSSManifest;
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
- export interface CompileCSSManifestResult extends Omit<CompileCSSResult, 'manifestInput'> {
9
- manifest: MasterCSSManifest;
10
- directives: CompileCSSResult;
10
+ interface CompileCSSManifestResult extends Omit<CompileCSSResult, 'manifestInput'> {
11
+ manifest: MasterCSSManifest;
12
+ directives: CompileCSSResult;
11
13
  }
12
- export declare function initCSSCompiler(input?: Parameters<typeof init>[0]): Promise<void>;
13
- export declare function compileCSS(source: string, options?: CompileCSSOptions): Promise<CompileCSSResult>;
14
- export declare function compileCSSManifest(source: string, options?: CompileCSSManifestSourceOptions): Promise<CompileCSSManifestResult>;
15
- export declare function parseDirectives(source: string, options?: CompileCSSOptions): Promise<{
16
- styleDefinitions?: import("~/packages/schema/src/css-directives").CSSDirectiveStyleDefinition[] | undefined;
17
- manifestInput: import("~/packages/schema/src/css-directives").CSSDirectiveManifestInput;
18
- extractionPolicy: import("~/packages/schema/src/css-directives").CSSDirectiveExtractionPolicy;
19
- classNames: string[];
20
- nativeClassNames: string[];
21
- warnings: string[];
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 };
@@ -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 { type CSSDirectiveManifestInput, type CSSDirectiveReference, type CSSDirectiveResult, type CSSDirectiveStyleDefinition } from '@master/css-schema/css-directives';
2
- import { setCSSTransform, type CSSTransform } from './css-transform';
3
- import { createSourceLocationResolver, type CSSDirectiveRuleRange } from '@master/css-lexer';
4
- import { collectStandaloneCSSDirectiveExtractionPolicy, createCSSDirectiveExtractionPolicy, findStandaloneCSSDirectiveStatements, findStandaloneMasterDirectiveStatements, mergeCSSDirectiveExtractionPolicy, removeStandaloneCSSDirectives, removeStandaloneMasterDirectives, type StandaloneCSSDirectiveStatement, type StandaloneMasterDirectiveStatement } from './lexer/standalone-master';
5
- export { collectStandaloneCSSDirectiveExtractionPolicy, createCSSDirectiveExtractionPolicy, findStandaloneCSSDirectiveStatements, findStandaloneMasterDirectiveStatements, mergeCSSDirectiveExtractionPolicy, removeStandaloneCSSDirectives, removeStandaloneMasterDirectives, setCSSTransform };
6
- export type { CSSTransform, StandaloneCSSDirectiveStatement, StandaloneMasterDirectiveStatement };
7
- export interface CompileCSSOptions {
8
- classes?: string[];
9
- from?: string;
10
- preserveNativeCSS?: boolean;
11
- onWarning?: (warning: string) => void;
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
- export interface CompileCSSFileOptions extends CompileCSSOptions {
14
- root?: string;
13
+ interface CompileCSSFileOptions extends CompileCSSOptions {
14
+ root?: string;
15
15
  }
16
- export type CompileCSSResult = CSSDirectiveResult;
17
- export interface ResolvedCSSImportGraph {
18
- source: string;
19
- dependencies: string[];
20
- references?: CSSDirectiveReference[];
16
+ type CompileCSSResult = CSSDirectiveResult;
17
+ interface ResolvedCSSImportGraph {
18
+ source: string;
19
+ dependencies: string[];
20
+ references?: CSSDirectiveReference[];
21
21
  }
22
22
  type ParsedStyleDefinition = CSSDirectiveStyleDefinition;
23
- export 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>;
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
- export interface CSSReferenceStatement extends CSSDirectiveReference {
33
- start: number;
34
- end: number;
35
- statement: string;
32
+ interface CSSReferenceStatement extends CSSDirectiveReference {
33
+ start: number;
34
+ end: number;
35
+ statement: string;
36
36
  }
37
- export declare function findCSSReferenceStatements(source: string, filename?: string): CSSReferenceStatement[];
38
- export declare function removeCSSReferenceStatements(source: string, filename?: string): string;
39
- export declare function maskManagedPatternEntryNames(source: string): string;
40
- export declare function compileCSS(source: string, options?: CompileCSSOptions): CompileCSSResult;
41
- export 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[];
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 };