sass 1.69.7 → 1.70.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.
package/sass.default.js CHANGED
@@ -10,6 +10,10 @@ export const compile = _cliPkgExports.compile;
10
10
  export const compileAsync = _cliPkgExports.compileAsync;
11
11
  export const compileString = _cliPkgExports.compileString;
12
12
  export const compileStringAsync = _cliPkgExports.compileStringAsync;
13
+ export const initCompiler = _cliPkgExports.initCompiler;
14
+ export const initAsyncCompiler = _cliPkgExports.initAsyncCompiler;
15
+ export const Compiler = _cliPkgExports.Compiler;
16
+ export const AsyncCompiler = _cliPkgExports.AsyncCompiler;
13
17
  export const Logger = _cliPkgExports.Logger;
14
18
  export const SassArgumentList = _cliPkgExports.SassArgumentList;
15
19
  export const SassBoolean = _cliPkgExports.SassBoolean;
package/sass.node.mjs CHANGED
@@ -4,6 +4,10 @@ export const compile = cjs.compile;
4
4
  export const compileAsync = cjs.compileAsync;
5
5
  export const compileString = cjs.compileString;
6
6
  export const compileStringAsync = cjs.compileStringAsync;
7
+ export const initCompiler = cjs.initCompiler;
8
+ export const initAsyncCompiler = cjs.initAsyncCompiler;
9
+ export const Compiler = cjs.Compiler;
10
+ export const AsyncCompiler = cjs.AsyncCompiler;
7
11
  export const Logger = cjs.Logger;
8
12
  export const SassArgumentList = cjs.SassArgumentList;
9
13
  export const SassBoolean = cjs.SassBoolean;
@@ -59,6 +63,22 @@ export default {
59
63
  defaultExportDeprecation();
60
64
  return cjs.compileStringAsync;
61
65
  },
66
+ get initCompiler() {
67
+ defaultExportDeprecation();
68
+ return cjs.initCompiler;
69
+ },
70
+ get initAsyncCompiler() {
71
+ defaultExportDeprecation();
72
+ return cjs.initAsyncCompiler;
73
+ },
74
+ get Compiler() {
75
+ defaultExportDeprecation();
76
+ return cjs.Compiler;
77
+ },
78
+ get AsyncCompiler() {
79
+ defaultExportDeprecation();
80
+ return cjs.AsyncCompiler;
81
+ },
62
82
  get Logger() {
63
83
  defaultExportDeprecation();
64
84
  return cjs.Logger;
@@ -37,6 +37,104 @@ export interface CompileResult {
37
37
  sourceMap?: RawSourceMap;
38
38
  }
39
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
+
40
138
  /**
41
139
  * Synchronously compiles the Sass file at `path` to CSS. If it succeeds it
42
140
  * returns a {@link CompileResult}, and if it fails it throws an {@link
@@ -44,10 +142,16 @@ export interface CompileResult {
44
142
  *
45
143
  * This only allows synchronous {@link Importer}s and {@link CustomFunction}s.
46
144
  *
47
- * **Heads up!** When using the `sass-embedded` npm package,
48
- * **{@link compileAsync} is almost always faster than {@link compile}**, due to
49
- * the overhead of emulating synchronous messaging with worker threads and
50
- * concurrent compilations being blocked on main thread.
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
51
155
  *
52
156
  * @example
53
157
  *
@@ -99,12 +203,18 @@ export function compileAsync(
99
203
  *
100
204
  * This only allows synchronous {@link Importer}s and {@link CustomFunction}s.
101
205
  *
102
- * **Heads up!** When using the `sass-embedded` npm package,
103
- * **{@link compileStringAsync} is almost always faster than
206
+ * **Heads up!** When using the [sass-embedded] npm package for single
207
+ * compilations, **{@link compileStringAsync} is almost always faster than
104
208
  * {@link compileString}**, due to the overhead of emulating synchronous
105
209
  * messaging with worker threads and concurrent compilations being blocked on
106
210
  * main thread.
107
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
+ *
108
218
  * @example
109
219
  *
110
220
  * ```js
@@ -162,3 +272,71 @@ export function compileStringAsync(
162
272
  source: string,
163
273
  options?: StringOptions<'async'>
164
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>;
package/types/index.d.ts CHANGED
@@ -3,11 +3,15 @@
3
3
  // implementations.
4
4
 
5
5
  export {
6
+ AsyncCompiler,
6
7
  CompileResult,
8
+ Compiler,
7
9
  compile,
8
10
  compileAsync,
9
11
  compileString,
10
12
  compileStringAsync,
13
+ initCompiler,
14
+ initAsyncCompiler,
11
15
  } from './compile';
12
16
  export {Exception} from './exception';
13
17
  export {