@sass/types 1.93.2
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 +20 -0
- package/README.md +6 -0
- package/package.json +18 -0
- package/types/compile.d.ts +342 -0
- package/types/deprecations.d.ts +290 -0
- package/types/exception.d.ts +41 -0
- package/types/importer.d.ts +471 -0
- package/types/index.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 +566 -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
|
+
}
|