sass 1.43.5 → 1.45.0

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.
@@ -0,0 +1,168 @@
1
+ import {LegacyPluginThis} from './plugin_this';
2
+
3
+ /**
4
+ * The value of `this` in the context of a [[LegacyImporter]] function.
5
+ *
6
+ * @category Legacy
7
+ * @deprecated This is only used by the legacy [[render]] and [[renderSync]]
8
+ * APIs. Use [[Importer]] with [[compile]], [[compileString]], [[compileAsync]],
9
+ * and [[compileStringAsync]] instead.
10
+ */
11
+ interface LegacyImporterThis extends LegacyPluginThis {
12
+ /**
13
+ * Whether the importer is being invoked because of a Sass `@import` rule, as
14
+ * opposed to a `@use` or `@forward` rule.
15
+ *
16
+ * This should *only* be used for determining whether or not to load
17
+ * [import-only files](https://sass-lang.com/documentation/at-rules/import#import-only-files).
18
+ *
19
+ * @compatibility dart: "1.33.0", node: false
20
+ */
21
+ fromImport: boolean;
22
+ }
23
+
24
+ /**
25
+ * The result of running a [[LegacyImporter]]. It must be one of the following
26
+ * types:
27
+ *
28
+ * * An object with the key `contents` whose value is the contents of a stylesheet
29
+ * (in SCSS syntax). This causes Sass to load that stylesheet’s contents.
30
+ *
31
+ * * An object with the key `file` whose value is a path on disk. This causes Sass
32
+ * to load that file as though it had been imported directly.
33
+ *
34
+ * * `null`, which indicates that it doesn’t recognize the URL and another
35
+ * importer should be tried instead.
36
+ *
37
+ * * An [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
38
+ * object, indicating that importing failed.
39
+ *
40
+ * @category Legacy
41
+ * @deprecated This only works with the legacy [[render]] and [[renderSync]]
42
+ * APIs. Use [[ImporterResult]] with [[compile]], [[compileString]],
43
+ * [[compileAsync]], and [[compileStringAsync]] instead.
44
+ */
45
+ export type LegacyImporterResult =
46
+ | {file: string}
47
+ | {contents: string}
48
+ | Error
49
+ | null;
50
+
51
+ /**
52
+ * A synchronous callback that implements custom Sass loading logic for
53
+ * [`@import` rules](https://sass-lang.com/documentation/at-rules/import) and
54
+ * [`@use` rules](https://sass-lang.com/documentation/at-rules/use). This can be
55
+ * passed to [[LegacySharedOptions.importer]] for either [[render]] or
56
+ * [[renderSync]].
57
+ *
58
+ * See [[LegacySharedOptions.importer]] for more detailed documentation.
59
+ *
60
+ * ```js
61
+ * sass.renderSync({
62
+ * file: "style.scss",
63
+ * importer: [
64
+ * function(url, prev) {
65
+ * if (url != "big-headers") return null;
66
+ *
67
+ * return {
68
+ * contents: 'h1 { font-size: 40px; }'
69
+ * };
70
+ * }
71
+ * ]
72
+ * });
73
+ * ```
74
+ *
75
+ * @param url - The `@use` or `@import` rule’s URL as a string, exactly as it
76
+ * appears in the stylesheet.
77
+ *
78
+ * @param prev - A string identifying the stylesheet that contained the `@use`
79
+ * or `@import`. This string’s format depends on how that stylesheet was loaded:
80
+ *
81
+ * * If the stylesheet was loaded from the filesystem, it’s the absolute path of
82
+ * its file.
83
+ * * If the stylesheet was loaded from an importer that returned its contents,
84
+ * it’s the URL of the `@use` or `@import` rule that loaded it.
85
+ * * If the stylesheet came from the data option, it’s the string "stdin".
86
+ *
87
+ * @category Legacy
88
+ * @deprecated This only works with the legacy [[render]] and [[renderSync]]
89
+ * APIs. Use [[Importer]] with [[compile]], [[compileString]], [[compileAsync]],
90
+ * and [[compileStringAsync]] instead.
91
+ */
92
+ type LegacySyncImporter = (
93
+ this: LegacyImporterThis,
94
+ url: string,
95
+ prev: string
96
+ ) => LegacyImporterResult;
97
+
98
+ /**
99
+ * An asynchronous callback that implements custom Sass loading logic for
100
+ * [`@import` rules](https://sass-lang.com/documentation/at-rules/import) and
101
+ * [`@use` rules](https://sass-lang.com/documentation/at-rules/use). This can be
102
+ * passed to [[LegacySharedOptions.importer]] for either [[render]] or
103
+ * [[renderSync]].
104
+ *
105
+ * An asynchronous importer must return `undefined`, and then call `done` with
106
+ * the result of its [[LegacyImporterResult]] once it's done running.
107
+ *
108
+ * See [[LegacySharedOptions.importer]] for more detailed documentation.
109
+ *
110
+ * ```js
111
+ * sass.render({
112
+ * file: "style.scss",
113
+ * importer: [
114
+ * function(url, prev, done) {
115
+ * if (url != "big-headers") done(null);
116
+ *
117
+ * done({
118
+ * contents: 'h1 { font-size: 40px; }'
119
+ * });
120
+ * }
121
+ * ]
122
+ * });
123
+ * ```
124
+ *
125
+ * @param url - The `@use` or `@import` rule’s URL as a string, exactly as it
126
+ * appears in the stylesheet.
127
+ *
128
+ * @param prev - A string identifying the stylesheet that contained the `@use`
129
+ * or `@import`. This string’s format depends on how that stylesheet was loaded:
130
+ *
131
+ * * If the stylesheet was loaded from the filesystem, it’s the absolute path of
132
+ * its file.
133
+ * * If the stylesheet was loaded from an importer that returned its contents,
134
+ * it’s the URL of the `@use` or `@import` rule that loaded it.
135
+ * * If the stylesheet came from the data option, it’s the string "stdin".
136
+ *
137
+ * @param done - The callback to call once the importer has finished running.
138
+ *
139
+ * @category Legacy
140
+ * @deprecated This only works with the legacy [[render]] and [[renderSync]]
141
+ * APIs. Use [[Importer]] with [[compile]], [[compileString]], [[compileAsync]],
142
+ * and [[compileStringAsync]] instead.
143
+ */
144
+ type LegacyAsyncImporter = (
145
+ this: LegacyImporterThis,
146
+ url: string,
147
+ prev: string,
148
+ done: (result: LegacyImporterResult) => void
149
+ ) => void;
150
+
151
+ /**
152
+ * A callback that implements custom Sass loading logic for [`@import`
153
+ * rules](https://sass-lang.com/documentation/at-rules/import) and [`@use`
154
+ * rules](https://sass-lang.com/documentation/at-rules/use). For [[renderSync]],
155
+ * this must be a [[LegacySyncImporter]] which returns its result directly; for
156
+ * [[render]], it may be either a [[LegacySyncImporter]] or a
157
+ * [[LegacyAsyncImporter]] which calls a callback with its result.
158
+ *
159
+ * See [[LegacySharedOptions.importer]] for more details.
160
+ *
161
+ * @category Legacy
162
+ * @deprecated This only works with the legacy [[render]] and [[renderSync]]
163
+ * APIs. Use [[Importer]] with [[compile]], [[compileString]], [[compileAsync]],
164
+ * and [[compileStringAsync]] instead.
165
+ */
166
+ export type LegacyImporter<sync = 'sync' | 'async'> = sync extends 'async'
167
+ ? LegacySyncImporter | LegacyAsyncImporter
168
+ : LegacySyncImporter;