sass-embedded-go 1.104.0-alpha0
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/README.md +37 -0
- package/lib/index.js +100 -0
- package/lib/index.js.map +1 -0
- package/lib/index.mjs +215 -0
- package/lib/src/canonicalize-context.js +31 -0
- package/lib/src/canonicalize-context.js.map +1 -0
- package/lib/src/compile.js +51 -0
- package/lib/src/compile.js.map +1 -0
- package/lib/src/compiler/async.js +187 -0
- package/lib/src/compiler/async.js.map +1 -0
- package/lib/src/compiler/sync.js +204 -0
- package/lib/src/compiler/sync.js.map +1 -0
- package/lib/src/compiler/utils.js +210 -0
- package/lib/src/compiler/utils.js.map +1 -0
- package/lib/src/compiler-module.js +64 -0
- package/lib/src/compiler-module.js.map +1 -0
- package/lib/src/compiler-path.js +82 -0
- package/lib/src/compiler-path.js.map +1 -0
- package/lib/src/deprecations.js +121 -0
- package/lib/src/deprecations.js.map +1 -0
- package/lib/src/deprotofy-span.js +41 -0
- package/lib/src/deprotofy-span.js.map +1 -0
- package/lib/src/dispatcher.js +241 -0
- package/lib/src/dispatcher.js.map +1 -0
- package/lib/src/elf.js +114 -0
- package/lib/src/elf.js.map +1 -0
- package/lib/src/exception.js +23 -0
- package/lib/src/exception.js.map +1 -0
- package/lib/src/function-registry.js +127 -0
- package/lib/src/function-registry.js.map +1 -0
- package/lib/src/importer-registry.js +201 -0
- package/lib/src/importer-registry.js.map +1 -0
- package/lib/src/legacy/importer.js +296 -0
- package/lib/src/legacy/importer.js.map +1 -0
- package/lib/src/legacy/index.js +329 -0
- package/lib/src/legacy/index.js.map +1 -0
- package/lib/src/legacy/resolve-path.js +133 -0
- package/lib/src/legacy/resolve-path.js.map +1 -0
- package/lib/src/legacy/utils.js +58 -0
- package/lib/src/legacy/utils.js.map +1 -0
- package/lib/src/legacy/value/base.js +18 -0
- package/lib/src/legacy/value/base.js.map +1 -0
- package/lib/src/legacy/value/color.js +65 -0
- package/lib/src/legacy/value/color.js.map +1 -0
- package/lib/src/legacy/value/index.js +23 -0
- package/lib/src/legacy/value/index.js.map +1 -0
- package/lib/src/legacy/value/list.js +50 -0
- package/lib/src/legacy/value/list.js.map +1 -0
- package/lib/src/legacy/value/map.js +74 -0
- package/lib/src/legacy/value/map.js.map +1 -0
- package/lib/src/legacy/value/number.js +60 -0
- package/lib/src/legacy/value/number.js.map +1 -0
- package/lib/src/legacy/value/string.js +27 -0
- package/lib/src/legacy/value/string.js.map +1 -0
- package/lib/src/legacy/value/wrap.js +115 -0
- package/lib/src/legacy/value/wrap.js.map +1 -0
- package/lib/src/logger.js +10 -0
- package/lib/src/logger.js.map +1 -0
- package/lib/src/message-transformer.js +108 -0
- package/lib/src/message-transformer.js.map +1 -0
- package/lib/src/messages.js +6 -0
- package/lib/src/messages.js.map +1 -0
- package/lib/src/packet-transformer.js +171 -0
- package/lib/src/packet-transformer.js.map +1 -0
- package/lib/src/protofier.js +492 -0
- package/lib/src/protofier.js.map +1 -0
- package/lib/src/request-tracker.js +52 -0
- package/lib/src/request-tracker.js.map +1 -0
- package/lib/src/utils.js +177 -0
- package/lib/src/utils.js.map +1 -0
- package/lib/src/value/argument-list.js +66 -0
- package/lib/src/value/argument-list.js.map +1 -0
- package/lib/src/value/boolean.js +69 -0
- package/lib/src/value/boolean.js.map +1 -0
- package/lib/src/value/calculations.js +114 -0
- package/lib/src/value/calculations.js.map +1 -0
- package/lib/src/value/color.js +869 -0
- package/lib/src/value/color.js.map +1 -0
- package/lib/src/value/function.js +74 -0
- package/lib/src/value/function.js.map +1 -0
- package/lib/src/value/index.js +166 -0
- package/lib/src/value/index.js.map +1 -0
- package/lib/src/value/list.js +101 -0
- package/lib/src/value/list.js.map +1 -0
- package/lib/src/value/map.js +92 -0
- package/lib/src/value/map.js.map +1 -0
- package/lib/src/value/mixin.js +50 -0
- package/lib/src/value/mixin.js.map +1 -0
- package/lib/src/value/null.js +49 -0
- package/lib/src/value/null.js.map +1 -0
- package/lib/src/value/number.js +583 -0
- package/lib/src/value/number.js.map +1 -0
- package/lib/src/value/string.js +118 -0
- package/lib/src/value/string.js.map +1 -0
- package/lib/src/value/utils.js +124 -0
- package/lib/src/value/utils.js.map +1 -0
- package/lib/src/vendor/deprecations.js +216 -0
- package/lib/src/vendor/deprecations.js.map +1 -0
- package/lib/src/vendor/embedded_sass_pb.js +432 -0
- package/lib/src/vendor/embedded_sass_pb.js.map +1 -0
- package/lib/src/vendor/sass/README.md +162 -0
- package/lib/src/vendor/sass/compile.d.ts +342 -0
- package/lib/src/vendor/sass/deprecations.d.ts +312 -0
- package/lib/src/vendor/sass/exception.d.ts +41 -0
- package/lib/src/vendor/sass/importer.d.ts +471 -0
- package/lib/src/vendor/sass/index.d.ts +122 -0
- package/lib/src/vendor/sass/index.m.d.ts +122 -0
- package/lib/src/vendor/sass/legacy/exception.d.ts +55 -0
- package/lib/src/vendor/sass/legacy/function.d.ts +757 -0
- package/lib/src/vendor/sass/legacy/importer.d.ts +169 -0
- package/lib/src/vendor/sass/legacy/options.d.ts +700 -0
- package/lib/src/vendor/sass/legacy/plugin_this.d.ts +74 -0
- package/lib/src/vendor/sass/legacy/render.d.ts +144 -0
- package/lib/src/vendor/sass/logger/index.d.ts +115 -0
- package/lib/src/vendor/sass/logger/source_location.d.ts +21 -0
- package/lib/src/vendor/sass/logger/source_span.d.ts +34 -0
- package/lib/src/vendor/sass/options.d.ts +468 -0
- package/lib/src/vendor/sass/util/promise_or.d.ts +17 -0
- package/lib/src/vendor/sass/value/argument_list.d.ts +47 -0
- package/lib/src/vendor/sass/value/boolean.d.ts +29 -0
- package/lib/src/vendor/sass/value/calculation.d.ts +137 -0
- package/lib/src/vendor/sass/value/color.d.ts +567 -0
- package/lib/src/vendor/sass/value/function.d.ts +22 -0
- package/lib/src/vendor/sass/value/index.d.ts +219 -0
- package/lib/src/vendor/sass/value/list.d.ts +54 -0
- package/lib/src/vendor/sass/value/map.d.ts +41 -0
- package/lib/src/vendor/sass/value/mixin.d.ts +14 -0
- package/lib/src/vendor/sass/value/number.d.ts +305 -0
- package/lib/src/vendor/sass/value/string.d.ts +84 -0
- package/lib/src/version.js +28 -0
- package/lib/src/version.js.map +1 -0
- package/package.json +36 -0
- package/types/compile.d.ts +342 -0
- package/types/deprecations.d.ts +312 -0
- package/types/exception.d.ts +41 -0
- package/types/importer.d.ts +471 -0
- package/types/index.d.ts +122 -0
- package/types/index.m.d.ts +122 -0
- package/types/legacy/exception.d.ts +55 -0
- package/types/legacy/function.d.ts +757 -0
- package/types/legacy/importer.d.ts +169 -0
- package/types/legacy/options.d.ts +700 -0
- package/types/legacy/plugin_this.d.ts +74 -0
- package/types/legacy/render.d.ts +144 -0
- package/types/logger/index.d.ts +115 -0
- package/types/logger/source_location.d.ts +21 -0
- package/types/logger/source_span.d.ts +34 -0
- package/types/options.d.ts +468 -0
- package/types/util/promise_or.d.ts +17 -0
- package/types/value/argument_list.d.ts +47 -0
- package/types/value/boolean.d.ts +29 -0
- package/types/value/calculation.d.ts +137 -0
- package/types/value/color.d.ts +567 -0
- package/types/value/function.d.ts +22 -0
- package/types/value/index.d.ts +219 -0
- package/types/value/list.d.ts +54 -0
- package/types/value/map.d.ts +41 -0
- package/types/value/mixin.d.ts +14 -0
- package/types/value/number.d.ts +305 -0
- package/types/value/string.d.ts +84 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {Value} from './index';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sass's [string type](https://sass-lang.com/documentation/values/strings).
|
|
5
|
+
*
|
|
6
|
+
* @category Custom Function
|
|
7
|
+
*/
|
|
8
|
+
export class SassString extends Value {
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new string.
|
|
11
|
+
*
|
|
12
|
+
* @param text - The contents of the string. For quoted strings, this is the
|
|
13
|
+
* semantic content—any escape sequences that were been written in the source
|
|
14
|
+
* text are resolved to their Unicode values. For unquoted strings, though,
|
|
15
|
+
* escape sequences are preserved as literal backslashes.
|
|
16
|
+
*
|
|
17
|
+
* @param options.quotes - Whether the string is quoted. Defaults to `true`.
|
|
18
|
+
*/
|
|
19
|
+
constructor(
|
|
20
|
+
text: string,
|
|
21
|
+
options?: {
|
|
22
|
+
quotes?: boolean;
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Creates an empty string.
|
|
28
|
+
*
|
|
29
|
+
* @param options.quotes - Whether the string is quoted. Defaults to `true`.
|
|
30
|
+
*/
|
|
31
|
+
constructor(options?: {quotes?: boolean});
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The contents of the string.
|
|
35
|
+
*
|
|
36
|
+
* For quoted strings, this is the semantic content—any escape sequences that
|
|
37
|
+
* were been written in the source text are resolved to their Unicode values.
|
|
38
|
+
* For unquoted strings, though, escape sequences are preserved as literal
|
|
39
|
+
* backslashes.
|
|
40
|
+
*
|
|
41
|
+
* This difference allows us to distinguish between identifiers with escapes,
|
|
42
|
+
* such as `url\u28 http://example.com\u29`, and unquoted strings that contain
|
|
43
|
+
* characters that aren't valid in identifiers, such as
|
|
44
|
+
* `url(http://example.com)`. Unfortunately, it also means that we don't
|
|
45
|
+
* consider `foo` and `f\6F\6F` the same string.
|
|
46
|
+
*/
|
|
47
|
+
get text(): string;
|
|
48
|
+
|
|
49
|
+
/** Whether this string has quotes. */
|
|
50
|
+
get hasQuotes(): boolean;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Sass's notion of this string's length.
|
|
54
|
+
*
|
|
55
|
+
* Sass treats strings as a series of Unicode code points while JavaScript
|
|
56
|
+
* treats them as a series of UTF-16 code units. For example, the character
|
|
57
|
+
* U+1F60A SMILING FACE WITH SMILING EYES is a single Unicode code point but
|
|
58
|
+
* is represented in UTF-16 as two code units (`0xD83D` and `0xDE0A`). So in
|
|
59
|
+
* JavaScript, `"n😊b".length` returns `4`, whereas in Sass
|
|
60
|
+
* `string.length("n😊b")` returns `3`.
|
|
61
|
+
*/
|
|
62
|
+
get sassLength(): number;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Converts `sassIndex` to a JavaScript index into {@link text}.
|
|
66
|
+
*
|
|
67
|
+
* Sass indices are one-based, while JavaScript indices are zero-based. Sass
|
|
68
|
+
* indices may also be negative in order to index from the end of the string.
|
|
69
|
+
*
|
|
70
|
+
* In addition, Sass indices refer to Unicode code points while JavaScript
|
|
71
|
+
* string indices refer to UTF-16 code units. For example, the character
|
|
72
|
+
* U+1F60A SMILING FACE WITH SMILING EYES is a single Unicode code point but
|
|
73
|
+
* is represented in UTF-16 as two code units (`0xD83D` and `0xDE0A`). So in
|
|
74
|
+
* JavaScript, `"n😊b".charCodeAt(1)` returns `0xD83D`, whereas in Sass
|
|
75
|
+
* `string.slice("n😊b", 1, 1)` returns `"😊"`.
|
|
76
|
+
*
|
|
77
|
+
* This function converts Sass's code point indices to JavaScript's code unit
|
|
78
|
+
* indices. This means it's O(n) in the length of `text`.
|
|
79
|
+
*
|
|
80
|
+
* @throws `Error` - If `sassIndex` isn't a number, if that number isn't an
|
|
81
|
+
* integer, or if that integer isn't a valid index for this string.
|
|
82
|
+
*/
|
|
83
|
+
sassIndexToStringIndex(sassIndex: Value, name?: string): number;
|
|
84
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2024 Google LLC. Use of this source code is governed by an
|
|
3
|
+
// MIT-style license that can be found in the LICENSE file or at
|
|
4
|
+
// https://opensource.org/licenses/MIT.
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Version = void 0;
|
|
7
|
+
class Version {
|
|
8
|
+
major;
|
|
9
|
+
minor;
|
|
10
|
+
patch;
|
|
11
|
+
constructor(major, minor, patch) {
|
|
12
|
+
this.major = major;
|
|
13
|
+
this.minor = minor;
|
|
14
|
+
this.patch = patch;
|
|
15
|
+
}
|
|
16
|
+
static parse(version) {
|
|
17
|
+
const match = version.match(/^(\d+)\.(\d+)\.(\d+)$/);
|
|
18
|
+
if (match === null) {
|
|
19
|
+
throw new Error(`Invalid version ${version}`);
|
|
20
|
+
}
|
|
21
|
+
return new Version(parseInt(match[1]), parseInt(match[2]), parseInt(match[3]));
|
|
22
|
+
}
|
|
23
|
+
toString() {
|
|
24
|
+
return `${this.major}.${this.minor}.${this.patch}`;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.Version = Version;
|
|
28
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../lib/src/version.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;;AAIvC;IAEa,KAAK;IACL,KAAK;IACL,KAAK;IAHhB,YACW,KAAa,EACb,KAAa,EACb,KAAa;qBAFb,KAAK;qBACL,KAAK;qBACL,KAAK;IACb,CAAC;IACJ,MAAM,CAAC,KAAK,CAAC,OAAe;QAC1B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;QACrD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,EAAE,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,IAAI,OAAO,CAChB,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAClB,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAClB,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CACnB,CAAC;IACJ,CAAC;IACD,QAAQ;QACN,OAAO,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;IACrD,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sass-embedded-go",
|
|
3
|
+
"version": "1.104.0-alpha0",
|
|
4
|
+
"description": "sass-embedded-compatible host API backed by the go-sass embedded compiler.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"types": "types/index.d.ts",
|
|
8
|
+
"files": ["lib/**/*", "types/**/*", "LICENSE", "README.md"],
|
|
9
|
+
"exports": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./types/index.m.d.ts",
|
|
12
|
+
"default": "./lib/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"types": "./types/index.d.ts",
|
|
15
|
+
"default": "./lib/index.js"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@bufbuild/protobuf": "2.13.0",
|
|
19
|
+
"colorjs.io": "0.5.2",
|
|
20
|
+
"immutable": "5.1.9",
|
|
21
|
+
"rxjs": "7.8.2",
|
|
22
|
+
"supports-color": "8.1.1",
|
|
23
|
+
"sync-child-process": "1.0.2",
|
|
24
|
+
"varint": "6.0.0"
|
|
25
|
+
},
|
|
26
|
+
"optionalDependencies": {
|
|
27
|
+
"sass-embedded-go-darwin-arm64": "1.104.0-alpha0",
|
|
28
|
+
"sass-embedded-go-darwin-x64": "1.104.0-alpha0",
|
|
29
|
+
"sass-embedded-go-linux-arm64": "1.104.0-alpha0",
|
|
30
|
+
"sass-embedded-go-linux-musl-arm64": "1.104.0-alpha0",
|
|
31
|
+
"sass-embedded-go-linux-musl-x64": "1.104.0-alpha0",
|
|
32
|
+
"sass-embedded-go-linux-x64": "1.104.0-alpha0",
|
|
33
|
+
"sass-embedded-go-win32-arm64": "1.104.0-alpha0",
|
|
34
|
+
"sass-embedded-go-win32-x64": "1.104.0-alpha0"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import {RawSourceMap} from 'source-map-js';
|
|
2
|
+
|
|
3
|
+
import {Options, StringOptions} from './options';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The result of compiling Sass to CSS. Returned by {@link compile}, {@link
|
|
7
|
+
* compileAsync}, {@link compileString}, and {@link compileStringAsync}.
|
|
8
|
+
*
|
|
9
|
+
* @category Compile
|
|
10
|
+
*/
|
|
11
|
+
export interface CompileResult {
|
|
12
|
+
/**
|
|
13
|
+
* The generated CSS.
|
|
14
|
+
*
|
|
15
|
+
* Note that this *never* includes a `sourceMapUrl` comment—it's up to the
|
|
16
|
+
* caller to determine where to save the source map and how to link to it from
|
|
17
|
+
* the stylesheet.
|
|
18
|
+
*/
|
|
19
|
+
css: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The canonical URLs of all the stylesheets that were loaded during the
|
|
23
|
+
* Sass compilation. The order of these URLs is not guaranteed.
|
|
24
|
+
*/
|
|
25
|
+
loadedUrls: URL[];
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The object representation of the source map that maps locations in the
|
|
29
|
+
* generated CSS back to locations in the Sass source code.
|
|
30
|
+
*
|
|
31
|
+
* This typically uses absolute `file:` URLs to refer to Sass files, although
|
|
32
|
+
* this can be controlled by having a custom {@link Importer} return {@link
|
|
33
|
+
* ImporterResult.sourceMapUrl}.
|
|
34
|
+
*
|
|
35
|
+
* This is set if and only if {@link Options.sourceMap} is `true`.
|
|
36
|
+
*/
|
|
37
|
+
sourceMap?: RawSourceMap;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The result of creating a synchronous compiler. Returned by
|
|
42
|
+
* {@link initCompiler}.
|
|
43
|
+
*
|
|
44
|
+
* @category Compile
|
|
45
|
+
*/
|
|
46
|
+
export class Compiler {
|
|
47
|
+
/**
|
|
48
|
+
* Throws an error if constructed directly, instead of via
|
|
49
|
+
* {@link initCompiler}.
|
|
50
|
+
*/
|
|
51
|
+
private constructor();
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The {@link compile} method exposed through a Compiler instance while it is
|
|
55
|
+
* active. If this is called after {@link dispose} on the Compiler
|
|
56
|
+
* instance, an error will be thrown.
|
|
57
|
+
*
|
|
58
|
+
* During the Compiler instance's lifespan, given the same input, this will
|
|
59
|
+
* return an identical result to the {@link compile} method exposed at the
|
|
60
|
+
* module root.
|
|
61
|
+
*/
|
|
62
|
+
compile(path: string, options?: Options<'sync'>): CompileResult;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The {@link compileString} method exposed through a Compiler instance while
|
|
66
|
+
* it is active. If this is called after {@link dispose} on the Compiler
|
|
67
|
+
* instance, an error will be thrown.
|
|
68
|
+
*
|
|
69
|
+
* During the Compiler instance's lifespan, given the same input, this will
|
|
70
|
+
* return an identical result to the {@link compileString} method exposed at
|
|
71
|
+
* the module root.
|
|
72
|
+
*/
|
|
73
|
+
compileString(source: string, options?: StringOptions<'sync'>): CompileResult;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Ends the lifespan of this Compiler instance. After this is invoked, all
|
|
77
|
+
* calls to the Compiler instance's {@link compile} or {@link compileString}
|
|
78
|
+
* methods will result in an error.
|
|
79
|
+
*/
|
|
80
|
+
dispose(): void;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The result of creating an asynchronous compiler. Returned by
|
|
85
|
+
* {@link initAsyncCompiler}.
|
|
86
|
+
*
|
|
87
|
+
* @category Compile
|
|
88
|
+
*/
|
|
89
|
+
export class AsyncCompiler {
|
|
90
|
+
/**
|
|
91
|
+
* Throws an error if constructed directly, instead of via
|
|
92
|
+
* {@link initAsyncCompiler}.
|
|
93
|
+
*/
|
|
94
|
+
private constructor();
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The {@link compileAsync} method exposed through an Async Compiler instance
|
|
98
|
+
* while it is active. If this is called after {@link dispose} on the Async
|
|
99
|
+
* Compiler instance, an error will be thrown.
|
|
100
|
+
*
|
|
101
|
+
* During the Async Compiler instance's lifespan, given the same input, this
|
|
102
|
+
* will return an identical result to the {@link compileAsync} method exposed
|
|
103
|
+
* at the module root.
|
|
104
|
+
*/
|
|
105
|
+
compileAsync(
|
|
106
|
+
path: string,
|
|
107
|
+
options?: Options<'async'>
|
|
108
|
+
): Promise<CompileResult>;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The {@link compileStringAsync} method exposed through an Async Compiler
|
|
112
|
+
* instance while it is active. If this is called after {@link dispose} on the
|
|
113
|
+
* Async Compiler instance, an error will be thrown.
|
|
114
|
+
*
|
|
115
|
+
* During the Async Compiler instance's lifespan, given the same input, this
|
|
116
|
+
* will return an identical result to the {@link compileStringAsync} method
|
|
117
|
+
* exposed at the module root.
|
|
118
|
+
*/
|
|
119
|
+
compileStringAsync(
|
|
120
|
+
source: string,
|
|
121
|
+
options?: StringOptions<'async'>
|
|
122
|
+
): Promise<CompileResult>;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Ends the lifespan of this Async Compiler instance. After this is invoked,
|
|
126
|
+
* all subsequent calls to the Compiler instance's `compileAsync` or
|
|
127
|
+
* `compileStringAsync` methods will result in an error.
|
|
128
|
+
*
|
|
129
|
+
* Any compilations that are submitted before `dispose` will not be cancelled,
|
|
130
|
+
* and will be allowed to settle.
|
|
131
|
+
*
|
|
132
|
+
* After all compilations have been settled and Sass completes any internal
|
|
133
|
+
* task cleanup, `dispose` will resolve its promise.
|
|
134
|
+
*/
|
|
135
|
+
dispose(): Promise<void>;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Synchronously compiles the Sass file at `path` to CSS. If it succeeds it
|
|
140
|
+
* returns a {@link CompileResult}, and if it fails it throws an {@link
|
|
141
|
+
* Exception}.
|
|
142
|
+
*
|
|
143
|
+
* This only allows synchronous {@link Importer}s and {@link CustomFunction}s.
|
|
144
|
+
*
|
|
145
|
+
* **Heads up!** When using the [sass-embedded] npm package for single
|
|
146
|
+
* compilations, **{@link compileAsync} is almost always faster than
|
|
147
|
+
* {@link compile}**, due to the overhead of emulating synchronous messaging
|
|
148
|
+
* with worker threads and concurrent compilations being blocked on main thread.
|
|
149
|
+
*
|
|
150
|
+
* If you are running multiple compilations with the [sass-embedded] npm
|
|
151
|
+
* package, using a {@link Compiler} will provide some speed improvements over
|
|
152
|
+
* the module-level methods, and an {@link AsyncCompiler} will be much faster.
|
|
153
|
+
*
|
|
154
|
+
* [sass-embedded]: https://www.npmjs.com/package/sass-embedded
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
*
|
|
158
|
+
* ```js
|
|
159
|
+
* const sass = require('sass');
|
|
160
|
+
*
|
|
161
|
+
* const result = sass.compile("style.scss");
|
|
162
|
+
* console.log(result.css);
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
* @category Compile
|
|
166
|
+
* @compatibility dart: "1.45.0", node: false
|
|
167
|
+
*/
|
|
168
|
+
export function compile(path: string, options?: Options<'sync'>): CompileResult;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Asynchronously compiles the Sass file at `path` to CSS. Returns a promise
|
|
172
|
+
* that resolves with a {@link CompileResult} if it succeeds and rejects with an
|
|
173
|
+
* {@link Exception} if it fails.
|
|
174
|
+
*
|
|
175
|
+
* This only allows synchronous or asynchronous {@link Importer}s and
|
|
176
|
+
* {@link CustomFunction}s.
|
|
177
|
+
*
|
|
178
|
+
* **Heads up!** When using the `sass` npm package, **{@link compile} is almost
|
|
179
|
+
* twice as fast as {@link compileAsync}**, due to the overhead of making the
|
|
180
|
+
* entire evaluation process asynchronous.
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
*
|
|
184
|
+
* ```js
|
|
185
|
+
* const sass = require('sass');
|
|
186
|
+
*
|
|
187
|
+
* const result = await sass.compileAsync("style.scss");
|
|
188
|
+
* console.log(result.css);
|
|
189
|
+
* ```
|
|
190
|
+
*
|
|
191
|
+
* @category Compile
|
|
192
|
+
* @compatibility dart: "1.45.0", node: false
|
|
193
|
+
*/
|
|
194
|
+
export function compileAsync(
|
|
195
|
+
path: string,
|
|
196
|
+
options?: Options<'async'>
|
|
197
|
+
): Promise<CompileResult>;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Synchronously compiles a stylesheet whose contents is `source` to CSS. If it
|
|
201
|
+
* succeeds it returns a {@link CompileResult}, and if it fails it throws an
|
|
202
|
+
* {@link Exception}.
|
|
203
|
+
*
|
|
204
|
+
* This only allows synchronous {@link Importer}s and {@link CustomFunction}s.
|
|
205
|
+
*
|
|
206
|
+
* **Heads up!** When using the [sass-embedded] npm package for single
|
|
207
|
+
* compilations, **{@link compileStringAsync} is almost always faster than
|
|
208
|
+
* {@link compileString}**, due to the overhead of emulating synchronous
|
|
209
|
+
* messaging with worker threads and concurrent compilations being blocked on
|
|
210
|
+
* main thread.
|
|
211
|
+
*
|
|
212
|
+
* If you are running multiple compilations with the [sass-embedded] npm
|
|
213
|
+
* package, using a {@link Compiler} will provide some speed improvements over
|
|
214
|
+
* the module-level methods, and an {@link AsyncCompiler} will be much faster.
|
|
215
|
+
*
|
|
216
|
+
* [sass-embedded]: https://www.npmjs.com/package/sass-embedded
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
*
|
|
220
|
+
* ```js
|
|
221
|
+
* const sass = require('sass');
|
|
222
|
+
*
|
|
223
|
+
* const result = sass.compileString(`
|
|
224
|
+
* h1 {
|
|
225
|
+
* font-size: 40px;
|
|
226
|
+
* code {
|
|
227
|
+
* font-face: Roboto Mono;
|
|
228
|
+
* }
|
|
229
|
+
* }`);
|
|
230
|
+
* console.log(result.css);
|
|
231
|
+
* ```
|
|
232
|
+
*
|
|
233
|
+
* @category Compile
|
|
234
|
+
* @compatibility dart: "1.45.0", node: false
|
|
235
|
+
*/
|
|
236
|
+
export function compileString(
|
|
237
|
+
source: string,
|
|
238
|
+
options?: StringOptions<'sync'>
|
|
239
|
+
): CompileResult;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Asynchronously compiles a stylesheet whose contents is `source` to CSS.
|
|
243
|
+
* Returns a promise that resolves with a {@link CompileResult} if it succeeds
|
|
244
|
+
* and rejects with an {@link Exception} if it fails.
|
|
245
|
+
*
|
|
246
|
+
* This only allows synchronous or asynchronous {@link Importer}s and {@link
|
|
247
|
+
* CustomFunction}s.
|
|
248
|
+
*
|
|
249
|
+
* **Heads up!** When using the `sass` npm package, **{@link compileString} is
|
|
250
|
+
* almost twice as fast as {@link compileStringAsync}**, due to the overhead
|
|
251
|
+
* of making the entire evaluation process asynchronous.
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
*
|
|
255
|
+
* ```js
|
|
256
|
+
* const sass = require('sass');
|
|
257
|
+
*
|
|
258
|
+
* const result = await sass.compileStringAsync(`
|
|
259
|
+
* h1 {
|
|
260
|
+
* font-size: 40px;
|
|
261
|
+
* code {
|
|
262
|
+
* font-face: Roboto Mono;
|
|
263
|
+
* }
|
|
264
|
+
* }`);
|
|
265
|
+
* console.log(result.css);
|
|
266
|
+
* ```
|
|
267
|
+
*
|
|
268
|
+
* @category Compile
|
|
269
|
+
* @compatibility dart: "1.45.0", node: false
|
|
270
|
+
*/
|
|
271
|
+
export function compileStringAsync(
|
|
272
|
+
source: string,
|
|
273
|
+
options?: StringOptions<'async'>
|
|
274
|
+
): Promise<CompileResult>;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Creates a synchronous {@link Compiler}. Each compiler instance exposes the
|
|
278
|
+
* {@link compile} and {@link compileString} methods within the lifespan of the
|
|
279
|
+
* Compiler. Given identical input, these methods will return results identical
|
|
280
|
+
* to their counterparts exposed at the module root. To use asynchronous
|
|
281
|
+
* compilation, use {@link initAsyncCompiler}.
|
|
282
|
+
*
|
|
283
|
+
* When calling the compile functions multiple times, using a compiler instance
|
|
284
|
+
* with the [sass-embedded] npm package is much faster than using the top-level
|
|
285
|
+
* compilation methods or the [sass] npm package.
|
|
286
|
+
*
|
|
287
|
+
* [sass-embedded]: https://www.npmjs.com/package/sass-embedded
|
|
288
|
+
*
|
|
289
|
+
* [sass]: https://www.npmjs.com/package/sass
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
*
|
|
293
|
+
* ```js
|
|
294
|
+
* const sass = require('sass');
|
|
295
|
+
* function setup() {
|
|
296
|
+
* const compiler = sass.initCompiler();
|
|
297
|
+
* const result1 = compiler.compileString('a {b: c}').css;
|
|
298
|
+
* const result2 = compiler.compileString('a {b: c}').css;
|
|
299
|
+
* compiler.dispose();
|
|
300
|
+
*
|
|
301
|
+
* // throws error
|
|
302
|
+
* const result3 = sass.compileString('a {b: c}').css;
|
|
303
|
+
* }
|
|
304
|
+
* ```
|
|
305
|
+
* @category Compile
|
|
306
|
+
* @compatibility dart: "1.70.0", node: false
|
|
307
|
+
*/
|
|
308
|
+
export function initCompiler(): Compiler;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Creates an asynchronous {@link AsyncCompiler}. Each compiler
|
|
312
|
+
* instance exposes the {@link compileAsync} and {@link compileStringAsync}
|
|
313
|
+
* methods within the lifespan of the Compiler. Given identical input, these
|
|
314
|
+
* methods will return results identical to their counterparts exposed at the
|
|
315
|
+
* module root. To use synchronous compilation, use {@link initCompiler};
|
|
316
|
+
*
|
|
317
|
+
* When calling the compile functions multiple times, using a compiler instance
|
|
318
|
+
* with the [sass-embedded] npm package is much faster than using the top-level
|
|
319
|
+
* compilation methods or the [sass] npm package.
|
|
320
|
+
*
|
|
321
|
+
* [sass-embedded]: https://www.npmjs.com/package/sass-embedded
|
|
322
|
+
*
|
|
323
|
+
* [sass]: https://www.npmjs.com/package/sass
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
*
|
|
327
|
+
* ```js
|
|
328
|
+
* const sass = require('sass');
|
|
329
|
+
* async function setup() {
|
|
330
|
+
* const compiler = await sass.initAsyncCompiler();
|
|
331
|
+
* const result1 = await compiler.compileStringAsync('a {b: c}').css;
|
|
332
|
+
* const result2 = await compiler.compileStringAsync('a {b: c}').css;
|
|
333
|
+
* await compiler.dispose();
|
|
334
|
+
*
|
|
335
|
+
* // throws error
|
|
336
|
+
* const result3 = await sass.compileStringAsync('a {b: c}').css;
|
|
337
|
+
* }
|
|
338
|
+
* ```
|
|
339
|
+
* @category Compile
|
|
340
|
+
* @compatibility dart: "1.70.0", node: false
|
|
341
|
+
*/
|
|
342
|
+
export function initAsyncCompiler(): Promise<AsyncCompiler>;
|