rearrage_stuff
This commit is contained in:
1693
node_modules/sass/LICENSE
generated
vendored
Normal file
1693
node_modules/sass/LICENSE
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
173
node_modules/sass/README.md
generated
vendored
Normal file
173
node_modules/sass/README.md
generated
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
A pure JavaScript implementation of [Sass][sass]. **Sass makes CSS fun again**.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img width="118px" alt="Sass logo" src="https://rawgit.com/sass/sass-site/master/source/assets/img/logos/logo.svg" />
|
||||
</td>
|
||||
<td valign="middle">
|
||||
<a href="https://www.npmjs.com/package/sass"><img width="100%" alt="npm statistics" src="https://nodei.co/npm/sass.png?downloads=true"></a>
|
||||
</td>
|
||||
<td valign="middle">
|
||||
<a href="https://github.com/sass/dart-sass/actions"><img alt="GitHub actions build status" src="https://github.com/sass/dart-sass/workflows/CI/badge.svg"></a>
|
||||
<br>
|
||||
<a href="https://ci.appveyor.com/project/nex3/dart-sass"><img alt="Appveyor build status" src="https://ci.appveyor.com/api/projects/status/84rl9hvu8uoecgef?svg=true"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
[sass]: https://sass-lang.com/
|
||||
|
||||
This package is a distribution of [Dart Sass][], compiled to pure JavaScript
|
||||
with no native code or external dependencies. It provides a command-line `sass`
|
||||
executable and a Node.js API.
|
||||
|
||||
[Dart Sass]: https://github.com/sass/dart-sass
|
||||
|
||||
* [Usage](#usage)
|
||||
* [See Also](#see-also)
|
||||
* [Behavioral Differences from Ruby Sass](#behavioral-differences-from-ruby-sass)
|
||||
|
||||
## Usage
|
||||
|
||||
You can install Sass globally using `npm install -g sass` which will provide
|
||||
access to the `sass` executable. You can also add it to your project using
|
||||
`npm install --save-dev sass`. This provides the executable as well as a
|
||||
library:
|
||||
|
||||
[npm]: https://www.npmjs.com/package/sass
|
||||
|
||||
```js
|
||||
const sass = require('sass');
|
||||
|
||||
const result = sass.compile(scssFilename);
|
||||
|
||||
// OR
|
||||
|
||||
// Note that `compileAsync()` is substantially slower than `compile()`.
|
||||
const result = await sass.compileAsync(scssFilename);
|
||||
```
|
||||
|
||||
See [the Sass website][js api] for full API documentation.
|
||||
|
||||
[js api]: https://sass-lang.com/documentation/js-api
|
||||
|
||||
### Legacy API
|
||||
|
||||
Dart Sass also supports an older JavaScript API that's fully compatible with
|
||||
[Node Sass] (with a few exceptions listed below), with support for both the
|
||||
[`render()`] and [`renderSync()`] functions. This API is considered deprecated
|
||||
and will be removed in Dart Sass 2.0.0, so it should be avoided in new projects.
|
||||
|
||||
[Node Sass]: https://github.com/sass/node-sass
|
||||
[`render()`]: https://sass-lang.com/documentation/js-api/functions/render
|
||||
[`renderSync()`]: https://sass-lang.com/documentation/js-api/functions/renderSync
|
||||
|
||||
Sass's support for the legacy JavaScript API has the following limitations:
|
||||
|
||||
* Only the `"expanded"` and `"compressed"` values of [`outputStyle`] are
|
||||
supported.
|
||||
|
||||
* Dart Sass doesn't support the [`precision`] option. Dart Sass defaults to a
|
||||
sufficiently high precision for all existing browsers, and making this
|
||||
customizable would make the code substantially less efficient.
|
||||
|
||||
* Dart Sass doesn't support the [`sourceComments`] option. Source maps are the
|
||||
recommended way of locating the origin of generated selectors.
|
||||
|
||||
[`outputStyle`]: https://sass-lang.com/documentation/js-api/interfaces/LegacySharedOptions#outputStyle
|
||||
[`precision`]: https://github.com/sass/node-sass#precision
|
||||
[`sourceComments`]: https://github.com/sass/node-sass#sourcecomments
|
||||
|
||||
## See Also
|
||||
|
||||
* [Dart Sass][], from which this package is compiled, can be used either as a
|
||||
stand-alone executable or as a Dart library. Running Dart Sass on the Dart VM
|
||||
is substantially faster than running the pure JavaScript version, so this may
|
||||
be appropriate for performance-sensitive applications. The Dart API is also
|
||||
(currently) more user-friendly than the JavaScript API. See
|
||||
[the Dart Sass README][Using Dart Sass] for details on how to use it.
|
||||
|
||||
* [Node Sass][], which is a wrapper around [LibSass][], the C++ implementation
|
||||
of Sass. Node Sass supports the same API as this package and is also faster
|
||||
(although it's usually a little slower than Dart Sass). However, it requires a
|
||||
native library which may be difficult to install, and it's generally slower to
|
||||
add features and fix bugs.
|
||||
|
||||
[Using Dart Sass]: https://github.com/sass/dart-sass#using-dart-sass
|
||||
[Node Sass]: https://www.npmjs.com/package/node-sass
|
||||
[LibSass]: https://sass-lang.com/libsass
|
||||
|
||||
## Behavioral Differences from Ruby Sass
|
||||
|
||||
There are a few intentional behavioral differences between Dart Sass and Ruby
|
||||
Sass. These are generally places where Ruby Sass has an undesired behavior, and
|
||||
it's substantially easier to implement the correct behavior than it would be to
|
||||
implement compatible behavior. These should all have tracking bugs against Ruby
|
||||
Sass to update the reference behavior.
|
||||
|
||||
1. `@extend` only accepts simple selectors, as does the second argument of
|
||||
`selector-extend()`. See [issue 1599][].
|
||||
|
||||
2. Subject selectors are not supported. See [issue 1126][].
|
||||
|
||||
3. Pseudo selector arguments are parsed as `<declaration-value>`s rather than
|
||||
having a more limited custom parsing. See [issue 2120][].
|
||||
|
||||
4. The numeric precision is set to 10. See [issue 1122][].
|
||||
|
||||
5. The indented syntax parser is more flexible: it doesn't require consistent
|
||||
indentation across the whole document. See [issue 2176][].
|
||||
|
||||
6. Colors do not support channel-by-channel arithmetic. See [issue 2144][].
|
||||
|
||||
7. Unitless numbers aren't `==` to unit numbers with the same value. In
|
||||
addition, map keys follow the same logic as `==`-equality. See
|
||||
[issue 1496][].
|
||||
|
||||
8. `rgba()` and `hsla()` alpha values with percentage units are interpreted as
|
||||
percentages. Other units are forbidden. See [issue 1525][].
|
||||
|
||||
9. Too many variable arguments passed to a function is an error. See
|
||||
[issue 1408][].
|
||||
|
||||
10. Allow `@extend` to reach outside a media query if there's an identical
|
||||
`@extend` defined outside that query. This isn't tracked explicitly, because
|
||||
it'll be irrelevant when [issue 1050][] is fixed.
|
||||
|
||||
11. Some selector pseudos containing placeholder selectors will be compiled
|
||||
where they wouldn't be in Ruby Sass. This better matches the semantics of
|
||||
the selectors in question, and is more efficient. See [issue 2228][].
|
||||
|
||||
12. The old-style `:property value` syntax is not supported in the indented
|
||||
syntax. See [issue 2245][].
|
||||
|
||||
13. The reference combinator is not supported. See [issue 303][].
|
||||
|
||||
14. Universal selector unification is symmetrical. See [issue 2247][].
|
||||
|
||||
15. `@extend` doesn't produce an error if it matches but fails to unify. See
|
||||
[issue 2250][].
|
||||
|
||||
16. Dart Sass currently only supports UTF-8 documents. We'd like to support
|
||||
more, but Dart currently doesn't support them. See [dart-lang/sdk#11744][],
|
||||
for example.
|
||||
|
||||
[issue 1599]: https://github.com/sass/sass/issues/1599
|
||||
[issue 1126]: https://github.com/sass/sass/issues/1126
|
||||
[issue 2120]: https://github.com/sass/sass/issues/2120
|
||||
[issue 1122]: https://github.com/sass/sass/issues/1122
|
||||
[issue 2176]: https://github.com/sass/sass/issues/2176
|
||||
[issue 2144]: https://github.com/sass/sass/issues/2144
|
||||
[issue 1496]: https://github.com/sass/sass/issues/1496
|
||||
[issue 1525]: https://github.com/sass/sass/issues/1525
|
||||
[issue 1408]: https://github.com/sass/sass/issues/1408
|
||||
[issue 1050]: https://github.com/sass/sass/issues/1050
|
||||
[issue 2228]: https://github.com/sass/sass/issues/2228
|
||||
[issue 2245]: https://github.com/sass/sass/issues/2245
|
||||
[issue 303]: https://github.com/sass/sass/issues/303
|
||||
[issue 2247]: https://github.com/sass/sass/issues/2247
|
||||
[issue 2250]: https://github.com/sass/sass/issues/2250
|
||||
[dart-lang/sdk#11744]: https://github.com/dart-lang/sdk/issues/11744
|
||||
|
||||
Disclaimer: this is not an official Google product.
|
||||
21
node_modules/sass/node_modules/chokidar/LICENSE
generated
vendored
Normal file
21
node_modules/sass/node_modules/chokidar/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012 Paul Miller (https://paulmillr.com), Elan Shanker
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the “Software”), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
305
node_modules/sass/node_modules/chokidar/README.md
generated
vendored
Normal file
305
node_modules/sass/node_modules/chokidar/README.md
generated
vendored
Normal file
@@ -0,0 +1,305 @@
|
||||
# Chokidar [](https://github.com/paulmillr/chokidar)
|
||||
|
||||
> Minimal and efficient cross-platform file watching library
|
||||
|
||||
## Why?
|
||||
|
||||
There are many reasons to prefer Chokidar to raw fs.watch / fs.watchFile in 2024:
|
||||
|
||||
- Events are properly reported
|
||||
- macOS events report filenames
|
||||
- events are not reported twice
|
||||
- changes are reported as add / change / unlink instead of useless `rename`
|
||||
- Atomic writes are supported, using `atomic` option
|
||||
- Some file editors use them
|
||||
- Chunked writes are supported, using `awaitWriteFinish` option
|
||||
- Large files are commonly written in chunks
|
||||
- File / dir filtering is supported
|
||||
- Symbolic links are supported
|
||||
- Recursive watching is always supported, instead of partial when using raw events
|
||||
- Includes a way to limit recursion depth
|
||||
|
||||
Chokidar relies on the Node.js core `fs` module, but when using
|
||||
`fs.watch` and `fs.watchFile` for watching, it normalizes the events it
|
||||
receives, often checking for truth by getting file stats and/or dir contents.
|
||||
The `fs.watch`-based implementation is the default, which
|
||||
avoids polling and keeps CPU usage down. Be advised that chokidar will initiate
|
||||
watchers recursively for everything within scope of the paths that have been
|
||||
specified, so be judicious about not wasting system resources by watching much
|
||||
more than needed. For some cases, `fs.watchFile`, which utilizes polling and uses more resources, is used.
|
||||
|
||||
Made for [Brunch](https://brunch.io/) in 2012,
|
||||
it is now used in [~30 million repositories](https://www.npmjs.com/browse/depended/chokidar) and
|
||||
has proven itself in production environments.
|
||||
|
||||
**Sep 2024 update:** v4 is out! It decreases dependency count from 13 to 1, removes
|
||||
support for globs, adds support for ESM / Common.js modules, and bumps minimum node.js version from v8 to v14.
|
||||
Check out [upgrading](#upgrading).
|
||||
|
||||
## Getting started
|
||||
|
||||
Install with npm:
|
||||
|
||||
```sh
|
||||
npm install chokidar
|
||||
```
|
||||
|
||||
Use it in your code:
|
||||
|
||||
```javascript
|
||||
import chokidar from 'chokidar';
|
||||
|
||||
// One-liner for current directory
|
||||
chokidar.watch('.').on('all', (event, path) => {
|
||||
console.log(event, path);
|
||||
});
|
||||
|
||||
|
||||
// Extended options
|
||||
// ----------------
|
||||
|
||||
// Initialize watcher.
|
||||
const watcher = chokidar.watch('file, dir, or array', {
|
||||
ignored: (path, stats) => stats?.isFile() && !path.endsWith('.js'), // only watch js files
|
||||
persistent: true
|
||||
});
|
||||
|
||||
// Something to use when events are received.
|
||||
const log = console.log.bind(console);
|
||||
// Add event listeners.
|
||||
watcher
|
||||
.on('add', path => log(`File ${path} has been added`))
|
||||
.on('change', path => log(`File ${path} has been changed`))
|
||||
.on('unlink', path => log(`File ${path} has been removed`));
|
||||
|
||||
// More possible events.
|
||||
watcher
|
||||
.on('addDir', path => log(`Directory ${path} has been added`))
|
||||
.on('unlinkDir', path => log(`Directory ${path} has been removed`))
|
||||
.on('error', error => log(`Watcher error: ${error}`))
|
||||
.on('ready', () => log('Initial scan complete. Ready for changes'))
|
||||
.on('raw', (event, path, details) => { // internal
|
||||
log('Raw event info:', event, path, details);
|
||||
});
|
||||
|
||||
// 'add', 'addDir' and 'change' events also receive stat() results as second
|
||||
// argument when available: https://nodejs.org/api/fs.html#fs_class_fs_stats
|
||||
watcher.on('change', (path, stats) => {
|
||||
if (stats) console.log(`File ${path} changed size to ${stats.size}`);
|
||||
});
|
||||
|
||||
// Watch new files.
|
||||
watcher.add('new-file');
|
||||
watcher.add(['new-file-2', 'new-file-3']);
|
||||
|
||||
// Get list of actual paths being watched on the filesystem
|
||||
let watchedPaths = watcher.getWatched();
|
||||
|
||||
// Un-watch some files.
|
||||
await watcher.unwatch('new-file');
|
||||
|
||||
// Stop watching. The method is async!
|
||||
await watcher.close().then(() => console.log('closed'));
|
||||
|
||||
// Full list of options. See below for descriptions.
|
||||
// Do not use this example!
|
||||
chokidar.watch('file', {
|
||||
persistent: true,
|
||||
|
||||
// ignore .txt files
|
||||
ignored: (file) => file.endsWith('.txt'),
|
||||
// watch only .txt files
|
||||
// ignored: (file, _stats) => _stats?.isFile() && !file.endsWith('.txt'),
|
||||
|
||||
awaitWriteFinish: true, // emit single event when chunked writes are completed
|
||||
atomic: true, // emit proper events when "atomic writes" (mv _tmp file) are used
|
||||
|
||||
// The options also allow specifying custom intervals in ms
|
||||
// awaitWriteFinish: {
|
||||
// stabilityThreshold: 2000,
|
||||
// pollInterval: 100
|
||||
// },
|
||||
// atomic: 100,
|
||||
|
||||
interval: 100,
|
||||
binaryInterval: 300,
|
||||
|
||||
cwd: '.',
|
||||
depth: 99,
|
||||
|
||||
followSymlinks: true,
|
||||
ignoreInitial: false,
|
||||
ignorePermissionErrors: false,
|
||||
usePolling: false,
|
||||
alwaysStat: false,
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
`chokidar.watch(paths, [options])`
|
||||
|
||||
* `paths` (string or array of strings). Paths to files, dirs to be watched
|
||||
recursively.
|
||||
* `options` (object) Options object as defined below:
|
||||
|
||||
#### Persistence
|
||||
|
||||
* `persistent` (default: `true`). Indicates whether the process
|
||||
should continue to run as long as files are being watched.
|
||||
|
||||
#### Path filtering
|
||||
|
||||
* `ignored` function, regex, or path. Defines files/paths to be ignored.
|
||||
The whole relative or absolute path is tested, not just filename. If a function with two arguments
|
||||
is provided, it gets called twice per path - once with a single argument (the path), second
|
||||
time with two arguments (the path and the
|
||||
[`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats)
|
||||
object of that path).
|
||||
* `ignoreInitial` (default: `false`). If set to `false` then `add`/`addDir` events are also emitted for matching paths while
|
||||
instantiating the watching as chokidar discovers these file paths (before the `ready` event).
|
||||
* `followSymlinks` (default: `true`). When `false`, only the
|
||||
symlinks themselves will be watched for changes instead of following
|
||||
the link references and bubbling events through the link's path.
|
||||
* `cwd` (no default). The base directory from which watch `paths` are to be
|
||||
derived. Paths emitted with events will be relative to this.
|
||||
|
||||
#### Performance
|
||||
|
||||
* `usePolling` (default: `false`).
|
||||
Whether to use fs.watchFile (backed by polling), or fs.watch. If polling
|
||||
leads to high CPU utilization, consider setting this to `false`. It is
|
||||
typically necessary to **set this to `true` to successfully watch files over
|
||||
a network**, and it may be necessary to successfully watch files in other
|
||||
non-standard situations. Setting to `true` explicitly on MacOS overrides the
|
||||
`useFsEvents` default. You may also set the CHOKIDAR_USEPOLLING env variable
|
||||
to true (1) or false (0) in order to override this option.
|
||||
* _Polling-specific settings_ (effective when `usePolling: true`)
|
||||
* `interval` (default: `100`). Interval of file system polling, in milliseconds. You may also
|
||||
set the CHOKIDAR_INTERVAL env variable to override this option.
|
||||
* `binaryInterval` (default: `300`). Interval of file system
|
||||
polling for binary files.
|
||||
([see list of binary extensions](https://github.com/sindresorhus/binary-extensions/blob/master/binary-extensions.json))
|
||||
* `alwaysStat` (default: `false`). If relying upon the
|
||||
[`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats)
|
||||
object that may get passed with `add`, `addDir`, and `change` events, set
|
||||
this to `true` to ensure it is provided even in cases where it wasn't
|
||||
already available from the underlying watch events.
|
||||
* `depth` (default: `undefined`). If set, limits how many levels of
|
||||
subdirectories will be traversed.
|
||||
* `awaitWriteFinish` (default: `false`).
|
||||
By default, the `add` event will fire when a file first appears on disk, before
|
||||
the entire file has been written. Furthermore, in some cases some `change`
|
||||
events will be emitted while the file is being written. In some cases,
|
||||
especially when watching for large files there will be a need to wait for the
|
||||
write operation to finish before responding to a file creation or modification.
|
||||
Setting `awaitWriteFinish` to `true` (or a truthy value) will poll file size,
|
||||
holding its `add` and `change` events until the size does not change for a
|
||||
configurable amount of time. The appropriate duration setting is heavily
|
||||
dependent on the OS and hardware. For accurate detection this parameter should
|
||||
be relatively high, making file watching much less responsive.
|
||||
Use with caution.
|
||||
* *`options.awaitWriteFinish` can be set to an object in order to adjust
|
||||
timing params:*
|
||||
* `awaitWriteFinish.stabilityThreshold` (default: 2000). Amount of time in
|
||||
milliseconds for a file size to remain constant before emitting its event.
|
||||
* `awaitWriteFinish.pollInterval` (default: 100). File size polling interval, in milliseconds.
|
||||
|
||||
#### Errors
|
||||
|
||||
* `ignorePermissionErrors` (default: `false`). Indicates whether to watch files
|
||||
that don't have read permissions if possible. If watching fails due to `EPERM`
|
||||
or `EACCES` with this set to `true`, the errors will be suppressed silently.
|
||||
* `atomic` (default: `true` if `useFsEvents` and `usePolling` are `false`).
|
||||
Automatically filters out artifacts that occur when using editors that use
|
||||
"atomic writes" instead of writing directly to the source file. If a file is
|
||||
re-added within 100 ms of being deleted, Chokidar emits a `change` event
|
||||
rather than `unlink` then `add`. If the default of 100 ms does not work well
|
||||
for you, you can override it by setting `atomic` to a custom value, in
|
||||
milliseconds.
|
||||
|
||||
### Methods & Events
|
||||
|
||||
`chokidar.watch()` produces an instance of `FSWatcher`. Methods of `FSWatcher`:
|
||||
|
||||
* `.add(path / paths)`: Add files, directories for tracking.
|
||||
Takes an array of strings or just one string.
|
||||
* `.on(event, callback)`: Listen for an FS event.
|
||||
Available events: `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `ready`,
|
||||
`raw`, `error`.
|
||||
Additionally `all` is available which gets emitted with the underlying event
|
||||
name and path for every event other than `ready`, `raw`, and `error`. `raw` is internal, use it carefully.
|
||||
* `.unwatch(path / paths)`: Stop watching files or directories.
|
||||
Takes an array of strings or just one string.
|
||||
* `.close()`: **async** Removes all listeners from watched files. Asynchronous, returns Promise. Use with `await` to ensure bugs don't happen.
|
||||
* `.getWatched()`: Returns an object representing all the paths on the file
|
||||
system being watched by this `FSWatcher` instance. The object's keys are all the
|
||||
directories (using absolute paths unless the `cwd` option was used), and the
|
||||
values are arrays of the names of the items contained in each directory.
|
||||
|
||||
### CLI
|
||||
|
||||
Check out third party [chokidar-cli](https://github.com/open-cli-tools/chokidar-cli),
|
||||
which allows to execute a command on each change, or get a stdio stream of change events.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Sometimes, Chokidar runs out of file handles, causing `EMFILE` and `ENOSP` errors:
|
||||
|
||||
* `bash: cannot set terminal process group (-1): Inappropriate ioctl for device bash: no job control in this shell`
|
||||
* `Error: watch /home/ ENOSPC`
|
||||
|
||||
There are two things that can cause it.
|
||||
|
||||
1. Exhausted file handles for generic fs operations
|
||||
- Can be solved by using [graceful-fs](https://www.npmjs.com/package/graceful-fs),
|
||||
which can monkey-patch native `fs` module used by chokidar: `let fs = require('fs'); let grfs = require('graceful-fs'); grfs.gracefulify(fs);`
|
||||
- Can also be solved by tuning OS: `echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p`.
|
||||
2. Exhausted file handles for `fs.watch`
|
||||
- Can't seem to be solved by graceful-fs or OS tuning
|
||||
- It's possible to start using `usePolling: true`, which will switch backend to resource-intensive `fs.watchFile`
|
||||
|
||||
All fsevents-related issues (`WARN optional dep failed`, `fsevents is not a constructor`) are solved by upgrading to v4+.
|
||||
|
||||
## Changelog
|
||||
|
||||
- **v4 (Sep 2024):** remove glob support and bundled fsevents. Decrease dependency count from 13 to 1. Rewrite in typescript. Bumps minimum node.js requirement to v14+
|
||||
- **v3 (Apr 2019):** massive CPU & RAM consumption improvements; reduces deps / package size by a factor of 17x and bumps Node.js requirement to v8.16+.
|
||||
- **v2 (Dec 2017):** globs are now posix-style-only. Tons of bugfixes.
|
||||
- **v1 (Apr 2015):** glob support, symlink support, tons of bugfixes. Node 0.8+ is supported
|
||||
- **v0.1 (Apr 2012):** Initial release, extracted from [Brunch](https://github.com/brunch/brunch/blob/9847a065aea300da99bd0753f90354cde9de1261/src/helpers.coffee#L66)
|
||||
|
||||
### Upgrading
|
||||
|
||||
If you've used globs before and want do replicate the functionality with v4:
|
||||
|
||||
```js
|
||||
// v3
|
||||
chok.watch('**/*.js');
|
||||
chok.watch("./directory/**/*");
|
||||
|
||||
// v4
|
||||
chok.watch('.', {
|
||||
ignored: (path, stats) => stats?.isFile() && !path.endsWith('.js'), // only watch js files
|
||||
});
|
||||
chok.watch('./directory');
|
||||
|
||||
// other way
|
||||
import { glob } from 'node:fs/promises';
|
||||
const watcher = watch(await Array.fromAsync(glob('**/*.js')));
|
||||
|
||||
// unwatching
|
||||
// v3
|
||||
chok.unwatch('**/*.js');
|
||||
// v4
|
||||
chok.unwatch(await glob('**/*.js'));
|
||||
```
|
||||
|
||||
## Also
|
||||
|
||||
Why was chokidar named this way? What's the meaning behind it?
|
||||
|
||||
>Chowkidar is a transliteration of a Hindi word meaning 'watchman, gatekeeper', चौकीदार. This ultimately comes from Sanskrit _ चतुष्क_ (crossway, quadrangle, consisting-of-four). This word is also used in other languages like Urdu as (چوکیدار) which is widely used in Pakistan and India.
|
||||
|
||||
## License
|
||||
|
||||
MIT (c) Paul Miller (<https://paulmillr.com>), see [LICENSE](LICENSE) file.
|
||||
90
node_modules/sass/node_modules/chokidar/esm/handler.d.ts
generated
vendored
Normal file
90
node_modules/sass/node_modules/chokidar/esm/handler.d.ts
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
import type { WatchEventType, Stats, FSWatcher as NativeFsWatcher } from 'fs';
|
||||
import type { FSWatcher, WatchHelper, Throttler } from './index.js';
|
||||
import type { EntryInfo } from 'readdirp';
|
||||
export type Path = string;
|
||||
export declare const STR_DATA = "data";
|
||||
export declare const STR_END = "end";
|
||||
export declare const STR_CLOSE = "close";
|
||||
export declare const EMPTY_FN: () => void;
|
||||
export declare const IDENTITY_FN: (val: unknown) => unknown;
|
||||
export declare const isWindows: boolean;
|
||||
export declare const isMacos: boolean;
|
||||
export declare const isLinux: boolean;
|
||||
export declare const isFreeBSD: boolean;
|
||||
export declare const isIBMi: boolean;
|
||||
export declare const EVENTS: {
|
||||
readonly ALL: "all";
|
||||
readonly READY: "ready";
|
||||
readonly ADD: "add";
|
||||
readonly CHANGE: "change";
|
||||
readonly ADD_DIR: "addDir";
|
||||
readonly UNLINK: "unlink";
|
||||
readonly UNLINK_DIR: "unlinkDir";
|
||||
readonly RAW: "raw";
|
||||
readonly ERROR: "error";
|
||||
};
|
||||
export type EventName = (typeof EVENTS)[keyof typeof EVENTS];
|
||||
export type FsWatchContainer = {
|
||||
listeners: (path: string) => void | Set<any>;
|
||||
errHandlers: (err: unknown) => void | Set<any>;
|
||||
rawEmitters: (ev: WatchEventType, path: string, opts: unknown) => void | Set<any>;
|
||||
watcher: NativeFsWatcher;
|
||||
watcherUnusable?: boolean;
|
||||
};
|
||||
export interface WatchHandlers {
|
||||
listener: (path: string) => void;
|
||||
errHandler: (err: unknown) => void;
|
||||
rawEmitter: (ev: WatchEventType, path: string, opts: unknown) => void;
|
||||
}
|
||||
/**
|
||||
* @mixin
|
||||
*/
|
||||
export declare class NodeFsHandler {
|
||||
fsw: FSWatcher;
|
||||
_boundHandleError: (error: unknown) => void;
|
||||
constructor(fsW: FSWatcher);
|
||||
/**
|
||||
* Watch file for changes with fs_watchFile or fs_watch.
|
||||
* @param path to file or dir
|
||||
* @param listener on fs change
|
||||
* @returns closer for the watcher instance
|
||||
*/
|
||||
_watchWithNodeFs(path: string, listener: (path: string, newStats?: any) => void | Promise<void>): (() => void) | undefined;
|
||||
/**
|
||||
* Watch a file and emit add event if warranted.
|
||||
* @returns closer for the watcher instance
|
||||
*/
|
||||
_handleFile(file: Path, stats: Stats, initialAdd: boolean): (() => void) | undefined;
|
||||
/**
|
||||
* Handle symlinks encountered while reading a dir.
|
||||
* @param entry returned by readdirp
|
||||
* @param directory path of dir being read
|
||||
* @param path of this item
|
||||
* @param item basename of this item
|
||||
* @returns true if no more processing is needed for this entry.
|
||||
*/
|
||||
_handleSymlink(entry: EntryInfo, directory: string, path: Path, item: string): Promise<boolean | undefined>;
|
||||
_handleRead(directory: string, initialAdd: boolean, wh: WatchHelper, target: Path, dir: Path, depth: number, throttler: Throttler): Promise<unknown> | undefined;
|
||||
/**
|
||||
* Read directory to add / remove files from `@watched` list and re-read it on change.
|
||||
* @param dir fs path
|
||||
* @param stats
|
||||
* @param initialAdd
|
||||
* @param depth relative to user-supplied path
|
||||
* @param target child path targeted for watch
|
||||
* @param wh Common watch helpers for this path
|
||||
* @param realpath
|
||||
* @returns closer for the watcher instance.
|
||||
*/
|
||||
_handleDir(dir: string, stats: Stats, initialAdd: boolean, depth: number, target: string, wh: WatchHelper, realpath: string): Promise<(() => void) | undefined>;
|
||||
/**
|
||||
* Handle added file, directory, or glob pattern.
|
||||
* Delegates call to _handleFile / _handleDir after checks.
|
||||
* @param path to file or ir
|
||||
* @param initialAdd was the file added at watch instantiation?
|
||||
* @param priorWh depth relative to user-supplied path
|
||||
* @param depth Child path actually targeted for watch
|
||||
* @param target Child path actually targeted for watch
|
||||
*/
|
||||
_addToNodeFs(path: string, initialAdd: boolean, priorWh: WatchHelper | undefined, depth: number, target?: string): Promise<string | false | undefined>;
|
||||
}
|
||||
629
node_modules/sass/node_modules/chokidar/esm/handler.js
generated
vendored
Normal file
629
node_modules/sass/node_modules/chokidar/esm/handler.js
generated
vendored
Normal file
@@ -0,0 +1,629 @@
|
||||
import { watchFile, unwatchFile, watch as fs_watch } from 'fs';
|
||||
import { open, stat, lstat, realpath as fsrealpath } from 'fs/promises';
|
||||
import * as sysPath from 'path';
|
||||
import { type as osType } from 'os';
|
||||
export const STR_DATA = 'data';
|
||||
export const STR_END = 'end';
|
||||
export const STR_CLOSE = 'close';
|
||||
export const EMPTY_FN = () => { };
|
||||
export const IDENTITY_FN = (val) => val;
|
||||
const pl = process.platform;
|
||||
export const isWindows = pl === 'win32';
|
||||
export const isMacos = pl === 'darwin';
|
||||
export const isLinux = pl === 'linux';
|
||||
export const isFreeBSD = pl === 'freebsd';
|
||||
export const isIBMi = osType() === 'OS400';
|
||||
export const EVENTS = {
|
||||
ALL: 'all',
|
||||
READY: 'ready',
|
||||
ADD: 'add',
|
||||
CHANGE: 'change',
|
||||
ADD_DIR: 'addDir',
|
||||
UNLINK: 'unlink',
|
||||
UNLINK_DIR: 'unlinkDir',
|
||||
RAW: 'raw',
|
||||
ERROR: 'error',
|
||||
};
|
||||
const EV = EVENTS;
|
||||
const THROTTLE_MODE_WATCH = 'watch';
|
||||
const statMethods = { lstat, stat };
|
||||
const KEY_LISTENERS = 'listeners';
|
||||
const KEY_ERR = 'errHandlers';
|
||||
const KEY_RAW = 'rawEmitters';
|
||||
const HANDLER_KEYS = [KEY_LISTENERS, KEY_ERR, KEY_RAW];
|
||||
// prettier-ignore
|
||||
const binaryExtensions = new Set([
|
||||
'3dm', '3ds', '3g2', '3gp', '7z', 'a', 'aac', 'adp', 'afdesign', 'afphoto', 'afpub', 'ai',
|
||||
'aif', 'aiff', 'alz', 'ape', 'apk', 'appimage', 'ar', 'arj', 'asf', 'au', 'avi',
|
||||
'bak', 'baml', 'bh', 'bin', 'bk', 'bmp', 'btif', 'bz2', 'bzip2',
|
||||
'cab', 'caf', 'cgm', 'class', 'cmx', 'cpio', 'cr2', 'cur', 'dat', 'dcm', 'deb', 'dex', 'djvu',
|
||||
'dll', 'dmg', 'dng', 'doc', 'docm', 'docx', 'dot', 'dotm', 'dra', 'DS_Store', 'dsk', 'dts',
|
||||
'dtshd', 'dvb', 'dwg', 'dxf',
|
||||
'ecelp4800', 'ecelp7470', 'ecelp9600', 'egg', 'eol', 'eot', 'epub', 'exe',
|
||||
'f4v', 'fbs', 'fh', 'fla', 'flac', 'flatpak', 'fli', 'flv', 'fpx', 'fst', 'fvt',
|
||||
'g3', 'gh', 'gif', 'graffle', 'gz', 'gzip',
|
||||
'h261', 'h263', 'h264', 'icns', 'ico', 'ief', 'img', 'ipa', 'iso',
|
||||
'jar', 'jpeg', 'jpg', 'jpgv', 'jpm', 'jxr', 'key', 'ktx',
|
||||
'lha', 'lib', 'lvp', 'lz', 'lzh', 'lzma', 'lzo',
|
||||
'm3u', 'm4a', 'm4v', 'mar', 'mdi', 'mht', 'mid', 'midi', 'mj2', 'mka', 'mkv', 'mmr', 'mng',
|
||||
'mobi', 'mov', 'movie', 'mp3',
|
||||
'mp4', 'mp4a', 'mpeg', 'mpg', 'mpga', 'mxu',
|
||||
'nef', 'npx', 'numbers', 'nupkg',
|
||||
'o', 'odp', 'ods', 'odt', 'oga', 'ogg', 'ogv', 'otf', 'ott',
|
||||
'pages', 'pbm', 'pcx', 'pdb', 'pdf', 'pea', 'pgm', 'pic', 'png', 'pnm', 'pot', 'potm',
|
||||
'potx', 'ppa', 'ppam',
|
||||
'ppm', 'pps', 'ppsm', 'ppsx', 'ppt', 'pptm', 'pptx', 'psd', 'pya', 'pyc', 'pyo', 'pyv',
|
||||
'qt',
|
||||
'rar', 'ras', 'raw', 'resources', 'rgb', 'rip', 'rlc', 'rmf', 'rmvb', 'rpm', 'rtf', 'rz',
|
||||
's3m', 's7z', 'scpt', 'sgi', 'shar', 'snap', 'sil', 'sketch', 'slk', 'smv', 'snk', 'so',
|
||||
'stl', 'suo', 'sub', 'swf',
|
||||
'tar', 'tbz', 'tbz2', 'tga', 'tgz', 'thmx', 'tif', 'tiff', 'tlz', 'ttc', 'ttf', 'txz',
|
||||
'udf', 'uvh', 'uvi', 'uvm', 'uvp', 'uvs', 'uvu',
|
||||
'viv', 'vob',
|
||||
'war', 'wav', 'wax', 'wbmp', 'wdp', 'weba', 'webm', 'webp', 'whl', 'wim', 'wm', 'wma',
|
||||
'wmv', 'wmx', 'woff', 'woff2', 'wrm', 'wvx',
|
||||
'xbm', 'xif', 'xla', 'xlam', 'xls', 'xlsb', 'xlsm', 'xlsx', 'xlt', 'xltm', 'xltx', 'xm',
|
||||
'xmind', 'xpi', 'xpm', 'xwd', 'xz',
|
||||
'z', 'zip', 'zipx',
|
||||
]);
|
||||
const isBinaryPath = (filePath) => binaryExtensions.has(sysPath.extname(filePath).slice(1).toLowerCase());
|
||||
// TODO: emit errors properly. Example: EMFILE on Macos.
|
||||
const foreach = (val, fn) => {
|
||||
if (val instanceof Set) {
|
||||
val.forEach(fn);
|
||||
}
|
||||
else {
|
||||
fn(val);
|
||||
}
|
||||
};
|
||||
const addAndConvert = (main, prop, item) => {
|
||||
let container = main[prop];
|
||||
if (!(container instanceof Set)) {
|
||||
main[prop] = container = new Set([container]);
|
||||
}
|
||||
container.add(item);
|
||||
};
|
||||
const clearItem = (cont) => (key) => {
|
||||
const set = cont[key];
|
||||
if (set instanceof Set) {
|
||||
set.clear();
|
||||
}
|
||||
else {
|
||||
delete cont[key];
|
||||
}
|
||||
};
|
||||
const delFromSet = (main, prop, item) => {
|
||||
const container = main[prop];
|
||||
if (container instanceof Set) {
|
||||
container.delete(item);
|
||||
}
|
||||
else if (container === item) {
|
||||
delete main[prop];
|
||||
}
|
||||
};
|
||||
const isEmptySet = (val) => (val instanceof Set ? val.size === 0 : !val);
|
||||
const FsWatchInstances = new Map();
|
||||
/**
|
||||
* Instantiates the fs_watch interface
|
||||
* @param path to be watched
|
||||
* @param options to be passed to fs_watch
|
||||
* @param listener main event handler
|
||||
* @param errHandler emits info about errors
|
||||
* @param emitRaw emits raw event data
|
||||
* @returns {NativeFsWatcher}
|
||||
*/
|
||||
function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
|
||||
const handleEvent = (rawEvent, evPath) => {
|
||||
listener(path);
|
||||
emitRaw(rawEvent, evPath, { watchedPath: path });
|
||||
// emit based on events occurring for files from a directory's watcher in
|
||||
// case the file's watcher misses it (and rely on throttling to de-dupe)
|
||||
if (evPath && path !== evPath) {
|
||||
fsWatchBroadcast(sysPath.resolve(path, evPath), KEY_LISTENERS, sysPath.join(path, evPath));
|
||||
}
|
||||
};
|
||||
try {
|
||||
return fs_watch(path, {
|
||||
persistent: options.persistent,
|
||||
}, handleEvent);
|
||||
}
|
||||
catch (error) {
|
||||
errHandler(error);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Helper for passing fs_watch event data to a collection of listeners
|
||||
* @param fullPath absolute path bound to fs_watch instance
|
||||
*/
|
||||
const fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
||||
const cont = FsWatchInstances.get(fullPath);
|
||||
if (!cont)
|
||||
return;
|
||||
foreach(cont[listenerType], (listener) => {
|
||||
listener(val1, val2, val3);
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Instantiates the fs_watch interface or binds listeners
|
||||
* to an existing one covering the same file system entry
|
||||
* @param path
|
||||
* @param fullPath absolute path
|
||||
* @param options to be passed to fs_watch
|
||||
* @param handlers container for event listener functions
|
||||
*/
|
||||
const setFsWatchListener = (path, fullPath, options, handlers) => {
|
||||
const { listener, errHandler, rawEmitter } = handlers;
|
||||
let cont = FsWatchInstances.get(fullPath);
|
||||
let watcher;
|
||||
if (!options.persistent) {
|
||||
watcher = createFsWatchInstance(path, options, listener, errHandler, rawEmitter);
|
||||
if (!watcher)
|
||||
return;
|
||||
return watcher.close.bind(watcher);
|
||||
}
|
||||
if (cont) {
|
||||
addAndConvert(cont, KEY_LISTENERS, listener);
|
||||
addAndConvert(cont, KEY_ERR, errHandler);
|
||||
addAndConvert(cont, KEY_RAW, rawEmitter);
|
||||
}
|
||||
else {
|
||||
watcher = createFsWatchInstance(path, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, // no need to use broadcast here
|
||||
fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
|
||||
if (!watcher)
|
||||
return;
|
||||
watcher.on(EV.ERROR, async (error) => {
|
||||
const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR);
|
||||
if (cont)
|
||||
cont.watcherUnusable = true; // documented since Node 10.4.1
|
||||
// Workaround for https://github.com/joyent/node/issues/4337
|
||||
if (isWindows && error.code === 'EPERM') {
|
||||
try {
|
||||
const fd = await open(path, 'r');
|
||||
await fd.close();
|
||||
broadcastErr(error);
|
||||
}
|
||||
catch (err) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
else {
|
||||
broadcastErr(error);
|
||||
}
|
||||
});
|
||||
cont = {
|
||||
listeners: listener,
|
||||
errHandlers: errHandler,
|
||||
rawEmitters: rawEmitter,
|
||||
watcher,
|
||||
};
|
||||
FsWatchInstances.set(fullPath, cont);
|
||||
}
|
||||
// const index = cont.listeners.indexOf(listener);
|
||||
// removes this instance's listeners and closes the underlying fs_watch
|
||||
// instance if there are no more listeners left
|
||||
return () => {
|
||||
delFromSet(cont, KEY_LISTENERS, listener);
|
||||
delFromSet(cont, KEY_ERR, errHandler);
|
||||
delFromSet(cont, KEY_RAW, rawEmitter);
|
||||
if (isEmptySet(cont.listeners)) {
|
||||
// Check to protect against issue gh-730.
|
||||
// if (cont.watcherUnusable) {
|
||||
cont.watcher.close();
|
||||
// }
|
||||
FsWatchInstances.delete(fullPath);
|
||||
HANDLER_KEYS.forEach(clearItem(cont));
|
||||
// @ts-ignore
|
||||
cont.watcher = undefined;
|
||||
Object.freeze(cont);
|
||||
}
|
||||
};
|
||||
};
|
||||
// fs_watchFile helpers
|
||||
// object to hold per-process fs_watchFile instances
|
||||
// (may be shared across chokidar FSWatcher instances)
|
||||
const FsWatchFileInstances = new Map();
|
||||
/**
|
||||
* Instantiates the fs_watchFile interface or binds listeners
|
||||
* to an existing one covering the same file system entry
|
||||
* @param path to be watched
|
||||
* @param fullPath absolute path
|
||||
* @param options options to be passed to fs_watchFile
|
||||
* @param handlers container for event listener functions
|
||||
* @returns closer
|
||||
*/
|
||||
const setFsWatchFileListener = (path, fullPath, options, handlers) => {
|
||||
const { listener, rawEmitter } = handlers;
|
||||
let cont = FsWatchFileInstances.get(fullPath);
|
||||
// let listeners = new Set();
|
||||
// let rawEmitters = new Set();
|
||||
const copts = cont && cont.options;
|
||||
if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
|
||||
// "Upgrade" the watcher to persistence or a quicker interval.
|
||||
// This creates some unlikely edge case issues if the user mixes
|
||||
// settings in a very weird way, but solving for those cases
|
||||
// doesn't seem worthwhile for the added complexity.
|
||||
// listeners = cont.listeners;
|
||||
// rawEmitters = cont.rawEmitters;
|
||||
unwatchFile(fullPath);
|
||||
cont = undefined;
|
||||
}
|
||||
if (cont) {
|
||||
addAndConvert(cont, KEY_LISTENERS, listener);
|
||||
addAndConvert(cont, KEY_RAW, rawEmitter);
|
||||
}
|
||||
else {
|
||||
// TODO
|
||||
// listeners.add(listener);
|
||||
// rawEmitters.add(rawEmitter);
|
||||
cont = {
|
||||
listeners: listener,
|
||||
rawEmitters: rawEmitter,
|
||||
options,
|
||||
watcher: watchFile(fullPath, options, (curr, prev) => {
|
||||
foreach(cont.rawEmitters, (rawEmitter) => {
|
||||
rawEmitter(EV.CHANGE, fullPath, { curr, prev });
|
||||
});
|
||||
const currmtime = curr.mtimeMs;
|
||||
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
||||
foreach(cont.listeners, (listener) => listener(path, curr));
|
||||
}
|
||||
}),
|
||||
};
|
||||
FsWatchFileInstances.set(fullPath, cont);
|
||||
}
|
||||
// const index = cont.listeners.indexOf(listener);
|
||||
// Removes this instance's listeners and closes the underlying fs_watchFile
|
||||
// instance if there are no more listeners left.
|
||||
return () => {
|
||||
delFromSet(cont, KEY_LISTENERS, listener);
|
||||
delFromSet(cont, KEY_RAW, rawEmitter);
|
||||
if (isEmptySet(cont.listeners)) {
|
||||
FsWatchFileInstances.delete(fullPath);
|
||||
unwatchFile(fullPath);
|
||||
cont.options = cont.watcher = undefined;
|
||||
Object.freeze(cont);
|
||||
}
|
||||
};
|
||||
};
|
||||
/**
|
||||
* @mixin
|
||||
*/
|
||||
export class NodeFsHandler {
|
||||
constructor(fsW) {
|
||||
this.fsw = fsW;
|
||||
this._boundHandleError = (error) => fsW._handleError(error);
|
||||
}
|
||||
/**
|
||||
* Watch file for changes with fs_watchFile or fs_watch.
|
||||
* @param path to file or dir
|
||||
* @param listener on fs change
|
||||
* @returns closer for the watcher instance
|
||||
*/
|
||||
_watchWithNodeFs(path, listener) {
|
||||
const opts = this.fsw.options;
|
||||
const directory = sysPath.dirname(path);
|
||||
const basename = sysPath.basename(path);
|
||||
const parent = this.fsw._getWatchedDir(directory);
|
||||
parent.add(basename);
|
||||
const absolutePath = sysPath.resolve(path);
|
||||
const options = {
|
||||
persistent: opts.persistent,
|
||||
};
|
||||
if (!listener)
|
||||
listener = EMPTY_FN;
|
||||
let closer;
|
||||
if (opts.usePolling) {
|
||||
const enableBin = opts.interval !== opts.binaryInterval;
|
||||
options.interval = enableBin && isBinaryPath(basename) ? opts.binaryInterval : opts.interval;
|
||||
closer = setFsWatchFileListener(path, absolutePath, options, {
|
||||
listener,
|
||||
rawEmitter: this.fsw._emitRaw,
|
||||
});
|
||||
}
|
||||
else {
|
||||
closer = setFsWatchListener(path, absolutePath, options, {
|
||||
listener,
|
||||
errHandler: this._boundHandleError,
|
||||
rawEmitter: this.fsw._emitRaw,
|
||||
});
|
||||
}
|
||||
return closer;
|
||||
}
|
||||
/**
|
||||
* Watch a file and emit add event if warranted.
|
||||
* @returns closer for the watcher instance
|
||||
*/
|
||||
_handleFile(file, stats, initialAdd) {
|
||||
if (this.fsw.closed) {
|
||||
return;
|
||||
}
|
||||
const dirname = sysPath.dirname(file);
|
||||
const basename = sysPath.basename(file);
|
||||
const parent = this.fsw._getWatchedDir(dirname);
|
||||
// stats is always present
|
||||
let prevStats = stats;
|
||||
// if the file is already being watched, do nothing
|
||||
if (parent.has(basename))
|
||||
return;
|
||||
const listener = async (path, newStats) => {
|
||||
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
|
||||
return;
|
||||
if (!newStats || newStats.mtimeMs === 0) {
|
||||
try {
|
||||
const newStats = await stat(file);
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
// Check that change event was not fired because of changed only accessTime.
|
||||
const at = newStats.atimeMs;
|
||||
const mt = newStats.mtimeMs;
|
||||
if (!at || at <= mt || mt !== prevStats.mtimeMs) {
|
||||
this.fsw._emit(EV.CHANGE, file, newStats);
|
||||
}
|
||||
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats.ino) {
|
||||
this.fsw._closeFile(path);
|
||||
prevStats = newStats;
|
||||
const closer = this._watchWithNodeFs(file, listener);
|
||||
if (closer)
|
||||
this.fsw._addPathCloser(path, closer);
|
||||
}
|
||||
else {
|
||||
prevStats = newStats;
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
// Fix issues where mtime is null but file is still present
|
||||
this.fsw._remove(dirname, basename);
|
||||
}
|
||||
// add is about to be emitted if file not already tracked in parent
|
||||
}
|
||||
else if (parent.has(basename)) {
|
||||
// Check that change event was not fired because of changed only accessTime.
|
||||
const at = newStats.atimeMs;
|
||||
const mt = newStats.mtimeMs;
|
||||
if (!at || at <= mt || mt !== prevStats.mtimeMs) {
|
||||
this.fsw._emit(EV.CHANGE, file, newStats);
|
||||
}
|
||||
prevStats = newStats;
|
||||
}
|
||||
};
|
||||
// kick off the watcher
|
||||
const closer = this._watchWithNodeFs(file, listener);
|
||||
// emit an add event if we're supposed to
|
||||
if (!(initialAdd && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(file)) {
|
||||
if (!this.fsw._throttle(EV.ADD, file, 0))
|
||||
return;
|
||||
this.fsw._emit(EV.ADD, file, stats);
|
||||
}
|
||||
return closer;
|
||||
}
|
||||
/**
|
||||
* Handle symlinks encountered while reading a dir.
|
||||
* @param entry returned by readdirp
|
||||
* @param directory path of dir being read
|
||||
* @param path of this item
|
||||
* @param item basename of this item
|
||||
* @returns true if no more processing is needed for this entry.
|
||||
*/
|
||||
async _handleSymlink(entry, directory, path, item) {
|
||||
if (this.fsw.closed) {
|
||||
return;
|
||||
}
|
||||
const full = entry.fullPath;
|
||||
const dir = this.fsw._getWatchedDir(directory);
|
||||
if (!this.fsw.options.followSymlinks) {
|
||||
// watch symlink directly (don't follow) and detect changes
|
||||
this.fsw._incrReadyCount();
|
||||
let linkPath;
|
||||
try {
|
||||
linkPath = await fsrealpath(path);
|
||||
}
|
||||
catch (e) {
|
||||
this.fsw._emitReady();
|
||||
return true;
|
||||
}
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
if (dir.has(item)) {
|
||||
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
||||
this.fsw._symlinkPaths.set(full, linkPath);
|
||||
this.fsw._emit(EV.CHANGE, path, entry.stats);
|
||||
}
|
||||
}
|
||||
else {
|
||||
dir.add(item);
|
||||
this.fsw._symlinkPaths.set(full, linkPath);
|
||||
this.fsw._emit(EV.ADD, path, entry.stats);
|
||||
}
|
||||
this.fsw._emitReady();
|
||||
return true;
|
||||
}
|
||||
// don't follow the same symlink more than once
|
||||
if (this.fsw._symlinkPaths.has(full)) {
|
||||
return true;
|
||||
}
|
||||
this.fsw._symlinkPaths.set(full, true);
|
||||
}
|
||||
_handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
|
||||
// Normalize the directory name on Windows
|
||||
directory = sysPath.join(directory, '');
|
||||
throttler = this.fsw._throttle('readdir', directory, 1000);
|
||||
if (!throttler)
|
||||
return;
|
||||
const previous = this.fsw._getWatchedDir(wh.path);
|
||||
const current = new Set();
|
||||
let stream = this.fsw._readdirp(directory, {
|
||||
fileFilter: (entry) => wh.filterPath(entry),
|
||||
directoryFilter: (entry) => wh.filterDir(entry),
|
||||
});
|
||||
if (!stream)
|
||||
return;
|
||||
stream
|
||||
.on(STR_DATA, async (entry) => {
|
||||
if (this.fsw.closed) {
|
||||
stream = undefined;
|
||||
return;
|
||||
}
|
||||
const item = entry.path;
|
||||
let path = sysPath.join(directory, item);
|
||||
current.add(item);
|
||||
if (entry.stats.isSymbolicLink() &&
|
||||
(await this._handleSymlink(entry, directory, path, item))) {
|
||||
return;
|
||||
}
|
||||
if (this.fsw.closed) {
|
||||
stream = undefined;
|
||||
return;
|
||||
}
|
||||
// Files that present in current directory snapshot
|
||||
// but absent in previous are added to watch list and
|
||||
// emit `add` event.
|
||||
if (item === target || (!target && !previous.has(item))) {
|
||||
this.fsw._incrReadyCount();
|
||||
// ensure relativeness of path is preserved in case of watcher reuse
|
||||
path = sysPath.join(dir, sysPath.relative(dir, path));
|
||||
this._addToNodeFs(path, initialAdd, wh, depth + 1);
|
||||
}
|
||||
})
|
||||
.on(EV.ERROR, this._boundHandleError);
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!stream)
|
||||
return reject();
|
||||
stream.once(STR_END, () => {
|
||||
if (this.fsw.closed) {
|
||||
stream = undefined;
|
||||
return;
|
||||
}
|
||||
const wasThrottled = throttler ? throttler.clear() : false;
|
||||
resolve(undefined);
|
||||
// Files that absent in current directory snapshot
|
||||
// but present in previous emit `remove` event
|
||||
// and are removed from @watched[directory].
|
||||
previous
|
||||
.getChildren()
|
||||
.filter((item) => {
|
||||
return item !== directory && !current.has(item);
|
||||
})
|
||||
.forEach((item) => {
|
||||
this.fsw._remove(directory, item);
|
||||
});
|
||||
stream = undefined;
|
||||
// one more time for any missed in case changes came in extremely quickly
|
||||
if (wasThrottled)
|
||||
this._handleRead(directory, false, wh, target, dir, depth, throttler);
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Read directory to add / remove files from `@watched` list and re-read it on change.
|
||||
* @param dir fs path
|
||||
* @param stats
|
||||
* @param initialAdd
|
||||
* @param depth relative to user-supplied path
|
||||
* @param target child path targeted for watch
|
||||
* @param wh Common watch helpers for this path
|
||||
* @param realpath
|
||||
* @returns closer for the watcher instance.
|
||||
*/
|
||||
async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath) {
|
||||
const parentDir = this.fsw._getWatchedDir(sysPath.dirname(dir));
|
||||
const tracked = parentDir.has(sysPath.basename(dir));
|
||||
if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
|
||||
this.fsw._emit(EV.ADD_DIR, dir, stats);
|
||||
}
|
||||
// ensure dir is tracked (harmless if redundant)
|
||||
parentDir.add(sysPath.basename(dir));
|
||||
this.fsw._getWatchedDir(dir);
|
||||
let throttler;
|
||||
let closer;
|
||||
const oDepth = this.fsw.options.depth;
|
||||
if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath)) {
|
||||
if (!target) {
|
||||
await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler);
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
}
|
||||
closer = this._watchWithNodeFs(dir, (dirPath, stats) => {
|
||||
// if current directory is removed, do nothing
|
||||
if (stats && stats.mtimeMs === 0)
|
||||
return;
|
||||
this._handleRead(dirPath, false, wh, target, dir, depth, throttler);
|
||||
});
|
||||
}
|
||||
return closer;
|
||||
}
|
||||
/**
|
||||
* Handle added file, directory, or glob pattern.
|
||||
* Delegates call to _handleFile / _handleDir after checks.
|
||||
* @param path to file or ir
|
||||
* @param initialAdd was the file added at watch instantiation?
|
||||
* @param priorWh depth relative to user-supplied path
|
||||
* @param depth Child path actually targeted for watch
|
||||
* @param target Child path actually targeted for watch
|
||||
*/
|
||||
async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
|
||||
const ready = this.fsw._emitReady;
|
||||
if (this.fsw._isIgnored(path) || this.fsw.closed) {
|
||||
ready();
|
||||
return false;
|
||||
}
|
||||
const wh = this.fsw._getWatchHelpers(path);
|
||||
if (priorWh) {
|
||||
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
||||
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
||||
}
|
||||
// evaluate what is at the path we're being asked to watch
|
||||
try {
|
||||
const stats = await statMethods[wh.statMethod](wh.watchPath);
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
if (this.fsw._isIgnored(wh.watchPath, stats)) {
|
||||
ready();
|
||||
return false;
|
||||
}
|
||||
const follow = this.fsw.options.followSymlinks;
|
||||
let closer;
|
||||
if (stats.isDirectory()) {
|
||||
const absPath = sysPath.resolve(path);
|
||||
const targetPath = follow ? await fsrealpath(path) : path;
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
// preserve this symlink's target path
|
||||
if (absPath !== targetPath && targetPath !== undefined) {
|
||||
this.fsw._symlinkPaths.set(absPath, targetPath);
|
||||
}
|
||||
}
|
||||
else if (stats.isSymbolicLink()) {
|
||||
const targetPath = follow ? await fsrealpath(path) : path;
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
const parent = sysPath.dirname(wh.watchPath);
|
||||
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
||||
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
||||
closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
// preserve this symlink's target path
|
||||
if (targetPath !== undefined) {
|
||||
this.fsw._symlinkPaths.set(sysPath.resolve(path), targetPath);
|
||||
}
|
||||
}
|
||||
else {
|
||||
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
||||
}
|
||||
ready();
|
||||
if (closer)
|
||||
this.fsw._addPathCloser(path, closer);
|
||||
return false;
|
||||
}
|
||||
catch (error) {
|
||||
if (this.fsw._handleError(error)) {
|
||||
ready();
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
215
node_modules/sass/node_modules/chokidar/esm/index.d.ts
generated
vendored
Normal file
215
node_modules/sass/node_modules/chokidar/esm/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,215 @@
|
||||
/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
|
||||
import { Stats } from 'fs';
|
||||
import { EventEmitter } from 'events';
|
||||
import { ReaddirpStream, ReaddirpOptions, EntryInfo } from 'readdirp';
|
||||
import { NodeFsHandler, EventName, Path, EVENTS as EV, WatchHandlers } from './handler.js';
|
||||
type AWF = {
|
||||
stabilityThreshold: number;
|
||||
pollInterval: number;
|
||||
};
|
||||
type BasicOpts = {
|
||||
persistent: boolean;
|
||||
ignoreInitial: boolean;
|
||||
followSymlinks: boolean;
|
||||
cwd?: string;
|
||||
usePolling: boolean;
|
||||
interval: number;
|
||||
binaryInterval: number;
|
||||
alwaysStat?: boolean;
|
||||
depth?: number;
|
||||
ignorePermissionErrors: boolean;
|
||||
atomic: boolean | number;
|
||||
};
|
||||
export type Throttler = {
|
||||
timeoutObject: NodeJS.Timeout;
|
||||
clear: () => void;
|
||||
count: number;
|
||||
};
|
||||
export type ChokidarOptions = Partial<BasicOpts & {
|
||||
ignored: Matcher | Matcher[];
|
||||
awaitWriteFinish: boolean | Partial<AWF>;
|
||||
}>;
|
||||
export type FSWInstanceOptions = BasicOpts & {
|
||||
ignored: Matcher[];
|
||||
awaitWriteFinish: false | AWF;
|
||||
};
|
||||
export type ThrottleType = 'readdir' | 'watch' | 'add' | 'remove' | 'change';
|
||||
export type EmitArgs = [path: Path, stats?: Stats];
|
||||
export type EmitErrorArgs = [error: Error, stats?: Stats];
|
||||
export type EmitArgsWithName = [event: EventName, ...EmitArgs];
|
||||
export type MatchFunction = (val: string, stats?: Stats) => boolean;
|
||||
export interface MatcherObject {
|
||||
path: string;
|
||||
recursive?: boolean;
|
||||
}
|
||||
export type Matcher = string | RegExp | MatchFunction | MatcherObject;
|
||||
/**
|
||||
* Directory entry.
|
||||
*/
|
||||
declare class DirEntry {
|
||||
path: Path;
|
||||
_removeWatcher: (dir: string, base: string) => void;
|
||||
items: Set<Path>;
|
||||
constructor(dir: Path, removeWatcher: (dir: string, base: string) => void);
|
||||
add(item: string): void;
|
||||
remove(item: string): Promise<void>;
|
||||
has(item: string): boolean | undefined;
|
||||
getChildren(): string[];
|
||||
dispose(): void;
|
||||
}
|
||||
export declare class WatchHelper {
|
||||
fsw: FSWatcher;
|
||||
path: string;
|
||||
watchPath: string;
|
||||
fullWatchPath: string;
|
||||
dirParts: string[][];
|
||||
followSymlinks: boolean;
|
||||
statMethod: 'stat' | 'lstat';
|
||||
constructor(path: string, follow: boolean, fsw: FSWatcher);
|
||||
entryPath(entry: EntryInfo): Path;
|
||||
filterPath(entry: EntryInfo): boolean;
|
||||
filterDir(entry: EntryInfo): boolean;
|
||||
}
|
||||
export interface FSWatcherKnownEventMap {
|
||||
[EV.READY]: [];
|
||||
[EV.RAW]: Parameters<WatchHandlers['rawEmitter']>;
|
||||
[EV.ERROR]: Parameters<WatchHandlers['errHandler']>;
|
||||
[EV.ALL]: [event: EventName, ...EmitArgs];
|
||||
}
|
||||
export type FSWatcherEventMap = FSWatcherKnownEventMap & {
|
||||
[k in Exclude<EventName, keyof FSWatcherKnownEventMap>]: EmitArgs;
|
||||
};
|
||||
/**
|
||||
* Watches files & directories for changes. Emitted events:
|
||||
* `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error`
|
||||
*
|
||||
* new FSWatcher()
|
||||
* .add(directories)
|
||||
* .on('add', path => log('File', path, 'was added'))
|
||||
*/
|
||||
export declare class FSWatcher extends EventEmitter<FSWatcherEventMap> {
|
||||
closed: boolean;
|
||||
options: FSWInstanceOptions;
|
||||
_closers: Map<string, Array<any>>;
|
||||
_ignoredPaths: Set<Matcher>;
|
||||
_throttled: Map<ThrottleType, Map<any, any>>;
|
||||
_streams: Set<ReaddirpStream>;
|
||||
_symlinkPaths: Map<Path, string | boolean>;
|
||||
_watched: Map<string, DirEntry>;
|
||||
_pendingWrites: Map<string, any>;
|
||||
_pendingUnlinks: Map<string, EmitArgsWithName>;
|
||||
_readyCount: number;
|
||||
_emitReady: () => void;
|
||||
_closePromise?: Promise<void>;
|
||||
_userIgnored?: MatchFunction;
|
||||
_readyEmitted: boolean;
|
||||
_emitRaw: WatchHandlers['rawEmitter'];
|
||||
_boundRemove: (dir: string, item: string) => void;
|
||||
_nodeFsHandler: NodeFsHandler;
|
||||
constructor(_opts?: ChokidarOptions);
|
||||
_addIgnoredPath(matcher: Matcher): void;
|
||||
_removeIgnoredPath(matcher: Matcher): void;
|
||||
/**
|
||||
* Adds paths to be watched on an existing FSWatcher instance.
|
||||
* @param paths_ file or file list. Other arguments are unused
|
||||
*/
|
||||
add(paths_: Path | Path[], _origAdd?: string, _internal?: boolean): FSWatcher;
|
||||
/**
|
||||
* Close watchers or start ignoring events from specified paths.
|
||||
*/
|
||||
unwatch(paths_: Path | Path[]): FSWatcher;
|
||||
/**
|
||||
* Close watchers and remove all listeners from watched paths.
|
||||
*/
|
||||
close(): Promise<void>;
|
||||
/**
|
||||
* Expose list of watched paths
|
||||
* @returns for chaining
|
||||
*/
|
||||
getWatched(): Record<string, string[]>;
|
||||
emitWithAll(event: EventName, args: EmitArgs): void;
|
||||
/**
|
||||
* Normalize and emit events.
|
||||
* Calling _emit DOES NOT MEAN emit() would be called!
|
||||
* @param event Type of event
|
||||
* @param path File or directory path
|
||||
* @param stats arguments to be passed with event
|
||||
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
||||
*/
|
||||
_emit(event: EventName, path: Path, stats?: Stats): Promise<this | undefined>;
|
||||
/**
|
||||
* Common handler for errors
|
||||
* @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
||||
*/
|
||||
_handleError(error: Error): Error | boolean;
|
||||
/**
|
||||
* Helper utility for throttling
|
||||
* @param actionType type being throttled
|
||||
* @param path being acted upon
|
||||
* @param timeout duration of time to suppress duplicate actions
|
||||
* @returns tracking object or false if action should be suppressed
|
||||
*/
|
||||
_throttle(actionType: ThrottleType, path: Path, timeout: number): Throttler | false;
|
||||
_incrReadyCount(): number;
|
||||
/**
|
||||
* Awaits write operation to finish.
|
||||
* Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.
|
||||
* @param path being acted upon
|
||||
* @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished
|
||||
* @param event
|
||||
* @param awfEmit Callback to be called when ready for event to be emitted.
|
||||
*/
|
||||
_awaitWriteFinish(path: Path, threshold: number, event: EventName, awfEmit: (err?: Error, stat?: Stats) => void): void;
|
||||
/**
|
||||
* Determines whether user has asked to ignore this path.
|
||||
*/
|
||||
_isIgnored(path: Path, stats?: Stats): boolean;
|
||||
_isntIgnored(path: Path, stat?: Stats): boolean;
|
||||
/**
|
||||
* Provides a set of common helpers and properties relating to symlink handling.
|
||||
* @param path file or directory pattern being watched
|
||||
*/
|
||||
_getWatchHelpers(path: Path): WatchHelper;
|
||||
/**
|
||||
* Provides directory tracking objects
|
||||
* @param directory path of the directory
|
||||
*/
|
||||
_getWatchedDir(directory: string): DirEntry;
|
||||
/**
|
||||
* Check for read permissions: https://stackoverflow.com/a/11781404/1358405
|
||||
*/
|
||||
_hasReadPermissions(stats: Stats): boolean;
|
||||
/**
|
||||
* Handles emitting unlink events for
|
||||
* files and directories, and via recursion, for
|
||||
* files and directories within directories that are unlinked
|
||||
* @param directory within which the following item is located
|
||||
* @param item base path of item/directory
|
||||
*/
|
||||
_remove(directory: string, item: string, isDirectory?: boolean): void;
|
||||
/**
|
||||
* Closes all watchers for a path
|
||||
*/
|
||||
_closePath(path: Path): void;
|
||||
/**
|
||||
* Closes only file-specific watchers
|
||||
*/
|
||||
_closeFile(path: Path): void;
|
||||
_addPathCloser(path: Path, closer: () => void): void;
|
||||
_readdirp(root: Path, opts?: Partial<ReaddirpOptions>): ReaddirpStream | undefined;
|
||||
}
|
||||
/**
|
||||
* Instantiates watcher with paths to be tracked.
|
||||
* @param paths file / directory paths
|
||||
* @param options opts, such as `atomic`, `awaitWriteFinish`, `ignored`, and others
|
||||
* @returns an instance of FSWatcher for chaining.
|
||||
* @example
|
||||
* const watcher = watch('.').on('all', (event, path) => { console.log(event, path); });
|
||||
* watch('.', { atomic: true, awaitWriteFinish: true, ignored: (f, stats) => stats?.isFile() && !f.endsWith('.js') })
|
||||
*/
|
||||
export declare function watch(paths: string | string[], options?: ChokidarOptions): FSWatcher;
|
||||
declare const _default: {
|
||||
watch: typeof watch;
|
||||
FSWatcher: typeof FSWatcher;
|
||||
};
|
||||
export default _default;
|
||||
798
node_modules/sass/node_modules/chokidar/esm/index.js
generated
vendored
Normal file
798
node_modules/sass/node_modules/chokidar/esm/index.js
generated
vendored
Normal file
@@ -0,0 +1,798 @@
|
||||
/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
|
||||
import { stat as statcb } from 'fs';
|
||||
import { stat, readdir } from 'fs/promises';
|
||||
import { EventEmitter } from 'events';
|
||||
import * as sysPath from 'path';
|
||||
import { readdirp } from 'readdirp';
|
||||
import { NodeFsHandler, EVENTS as EV, isWindows, isIBMi, EMPTY_FN, STR_CLOSE, STR_END, } from './handler.js';
|
||||
const SLASH = '/';
|
||||
const SLASH_SLASH = '//';
|
||||
const ONE_DOT = '.';
|
||||
const TWO_DOTS = '..';
|
||||
const STRING_TYPE = 'string';
|
||||
const BACK_SLASH_RE = /\\/g;
|
||||
const DOUBLE_SLASH_RE = /\/\//;
|
||||
const DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
|
||||
const REPLACER_RE = /^\.[/\\]/;
|
||||
function arrify(item) {
|
||||
return Array.isArray(item) ? item : [item];
|
||||
}
|
||||
const isMatcherObject = (matcher) => typeof matcher === 'object' && matcher !== null && !(matcher instanceof RegExp);
|
||||
function createPattern(matcher) {
|
||||
if (typeof matcher === 'function')
|
||||
return matcher;
|
||||
if (typeof matcher === 'string')
|
||||
return (string) => matcher === string;
|
||||
if (matcher instanceof RegExp)
|
||||
return (string) => matcher.test(string);
|
||||
if (typeof matcher === 'object' && matcher !== null) {
|
||||
return (string) => {
|
||||
if (matcher.path === string)
|
||||
return true;
|
||||
if (matcher.recursive) {
|
||||
const relative = sysPath.relative(matcher.path, string);
|
||||
if (!relative) {
|
||||
return false;
|
||||
}
|
||||
return !relative.startsWith('..') && !sysPath.isAbsolute(relative);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
return () => false;
|
||||
}
|
||||
function normalizePath(path) {
|
||||
if (typeof path !== 'string')
|
||||
throw new Error('string expected');
|
||||
path = sysPath.normalize(path);
|
||||
path = path.replace(/\\/g, '/');
|
||||
let prepend = false;
|
||||
if (path.startsWith('//'))
|
||||
prepend = true;
|
||||
const DOUBLE_SLASH_RE = /\/\//;
|
||||
while (path.match(DOUBLE_SLASH_RE))
|
||||
path = path.replace(DOUBLE_SLASH_RE, '/');
|
||||
if (prepend)
|
||||
path = '/' + path;
|
||||
return path;
|
||||
}
|
||||
function matchPatterns(patterns, testString, stats) {
|
||||
const path = normalizePath(testString);
|
||||
for (let index = 0; index < patterns.length; index++) {
|
||||
const pattern = patterns[index];
|
||||
if (pattern(path, stats)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function anymatch(matchers, testString) {
|
||||
if (matchers == null) {
|
||||
throw new TypeError('anymatch: specify first argument');
|
||||
}
|
||||
// Early cache for matchers.
|
||||
const matchersArray = arrify(matchers);
|
||||
const patterns = matchersArray.map((matcher) => createPattern(matcher));
|
||||
if (testString == null) {
|
||||
return (testString, stats) => {
|
||||
return matchPatterns(patterns, testString, stats);
|
||||
};
|
||||
}
|
||||
return matchPatterns(patterns, testString);
|
||||
}
|
||||
const unifyPaths = (paths_) => {
|
||||
const paths = arrify(paths_).flat();
|
||||
if (!paths.every((p) => typeof p === STRING_TYPE)) {
|
||||
throw new TypeError(`Non-string provided as watch path: ${paths}`);
|
||||
}
|
||||
return paths.map(normalizePathToUnix);
|
||||
};
|
||||
// If SLASH_SLASH occurs at the beginning of path, it is not replaced
|
||||
// because "//StoragePC/DrivePool/Movies" is a valid network path
|
||||
const toUnix = (string) => {
|
||||
let str = string.replace(BACK_SLASH_RE, SLASH);
|
||||
let prepend = false;
|
||||
if (str.startsWith(SLASH_SLASH)) {
|
||||
prepend = true;
|
||||
}
|
||||
while (str.match(DOUBLE_SLASH_RE)) {
|
||||
str = str.replace(DOUBLE_SLASH_RE, SLASH);
|
||||
}
|
||||
if (prepend) {
|
||||
str = SLASH + str;
|
||||
}
|
||||
return str;
|
||||
};
|
||||
// Our version of upath.normalize
|
||||
// TODO: this is not equal to path-normalize module - investigate why
|
||||
const normalizePathToUnix = (path) => toUnix(sysPath.normalize(toUnix(path)));
|
||||
// TODO: refactor
|
||||
const normalizeIgnored = (cwd = '') => (path) => {
|
||||
if (typeof path === 'string') {
|
||||
return normalizePathToUnix(sysPath.isAbsolute(path) ? path : sysPath.join(cwd, path));
|
||||
}
|
||||
else {
|
||||
return path;
|
||||
}
|
||||
};
|
||||
const getAbsolutePath = (path, cwd) => {
|
||||
if (sysPath.isAbsolute(path)) {
|
||||
return path;
|
||||
}
|
||||
return sysPath.join(cwd, path);
|
||||
};
|
||||
const EMPTY_SET = Object.freeze(new Set());
|
||||
/**
|
||||
* Directory entry.
|
||||
*/
|
||||
class DirEntry {
|
||||
constructor(dir, removeWatcher) {
|
||||
this.path = dir;
|
||||
this._removeWatcher = removeWatcher;
|
||||
this.items = new Set();
|
||||
}
|
||||
add(item) {
|
||||
const { items } = this;
|
||||
if (!items)
|
||||
return;
|
||||
if (item !== ONE_DOT && item !== TWO_DOTS)
|
||||
items.add(item);
|
||||
}
|
||||
async remove(item) {
|
||||
const { items } = this;
|
||||
if (!items)
|
||||
return;
|
||||
items.delete(item);
|
||||
if (items.size > 0)
|
||||
return;
|
||||
const dir = this.path;
|
||||
try {
|
||||
await readdir(dir);
|
||||
}
|
||||
catch (err) {
|
||||
if (this._removeWatcher) {
|
||||
this._removeWatcher(sysPath.dirname(dir), sysPath.basename(dir));
|
||||
}
|
||||
}
|
||||
}
|
||||
has(item) {
|
||||
const { items } = this;
|
||||
if (!items)
|
||||
return;
|
||||
return items.has(item);
|
||||
}
|
||||
getChildren() {
|
||||
const { items } = this;
|
||||
if (!items)
|
||||
return [];
|
||||
return [...items.values()];
|
||||
}
|
||||
dispose() {
|
||||
this.items.clear();
|
||||
this.path = '';
|
||||
this._removeWatcher = EMPTY_FN;
|
||||
this.items = EMPTY_SET;
|
||||
Object.freeze(this);
|
||||
}
|
||||
}
|
||||
const STAT_METHOD_F = 'stat';
|
||||
const STAT_METHOD_L = 'lstat';
|
||||
export class WatchHelper {
|
||||
constructor(path, follow, fsw) {
|
||||
this.fsw = fsw;
|
||||
const watchPath = path;
|
||||
this.path = path = path.replace(REPLACER_RE, '');
|
||||
this.watchPath = watchPath;
|
||||
this.fullWatchPath = sysPath.resolve(watchPath);
|
||||
this.dirParts = [];
|
||||
this.dirParts.forEach((parts) => {
|
||||
if (parts.length > 1)
|
||||
parts.pop();
|
||||
});
|
||||
this.followSymlinks = follow;
|
||||
this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
|
||||
}
|
||||
entryPath(entry) {
|
||||
return sysPath.join(this.watchPath, sysPath.relative(this.watchPath, entry.fullPath));
|
||||
}
|
||||
filterPath(entry) {
|
||||
const { stats } = entry;
|
||||
if (stats && stats.isSymbolicLink())
|
||||
return this.filterDir(entry);
|
||||
const resolvedPath = this.entryPath(entry);
|
||||
// TODO: what if stats is undefined? remove !
|
||||
return this.fsw._isntIgnored(resolvedPath, stats) && this.fsw._hasReadPermissions(stats);
|
||||
}
|
||||
filterDir(entry) {
|
||||
return this.fsw._isntIgnored(this.entryPath(entry), entry.stats);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Watches files & directories for changes. Emitted events:
|
||||
* `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error`
|
||||
*
|
||||
* new FSWatcher()
|
||||
* .add(directories)
|
||||
* .on('add', path => log('File', path, 'was added'))
|
||||
*/
|
||||
export class FSWatcher extends EventEmitter {
|
||||
// Not indenting methods for history sake; for now.
|
||||
constructor(_opts = {}) {
|
||||
super();
|
||||
this.closed = false;
|
||||
this._closers = new Map();
|
||||
this._ignoredPaths = new Set();
|
||||
this._throttled = new Map();
|
||||
this._streams = new Set();
|
||||
this._symlinkPaths = new Map();
|
||||
this._watched = new Map();
|
||||
this._pendingWrites = new Map();
|
||||
this._pendingUnlinks = new Map();
|
||||
this._readyCount = 0;
|
||||
this._readyEmitted = false;
|
||||
const awf = _opts.awaitWriteFinish;
|
||||
const DEF_AWF = { stabilityThreshold: 2000, pollInterval: 100 };
|
||||
const opts = {
|
||||
// Defaults
|
||||
persistent: true,
|
||||
ignoreInitial: false,
|
||||
ignorePermissionErrors: false,
|
||||
interval: 100,
|
||||
binaryInterval: 300,
|
||||
followSymlinks: true,
|
||||
usePolling: false,
|
||||
// useAsync: false,
|
||||
atomic: true, // NOTE: overwritten later (depends on usePolling)
|
||||
..._opts,
|
||||
// Change format
|
||||
ignored: _opts.ignored ? arrify(_opts.ignored) : arrify([]),
|
||||
awaitWriteFinish: awf === true ? DEF_AWF : typeof awf === 'object' ? { ...DEF_AWF, ...awf } : false,
|
||||
};
|
||||
// Always default to polling on IBM i because fs.watch() is not available on IBM i.
|
||||
if (isIBMi)
|
||||
opts.usePolling = true;
|
||||
// Editor atomic write normalization enabled by default with fs.watch
|
||||
if (opts.atomic === undefined)
|
||||
opts.atomic = !opts.usePolling;
|
||||
// opts.atomic = typeof _opts.atomic === 'number' ? _opts.atomic : 100;
|
||||
// Global override. Useful for developers, who need to force polling for all
|
||||
// instances of chokidar, regardless of usage / dependency depth
|
||||
const envPoll = process.env.CHOKIDAR_USEPOLLING;
|
||||
if (envPoll !== undefined) {
|
||||
const envLower = envPoll.toLowerCase();
|
||||
if (envLower === 'false' || envLower === '0')
|
||||
opts.usePolling = false;
|
||||
else if (envLower === 'true' || envLower === '1')
|
||||
opts.usePolling = true;
|
||||
else
|
||||
opts.usePolling = !!envLower;
|
||||
}
|
||||
const envInterval = process.env.CHOKIDAR_INTERVAL;
|
||||
if (envInterval)
|
||||
opts.interval = Number.parseInt(envInterval, 10);
|
||||
// This is done to emit ready only once, but each 'add' will increase that?
|
||||
let readyCalls = 0;
|
||||
this._emitReady = () => {
|
||||
readyCalls++;
|
||||
if (readyCalls >= this._readyCount) {
|
||||
this._emitReady = EMPTY_FN;
|
||||
this._readyEmitted = true;
|
||||
// use process.nextTick to allow time for listener to be bound
|
||||
process.nextTick(() => this.emit(EV.READY));
|
||||
}
|
||||
};
|
||||
this._emitRaw = (...args) => this.emit(EV.RAW, ...args);
|
||||
this._boundRemove = this._remove.bind(this);
|
||||
this.options = opts;
|
||||
this._nodeFsHandler = new NodeFsHandler(this);
|
||||
// You’re frozen when your heart’s not open.
|
||||
Object.freeze(opts);
|
||||
}
|
||||
_addIgnoredPath(matcher) {
|
||||
if (isMatcherObject(matcher)) {
|
||||
// return early if we already have a deeply equal matcher object
|
||||
for (const ignored of this._ignoredPaths) {
|
||||
if (isMatcherObject(ignored) &&
|
||||
ignored.path === matcher.path &&
|
||||
ignored.recursive === matcher.recursive) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._ignoredPaths.add(matcher);
|
||||
}
|
||||
_removeIgnoredPath(matcher) {
|
||||
this._ignoredPaths.delete(matcher);
|
||||
// now find any matcher objects with the matcher as path
|
||||
if (typeof matcher === 'string') {
|
||||
for (const ignored of this._ignoredPaths) {
|
||||
// TODO (43081j): make this more efficient.
|
||||
// probably just make a `this._ignoredDirectories` or some
|
||||
// such thing.
|
||||
if (isMatcherObject(ignored) && ignored.path === matcher) {
|
||||
this._ignoredPaths.delete(ignored);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Public methods
|
||||
/**
|
||||
* Adds paths to be watched on an existing FSWatcher instance.
|
||||
* @param paths_ file or file list. Other arguments are unused
|
||||
*/
|
||||
add(paths_, _origAdd, _internal) {
|
||||
const { cwd } = this.options;
|
||||
this.closed = false;
|
||||
this._closePromise = undefined;
|
||||
let paths = unifyPaths(paths_);
|
||||
if (cwd) {
|
||||
paths = paths.map((path) => {
|
||||
const absPath = getAbsolutePath(path, cwd);
|
||||
// Check `path` instead of `absPath` because the cwd portion can't be a glob
|
||||
return absPath;
|
||||
});
|
||||
}
|
||||
paths.forEach((path) => {
|
||||
this._removeIgnoredPath(path);
|
||||
});
|
||||
this._userIgnored = undefined;
|
||||
if (!this._readyCount)
|
||||
this._readyCount = 0;
|
||||
this._readyCount += paths.length;
|
||||
Promise.all(paths.map(async (path) => {
|
||||
const res = await this._nodeFsHandler._addToNodeFs(path, !_internal, undefined, 0, _origAdd);
|
||||
if (res)
|
||||
this._emitReady();
|
||||
return res;
|
||||
})).then((results) => {
|
||||
if (this.closed)
|
||||
return;
|
||||
results.forEach((item) => {
|
||||
if (item)
|
||||
this.add(sysPath.dirname(item), sysPath.basename(_origAdd || item));
|
||||
});
|
||||
});
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Close watchers or start ignoring events from specified paths.
|
||||
*/
|
||||
unwatch(paths_) {
|
||||
if (this.closed)
|
||||
return this;
|
||||
const paths = unifyPaths(paths_);
|
||||
const { cwd } = this.options;
|
||||
paths.forEach((path) => {
|
||||
// convert to absolute path unless relative path already matches
|
||||
if (!sysPath.isAbsolute(path) && !this._closers.has(path)) {
|
||||
if (cwd)
|
||||
path = sysPath.join(cwd, path);
|
||||
path = sysPath.resolve(path);
|
||||
}
|
||||
this._closePath(path);
|
||||
this._addIgnoredPath(path);
|
||||
if (this._watched.has(path)) {
|
||||
this._addIgnoredPath({
|
||||
path,
|
||||
recursive: true,
|
||||
});
|
||||
}
|
||||
// reset the cached userIgnored anymatch fn
|
||||
// to make ignoredPaths changes effective
|
||||
this._userIgnored = undefined;
|
||||
});
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Close watchers and remove all listeners from watched paths.
|
||||
*/
|
||||
close() {
|
||||
if (this._closePromise) {
|
||||
return this._closePromise;
|
||||
}
|
||||
this.closed = true;
|
||||
// Memory management.
|
||||
this.removeAllListeners();
|
||||
const closers = [];
|
||||
this._closers.forEach((closerList) => closerList.forEach((closer) => {
|
||||
const promise = closer();
|
||||
if (promise instanceof Promise)
|
||||
closers.push(promise);
|
||||
}));
|
||||
this._streams.forEach((stream) => stream.destroy());
|
||||
this._userIgnored = undefined;
|
||||
this._readyCount = 0;
|
||||
this._readyEmitted = false;
|
||||
this._watched.forEach((dirent) => dirent.dispose());
|
||||
this._closers.clear();
|
||||
this._watched.clear();
|
||||
this._streams.clear();
|
||||
this._symlinkPaths.clear();
|
||||
this._throttled.clear();
|
||||
this._closePromise = closers.length
|
||||
? Promise.all(closers).then(() => undefined)
|
||||
: Promise.resolve();
|
||||
return this._closePromise;
|
||||
}
|
||||
/**
|
||||
* Expose list of watched paths
|
||||
* @returns for chaining
|
||||
*/
|
||||
getWatched() {
|
||||
const watchList = {};
|
||||
this._watched.forEach((entry, dir) => {
|
||||
const key = this.options.cwd ? sysPath.relative(this.options.cwd, dir) : dir;
|
||||
const index = key || ONE_DOT;
|
||||
watchList[index] = entry.getChildren().sort();
|
||||
});
|
||||
return watchList;
|
||||
}
|
||||
emitWithAll(event, args) {
|
||||
this.emit(event, ...args);
|
||||
if (event !== EV.ERROR)
|
||||
this.emit(EV.ALL, event, ...args);
|
||||
}
|
||||
// Common helpers
|
||||
// --------------
|
||||
/**
|
||||
* Normalize and emit events.
|
||||
* Calling _emit DOES NOT MEAN emit() would be called!
|
||||
* @param event Type of event
|
||||
* @param path File or directory path
|
||||
* @param stats arguments to be passed with event
|
||||
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
||||
*/
|
||||
async _emit(event, path, stats) {
|
||||
if (this.closed)
|
||||
return;
|
||||
const opts = this.options;
|
||||
if (isWindows)
|
||||
path = sysPath.normalize(path);
|
||||
if (opts.cwd)
|
||||
path = sysPath.relative(opts.cwd, path);
|
||||
const args = [path];
|
||||
if (stats != null)
|
||||
args.push(stats);
|
||||
const awf = opts.awaitWriteFinish;
|
||||
let pw;
|
||||
if (awf && (pw = this._pendingWrites.get(path))) {
|
||||
pw.lastChange = new Date();
|
||||
return this;
|
||||
}
|
||||
if (opts.atomic) {
|
||||
if (event === EV.UNLINK) {
|
||||
this._pendingUnlinks.set(path, [event, ...args]);
|
||||
setTimeout(() => {
|
||||
this._pendingUnlinks.forEach((entry, path) => {
|
||||
this.emit(...entry);
|
||||
this.emit(EV.ALL, ...entry);
|
||||
this._pendingUnlinks.delete(path);
|
||||
});
|
||||
}, typeof opts.atomic === 'number' ? opts.atomic : 100);
|
||||
return this;
|
||||
}
|
||||
if (event === EV.ADD && this._pendingUnlinks.has(path)) {
|
||||
event = EV.CHANGE;
|
||||
this._pendingUnlinks.delete(path);
|
||||
}
|
||||
}
|
||||
if (awf && (event === EV.ADD || event === EV.CHANGE) && this._readyEmitted) {
|
||||
const awfEmit = (err, stats) => {
|
||||
if (err) {
|
||||
event = EV.ERROR;
|
||||
args[0] = err;
|
||||
this.emitWithAll(event, args);
|
||||
}
|
||||
else if (stats) {
|
||||
// if stats doesn't exist the file must have been deleted
|
||||
if (args.length > 1) {
|
||||
args[1] = stats;
|
||||
}
|
||||
else {
|
||||
args.push(stats);
|
||||
}
|
||||
this.emitWithAll(event, args);
|
||||
}
|
||||
};
|
||||
this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit);
|
||||
return this;
|
||||
}
|
||||
if (event === EV.CHANGE) {
|
||||
const isThrottled = !this._throttle(EV.CHANGE, path, 50);
|
||||
if (isThrottled)
|
||||
return this;
|
||||
}
|
||||
if (opts.alwaysStat &&
|
||||
stats === undefined &&
|
||||
(event === EV.ADD || event === EV.ADD_DIR || event === EV.CHANGE)) {
|
||||
const fullPath = opts.cwd ? sysPath.join(opts.cwd, path) : path;
|
||||
let stats;
|
||||
try {
|
||||
stats = await stat(fullPath);
|
||||
}
|
||||
catch (err) {
|
||||
// do nothing
|
||||
}
|
||||
// Suppress event when fs_stat fails, to avoid sending undefined 'stat'
|
||||
if (!stats || this.closed)
|
||||
return;
|
||||
args.push(stats);
|
||||
}
|
||||
this.emitWithAll(event, args);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Common handler for errors
|
||||
* @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
||||
*/
|
||||
_handleError(error) {
|
||||
const code = error && error.code;
|
||||
if (error &&
|
||||
code !== 'ENOENT' &&
|
||||
code !== 'ENOTDIR' &&
|
||||
(!this.options.ignorePermissionErrors || (code !== 'EPERM' && code !== 'EACCES'))) {
|
||||
this.emit(EV.ERROR, error);
|
||||
}
|
||||
return error || this.closed;
|
||||
}
|
||||
/**
|
||||
* Helper utility for throttling
|
||||
* @param actionType type being throttled
|
||||
* @param path being acted upon
|
||||
* @param timeout duration of time to suppress duplicate actions
|
||||
* @returns tracking object or false if action should be suppressed
|
||||
*/
|
||||
_throttle(actionType, path, timeout) {
|
||||
if (!this._throttled.has(actionType)) {
|
||||
this._throttled.set(actionType, new Map());
|
||||
}
|
||||
const action = this._throttled.get(actionType);
|
||||
if (!action)
|
||||
throw new Error('invalid throttle');
|
||||
const actionPath = action.get(path);
|
||||
if (actionPath) {
|
||||
actionPath.count++;
|
||||
return false;
|
||||
}
|
||||
// eslint-disable-next-line prefer-const
|
||||
let timeoutObject;
|
||||
const clear = () => {
|
||||
const item = action.get(path);
|
||||
const count = item ? item.count : 0;
|
||||
action.delete(path);
|
||||
clearTimeout(timeoutObject);
|
||||
if (item)
|
||||
clearTimeout(item.timeoutObject);
|
||||
return count;
|
||||
};
|
||||
timeoutObject = setTimeout(clear, timeout);
|
||||
const thr = { timeoutObject, clear, count: 0 };
|
||||
action.set(path, thr);
|
||||
return thr;
|
||||
}
|
||||
_incrReadyCount() {
|
||||
return this._readyCount++;
|
||||
}
|
||||
/**
|
||||
* Awaits write operation to finish.
|
||||
* Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.
|
||||
* @param path being acted upon
|
||||
* @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished
|
||||
* @param event
|
||||
* @param awfEmit Callback to be called when ready for event to be emitted.
|
||||
*/
|
||||
_awaitWriteFinish(path, threshold, event, awfEmit) {
|
||||
const awf = this.options.awaitWriteFinish;
|
||||
if (typeof awf !== 'object')
|
||||
return;
|
||||
const pollInterval = awf.pollInterval;
|
||||
let timeoutHandler;
|
||||
let fullPath = path;
|
||||
if (this.options.cwd && !sysPath.isAbsolute(path)) {
|
||||
fullPath = sysPath.join(this.options.cwd, path);
|
||||
}
|
||||
const now = new Date();
|
||||
const writes = this._pendingWrites;
|
||||
function awaitWriteFinishFn(prevStat) {
|
||||
statcb(fullPath, (err, curStat) => {
|
||||
if (err || !writes.has(path)) {
|
||||
if (err && err.code !== 'ENOENT')
|
||||
awfEmit(err);
|
||||
return;
|
||||
}
|
||||
const now = Number(new Date());
|
||||
if (prevStat && curStat.size !== prevStat.size) {
|
||||
writes.get(path).lastChange = now;
|
||||
}
|
||||
const pw = writes.get(path);
|
||||
const df = now - pw.lastChange;
|
||||
if (df >= threshold) {
|
||||
writes.delete(path);
|
||||
awfEmit(undefined, curStat);
|
||||
}
|
||||
else {
|
||||
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!writes.has(path)) {
|
||||
writes.set(path, {
|
||||
lastChange: now,
|
||||
cancelWait: () => {
|
||||
writes.delete(path);
|
||||
clearTimeout(timeoutHandler);
|
||||
return event;
|
||||
},
|
||||
});
|
||||
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Determines whether user has asked to ignore this path.
|
||||
*/
|
||||
_isIgnored(path, stats) {
|
||||
if (this.options.atomic && DOT_RE.test(path))
|
||||
return true;
|
||||
if (!this._userIgnored) {
|
||||
const { cwd } = this.options;
|
||||
const ign = this.options.ignored;
|
||||
const ignored = (ign || []).map(normalizeIgnored(cwd));
|
||||
const ignoredPaths = [...this._ignoredPaths];
|
||||
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
||||
this._userIgnored = anymatch(list, undefined);
|
||||
}
|
||||
return this._userIgnored(path, stats);
|
||||
}
|
||||
_isntIgnored(path, stat) {
|
||||
return !this._isIgnored(path, stat);
|
||||
}
|
||||
/**
|
||||
* Provides a set of common helpers and properties relating to symlink handling.
|
||||
* @param path file or directory pattern being watched
|
||||
*/
|
||||
_getWatchHelpers(path) {
|
||||
return new WatchHelper(path, this.options.followSymlinks, this);
|
||||
}
|
||||
// Directory helpers
|
||||
// -----------------
|
||||
/**
|
||||
* Provides directory tracking objects
|
||||
* @param directory path of the directory
|
||||
*/
|
||||
_getWatchedDir(directory) {
|
||||
const dir = sysPath.resolve(directory);
|
||||
if (!this._watched.has(dir))
|
||||
this._watched.set(dir, new DirEntry(dir, this._boundRemove));
|
||||
return this._watched.get(dir);
|
||||
}
|
||||
// File helpers
|
||||
// ------------
|
||||
/**
|
||||
* Check for read permissions: https://stackoverflow.com/a/11781404/1358405
|
||||
*/
|
||||
_hasReadPermissions(stats) {
|
||||
if (this.options.ignorePermissionErrors)
|
||||
return true;
|
||||
return Boolean(Number(stats.mode) & 0o400);
|
||||
}
|
||||
/**
|
||||
* Handles emitting unlink events for
|
||||
* files and directories, and via recursion, for
|
||||
* files and directories within directories that are unlinked
|
||||
* @param directory within which the following item is located
|
||||
* @param item base path of item/directory
|
||||
*/
|
||||
_remove(directory, item, isDirectory) {
|
||||
// if what is being deleted is a directory, get that directory's paths
|
||||
// for recursive deleting and cleaning of watched object
|
||||
// if it is not a directory, nestedDirectoryChildren will be empty array
|
||||
const path = sysPath.join(directory, item);
|
||||
const fullPath = sysPath.resolve(path);
|
||||
isDirectory =
|
||||
isDirectory != null ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);
|
||||
// prevent duplicate handling in case of arriving here nearly simultaneously
|
||||
// via multiple paths (such as _handleFile and _handleDir)
|
||||
if (!this._throttle('remove', path, 100))
|
||||
return;
|
||||
// if the only watched file is removed, watch for its return
|
||||
if (!isDirectory && this._watched.size === 1) {
|
||||
this.add(directory, item, true);
|
||||
}
|
||||
// This will create a new entry in the watched object in either case
|
||||
// so we got to do the directory check beforehand
|
||||
const wp = this._getWatchedDir(path);
|
||||
const nestedDirectoryChildren = wp.getChildren();
|
||||
// Recursively remove children directories / files.
|
||||
nestedDirectoryChildren.forEach((nested) => this._remove(path, nested));
|
||||
// Check if item was on the watched list and remove it
|
||||
const parent = this._getWatchedDir(directory);
|
||||
const wasTracked = parent.has(item);
|
||||
parent.remove(item);
|
||||
// Fixes issue #1042 -> Relative paths were detected and added as symlinks
|
||||
// (https://github.com/paulmillr/chokidar/blob/e1753ddbc9571bdc33b4a4af172d52cb6e611c10/lib/nodefs-handler.js#L612),
|
||||
// but never removed from the map in case the path was deleted.
|
||||
// This leads to an incorrect state if the path was recreated:
|
||||
// https://github.com/paulmillr/chokidar/blob/e1753ddbc9571bdc33b4a4af172d52cb6e611c10/lib/nodefs-handler.js#L553
|
||||
if (this._symlinkPaths.has(fullPath)) {
|
||||
this._symlinkPaths.delete(fullPath);
|
||||
}
|
||||
// If we wait for this file to be fully written, cancel the wait.
|
||||
let relPath = path;
|
||||
if (this.options.cwd)
|
||||
relPath = sysPath.relative(this.options.cwd, path);
|
||||
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
||||
const event = this._pendingWrites.get(relPath).cancelWait();
|
||||
if (event === EV.ADD)
|
||||
return;
|
||||
}
|
||||
// The Entry will either be a directory that just got removed
|
||||
// or a bogus entry to a file, in either case we have to remove it
|
||||
this._watched.delete(path);
|
||||
this._watched.delete(fullPath);
|
||||
const eventName = isDirectory ? EV.UNLINK_DIR : EV.UNLINK;
|
||||
if (wasTracked && !this._isIgnored(path))
|
||||
this._emit(eventName, path);
|
||||
// Avoid conflicts if we later create another file with the same name
|
||||
this._closePath(path);
|
||||
}
|
||||
/**
|
||||
* Closes all watchers for a path
|
||||
*/
|
||||
_closePath(path) {
|
||||
this._closeFile(path);
|
||||
const dir = sysPath.dirname(path);
|
||||
this._getWatchedDir(dir).remove(sysPath.basename(path));
|
||||
}
|
||||
/**
|
||||
* Closes only file-specific watchers
|
||||
*/
|
||||
_closeFile(path) {
|
||||
const closers = this._closers.get(path);
|
||||
if (!closers)
|
||||
return;
|
||||
closers.forEach((closer) => closer());
|
||||
this._closers.delete(path);
|
||||
}
|
||||
_addPathCloser(path, closer) {
|
||||
if (!closer)
|
||||
return;
|
||||
let list = this._closers.get(path);
|
||||
if (!list) {
|
||||
list = [];
|
||||
this._closers.set(path, list);
|
||||
}
|
||||
list.push(closer);
|
||||
}
|
||||
_readdirp(root, opts) {
|
||||
if (this.closed)
|
||||
return;
|
||||
const options = { type: EV.ALL, alwaysStat: true, lstat: true, ...opts, depth: 0 };
|
||||
let stream = readdirp(root, options);
|
||||
this._streams.add(stream);
|
||||
stream.once(STR_CLOSE, () => {
|
||||
stream = undefined;
|
||||
});
|
||||
stream.once(STR_END, () => {
|
||||
if (stream) {
|
||||
this._streams.delete(stream);
|
||||
stream = undefined;
|
||||
}
|
||||
});
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Instantiates watcher with paths to be tracked.
|
||||
* @param paths file / directory paths
|
||||
* @param options opts, such as `atomic`, `awaitWriteFinish`, `ignored`, and others
|
||||
* @returns an instance of FSWatcher for chaining.
|
||||
* @example
|
||||
* const watcher = watch('.').on('all', (event, path) => { console.log(event, path); });
|
||||
* watch('.', { atomic: true, awaitWriteFinish: true, ignored: (f, stats) => stats?.isFile() && !f.endsWith('.js') })
|
||||
*/
|
||||
export function watch(paths, options = {}) {
|
||||
const watcher = new FSWatcher(options);
|
||||
watcher.add(paths);
|
||||
return watcher;
|
||||
}
|
||||
export default { watch, FSWatcher };
|
||||
1
node_modules/sass/node_modules/chokidar/esm/package.json
generated
vendored
Normal file
1
node_modules/sass/node_modules/chokidar/esm/package.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{ "type": "module", "sideEffects": false }
|
||||
90
node_modules/sass/node_modules/chokidar/handler.d.ts
generated
vendored
Normal file
90
node_modules/sass/node_modules/chokidar/handler.d.ts
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
import type { WatchEventType, Stats, FSWatcher as NativeFsWatcher } from 'fs';
|
||||
import type { FSWatcher, WatchHelper, Throttler } from './index.js';
|
||||
import type { EntryInfo } from 'readdirp';
|
||||
export type Path = string;
|
||||
export declare const STR_DATA = "data";
|
||||
export declare const STR_END = "end";
|
||||
export declare const STR_CLOSE = "close";
|
||||
export declare const EMPTY_FN: () => void;
|
||||
export declare const IDENTITY_FN: (val: unknown) => unknown;
|
||||
export declare const isWindows: boolean;
|
||||
export declare const isMacos: boolean;
|
||||
export declare const isLinux: boolean;
|
||||
export declare const isFreeBSD: boolean;
|
||||
export declare const isIBMi: boolean;
|
||||
export declare const EVENTS: {
|
||||
readonly ALL: "all";
|
||||
readonly READY: "ready";
|
||||
readonly ADD: "add";
|
||||
readonly CHANGE: "change";
|
||||
readonly ADD_DIR: "addDir";
|
||||
readonly UNLINK: "unlink";
|
||||
readonly UNLINK_DIR: "unlinkDir";
|
||||
readonly RAW: "raw";
|
||||
readonly ERROR: "error";
|
||||
};
|
||||
export type EventName = (typeof EVENTS)[keyof typeof EVENTS];
|
||||
export type FsWatchContainer = {
|
||||
listeners: (path: string) => void | Set<any>;
|
||||
errHandlers: (err: unknown) => void | Set<any>;
|
||||
rawEmitters: (ev: WatchEventType, path: string, opts: unknown) => void | Set<any>;
|
||||
watcher: NativeFsWatcher;
|
||||
watcherUnusable?: boolean;
|
||||
};
|
||||
export interface WatchHandlers {
|
||||
listener: (path: string) => void;
|
||||
errHandler: (err: unknown) => void;
|
||||
rawEmitter: (ev: WatchEventType, path: string, opts: unknown) => void;
|
||||
}
|
||||
/**
|
||||
* @mixin
|
||||
*/
|
||||
export declare class NodeFsHandler {
|
||||
fsw: FSWatcher;
|
||||
_boundHandleError: (error: unknown) => void;
|
||||
constructor(fsW: FSWatcher);
|
||||
/**
|
||||
* Watch file for changes with fs_watchFile or fs_watch.
|
||||
* @param path to file or dir
|
||||
* @param listener on fs change
|
||||
* @returns closer for the watcher instance
|
||||
*/
|
||||
_watchWithNodeFs(path: string, listener: (path: string, newStats?: any) => void | Promise<void>): (() => void) | undefined;
|
||||
/**
|
||||
* Watch a file and emit add event if warranted.
|
||||
* @returns closer for the watcher instance
|
||||
*/
|
||||
_handleFile(file: Path, stats: Stats, initialAdd: boolean): (() => void) | undefined;
|
||||
/**
|
||||
* Handle symlinks encountered while reading a dir.
|
||||
* @param entry returned by readdirp
|
||||
* @param directory path of dir being read
|
||||
* @param path of this item
|
||||
* @param item basename of this item
|
||||
* @returns true if no more processing is needed for this entry.
|
||||
*/
|
||||
_handleSymlink(entry: EntryInfo, directory: string, path: Path, item: string): Promise<boolean | undefined>;
|
||||
_handleRead(directory: string, initialAdd: boolean, wh: WatchHelper, target: Path, dir: Path, depth: number, throttler: Throttler): Promise<unknown> | undefined;
|
||||
/**
|
||||
* Read directory to add / remove files from `@watched` list and re-read it on change.
|
||||
* @param dir fs path
|
||||
* @param stats
|
||||
* @param initialAdd
|
||||
* @param depth relative to user-supplied path
|
||||
* @param target child path targeted for watch
|
||||
* @param wh Common watch helpers for this path
|
||||
* @param realpath
|
||||
* @returns closer for the watcher instance.
|
||||
*/
|
||||
_handleDir(dir: string, stats: Stats, initialAdd: boolean, depth: number, target: string, wh: WatchHelper, realpath: string): Promise<(() => void) | undefined>;
|
||||
/**
|
||||
* Handle added file, directory, or glob pattern.
|
||||
* Delegates call to _handleFile / _handleDir after checks.
|
||||
* @param path to file or ir
|
||||
* @param initialAdd was the file added at watch instantiation?
|
||||
* @param priorWh depth relative to user-supplied path
|
||||
* @param depth Child path actually targeted for watch
|
||||
* @param target Child path actually targeted for watch
|
||||
*/
|
||||
_addToNodeFs(path: string, initialAdd: boolean, priorWh: WatchHelper | undefined, depth: number, target?: string): Promise<string | false | undefined>;
|
||||
}
|
||||
635
node_modules/sass/node_modules/chokidar/handler.js
generated
vendored
Normal file
635
node_modules/sass/node_modules/chokidar/handler.js
generated
vendored
Normal file
@@ -0,0 +1,635 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.NodeFsHandler = exports.EVENTS = exports.isIBMi = exports.isFreeBSD = exports.isLinux = exports.isMacos = exports.isWindows = exports.IDENTITY_FN = exports.EMPTY_FN = exports.STR_CLOSE = exports.STR_END = exports.STR_DATA = void 0;
|
||||
const fs_1 = require("fs");
|
||||
const promises_1 = require("fs/promises");
|
||||
const sysPath = require("path");
|
||||
const os_1 = require("os");
|
||||
exports.STR_DATA = 'data';
|
||||
exports.STR_END = 'end';
|
||||
exports.STR_CLOSE = 'close';
|
||||
const EMPTY_FN = () => { };
|
||||
exports.EMPTY_FN = EMPTY_FN;
|
||||
const IDENTITY_FN = (val) => val;
|
||||
exports.IDENTITY_FN = IDENTITY_FN;
|
||||
const pl = process.platform;
|
||||
exports.isWindows = pl === 'win32';
|
||||
exports.isMacos = pl === 'darwin';
|
||||
exports.isLinux = pl === 'linux';
|
||||
exports.isFreeBSD = pl === 'freebsd';
|
||||
exports.isIBMi = (0, os_1.type)() === 'OS400';
|
||||
exports.EVENTS = {
|
||||
ALL: 'all',
|
||||
READY: 'ready',
|
||||
ADD: 'add',
|
||||
CHANGE: 'change',
|
||||
ADD_DIR: 'addDir',
|
||||
UNLINK: 'unlink',
|
||||
UNLINK_DIR: 'unlinkDir',
|
||||
RAW: 'raw',
|
||||
ERROR: 'error',
|
||||
};
|
||||
const EV = exports.EVENTS;
|
||||
const THROTTLE_MODE_WATCH = 'watch';
|
||||
const statMethods = { lstat: promises_1.lstat, stat: promises_1.stat };
|
||||
const KEY_LISTENERS = 'listeners';
|
||||
const KEY_ERR = 'errHandlers';
|
||||
const KEY_RAW = 'rawEmitters';
|
||||
const HANDLER_KEYS = [KEY_LISTENERS, KEY_ERR, KEY_RAW];
|
||||
// prettier-ignore
|
||||
const binaryExtensions = new Set([
|
||||
'3dm', '3ds', '3g2', '3gp', '7z', 'a', 'aac', 'adp', 'afdesign', 'afphoto', 'afpub', 'ai',
|
||||
'aif', 'aiff', 'alz', 'ape', 'apk', 'appimage', 'ar', 'arj', 'asf', 'au', 'avi',
|
||||
'bak', 'baml', 'bh', 'bin', 'bk', 'bmp', 'btif', 'bz2', 'bzip2',
|
||||
'cab', 'caf', 'cgm', 'class', 'cmx', 'cpio', 'cr2', 'cur', 'dat', 'dcm', 'deb', 'dex', 'djvu',
|
||||
'dll', 'dmg', 'dng', 'doc', 'docm', 'docx', 'dot', 'dotm', 'dra', 'DS_Store', 'dsk', 'dts',
|
||||
'dtshd', 'dvb', 'dwg', 'dxf',
|
||||
'ecelp4800', 'ecelp7470', 'ecelp9600', 'egg', 'eol', 'eot', 'epub', 'exe',
|
||||
'f4v', 'fbs', 'fh', 'fla', 'flac', 'flatpak', 'fli', 'flv', 'fpx', 'fst', 'fvt',
|
||||
'g3', 'gh', 'gif', 'graffle', 'gz', 'gzip',
|
||||
'h261', 'h263', 'h264', 'icns', 'ico', 'ief', 'img', 'ipa', 'iso',
|
||||
'jar', 'jpeg', 'jpg', 'jpgv', 'jpm', 'jxr', 'key', 'ktx',
|
||||
'lha', 'lib', 'lvp', 'lz', 'lzh', 'lzma', 'lzo',
|
||||
'm3u', 'm4a', 'm4v', 'mar', 'mdi', 'mht', 'mid', 'midi', 'mj2', 'mka', 'mkv', 'mmr', 'mng',
|
||||
'mobi', 'mov', 'movie', 'mp3',
|
||||
'mp4', 'mp4a', 'mpeg', 'mpg', 'mpga', 'mxu',
|
||||
'nef', 'npx', 'numbers', 'nupkg',
|
||||
'o', 'odp', 'ods', 'odt', 'oga', 'ogg', 'ogv', 'otf', 'ott',
|
||||
'pages', 'pbm', 'pcx', 'pdb', 'pdf', 'pea', 'pgm', 'pic', 'png', 'pnm', 'pot', 'potm',
|
||||
'potx', 'ppa', 'ppam',
|
||||
'ppm', 'pps', 'ppsm', 'ppsx', 'ppt', 'pptm', 'pptx', 'psd', 'pya', 'pyc', 'pyo', 'pyv',
|
||||
'qt',
|
||||
'rar', 'ras', 'raw', 'resources', 'rgb', 'rip', 'rlc', 'rmf', 'rmvb', 'rpm', 'rtf', 'rz',
|
||||
's3m', 's7z', 'scpt', 'sgi', 'shar', 'snap', 'sil', 'sketch', 'slk', 'smv', 'snk', 'so',
|
||||
'stl', 'suo', 'sub', 'swf',
|
||||
'tar', 'tbz', 'tbz2', 'tga', 'tgz', 'thmx', 'tif', 'tiff', 'tlz', 'ttc', 'ttf', 'txz',
|
||||
'udf', 'uvh', 'uvi', 'uvm', 'uvp', 'uvs', 'uvu',
|
||||
'viv', 'vob',
|
||||
'war', 'wav', 'wax', 'wbmp', 'wdp', 'weba', 'webm', 'webp', 'whl', 'wim', 'wm', 'wma',
|
||||
'wmv', 'wmx', 'woff', 'woff2', 'wrm', 'wvx',
|
||||
'xbm', 'xif', 'xla', 'xlam', 'xls', 'xlsb', 'xlsm', 'xlsx', 'xlt', 'xltm', 'xltx', 'xm',
|
||||
'xmind', 'xpi', 'xpm', 'xwd', 'xz',
|
||||
'z', 'zip', 'zipx',
|
||||
]);
|
||||
const isBinaryPath = (filePath) => binaryExtensions.has(sysPath.extname(filePath).slice(1).toLowerCase());
|
||||
// TODO: emit errors properly. Example: EMFILE on Macos.
|
||||
const foreach = (val, fn) => {
|
||||
if (val instanceof Set) {
|
||||
val.forEach(fn);
|
||||
}
|
||||
else {
|
||||
fn(val);
|
||||
}
|
||||
};
|
||||
const addAndConvert = (main, prop, item) => {
|
||||
let container = main[prop];
|
||||
if (!(container instanceof Set)) {
|
||||
main[prop] = container = new Set([container]);
|
||||
}
|
||||
container.add(item);
|
||||
};
|
||||
const clearItem = (cont) => (key) => {
|
||||
const set = cont[key];
|
||||
if (set instanceof Set) {
|
||||
set.clear();
|
||||
}
|
||||
else {
|
||||
delete cont[key];
|
||||
}
|
||||
};
|
||||
const delFromSet = (main, prop, item) => {
|
||||
const container = main[prop];
|
||||
if (container instanceof Set) {
|
||||
container.delete(item);
|
||||
}
|
||||
else if (container === item) {
|
||||
delete main[prop];
|
||||
}
|
||||
};
|
||||
const isEmptySet = (val) => (val instanceof Set ? val.size === 0 : !val);
|
||||
const FsWatchInstances = new Map();
|
||||
/**
|
||||
* Instantiates the fs_watch interface
|
||||
* @param path to be watched
|
||||
* @param options to be passed to fs_watch
|
||||
* @param listener main event handler
|
||||
* @param errHandler emits info about errors
|
||||
* @param emitRaw emits raw event data
|
||||
* @returns {NativeFsWatcher}
|
||||
*/
|
||||
function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
|
||||
const handleEvent = (rawEvent, evPath) => {
|
||||
listener(path);
|
||||
emitRaw(rawEvent, evPath, { watchedPath: path });
|
||||
// emit based on events occurring for files from a directory's watcher in
|
||||
// case the file's watcher misses it (and rely on throttling to de-dupe)
|
||||
if (evPath && path !== evPath) {
|
||||
fsWatchBroadcast(sysPath.resolve(path, evPath), KEY_LISTENERS, sysPath.join(path, evPath));
|
||||
}
|
||||
};
|
||||
try {
|
||||
return (0, fs_1.watch)(path, {
|
||||
persistent: options.persistent,
|
||||
}, handleEvent);
|
||||
}
|
||||
catch (error) {
|
||||
errHandler(error);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Helper for passing fs_watch event data to a collection of listeners
|
||||
* @param fullPath absolute path bound to fs_watch instance
|
||||
*/
|
||||
const fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
||||
const cont = FsWatchInstances.get(fullPath);
|
||||
if (!cont)
|
||||
return;
|
||||
foreach(cont[listenerType], (listener) => {
|
||||
listener(val1, val2, val3);
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Instantiates the fs_watch interface or binds listeners
|
||||
* to an existing one covering the same file system entry
|
||||
* @param path
|
||||
* @param fullPath absolute path
|
||||
* @param options to be passed to fs_watch
|
||||
* @param handlers container for event listener functions
|
||||
*/
|
||||
const setFsWatchListener = (path, fullPath, options, handlers) => {
|
||||
const { listener, errHandler, rawEmitter } = handlers;
|
||||
let cont = FsWatchInstances.get(fullPath);
|
||||
let watcher;
|
||||
if (!options.persistent) {
|
||||
watcher = createFsWatchInstance(path, options, listener, errHandler, rawEmitter);
|
||||
if (!watcher)
|
||||
return;
|
||||
return watcher.close.bind(watcher);
|
||||
}
|
||||
if (cont) {
|
||||
addAndConvert(cont, KEY_LISTENERS, listener);
|
||||
addAndConvert(cont, KEY_ERR, errHandler);
|
||||
addAndConvert(cont, KEY_RAW, rawEmitter);
|
||||
}
|
||||
else {
|
||||
watcher = createFsWatchInstance(path, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, // no need to use broadcast here
|
||||
fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
|
||||
if (!watcher)
|
||||
return;
|
||||
watcher.on(EV.ERROR, async (error) => {
|
||||
const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR);
|
||||
if (cont)
|
||||
cont.watcherUnusable = true; // documented since Node 10.4.1
|
||||
// Workaround for https://github.com/joyent/node/issues/4337
|
||||
if (exports.isWindows && error.code === 'EPERM') {
|
||||
try {
|
||||
const fd = await (0, promises_1.open)(path, 'r');
|
||||
await fd.close();
|
||||
broadcastErr(error);
|
||||
}
|
||||
catch (err) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
else {
|
||||
broadcastErr(error);
|
||||
}
|
||||
});
|
||||
cont = {
|
||||
listeners: listener,
|
||||
errHandlers: errHandler,
|
||||
rawEmitters: rawEmitter,
|
||||
watcher,
|
||||
};
|
||||
FsWatchInstances.set(fullPath, cont);
|
||||
}
|
||||
// const index = cont.listeners.indexOf(listener);
|
||||
// removes this instance's listeners and closes the underlying fs_watch
|
||||
// instance if there are no more listeners left
|
||||
return () => {
|
||||
delFromSet(cont, KEY_LISTENERS, listener);
|
||||
delFromSet(cont, KEY_ERR, errHandler);
|
||||
delFromSet(cont, KEY_RAW, rawEmitter);
|
||||
if (isEmptySet(cont.listeners)) {
|
||||
// Check to protect against issue gh-730.
|
||||
// if (cont.watcherUnusable) {
|
||||
cont.watcher.close();
|
||||
// }
|
||||
FsWatchInstances.delete(fullPath);
|
||||
HANDLER_KEYS.forEach(clearItem(cont));
|
||||
// @ts-ignore
|
||||
cont.watcher = undefined;
|
||||
Object.freeze(cont);
|
||||
}
|
||||
};
|
||||
};
|
||||
// fs_watchFile helpers
|
||||
// object to hold per-process fs_watchFile instances
|
||||
// (may be shared across chokidar FSWatcher instances)
|
||||
const FsWatchFileInstances = new Map();
|
||||
/**
|
||||
* Instantiates the fs_watchFile interface or binds listeners
|
||||
* to an existing one covering the same file system entry
|
||||
* @param path to be watched
|
||||
* @param fullPath absolute path
|
||||
* @param options options to be passed to fs_watchFile
|
||||
* @param handlers container for event listener functions
|
||||
* @returns closer
|
||||
*/
|
||||
const setFsWatchFileListener = (path, fullPath, options, handlers) => {
|
||||
const { listener, rawEmitter } = handlers;
|
||||
let cont = FsWatchFileInstances.get(fullPath);
|
||||
// let listeners = new Set();
|
||||
// let rawEmitters = new Set();
|
||||
const copts = cont && cont.options;
|
||||
if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
|
||||
// "Upgrade" the watcher to persistence or a quicker interval.
|
||||
// This creates some unlikely edge case issues if the user mixes
|
||||
// settings in a very weird way, but solving for those cases
|
||||
// doesn't seem worthwhile for the added complexity.
|
||||
// listeners = cont.listeners;
|
||||
// rawEmitters = cont.rawEmitters;
|
||||
(0, fs_1.unwatchFile)(fullPath);
|
||||
cont = undefined;
|
||||
}
|
||||
if (cont) {
|
||||
addAndConvert(cont, KEY_LISTENERS, listener);
|
||||
addAndConvert(cont, KEY_RAW, rawEmitter);
|
||||
}
|
||||
else {
|
||||
// TODO
|
||||
// listeners.add(listener);
|
||||
// rawEmitters.add(rawEmitter);
|
||||
cont = {
|
||||
listeners: listener,
|
||||
rawEmitters: rawEmitter,
|
||||
options,
|
||||
watcher: (0, fs_1.watchFile)(fullPath, options, (curr, prev) => {
|
||||
foreach(cont.rawEmitters, (rawEmitter) => {
|
||||
rawEmitter(EV.CHANGE, fullPath, { curr, prev });
|
||||
});
|
||||
const currmtime = curr.mtimeMs;
|
||||
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
||||
foreach(cont.listeners, (listener) => listener(path, curr));
|
||||
}
|
||||
}),
|
||||
};
|
||||
FsWatchFileInstances.set(fullPath, cont);
|
||||
}
|
||||
// const index = cont.listeners.indexOf(listener);
|
||||
// Removes this instance's listeners and closes the underlying fs_watchFile
|
||||
// instance if there are no more listeners left.
|
||||
return () => {
|
||||
delFromSet(cont, KEY_LISTENERS, listener);
|
||||
delFromSet(cont, KEY_RAW, rawEmitter);
|
||||
if (isEmptySet(cont.listeners)) {
|
||||
FsWatchFileInstances.delete(fullPath);
|
||||
(0, fs_1.unwatchFile)(fullPath);
|
||||
cont.options = cont.watcher = undefined;
|
||||
Object.freeze(cont);
|
||||
}
|
||||
};
|
||||
};
|
||||
/**
|
||||
* @mixin
|
||||
*/
|
||||
class NodeFsHandler {
|
||||
constructor(fsW) {
|
||||
this.fsw = fsW;
|
||||
this._boundHandleError = (error) => fsW._handleError(error);
|
||||
}
|
||||
/**
|
||||
* Watch file for changes with fs_watchFile or fs_watch.
|
||||
* @param path to file or dir
|
||||
* @param listener on fs change
|
||||
* @returns closer for the watcher instance
|
||||
*/
|
||||
_watchWithNodeFs(path, listener) {
|
||||
const opts = this.fsw.options;
|
||||
const directory = sysPath.dirname(path);
|
||||
const basename = sysPath.basename(path);
|
||||
const parent = this.fsw._getWatchedDir(directory);
|
||||
parent.add(basename);
|
||||
const absolutePath = sysPath.resolve(path);
|
||||
const options = {
|
||||
persistent: opts.persistent,
|
||||
};
|
||||
if (!listener)
|
||||
listener = exports.EMPTY_FN;
|
||||
let closer;
|
||||
if (opts.usePolling) {
|
||||
const enableBin = opts.interval !== opts.binaryInterval;
|
||||
options.interval = enableBin && isBinaryPath(basename) ? opts.binaryInterval : opts.interval;
|
||||
closer = setFsWatchFileListener(path, absolutePath, options, {
|
||||
listener,
|
||||
rawEmitter: this.fsw._emitRaw,
|
||||
});
|
||||
}
|
||||
else {
|
||||
closer = setFsWatchListener(path, absolutePath, options, {
|
||||
listener,
|
||||
errHandler: this._boundHandleError,
|
||||
rawEmitter: this.fsw._emitRaw,
|
||||
});
|
||||
}
|
||||
return closer;
|
||||
}
|
||||
/**
|
||||
* Watch a file and emit add event if warranted.
|
||||
* @returns closer for the watcher instance
|
||||
*/
|
||||
_handleFile(file, stats, initialAdd) {
|
||||
if (this.fsw.closed) {
|
||||
return;
|
||||
}
|
||||
const dirname = sysPath.dirname(file);
|
||||
const basename = sysPath.basename(file);
|
||||
const parent = this.fsw._getWatchedDir(dirname);
|
||||
// stats is always present
|
||||
let prevStats = stats;
|
||||
// if the file is already being watched, do nothing
|
||||
if (parent.has(basename))
|
||||
return;
|
||||
const listener = async (path, newStats) => {
|
||||
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
|
||||
return;
|
||||
if (!newStats || newStats.mtimeMs === 0) {
|
||||
try {
|
||||
const newStats = await (0, promises_1.stat)(file);
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
// Check that change event was not fired because of changed only accessTime.
|
||||
const at = newStats.atimeMs;
|
||||
const mt = newStats.mtimeMs;
|
||||
if (!at || at <= mt || mt !== prevStats.mtimeMs) {
|
||||
this.fsw._emit(EV.CHANGE, file, newStats);
|
||||
}
|
||||
if ((exports.isMacos || exports.isLinux || exports.isFreeBSD) && prevStats.ino !== newStats.ino) {
|
||||
this.fsw._closeFile(path);
|
||||
prevStats = newStats;
|
||||
const closer = this._watchWithNodeFs(file, listener);
|
||||
if (closer)
|
||||
this.fsw._addPathCloser(path, closer);
|
||||
}
|
||||
else {
|
||||
prevStats = newStats;
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
// Fix issues where mtime is null but file is still present
|
||||
this.fsw._remove(dirname, basename);
|
||||
}
|
||||
// add is about to be emitted if file not already tracked in parent
|
||||
}
|
||||
else if (parent.has(basename)) {
|
||||
// Check that change event was not fired because of changed only accessTime.
|
||||
const at = newStats.atimeMs;
|
||||
const mt = newStats.mtimeMs;
|
||||
if (!at || at <= mt || mt !== prevStats.mtimeMs) {
|
||||
this.fsw._emit(EV.CHANGE, file, newStats);
|
||||
}
|
||||
prevStats = newStats;
|
||||
}
|
||||
};
|
||||
// kick off the watcher
|
||||
const closer = this._watchWithNodeFs(file, listener);
|
||||
// emit an add event if we're supposed to
|
||||
if (!(initialAdd && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(file)) {
|
||||
if (!this.fsw._throttle(EV.ADD, file, 0))
|
||||
return;
|
||||
this.fsw._emit(EV.ADD, file, stats);
|
||||
}
|
||||
return closer;
|
||||
}
|
||||
/**
|
||||
* Handle symlinks encountered while reading a dir.
|
||||
* @param entry returned by readdirp
|
||||
* @param directory path of dir being read
|
||||
* @param path of this item
|
||||
* @param item basename of this item
|
||||
* @returns true if no more processing is needed for this entry.
|
||||
*/
|
||||
async _handleSymlink(entry, directory, path, item) {
|
||||
if (this.fsw.closed) {
|
||||
return;
|
||||
}
|
||||
const full = entry.fullPath;
|
||||
const dir = this.fsw._getWatchedDir(directory);
|
||||
if (!this.fsw.options.followSymlinks) {
|
||||
// watch symlink directly (don't follow) and detect changes
|
||||
this.fsw._incrReadyCount();
|
||||
let linkPath;
|
||||
try {
|
||||
linkPath = await (0, promises_1.realpath)(path);
|
||||
}
|
||||
catch (e) {
|
||||
this.fsw._emitReady();
|
||||
return true;
|
||||
}
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
if (dir.has(item)) {
|
||||
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
||||
this.fsw._symlinkPaths.set(full, linkPath);
|
||||
this.fsw._emit(EV.CHANGE, path, entry.stats);
|
||||
}
|
||||
}
|
||||
else {
|
||||
dir.add(item);
|
||||
this.fsw._symlinkPaths.set(full, linkPath);
|
||||
this.fsw._emit(EV.ADD, path, entry.stats);
|
||||
}
|
||||
this.fsw._emitReady();
|
||||
return true;
|
||||
}
|
||||
// don't follow the same symlink more than once
|
||||
if (this.fsw._symlinkPaths.has(full)) {
|
||||
return true;
|
||||
}
|
||||
this.fsw._symlinkPaths.set(full, true);
|
||||
}
|
||||
_handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
|
||||
// Normalize the directory name on Windows
|
||||
directory = sysPath.join(directory, '');
|
||||
throttler = this.fsw._throttle('readdir', directory, 1000);
|
||||
if (!throttler)
|
||||
return;
|
||||
const previous = this.fsw._getWatchedDir(wh.path);
|
||||
const current = new Set();
|
||||
let stream = this.fsw._readdirp(directory, {
|
||||
fileFilter: (entry) => wh.filterPath(entry),
|
||||
directoryFilter: (entry) => wh.filterDir(entry),
|
||||
});
|
||||
if (!stream)
|
||||
return;
|
||||
stream
|
||||
.on(exports.STR_DATA, async (entry) => {
|
||||
if (this.fsw.closed) {
|
||||
stream = undefined;
|
||||
return;
|
||||
}
|
||||
const item = entry.path;
|
||||
let path = sysPath.join(directory, item);
|
||||
current.add(item);
|
||||
if (entry.stats.isSymbolicLink() &&
|
||||
(await this._handleSymlink(entry, directory, path, item))) {
|
||||
return;
|
||||
}
|
||||
if (this.fsw.closed) {
|
||||
stream = undefined;
|
||||
return;
|
||||
}
|
||||
// Files that present in current directory snapshot
|
||||
// but absent in previous are added to watch list and
|
||||
// emit `add` event.
|
||||
if (item === target || (!target && !previous.has(item))) {
|
||||
this.fsw._incrReadyCount();
|
||||
// ensure relativeness of path is preserved in case of watcher reuse
|
||||
path = sysPath.join(dir, sysPath.relative(dir, path));
|
||||
this._addToNodeFs(path, initialAdd, wh, depth + 1);
|
||||
}
|
||||
})
|
||||
.on(EV.ERROR, this._boundHandleError);
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!stream)
|
||||
return reject();
|
||||
stream.once(exports.STR_END, () => {
|
||||
if (this.fsw.closed) {
|
||||
stream = undefined;
|
||||
return;
|
||||
}
|
||||
const wasThrottled = throttler ? throttler.clear() : false;
|
||||
resolve(undefined);
|
||||
// Files that absent in current directory snapshot
|
||||
// but present in previous emit `remove` event
|
||||
// and are removed from @watched[directory].
|
||||
previous
|
||||
.getChildren()
|
||||
.filter((item) => {
|
||||
return item !== directory && !current.has(item);
|
||||
})
|
||||
.forEach((item) => {
|
||||
this.fsw._remove(directory, item);
|
||||
});
|
||||
stream = undefined;
|
||||
// one more time for any missed in case changes came in extremely quickly
|
||||
if (wasThrottled)
|
||||
this._handleRead(directory, false, wh, target, dir, depth, throttler);
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Read directory to add / remove files from `@watched` list and re-read it on change.
|
||||
* @param dir fs path
|
||||
* @param stats
|
||||
* @param initialAdd
|
||||
* @param depth relative to user-supplied path
|
||||
* @param target child path targeted for watch
|
||||
* @param wh Common watch helpers for this path
|
||||
* @param realpath
|
||||
* @returns closer for the watcher instance.
|
||||
*/
|
||||
async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath) {
|
||||
const parentDir = this.fsw._getWatchedDir(sysPath.dirname(dir));
|
||||
const tracked = parentDir.has(sysPath.basename(dir));
|
||||
if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
|
||||
this.fsw._emit(EV.ADD_DIR, dir, stats);
|
||||
}
|
||||
// ensure dir is tracked (harmless if redundant)
|
||||
parentDir.add(sysPath.basename(dir));
|
||||
this.fsw._getWatchedDir(dir);
|
||||
let throttler;
|
||||
let closer;
|
||||
const oDepth = this.fsw.options.depth;
|
||||
if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath)) {
|
||||
if (!target) {
|
||||
await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler);
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
}
|
||||
closer = this._watchWithNodeFs(dir, (dirPath, stats) => {
|
||||
// if current directory is removed, do nothing
|
||||
if (stats && stats.mtimeMs === 0)
|
||||
return;
|
||||
this._handleRead(dirPath, false, wh, target, dir, depth, throttler);
|
||||
});
|
||||
}
|
||||
return closer;
|
||||
}
|
||||
/**
|
||||
* Handle added file, directory, or glob pattern.
|
||||
* Delegates call to _handleFile / _handleDir after checks.
|
||||
* @param path to file or ir
|
||||
* @param initialAdd was the file added at watch instantiation?
|
||||
* @param priorWh depth relative to user-supplied path
|
||||
* @param depth Child path actually targeted for watch
|
||||
* @param target Child path actually targeted for watch
|
||||
*/
|
||||
async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
|
||||
const ready = this.fsw._emitReady;
|
||||
if (this.fsw._isIgnored(path) || this.fsw.closed) {
|
||||
ready();
|
||||
return false;
|
||||
}
|
||||
const wh = this.fsw._getWatchHelpers(path);
|
||||
if (priorWh) {
|
||||
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
||||
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
||||
}
|
||||
// evaluate what is at the path we're being asked to watch
|
||||
try {
|
||||
const stats = await statMethods[wh.statMethod](wh.watchPath);
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
if (this.fsw._isIgnored(wh.watchPath, stats)) {
|
||||
ready();
|
||||
return false;
|
||||
}
|
||||
const follow = this.fsw.options.followSymlinks;
|
||||
let closer;
|
||||
if (stats.isDirectory()) {
|
||||
const absPath = sysPath.resolve(path);
|
||||
const targetPath = follow ? await (0, promises_1.realpath)(path) : path;
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
// preserve this symlink's target path
|
||||
if (absPath !== targetPath && targetPath !== undefined) {
|
||||
this.fsw._symlinkPaths.set(absPath, targetPath);
|
||||
}
|
||||
}
|
||||
else if (stats.isSymbolicLink()) {
|
||||
const targetPath = follow ? await (0, promises_1.realpath)(path) : path;
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
const parent = sysPath.dirname(wh.watchPath);
|
||||
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
||||
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
||||
closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);
|
||||
if (this.fsw.closed)
|
||||
return;
|
||||
// preserve this symlink's target path
|
||||
if (targetPath !== undefined) {
|
||||
this.fsw._symlinkPaths.set(sysPath.resolve(path), targetPath);
|
||||
}
|
||||
}
|
||||
else {
|
||||
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
||||
}
|
||||
ready();
|
||||
if (closer)
|
||||
this.fsw._addPathCloser(path, closer);
|
||||
return false;
|
||||
}
|
||||
catch (error) {
|
||||
if (this.fsw._handleError(error)) {
|
||||
ready();
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.NodeFsHandler = NodeFsHandler;
|
||||
215
node_modules/sass/node_modules/chokidar/index.d.ts
generated
vendored
Normal file
215
node_modules/sass/node_modules/chokidar/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,215 @@
|
||||
/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
|
||||
import { Stats } from 'fs';
|
||||
import { EventEmitter } from 'events';
|
||||
import { ReaddirpStream, ReaddirpOptions, EntryInfo } from 'readdirp';
|
||||
import { NodeFsHandler, EventName, Path, EVENTS as EV, WatchHandlers } from './handler.js';
|
||||
type AWF = {
|
||||
stabilityThreshold: number;
|
||||
pollInterval: number;
|
||||
};
|
||||
type BasicOpts = {
|
||||
persistent: boolean;
|
||||
ignoreInitial: boolean;
|
||||
followSymlinks: boolean;
|
||||
cwd?: string;
|
||||
usePolling: boolean;
|
||||
interval: number;
|
||||
binaryInterval: number;
|
||||
alwaysStat?: boolean;
|
||||
depth?: number;
|
||||
ignorePermissionErrors: boolean;
|
||||
atomic: boolean | number;
|
||||
};
|
||||
export type Throttler = {
|
||||
timeoutObject: NodeJS.Timeout;
|
||||
clear: () => void;
|
||||
count: number;
|
||||
};
|
||||
export type ChokidarOptions = Partial<BasicOpts & {
|
||||
ignored: Matcher | Matcher[];
|
||||
awaitWriteFinish: boolean | Partial<AWF>;
|
||||
}>;
|
||||
export type FSWInstanceOptions = BasicOpts & {
|
||||
ignored: Matcher[];
|
||||
awaitWriteFinish: false | AWF;
|
||||
};
|
||||
export type ThrottleType = 'readdir' | 'watch' | 'add' | 'remove' | 'change';
|
||||
export type EmitArgs = [path: Path, stats?: Stats];
|
||||
export type EmitErrorArgs = [error: Error, stats?: Stats];
|
||||
export type EmitArgsWithName = [event: EventName, ...EmitArgs];
|
||||
export type MatchFunction = (val: string, stats?: Stats) => boolean;
|
||||
export interface MatcherObject {
|
||||
path: string;
|
||||
recursive?: boolean;
|
||||
}
|
||||
export type Matcher = string | RegExp | MatchFunction | MatcherObject;
|
||||
/**
|
||||
* Directory entry.
|
||||
*/
|
||||
declare class DirEntry {
|
||||
path: Path;
|
||||
_removeWatcher: (dir: string, base: string) => void;
|
||||
items: Set<Path>;
|
||||
constructor(dir: Path, removeWatcher: (dir: string, base: string) => void);
|
||||
add(item: string): void;
|
||||
remove(item: string): Promise<void>;
|
||||
has(item: string): boolean | undefined;
|
||||
getChildren(): string[];
|
||||
dispose(): void;
|
||||
}
|
||||
export declare class WatchHelper {
|
||||
fsw: FSWatcher;
|
||||
path: string;
|
||||
watchPath: string;
|
||||
fullWatchPath: string;
|
||||
dirParts: string[][];
|
||||
followSymlinks: boolean;
|
||||
statMethod: 'stat' | 'lstat';
|
||||
constructor(path: string, follow: boolean, fsw: FSWatcher);
|
||||
entryPath(entry: EntryInfo): Path;
|
||||
filterPath(entry: EntryInfo): boolean;
|
||||
filterDir(entry: EntryInfo): boolean;
|
||||
}
|
||||
export interface FSWatcherKnownEventMap {
|
||||
[EV.READY]: [];
|
||||
[EV.RAW]: Parameters<WatchHandlers['rawEmitter']>;
|
||||
[EV.ERROR]: Parameters<WatchHandlers['errHandler']>;
|
||||
[EV.ALL]: [event: EventName, ...EmitArgs];
|
||||
}
|
||||
export type FSWatcherEventMap = FSWatcherKnownEventMap & {
|
||||
[k in Exclude<EventName, keyof FSWatcherKnownEventMap>]: EmitArgs;
|
||||
};
|
||||
/**
|
||||
* Watches files & directories for changes. Emitted events:
|
||||
* `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error`
|
||||
*
|
||||
* new FSWatcher()
|
||||
* .add(directories)
|
||||
* .on('add', path => log('File', path, 'was added'))
|
||||
*/
|
||||
export declare class FSWatcher extends EventEmitter<FSWatcherEventMap> {
|
||||
closed: boolean;
|
||||
options: FSWInstanceOptions;
|
||||
_closers: Map<string, Array<any>>;
|
||||
_ignoredPaths: Set<Matcher>;
|
||||
_throttled: Map<ThrottleType, Map<any, any>>;
|
||||
_streams: Set<ReaddirpStream>;
|
||||
_symlinkPaths: Map<Path, string | boolean>;
|
||||
_watched: Map<string, DirEntry>;
|
||||
_pendingWrites: Map<string, any>;
|
||||
_pendingUnlinks: Map<string, EmitArgsWithName>;
|
||||
_readyCount: number;
|
||||
_emitReady: () => void;
|
||||
_closePromise?: Promise<void>;
|
||||
_userIgnored?: MatchFunction;
|
||||
_readyEmitted: boolean;
|
||||
_emitRaw: WatchHandlers['rawEmitter'];
|
||||
_boundRemove: (dir: string, item: string) => void;
|
||||
_nodeFsHandler: NodeFsHandler;
|
||||
constructor(_opts?: ChokidarOptions);
|
||||
_addIgnoredPath(matcher: Matcher): void;
|
||||
_removeIgnoredPath(matcher: Matcher): void;
|
||||
/**
|
||||
* Adds paths to be watched on an existing FSWatcher instance.
|
||||
* @param paths_ file or file list. Other arguments are unused
|
||||
*/
|
||||
add(paths_: Path | Path[], _origAdd?: string, _internal?: boolean): FSWatcher;
|
||||
/**
|
||||
* Close watchers or start ignoring events from specified paths.
|
||||
*/
|
||||
unwatch(paths_: Path | Path[]): FSWatcher;
|
||||
/**
|
||||
* Close watchers and remove all listeners from watched paths.
|
||||
*/
|
||||
close(): Promise<void>;
|
||||
/**
|
||||
* Expose list of watched paths
|
||||
* @returns for chaining
|
||||
*/
|
||||
getWatched(): Record<string, string[]>;
|
||||
emitWithAll(event: EventName, args: EmitArgs): void;
|
||||
/**
|
||||
* Normalize and emit events.
|
||||
* Calling _emit DOES NOT MEAN emit() would be called!
|
||||
* @param event Type of event
|
||||
* @param path File or directory path
|
||||
* @param stats arguments to be passed with event
|
||||
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
||||
*/
|
||||
_emit(event: EventName, path: Path, stats?: Stats): Promise<this | undefined>;
|
||||
/**
|
||||
* Common handler for errors
|
||||
* @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
||||
*/
|
||||
_handleError(error: Error): Error | boolean;
|
||||
/**
|
||||
* Helper utility for throttling
|
||||
* @param actionType type being throttled
|
||||
* @param path being acted upon
|
||||
* @param timeout duration of time to suppress duplicate actions
|
||||
* @returns tracking object or false if action should be suppressed
|
||||
*/
|
||||
_throttle(actionType: ThrottleType, path: Path, timeout: number): Throttler | false;
|
||||
_incrReadyCount(): number;
|
||||
/**
|
||||
* Awaits write operation to finish.
|
||||
* Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.
|
||||
* @param path being acted upon
|
||||
* @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished
|
||||
* @param event
|
||||
* @param awfEmit Callback to be called when ready for event to be emitted.
|
||||
*/
|
||||
_awaitWriteFinish(path: Path, threshold: number, event: EventName, awfEmit: (err?: Error, stat?: Stats) => void): void;
|
||||
/**
|
||||
* Determines whether user has asked to ignore this path.
|
||||
*/
|
||||
_isIgnored(path: Path, stats?: Stats): boolean;
|
||||
_isntIgnored(path: Path, stat?: Stats): boolean;
|
||||
/**
|
||||
* Provides a set of common helpers and properties relating to symlink handling.
|
||||
* @param path file or directory pattern being watched
|
||||
*/
|
||||
_getWatchHelpers(path: Path): WatchHelper;
|
||||
/**
|
||||
* Provides directory tracking objects
|
||||
* @param directory path of the directory
|
||||
*/
|
||||
_getWatchedDir(directory: string): DirEntry;
|
||||
/**
|
||||
* Check for read permissions: https://stackoverflow.com/a/11781404/1358405
|
||||
*/
|
||||
_hasReadPermissions(stats: Stats): boolean;
|
||||
/**
|
||||
* Handles emitting unlink events for
|
||||
* files and directories, and via recursion, for
|
||||
* files and directories within directories that are unlinked
|
||||
* @param directory within which the following item is located
|
||||
* @param item base path of item/directory
|
||||
*/
|
||||
_remove(directory: string, item: string, isDirectory?: boolean): void;
|
||||
/**
|
||||
* Closes all watchers for a path
|
||||
*/
|
||||
_closePath(path: Path): void;
|
||||
/**
|
||||
* Closes only file-specific watchers
|
||||
*/
|
||||
_closeFile(path: Path): void;
|
||||
_addPathCloser(path: Path, closer: () => void): void;
|
||||
_readdirp(root: Path, opts?: Partial<ReaddirpOptions>): ReaddirpStream | undefined;
|
||||
}
|
||||
/**
|
||||
* Instantiates watcher with paths to be tracked.
|
||||
* @param paths file / directory paths
|
||||
* @param options opts, such as `atomic`, `awaitWriteFinish`, `ignored`, and others
|
||||
* @returns an instance of FSWatcher for chaining.
|
||||
* @example
|
||||
* const watcher = watch('.').on('all', (event, path) => { console.log(event, path); });
|
||||
* watch('.', { atomic: true, awaitWriteFinish: true, ignored: (f, stats) => stats?.isFile() && !f.endsWith('.js') })
|
||||
*/
|
||||
export declare function watch(paths: string | string[], options?: ChokidarOptions): FSWatcher;
|
||||
declare const _default: {
|
||||
watch: typeof watch;
|
||||
FSWatcher: typeof FSWatcher;
|
||||
};
|
||||
export default _default;
|
||||
804
node_modules/sass/node_modules/chokidar/index.js
generated
vendored
Normal file
804
node_modules/sass/node_modules/chokidar/index.js
generated
vendored
Normal file
@@ -0,0 +1,804 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FSWatcher = exports.WatchHelper = void 0;
|
||||
exports.watch = watch;
|
||||
/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
|
||||
const fs_1 = require("fs");
|
||||
const promises_1 = require("fs/promises");
|
||||
const events_1 = require("events");
|
||||
const sysPath = require("path");
|
||||
const readdirp_1 = require("readdirp");
|
||||
const handler_js_1 = require("./handler.js");
|
||||
const SLASH = '/';
|
||||
const SLASH_SLASH = '//';
|
||||
const ONE_DOT = '.';
|
||||
const TWO_DOTS = '..';
|
||||
const STRING_TYPE = 'string';
|
||||
const BACK_SLASH_RE = /\\/g;
|
||||
const DOUBLE_SLASH_RE = /\/\//;
|
||||
const DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
|
||||
const REPLACER_RE = /^\.[/\\]/;
|
||||
function arrify(item) {
|
||||
return Array.isArray(item) ? item : [item];
|
||||
}
|
||||
const isMatcherObject = (matcher) => typeof matcher === 'object' && matcher !== null && !(matcher instanceof RegExp);
|
||||
function createPattern(matcher) {
|
||||
if (typeof matcher === 'function')
|
||||
return matcher;
|
||||
if (typeof matcher === 'string')
|
||||
return (string) => matcher === string;
|
||||
if (matcher instanceof RegExp)
|
||||
return (string) => matcher.test(string);
|
||||
if (typeof matcher === 'object' && matcher !== null) {
|
||||
return (string) => {
|
||||
if (matcher.path === string)
|
||||
return true;
|
||||
if (matcher.recursive) {
|
||||
const relative = sysPath.relative(matcher.path, string);
|
||||
if (!relative) {
|
||||
return false;
|
||||
}
|
||||
return !relative.startsWith('..') && !sysPath.isAbsolute(relative);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
return () => false;
|
||||
}
|
||||
function normalizePath(path) {
|
||||
if (typeof path !== 'string')
|
||||
throw new Error('string expected');
|
||||
path = sysPath.normalize(path);
|
||||
path = path.replace(/\\/g, '/');
|
||||
let prepend = false;
|
||||
if (path.startsWith('//'))
|
||||
prepend = true;
|
||||
const DOUBLE_SLASH_RE = /\/\//;
|
||||
while (path.match(DOUBLE_SLASH_RE))
|
||||
path = path.replace(DOUBLE_SLASH_RE, '/');
|
||||
if (prepend)
|
||||
path = '/' + path;
|
||||
return path;
|
||||
}
|
||||
function matchPatterns(patterns, testString, stats) {
|
||||
const path = normalizePath(testString);
|
||||
for (let index = 0; index < patterns.length; index++) {
|
||||
const pattern = patterns[index];
|
||||
if (pattern(path, stats)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function anymatch(matchers, testString) {
|
||||
if (matchers == null) {
|
||||
throw new TypeError('anymatch: specify first argument');
|
||||
}
|
||||
// Early cache for matchers.
|
||||
const matchersArray = arrify(matchers);
|
||||
const patterns = matchersArray.map((matcher) => createPattern(matcher));
|
||||
if (testString == null) {
|
||||
return (testString, stats) => {
|
||||
return matchPatterns(patterns, testString, stats);
|
||||
};
|
||||
}
|
||||
return matchPatterns(patterns, testString);
|
||||
}
|
||||
const unifyPaths = (paths_) => {
|
||||
const paths = arrify(paths_).flat();
|
||||
if (!paths.every((p) => typeof p === STRING_TYPE)) {
|
||||
throw new TypeError(`Non-string provided as watch path: ${paths}`);
|
||||
}
|
||||
return paths.map(normalizePathToUnix);
|
||||
};
|
||||
// If SLASH_SLASH occurs at the beginning of path, it is not replaced
|
||||
// because "//StoragePC/DrivePool/Movies" is a valid network path
|
||||
const toUnix = (string) => {
|
||||
let str = string.replace(BACK_SLASH_RE, SLASH);
|
||||
let prepend = false;
|
||||
if (str.startsWith(SLASH_SLASH)) {
|
||||
prepend = true;
|
||||
}
|
||||
while (str.match(DOUBLE_SLASH_RE)) {
|
||||
str = str.replace(DOUBLE_SLASH_RE, SLASH);
|
||||
}
|
||||
if (prepend) {
|
||||
str = SLASH + str;
|
||||
}
|
||||
return str;
|
||||
};
|
||||
// Our version of upath.normalize
|
||||
// TODO: this is not equal to path-normalize module - investigate why
|
||||
const normalizePathToUnix = (path) => toUnix(sysPath.normalize(toUnix(path)));
|
||||
// TODO: refactor
|
||||
const normalizeIgnored = (cwd = '') => (path) => {
|
||||
if (typeof path === 'string') {
|
||||
return normalizePathToUnix(sysPath.isAbsolute(path) ? path : sysPath.join(cwd, path));
|
||||
}
|
||||
else {
|
||||
return path;
|
||||
}
|
||||
};
|
||||
const getAbsolutePath = (path, cwd) => {
|
||||
if (sysPath.isAbsolute(path)) {
|
||||
return path;
|
||||
}
|
||||
return sysPath.join(cwd, path);
|
||||
};
|
||||
const EMPTY_SET = Object.freeze(new Set());
|
||||
/**
|
||||
* Directory entry.
|
||||
*/
|
||||
class DirEntry {
|
||||
constructor(dir, removeWatcher) {
|
||||
this.path = dir;
|
||||
this._removeWatcher = removeWatcher;
|
||||
this.items = new Set();
|
||||
}
|
||||
add(item) {
|
||||
const { items } = this;
|
||||
if (!items)
|
||||
return;
|
||||
if (item !== ONE_DOT && item !== TWO_DOTS)
|
||||
items.add(item);
|
||||
}
|
||||
async remove(item) {
|
||||
const { items } = this;
|
||||
if (!items)
|
||||
return;
|
||||
items.delete(item);
|
||||
if (items.size > 0)
|
||||
return;
|
||||
const dir = this.path;
|
||||
try {
|
||||
await (0, promises_1.readdir)(dir);
|
||||
}
|
||||
catch (err) {
|
||||
if (this._removeWatcher) {
|
||||
this._removeWatcher(sysPath.dirname(dir), sysPath.basename(dir));
|
||||
}
|
||||
}
|
||||
}
|
||||
has(item) {
|
||||
const { items } = this;
|
||||
if (!items)
|
||||
return;
|
||||
return items.has(item);
|
||||
}
|
||||
getChildren() {
|
||||
const { items } = this;
|
||||
if (!items)
|
||||
return [];
|
||||
return [...items.values()];
|
||||
}
|
||||
dispose() {
|
||||
this.items.clear();
|
||||
this.path = '';
|
||||
this._removeWatcher = handler_js_1.EMPTY_FN;
|
||||
this.items = EMPTY_SET;
|
||||
Object.freeze(this);
|
||||
}
|
||||
}
|
||||
const STAT_METHOD_F = 'stat';
|
||||
const STAT_METHOD_L = 'lstat';
|
||||
class WatchHelper {
|
||||
constructor(path, follow, fsw) {
|
||||
this.fsw = fsw;
|
||||
const watchPath = path;
|
||||
this.path = path = path.replace(REPLACER_RE, '');
|
||||
this.watchPath = watchPath;
|
||||
this.fullWatchPath = sysPath.resolve(watchPath);
|
||||
this.dirParts = [];
|
||||
this.dirParts.forEach((parts) => {
|
||||
if (parts.length > 1)
|
||||
parts.pop();
|
||||
});
|
||||
this.followSymlinks = follow;
|
||||
this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
|
||||
}
|
||||
entryPath(entry) {
|
||||
return sysPath.join(this.watchPath, sysPath.relative(this.watchPath, entry.fullPath));
|
||||
}
|
||||
filterPath(entry) {
|
||||
const { stats } = entry;
|
||||
if (stats && stats.isSymbolicLink())
|
||||
return this.filterDir(entry);
|
||||
const resolvedPath = this.entryPath(entry);
|
||||
// TODO: what if stats is undefined? remove !
|
||||
return this.fsw._isntIgnored(resolvedPath, stats) && this.fsw._hasReadPermissions(stats);
|
||||
}
|
||||
filterDir(entry) {
|
||||
return this.fsw._isntIgnored(this.entryPath(entry), entry.stats);
|
||||
}
|
||||
}
|
||||
exports.WatchHelper = WatchHelper;
|
||||
/**
|
||||
* Watches files & directories for changes. Emitted events:
|
||||
* `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error`
|
||||
*
|
||||
* new FSWatcher()
|
||||
* .add(directories)
|
||||
* .on('add', path => log('File', path, 'was added'))
|
||||
*/
|
||||
class FSWatcher extends events_1.EventEmitter {
|
||||
// Not indenting methods for history sake; for now.
|
||||
constructor(_opts = {}) {
|
||||
super();
|
||||
this.closed = false;
|
||||
this._closers = new Map();
|
||||
this._ignoredPaths = new Set();
|
||||
this._throttled = new Map();
|
||||
this._streams = new Set();
|
||||
this._symlinkPaths = new Map();
|
||||
this._watched = new Map();
|
||||
this._pendingWrites = new Map();
|
||||
this._pendingUnlinks = new Map();
|
||||
this._readyCount = 0;
|
||||
this._readyEmitted = false;
|
||||
const awf = _opts.awaitWriteFinish;
|
||||
const DEF_AWF = { stabilityThreshold: 2000, pollInterval: 100 };
|
||||
const opts = {
|
||||
// Defaults
|
||||
persistent: true,
|
||||
ignoreInitial: false,
|
||||
ignorePermissionErrors: false,
|
||||
interval: 100,
|
||||
binaryInterval: 300,
|
||||
followSymlinks: true,
|
||||
usePolling: false,
|
||||
// useAsync: false,
|
||||
atomic: true, // NOTE: overwritten later (depends on usePolling)
|
||||
..._opts,
|
||||
// Change format
|
||||
ignored: _opts.ignored ? arrify(_opts.ignored) : arrify([]),
|
||||
awaitWriteFinish: awf === true ? DEF_AWF : typeof awf === 'object' ? { ...DEF_AWF, ...awf } : false,
|
||||
};
|
||||
// Always default to polling on IBM i because fs.watch() is not available on IBM i.
|
||||
if (handler_js_1.isIBMi)
|
||||
opts.usePolling = true;
|
||||
// Editor atomic write normalization enabled by default with fs.watch
|
||||
if (opts.atomic === undefined)
|
||||
opts.atomic = !opts.usePolling;
|
||||
// opts.atomic = typeof _opts.atomic === 'number' ? _opts.atomic : 100;
|
||||
// Global override. Useful for developers, who need to force polling for all
|
||||
// instances of chokidar, regardless of usage / dependency depth
|
||||
const envPoll = process.env.CHOKIDAR_USEPOLLING;
|
||||
if (envPoll !== undefined) {
|
||||
const envLower = envPoll.toLowerCase();
|
||||
if (envLower === 'false' || envLower === '0')
|
||||
opts.usePolling = false;
|
||||
else if (envLower === 'true' || envLower === '1')
|
||||
opts.usePolling = true;
|
||||
else
|
||||
opts.usePolling = !!envLower;
|
||||
}
|
||||
const envInterval = process.env.CHOKIDAR_INTERVAL;
|
||||
if (envInterval)
|
||||
opts.interval = Number.parseInt(envInterval, 10);
|
||||
// This is done to emit ready only once, but each 'add' will increase that?
|
||||
let readyCalls = 0;
|
||||
this._emitReady = () => {
|
||||
readyCalls++;
|
||||
if (readyCalls >= this._readyCount) {
|
||||
this._emitReady = handler_js_1.EMPTY_FN;
|
||||
this._readyEmitted = true;
|
||||
// use process.nextTick to allow time for listener to be bound
|
||||
process.nextTick(() => this.emit(handler_js_1.EVENTS.READY));
|
||||
}
|
||||
};
|
||||
this._emitRaw = (...args) => this.emit(handler_js_1.EVENTS.RAW, ...args);
|
||||
this._boundRemove = this._remove.bind(this);
|
||||
this.options = opts;
|
||||
this._nodeFsHandler = new handler_js_1.NodeFsHandler(this);
|
||||
// You’re frozen when your heart’s not open.
|
||||
Object.freeze(opts);
|
||||
}
|
||||
_addIgnoredPath(matcher) {
|
||||
if (isMatcherObject(matcher)) {
|
||||
// return early if we already have a deeply equal matcher object
|
||||
for (const ignored of this._ignoredPaths) {
|
||||
if (isMatcherObject(ignored) &&
|
||||
ignored.path === matcher.path &&
|
||||
ignored.recursive === matcher.recursive) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._ignoredPaths.add(matcher);
|
||||
}
|
||||
_removeIgnoredPath(matcher) {
|
||||
this._ignoredPaths.delete(matcher);
|
||||
// now find any matcher objects with the matcher as path
|
||||
if (typeof matcher === 'string') {
|
||||
for (const ignored of this._ignoredPaths) {
|
||||
// TODO (43081j): make this more efficient.
|
||||
// probably just make a `this._ignoredDirectories` or some
|
||||
// such thing.
|
||||
if (isMatcherObject(ignored) && ignored.path === matcher) {
|
||||
this._ignoredPaths.delete(ignored);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Public methods
|
||||
/**
|
||||
* Adds paths to be watched on an existing FSWatcher instance.
|
||||
* @param paths_ file or file list. Other arguments are unused
|
||||
*/
|
||||
add(paths_, _origAdd, _internal) {
|
||||
const { cwd } = this.options;
|
||||
this.closed = false;
|
||||
this._closePromise = undefined;
|
||||
let paths = unifyPaths(paths_);
|
||||
if (cwd) {
|
||||
paths = paths.map((path) => {
|
||||
const absPath = getAbsolutePath(path, cwd);
|
||||
// Check `path` instead of `absPath` because the cwd portion can't be a glob
|
||||
return absPath;
|
||||
});
|
||||
}
|
||||
paths.forEach((path) => {
|
||||
this._removeIgnoredPath(path);
|
||||
});
|
||||
this._userIgnored = undefined;
|
||||
if (!this._readyCount)
|
||||
this._readyCount = 0;
|
||||
this._readyCount += paths.length;
|
||||
Promise.all(paths.map(async (path) => {
|
||||
const res = await this._nodeFsHandler._addToNodeFs(path, !_internal, undefined, 0, _origAdd);
|
||||
if (res)
|
||||
this._emitReady();
|
||||
return res;
|
||||
})).then((results) => {
|
||||
if (this.closed)
|
||||
return;
|
||||
results.forEach((item) => {
|
||||
if (item)
|
||||
this.add(sysPath.dirname(item), sysPath.basename(_origAdd || item));
|
||||
});
|
||||
});
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Close watchers or start ignoring events from specified paths.
|
||||
*/
|
||||
unwatch(paths_) {
|
||||
if (this.closed)
|
||||
return this;
|
||||
const paths = unifyPaths(paths_);
|
||||
const { cwd } = this.options;
|
||||
paths.forEach((path) => {
|
||||
// convert to absolute path unless relative path already matches
|
||||
if (!sysPath.isAbsolute(path) && !this._closers.has(path)) {
|
||||
if (cwd)
|
||||
path = sysPath.join(cwd, path);
|
||||
path = sysPath.resolve(path);
|
||||
}
|
||||
this._closePath(path);
|
||||
this._addIgnoredPath(path);
|
||||
if (this._watched.has(path)) {
|
||||
this._addIgnoredPath({
|
||||
path,
|
||||
recursive: true,
|
||||
});
|
||||
}
|
||||
// reset the cached userIgnored anymatch fn
|
||||
// to make ignoredPaths changes effective
|
||||
this._userIgnored = undefined;
|
||||
});
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Close watchers and remove all listeners from watched paths.
|
||||
*/
|
||||
close() {
|
||||
if (this._closePromise) {
|
||||
return this._closePromise;
|
||||
}
|
||||
this.closed = true;
|
||||
// Memory management.
|
||||
this.removeAllListeners();
|
||||
const closers = [];
|
||||
this._closers.forEach((closerList) => closerList.forEach((closer) => {
|
||||
const promise = closer();
|
||||
if (promise instanceof Promise)
|
||||
closers.push(promise);
|
||||
}));
|
||||
this._streams.forEach((stream) => stream.destroy());
|
||||
this._userIgnored = undefined;
|
||||
this._readyCount = 0;
|
||||
this._readyEmitted = false;
|
||||
this._watched.forEach((dirent) => dirent.dispose());
|
||||
this._closers.clear();
|
||||
this._watched.clear();
|
||||
this._streams.clear();
|
||||
this._symlinkPaths.clear();
|
||||
this._throttled.clear();
|
||||
this._closePromise = closers.length
|
||||
? Promise.all(closers).then(() => undefined)
|
||||
: Promise.resolve();
|
||||
return this._closePromise;
|
||||
}
|
||||
/**
|
||||
* Expose list of watched paths
|
||||
* @returns for chaining
|
||||
*/
|
||||
getWatched() {
|
||||
const watchList = {};
|
||||
this._watched.forEach((entry, dir) => {
|
||||
const key = this.options.cwd ? sysPath.relative(this.options.cwd, dir) : dir;
|
||||
const index = key || ONE_DOT;
|
||||
watchList[index] = entry.getChildren().sort();
|
||||
});
|
||||
return watchList;
|
||||
}
|
||||
emitWithAll(event, args) {
|
||||
this.emit(event, ...args);
|
||||
if (event !== handler_js_1.EVENTS.ERROR)
|
||||
this.emit(handler_js_1.EVENTS.ALL, event, ...args);
|
||||
}
|
||||
// Common helpers
|
||||
// --------------
|
||||
/**
|
||||
* Normalize and emit events.
|
||||
* Calling _emit DOES NOT MEAN emit() would be called!
|
||||
* @param event Type of event
|
||||
* @param path File or directory path
|
||||
* @param stats arguments to be passed with event
|
||||
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
||||
*/
|
||||
async _emit(event, path, stats) {
|
||||
if (this.closed)
|
||||
return;
|
||||
const opts = this.options;
|
||||
if (handler_js_1.isWindows)
|
||||
path = sysPath.normalize(path);
|
||||
if (opts.cwd)
|
||||
path = sysPath.relative(opts.cwd, path);
|
||||
const args = [path];
|
||||
if (stats != null)
|
||||
args.push(stats);
|
||||
const awf = opts.awaitWriteFinish;
|
||||
let pw;
|
||||
if (awf && (pw = this._pendingWrites.get(path))) {
|
||||
pw.lastChange = new Date();
|
||||
return this;
|
||||
}
|
||||
if (opts.atomic) {
|
||||
if (event === handler_js_1.EVENTS.UNLINK) {
|
||||
this._pendingUnlinks.set(path, [event, ...args]);
|
||||
setTimeout(() => {
|
||||
this._pendingUnlinks.forEach((entry, path) => {
|
||||
this.emit(...entry);
|
||||
this.emit(handler_js_1.EVENTS.ALL, ...entry);
|
||||
this._pendingUnlinks.delete(path);
|
||||
});
|
||||
}, typeof opts.atomic === 'number' ? opts.atomic : 100);
|
||||
return this;
|
||||
}
|
||||
if (event === handler_js_1.EVENTS.ADD && this._pendingUnlinks.has(path)) {
|
||||
event = handler_js_1.EVENTS.CHANGE;
|
||||
this._pendingUnlinks.delete(path);
|
||||
}
|
||||
}
|
||||
if (awf && (event === handler_js_1.EVENTS.ADD || event === handler_js_1.EVENTS.CHANGE) && this._readyEmitted) {
|
||||
const awfEmit = (err, stats) => {
|
||||
if (err) {
|
||||
event = handler_js_1.EVENTS.ERROR;
|
||||
args[0] = err;
|
||||
this.emitWithAll(event, args);
|
||||
}
|
||||
else if (stats) {
|
||||
// if stats doesn't exist the file must have been deleted
|
||||
if (args.length > 1) {
|
||||
args[1] = stats;
|
||||
}
|
||||
else {
|
||||
args.push(stats);
|
||||
}
|
||||
this.emitWithAll(event, args);
|
||||
}
|
||||
};
|
||||
this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit);
|
||||
return this;
|
||||
}
|
||||
if (event === handler_js_1.EVENTS.CHANGE) {
|
||||
const isThrottled = !this._throttle(handler_js_1.EVENTS.CHANGE, path, 50);
|
||||
if (isThrottled)
|
||||
return this;
|
||||
}
|
||||
if (opts.alwaysStat &&
|
||||
stats === undefined &&
|
||||
(event === handler_js_1.EVENTS.ADD || event === handler_js_1.EVENTS.ADD_DIR || event === handler_js_1.EVENTS.CHANGE)) {
|
||||
const fullPath = opts.cwd ? sysPath.join(opts.cwd, path) : path;
|
||||
let stats;
|
||||
try {
|
||||
stats = await (0, promises_1.stat)(fullPath);
|
||||
}
|
||||
catch (err) {
|
||||
// do nothing
|
||||
}
|
||||
// Suppress event when fs_stat fails, to avoid sending undefined 'stat'
|
||||
if (!stats || this.closed)
|
||||
return;
|
||||
args.push(stats);
|
||||
}
|
||||
this.emitWithAll(event, args);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Common handler for errors
|
||||
* @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
||||
*/
|
||||
_handleError(error) {
|
||||
const code = error && error.code;
|
||||
if (error &&
|
||||
code !== 'ENOENT' &&
|
||||
code !== 'ENOTDIR' &&
|
||||
(!this.options.ignorePermissionErrors || (code !== 'EPERM' && code !== 'EACCES'))) {
|
||||
this.emit(handler_js_1.EVENTS.ERROR, error);
|
||||
}
|
||||
return error || this.closed;
|
||||
}
|
||||
/**
|
||||
* Helper utility for throttling
|
||||
* @param actionType type being throttled
|
||||
* @param path being acted upon
|
||||
* @param timeout duration of time to suppress duplicate actions
|
||||
* @returns tracking object or false if action should be suppressed
|
||||
*/
|
||||
_throttle(actionType, path, timeout) {
|
||||
if (!this._throttled.has(actionType)) {
|
||||
this._throttled.set(actionType, new Map());
|
||||
}
|
||||
const action = this._throttled.get(actionType);
|
||||
if (!action)
|
||||
throw new Error('invalid throttle');
|
||||
const actionPath = action.get(path);
|
||||
if (actionPath) {
|
||||
actionPath.count++;
|
||||
return false;
|
||||
}
|
||||
// eslint-disable-next-line prefer-const
|
||||
let timeoutObject;
|
||||
const clear = () => {
|
||||
const item = action.get(path);
|
||||
const count = item ? item.count : 0;
|
||||
action.delete(path);
|
||||
clearTimeout(timeoutObject);
|
||||
if (item)
|
||||
clearTimeout(item.timeoutObject);
|
||||
return count;
|
||||
};
|
||||
timeoutObject = setTimeout(clear, timeout);
|
||||
const thr = { timeoutObject, clear, count: 0 };
|
||||
action.set(path, thr);
|
||||
return thr;
|
||||
}
|
||||
_incrReadyCount() {
|
||||
return this._readyCount++;
|
||||
}
|
||||
/**
|
||||
* Awaits write operation to finish.
|
||||
* Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.
|
||||
* @param path being acted upon
|
||||
* @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished
|
||||
* @param event
|
||||
* @param awfEmit Callback to be called when ready for event to be emitted.
|
||||
*/
|
||||
_awaitWriteFinish(path, threshold, event, awfEmit) {
|
||||
const awf = this.options.awaitWriteFinish;
|
||||
if (typeof awf !== 'object')
|
||||
return;
|
||||
const pollInterval = awf.pollInterval;
|
||||
let timeoutHandler;
|
||||
let fullPath = path;
|
||||
if (this.options.cwd && !sysPath.isAbsolute(path)) {
|
||||
fullPath = sysPath.join(this.options.cwd, path);
|
||||
}
|
||||
const now = new Date();
|
||||
const writes = this._pendingWrites;
|
||||
function awaitWriteFinishFn(prevStat) {
|
||||
(0, fs_1.stat)(fullPath, (err, curStat) => {
|
||||
if (err || !writes.has(path)) {
|
||||
if (err && err.code !== 'ENOENT')
|
||||
awfEmit(err);
|
||||
return;
|
||||
}
|
||||
const now = Number(new Date());
|
||||
if (prevStat && curStat.size !== prevStat.size) {
|
||||
writes.get(path).lastChange = now;
|
||||
}
|
||||
const pw = writes.get(path);
|
||||
const df = now - pw.lastChange;
|
||||
if (df >= threshold) {
|
||||
writes.delete(path);
|
||||
awfEmit(undefined, curStat);
|
||||
}
|
||||
else {
|
||||
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!writes.has(path)) {
|
||||
writes.set(path, {
|
||||
lastChange: now,
|
||||
cancelWait: () => {
|
||||
writes.delete(path);
|
||||
clearTimeout(timeoutHandler);
|
||||
return event;
|
||||
},
|
||||
});
|
||||
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Determines whether user has asked to ignore this path.
|
||||
*/
|
||||
_isIgnored(path, stats) {
|
||||
if (this.options.atomic && DOT_RE.test(path))
|
||||
return true;
|
||||
if (!this._userIgnored) {
|
||||
const { cwd } = this.options;
|
||||
const ign = this.options.ignored;
|
||||
const ignored = (ign || []).map(normalizeIgnored(cwd));
|
||||
const ignoredPaths = [...this._ignoredPaths];
|
||||
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
||||
this._userIgnored = anymatch(list, undefined);
|
||||
}
|
||||
return this._userIgnored(path, stats);
|
||||
}
|
||||
_isntIgnored(path, stat) {
|
||||
return !this._isIgnored(path, stat);
|
||||
}
|
||||
/**
|
||||
* Provides a set of common helpers and properties relating to symlink handling.
|
||||
* @param path file or directory pattern being watched
|
||||
*/
|
||||
_getWatchHelpers(path) {
|
||||
return new WatchHelper(path, this.options.followSymlinks, this);
|
||||
}
|
||||
// Directory helpers
|
||||
// -----------------
|
||||
/**
|
||||
* Provides directory tracking objects
|
||||
* @param directory path of the directory
|
||||
*/
|
||||
_getWatchedDir(directory) {
|
||||
const dir = sysPath.resolve(directory);
|
||||
if (!this._watched.has(dir))
|
||||
this._watched.set(dir, new DirEntry(dir, this._boundRemove));
|
||||
return this._watched.get(dir);
|
||||
}
|
||||
// File helpers
|
||||
// ------------
|
||||
/**
|
||||
* Check for read permissions: https://stackoverflow.com/a/11781404/1358405
|
||||
*/
|
||||
_hasReadPermissions(stats) {
|
||||
if (this.options.ignorePermissionErrors)
|
||||
return true;
|
||||
return Boolean(Number(stats.mode) & 0o400);
|
||||
}
|
||||
/**
|
||||
* Handles emitting unlink events for
|
||||
* files and directories, and via recursion, for
|
||||
* files and directories within directories that are unlinked
|
||||
* @param directory within which the following item is located
|
||||
* @param item base path of item/directory
|
||||
*/
|
||||
_remove(directory, item, isDirectory) {
|
||||
// if what is being deleted is a directory, get that directory's paths
|
||||
// for recursive deleting and cleaning of watched object
|
||||
// if it is not a directory, nestedDirectoryChildren will be empty array
|
||||
const path = sysPath.join(directory, item);
|
||||
const fullPath = sysPath.resolve(path);
|
||||
isDirectory =
|
||||
isDirectory != null ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);
|
||||
// prevent duplicate handling in case of arriving here nearly simultaneously
|
||||
// via multiple paths (such as _handleFile and _handleDir)
|
||||
if (!this._throttle('remove', path, 100))
|
||||
return;
|
||||
// if the only watched file is removed, watch for its return
|
||||
if (!isDirectory && this._watched.size === 1) {
|
||||
this.add(directory, item, true);
|
||||
}
|
||||
// This will create a new entry in the watched object in either case
|
||||
// so we got to do the directory check beforehand
|
||||
const wp = this._getWatchedDir(path);
|
||||
const nestedDirectoryChildren = wp.getChildren();
|
||||
// Recursively remove children directories / files.
|
||||
nestedDirectoryChildren.forEach((nested) => this._remove(path, nested));
|
||||
// Check if item was on the watched list and remove it
|
||||
const parent = this._getWatchedDir(directory);
|
||||
const wasTracked = parent.has(item);
|
||||
parent.remove(item);
|
||||
// Fixes issue #1042 -> Relative paths were detected and added as symlinks
|
||||
// (https://github.com/paulmillr/chokidar/blob/e1753ddbc9571bdc33b4a4af172d52cb6e611c10/lib/nodefs-handler.js#L612),
|
||||
// but never removed from the map in case the path was deleted.
|
||||
// This leads to an incorrect state if the path was recreated:
|
||||
// https://github.com/paulmillr/chokidar/blob/e1753ddbc9571bdc33b4a4af172d52cb6e611c10/lib/nodefs-handler.js#L553
|
||||
if (this._symlinkPaths.has(fullPath)) {
|
||||
this._symlinkPaths.delete(fullPath);
|
||||
}
|
||||
// If we wait for this file to be fully written, cancel the wait.
|
||||
let relPath = path;
|
||||
if (this.options.cwd)
|
||||
relPath = sysPath.relative(this.options.cwd, path);
|
||||
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
||||
const event = this._pendingWrites.get(relPath).cancelWait();
|
||||
if (event === handler_js_1.EVENTS.ADD)
|
||||
return;
|
||||
}
|
||||
// The Entry will either be a directory that just got removed
|
||||
// or a bogus entry to a file, in either case we have to remove it
|
||||
this._watched.delete(path);
|
||||
this._watched.delete(fullPath);
|
||||
const eventName = isDirectory ? handler_js_1.EVENTS.UNLINK_DIR : handler_js_1.EVENTS.UNLINK;
|
||||
if (wasTracked && !this._isIgnored(path))
|
||||
this._emit(eventName, path);
|
||||
// Avoid conflicts if we later create another file with the same name
|
||||
this._closePath(path);
|
||||
}
|
||||
/**
|
||||
* Closes all watchers for a path
|
||||
*/
|
||||
_closePath(path) {
|
||||
this._closeFile(path);
|
||||
const dir = sysPath.dirname(path);
|
||||
this._getWatchedDir(dir).remove(sysPath.basename(path));
|
||||
}
|
||||
/**
|
||||
* Closes only file-specific watchers
|
||||
*/
|
||||
_closeFile(path) {
|
||||
const closers = this._closers.get(path);
|
||||
if (!closers)
|
||||
return;
|
||||
closers.forEach((closer) => closer());
|
||||
this._closers.delete(path);
|
||||
}
|
||||
_addPathCloser(path, closer) {
|
||||
if (!closer)
|
||||
return;
|
||||
let list = this._closers.get(path);
|
||||
if (!list) {
|
||||
list = [];
|
||||
this._closers.set(path, list);
|
||||
}
|
||||
list.push(closer);
|
||||
}
|
||||
_readdirp(root, opts) {
|
||||
if (this.closed)
|
||||
return;
|
||||
const options = { type: handler_js_1.EVENTS.ALL, alwaysStat: true, lstat: true, ...opts, depth: 0 };
|
||||
let stream = (0, readdirp_1.readdirp)(root, options);
|
||||
this._streams.add(stream);
|
||||
stream.once(handler_js_1.STR_CLOSE, () => {
|
||||
stream = undefined;
|
||||
});
|
||||
stream.once(handler_js_1.STR_END, () => {
|
||||
if (stream) {
|
||||
this._streams.delete(stream);
|
||||
stream = undefined;
|
||||
}
|
||||
});
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
exports.FSWatcher = FSWatcher;
|
||||
/**
|
||||
* Instantiates watcher with paths to be tracked.
|
||||
* @param paths file / directory paths
|
||||
* @param options opts, such as `atomic`, `awaitWriteFinish`, `ignored`, and others
|
||||
* @returns an instance of FSWatcher for chaining.
|
||||
* @example
|
||||
* const watcher = watch('.').on('all', (event, path) => { console.log(event, path); });
|
||||
* watch('.', { atomic: true, awaitWriteFinish: true, ignored: (f, stats) => stats?.isFile() && !f.endsWith('.js') })
|
||||
*/
|
||||
function watch(paths, options = {}) {
|
||||
const watcher = new FSWatcher(options);
|
||||
watcher.add(paths);
|
||||
return watcher;
|
||||
}
|
||||
exports.default = { watch, FSWatcher };
|
||||
69
node_modules/sass/node_modules/chokidar/package.json
generated
vendored
Normal file
69
node_modules/sass/node_modules/chokidar/package.json
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"name": "chokidar",
|
||||
"description": "Minimal and efficient cross-platform file watching library",
|
||||
"version": "4.0.3",
|
||||
"homepage": "https://github.com/paulmillr/chokidar",
|
||||
"author": "Paul Miller (https://paulmillr.com)",
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"handler.js",
|
||||
"handler.d.ts",
|
||||
"esm"
|
||||
],
|
||||
"main": "./index.js",
|
||||
"module": "./esm/index.js",
|
||||
"types": "./index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./esm/index.js",
|
||||
"require": "./index.js"
|
||||
},
|
||||
"./handler.js": {
|
||||
"import": "./esm/handler.js",
|
||||
"require": "./handler.js"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"readdirp": "^4.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@paulmillr/jsbt": "0.2.1",
|
||||
"@types/node": "20.14.8",
|
||||
"chai": "4.3.4",
|
||||
"prettier": "3.1.1",
|
||||
"rimraf": "5.0.5",
|
||||
"sinon": "12.0.1",
|
||||
"sinon-chai": "3.7.0",
|
||||
"typescript": "5.5.2",
|
||||
"upath": "2.0.1"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": ">= 14.16.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/paulmillr/chokidar.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/paulmillr/chokidar/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "tsc && tsc -p tsconfig.esm.json",
|
||||
"lint": "prettier --check src",
|
||||
"format": "prettier --write src",
|
||||
"test": "node --test"
|
||||
},
|
||||
"keywords": [
|
||||
"fs",
|
||||
"watch",
|
||||
"watchFile",
|
||||
"watcher",
|
||||
"watching",
|
||||
"file",
|
||||
"fsevents"
|
||||
],
|
||||
"funding": "https://paulmillr.com/funding/"
|
||||
}
|
||||
21
node_modules/sass/node_modules/readdirp/LICENSE
generated
vendored
Normal file
21
node_modules/sass/node_modules/readdirp/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2012-2019 Thorsten Lorenz, Paul Miller (https://paulmillr.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
120
node_modules/sass/node_modules/readdirp/README.md
generated
vendored
Normal file
120
node_modules/sass/node_modules/readdirp/README.md
generated
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
# readdirp [](https://github.com/paulmillr/readdirp)
|
||||
|
||||
Recursive version of fs.readdir. Exposes a **stream API** (with small RAM & CPU footprint) and a **promise API**.
|
||||
|
||||
```sh
|
||||
npm install readdirp
|
||||
jsr add jsr:@paulmillr/readdirp
|
||||
```
|
||||
|
||||
```javascript
|
||||
// Use streams to achieve small RAM & CPU footprint.
|
||||
// 1) Streams example with for-await.
|
||||
import readdirp from 'readdirp';
|
||||
for await (const entry of readdirp('.')) {
|
||||
const {path} = entry;
|
||||
console.log(`${JSON.stringify({path})}`);
|
||||
}
|
||||
|
||||
// 2) Streams example, non for-await.
|
||||
// Print out all JS files along with their size within the current folder & subfolders.
|
||||
import readdirp from 'readdirp';
|
||||
readdirp('.', {alwaysStat: true, fileFilter: (f) => f.basename.endsWith('.js')})
|
||||
.on('data', (entry) => {
|
||||
const {path, stats: {size}} = entry;
|
||||
console.log(`${JSON.stringify({path, size})}`);
|
||||
})
|
||||
// Optionally call stream.destroy() in `warn()` in order to abort and cause 'close' to be emitted
|
||||
.on('warn', error => console.error('non-fatal error', error))
|
||||
.on('error', error => console.error('fatal error', error))
|
||||
.on('end', () => console.log('done'));
|
||||
|
||||
// 3) Promise example. More RAM and CPU than streams / for-await.
|
||||
import { readdirpPromise } from 'readdirp';
|
||||
const files = await readdirpPromise('.');
|
||||
console.log(files.map(file => file.path));
|
||||
|
||||
// Other options.
|
||||
import readdirp from 'readdirp';
|
||||
readdirp('test', {
|
||||
fileFilter: (f) => f.basename.endsWith('.js'),
|
||||
directoryFilter: (d) => d.basename !== '.git',
|
||||
// directoryFilter: (di) => di.basename.length === 9
|
||||
type: 'files_directories',
|
||||
depth: 1
|
||||
});
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
`const stream = readdirp(root[, options])` — **Stream API**
|
||||
|
||||
- Reads given root recursively and returns a `stream` of [entry infos](#entryinfo)
|
||||
- Optionally can be used like `for await (const entry of stream)` with node.js 10+ (`asyncIterator`).
|
||||
- `on('data', (entry) => {})` [entry info](#entryinfo) for every file / dir.
|
||||
- `on('warn', (error) => {})` non-fatal `Error` that prevents a file / dir from being processed. Example: inaccessible to the user.
|
||||
- `on('error', (error) => {})` fatal `Error` which also ends the stream. Example: illegal options where passed.
|
||||
- `on('end')` — we are done. Called when all entries were found and no more will be emitted.
|
||||
- `on('close')` — stream is destroyed via `stream.destroy()`.
|
||||
Could be useful if you want to manually abort even on a non fatal error.
|
||||
At that point the stream is no longer `readable` and no more entries, warning or errors are emitted
|
||||
- To learn more about streams, consult the very detailed [nodejs streams documentation](https://nodejs.org/api/stream.html)
|
||||
or the [stream-handbook](https://github.com/substack/stream-handbook)
|
||||
|
||||
`const entries = await readdirp.promise(root[, options])` — **Promise API**. Returns a list of [entry infos](#entryinfo).
|
||||
|
||||
First argument is awalys `root`, path in which to start reading and recursing into subdirectories.
|
||||
|
||||
### options
|
||||
|
||||
- `fileFilter`: filter to include or exclude files
|
||||
- **Function**: a function that takes an entry info as a parameter and returns true to include or false to exclude the entry
|
||||
- `directoryFilter`: filter to include/exclude directories found and to recurse into. Directories that do not pass a filter will not be recursed into.
|
||||
- `depth: 5`: depth at which to stop recursing even if more subdirectories are found
|
||||
- `type: 'files'`: determines if data events on the stream should be emitted for `'files'` (default), `'directories'`, `'files_directories'`, or `'all'`. Setting to `'all'` will also include entries for other types of file descriptors like character devices, unix sockets and named pipes.
|
||||
- `alwaysStat: false`: always return `stats` property for every file. Default is `false`, readdirp will return `Dirent` entries. Setting it to `true` can double readdir execution time - use it only when you need file `size`, `mtime` etc. Cannot be enabled on node <10.10.0.
|
||||
- `lstat: false`: include symlink entries in the stream along with files. When `true`, `fs.lstat` would be used instead of `fs.stat`
|
||||
|
||||
### `EntryInfo`
|
||||
|
||||
Has the following properties:
|
||||
|
||||
- `path: 'assets/javascripts/react.js'`: path to the file/directory (relative to given root)
|
||||
- `fullPath: '/Users/dev/projects/app/assets/javascripts/react.js'`: full path to the file/directory found
|
||||
- `basename: 'react.js'`: name of the file/directory
|
||||
- `dirent: fs.Dirent`: built-in [dir entry object](https://nodejs.org/api/fs.html#fs_class_fs_dirent) - only with `alwaysStat: false`
|
||||
- `stats: fs.Stats`: built in [stat object](https://nodejs.org/api/fs.html#fs_class_fs_stats) - only with `alwaysStat: true`
|
||||
|
||||
## Changelog
|
||||
|
||||
- 4.0 (Aug 25, 2024) rewritten in typescript, producing hybrid common.js / esm module.
|
||||
- Remove glob support and all dependencies
|
||||
- Make sure you're using `let {readdirp} = require('readdirp')` in common.js
|
||||
- 3.5 (Oct 13, 2020) disallows recursive directory-based symlinks.
|
||||
Before, it could have entered infinite loop.
|
||||
- 3.4 (Mar 19, 2020) adds support for directory-based symlinks.
|
||||
- 3.3 (Dec 6, 2019) stabilizes RAM consumption and enables perf management with `highWaterMark` option. Fixes race conditions related to `for-await` looping.
|
||||
- 3.2 (Oct 14, 2019) improves performance by 250% and makes streams implementation more idiomatic.
|
||||
- 3.1 (Jul 7, 2019) brings `bigint` support to `stat` output on Windows. This is backwards-incompatible for some cases. Be careful. It you use it incorrectly, you'll see "TypeError: Cannot mix BigInt and other types, use explicit conversions".
|
||||
- 3.0 brings huge performance improvements and stream backpressure support.
|
||||
- Upgrading 2.x to 3.x:
|
||||
- Signature changed from `readdirp(options)` to `readdirp(root, options)`
|
||||
- Replaced callback API with promise API.
|
||||
- Renamed `entryType` option to `type`
|
||||
- Renamed `entryType: 'both'` to `'files_directories'`
|
||||
- `EntryInfo`
|
||||
- Renamed `stat` to `stats`
|
||||
- Emitted only when `alwaysStat: true`
|
||||
- `dirent` is emitted instead of `stats` by default with `alwaysStat: false`
|
||||
- Renamed `name` to `basename`
|
||||
- Removed `parentDir` and `fullParentDir` properties
|
||||
- Supported node.js versions:
|
||||
- 4.x: node 14+
|
||||
- 3.x: node 8+
|
||||
- 2.x: node 0.6+
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2012-2019 Thorsten Lorenz, Paul Miller (<https://paulmillr.com>)
|
||||
|
||||
MIT License, see [LICENSE](LICENSE) file.
|
||||
108
node_modules/sass/node_modules/readdirp/esm/index.d.ts
generated
vendored
Normal file
108
node_modules/sass/node_modules/readdirp/esm/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
/**
|
||||
* Recursive version of readdir. Exposes a streaming API and promise API.
|
||||
* Streaming API allows to use a small amount of RAM.
|
||||
*
|
||||
* @module
|
||||
* @example
|
||||
```js
|
||||
import readdirp from 'readdirp';
|
||||
for await (const entry of readdirp('.')) {
|
||||
const {path} = entry;
|
||||
console.log(`${JSON.stringify({path})}`);
|
||||
}
|
||||
```
|
||||
*/
|
||||
/*! readdirp - MIT License (c) 2012-2019 Thorsten Lorenz, Paul Miller (https://paulmillr.com) */
|
||||
import type { Stats, Dirent } from 'node:fs';
|
||||
import { Readable } from 'node:stream';
|
||||
/** Path in file system. */
|
||||
export type Path = string;
|
||||
/** Emitted entry. Contains relative & absolute path, basename, and either stats or dirent. */
|
||||
export interface EntryInfo {
|
||||
path: string;
|
||||
fullPath: string;
|
||||
stats?: Stats;
|
||||
dirent?: Dirent;
|
||||
basename: string;
|
||||
}
|
||||
/** Path or dir entries (files) */
|
||||
export type PathOrDirent = Dirent | Path;
|
||||
/** Filterer for files */
|
||||
export type Tester = (entryInfo: EntryInfo) => boolean;
|
||||
export type Predicate = string[] | string | Tester;
|
||||
export declare const EntryTypes: {
|
||||
readonly FILE_TYPE: "files";
|
||||
readonly DIR_TYPE: "directories";
|
||||
readonly FILE_DIR_TYPE: "files_directories";
|
||||
readonly EVERYTHING_TYPE: "all";
|
||||
};
|
||||
export type EntryType = (typeof EntryTypes)[keyof typeof EntryTypes];
|
||||
/**
|
||||
* Options for readdirp.
|
||||
* * type: files, directories, or both
|
||||
* * lstat: whether to use symlink-friendly stat
|
||||
* * depth: max depth
|
||||
* * alwaysStat: whether to use stat (more resources) or dirent
|
||||
* * highWaterMark: streaming param, specifies max amount of resources per entry
|
||||
*/
|
||||
export type ReaddirpOptions = {
|
||||
root: string;
|
||||
fileFilter?: Predicate;
|
||||
directoryFilter?: Predicate;
|
||||
type?: EntryType;
|
||||
lstat?: boolean;
|
||||
depth?: number;
|
||||
alwaysStat?: boolean;
|
||||
highWaterMark?: number;
|
||||
};
|
||||
/** Directory entry. Contains path, depth count, and files. */
|
||||
export interface DirEntry {
|
||||
files: PathOrDirent[];
|
||||
depth: number;
|
||||
path: Path;
|
||||
}
|
||||
/** Readable readdir stream, emitting new files as they're being listed. */
|
||||
export declare class ReaddirpStream extends Readable {
|
||||
parents: any[];
|
||||
reading: boolean;
|
||||
parent?: DirEntry;
|
||||
_stat: Function;
|
||||
_maxDepth: number;
|
||||
_wantsDir: boolean;
|
||||
_wantsFile: boolean;
|
||||
_wantsEverything: boolean;
|
||||
_root: Path;
|
||||
_isDirent: boolean;
|
||||
_statsProp: 'dirent' | 'stats';
|
||||
_rdOptions: {
|
||||
encoding: 'utf8';
|
||||
withFileTypes: boolean;
|
||||
};
|
||||
_fileFilter: Tester;
|
||||
_directoryFilter: Tester;
|
||||
constructor(options?: Partial<ReaddirpOptions>);
|
||||
_read(batch: number): Promise<void>;
|
||||
_exploreDir(path: Path, depth: number): Promise<{
|
||||
files: string[] | undefined;
|
||||
depth: number;
|
||||
path: string;
|
||||
}>;
|
||||
_formatEntry(dirent: PathOrDirent, path: Path): Promise<EntryInfo | undefined>;
|
||||
_onError(err: Error): void;
|
||||
_getEntryType(entry: EntryInfo): Promise<void | '' | 'file' | 'directory'>;
|
||||
_includeAsFile(entry: EntryInfo): boolean | undefined;
|
||||
}
|
||||
/**
|
||||
* Streaming version: Reads all files and directories in given root recursively.
|
||||
* Consumes ~constant small amount of RAM.
|
||||
* @param root Root directory
|
||||
* @param options Options to specify root (start directory), filters and recursion depth
|
||||
*/
|
||||
export declare function readdirp(root: Path, options?: Partial<ReaddirpOptions>): ReaddirpStream;
|
||||
/**
|
||||
* Promise version: Reads all files and directories in given root recursively.
|
||||
* Compared to streaming version, will consume a lot of RAM e.g. when 1 million files are listed.
|
||||
* @returns array of paths and their entry infos
|
||||
*/
|
||||
export declare function readdirpPromise(root: Path, options?: Partial<ReaddirpOptions>): Promise<EntryInfo[]>;
|
||||
export default readdirp;
|
||||
257
node_modules/sass/node_modules/readdirp/esm/index.js
generated
vendored
Normal file
257
node_modules/sass/node_modules/readdirp/esm/index.js
generated
vendored
Normal file
@@ -0,0 +1,257 @@
|
||||
import { stat, lstat, readdir, realpath } from 'node:fs/promises';
|
||||
import { Readable } from 'node:stream';
|
||||
import { resolve as presolve, relative as prelative, join as pjoin, sep as psep } from 'node:path';
|
||||
export const EntryTypes = {
|
||||
FILE_TYPE: 'files',
|
||||
DIR_TYPE: 'directories',
|
||||
FILE_DIR_TYPE: 'files_directories',
|
||||
EVERYTHING_TYPE: 'all',
|
||||
};
|
||||
const defaultOptions = {
|
||||
root: '.',
|
||||
fileFilter: (_entryInfo) => true,
|
||||
directoryFilter: (_entryInfo) => true,
|
||||
type: EntryTypes.FILE_TYPE,
|
||||
lstat: false,
|
||||
depth: 2147483648,
|
||||
alwaysStat: false,
|
||||
highWaterMark: 4096,
|
||||
};
|
||||
Object.freeze(defaultOptions);
|
||||
const RECURSIVE_ERROR_CODE = 'READDIRP_RECURSIVE_ERROR';
|
||||
const NORMAL_FLOW_ERRORS = new Set(['ENOENT', 'EPERM', 'EACCES', 'ELOOP', RECURSIVE_ERROR_CODE]);
|
||||
const ALL_TYPES = [
|
||||
EntryTypes.DIR_TYPE,
|
||||
EntryTypes.EVERYTHING_TYPE,
|
||||
EntryTypes.FILE_DIR_TYPE,
|
||||
EntryTypes.FILE_TYPE,
|
||||
];
|
||||
const DIR_TYPES = new Set([
|
||||
EntryTypes.DIR_TYPE,
|
||||
EntryTypes.EVERYTHING_TYPE,
|
||||
EntryTypes.FILE_DIR_TYPE,
|
||||
]);
|
||||
const FILE_TYPES = new Set([
|
||||
EntryTypes.EVERYTHING_TYPE,
|
||||
EntryTypes.FILE_DIR_TYPE,
|
||||
EntryTypes.FILE_TYPE,
|
||||
]);
|
||||
const isNormalFlowError = (error) => NORMAL_FLOW_ERRORS.has(error.code);
|
||||
const wantBigintFsStats = process.platform === 'win32';
|
||||
const emptyFn = (_entryInfo) => true;
|
||||
const normalizeFilter = (filter) => {
|
||||
if (filter === undefined)
|
||||
return emptyFn;
|
||||
if (typeof filter === 'function')
|
||||
return filter;
|
||||
if (typeof filter === 'string') {
|
||||
const fl = filter.trim();
|
||||
return (entry) => entry.basename === fl;
|
||||
}
|
||||
if (Array.isArray(filter)) {
|
||||
const trItems = filter.map((item) => item.trim());
|
||||
return (entry) => trItems.some((f) => entry.basename === f);
|
||||
}
|
||||
return emptyFn;
|
||||
};
|
||||
/** Readable readdir stream, emitting new files as they're being listed. */
|
||||
export class ReaddirpStream extends Readable {
|
||||
constructor(options = {}) {
|
||||
super({
|
||||
objectMode: true,
|
||||
autoDestroy: true,
|
||||
highWaterMark: options.highWaterMark,
|
||||
});
|
||||
const opts = { ...defaultOptions, ...options };
|
||||
const { root, type } = opts;
|
||||
this._fileFilter = normalizeFilter(opts.fileFilter);
|
||||
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
||||
const statMethod = opts.lstat ? lstat : stat;
|
||||
// Use bigint stats if it's windows and stat() supports options (node 10+).
|
||||
if (wantBigintFsStats) {
|
||||
this._stat = (path) => statMethod(path, { bigint: true });
|
||||
}
|
||||
else {
|
||||
this._stat = statMethod;
|
||||
}
|
||||
this._maxDepth = opts.depth ?? defaultOptions.depth;
|
||||
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
||||
this._wantsFile = type ? FILE_TYPES.has(type) : false;
|
||||
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
||||
this._root = presolve(root);
|
||||
this._isDirent = !opts.alwaysStat;
|
||||
this._statsProp = this._isDirent ? 'dirent' : 'stats';
|
||||
this._rdOptions = { encoding: 'utf8', withFileTypes: this._isDirent };
|
||||
// Launch stream with one parent, the root dir.
|
||||
this.parents = [this._exploreDir(root, 1)];
|
||||
this.reading = false;
|
||||
this.parent = undefined;
|
||||
}
|
||||
async _read(batch) {
|
||||
if (this.reading)
|
||||
return;
|
||||
this.reading = true;
|
||||
try {
|
||||
while (!this.destroyed && batch > 0) {
|
||||
const par = this.parent;
|
||||
const fil = par && par.files;
|
||||
if (fil && fil.length > 0) {
|
||||
const { path, depth } = par;
|
||||
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path));
|
||||
const awaited = await Promise.all(slice);
|
||||
for (const entry of awaited) {
|
||||
if (!entry)
|
||||
continue;
|
||||
if (this.destroyed)
|
||||
return;
|
||||
const entryType = await this._getEntryType(entry);
|
||||
if (entryType === 'directory' && this._directoryFilter(entry)) {
|
||||
if (depth <= this._maxDepth) {
|
||||
this.parents.push(this._exploreDir(entry.fullPath, depth + 1));
|
||||
}
|
||||
if (this._wantsDir) {
|
||||
this.push(entry);
|
||||
batch--;
|
||||
}
|
||||
}
|
||||
else if ((entryType === 'file' || this._includeAsFile(entry)) &&
|
||||
this._fileFilter(entry)) {
|
||||
if (this._wantsFile) {
|
||||
this.push(entry);
|
||||
batch--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
const parent = this.parents.pop();
|
||||
if (!parent) {
|
||||
this.push(null);
|
||||
break;
|
||||
}
|
||||
this.parent = await parent;
|
||||
if (this.destroyed)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
this.destroy(error);
|
||||
}
|
||||
finally {
|
||||
this.reading = false;
|
||||
}
|
||||
}
|
||||
async _exploreDir(path, depth) {
|
||||
let files;
|
||||
try {
|
||||
files = await readdir(path, this._rdOptions);
|
||||
}
|
||||
catch (error) {
|
||||
this._onError(error);
|
||||
}
|
||||
return { files, depth, path };
|
||||
}
|
||||
async _formatEntry(dirent, path) {
|
||||
let entry;
|
||||
const basename = this._isDirent ? dirent.name : dirent;
|
||||
try {
|
||||
const fullPath = presolve(pjoin(path, basename));
|
||||
entry = { path: prelative(this._root, fullPath), fullPath, basename };
|
||||
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
||||
}
|
||||
catch (err) {
|
||||
this._onError(err);
|
||||
return;
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
_onError(err) {
|
||||
if (isNormalFlowError(err) && !this.destroyed) {
|
||||
this.emit('warn', err);
|
||||
}
|
||||
else {
|
||||
this.destroy(err);
|
||||
}
|
||||
}
|
||||
async _getEntryType(entry) {
|
||||
// entry may be undefined, because a warning or an error were emitted
|
||||
// and the statsProp is undefined
|
||||
if (!entry && this._statsProp in entry) {
|
||||
return '';
|
||||
}
|
||||
const stats = entry[this._statsProp];
|
||||
if (stats.isFile())
|
||||
return 'file';
|
||||
if (stats.isDirectory())
|
||||
return 'directory';
|
||||
if (stats && stats.isSymbolicLink()) {
|
||||
const full = entry.fullPath;
|
||||
try {
|
||||
const entryRealPath = await realpath(full);
|
||||
const entryRealPathStats = await lstat(entryRealPath);
|
||||
if (entryRealPathStats.isFile()) {
|
||||
return 'file';
|
||||
}
|
||||
if (entryRealPathStats.isDirectory()) {
|
||||
const len = entryRealPath.length;
|
||||
if (full.startsWith(entryRealPath) && full.substr(len, 1) === psep) {
|
||||
const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
|
||||
// @ts-ignore
|
||||
recursiveError.code = RECURSIVE_ERROR_CODE;
|
||||
return this._onError(recursiveError);
|
||||
}
|
||||
return 'directory';
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
this._onError(error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
_includeAsFile(entry) {
|
||||
const stats = entry && entry[this._statsProp];
|
||||
return stats && this._wantsEverything && !stats.isDirectory();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Streaming version: Reads all files and directories in given root recursively.
|
||||
* Consumes ~constant small amount of RAM.
|
||||
* @param root Root directory
|
||||
* @param options Options to specify root (start directory), filters and recursion depth
|
||||
*/
|
||||
export function readdirp(root, options = {}) {
|
||||
// @ts-ignore
|
||||
let type = options.entryType || options.type;
|
||||
if (type === 'both')
|
||||
type = EntryTypes.FILE_DIR_TYPE; // backwards-compatibility
|
||||
if (type)
|
||||
options.type = type;
|
||||
if (!root) {
|
||||
throw new Error('readdirp: root argument is required. Usage: readdirp(root, options)');
|
||||
}
|
||||
else if (typeof root !== 'string') {
|
||||
throw new TypeError('readdirp: root argument must be a string. Usage: readdirp(root, options)');
|
||||
}
|
||||
else if (type && !ALL_TYPES.includes(type)) {
|
||||
throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(', ')}`);
|
||||
}
|
||||
options.root = root;
|
||||
return new ReaddirpStream(options);
|
||||
}
|
||||
/**
|
||||
* Promise version: Reads all files and directories in given root recursively.
|
||||
* Compared to streaming version, will consume a lot of RAM e.g. when 1 million files are listed.
|
||||
* @returns array of paths and their entry infos
|
||||
*/
|
||||
export function readdirpPromise(root, options = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const files = [];
|
||||
readdirp(root, options)
|
||||
.on('data', (entry) => files.push(entry))
|
||||
.on('end', () => resolve(files))
|
||||
.on('error', (error) => reject(error));
|
||||
});
|
||||
}
|
||||
export default readdirp;
|
||||
1
node_modules/sass/node_modules/readdirp/esm/package.json
generated
vendored
Normal file
1
node_modules/sass/node_modules/readdirp/esm/package.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{ "type": "module", "sideEffects": false }
|
||||
108
node_modules/sass/node_modules/readdirp/index.d.ts
generated
vendored
Normal file
108
node_modules/sass/node_modules/readdirp/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
/**
|
||||
* Recursive version of readdir. Exposes a streaming API and promise API.
|
||||
* Streaming API allows to use a small amount of RAM.
|
||||
*
|
||||
* @module
|
||||
* @example
|
||||
```js
|
||||
import readdirp from 'readdirp';
|
||||
for await (const entry of readdirp('.')) {
|
||||
const {path} = entry;
|
||||
console.log(`${JSON.stringify({path})}`);
|
||||
}
|
||||
```
|
||||
*/
|
||||
/*! readdirp - MIT License (c) 2012-2019 Thorsten Lorenz, Paul Miller (https://paulmillr.com) */
|
||||
import type { Stats, Dirent } from 'node:fs';
|
||||
import { Readable } from 'node:stream';
|
||||
/** Path in file system. */
|
||||
export type Path = string;
|
||||
/** Emitted entry. Contains relative & absolute path, basename, and either stats or dirent. */
|
||||
export interface EntryInfo {
|
||||
path: string;
|
||||
fullPath: string;
|
||||
stats?: Stats;
|
||||
dirent?: Dirent;
|
||||
basename: string;
|
||||
}
|
||||
/** Path or dir entries (files) */
|
||||
export type PathOrDirent = Dirent | Path;
|
||||
/** Filterer for files */
|
||||
export type Tester = (entryInfo: EntryInfo) => boolean;
|
||||
export type Predicate = string[] | string | Tester;
|
||||
export declare const EntryTypes: {
|
||||
readonly FILE_TYPE: "files";
|
||||
readonly DIR_TYPE: "directories";
|
||||
readonly FILE_DIR_TYPE: "files_directories";
|
||||
readonly EVERYTHING_TYPE: "all";
|
||||
};
|
||||
export type EntryType = (typeof EntryTypes)[keyof typeof EntryTypes];
|
||||
/**
|
||||
* Options for readdirp.
|
||||
* * type: files, directories, or both
|
||||
* * lstat: whether to use symlink-friendly stat
|
||||
* * depth: max depth
|
||||
* * alwaysStat: whether to use stat (more resources) or dirent
|
||||
* * highWaterMark: streaming param, specifies max amount of resources per entry
|
||||
*/
|
||||
export type ReaddirpOptions = {
|
||||
root: string;
|
||||
fileFilter?: Predicate;
|
||||
directoryFilter?: Predicate;
|
||||
type?: EntryType;
|
||||
lstat?: boolean;
|
||||
depth?: number;
|
||||
alwaysStat?: boolean;
|
||||
highWaterMark?: number;
|
||||
};
|
||||
/** Directory entry. Contains path, depth count, and files. */
|
||||
export interface DirEntry {
|
||||
files: PathOrDirent[];
|
||||
depth: number;
|
||||
path: Path;
|
||||
}
|
||||
/** Readable readdir stream, emitting new files as they're being listed. */
|
||||
export declare class ReaddirpStream extends Readable {
|
||||
parents: any[];
|
||||
reading: boolean;
|
||||
parent?: DirEntry;
|
||||
_stat: Function;
|
||||
_maxDepth: number;
|
||||
_wantsDir: boolean;
|
||||
_wantsFile: boolean;
|
||||
_wantsEverything: boolean;
|
||||
_root: Path;
|
||||
_isDirent: boolean;
|
||||
_statsProp: 'dirent' | 'stats';
|
||||
_rdOptions: {
|
||||
encoding: 'utf8';
|
||||
withFileTypes: boolean;
|
||||
};
|
||||
_fileFilter: Tester;
|
||||
_directoryFilter: Tester;
|
||||
constructor(options?: Partial<ReaddirpOptions>);
|
||||
_read(batch: number): Promise<void>;
|
||||
_exploreDir(path: Path, depth: number): Promise<{
|
||||
files: string[] | undefined;
|
||||
depth: number;
|
||||
path: string;
|
||||
}>;
|
||||
_formatEntry(dirent: PathOrDirent, path: Path): Promise<EntryInfo | undefined>;
|
||||
_onError(err: Error): void;
|
||||
_getEntryType(entry: EntryInfo): Promise<void | '' | 'file' | 'directory'>;
|
||||
_includeAsFile(entry: EntryInfo): boolean | undefined;
|
||||
}
|
||||
/**
|
||||
* Streaming version: Reads all files and directories in given root recursively.
|
||||
* Consumes ~constant small amount of RAM.
|
||||
* @param root Root directory
|
||||
* @param options Options to specify root (start directory), filters and recursion depth
|
||||
*/
|
||||
export declare function readdirp(root: Path, options?: Partial<ReaddirpOptions>): ReaddirpStream;
|
||||
/**
|
||||
* Promise version: Reads all files and directories in given root recursively.
|
||||
* Compared to streaming version, will consume a lot of RAM e.g. when 1 million files are listed.
|
||||
* @returns array of paths and their entry infos
|
||||
*/
|
||||
export declare function readdirpPromise(root: Path, options?: Partial<ReaddirpOptions>): Promise<EntryInfo[]>;
|
||||
export default readdirp;
|
||||
263
node_modules/sass/node_modules/readdirp/index.js
generated
vendored
Normal file
263
node_modules/sass/node_modules/readdirp/index.js
generated
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ReaddirpStream = exports.EntryTypes = void 0;
|
||||
exports.readdirp = readdirp;
|
||||
exports.readdirpPromise = readdirpPromise;
|
||||
const promises_1 = require("node:fs/promises");
|
||||
const node_stream_1 = require("node:stream");
|
||||
const node_path_1 = require("node:path");
|
||||
exports.EntryTypes = {
|
||||
FILE_TYPE: 'files',
|
||||
DIR_TYPE: 'directories',
|
||||
FILE_DIR_TYPE: 'files_directories',
|
||||
EVERYTHING_TYPE: 'all',
|
||||
};
|
||||
const defaultOptions = {
|
||||
root: '.',
|
||||
fileFilter: (_entryInfo) => true,
|
||||
directoryFilter: (_entryInfo) => true,
|
||||
type: exports.EntryTypes.FILE_TYPE,
|
||||
lstat: false,
|
||||
depth: 2147483648,
|
||||
alwaysStat: false,
|
||||
highWaterMark: 4096,
|
||||
};
|
||||
Object.freeze(defaultOptions);
|
||||
const RECURSIVE_ERROR_CODE = 'READDIRP_RECURSIVE_ERROR';
|
||||
const NORMAL_FLOW_ERRORS = new Set(['ENOENT', 'EPERM', 'EACCES', 'ELOOP', RECURSIVE_ERROR_CODE]);
|
||||
const ALL_TYPES = [
|
||||
exports.EntryTypes.DIR_TYPE,
|
||||
exports.EntryTypes.EVERYTHING_TYPE,
|
||||
exports.EntryTypes.FILE_DIR_TYPE,
|
||||
exports.EntryTypes.FILE_TYPE,
|
||||
];
|
||||
const DIR_TYPES = new Set([
|
||||
exports.EntryTypes.DIR_TYPE,
|
||||
exports.EntryTypes.EVERYTHING_TYPE,
|
||||
exports.EntryTypes.FILE_DIR_TYPE,
|
||||
]);
|
||||
const FILE_TYPES = new Set([
|
||||
exports.EntryTypes.EVERYTHING_TYPE,
|
||||
exports.EntryTypes.FILE_DIR_TYPE,
|
||||
exports.EntryTypes.FILE_TYPE,
|
||||
]);
|
||||
const isNormalFlowError = (error) => NORMAL_FLOW_ERRORS.has(error.code);
|
||||
const wantBigintFsStats = process.platform === 'win32';
|
||||
const emptyFn = (_entryInfo) => true;
|
||||
const normalizeFilter = (filter) => {
|
||||
if (filter === undefined)
|
||||
return emptyFn;
|
||||
if (typeof filter === 'function')
|
||||
return filter;
|
||||
if (typeof filter === 'string') {
|
||||
const fl = filter.trim();
|
||||
return (entry) => entry.basename === fl;
|
||||
}
|
||||
if (Array.isArray(filter)) {
|
||||
const trItems = filter.map((item) => item.trim());
|
||||
return (entry) => trItems.some((f) => entry.basename === f);
|
||||
}
|
||||
return emptyFn;
|
||||
};
|
||||
/** Readable readdir stream, emitting new files as they're being listed. */
|
||||
class ReaddirpStream extends node_stream_1.Readable {
|
||||
constructor(options = {}) {
|
||||
super({
|
||||
objectMode: true,
|
||||
autoDestroy: true,
|
||||
highWaterMark: options.highWaterMark,
|
||||
});
|
||||
const opts = { ...defaultOptions, ...options };
|
||||
const { root, type } = opts;
|
||||
this._fileFilter = normalizeFilter(opts.fileFilter);
|
||||
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
||||
const statMethod = opts.lstat ? promises_1.lstat : promises_1.stat;
|
||||
// Use bigint stats if it's windows and stat() supports options (node 10+).
|
||||
if (wantBigintFsStats) {
|
||||
this._stat = (path) => statMethod(path, { bigint: true });
|
||||
}
|
||||
else {
|
||||
this._stat = statMethod;
|
||||
}
|
||||
this._maxDepth = opts.depth ?? defaultOptions.depth;
|
||||
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
||||
this._wantsFile = type ? FILE_TYPES.has(type) : false;
|
||||
this._wantsEverything = type === exports.EntryTypes.EVERYTHING_TYPE;
|
||||
this._root = (0, node_path_1.resolve)(root);
|
||||
this._isDirent = !opts.alwaysStat;
|
||||
this._statsProp = this._isDirent ? 'dirent' : 'stats';
|
||||
this._rdOptions = { encoding: 'utf8', withFileTypes: this._isDirent };
|
||||
// Launch stream with one parent, the root dir.
|
||||
this.parents = [this._exploreDir(root, 1)];
|
||||
this.reading = false;
|
||||
this.parent = undefined;
|
||||
}
|
||||
async _read(batch) {
|
||||
if (this.reading)
|
||||
return;
|
||||
this.reading = true;
|
||||
try {
|
||||
while (!this.destroyed && batch > 0) {
|
||||
const par = this.parent;
|
||||
const fil = par && par.files;
|
||||
if (fil && fil.length > 0) {
|
||||
const { path, depth } = par;
|
||||
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path));
|
||||
const awaited = await Promise.all(slice);
|
||||
for (const entry of awaited) {
|
||||
if (!entry)
|
||||
continue;
|
||||
if (this.destroyed)
|
||||
return;
|
||||
const entryType = await this._getEntryType(entry);
|
||||
if (entryType === 'directory' && this._directoryFilter(entry)) {
|
||||
if (depth <= this._maxDepth) {
|
||||
this.parents.push(this._exploreDir(entry.fullPath, depth + 1));
|
||||
}
|
||||
if (this._wantsDir) {
|
||||
this.push(entry);
|
||||
batch--;
|
||||
}
|
||||
}
|
||||
else if ((entryType === 'file' || this._includeAsFile(entry)) &&
|
||||
this._fileFilter(entry)) {
|
||||
if (this._wantsFile) {
|
||||
this.push(entry);
|
||||
batch--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
const parent = this.parents.pop();
|
||||
if (!parent) {
|
||||
this.push(null);
|
||||
break;
|
||||
}
|
||||
this.parent = await parent;
|
||||
if (this.destroyed)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
this.destroy(error);
|
||||
}
|
||||
finally {
|
||||
this.reading = false;
|
||||
}
|
||||
}
|
||||
async _exploreDir(path, depth) {
|
||||
let files;
|
||||
try {
|
||||
files = await (0, promises_1.readdir)(path, this._rdOptions);
|
||||
}
|
||||
catch (error) {
|
||||
this._onError(error);
|
||||
}
|
||||
return { files, depth, path };
|
||||
}
|
||||
async _formatEntry(dirent, path) {
|
||||
let entry;
|
||||
const basename = this._isDirent ? dirent.name : dirent;
|
||||
try {
|
||||
const fullPath = (0, node_path_1.resolve)((0, node_path_1.join)(path, basename));
|
||||
entry = { path: (0, node_path_1.relative)(this._root, fullPath), fullPath, basename };
|
||||
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
||||
}
|
||||
catch (err) {
|
||||
this._onError(err);
|
||||
return;
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
_onError(err) {
|
||||
if (isNormalFlowError(err) && !this.destroyed) {
|
||||
this.emit('warn', err);
|
||||
}
|
||||
else {
|
||||
this.destroy(err);
|
||||
}
|
||||
}
|
||||
async _getEntryType(entry) {
|
||||
// entry may be undefined, because a warning or an error were emitted
|
||||
// and the statsProp is undefined
|
||||
if (!entry && this._statsProp in entry) {
|
||||
return '';
|
||||
}
|
||||
const stats = entry[this._statsProp];
|
||||
if (stats.isFile())
|
||||
return 'file';
|
||||
if (stats.isDirectory())
|
||||
return 'directory';
|
||||
if (stats && stats.isSymbolicLink()) {
|
||||
const full = entry.fullPath;
|
||||
try {
|
||||
const entryRealPath = await (0, promises_1.realpath)(full);
|
||||
const entryRealPathStats = await (0, promises_1.lstat)(entryRealPath);
|
||||
if (entryRealPathStats.isFile()) {
|
||||
return 'file';
|
||||
}
|
||||
if (entryRealPathStats.isDirectory()) {
|
||||
const len = entryRealPath.length;
|
||||
if (full.startsWith(entryRealPath) && full.substr(len, 1) === node_path_1.sep) {
|
||||
const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
|
||||
// @ts-ignore
|
||||
recursiveError.code = RECURSIVE_ERROR_CODE;
|
||||
return this._onError(recursiveError);
|
||||
}
|
||||
return 'directory';
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
this._onError(error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
_includeAsFile(entry) {
|
||||
const stats = entry && entry[this._statsProp];
|
||||
return stats && this._wantsEverything && !stats.isDirectory();
|
||||
}
|
||||
}
|
||||
exports.ReaddirpStream = ReaddirpStream;
|
||||
/**
|
||||
* Streaming version: Reads all files and directories in given root recursively.
|
||||
* Consumes ~constant small amount of RAM.
|
||||
* @param root Root directory
|
||||
* @param options Options to specify root (start directory), filters and recursion depth
|
||||
*/
|
||||
function readdirp(root, options = {}) {
|
||||
// @ts-ignore
|
||||
let type = options.entryType || options.type;
|
||||
if (type === 'both')
|
||||
type = exports.EntryTypes.FILE_DIR_TYPE; // backwards-compatibility
|
||||
if (type)
|
||||
options.type = type;
|
||||
if (!root) {
|
||||
throw new Error('readdirp: root argument is required. Usage: readdirp(root, options)');
|
||||
}
|
||||
else if (typeof root !== 'string') {
|
||||
throw new TypeError('readdirp: root argument must be a string. Usage: readdirp(root, options)');
|
||||
}
|
||||
else if (type && !ALL_TYPES.includes(type)) {
|
||||
throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(', ')}`);
|
||||
}
|
||||
options.root = root;
|
||||
return new ReaddirpStream(options);
|
||||
}
|
||||
/**
|
||||
* Promise version: Reads all files and directories in given root recursively.
|
||||
* Compared to streaming version, will consume a lot of RAM e.g. when 1 million files are listed.
|
||||
* @returns array of paths and their entry infos
|
||||
*/
|
||||
function readdirpPromise(root, options = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const files = [];
|
||||
readdirp(root, options)
|
||||
.on('data', (entry) => files.push(entry))
|
||||
.on('end', () => resolve(files))
|
||||
.on('error', (error) => reject(error));
|
||||
});
|
||||
}
|
||||
exports.default = readdirp;
|
||||
70
node_modules/sass/node_modules/readdirp/package.json
generated
vendored
Normal file
70
node_modules/sass/node_modules/readdirp/package.json
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"name": "readdirp",
|
||||
"description": "Recursive version of fs.readdir with small RAM & CPU footprint.",
|
||||
"version": "4.1.2",
|
||||
"homepage": "https://github.com/paulmillr/readdirp",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/paulmillr/readdirp.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/paulmillr/readdirp/issues"
|
||||
},
|
||||
"author": "Thorsten Lorenz <thlorenz@gmx.de> (thlorenz.com)",
|
||||
"contributors": [
|
||||
"Thorsten Lorenz <thlorenz@gmx.de> (thlorenz.com)",
|
||||
"Paul Miller (https://paulmillr.com)"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 14.18.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"index.d.ts.map",
|
||||
"index.js.map",
|
||||
"esm"
|
||||
],
|
||||
"main": "./index.js",
|
||||
"module": "./esm/index.js",
|
||||
"types": "./index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./esm/index.js",
|
||||
"require": "./index.js"
|
||||
}
|
||||
},
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"recursive",
|
||||
"fs",
|
||||
"stream",
|
||||
"streams",
|
||||
"readdir",
|
||||
"filesystem",
|
||||
"find",
|
||||
"filter"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc && tsc -p tsconfig.cjs.json",
|
||||
"lint": "prettier --check index.ts test/index.test.js",
|
||||
"format": "prettier --write index.ts test/index.test.js",
|
||||
"test": "node test/index.test.js",
|
||||
"test:coverage": "c8 node test/index.test.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@paulmillr/jsbt": "0.3.1",
|
||||
"@types/node": "20.14.8",
|
||||
"c8": "10.1.3",
|
||||
"chai": "4.3.4",
|
||||
"chai-subset": "1.6.0",
|
||||
"micro-should": "0.5.0",
|
||||
"prettier": "3.1.1",
|
||||
"typescript": "5.5.2"
|
||||
},
|
||||
"funding": {
|
||||
"type": "individual",
|
||||
"url": "https://paulmillr.com/funding/"
|
||||
}
|
||||
}
|
||||
1
node_modules/sass/package.json
generated
vendored
Normal file
1
node_modules/sass/package.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"name":"sass","description":"A pure JavaScript implementation of Sass.","license":"MIT","bugs":"https://github.com/sass/dart-sass/issues","homepage":"https://github.com/sass/dart-sass","repository":{"type":"git","url":"https://github.com/sass/dart-sass"},"author":{"name":"Natalie Weizenbaum","email":"nweiz@google.com","url":"https://github.com/nex3"},"engines":{"node":">=14.0.0"},"dependencies":{"chokidar":"^4.0.0","immutable":"^5.0.2","source-map-js":">=0.6.2 <2.0.0"},"optionalDependencies":{"@parcel/watcher":"^2.4.1"},"keywords":["style","scss","sass","preprocessor","css"],"types":"types/index.d.ts","exports":{"types":"./types/index.d.ts","node":{"require":"./sass.node.js","default":"./sass.node.mjs"},"default":{"require":"./sass.default.cjs","default":"./sass.default.js"}},"version":"1.92.1","bin":{"sass":"sass.js"},"main":"sass.node.js"}
|
||||
127618
node_modules/sass/sass.dart.js
generated
vendored
Normal file
127618
node_modules/sass/sass.dart.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
8
node_modules/sass/sass.default.cjs
generated
vendored
Normal file
8
node_modules/sass/sass.default.cjs
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
require('./sass.dart.js');
|
||||
const library = globalThis._cliPkgExports.pop();
|
||||
if (globalThis._cliPkgExports.length === 0) delete globalThis._cliPkgExports;
|
||||
library.load({
|
||||
immutable: require("immutable"),
|
||||
});
|
||||
|
||||
module.exports = library;
|
||||
48
node_modules/sass/sass.default.js
generated
vendored
Normal file
48
node_modules/sass/sass.default.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
import * as immutable from "immutable"
|
||||
import "./sass.dart.js";
|
||||
|
||||
const _cliPkgLibrary = globalThis._cliPkgExports.pop();
|
||||
if (globalThis._cliPkgExports.length === 0) delete globalThis._cliPkgExports;
|
||||
const _cliPkgExports = {};
|
||||
_cliPkgLibrary.load({immutable}, _cliPkgExports);
|
||||
|
||||
export const compile = _cliPkgExports.compile;
|
||||
export const compileAsync = _cliPkgExports.compileAsync;
|
||||
export const compileString = _cliPkgExports.compileString;
|
||||
export const compileStringAsync = _cliPkgExports.compileStringAsync;
|
||||
export const initCompiler = _cliPkgExports.initCompiler;
|
||||
export const initAsyncCompiler = _cliPkgExports.initAsyncCompiler;
|
||||
export const Compiler = _cliPkgExports.Compiler;
|
||||
export const AsyncCompiler = _cliPkgExports.AsyncCompiler;
|
||||
export const Logger = _cliPkgExports.Logger;
|
||||
export const SassArgumentList = _cliPkgExports.SassArgumentList;
|
||||
export const SassBoolean = _cliPkgExports.SassBoolean;
|
||||
export const SassCalculation = _cliPkgExports.SassCalculation;
|
||||
export const CalculationOperation = _cliPkgExports.CalculationOperation;
|
||||
export const CalculationInterpolation = _cliPkgExports.CalculationInterpolation;
|
||||
export const SassColor = _cliPkgExports.SassColor;
|
||||
export const SassFunction = _cliPkgExports.SassFunction;
|
||||
export const SassList = _cliPkgExports.SassList;
|
||||
export const SassMap = _cliPkgExports.SassMap;
|
||||
export const SassMixin = _cliPkgExports.SassMixin;
|
||||
export const SassNumber = _cliPkgExports.SassNumber;
|
||||
export const SassString = _cliPkgExports.SassString;
|
||||
export const Value = _cliPkgExports.Value;
|
||||
export const CustomFunction = _cliPkgExports.CustomFunction;
|
||||
export const ListSeparator = _cliPkgExports.ListSeparator;
|
||||
export const sassFalse = _cliPkgExports.sassFalse;
|
||||
export const sassNull = _cliPkgExports.sassNull;
|
||||
export const sassTrue = _cliPkgExports.sassTrue;
|
||||
export const Exception = _cliPkgExports.Exception;
|
||||
export const PromiseOr = _cliPkgExports.PromiseOr;
|
||||
export const info = _cliPkgExports.info;
|
||||
export const render = _cliPkgExports.render;
|
||||
export const renderSync = _cliPkgExports.renderSync;
|
||||
export const TRUE = _cliPkgExports.TRUE;
|
||||
export const FALSE = _cliPkgExports.FALSE;
|
||||
export const NULL = _cliPkgExports.NULL;
|
||||
export const types = _cliPkgExports.types;
|
||||
export const NodePackageImporter = _cliPkgExports.NodePackageImporter;
|
||||
export const deprecations = _cliPkgExports.deprecations;
|
||||
export const Version = _cliPkgExports.Version;
|
||||
export const parser_ = _cliPkgExports.parser_;
|
||||
18
node_modules/sass/sass.js
generated
vendored
Executable file
18
node_modules/sass/sass.js
generated
vendored
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
require('./sass.dart.js');
|
||||
var library = globalThis._cliPkgExports.pop();
|
||||
if (globalThis._cliPkgExports.length === 0) delete globalThis._cliPkgExports;
|
||||
|
||||
library.load({
|
||||
readline: require("readline"),
|
||||
chokidar: require("chokidar"),
|
||||
parcel_watcher: (function(i){let r;return function parcel_watcher(){if(void 0!==r)return r;try{r=require(i)}catch(e){if('MODULE_NOT_FOUND'!==e.code)console.error(e);r=null}return r}})("@parcel/watcher"),
|
||||
util: require("util"),
|
||||
stream: require("stream"),
|
||||
nodeModule: require("module"),
|
||||
fs: require("fs"),
|
||||
immutable: require("immutable"),
|
||||
});
|
||||
|
||||
library.cli_pkg_main_0_(process.argv.slice(2));
|
||||
12
node_modules/sass/sass.node.js
generated
vendored
Normal file
12
node_modules/sass/sass.node.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
require('./sass.dart.js');
|
||||
const library = globalThis._cliPkgExports.pop();
|
||||
if (globalThis._cliPkgExports.length === 0) delete globalThis._cliPkgExports;
|
||||
library.load({
|
||||
util: require("util"),
|
||||
stream: require("stream"),
|
||||
nodeModule: require("module"),
|
||||
fs: require("fs"),
|
||||
immutable: require("immutable"),
|
||||
});
|
||||
|
||||
module.exports = library;
|
||||
214
node_modules/sass/sass.node.mjs
generated
vendored
Normal file
214
node_modules/sass/sass.node.mjs
generated
vendored
Normal file
@@ -0,0 +1,214 @@
|
||||
import cjs from "./sass.node.js";
|
||||
|
||||
export const compile = cjs.compile;
|
||||
export const compileAsync = cjs.compileAsync;
|
||||
export const compileString = cjs.compileString;
|
||||
export const compileStringAsync = cjs.compileStringAsync;
|
||||
export const initCompiler = cjs.initCompiler;
|
||||
export const initAsyncCompiler = cjs.initAsyncCompiler;
|
||||
export const Compiler = cjs.Compiler;
|
||||
export const AsyncCompiler = cjs.AsyncCompiler;
|
||||
export const Logger = cjs.Logger;
|
||||
export const SassArgumentList = cjs.SassArgumentList;
|
||||
export const SassBoolean = cjs.SassBoolean;
|
||||
export const SassCalculation = cjs.SassCalculation;
|
||||
export const CalculationOperation = cjs.CalculationOperation;
|
||||
export const CalculationInterpolation = cjs.CalculationInterpolation;
|
||||
export const SassColor = cjs.SassColor;
|
||||
export const SassFunction = cjs.SassFunction;
|
||||
export const SassList = cjs.SassList;
|
||||
export const SassMap = cjs.SassMap;
|
||||
export const SassMixin = cjs.SassMixin;
|
||||
export const SassNumber = cjs.SassNumber;
|
||||
export const SassString = cjs.SassString;
|
||||
export const Value = cjs.Value;
|
||||
export const CustomFunction = cjs.CustomFunction;
|
||||
export const ListSeparator = cjs.ListSeparator;
|
||||
export const sassFalse = cjs.sassFalse;
|
||||
export const sassNull = cjs.sassNull;
|
||||
export const sassTrue = cjs.sassTrue;
|
||||
export const Exception = cjs.Exception;
|
||||
export const PromiseOr = cjs.PromiseOr;
|
||||
export const info = cjs.info;
|
||||
export const render = cjs.render;
|
||||
export const renderSync = cjs.renderSync;
|
||||
export const TRUE = cjs.TRUE;
|
||||
export const FALSE = cjs.FALSE;
|
||||
export const NULL = cjs.NULL;
|
||||
export const types = cjs.types;
|
||||
export const NodePackageImporter = cjs.NodePackageImporter;
|
||||
export const deprecations = cjs.deprecations;
|
||||
export const Version = cjs.Version;
|
||||
export const parser_ = cjs.parser_;
|
||||
|
||||
let printedDefaultExportDeprecation = false;
|
||||
function defaultExportDeprecation() {
|
||||
if (printedDefaultExportDeprecation) return;
|
||||
printedDefaultExportDeprecation = true;
|
||||
console.error(
|
||||
"`import sass from 'sass'` is deprecated.\n" +
|
||||
"Please use `import * as sass from 'sass'` instead.");
|
||||
}
|
||||
|
||||
export default {
|
||||
get compile() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.compile;
|
||||
},
|
||||
get compileAsync() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.compileAsync;
|
||||
},
|
||||
get compileString() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.compileString;
|
||||
},
|
||||
get compileStringAsync() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.compileStringAsync;
|
||||
},
|
||||
get initCompiler() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.initCompiler;
|
||||
},
|
||||
get initAsyncCompiler() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.initAsyncCompiler;
|
||||
},
|
||||
get Compiler() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.Compiler;
|
||||
},
|
||||
get AsyncCompiler() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.AsyncCompiler;
|
||||
},
|
||||
get Logger() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.Logger;
|
||||
},
|
||||
get SassArgumentList() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.SassArgumentList;
|
||||
},
|
||||
get SassBoolean() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.SassBoolean;
|
||||
},
|
||||
get SassCalculation() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.SassCalculation;
|
||||
},
|
||||
get CalculationOperation() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.CalculationOperation;
|
||||
},
|
||||
get CalculationInterpolation() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.CalculationInterpolation;
|
||||
},
|
||||
get SassColor() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.SassColor;
|
||||
},
|
||||
get SassFunction() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.SassFunction;
|
||||
},
|
||||
get SassList() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.SassList;
|
||||
},
|
||||
get SassMap() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.SassMap;
|
||||
},
|
||||
get SassMixin() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.SassMixin;
|
||||
},
|
||||
get SassNumber() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.SassNumber;
|
||||
},
|
||||
get SassString() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.SassString;
|
||||
},
|
||||
get Value() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.Value;
|
||||
},
|
||||
get CustomFunction() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.CustomFunction;
|
||||
},
|
||||
get ListSeparator() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.ListSeparator;
|
||||
},
|
||||
get sassFalse() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.sassFalse;
|
||||
},
|
||||
get sassNull() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.sassNull;
|
||||
},
|
||||
get sassTrue() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.sassTrue;
|
||||
},
|
||||
get Exception() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.Exception;
|
||||
},
|
||||
get PromiseOr() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.PromiseOr;
|
||||
},
|
||||
get info() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.info;
|
||||
},
|
||||
get render() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.render;
|
||||
},
|
||||
get renderSync() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.renderSync;
|
||||
},
|
||||
get TRUE() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.TRUE;
|
||||
},
|
||||
get FALSE() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.FALSE;
|
||||
},
|
||||
get NULL() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.NULL;
|
||||
},
|
||||
get types() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.types;
|
||||
},
|
||||
get NodePackageImporter() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.NodePackageImporter;
|
||||
},
|
||||
get deprecations() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.deprecations;
|
||||
},
|
||||
get Version() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.Version;
|
||||
},
|
||||
get parser_() {
|
||||
defaultExportDeprecation();
|
||||
return cjs.parser_;
|
||||
},
|
||||
};
|
||||
342
node_modules/sass/types/compile.d.ts
generated
vendored
Normal file
342
node_modules/sass/types/compile.d.ts
generated
vendored
Normal file
@@ -0,0 +1,342 @@
|
||||
import {RawSourceMap} from 'source-map-js';
|
||||
|
||||
import {Options, StringOptions} from './options';
|
||||
|
||||
/**
|
||||
* The result of compiling Sass to CSS. Returned by {@link compile}, {@link
|
||||
* compileAsync}, {@link compileString}, and {@link compileStringAsync}.
|
||||
*
|
||||
* @category Compile
|
||||
*/
|
||||
export interface CompileResult {
|
||||
/**
|
||||
* The generated CSS.
|
||||
*
|
||||
* Note that this *never* includes a `sourceMapUrl` comment—it's up to the
|
||||
* caller to determine where to save the source map and how to link to it from
|
||||
* the stylesheet.
|
||||
*/
|
||||
css: string;
|
||||
|
||||
/**
|
||||
* The canonical URLs of all the stylesheets that were loaded during the
|
||||
* Sass compilation. The order of these URLs is not guaranteed.
|
||||
*/
|
||||
loadedUrls: URL[];
|
||||
|
||||
/**
|
||||
* The object representation of the source map that maps locations in the
|
||||
* generated CSS back to locations in the Sass source code.
|
||||
*
|
||||
* This typically uses absolute `file:` URLs to refer to Sass files, although
|
||||
* this can be controlled by having a custom {@link Importer} return {@link
|
||||
* ImporterResult.sourceMapUrl}.
|
||||
*
|
||||
* This is set if and only if {@link Options.sourceMap} is `true`.
|
||||
*/
|
||||
sourceMap?: RawSourceMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The result of creating a synchronous compiler. Returned by
|
||||
* {@link initCompiler}.
|
||||
*
|
||||
* @category Compile
|
||||
*/
|
||||
export class Compiler {
|
||||
/**
|
||||
* Throws an error if constructed directly, instead of via
|
||||
* {@link initCompiler}.
|
||||
*/
|
||||
private constructor();
|
||||
|
||||
/**
|
||||
* The {@link compile} method exposed through a Compiler instance while it is
|
||||
* active. If this is called after {@link dispose} on the Compiler
|
||||
* instance, an error will be thrown.
|
||||
*
|
||||
* During the Compiler instance's lifespan, given the same input, this will
|
||||
* return an identical result to the {@link compile} method exposed at the
|
||||
* module root.
|
||||
*/
|
||||
compile(path: string, options?: Options<'sync'>): CompileResult;
|
||||
|
||||
/**
|
||||
* The {@link compileString} method exposed through a Compiler instance while
|
||||
* it is active. If this is called after {@link dispose} on the Compiler
|
||||
* instance, an error will be thrown.
|
||||
*
|
||||
* During the Compiler instance's lifespan, given the same input, this will
|
||||
* return an identical result to the {@link compileString} method exposed at
|
||||
* the module root.
|
||||
*/
|
||||
compileString(source: string, options?: StringOptions<'sync'>): CompileResult;
|
||||
|
||||
/**
|
||||
* Ends the lifespan of this Compiler instance. After this is invoked, all
|
||||
* calls to the Compiler instance's {@link compile} or {@link compileString}
|
||||
* methods will result in an error.
|
||||
*/
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* The result of creating an asynchronous compiler. Returned by
|
||||
* {@link initAsyncCompiler}.
|
||||
*
|
||||
* @category Compile
|
||||
*/
|
||||
export class AsyncCompiler {
|
||||
/**
|
||||
* Throws an error if constructed directly, instead of via
|
||||
* {@link initAsyncCompiler}.
|
||||
*/
|
||||
private constructor();
|
||||
|
||||
/**
|
||||
* The {@link compileAsync} method exposed through an Async Compiler instance
|
||||
* while it is active. If this is called after {@link dispose} on the Async
|
||||
* Compiler instance, an error will be thrown.
|
||||
*
|
||||
* During the Async Compiler instance's lifespan, given the same input, this
|
||||
* will return an identical result to the {@link compileAsync} method exposed
|
||||
* at the module root.
|
||||
*/
|
||||
compileAsync(
|
||||
path: string,
|
||||
options?: Options<'async'>
|
||||
): Promise<CompileResult>;
|
||||
|
||||
/**
|
||||
* The {@link compileStringAsync} method exposed through an Async Compiler
|
||||
* instance while it is active. If this is called after {@link dispose} on the
|
||||
* Async Compiler instance, an error will be thrown.
|
||||
*
|
||||
* During the Async Compiler instance's lifespan, given the same input, this
|
||||
* will return an identical result to the {@link compileStringAsync} method
|
||||
* exposed at the module root.
|
||||
*/
|
||||
compileStringAsync(
|
||||
source: string,
|
||||
options?: StringOptions<'async'>
|
||||
): Promise<CompileResult>;
|
||||
|
||||
/**
|
||||
* Ends the lifespan of this Async Compiler instance. After this is invoked,
|
||||
* all subsequent calls to the Compiler instance's `compileAsync` or
|
||||
* `compileStringAsync` methods will result in an error.
|
||||
*
|
||||
* Any compilations that are submitted before `dispose` will not be cancelled,
|
||||
* and will be allowed to settle.
|
||||
*
|
||||
* After all compilations have been settled and Sass completes any internal
|
||||
* task cleanup, `dispose` will resolve its promise.
|
||||
*/
|
||||
dispose(): Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronously compiles the Sass file at `path` to CSS. If it succeeds it
|
||||
* returns a {@link CompileResult}, and if it fails it throws an {@link
|
||||
* Exception}.
|
||||
*
|
||||
* This only allows synchronous {@link Importer}s and {@link CustomFunction}s.
|
||||
*
|
||||
* **Heads up!** When using the [sass-embedded] npm package for single
|
||||
* compilations, **{@link compileAsync} is almost always faster than
|
||||
* {@link compile}**, due to the overhead of emulating synchronous messaging
|
||||
* with worker threads and concurrent compilations being blocked on main thread.
|
||||
*
|
||||
* If you are running multiple compilations with the [sass-embedded] npm
|
||||
* package, using a {@link Compiler} will provide some speed improvements over
|
||||
* the module-level methods, and an {@link AsyncCompiler} will be much faster.
|
||||
*
|
||||
* [sass-embedded]: https://www.npmjs.com/package/sass-embedded
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* const sass = require('sass');
|
||||
*
|
||||
* const result = sass.compile("style.scss");
|
||||
* console.log(result.css);
|
||||
* ```
|
||||
*
|
||||
* @category Compile
|
||||
* @compatibility dart: "1.45.0", node: false
|
||||
*/
|
||||
export function compile(path: string, options?: Options<'sync'>): CompileResult;
|
||||
|
||||
/**
|
||||
* Asynchronously compiles the Sass file at `path` to CSS. Returns a promise
|
||||
* that resolves with a {@link CompileResult} if it succeeds and rejects with an
|
||||
* {@link Exception} if it fails.
|
||||
*
|
||||
* This only allows synchronous or asynchronous {@link Importer}s and
|
||||
* {@link CustomFunction}s.
|
||||
*
|
||||
* **Heads up!** When using the `sass` npm package, **{@link compile} is almost
|
||||
* twice as fast as {@link compileAsync}**, due to the overhead of making the
|
||||
* entire evaluation process asynchronous.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* const sass = require('sass');
|
||||
*
|
||||
* const result = await sass.compileAsync("style.scss");
|
||||
* console.log(result.css);
|
||||
* ```
|
||||
*
|
||||
* @category Compile
|
||||
* @compatibility dart: "1.45.0", node: false
|
||||
*/
|
||||
export function compileAsync(
|
||||
path: string,
|
||||
options?: Options<'async'>
|
||||
): Promise<CompileResult>;
|
||||
|
||||
/**
|
||||
* Synchronously compiles a stylesheet whose contents is `source` to CSS. If it
|
||||
* succeeds it returns a {@link CompileResult}, and if it fails it throws an
|
||||
* {@link Exception}.
|
||||
*
|
||||
* This only allows synchronous {@link Importer}s and {@link CustomFunction}s.
|
||||
*
|
||||
* **Heads up!** When using the [sass-embedded] npm package for single
|
||||
* compilations, **{@link compileStringAsync} is almost always faster than
|
||||
* {@link compileString}**, due to the overhead of emulating synchronous
|
||||
* messaging with worker threads and concurrent compilations being blocked on
|
||||
* main thread.
|
||||
*
|
||||
* If you are running multiple compilations with the [sass-embedded] npm
|
||||
* package, using a {@link Compiler} will provide some speed improvements over
|
||||
* the module-level methods, and an {@link AsyncCompiler} will be much faster.
|
||||
*
|
||||
* [sass-embedded]: https://www.npmjs.com/package/sass-embedded
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* const sass = require('sass');
|
||||
*
|
||||
* const result = sass.compileString(`
|
||||
* h1 {
|
||||
* font-size: 40px;
|
||||
* code {
|
||||
* font-face: Roboto Mono;
|
||||
* }
|
||||
* }`);
|
||||
* console.log(result.css);
|
||||
* ```
|
||||
*
|
||||
* @category Compile
|
||||
* @compatibility dart: "1.45.0", node: false
|
||||
*/
|
||||
export function compileString(
|
||||
source: string,
|
||||
options?: StringOptions<'sync'>
|
||||
): CompileResult;
|
||||
|
||||
/**
|
||||
* Asynchronously compiles a stylesheet whose contents is `source` to CSS.
|
||||
* Returns a promise that resolves with a {@link CompileResult} if it succeeds
|
||||
* and rejects with an {@link Exception} if it fails.
|
||||
*
|
||||
* This only allows synchronous or asynchronous {@link Importer}s and {@link
|
||||
* CustomFunction}s.
|
||||
*
|
||||
* **Heads up!** When using the `sass` npm package, **{@link compileString} is
|
||||
* almost twice as fast as {@link compileStringAsync}**, due to the overhead
|
||||
* of making the entire evaluation process asynchronous.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* const sass = require('sass');
|
||||
*
|
||||
* const result = await sass.compileStringAsync(`
|
||||
* h1 {
|
||||
* font-size: 40px;
|
||||
* code {
|
||||
* font-face: Roboto Mono;
|
||||
* }
|
||||
* }`);
|
||||
* console.log(result.css);
|
||||
* ```
|
||||
*
|
||||
* @category Compile
|
||||
* @compatibility dart: "1.45.0", node: false
|
||||
*/
|
||||
export function compileStringAsync(
|
||||
source: string,
|
||||
options?: StringOptions<'async'>
|
||||
): Promise<CompileResult>;
|
||||
|
||||
/**
|
||||
* Creates a synchronous {@link Compiler}. Each compiler instance exposes the
|
||||
* {@link compile} and {@link compileString} methods within the lifespan of the
|
||||
* Compiler. Given identical input, these methods will return results identical
|
||||
* to their counterparts exposed at the module root. To use asynchronous
|
||||
* compilation, use {@link initAsyncCompiler}.
|
||||
*
|
||||
* When calling the compile functions multiple times, using a compiler instance
|
||||
* with the [sass-embedded] npm package is much faster than using the top-level
|
||||
* compilation methods or the [sass] npm package.
|
||||
*
|
||||
* [sass-embedded]: https://www.npmjs.com/package/sass-embedded
|
||||
*
|
||||
* [sass]: https://www.npmjs.com/package/sass
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* const sass = require('sass');
|
||||
* function setup() {
|
||||
* const compiler = sass.initCompiler();
|
||||
* const result1 = compiler.compileString('a {b: c}').css;
|
||||
* const result2 = compiler.compileString('a {b: c}').css;
|
||||
* compiler.dispose();
|
||||
*
|
||||
* // throws error
|
||||
* const result3 = sass.compileString('a {b: c}').css;
|
||||
* }
|
||||
* ```
|
||||
* @category Compile
|
||||
* @compatibility dart: "1.70.0", node: false
|
||||
*/
|
||||
export function initCompiler(): Compiler;
|
||||
|
||||
/**
|
||||
* Creates an asynchronous {@link AsyncCompiler}. Each compiler
|
||||
* instance exposes the {@link compileAsync} and {@link compileStringAsync}
|
||||
* methods within the lifespan of the Compiler. Given identical input, these
|
||||
* methods will return results identical to their counterparts exposed at the
|
||||
* module root. To use synchronous compilation, use {@link initCompiler};
|
||||
*
|
||||
* When calling the compile functions multiple times, using a compiler instance
|
||||
* with the [sass-embedded] npm package is much faster than using the top-level
|
||||
* compilation methods or the [sass] npm package.
|
||||
*
|
||||
* [sass-embedded]: https://www.npmjs.com/package/sass-embedded
|
||||
*
|
||||
* [sass]: https://www.npmjs.com/package/sass
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* const sass = require('sass');
|
||||
* async function setup() {
|
||||
* const compiler = await sass.initAsyncCompiler();
|
||||
* const result1 = await compiler.compileStringAsync('a {b: c}').css;
|
||||
* const result2 = await compiler.compileStringAsync('a {b: c}').css;
|
||||
* await compiler.dispose();
|
||||
*
|
||||
* // throws error
|
||||
* const result3 = await sass.compileStringAsync('a {b: c}').css;
|
||||
* }
|
||||
* ```
|
||||
* @category Compile
|
||||
* @compatibility dart: "1.70.0", node: false
|
||||
*/
|
||||
export function initAsyncCompiler(): Promise<AsyncCompiler>;
|
||||
290
node_modules/sass/types/deprecations.d.ts
generated
vendored
Normal file
290
node_modules/sass/types/deprecations.d.ts
generated
vendored
Normal file
@@ -0,0 +1,290 @@
|
||||
/**
|
||||
* All of the deprecation types currently used by Sass.
|
||||
*
|
||||
* Any of these IDs or the deprecation objects they point to can be passed to
|
||||
* `fatalDeprecations`, `futureDeprecations`, or `silenceDeprecations`.
|
||||
*/
|
||||
export interface Deprecations {
|
||||
// START AUTOGENERATED LIST
|
||||
// Checksum: 0d3df25297a4e76b865aee1e908baf355e26d665
|
||||
|
||||
/**
|
||||
* Deprecation for passing a string directly to meta.call().
|
||||
*
|
||||
* This deprecation was active in the first version of Dart Sass.
|
||||
*/
|
||||
'call-string': Deprecation<'call-string'>;
|
||||
|
||||
/**
|
||||
* Deprecation for @elseif.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.3.2.
|
||||
*/
|
||||
elseif: Deprecation<'elseif'>;
|
||||
|
||||
/**
|
||||
* Deprecation for @-moz-document.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.7.2.
|
||||
*/
|
||||
'moz-document': Deprecation<'moz-document'>;
|
||||
|
||||
/**
|
||||
* Deprecation for imports using relative canonical URLs.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.14.2.
|
||||
*/
|
||||
'relative-canonical': Deprecation<'relative-canonical'>;
|
||||
|
||||
/**
|
||||
* Deprecation for declaring new variables with !global.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.17.2.
|
||||
*/
|
||||
'new-global': Deprecation<'new-global'>;
|
||||
|
||||
/**
|
||||
* Deprecation for using color module functions in place of plain CSS functions.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.23.0.
|
||||
*/
|
||||
'color-module-compat': Deprecation<'color-module-compat'>;
|
||||
|
||||
/**
|
||||
* Deprecation for / operator for division.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.33.0.
|
||||
*/
|
||||
'slash-div': Deprecation<'slash-div'>;
|
||||
|
||||
/**
|
||||
* Deprecation for leading, trailing, and repeated combinators.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.54.0.
|
||||
*/
|
||||
'bogus-combinators': Deprecation<'bogus-combinators'>;
|
||||
|
||||
/**
|
||||
* Deprecation for ambiguous + and - operators.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.55.0.
|
||||
*/
|
||||
'strict-unary': Deprecation<'strict-unary'>;
|
||||
|
||||
/**
|
||||
* Deprecation for passing invalid units to built-in functions.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.56.0.
|
||||
*/
|
||||
'function-units': Deprecation<'function-units'>;
|
||||
|
||||
/**
|
||||
* Deprecation for using !default or !global multiple times for one variable.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.62.0.
|
||||
*/
|
||||
'duplicate-var-flags': Deprecation<'duplicate-var-flags'>;
|
||||
|
||||
/**
|
||||
* Deprecation for passing null as alpha in the JS API.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.62.3.
|
||||
*/
|
||||
'null-alpha': Deprecation<'null-alpha'>;
|
||||
|
||||
/**
|
||||
* Deprecation for passing percentages to the Sass abs() function.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.65.0.
|
||||
*/
|
||||
'abs-percent': Deprecation<'abs-percent'>;
|
||||
|
||||
/**
|
||||
* Deprecation for using the current working directory as an implicit load path.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.73.0.
|
||||
*/
|
||||
'fs-importer-cwd': Deprecation<'fs-importer-cwd'>;
|
||||
|
||||
/**
|
||||
* Deprecation for function and mixin names beginning with --.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.76.0.
|
||||
*/
|
||||
'css-function-mixin': Deprecation<'css-function-mixin'>;
|
||||
|
||||
/**
|
||||
* Deprecation for declarations after or between nested rules.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.77.7.
|
||||
* It became obsolete in Dart Sass 1.92.0.
|
||||
*/
|
||||
'mixed-decls': Deprecation<'mixed-decls'>;
|
||||
|
||||
/**
|
||||
* Deprecation for meta.feature-exists
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.78.0.
|
||||
*/
|
||||
'feature-exists': Deprecation<'feature-exists'>;
|
||||
|
||||
/**
|
||||
* Deprecation for certain uses of built-in sass:color functions.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.79.0.
|
||||
*/
|
||||
'color-4-api': Deprecation<'color-4-api'>;
|
||||
|
||||
/**
|
||||
* Deprecation for using global color functions instead of sass:color.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.79.0.
|
||||
*/
|
||||
'color-functions': Deprecation<'color-functions'>;
|
||||
|
||||
/**
|
||||
* Deprecation for legacy JS API.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.79.0.
|
||||
*/
|
||||
'legacy-js-api': Deprecation<'legacy-js-api'>;
|
||||
|
||||
/**
|
||||
* Deprecation for @import rules.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.80.0.
|
||||
*/
|
||||
import: Deprecation<'import'>;
|
||||
|
||||
/**
|
||||
* Deprecation for global built-in functions that are available in sass: modules.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.80.0.
|
||||
*/
|
||||
'global-builtin': Deprecation<'global-builtin'>;
|
||||
|
||||
/**
|
||||
* Deprecation for functions named "type".
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.86.0.
|
||||
* It became obsolete in Dart Sass 1.92.0.
|
||||
*/
|
||||
'type-function': Deprecation<'type-function'>;
|
||||
|
||||
/**
|
||||
* Deprecation for passing a relative url to compileString().
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.88.0.
|
||||
*/
|
||||
'compile-string-relative-url': Deprecation<'compile-string-relative-url'>;
|
||||
|
||||
/**
|
||||
* Deprecation for a rest parameter before a positional or named parameter.
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.91.0.
|
||||
*/
|
||||
'misplaced-rest': Deprecation<'misplaced-rest'>;
|
||||
|
||||
/**
|
||||
* Deprecation for configuring private variables in @use, @forward, or load-css().
|
||||
*
|
||||
* This deprecation became active in Dart Sass 1.92.0.
|
||||
*/
|
||||
'with-private': Deprecation<'with-private'>;
|
||||
|
||||
// END AUTOGENERATED LIST
|
||||
|
||||
/**
|
||||
* Used for any user-emitted deprecation warnings.
|
||||
*/
|
||||
'user-authored': Deprecation<'user-authored', 'user'>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Either a deprecation or its ID, either of which can be passed to any of
|
||||
* the relevant compiler options.
|
||||
*
|
||||
* @category Messages
|
||||
* @compatibility dart: "1.74.0", node: false
|
||||
*/
|
||||
export type DeprecationOrId = Deprecation | keyof Deprecations;
|
||||
|
||||
/**
|
||||
* The possible statuses that each deprecation can have.
|
||||
*
|
||||
* "active" deprecations are currently emitting deprecation warnings.
|
||||
* "future" deprecations are not yet active, but will be in the future.
|
||||
* "obsolete" deprecations were once active, but no longer are.
|
||||
*
|
||||
* The only "user" deprecation is "user-authored", which is used for deprecation
|
||||
* warnings coming from user code.
|
||||
*
|
||||
* @category Messages
|
||||
* @compatibility dart: "1.74.0", node: false
|
||||
*/
|
||||
export type DeprecationStatus = 'active' | 'user' | 'future' | 'obsolete';
|
||||
|
||||
/**
|
||||
* A deprecated feature in the language.
|
||||
*
|
||||
* @category Messages
|
||||
* @compatibility dart: "1.74.0", node: false
|
||||
*/
|
||||
export interface Deprecation<
|
||||
id extends keyof Deprecations = keyof Deprecations,
|
||||
status extends DeprecationStatus = DeprecationStatus
|
||||
> {
|
||||
/** The unique ID of this deprecation. */
|
||||
id: id;
|
||||
|
||||
/** The current status of this deprecation. */
|
||||
status: status;
|
||||
|
||||
/** A human-readable description of this deprecation. */
|
||||
description?: string;
|
||||
|
||||
/** The version this deprecation first became active in. */
|
||||
deprecatedIn: status extends 'future' | 'user' ? null : Version;
|
||||
|
||||
/** The version this deprecation became obsolete in. */
|
||||
obsoleteIn: status extends 'obsolete' ? Version : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A semantic version of the compiler.
|
||||
*
|
||||
* @category Messages
|
||||
* @compatibility dart: "1.74.0", node: false
|
||||
*/
|
||||
export class Version {
|
||||
/**
|
||||
* Constructs a new version.
|
||||
*
|
||||
* All components must be non-negative integers.
|
||||
*
|
||||
* @param major - The major version.
|
||||
* @param minor - The minor version.
|
||||
* @param patch - The patch version.
|
||||
*/
|
||||
constructor(major: number, minor: number, patch: number);
|
||||
readonly major: number;
|
||||
readonly minor: number;
|
||||
readonly patch: number;
|
||||
|
||||
/**
|
||||
* Parses a version from a string.
|
||||
*
|
||||
* This throws an error if a valid version can't be parsed.
|
||||
*
|
||||
* @param version - A string in the form "major.minor.patch".
|
||||
*/
|
||||
static parse(version: string): Version;
|
||||
}
|
||||
|
||||
/**
|
||||
* An object containing all deprecation types.
|
||||
*
|
||||
* @category Messages
|
||||
* @compatibility dart: "1.74.0", node: false
|
||||
*/
|
||||
export const deprecations: Deprecations;
|
||||
41
node_modules/sass/types/exception.d.ts
generated
vendored
Normal file
41
node_modules/sass/types/exception.d.ts
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
import {SourceSpan} from './logger';
|
||||
|
||||
/**
|
||||
* An exception thrown because a Sass compilation failed.
|
||||
*
|
||||
* @category Other
|
||||
*/
|
||||
export class Exception extends Error {
|
||||
private constructor();
|
||||
|
||||
/**
|
||||
* A human-friendly representation of the exception.
|
||||
*
|
||||
* Because many tools simply print `Error.message` directly, this includes not
|
||||
* only the textual description of what went wrong (the {@link sassMessage})
|
||||
* but also an indication of where in the Sass stylesheet the error occurred
|
||||
* (the {@link span}) and the Sass stack trace at the point of error (the
|
||||
* {@link sassStack}).
|
||||
*/
|
||||
message: string;
|
||||
|
||||
/**
|
||||
* A textual description of what went wrong.
|
||||
*
|
||||
* Unlike {@link message}, this does *not* include representations of {@link
|
||||
* span} or {@link sassStack}.
|
||||
*/
|
||||
readonly sassMessage: string;
|
||||
|
||||
/**
|
||||
* A human-friendly representation of the Sass stack trace at the point of
|
||||
* error.
|
||||
*/
|
||||
readonly sassStack: string;
|
||||
|
||||
/** The location the error occurred in the Sass file that triggered it. */
|
||||
readonly span: SourceSpan;
|
||||
|
||||
/** Returns the same string as {@link message}. */
|
||||
toString(): string;
|
||||
}
|
||||
471
node_modules/sass/types/importer.d.ts
generated
vendored
Normal file
471
node_modules/sass/types/importer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,471 @@
|
||||
import {Syntax} from './options';
|
||||
import {PromiseOr} from './util/promise_or';
|
||||
|
||||
/**
|
||||
* Contextual information passed to {@link Importer.canonicalize} and {@link
|
||||
* FileImporter.findFileUrl}. Not all importers will need this information to
|
||||
* resolve loads, but some may find it useful.
|
||||
*/
|
||||
export interface CanonicalizeContext {
|
||||
/**
|
||||
* Whether this is being invoked because of a Sass
|
||||
* `@import` rule, as opposed to a `@use` or `@forward` rule.
|
||||
*
|
||||
* This should *only* be used for determining whether or not to load
|
||||
* [import-only files](https://sass-lang.com/documentation/at-rules/import#import-only-files).
|
||||
*/
|
||||
fromImport: boolean;
|
||||
|
||||
/**
|
||||
* The canonical URL of the file that contains the load, if that information
|
||||
* is available.
|
||||
*
|
||||
* For an {@link Importer}, this is only passed when the `url` parameter is a
|
||||
* relative URL _or_ when its [URL scheme] is included in {@link
|
||||
* Importer.nonCanonicalScheme}. This ensures that canonical URLs are always
|
||||
* resolved the same way regardless of context.
|
||||
*
|
||||
* [URL scheme]: https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Web_mechanics/What_is_a_URL#scheme
|
||||
*
|
||||
* For a {@link FileImporter}, this is always available as long as Sass knows
|
||||
* the canonical URL of the containing file.
|
||||
*/
|
||||
containingUrl: URL | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A special type of importer that redirects all loads to existing files on
|
||||
* disk. Although this is less powerful than a full {@link Importer}, it
|
||||
* automatically takes care of Sass features like resolving partials and file
|
||||
* extensions and of loading the file from disk.
|
||||
*
|
||||
* Like all importers, this implements custom Sass loading logic for [`@use`
|
||||
* rules](https://sass-lang.com/documentation/at-rules/use) and [`@import`
|
||||
* rules](https://sass-lang.com/documentation/at-rules/import). It can be passed
|
||||
* to {@link Options.importers} or {@link StringOptions.importer}.
|
||||
*
|
||||
* @typeParam sync - A `FileImporter<'sync'>`'s {@link findFileUrl} must return
|
||||
* synchronously, but in return it can be passed to {@link compile} and {@link
|
||||
* compileString} in addition to {@link compileAsync} and {@link
|
||||
* compileStringAsync}.
|
||||
*
|
||||
* A `FileImporter<'async'>`'s {@link findFileUrl} may either return
|
||||
* synchronously or asynchronously, but it can only be used with {@link
|
||||
* compileAsync} and {@link compileStringAsync}.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* const {pathToFileURL} = require('url');
|
||||
*
|
||||
* sass.compile('style.scss', {
|
||||
* importers: [{
|
||||
* // An importer that redirects relative URLs starting with "~" to
|
||||
* // `node_modules`.
|
||||
* findFileUrl(url) {
|
||||
* if (!url.startsWith('~')) return null;
|
||||
* return new URL(url.substring(1), pathToFileURL('node_modules'));
|
||||
* }
|
||||
* }]
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @category Importer
|
||||
*/
|
||||
export interface FileImporter<
|
||||
sync extends 'sync' | 'async' = 'sync' | 'async'
|
||||
> {
|
||||
/**
|
||||
* A callback that's called to partially resolve a load (such as
|
||||
* [`@use`](https://sass-lang.com/documentation/at-rules/use) or
|
||||
* [`@import`](https://sass-lang.com/documentation/at-rules/import)) to a file
|
||||
* on disk.
|
||||
*
|
||||
* Unlike an {@link Importer}, the compiler will automatically handle relative
|
||||
* loads for a {@link FileImporter}. See {@link Options.importers} for more
|
||||
* details on the way loads are resolved.
|
||||
*
|
||||
* @param url - The loaded URL. Since this might be relative, it's represented
|
||||
* as a string rather than a {@link URL} object.
|
||||
*
|
||||
* @returns An absolute `file:` URL if this importer recognizes the `url`.
|
||||
* This may be only partially resolved: the compiler will automatically look
|
||||
* for [partials](https://sass-lang.com/documentation/at-rules/use#partials),
|
||||
* [index files](https://sass-lang.com/documentation/at-rules/use#index-files),
|
||||
* and file extensions based on the returned URL. An importer may also return
|
||||
* a fully resolved URL if it so chooses.
|
||||
*
|
||||
* If this importer doesn't recognize the URL, it should return `null` instead
|
||||
* to allow other importers or {@link Options.loadPaths | load paths} to
|
||||
* handle it.
|
||||
*
|
||||
* This may also return a `Promise`, but if it does the importer may only be
|
||||
* passed to {@link compileAsync} and {@link compileStringAsync}, not {@link
|
||||
* compile} or {@link compileString}.
|
||||
*
|
||||
* @throws any - If this importer recognizes `url` but determines that it's
|
||||
* invalid, it may throw an exception that will be wrapped by Sass. If the
|
||||
* exception object has a `message` property, it will be used as the wrapped
|
||||
* exception's message; otherwise, the exception object's `toString()` will be
|
||||
* used. This means it's safe for importers to throw plain strings.
|
||||
*/
|
||||
findFileUrl(
|
||||
url: string,
|
||||
context: CanonicalizeContext
|
||||
): PromiseOr<URL | null, sync>;
|
||||
|
||||
/** @hidden */
|
||||
canonicalize?: never;
|
||||
}
|
||||
|
||||
/**
|
||||
* An object that implements custom Sass loading logic for [`@use`
|
||||
* rules](https://sass-lang.com/documentation/at-rules/use) and [`@import`
|
||||
* rules](https://sass-lang.com/documentation/at-rules/import). It can be passed
|
||||
* to {@link Options.importers} or {@link StringOptions.importer}.
|
||||
*
|
||||
* Importers that simply redirect to files on disk are encouraged to use the
|
||||
* {@link FileImporter} interface instead.
|
||||
*
|
||||
* ### Resolving a Load
|
||||
*
|
||||
* This is the process of resolving a load using a custom importer:
|
||||
*
|
||||
* - The compiler encounters `@use "db:foo/bar/baz"`.
|
||||
* - It calls {@link canonicalize} with `"db:foo/bar/baz"`.
|
||||
* - {@link canonicalize} returns `new URL("db:foo/bar/baz/_index.scss")`.
|
||||
* - If the compiler has already loaded a stylesheet with this canonical URL, it
|
||||
* re-uses the existing module.
|
||||
* - Otherwise, it calls {@link load} with `new
|
||||
* URL("db:foo/bar/baz/_index.scss")`.
|
||||
* - {@link load} returns an {@link ImporterResult} that the compiler uses as
|
||||
* the contents of the module.
|
||||
*
|
||||
* See {@link Options.importers} for more details on the way loads are resolved
|
||||
* using multiple importers and load paths.
|
||||
*
|
||||
* @typeParam sync - An `Importer<'sync'>`'s {@link canonicalize} and {@link
|
||||
* load} must return synchronously, but in return it can be passed to {@link
|
||||
* compile} and {@link compileString} in addition to {@link compileAsync} and
|
||||
* {@link compileStringAsync}.
|
||||
*
|
||||
* An `Importer<'async'>`'s {@link canonicalize} and {@link load} may either
|
||||
* return synchronously or asynchronously, but it can only be used with {@link
|
||||
* compileAsync} and {@link compileStringAsync}.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* sass.compile('style.scss', {
|
||||
* // An importer for URLs like `bgcolor:orange` that generates a
|
||||
* // stylesheet with the given background color.
|
||||
* importers: [{
|
||||
* canonicalize(url) {
|
||||
* if (!url.startsWith('bgcolor:')) return null;
|
||||
* return new URL(url);
|
||||
* },
|
||||
* load(canonicalUrl) {
|
||||
* return {
|
||||
* contents: `body {background-color: ${canonicalUrl.pathname}}`,
|
||||
* syntax: 'scss'
|
||||
* };
|
||||
* }
|
||||
* }]
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @category Importer
|
||||
*/
|
||||
export interface Importer<sync extends 'sync' | 'async' = 'sync' | 'async'> {
|
||||
/**
|
||||
* If `url` is recognized by this importer, returns its canonical format.
|
||||
*
|
||||
* If Sass has already loaded a stylesheet with the returned canonical URL, it
|
||||
* re-uses the existing parse tree (and the loaded module for `@use`). This
|
||||
* means that importers **must ensure** that the same canonical URL always
|
||||
* refers to the same stylesheet, *even across different importers*. As such,
|
||||
* importers are encouraged to use unique URL schemes to disambiguate between
|
||||
* one another.
|
||||
*
|
||||
* As much as possible, custom importers should canonicalize URLs the same way
|
||||
* as the built-in filesystem importer:
|
||||
*
|
||||
* - The importer should look for stylesheets by adding the prefix `_` to the
|
||||
* URL's basename, and by adding the extensions `.sass` and `.scss` if the
|
||||
* URL doesn't already have one of those extensions. For example, if the
|
||||
* URL was `foo/bar/baz`, the importer would look for:
|
||||
* - `foo/bar/baz.sass`
|
||||
* - `foo/bar/baz.scss`
|
||||
* - `foo/bar/_baz.sass`
|
||||
* - `foo/bar/_baz.scss`
|
||||
*
|
||||
* If the URL was `foo/bar/baz.scss`, the importer would just look for:
|
||||
* - `foo/bar/baz.scss`
|
||||
* - `foo/bar/_baz.scss`
|
||||
*
|
||||
* If the importer finds a stylesheet at more than one of these URLs, it
|
||||
* should throw an exception indicating that the URL is ambiguous. Note that
|
||||
* if the extension is explicitly specified, a stylesheet with the opposite
|
||||
* extension is allowed to exist.
|
||||
*
|
||||
* - If none of the possible paths is valid, the importer should perform the
|
||||
* same resolution on the URL followed by `/index`. In the example above,
|
||||
* it would look for:
|
||||
* - `foo/bar/baz/index.sass`
|
||||
* - `foo/bar/baz/index.scss`
|
||||
* - `foo/bar/baz/_index.sass`
|
||||
* - `foo/bar/baz/_index.scss`
|
||||
*
|
||||
* As above, if the importer finds a stylesheet at more than one of these
|
||||
* URLs, it should throw an exception indicating that the import is
|
||||
* ambiguous.
|
||||
*
|
||||
* If no stylesheets are found, the importer should return `null`.
|
||||
*
|
||||
* Calling {@link canonicalize} multiple times with the same URL must return
|
||||
* the same result. Calling {@link canonicalize} with a URL returned by a
|
||||
* previous call to {@link canonicalize} must return that URL.
|
||||
*
|
||||
* #### Relative URLs
|
||||
*
|
||||
* Relative loads in stylesheets loaded from an importer are first resolved
|
||||
* relative to the canonical URL of the stylesheet that contains it and passed
|
||||
* back to the {@link canonicalize} method for the local importer that loaded
|
||||
* that stylesheet. For example, suppose the "Resolving a Load" example {@link
|
||||
* Importer | above} returned a stylesheet that contained `@use "mixins"`:
|
||||
*
|
||||
* - The compiler resolves the URL `mixins` relative to the current
|
||||
* stylesheet's canonical URL `db:foo/bar/baz/_index.scss` to get
|
||||
* `db:foo/bar/baz/mixins`.
|
||||
* - It calls {@link canonicalize} with `"db:foo/bar/baz/mixins"`.
|
||||
* - {@link canonicalize} returns `new URL("db:foo/bar/baz/_mixins.scss")`.
|
||||
*
|
||||
* Because of this, {@link canonicalize} must return a meaningful result when
|
||||
* called with a URL relative to one returned by an earlier call to {@link
|
||||
* canonicalize}.
|
||||
*
|
||||
* If the local importer's `canonicalize` method returns `null`, the relative
|
||||
* URL is then passed to each of {@link Options.importers}' `canonicalize()`
|
||||
* methods in turn until one returns a canonical URL. If none of them do, the
|
||||
* load fails.
|
||||
*
|
||||
* @param url - The loaded URL. Since this might be relative, it's represented
|
||||
* as a string rather than a {@link URL} object.
|
||||
*
|
||||
* @returns An absolute URL if this importer recognizes the `url`, or `null`
|
||||
* if it doesn't. If this returns `null`, other importers or {@link
|
||||
* Options.loadPaths | load paths} may handle the load.
|
||||
*
|
||||
* This may also return a `Promise`, but if it does the importer may only be
|
||||
* passed to {@link compileAsync} and {@link compileStringAsync}, not {@link
|
||||
* compile} or {@link compileString}.
|
||||
*
|
||||
* @throws any - If this importer recognizes `url` but determines that it's
|
||||
* invalid, it may throw an exception that will be wrapped by Sass. If the
|
||||
* exception object has a `message` property, it will be used as the wrapped
|
||||
* exception's message; otherwise, the exception object's `toString()` will be
|
||||
* used. This means it's safe for importers to throw plain strings.
|
||||
*/
|
||||
canonicalize(
|
||||
url: string,
|
||||
context: CanonicalizeContext
|
||||
): PromiseOr<URL | null, sync>;
|
||||
|
||||
/**
|
||||
* Loads the Sass text for the given `canonicalUrl`, or returns `null` if this
|
||||
* importer can't find the stylesheet it refers to.
|
||||
*
|
||||
* @param canonicalUrl - The canonical URL of the stylesheet to load. This is
|
||||
* guaranteed to come from a call to {@link canonicalize}, although not every
|
||||
* call to {@link canonicalize} will result in a call to {@link load}.
|
||||
*
|
||||
* @returns The contents of the stylesheet at `canonicalUrl` if it can be
|
||||
* loaded, or `null` if it can't.
|
||||
*
|
||||
* This may also return a `Promise`, but if it does the importer may only be
|
||||
* passed to {@link compileAsync} and {@link compileStringAsync}, not {@link
|
||||
* compile} or {@link compileString}.
|
||||
*
|
||||
* @throws any - If this importer finds a stylesheet at `url` but it fails to
|
||||
* load for some reason, or if `url` is uniquely associated with this importer
|
||||
* but doesn't refer to a real stylesheet, the importer may throw an exception
|
||||
* that will be wrapped by Sass. If the exception object has a `message`
|
||||
* property, it will be used as the wrapped exception's message; otherwise,
|
||||
* the exception object's `toString()` will be used. This means it's safe for
|
||||
* importers to throw plain strings.
|
||||
*/
|
||||
load(canonicalUrl: URL): PromiseOr<ImporterResult | null, sync>;
|
||||
|
||||
/** @hidden */
|
||||
findFileUrl?: never;
|
||||
|
||||
/**
|
||||
* A URL scheme or set of schemes (without the `:`) that this importer
|
||||
* promises never to use for URLs returned by {@link canonicalize}. If it does
|
||||
* return a URL with one of these schemes, that's an error.
|
||||
*
|
||||
* If this is set, any call to canonicalize for a URL with a non-canonical
|
||||
* scheme will be passed {@link CanonicalizeContext.containingUrl} if it's
|
||||
* known.
|
||||
*
|
||||
* These schemes may only contain lowercase ASCII letters, ASCII numerals,
|
||||
* `+`, `-`, and `.`. They may not be empty.
|
||||
*/
|
||||
nonCanonicalScheme?: string | string[];
|
||||
}
|
||||
|
||||
declare const nodePackageImporterKey: unique symbol;
|
||||
|
||||
/**
|
||||
* The built-in Node.js package importer. This loads pkg: URLs from node_modules
|
||||
* according to the standard Node.js resolution algorithm.
|
||||
*
|
||||
* A Node.js package importer is exposed as a class that can be added to the
|
||||
* `importers` option.
|
||||
*
|
||||
*```js
|
||||
* const sass = require('sass');
|
||||
* sass.compileString('@use "pkg:vuetify', {
|
||||
* importers: [new sass.NodePackageImporter()]
|
||||
* });
|
||||
*```
|
||||
*
|
||||
* ## Writing Sass packages
|
||||
*
|
||||
* Package authors can control what is exposed to their users through their
|
||||
* `package.json` manifest. The recommended method is to add a `sass`
|
||||
* conditional export to `package.json`.
|
||||
*
|
||||
* ```json
|
||||
* // node_modules/uicomponents/package.json
|
||||
* {
|
||||
* "exports": {
|
||||
* ".": {
|
||||
* "sass": "./src/scss/index.scss",
|
||||
* "import": "./dist/js/index.mjs",
|
||||
* "default": "./dist/js/index.js"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* This allows a package user to write `@use "pkg:uicomponents"` to load the
|
||||
* file at `node_modules/uicomponents/src/scss/index.scss`.
|
||||
*
|
||||
* The Node.js package importer supports the variety of formats supported by
|
||||
* Node.js [package entry points], allowing authors to expose multiple subpaths.
|
||||
*
|
||||
* [package entry points]:
|
||||
* https://nodejs.org/api/packages.html#package-entry-points
|
||||
*
|
||||
* ```json
|
||||
* // node_modules/uicomponents/package.json
|
||||
* {
|
||||
* "exports": {
|
||||
* ".": {
|
||||
* "sass": "./src/scss/index.scss",
|
||||
* },
|
||||
* "./colors.scss": {
|
||||
* "sass": "./src/scss/_colors.scss",
|
||||
* },
|
||||
* "./theme/*.scss": {
|
||||
* "sass": "./src/scss/theme/*.scss",
|
||||
* },
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* This allows a package user to write:
|
||||
*
|
||||
* - `@use "pkg:uicomponents";` to import the root export.
|
||||
* - `@use "pkg:uicomponents/colors";` to import the colors partial.
|
||||
* - `@use "pkg:uicomponents/theme/purple";` to import a purple theme.
|
||||
*
|
||||
* Note that while library users can rely on the importer to resolve
|
||||
* [partials](https://sass-lang.com/documentation/at-rules/use#partials), [index
|
||||
* files](https://sass-lang.com/documentation/at-rules/use#index-files), and
|
||||
* extensions, library authors must specify the entire file path in `exports`.
|
||||
*
|
||||
* In addition to the `sass` condition, the `style` condition is also
|
||||
* acceptable. Sass will match the `default` condition if it's a relevant file
|
||||
* type, but authors are discouraged from relying on this. Notably, the key
|
||||
* order matters, and the importer will resolve to the first value with a key
|
||||
* that is `sass`, `style`, or `default`, so you should always put `default`
|
||||
* last.
|
||||
*
|
||||
* To help package authors who haven't transitioned to package entry points
|
||||
* using the `exports` field, the Node.js package importer provides several
|
||||
* fallback options. If the `pkg:` URL does not have a subpath, the Node.js
|
||||
* package importer will look for a `sass` or `style` key at the root of
|
||||
* `package.json`.
|
||||
*
|
||||
* ```json
|
||||
* // node_modules/uicomponents/package.json
|
||||
* {
|
||||
* "sass": "./src/scss/index.scss",
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* This allows a user to write `@use "pkg:uicomponents";` to import the
|
||||
* `index.scss` file.
|
||||
*
|
||||
* Finally, the Node.js package importer will look for an `index` file at the
|
||||
* package root, resolving partials and extensions. For example, if the file
|
||||
* `_index.scss` exists in the package root of `uicomponents`, a user can import
|
||||
* that with `@use "pkg:uicomponents";`.
|
||||
*
|
||||
* If a `pkg:` URL includes a subpath that doesn't have a match in package entry
|
||||
* points, the Node.js importer will attempt to find that file relative to the
|
||||
* package root, resolving for file extensions, partials and index files. For
|
||||
* example, if the file `src/sass/_colors.scss` exists in the `uicomponents`
|
||||
* package, a user can import that file using `@use
|
||||
* "pkg:uicomponents/src/sass/colors";`.
|
||||
*
|
||||
* @compatibility dart: "1.71.0", node: false
|
||||
* @category Importer
|
||||
*/
|
||||
export class NodePackageImporter {
|
||||
/** Used to distinguish this type from any arbitrary object. */
|
||||
private readonly [nodePackageImporterKey]: true;
|
||||
|
||||
/**
|
||||
* The NodePackageImporter has an optional `entryPointDirectory` option, which
|
||||
* is the directory where the Node Package Importer should start when
|
||||
* resolving `pkg:` URLs in sources other than files on disk. This will be
|
||||
* used as the `parentURL` in the [Node Module
|
||||
* Resolution](https://nodejs.org/api/esm.html#resolution-algorithm-specification)
|
||||
* algorithm.
|
||||
*
|
||||
* In order to be found by the Node Package Importer, a package will need to
|
||||
* be inside a node_modules folder located in the `entryPointDirectory`, or
|
||||
* one of its parent directories, up to the filesystem root.
|
||||
*
|
||||
* Relative paths will be resolved relative to the current working directory.
|
||||
* If a path is not provided, this defaults to the parent directory of the
|
||||
* Node.js entrypoint. If that's not available, this will throw an error.
|
||||
*/
|
||||
constructor(entryPointDirectory?: string);
|
||||
}
|
||||
|
||||
/**
|
||||
* The result of successfully loading a stylesheet with an {@link Importer}.
|
||||
*
|
||||
* @category Importer
|
||||
*/
|
||||
export interface ImporterResult {
|
||||
/** The contents of the stylesheet. */
|
||||
contents: string;
|
||||
|
||||
/** The syntax with which to parse {@link contents}. */
|
||||
syntax: Syntax;
|
||||
|
||||
/**
|
||||
* The URL to use to link to the loaded stylesheet's source code in source
|
||||
* maps. A `file:` URL is ideal because it's accessible to both browsers and
|
||||
* other build tools, but an `http:` URL is also acceptable.
|
||||
*
|
||||
* If this isn't set, it defaults to a `data:` URL that contains the contents
|
||||
* of the loaded stylesheet.
|
||||
*/
|
||||
sourceMapUrl?: URL;
|
||||
}
|
||||
122
node_modules/sass/types/index.d.ts
generated
vendored
Normal file
122
node_modules/sass/types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
// This is a mirror of the JS API definitions in `spec/js-api`, but with comments
|
||||
// written to provide user-facing documentation rather than to specify behavior for
|
||||
// implementations.
|
||||
|
||||
export {
|
||||
AsyncCompiler,
|
||||
CompileResult,
|
||||
Compiler,
|
||||
compile,
|
||||
compileAsync,
|
||||
compileString,
|
||||
compileStringAsync,
|
||||
initCompiler,
|
||||
initAsyncCompiler,
|
||||
} from './compile';
|
||||
export {
|
||||
deprecations,
|
||||
Deprecation,
|
||||
Deprecations,
|
||||
DeprecationOrId,
|
||||
DeprecationStatus,
|
||||
Version,
|
||||
} from './deprecations';
|
||||
export {Exception} from './exception';
|
||||
export {
|
||||
CanonicalizeContext,
|
||||
FileImporter,
|
||||
Importer,
|
||||
ImporterResult,
|
||||
NodePackageImporter,
|
||||
} from './importer';
|
||||
export {Logger, LoggerWarnOptions, SourceSpan, SourceLocation} from './logger';
|
||||
export {
|
||||
CustomFunction,
|
||||
Options,
|
||||
OutputStyle,
|
||||
StringOptions,
|
||||
StringOptionsWithImporter,
|
||||
StringOptionsWithoutImporter,
|
||||
Syntax,
|
||||
} from './options';
|
||||
export {PromiseOr} from './util/promise_or';
|
||||
export {
|
||||
CalculationInterpolation,
|
||||
CalculationOperation,
|
||||
CalculationOperator,
|
||||
CalculationValue,
|
||||
ChannelName,
|
||||
ChannelNameHsl,
|
||||
ChannelNameHwb,
|
||||
ChannelNameLch,
|
||||
ChannelNameLab,
|
||||
ChannelNameRgb,
|
||||
ChannelNameXyz,
|
||||
ColorSpaceHsl,
|
||||
ColorSpaceHwb,
|
||||
ColorSpaceLch,
|
||||
ColorSpaceLab,
|
||||
ColorSpaceRgb,
|
||||
ColorSpaceXyz,
|
||||
GamutMapMethod,
|
||||
HueInterpolationMethod,
|
||||
KnownColorSpace,
|
||||
ListSeparator,
|
||||
PolarColorSpace,
|
||||
RectangularColorSpace,
|
||||
SassArgumentList,
|
||||
SassBoolean,
|
||||
SassCalculation,
|
||||
SassColor,
|
||||
SassFunction,
|
||||
SassList,
|
||||
SassMap,
|
||||
SassMixin,
|
||||
SassNumber,
|
||||
SassString,
|
||||
Value,
|
||||
sassFalse,
|
||||
sassNull,
|
||||
sassTrue,
|
||||
} from './value';
|
||||
|
||||
// Legacy APIs
|
||||
export {LegacyException} from './legacy/exception';
|
||||
export {
|
||||
FALSE,
|
||||
LegacyAsyncFunction,
|
||||
LegacyAsyncFunctionDone,
|
||||
LegacyFunction,
|
||||
LegacySyncFunction,
|
||||
LegacyValue,
|
||||
NULL,
|
||||
TRUE,
|
||||
types,
|
||||
} from './legacy/function';
|
||||
export {
|
||||
LegacyAsyncImporter,
|
||||
LegacyImporter,
|
||||
LegacyImporterResult,
|
||||
LegacyImporterThis,
|
||||
LegacySyncImporter,
|
||||
} from './legacy/importer';
|
||||
export {
|
||||
LegacySharedOptions,
|
||||
LegacyFileOptions,
|
||||
LegacyStringOptions,
|
||||
LegacyOptions,
|
||||
} from './legacy/options';
|
||||
export {LegacyPluginThis} from './legacy/plugin_this';
|
||||
export {LegacyResult, render, renderSync} from './legacy/render';
|
||||
|
||||
/**
|
||||
* Information about the Sass implementation. This always begins with a unique
|
||||
* identifier for the Sass implementation, followed by U+0009 TAB, followed by
|
||||
* its npm package version. Some implementations include additional information
|
||||
* as well, but not in any standardized format.
|
||||
*
|
||||
* * For Dart Sass, the implementation name is `dart-sass`.
|
||||
* * For Node Sass, the implementation name is `node-sass`.
|
||||
* * For the embedded host, the implementation name is `sass-embedded`.
|
||||
*/
|
||||
export const info: string;
|
||||
55
node_modules/sass/types/legacy/exception.d.ts
generated
vendored
Normal file
55
node_modules/sass/types/legacy/exception.d.ts
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* The exception type thrown by {@link renderSync} and passed as the error to
|
||||
* {@link render}'s callback.
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This is only thrown by the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link compile}, {@link compileString}, {@link
|
||||
* compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
export interface LegacyException extends Error {
|
||||
/**
|
||||
* The error message. For Dart Sass, when possible this includes a highlighted
|
||||
* indication of where in the source file the error occurred as well as the
|
||||
* Sass stack trace.
|
||||
*/
|
||||
message: string;
|
||||
|
||||
/**
|
||||
* The error message. For Dart Sass, this is the same as the result of calling
|
||||
* {@link toString}, which is itself the same as {@link message} but with the
|
||||
* prefix "Error:".
|
||||
*/
|
||||
formatted: string;
|
||||
|
||||
/**
|
||||
* The (1-based) line number on which the error occurred, if this exception is
|
||||
* associated with a specific Sass file location.
|
||||
*/
|
||||
line?: number;
|
||||
|
||||
/**
|
||||
* The (1-based) column number within {@link line} at which the error
|
||||
* occurred, if this exception is associated with a specific Sass file
|
||||
* location.
|
||||
*/
|
||||
column?: number;
|
||||
|
||||
/**
|
||||
* Analogous to the exit code for an executable. `1` for an error caused by a
|
||||
* Sass file, `3` for any other type of error.
|
||||
*/
|
||||
status: number;
|
||||
|
||||
/**
|
||||
* If this exception was caused by an error in a Sass file, this will
|
||||
* represent the Sass file's location. It can be in one of three formats:
|
||||
*
|
||||
* * If the Sass file was loaded from disk, this is the path to that file.
|
||||
* * If the Sass file was generated by an importer, this is its canonical URL.
|
||||
* * If the Sass file was passed as {@link LegacyStringOptions.data} without a
|
||||
* corresponding {@link LegacyStringOptions.file}, this is the special
|
||||
* string `"stdin"`.
|
||||
*/
|
||||
file?: string;
|
||||
}
|
||||
757
node_modules/sass/types/legacy/function.d.ts
generated
vendored
Normal file
757
node_modules/sass/types/legacy/function.d.ts
generated
vendored
Normal file
@@ -0,0 +1,757 @@
|
||||
import {LegacyPluginThis} from './plugin_this';
|
||||
|
||||
/**
|
||||
* A synchronous callback that implements a custom Sass function. This can be
|
||||
* passed to {@link LegacySharedOptions.functions} for either {@link render} or
|
||||
* {@link renderSync}.
|
||||
*
|
||||
* If this throws an error, Sass will treat that as the function failing with
|
||||
* that error message.
|
||||
*
|
||||
* ```js
|
||||
* const result = sass.renderSync({
|
||||
* file: 'style.scss',
|
||||
* functions: {
|
||||
* "sum($arg1, $arg2)": (arg1, arg2) => {
|
||||
* if (!(arg1 instanceof sass.types.Number)) {
|
||||
* throw new Error("$arg1: Expected a number");
|
||||
* } else if (!(arg2 instanceof sass.types.Number)) {
|
||||
* throw new Error("$arg2: Expected a number");
|
||||
* }
|
||||
* return new sass.types.Number(arg1.getValue() + arg2.getValue());
|
||||
* }
|
||||
* }
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param args - One argument for each argument that's declared in the signature
|
||||
* that's passed to {@link LegacySharedOptions.functions}. If the signature
|
||||
* [takes arbitrary
|
||||
* arguments](https://sass-lang.com/documentation/at-rules/function#taking-arbitrary-arguments),
|
||||
* they're passed as a single argument list in the last argument.
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This only works with the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link CustomFunction} with {@link compile}, {@link
|
||||
* compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
export type LegacySyncFunction = (
|
||||
this: LegacyPluginThis,
|
||||
...args: LegacyValue[]
|
||||
) => LegacyValue;
|
||||
|
||||
/**
|
||||
* An asynchronous callback that implements a custom Sass function. This can be
|
||||
* passed to {@link LegacySharedOptions.functions}, but only for {@link render}.
|
||||
*
|
||||
* An asynchronous function must return `undefined`. Its final argument will
|
||||
* always be a callback, which it should call with the result of the function
|
||||
* once it's done running.
|
||||
*
|
||||
* If this throws an error, Sass will treat that as the function failing with
|
||||
* that error message.
|
||||
*
|
||||
* ```js
|
||||
* sass.render({
|
||||
* file: 'style.scss',
|
||||
* functions: {
|
||||
* "sum($arg1, $arg2)": (arg1, arg2, done) => {
|
||||
* if (!(arg1 instanceof sass.types.Number)) {
|
||||
* throw new Error("$arg1: Expected a number");
|
||||
* } else if (!(arg2 instanceof sass.types.Number)) {
|
||||
* throw new Error("$arg2: Expected a number");
|
||||
* }
|
||||
* done(new sass.types.Number(arg1.getValue() + arg2.getValue()));
|
||||
* }
|
||||
* }
|
||||
* }, (result, error) => {
|
||||
* // ...
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* This is passed one argument for each argument that's declared in the
|
||||
* signature that's passed to {@link LegacySharedOptions.functions}. If the
|
||||
* signature [takes arbitrary
|
||||
* arguments](https://sass-lang.com/documentation/at-rules/function#taking-arbitrary-arguments),
|
||||
* they're passed as a single argument list in the last argument before the
|
||||
* callback.
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This only works with the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link CustomFunction} with {@link compile}, {@link
|
||||
* compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
export type LegacyAsyncFunction =
|
||||
| ((this: LegacyPluginThis, done: (result: LegacyValue) => void) => void)
|
||||
| ((
|
||||
this: LegacyPluginThis,
|
||||
arg1: LegacyValue,
|
||||
done: LegacyAsyncFunctionDone
|
||||
) => void)
|
||||
| ((
|
||||
this: LegacyPluginThis,
|
||||
arg1: LegacyValue,
|
||||
arg2: LegacyValue,
|
||||
done: LegacyAsyncFunctionDone
|
||||
) => void)
|
||||
| ((
|
||||
this: LegacyPluginThis,
|
||||
arg1: LegacyValue,
|
||||
arg2: LegacyValue,
|
||||
arg3: LegacyValue,
|
||||
done: LegacyAsyncFunctionDone
|
||||
) => void)
|
||||
| ((
|
||||
this: LegacyPluginThis,
|
||||
arg1: LegacyValue,
|
||||
arg2: LegacyValue,
|
||||
arg3: LegacyValue,
|
||||
arg4: LegacyValue,
|
||||
done: LegacyAsyncFunctionDone
|
||||
) => void)
|
||||
| ((
|
||||
this: LegacyPluginThis,
|
||||
arg1: LegacyValue,
|
||||
arg2: LegacyValue,
|
||||
arg3: LegacyValue,
|
||||
arg4: LegacyValue,
|
||||
arg5: LegacyValue,
|
||||
done: LegacyAsyncFunctionDone
|
||||
) => void)
|
||||
| ((
|
||||
this: LegacyPluginThis,
|
||||
arg1: LegacyValue,
|
||||
arg2: LegacyValue,
|
||||
arg3: LegacyValue,
|
||||
arg4: LegacyValue,
|
||||
arg5: LegacyValue,
|
||||
arg6: LegacyValue,
|
||||
done: LegacyAsyncFunctionDone
|
||||
) => void)
|
||||
| ((
|
||||
this: LegacyPluginThis,
|
||||
...args: [...LegacyValue[], LegacyAsyncFunctionDone]
|
||||
) => void);
|
||||
|
||||
/**
|
||||
* The function called by a {@link LegacyAsyncFunction} to indicate that it's
|
||||
* finished.
|
||||
*
|
||||
* @param result - If this is a {@link LegacyValue}, that indicates that the
|
||||
* function call completed successfully. If it's a {@link types.Error}, that
|
||||
* indicates that the function call failed.
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This only works with the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link CustomFunction} with {@link compile}, {@link
|
||||
* compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
export type LegacyAsyncFunctionDone = (
|
||||
result: LegacyValue | types.Error
|
||||
) => void;
|
||||
|
||||
/**
|
||||
* A callback that implements a custom Sass function. For {@link renderSync},
|
||||
* this must be a {@link LegacySyncFunction} which returns its result directly;
|
||||
* for {@link render}, it may be either a {@link LegacySyncFunction} or a {@link
|
||||
* LegacyAsyncFunction} which calls a callback with its result.
|
||||
*
|
||||
* See {@link LegacySharedOptions.functions} for more details.
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This only works with the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link CustomFunction} with {@link compile}, {@link
|
||||
* compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
export type LegacyFunction<sync extends 'sync' | 'async'> = sync extends 'async'
|
||||
? LegacySyncFunction | LegacyAsyncFunction
|
||||
: LegacySyncFunction;
|
||||
|
||||
/**
|
||||
* A type representing all the possible values that may be passed to or returned
|
||||
* from a {@link LegacyFunction}.
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This only works with the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link Value} with {@link compile}, {@link
|
||||
* compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
export type LegacyValue =
|
||||
| types.Null
|
||||
| types.Number
|
||||
| types.String
|
||||
| types.Boolean
|
||||
| types.Color
|
||||
| types.List
|
||||
| types.Map;
|
||||
|
||||
/**
|
||||
* A shorthand for `sass.types.Boolean.TRUE`.
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This only works with the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link sassTrue} with {@link compile}, {@link
|
||||
* compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
export const TRUE: types.Boolean<true>;
|
||||
|
||||
/**
|
||||
* A shorthand for `sass.types.Boolean.FALSE`.
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This only works with the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link sassFalse} with {@link compile}, {@link
|
||||
* compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
export const FALSE: types.Boolean<false>;
|
||||
|
||||
/**
|
||||
* A shorthand for `sass.types.Null.NULL`.
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This only works with the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link sassNull} with {@link compile}, {@link
|
||||
* compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
export const NULL: types.Null;
|
||||
|
||||
/**
|
||||
* The namespace for value types used in the legacy function API.
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This only works with the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link Value} with {@link compile}, {@link
|
||||
* compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
export namespace types {
|
||||
/**
|
||||
* The class for Sass's singleton [`null`
|
||||
* value](https://sass-lang.com/documentation/values/null). The value itself
|
||||
* can be accessed through the {@link NULL} field.
|
||||
*/
|
||||
export class Null {
|
||||
/** Sass's singleton `null` value. */
|
||||
static readonly NULL: Null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sass's [number type](https://sass-lang.com/documentation/values/numbers).
|
||||
*/
|
||||
export class Number {
|
||||
/**
|
||||
* @param value - The numeric value of the number.
|
||||
*
|
||||
* @param unit - If passed, the number's unit.
|
||||
*
|
||||
* Complex units can be represented as
|
||||
* `<unit>*<unit>*.../<unit>*<unit>*...`, with numerator units on the
|
||||
* left-hand side of the `/` and denominator units on the right. A number
|
||||
* with only numerator units may omit the `/` and the units after it, and a
|
||||
* number with only denominator units may be represented
|
||||
* with no units before the `/`.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```scss
|
||||
* new sass.types.Number(0.5); // == 0.5
|
||||
* new sass.types.Number(10, "px"); // == 10px
|
||||
* new sass.types.Number(10, "px*px"); // == 10px * 1px
|
||||
* new sass.types.Number(10, "px/s"); // == math.div(10px, 1s)
|
||||
* new sass.types.Number(10, "px*px/s*s"); // == 10px * math.div(math.div(1px, 1s), 1s)
|
||||
* ```
|
||||
*/
|
||||
constructor(value: number, unit?: string);
|
||||
|
||||
/**
|
||||
* Returns the value of the number, ignoring units.
|
||||
*
|
||||
* **Heads up!** This means that `96px` and `1in` will return different
|
||||
* values, even though they represent the same length.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* const number = new sass.types.Number(10, "px");
|
||||
* number.getValue(); // 10
|
||||
* ```
|
||||
*/
|
||||
getValue(): number;
|
||||
|
||||
/**
|
||||
* Destructively modifies this number by setting its numeric value to
|
||||
* `value`, independent of its units.
|
||||
*
|
||||
* @deprecated Use {@link constructor} instead.
|
||||
*/
|
||||
setValue(value: number): void;
|
||||
|
||||
/**
|
||||
* Returns a string representation of this number's units. Complex units are
|
||||
* returned in the same format that {@link constructor} accepts them.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* // number is `10px`.
|
||||
* number.getUnit(); // "px"
|
||||
*
|
||||
* // number is `math.div(10px, 1s)`.
|
||||
* number.getUnit(); // "px/s"
|
||||
* ```
|
||||
*/
|
||||
getUnit(): string;
|
||||
|
||||
/**
|
||||
* Destructively modifies this number by setting its units to `unit`,
|
||||
* independent of its numeric value. Complex units are specified in the same
|
||||
* format as {@link constructor}.
|
||||
*
|
||||
* @deprecated Use {@link constructor} instead.
|
||||
*/
|
||||
setUnit(unit: string): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sass's [string type](https://sass-lang.com/documentation/values/strings).
|
||||
*
|
||||
* **Heads up!** This API currently provides no way of distinguishing between
|
||||
* a [quoted](https://sass-lang.com/documentation/values/strings#quoted) and
|
||||
* [unquoted](https://sass-lang.com/documentation/values/strings#unquoted)
|
||||
* string.
|
||||
*/
|
||||
export class String {
|
||||
/**
|
||||
* Creates an unquoted string with the given contents.
|
||||
*
|
||||
* **Heads up!** This API currently provides no way of creating a
|
||||
* [quoted](https://sass-lang.com/documentation/values/strings#quoted)
|
||||
* string.
|
||||
*/
|
||||
constructor(value: string);
|
||||
|
||||
/**
|
||||
* Returns the contents of the string. If the string contains escapes,
|
||||
* those escapes are included literally if it’s
|
||||
* [unquoted](https://sass-lang.com/documentation/values/strings#unquoted),
|
||||
* while the values of the escapes are included if it’s
|
||||
* [quoted](https://sass-lang.com/documentation/values/strings#quoted).
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```
|
||||
* // string is `Arial`.
|
||||
* string.getValue(); // "Arial"
|
||||
*
|
||||
* // string is `"Helvetica Neue"`.
|
||||
* string.getValue(); // "Helvetica Neue"
|
||||
*
|
||||
* // string is `\1F46D`.
|
||||
* string.getValue(); // "\\1F46D"
|
||||
*
|
||||
* // string is `"\1F46D"`.
|
||||
* string.getValue(); // "👭"
|
||||
* ```
|
||||
*/
|
||||
getValue(): string;
|
||||
|
||||
/**
|
||||
* Destructively modifies this string by setting its numeric value to
|
||||
* `value`.
|
||||
*
|
||||
* **Heads up!** Even if the string was originally quoted, this will cause
|
||||
* it to become unquoted.
|
||||
*
|
||||
* @deprecated Use {@link constructor} instead.
|
||||
*/
|
||||
setValue(value: string): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sass's [boolean type](https://sass-lang.com/documentation/values/booleans).
|
||||
*
|
||||
* Custom functions should respect Sass’s notion of
|
||||
* [truthiness](https://sass-lang.com/documentation/at-rules/control/if#truthiness-and-falsiness)
|
||||
* by treating `false` and `null` as falsey and everything else as truthy.
|
||||
*
|
||||
* **Heads up!** Boolean values can't be constructed, they can only be
|
||||
* accessed through the {@link TRUE} and {@link FALSE} constants.
|
||||
*/
|
||||
export class Boolean<T extends boolean = boolean> {
|
||||
/**
|
||||
* Returns `true` if this is Sass's `true` value and `false` if this is
|
||||
* Sass's `false` value.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* // boolean is `true`.
|
||||
* boolean.getValue(); // true
|
||||
* boolean === sass.types.Boolean.TRUE; // true
|
||||
*
|
||||
* // boolean is `false`.
|
||||
* boolean.getValue(); // false
|
||||
* boolean === sass.types.Boolean.FALSE; // true
|
||||
* ```
|
||||
*/
|
||||
getValue(): T;
|
||||
|
||||
/** Sass's `true` value. */
|
||||
static readonly TRUE: Boolean<true>;
|
||||
|
||||
/** Sass's `false` value. */
|
||||
static readonly FALSE: Boolean<false>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sass's [color type](https://sass-lang.com/documentation/values/colors).
|
||||
*/
|
||||
export class Color {
|
||||
/**
|
||||
* Creates a new Sass color with the given red, green, blue, and alpha
|
||||
* channels. The red, green, and blue channels must be integers between 0
|
||||
* and 255 (inclusive), and alpha must be between 0 and 1 (inclusive).
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* new sass.types.Color(107, 113, 127); // #6b717f
|
||||
* new sass.types.Color(0, 0, 0, 0); // rgba(0, 0, 0, 0)
|
||||
* ```
|
||||
*/
|
||||
constructor(r: number, g: number, b: number, a?: number);
|
||||
|
||||
/**
|
||||
* Creates a new Sass color with alpha, red, green, and blue channels taken
|
||||
* from respective two-byte chunks of a hexidecimal number.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* new sass.types.Color(0xff6b717f); // #6b717f
|
||||
* new sass.types.Color(0x00000000); // rgba(0, 0, 0, 0)
|
||||
* ```
|
||||
*/
|
||||
constructor(argb: number);
|
||||
|
||||
/**
|
||||
* Returns the red channel of the color as an integer from 0 to 255.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* // color is `#6b717f`.
|
||||
* color.getR(); // 107
|
||||
*
|
||||
* // color is `#b37399`.
|
||||
* color.getR(); // 179
|
||||
* ```
|
||||
*/
|
||||
getR(): number;
|
||||
|
||||
/**
|
||||
* Sets the red channel of the color. The value must be an integer between 0
|
||||
* and 255 (inclusive).
|
||||
*
|
||||
* @deprecated Use {@link constructor} instead.
|
||||
*/
|
||||
setR(value: number): void;
|
||||
|
||||
/**
|
||||
* Returns the green channel of the color as an integer from 0 to 255.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* // color is `#6b717f`.
|
||||
* color.getG(); // 113
|
||||
*
|
||||
* // color is `#b37399`.
|
||||
* color.getG(); // 115
|
||||
* ```
|
||||
*/
|
||||
getG(): number;
|
||||
|
||||
/**
|
||||
* Sets the green channel of the color. The value must be an integer between
|
||||
* 0 and 255 (inclusive).
|
||||
*
|
||||
* @deprecated Use {@link constructor} instead.
|
||||
*/
|
||||
setG(value: number): void;
|
||||
|
||||
/**
|
||||
* Returns the blue channel of the color as an integer from 0 to 255.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* // color is `#6b717f`.
|
||||
* color.getB(); // 127
|
||||
*
|
||||
* // color is `#b37399`.
|
||||
* color.getB(); // 153
|
||||
* ```
|
||||
*/
|
||||
getB(): number;
|
||||
|
||||
/**
|
||||
* Sets the blue channel of the color. The value must be an integer between
|
||||
* 0 and 255 (inclusive).
|
||||
*
|
||||
* @deprecated Use {@link constructor} instead.
|
||||
*/
|
||||
setB(value: number): void;
|
||||
|
||||
/**
|
||||
* Returns the alpha channel of the color as a number from 0 to 1.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* // color is `#6b717f`.
|
||||
* color.getA(); // 1
|
||||
*
|
||||
* // color is `transparent`.
|
||||
* color.getA(); // 0
|
||||
* ```
|
||||
*/
|
||||
getA(): number;
|
||||
|
||||
/**
|
||||
* Sets the alpha channel of the color. The value must be between 0 and 1
|
||||
* (inclusive).
|
||||
*
|
||||
* @deprecated Use {@link constructor} instead.
|
||||
*/
|
||||
setA(value: number): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sass's [list type](https://sass-lang.com/documentation/values/lists).
|
||||
*
|
||||
* **Heads up!** This list type’s methods use 0-based indexing, even though
|
||||
* within Sass lists use 1-based indexing. These methods also don’t support
|
||||
* using negative numbers to index backwards from the end of the list.
|
||||
*/
|
||||
export class List {
|
||||
/**
|
||||
* Creates a new Sass list.
|
||||
*
|
||||
* **Heads up!** The initial values of the list elements are undefined.
|
||||
* These elements must be set using {@link setValue} before accessing them
|
||||
* or passing the list back to Sass.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* const list = new sass.types.List(3);
|
||||
* list.setValue(0, new sass.types.Number(10, "px"));
|
||||
* list.setValue(1, new sass.types.Number(15, "px"));
|
||||
* list.setValue(2, new sass.types.Number(32, "px"));
|
||||
* list; // 10px, 15px, 32px
|
||||
* ```
|
||||
*
|
||||
* @param length - The number of (initially undefined) elements in the list.
|
||||
* @param commaSeparator - If `true`, the list is comma-separated; otherwise,
|
||||
* it's space-separated. Defaults to `true`.
|
||||
*/
|
||||
constructor(length: number, commaSeparator?: boolean);
|
||||
|
||||
/**
|
||||
* Returns the element at `index`, or `undefined` if that value hasn't yet
|
||||
* been set.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* // list is `10px, 15px, 32px`
|
||||
* list.getValue(0); // 10px
|
||||
* list.getValue(2); // 32px
|
||||
* ```
|
||||
*
|
||||
* @param index - A (0-based) index into this list.
|
||||
* @throws `Error` if `index` is less than 0 or greater than or equal to the
|
||||
* number of elements in this list.
|
||||
*/
|
||||
getValue(index: number): LegacyValue | undefined;
|
||||
|
||||
/**
|
||||
* Sets the element at `index` to `value`.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* // list is `10px, 15px, 32px`
|
||||
* list.setValue(1, new sass.types.Number(18, "px"));
|
||||
* list; // 10px, 18px, 32px
|
||||
* ```
|
||||
*
|
||||
* @param index - A (0-based) index into this list.
|
||||
* @throws `Error` if `index` is less than 0 or greater than or equal to the
|
||||
* number of elements in this list.
|
||||
*/
|
||||
setValue(index: number, value: LegacyValue): void;
|
||||
|
||||
/**
|
||||
* Returns `true` if this list is comma-separated and `false` otherwise.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* // list is `10px, 15px, 32px`
|
||||
* list.getSeparator(); // true
|
||||
*
|
||||
* // list is `1px solid`
|
||||
* list.getSeparator(); // false
|
||||
* ```
|
||||
*/
|
||||
getSeparator(): boolean;
|
||||
|
||||
/**
|
||||
* Sets whether the list is comma-separated.
|
||||
*
|
||||
* @param isComma - `true` to make the list comma-separated, `false` otherwise.
|
||||
*/
|
||||
setSeparator(isComma: boolean): void;
|
||||
|
||||
/**
|
||||
* Returns the number of elements in the list.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* // list is `10px, 15px, 32px`
|
||||
* list.getLength(); // 3
|
||||
*
|
||||
* // list is `1px solid`
|
||||
* list.getLength(); // 2
|
||||
* ```
|
||||
*/
|
||||
getLength(): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sass's [map type](https://sass-lang.com/documentation/values/maps).
|
||||
*
|
||||
* **Heads up!** This map type is represented as a list of key-value pairs
|
||||
* rather than a mapping from keys to values. The only way to find the value
|
||||
* associated with a given key is to iterate through the map checking for that
|
||||
* key. Maps created through this API are still forbidden from having duplicate
|
||||
* keys.
|
||||
*/
|
||||
export class Map {
|
||||
/**
|
||||
* Creates a new Sass map.
|
||||
*
|
||||
* **Heads up!** The initial keys and values of the map are undefined. They
|
||||
* must be set using {@link setKey} and {@link setValue} before accessing
|
||||
* them or passing the map back to Sass.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* const map = new sass.types.Map(2);
|
||||
* map.setKey(0, new sass.types.String("width"));
|
||||
* map.setValue(0, new sass.types.Number(300, "px"));
|
||||
* map.setKey(1, new sass.types.String("height"));
|
||||
* map.setValue(1, new sass.types.Number(100, "px"));
|
||||
* map; // (width: 300px, height: 100px)
|
||||
* ```
|
||||
*
|
||||
* @param length - The number of (initially undefined) key/value pairs in the map.
|
||||
*/
|
||||
constructor(length: number);
|
||||
|
||||
/**
|
||||
* Returns the value in the key/value pair at `index`.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* // map is `(width: 300px, height: 100px)`
|
||||
* map.getValue(0); // 300px
|
||||
* map.getValue(1); // 100px
|
||||
* ```
|
||||
*
|
||||
* @param index - A (0-based) index of a key/value pair in this map.
|
||||
* @throws `Error` if `index` is less than 0 or greater than or equal to the
|
||||
* number of pairs in this map.
|
||||
*/
|
||||
getValue(index: number): LegacyValue;
|
||||
|
||||
/**
|
||||
* Sets the value in the key/value pair at `index` to `value`.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* // map is `("light": 200, "medium": 400, "bold": 600)`
|
||||
* map.setValue(1, new sass.types.Number(300));
|
||||
* map; // ("light": 200, "medium": 300, "bold": 600)
|
||||
* ```
|
||||
*
|
||||
* @param index - A (0-based) index of a key/value pair in this map.
|
||||
* @throws `Error` if `index` is less than 0 or greater than or equal to the
|
||||
* number of pairs in this map.
|
||||
*/
|
||||
setValue(index: number, value: LegacyValue): void;
|
||||
|
||||
/**
|
||||
* Returns the key in the key/value pair at `index`.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* // map is `(width: 300px, height: 100px)`
|
||||
* map.getKey(0); // width
|
||||
* map.getKey(1); // height
|
||||
* ```
|
||||
*
|
||||
* @param index - A (0-based) index of a key/value pair in this map.
|
||||
* @throws `Error` if `index` is less than 0 or greater than or equal to the
|
||||
* number of pairs in this map.
|
||||
*/
|
||||
getKey(index: number): LegacyValue;
|
||||
|
||||
/**
|
||||
* Sets the value in the key/value pair at `index` to `value`.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* // map is `("light": 200, "medium": 400, "bold": 600)`
|
||||
* map.setValue(1, new sass.types.String("lighter"));
|
||||
* map; // ("lighter": 200, "medium": 300, "bold": 600)
|
||||
* ```
|
||||
*
|
||||
* @param index - A (0-based) index of a key/value pair in this map.
|
||||
* @throws `Error` if `index` is less than 0 or greater than or equal to the
|
||||
* number of pairs in this map.
|
||||
*/
|
||||
setKey(index: number, key: LegacyValue): void;
|
||||
|
||||
/**
|
||||
* Returns the number of key/value pairs in this map.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* // map is `("light": 200, "medium": 400, "bold": 600)`
|
||||
* map.getLength(); // 3
|
||||
*
|
||||
* // map is `(width: 300px, height: 100px)`
|
||||
* map.getLength(); // 2
|
||||
* ```
|
||||
*/
|
||||
getLength(): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* An error that can be returned from a Sass function to signal that it
|
||||
* encountered an error. This is the only way to signal an error
|
||||
* asynchronously from a {@link LegacyAsyncFunction}.
|
||||
*/
|
||||
export class Error {
|
||||
constructor(message: string);
|
||||
}
|
||||
}
|
||||
169
node_modules/sass/types/legacy/importer.d.ts
generated
vendored
Normal file
169
node_modules/sass/types/legacy/importer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
import {LegacyPluginThis} from './plugin_this';
|
||||
|
||||
/**
|
||||
* The value of `this` in the context of a {@link LegacyImporter} function.
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This is only used by the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link Importer} with {@link compile}, {@link
|
||||
* compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
interface LegacyImporterThis extends LegacyPluginThis {
|
||||
/**
|
||||
* Whether the importer is being invoked because of a Sass `@import` rule, as
|
||||
* opposed to a `@use` or `@forward` rule.
|
||||
*
|
||||
* This should *only* be used for determining whether or not to load
|
||||
* [import-only files](https://sass-lang.com/documentation/at-rules/import#import-only-files).
|
||||
*
|
||||
* @compatibility dart: "1.33.0", node: false
|
||||
*/
|
||||
fromImport: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* The result of running a {@link LegacyImporter}. It must be one of the
|
||||
* following types:
|
||||
*
|
||||
* * An object with the key `contents` whose value is the contents of a stylesheet
|
||||
* (in SCSS syntax). This causes Sass to load that stylesheet’s contents.
|
||||
*
|
||||
* * An object with the key `file` whose value is a path on disk. This causes Sass
|
||||
* to load that file as though it had been imported directly.
|
||||
*
|
||||
* * `null`, which indicates that it doesn’t recognize the URL and another
|
||||
* importer should be tried instead.
|
||||
*
|
||||
* * An [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
|
||||
* object, indicating that importing failed.
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This only works with the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link ImporterResult} with {@link compile}, {@link
|
||||
* compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
export type LegacyImporterResult =
|
||||
| {file: string}
|
||||
| {contents: string}
|
||||
| Error
|
||||
| null;
|
||||
|
||||
/**
|
||||
* A synchronous callback that implements custom Sass loading logic for
|
||||
* [`@import` rules](https://sass-lang.com/documentation/at-rules/import) and
|
||||
* [`@use` rules](https://sass-lang.com/documentation/at-rules/use). This can be
|
||||
* passed to {@link LegacySharedOptions.importer} for either {@link render} or
|
||||
* {@link renderSync}.
|
||||
*
|
||||
* See {@link LegacySharedOptions.importer} for more detailed documentation.
|
||||
*
|
||||
* ```js
|
||||
* sass.renderSync({
|
||||
* file: "style.scss",
|
||||
* importer: [
|
||||
* function(url, prev) {
|
||||
* if (url != "big-headers") return null;
|
||||
*
|
||||
* return {
|
||||
* contents: 'h1 { font-size: 40px; }'
|
||||
* };
|
||||
* }
|
||||
* ]
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param url - The `@use` or `@import` rule’s URL as a string, exactly as it
|
||||
* appears in the stylesheet.
|
||||
*
|
||||
* @param prev - A string identifying the stylesheet that contained the `@use`
|
||||
* or `@import`. This string’s format depends on how that stylesheet was loaded:
|
||||
*
|
||||
* * If the stylesheet was loaded from the filesystem, it’s the absolute path of
|
||||
* its file.
|
||||
* * If the stylesheet was loaded from an importer that returned its contents,
|
||||
* it’s the URL of the `@use` or `@import` rule that loaded it.
|
||||
* * If the stylesheet came from the data option, it’s the string "stdin".
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This only works with the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link Importer} with {@link compile}, {@link
|
||||
* compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
type LegacySyncImporter = (
|
||||
this: LegacyImporterThis,
|
||||
url: string,
|
||||
prev: string
|
||||
) => LegacyImporterResult;
|
||||
|
||||
/**
|
||||
* An asynchronous callback that implements custom Sass loading logic for
|
||||
* [`@import` rules](https://sass-lang.com/documentation/at-rules/import) and
|
||||
* [`@use` rules](https://sass-lang.com/documentation/at-rules/use). This can be
|
||||
* passed to {@link LegacySharedOptions.importer} for either {@link render} or
|
||||
* {@link renderSync}.
|
||||
*
|
||||
* An asynchronous importer must return `undefined`, and then call `done` with
|
||||
* the result of its {@link LegacyImporterResult} once it's done running.
|
||||
*
|
||||
* See {@link LegacySharedOptions.importer} for more detailed documentation.
|
||||
*
|
||||
* ```js
|
||||
* sass.render({
|
||||
* file: "style.scss",
|
||||
* importer: [
|
||||
* function(url, prev, done) {
|
||||
* if (url != "big-headers") done(null);
|
||||
*
|
||||
* done({
|
||||
* contents: 'h1 { font-size: 40px; }'
|
||||
* });
|
||||
* }
|
||||
* ]
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param url - The `@use` or `@import` rule’s URL as a string, exactly as it
|
||||
* appears in the stylesheet.
|
||||
*
|
||||
* @param prev - A string identifying the stylesheet that contained the `@use`
|
||||
* or `@import`. This string’s format depends on how that stylesheet was loaded:
|
||||
*
|
||||
* * If the stylesheet was loaded from the filesystem, it’s the absolute path of
|
||||
* its file.
|
||||
* * If the stylesheet was loaded from an importer that returned its contents,
|
||||
* it’s the URL of the `@use` or `@import` rule that loaded it.
|
||||
* * If the stylesheet came from the data option, it’s the string "stdin".
|
||||
*
|
||||
* @param done - The callback to call once the importer has finished running.
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This only works with the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link Importer} with {@link compile}, {@link
|
||||
* compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
type LegacyAsyncImporter = (
|
||||
this: LegacyImporterThis,
|
||||
url: string,
|
||||
prev: string,
|
||||
done: (result: LegacyImporterResult) => void
|
||||
) => void;
|
||||
|
||||
/**
|
||||
* A callback that implements custom Sass loading logic for [`@import`
|
||||
* rules](https://sass-lang.com/documentation/at-rules/import) and [`@use`
|
||||
* rules](https://sass-lang.com/documentation/at-rules/use). For {@link
|
||||
* renderSync}, this must be a {@link LegacySyncImporter} which returns its
|
||||
* result directly; for {@link render}, it may be either a {@link
|
||||
* LegacySyncImporter} or a {@link LegacyAsyncImporter} which calls a callback
|
||||
* with its result.
|
||||
*
|
||||
* See {@link LegacySharedOptions.importer} for more details.
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This only works with the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link Importer} with {@link compile}, {@link
|
||||
* compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
export type LegacyImporter<sync = 'sync' | 'async'> = sync extends 'async'
|
||||
? LegacySyncImporter | LegacyAsyncImporter
|
||||
: LegacySyncImporter;
|
||||
700
node_modules/sass/types/legacy/options.d.ts
generated
vendored
Normal file
700
node_modules/sass/types/legacy/options.d.ts
generated
vendored
Normal file
@@ -0,0 +1,700 @@
|
||||
import {DeprecationOrId, Version} from '../deprecations';
|
||||
import {Logger} from '../logger';
|
||||
import {LegacyImporter} from './importer';
|
||||
import {LegacyFunction} from './function';
|
||||
import {NodePackageImporter} from '../importer';
|
||||
|
||||
/**
|
||||
* Options for {@link render} and {@link renderSync} that are shared between
|
||||
* {@link LegacyFileOptions} and {@link LegacyStringOptions}.
|
||||
*
|
||||
* @typeParam sync - This lets the TypeScript checker verify that {@link
|
||||
* LegacyAsyncImporter}s and {@link LegacyAsyncFunction}s aren't passed to
|
||||
* {@link renderSync}.
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This only works with the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link Options} with {@link compile}, {@link
|
||||
* compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
export interface LegacySharedOptions<sync extends 'sync' | 'async'> {
|
||||
/**
|
||||
* This array of strings option provides [load
|
||||
* paths](https://sass-lang.com/documentation/at-rules/import#load-paths) for
|
||||
* Sass to look for stylesheets. Earlier load paths will take precedence over
|
||||
* later ones.
|
||||
*
|
||||
* ```js
|
||||
* sass.renderSync({
|
||||
* file: "style.scss",
|
||||
* includePaths: ["node_modules/bootstrap/dist/css"]
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Load paths are also loaded from the `SASS_PATH` environment variable, if
|
||||
* it’s set. This variable should be a list of paths separated by `;` (on
|
||||
* Windows) or `:` (on other operating systems). Load paths from the
|
||||
* `includePaths` option take precedence over load paths from `SASS_PATH`.
|
||||
*
|
||||
* ```sh
|
||||
* $ SASS_PATH=node_modules/bootstrap/dist/css sass style.scss style.css
|
||||
* ```
|
||||
*
|
||||
* @category Input
|
||||
* @compatibility feature: "SASS_PATH", dart: "1.15.0", node: "3.9.0"
|
||||
*
|
||||
* Earlier versions of Dart Sass and Node Sass didn’t support the `SASS_PATH`
|
||||
* environment variable.
|
||||
*/
|
||||
includePaths?: string[];
|
||||
|
||||
/**
|
||||
* Whether the generated CSS should use spaces or tabs for indentation.
|
||||
*
|
||||
* ```js
|
||||
* const result = sass.renderSync({
|
||||
* file: "style.scss",
|
||||
* indentType: "tab",
|
||||
* indentWidth: 1
|
||||
* });
|
||||
*
|
||||
* result.css.toString();
|
||||
* // "h1 {\n\tfont-size: 40px;\n}\n"
|
||||
* ```
|
||||
*
|
||||
* @defaultValue `'space'`
|
||||
* @category Output
|
||||
* @compatibility dart: true, node: "3.0.0"
|
||||
*/
|
||||
indentType?: 'space' | 'tab';
|
||||
|
||||
/**
|
||||
* How many spaces or tabs (depending on {@link indentType}) should be used
|
||||
* per indentation level in the generated CSS. It must be between 0 and 10
|
||||
* (inclusive).
|
||||
*
|
||||
* @defaultValue `2`
|
||||
* @category Output
|
||||
* @compatibility dart: true, node: "3.0.0"
|
||||
*/
|
||||
indentWidth?: number;
|
||||
|
||||
/**
|
||||
* Which character sequence to use at the end of each line in the generated
|
||||
* CSS. It can have the following values:
|
||||
*
|
||||
* * `'lf'` uses U+000A LINE FEED.
|
||||
* * `'lfcr'` uses U+000A LINE FEED followed by U+000D CARRIAGE RETURN.
|
||||
* * `'cr'` uses U+000D CARRIAGE RETURN.
|
||||
* * `'crlf'` uses U+000D CARRIAGE RETURN followed by U+000A LINE FEED.
|
||||
*
|
||||
* @defaultValue `'lf'`
|
||||
* @category Output
|
||||
* @compatibility dart: true, node: "3.0.0"
|
||||
*/
|
||||
linefeed?: 'cr' | 'crlf' | 'lf' | 'lfcr';
|
||||
|
||||
/**
|
||||
* If `true`, Sass won't add a link from the generated CSS to the source map.
|
||||
*
|
||||
* ```js
|
||||
* const result = sass.renderSync({
|
||||
* file: "style.scss",
|
||||
* sourceMap: "out.map",
|
||||
* omitSourceMapUrl: true
|
||||
* })
|
||||
* console.log(result.css.toString());
|
||||
* // h1 {
|
||||
* // font-size: 40px;
|
||||
* // }
|
||||
* ```
|
||||
*
|
||||
* @defaultValue `false`
|
||||
* @category Source Maps
|
||||
*/
|
||||
omitSourceMapUrl?: boolean;
|
||||
|
||||
/**
|
||||
* The location that Sass expects the generated CSS to be saved to. It’s used
|
||||
* to determine the URL used to link from the generated CSS to the source map,
|
||||
* and from the source map to the Sass source files.
|
||||
*
|
||||
* **Heads up!** Despite the name, Sass does *not* write the CSS output to
|
||||
* this file. The caller must do that themselves.
|
||||
*
|
||||
* ```js
|
||||
* result = sass.renderSync({
|
||||
* file: "style.scss",
|
||||
* sourceMap: true,
|
||||
* outFile: "out.css"
|
||||
* })
|
||||
* console.log(result.css.toString());
|
||||
* // h1 {
|
||||
* // font-size: 40px;
|
||||
* // }
|
||||
* // /*# sourceMappingURL=out.css.map * /
|
||||
* ```
|
||||
*
|
||||
* @category Source Maps
|
||||
*/
|
||||
outFile?: string;
|
||||
|
||||
/**
|
||||
* The output style of the compiled CSS. There are four possible output styles:
|
||||
*
|
||||
* * `"expanded"` (the default for Dart Sass) writes each selector and
|
||||
* declaration on its own line.
|
||||
*
|
||||
* * `"compressed"` removes as many extra characters as possible, and writes
|
||||
* the entire stylesheet on a single line.
|
||||
*
|
||||
* * `"nested"` (the default for Node Sass, not supported by Dart Sass)
|
||||
* indents CSS rules to match the nesting of the Sass source.
|
||||
*
|
||||
* * `"compact"` (not supported by Dart Sass) puts each CSS rule on its own single line.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* const source = `
|
||||
* h1 {
|
||||
* font-size: 40px;
|
||||
* code {
|
||||
* font-face: Roboto Mono;
|
||||
* }
|
||||
* }`;
|
||||
*
|
||||
* let result = sass.renderSync({
|
||||
* data: source,
|
||||
* outputStyle: "expanded"
|
||||
* });
|
||||
* console.log(result.css.toString());
|
||||
* // h1 {
|
||||
* // font-size: 40px;
|
||||
* // }
|
||||
* // h1 code {
|
||||
* // font-face: Roboto Mono;
|
||||
* // }
|
||||
*
|
||||
* result = sass.renderSync({
|
||||
* data: source,
|
||||
* outputStyle: "compressed"
|
||||
* });
|
||||
* console.log(result.css.toString());
|
||||
* // h1{font-size:40px}h1 code{font-face:Roboto Mono}
|
||||
*
|
||||
* result = sass.renderSync({
|
||||
* data: source,
|
||||
* outputStyle: "nested"
|
||||
* });
|
||||
* console.log(result.css.toString());
|
||||
* // h1 {
|
||||
* // font-size: 40px; }
|
||||
* // h1 code {
|
||||
* // font-face: Roboto Mono; }
|
||||
*
|
||||
* result = sass.renderSync({
|
||||
* data: source,
|
||||
* outputStyle: "compact"
|
||||
* });
|
||||
* console.log(result.css.toString());
|
||||
* // h1 { font-size: 40px; }
|
||||
* // h1 code { font-face: Roboto Mono; }
|
||||
* ```
|
||||
*
|
||||
* @category Output
|
||||
*/
|
||||
outputStyle?: 'compressed' | 'expanded' | 'nested' | 'compact';
|
||||
|
||||
/**
|
||||
* Whether or not Sass should generate a source map. If it does, the source
|
||||
* map will be available as {@link LegacyResult.map} (unless {@link
|
||||
* sourceMapEmbed} is `true`).
|
||||
*
|
||||
* If this option is a string, it’s the path that the source map is expected
|
||||
* to be written to, which is used to link to the source map from the
|
||||
* generated CSS and to link *from* the source map to the Sass source files.
|
||||
* Note that if `sourceMap` is a string and {@link outFile} isn’t passed, Sass
|
||||
* assumes that the CSS will be written to the same directory as the file
|
||||
* option if it’s passed.
|
||||
*
|
||||
* If this option is `true`, the path is assumed to be {@link outFile} with
|
||||
* `.map` added to the end. If it’s `true` and {@link outFile} isn’t passed,
|
||||
* it has no effect.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* let result = sass.renderSync({
|
||||
* file: "style.scss",
|
||||
* sourceMap: "out.map"
|
||||
* })
|
||||
* console.log(result.css.toString());
|
||||
* // h1 {
|
||||
* // font-size: 40px;
|
||||
* // }
|
||||
* // /*# sourceMappingURL=out.map * /
|
||||
*
|
||||
* result = sass.renderSync({
|
||||
* file: "style.scss",
|
||||
* sourceMap: true,
|
||||
* outFile: "out.css"
|
||||
* })
|
||||
* console.log(result.css.toString());
|
||||
* // h1 {
|
||||
* // font-size: 40px;
|
||||
* // }
|
||||
* // /*# sourceMappingURL=out.css.map * /
|
||||
* ```
|
||||
*
|
||||
* @defaultValue `false`
|
||||
* @category Source Maps
|
||||
*/
|
||||
sourceMap?: boolean | string;
|
||||
|
||||
/**
|
||||
* Whether to embed the entire contents of the Sass files that contributed to
|
||||
* the generated CSS in the source map. This may produce very large source
|
||||
* maps, but it guarantees that the source will be available on any computer
|
||||
* no matter how the CSS is served.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* sass.renderSync({
|
||||
* file: "style.scss",
|
||||
* sourceMap: "out.map",
|
||||
* sourceMapContents: true
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* @defaultValue `false`
|
||||
* @category Source Maps
|
||||
*/
|
||||
sourceMapContents?: boolean;
|
||||
|
||||
/**
|
||||
* Whether to embed the contents of the source map file in the generated CSS,
|
||||
* rather than creating a separate file and linking to it from the CSS.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* sass.renderSync({
|
||||
* file: "style.scss",
|
||||
* sourceMap: "out.map",
|
||||
* sourceMapEmbed: true
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @defaultValue `false`
|
||||
* @category Source Maps
|
||||
*/
|
||||
sourceMapEmbed?: boolean;
|
||||
|
||||
/**
|
||||
* If this is passed, it's prepended to all the links from the source map to
|
||||
* the Sass source files.
|
||||
*
|
||||
* @category Source Maps
|
||||
*/
|
||||
sourceMapRoot?: string;
|
||||
|
||||
/**
|
||||
* Additional handler(s) for loading files when a [`@use`
|
||||
* rule](https://sass-lang.com/documentation/at-rules/use) or an [`@import`
|
||||
* rule](https://sass-lang.com/documentation/at-rules/import) is encountered.
|
||||
* It can either be a single {@link LegacyImporter} function, or an array of
|
||||
* {@link LegacyImporter}s.
|
||||
*
|
||||
* Importers take the URL of the `@import` or `@use` rule and return a {@link
|
||||
* LegacyImporterResult} indicating how to handle that rule. For more details,
|
||||
* see {@link LegacySyncImporter} and {@link LegacyAsyncImporter}.
|
||||
*
|
||||
* Loads are resolved by trying, in order:
|
||||
*
|
||||
* * Loading a file from disk relative to the file in which the `@use` or
|
||||
* `@import` appeared.
|
||||
*
|
||||
* * Each custom importer.
|
||||
*
|
||||
* * Loading a file relative to the current working directory.
|
||||
*
|
||||
* * Each load path in {@link includePaths}.
|
||||
*
|
||||
* * Each load path specified in the `SASS_PATH` environment variable, which
|
||||
* should be semicolon-separated on Windows and colon-separated elsewhere.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* sass.render({
|
||||
* file: "style.scss",
|
||||
* importer: [
|
||||
* // This importer uses the synchronous API, and can be passed to either
|
||||
* // renderSync() or render().
|
||||
* function(url, prev) {
|
||||
* // This generates a stylesheet from scratch for `@use "big-headers"`.
|
||||
* if (url != "big-headers") return null;
|
||||
*
|
||||
* return {
|
||||
* contents: `
|
||||
* h1 {
|
||||
* font-size: 40px;
|
||||
* }`
|
||||
* };
|
||||
* },
|
||||
*
|
||||
* // This importer uses the asynchronous API, and can only be passed to
|
||||
* // render().
|
||||
* function(url, prev, done) {
|
||||
* // Convert `@use "foo/bar"` to "node_modules/foo/sass/bar".
|
||||
* const components = url.split('/');
|
||||
* const innerPath = components.slice(1).join('/');
|
||||
* done({
|
||||
* file: `node_modules/${components.first}/sass/${innerPath}`
|
||||
* });
|
||||
* }
|
||||
* ]
|
||||
* }, function(err, result) {
|
||||
* // ...
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @category Plugins
|
||||
* @compatibility dart: true, node: "3.0.0"
|
||||
*
|
||||
* Versions of Node Sass before 3.0.0 don’t support arrays of importers, nor
|
||||
* do they support importers that return `Error` objects.
|
||||
*
|
||||
* Versions of Node Sass before 2.0.0 don’t support the `importer` option at
|
||||
* all.
|
||||
*
|
||||
* @compatibility feature: "Import order", dart: "1.20.2", node: false
|
||||
*
|
||||
* Versions of Dart Sass before 1.20.2 preferred resolving imports using
|
||||
* {@link includePaths} before resolving them using custom importers.
|
||||
*
|
||||
* All versions of Node Sass currently pass imports to importers before
|
||||
* loading them relative to the file in which the `@import` appears. This
|
||||
* behavior is considered incorrect and should not be relied on because it
|
||||
* violates the principle of *locality*, which says that it should be possible
|
||||
* to reason about a stylesheet without knowing everything about how the
|
||||
* entire system is set up. If a user tries to import a stylesheet relative to
|
||||
* another stylesheet, that import should *always* work. It shouldn’t be
|
||||
* possible for some configuration somewhere else to break it.
|
||||
*/
|
||||
importer?: LegacyImporter<sync> | LegacyImporter<sync>[];
|
||||
|
||||
/**
|
||||
* Additional built-in Sass functions that are available in all stylesheets.
|
||||
* This option takes an object whose keys are Sass function signatures and
|
||||
* whose values are {@link LegacyFunction}s. Each function should take the
|
||||
* same arguments as its signature.
|
||||
*
|
||||
* Functions are passed subclasses of {@link LegacyValue}, and must return the
|
||||
* same.
|
||||
*
|
||||
* **Heads up!** When writing custom functions, it’s important to ensure that
|
||||
* all the arguments are the types you expect. Otherwise, users’ stylesheets
|
||||
* could crash in hard-to-debug ways or, worse, compile to meaningless CSS.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* sass.render({
|
||||
* data: `
|
||||
* h1 {
|
||||
* font-size: pow(2, 5) * 1px;
|
||||
* }`,
|
||||
* functions: {
|
||||
* // This function uses the synchronous API, and can be passed to either
|
||||
* // renderSync() or render().
|
||||
* 'pow($base, $exponent)': function(base, exponent) {
|
||||
* if (!(base instanceof sass.types.Number)) {
|
||||
* throw "$base: Expected a number.";
|
||||
* } else if (base.getUnit()) {
|
||||
* throw "$base: Expected a unitless number.";
|
||||
* }
|
||||
*
|
||||
* if (!(exponent instanceof sass.types.Number)) {
|
||||
* throw "$exponent: Expected a number.";
|
||||
* } else if (exponent.getUnit()) {
|
||||
* throw "$exponent: Expected a unitless number.";
|
||||
* }
|
||||
*
|
||||
* return new sass.types.Number(
|
||||
* Math.pow(base.getValue(), exponent.getValue()));
|
||||
* },
|
||||
*
|
||||
* // This function uses the asynchronous API, and can only be passed to
|
||||
* // render().
|
||||
* 'sqrt($number)': function(number, done) {
|
||||
* if (!(number instanceof sass.types.Number)) {
|
||||
* throw "$number: Expected a number.";
|
||||
* } else if (number.getUnit()) {
|
||||
* throw "$number: Expected a unitless number.";
|
||||
* }
|
||||
*
|
||||
* done(new sass.types.Number(Math.sqrt(number.getValue())));
|
||||
* }
|
||||
* }
|
||||
* }, function(err, result) {
|
||||
* console.log(result.css.toString());
|
||||
* // h1 {
|
||||
* // font-size: 32px;
|
||||
* // }
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @category Plugins
|
||||
*/
|
||||
functions?: {[key: string]: LegacyFunction<sync>};
|
||||
|
||||
/**
|
||||
* By default, if the CSS document contains non-ASCII characters, Sass adds a
|
||||
* `@charset` declaration (in expanded output mode) or a byte-order mark (in
|
||||
* compressed mode) to indicate its encoding to browsers or other consumers.
|
||||
* If `charset` is `false`, these annotations are omitted.
|
||||
*
|
||||
* @category Output
|
||||
* @compatibility dart: "1.39.0", node: false
|
||||
*/
|
||||
charset?: boolean;
|
||||
|
||||
/**
|
||||
* If this option is set to `true`, Sass won’t print warnings that are caused
|
||||
* by dependencies. A “dependency” is defined as any file that’s loaded
|
||||
* through {@link includePaths} or {@link importer}. Stylesheets that are
|
||||
* imported relative to the entrypoint are not considered dependencies.
|
||||
*
|
||||
* This is useful for silencing deprecation warnings that you can’t fix on
|
||||
* your own. However, please <em>also</em> notify your dependencies of the deprecations
|
||||
* so that they can get fixed as soon as possible!
|
||||
*
|
||||
* **Heads up!** If {@link render} or {@link renderSync} is called without
|
||||
* {@link LegacyFileOptions.file} or {@link LegacyStringOptions.file},
|
||||
* <em>all</em> stylesheets it loads will be considered dependencies. Since it
|
||||
* doesn’t have a path of its own, everything it loads is coming from a load
|
||||
* path rather than a relative import.
|
||||
*
|
||||
* @defaultValue `false`
|
||||
* @category Messages
|
||||
* @compatibility dart: "1.35.0", node: false
|
||||
*/
|
||||
quietDeps?: boolean;
|
||||
|
||||
/**
|
||||
* A set of deprecations to treat as fatal.
|
||||
*
|
||||
* If a deprecation warning of any provided type is encountered during
|
||||
* compilation, the compiler will error instead.
|
||||
*
|
||||
* If a `Version` is provided, then all deprecations that were active in that
|
||||
* compiler version will be treated as fatal.
|
||||
*
|
||||
* @category Messages
|
||||
* @compatiblity dart: "1.78.0", node: false
|
||||
*/
|
||||
fatalDeprecations?: (DeprecationOrId | Version)[];
|
||||
|
||||
/**
|
||||
* A set of future deprecations to opt into early.
|
||||
*
|
||||
* Future deprecations passed here will be treated as active by the compiler,
|
||||
* emitting warnings as necessary.
|
||||
*
|
||||
* @category Messages
|
||||
* @compatiblity dart: "1.78.0", node: false
|
||||
*/
|
||||
futureDeprecations?: DeprecationOrId[];
|
||||
|
||||
/**
|
||||
* A set of active deprecations to ignore.
|
||||
*
|
||||
* If a deprecation warning of any provided type is encountered during
|
||||
* compilation, the compiler will ignore it instead.
|
||||
*
|
||||
* **Heads up!** The deprecated functionality you're depending on will
|
||||
* eventually break.
|
||||
*
|
||||
* @category Messages
|
||||
* @compatiblity dart: "1.78.0", node: false
|
||||
*/
|
||||
silenceDeprecations?: DeprecationOrId[];
|
||||
|
||||
/**
|
||||
* By default, Dart Sass will print only five instances of the same
|
||||
* deprecation warning per compilation to avoid deluging users in console
|
||||
* noise. If you set `verbose` to `true`, it will instead print every
|
||||
* deprecation warning it encounters.
|
||||
*
|
||||
* @defaultValue `false`
|
||||
* @category Messages
|
||||
* @compatibility dart: "1.35.0", node: false
|
||||
*/
|
||||
verbose?: boolean;
|
||||
|
||||
/**
|
||||
* An object to use to handle warnings and/or debug messages from Sass.
|
||||
*
|
||||
* By default, Sass emits warnings and debug messages to standard error, but
|
||||
* if {@link Logger.warn} or {@link Logger.debug} is set, this will invoke
|
||||
* them instead.
|
||||
*
|
||||
* The special value {@link Logger.silent} can be used to easily silence all
|
||||
* messages.
|
||||
*
|
||||
* @category Messages
|
||||
* @compatibility dart: "1.43.0", node: false
|
||||
*/
|
||||
logger?: Logger;
|
||||
|
||||
/**
|
||||
* If this option is set to an instance of `NodePackageImporter`, Sass will
|
||||
* use the built-in Node.js package importer to resolve Sass files with a
|
||||
* `pkg:` URL scheme. Details for library authors and users can be found in
|
||||
* the {@link NodePackageImporter} documentation.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* sass.renderSync({
|
||||
* data: '@use "pkg:vuetify";',
|
||||
* pkgImporter: new sass.NodePackageImporter()
|
||||
* });
|
||||
* ```
|
||||
* @category Plugins
|
||||
* @compatibility dart: "2.0", node: false
|
||||
*/
|
||||
pkgImporter?: NodePackageImporter;
|
||||
}
|
||||
|
||||
/**
|
||||
* If {@link file} is passed without {@link data}, Sass will load the stylesheet
|
||||
* at {@link file} and compile it to CSS.
|
||||
*
|
||||
* @typeParam sync - This lets the TypeScript checker verify that {@link
|
||||
* LegacyAsyncImporter}s and {@link LegacyAsyncFunction}s aren't passed to
|
||||
* {@link renderSync}.
|
||||
*/
|
||||
export interface LegacyFileOptions<sync extends 'sync' | 'async'>
|
||||
extends LegacySharedOptions<sync> {
|
||||
/**
|
||||
* The path to the file for Sass to load and compile. If the file’s extension
|
||||
* is `.scss`, it will be parsed as SCSS; if it’s `.sass`, it will be parsed
|
||||
* as the indented syntax; and if it’s `.css`, it will be parsed as plain CSS.
|
||||
* If it has no extension, it will be parsed as SCSS.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* sass.renderSync({file: "style.scss"});
|
||||
* ```
|
||||
*
|
||||
* @category Input
|
||||
* @compatibility feature: "Plain CSS files", dart: "1.11.0", node: "partial"
|
||||
*
|
||||
* Node Sass and older versions of Dart Sass support loading files with the
|
||||
* extension `.css`, but contrary to the specification they’re treated as SCSS
|
||||
* files rather than being parsed as CSS. This behavior has been deprecated
|
||||
* and should not be relied on. Any files that use Sass features should use
|
||||
* the `.scss` extension.
|
||||
*
|
||||
* All versions of Node Sass and Dart Sass otherwise support the file option
|
||||
* as described below.
|
||||
*/
|
||||
file: string;
|
||||
|
||||
/**
|
||||
* See {@link LegacyStringOptions.file} for documentation of passing {@link
|
||||
* file} along with {@link data}.
|
||||
*
|
||||
* @category Input
|
||||
*/
|
||||
data?: never;
|
||||
}
|
||||
|
||||
/**
|
||||
* If {@link data} is passed, Sass will use it as the contents of the stylesheet
|
||||
* to compile.
|
||||
*
|
||||
* @typeParam sync - This lets the TypeScript checker verify that {@link
|
||||
* LegacyAsyncImporter}s and {@link LegacyAsyncFunction}s aren't passed to
|
||||
* {@link renderSync}.
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This only works with the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link StringOptions} with {@link compile}, {@link
|
||||
* compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
export interface LegacyStringOptions<sync extends 'sync' | 'async'>
|
||||
extends LegacySharedOptions<sync> {
|
||||
/**
|
||||
* The contents of the stylesheet to compile. Unless {@link file} is passed as
|
||||
* well, the stylesheet’s URL is set to `"stdin"`.
|
||||
*
|
||||
* By default, this stylesheet is parsed as SCSS. This can be controlled using
|
||||
* {@link indentedSyntax}.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* sass.renderSync({
|
||||
* data: `
|
||||
* h1 {
|
||||
* font-size: 40px;
|
||||
* }`
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @category Input
|
||||
*/
|
||||
data: string;
|
||||
|
||||
/**
|
||||
* If `file` and {@link data} are both passed, `file` is used as the path of
|
||||
* the stylesheet for error reporting, but {@link data} is used as the
|
||||
* contents of the stylesheet. In this case, `file`’s extension is not used to
|
||||
* determine the syntax of the stylesheet.
|
||||
*
|
||||
* @category Input
|
||||
*/
|
||||
file?: string;
|
||||
|
||||
/**
|
||||
* This flag controls whether {@link data} is parsed as the indented syntax or
|
||||
* not.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* sass.renderSync({
|
||||
* data: `
|
||||
* h1
|
||||
* font-size: 40px`,
|
||||
* indentedSyntax: true
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @defaultValue `false`
|
||||
* @category Input
|
||||
*/
|
||||
indentedSyntax?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for {@link render} and {@link renderSync}. This can either be {@link
|
||||
* LegacyFileOptions} to load a file from disk, or {@link LegacyStringOptions}
|
||||
* to compile a string of Sass code.
|
||||
*
|
||||
* See {@link LegacySharedOptions} for options that are shared across both file
|
||||
* and string inputs.
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This only works with the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link Options} with {@link compile}, {@link
|
||||
* compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
export type LegacyOptions<sync extends 'sync' | 'async'> =
|
||||
| LegacyFileOptions<sync>
|
||||
| LegacyStringOptions<sync>;
|
||||
74
node_modules/sass/types/legacy/plugin_this.d.ts
generated
vendored
Normal file
74
node_modules/sass/types/legacy/plugin_this.d.ts
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* The value of `this` in the context of a {@link LegacyImporter} or {@link
|
||||
* LegacyFunction} callback.
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This is only used by the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link compile}, {@link compileString}, {@link
|
||||
* compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
export interface LegacyPluginThis {
|
||||
/**
|
||||
* A partial representation of the options passed to {@link render} or {@link
|
||||
* renderSync}.
|
||||
*/
|
||||
options: {
|
||||
/** The same {@link LegacyPluginThis} instance that contains this object. */
|
||||
context: LegacyPluginThis;
|
||||
|
||||
/**
|
||||
* The value passed to {@link LegacyFileOptions.file} or {@link
|
||||
* LegacyStringOptions.file}.
|
||||
*/
|
||||
file?: string;
|
||||
|
||||
/** The value passed to {@link LegacyStringOptions.data}. */
|
||||
data?: string;
|
||||
|
||||
/**
|
||||
* The value passed to {@link LegacySharedOptions.includePaths} separated by
|
||||
* `";"` on Windows or `":"` on other operating systems. This always
|
||||
* includes the current working directory as the first entry.
|
||||
*/
|
||||
includePaths: string;
|
||||
|
||||
/** Always the number 10. */
|
||||
precision: 10;
|
||||
|
||||
/** Always the number 1. */
|
||||
style: 1;
|
||||
|
||||
/** 1 if {@link LegacySharedOptions.indentType} was `"tab"`, 0 otherwise. */
|
||||
indentType: 1 | 0;
|
||||
|
||||
/**
|
||||
* The value passed to {@link LegacySharedOptions.indentWidth}, or `2`
|
||||
* otherwise.
|
||||
*/
|
||||
indentWidth: number;
|
||||
|
||||
/**
|
||||
* The value passed to {@link LegacySharedOptions.linefeed}, or `"\n"`
|
||||
* otherwise.
|
||||
*/
|
||||
linefeed: '\r' | '\r\n' | '\n' | '\n\r';
|
||||
|
||||
/** A partially-constructed {@link LegacyResult} object. */
|
||||
result: {
|
||||
/** Partial information about the compilation in progress. */
|
||||
stats: {
|
||||
/**
|
||||
* The number of milliseconds between 1 January 1970 at 00:00:00 UTC and
|
||||
* the time at which Sass compilation began.
|
||||
*/
|
||||
start: number;
|
||||
|
||||
/**
|
||||
* {@link LegacyFileOptions.file} if it was passed, otherwise the string
|
||||
* `"data"`.
|
||||
*/
|
||||
entry: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
144
node_modules/sass/types/legacy/render.d.ts
generated
vendored
Normal file
144
node_modules/sass/types/legacy/render.d.ts
generated
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
import {LegacyException} from './exception';
|
||||
import {LegacyOptions} from './options';
|
||||
|
||||
/**
|
||||
* The object returned by {@link render} and {@link renderSync} after a
|
||||
* successful compilation.
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated This is only used by the legacy {@link render} and {@link
|
||||
* renderSync} APIs. Use {@link compile}, {@link compileString}, {@link
|
||||
* compileAsync}, and {@link compileStringAsync} instead.
|
||||
*/
|
||||
export interface LegacyResult {
|
||||
/**
|
||||
* The compiled CSS. This can be converted to a string by calling
|
||||
* [Buffer.toString](https://nodejs.org/api/buffer.html#buffer_buf_tostring_encoding_start_end).
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* const result = sass.renderSync({file: "style.scss"});
|
||||
*
|
||||
* console.log(result.css.toString());
|
||||
* ```
|
||||
*/
|
||||
css: Buffer;
|
||||
|
||||
/**
|
||||
* The source map that maps the compiled CSS to the source files from which it
|
||||
* was generated. This can be converted to a string by calling
|
||||
* [Buffer.toString](https://nodejs.org/api/buffer.html#buffer_buf_tostring_encoding_start_end).
|
||||
*
|
||||
* This is `undefined` unless either
|
||||
*
|
||||
* * {@link LegacySharedOptions.sourceMap} is a string; or
|
||||
* * {@link LegacySharedOptions.sourceMap} is `true` and
|
||||
* {@link LegacySharedOptions.outFile} is set.
|
||||
*
|
||||
* The source map uses absolute [`file:`
|
||||
* URLs](https://en.wikipedia.org/wiki/File_URI_scheme) to link to the Sass
|
||||
* source files, except if the source file comes from {@link
|
||||
* LegacyStringOptions.data} in which case it lists its URL as `"stdin"`.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* const result = sass.renderSync({
|
||||
* file: "style.scss",
|
||||
* sourceMap: true,
|
||||
* outFile: "style.css"
|
||||
* })
|
||||
*
|
||||
* console.log(result.map.toString());
|
||||
* ```
|
||||
*/
|
||||
map?: Buffer;
|
||||
|
||||
/** Additional information about the compilation. */
|
||||
stats: {
|
||||
/**
|
||||
* The absolute path of {@link LegacyFileOptions.file} or {@link
|
||||
* LegacyStringOptions.file}, or `"data"` if {@link
|
||||
* LegacyStringOptions.file} wasn't set.
|
||||
*/
|
||||
entry: string;
|
||||
|
||||
/**
|
||||
* The number of milliseconds between 1 January 1970 at 00:00:00 UTC and the
|
||||
* time at which Sass compilation began.
|
||||
*/
|
||||
start: number;
|
||||
|
||||
/**
|
||||
* The number of milliseconds between 1 January 1970 at 00:00:00 UTC and the
|
||||
* time at which Sass compilation ended.
|
||||
*/
|
||||
end: number;
|
||||
|
||||
/**
|
||||
* The number of milliseconds it took to compile the Sass file. This is
|
||||
* always equal to `start` minus `end`.
|
||||
*/
|
||||
duration: number;
|
||||
|
||||
/**
|
||||
* An array of the absolute paths of all Sass files loaded during
|
||||
* compilation. If a stylesheet was loaded from a {@link LegacyImporter}
|
||||
* that returned the stylesheet’s contents, the raw string of the `@use` or
|
||||
* `@import` that loaded that stylesheet included in this array.
|
||||
*/
|
||||
includedFiles: string[];
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* This function synchronously compiles a Sass file to CSS. If it succeeds, it
|
||||
* returns the result, and if it fails it throws an error.
|
||||
*
|
||||
* **Heads up!** When using the `sass-embedded` npm package, **{@link render}
|
||||
* is almost always faster than {@link renderSync}**, due to the overhead of
|
||||
* emulating synchronous messaging with worker threads and concurrent
|
||||
* compilations being blocked on main thread.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* const sass = require('sass'); // or require('node-sass');
|
||||
*
|
||||
* const result = sass.renderSync({file: "style.scss"});
|
||||
* // ...
|
||||
* ```
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated Use {@link compile} or {@link compileString} instead.
|
||||
*/
|
||||
export function renderSync(options: LegacyOptions<'sync'>): LegacyResult;
|
||||
|
||||
/**
|
||||
|
||||
* This function asynchronously compiles a Sass file to CSS, and calls
|
||||
* `callback` with a {@link LegacyResult} if compilation succeeds or {@link
|
||||
* LegacyException} if it fails.
|
||||
*
|
||||
* **Heads up!** When using the `sass` npm package, **{@link renderSync} is
|
||||
* almost twice as fast as {@link render}** by default, due to the overhead of
|
||||
* making the entire evaluation process asynchronous.
|
||||
*
|
||||
* ```js
|
||||
* const sass = require('sass'); // or require('node-sass');
|
||||
*
|
||||
* sass.render({
|
||||
* file: "style.scss"
|
||||
* }, function(err, result) {
|
||||
* // ...
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @category Legacy
|
||||
* @deprecated Use {@link compileAsync} or {@link compileStringAsync} instead.
|
||||
*/
|
||||
export function render(
|
||||
options: LegacyOptions<'async'>,
|
||||
callback: (exception?: LegacyException, result?: LegacyResult) => void
|
||||
): void;
|
||||
115
node_modules/sass/types/logger/index.d.ts
generated
vendored
Normal file
115
node_modules/sass/types/logger/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
import {Deprecation} from '../deprecations';
|
||||
import {SourceSpan} from './source_span';
|
||||
|
||||
export {SourceLocation} from './source_location';
|
||||
export {SourceSpan} from './source_span';
|
||||
|
||||
/**
|
||||
* The options passed to {@link Logger.warn}.
|
||||
*
|
||||
* * `deprecation`: Whether this is a deprecation warning.
|
||||
*
|
||||
* * `deprecationType`: The type of deprecation. Only set if `deprecation` is
|
||||
* true.
|
||||
*
|
||||
* * `span`: The location in the Sass source code that generated this warning.
|
||||
* This may be unset if the warning didn't come from Sass source, for
|
||||
* example if it's from a deprecated JavaScript option.
|
||||
*
|
||||
* * `stack`: The Sass stack trace at the point the warning was issued. This may
|
||||
* be unset if the warning didn't come from Sass source, for example if it's
|
||||
* from a deprecated JavaScript option.
|
||||
*
|
||||
* @category Logger
|
||||
*/
|
||||
export type LoggerWarnOptions = (
|
||||
| {
|
||||
deprecation: true;
|
||||
deprecationType: Deprecation;
|
||||
}
|
||||
| {deprecation: false}
|
||||
) & {
|
||||
span?: SourceSpan;
|
||||
stack?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* An object that can be passed to {@link LegacySharedOptions.logger} to control
|
||||
* how Sass emits warnings and debug messages.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* const fs = require('fs');
|
||||
* const sass = require('sass');
|
||||
*
|
||||
* let log = "";
|
||||
* sass.renderSync({
|
||||
* file: 'input.scss',
|
||||
* logger: {
|
||||
* warn(message, options) {
|
||||
* if (options.span) {
|
||||
* log += `${span.url}:${span.start.line}:${span.start.column}: ` +
|
||||
* `${message}\n`;
|
||||
* } else {
|
||||
* log += `::: ${message}\n`;
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* fs.writeFileSync('log.txt', log);
|
||||
* ```
|
||||
*
|
||||
* @category Logger
|
||||
*/
|
||||
export interface Logger {
|
||||
/**
|
||||
* This method is called when Sass emits a warning, whether due to a [`@warn`
|
||||
* rule](https://sass-lang.com/documentation/at-rules/warn) or a warning
|
||||
* generated by the Sass compiler.
|
||||
*
|
||||
* If this is `undefined`, Sass will print warnings to standard error.
|
||||
*
|
||||
* `options` may contain the following fields:
|
||||
*
|
||||
* @param message - The warning message.
|
||||
*/
|
||||
warn?(message: string, options: LoggerWarnOptions): void;
|
||||
|
||||
/**
|
||||
* This method is called when Sass emits a debug message due to a [`@debug`
|
||||
* rule](https://sass-lang.com/documentation/at-rules/debug).
|
||||
*
|
||||
* If this is `undefined`, Sass will print debug messages to standard error.
|
||||
*
|
||||
* @param message - The debug message.
|
||||
* @param options.span - The location in the Sass source code that generated this
|
||||
* debug message.
|
||||
*/
|
||||
debug?(message: string, options: {span: SourceSpan}): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* A namespace for built-in {@link Logger}s.
|
||||
*
|
||||
* @category Logger
|
||||
* @compatibility dart: "1.43.0", node: false
|
||||
*/
|
||||
export namespace Logger {
|
||||
/**
|
||||
* A {@link Logger} that silently ignores all warnings and debug messages.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* const sass = require('sass');
|
||||
*
|
||||
* const result = sass.renderSync({
|
||||
* file: 'input.scss',
|
||||
* logger: sass.Logger.silent,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export const silent: Logger;
|
||||
}
|
||||
21
node_modules/sass/types/logger/source_location.d.ts
generated
vendored
Normal file
21
node_modules/sass/types/logger/source_location.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* A specific location within a source file.
|
||||
*
|
||||
* This is always associated with a {@link SourceSpan} which indicates *which*
|
||||
* file it refers to.
|
||||
*
|
||||
* @category Logger
|
||||
*/
|
||||
export interface SourceLocation {
|
||||
/**
|
||||
* The 0-based index of this location within its source file, in terms of
|
||||
* UTF-16 code units.
|
||||
*/
|
||||
offset: number;
|
||||
|
||||
/** The 0-based line number of this location. */
|
||||
line: number;
|
||||
|
||||
/** The 0-based column number of this location. */
|
||||
column: number;
|
||||
}
|
||||
34
node_modules/sass/types/logger/source_span.d.ts
generated
vendored
Normal file
34
node_modules/sass/types/logger/source_span.d.ts
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import {SourceLocation} from './source_location';
|
||||
|
||||
/**
|
||||
* A span of text within a source file.
|
||||
*
|
||||
* @category Logger
|
||||
*/
|
||||
export interface SourceSpan {
|
||||
/** The beginning of this span, inclusive. */
|
||||
start: SourceLocation;
|
||||
|
||||
/**
|
||||
* The end of this span, exclusive.
|
||||
*
|
||||
* If {@link start} and {@link end} refer to the same location, the span has
|
||||
* zero length and refers to the point immediately after {@link start} and
|
||||
* before the next character.
|
||||
*/
|
||||
end: SourceLocation;
|
||||
|
||||
/** The canonical URL of the file this span refers to. */
|
||||
url?: URL;
|
||||
|
||||
/** The text covered by the span. */
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* Text surrounding the span.
|
||||
*
|
||||
* If this is set, it must include only whole lines, and it must include at
|
||||
* least all line(s) which are partially covered by this span.
|
||||
*/
|
||||
context?: string;
|
||||
}
|
||||
468
node_modules/sass/types/options.d.ts
generated
vendored
Normal file
468
node_modules/sass/types/options.d.ts
generated
vendored
Normal file
@@ -0,0 +1,468 @@
|
||||
import {DeprecationOrId, Version} from './deprecations';
|
||||
import {FileImporter, Importer, NodePackageImporter} from './importer';
|
||||
import {Logger} from './logger';
|
||||
import {Value} from './value';
|
||||
import {PromiseOr} from './util/promise_or';
|
||||
|
||||
/**
|
||||
* Syntaxes supported by Sass:
|
||||
*
|
||||
* - `'scss'` is the [SCSS
|
||||
* syntax](https://sass-lang.com/documentation/syntax#scss).
|
||||
* - `'indented'` is the [indented
|
||||
* syntax](https://sass-lang.com/documentation/syntax#the-indented-syntax)
|
||||
* - `'css'` is plain CSS, which is parsed like SCSS but forbids the use of any
|
||||
* special Sass features.
|
||||
*
|
||||
* @category Options
|
||||
*/
|
||||
export type Syntax = 'scss' | 'indented' | 'css';
|
||||
|
||||
/**
|
||||
* Possible output styles for the compiled CSS:
|
||||
*
|
||||
* - `"expanded"` (the default for Dart Sass) writes each selector and
|
||||
* declaration on its own line.
|
||||
*
|
||||
* - `"compressed"` removes as many extra characters as possible, and writes
|
||||
* the entire stylesheet on a single line.
|
||||
*
|
||||
* @category Options
|
||||
*/
|
||||
export type OutputStyle = 'expanded' | 'compressed';
|
||||
|
||||
/**
|
||||
* A callback that implements a custom Sass function. This can be passed to
|
||||
* {@link Options.functions}.
|
||||
*
|
||||
* ```js
|
||||
* const result = sass.compile('style.scss', {
|
||||
* functions: {
|
||||
* "sum($arg1, $arg2)": (args) => {
|
||||
* const arg1 = args[0].assertNumber('arg1');
|
||||
* const value1 = arg1.value;
|
||||
* const value2 = args[1].assertNumber('arg2')
|
||||
* .convertValueToMatch(arg1, 'arg2', 'arg1');
|
||||
* return new sass.SassNumber(value1 + value2).coerceToMatch(arg1);
|
||||
* }
|
||||
* }
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @typeParam sync - A `CustomFunction<'sync'>` must return synchronously, but
|
||||
* in return it can be passed to {@link compile} and {@link compileString} in
|
||||
* addition to {@link compileAsync} and {@link compileStringAsync}.
|
||||
*
|
||||
* A `CustomFunction<'async'>` may either return synchronously or
|
||||
* asynchronously, but it can only be used with {@link compileAsync} and {@link
|
||||
* compileStringAsync}.
|
||||
*
|
||||
* @param args - An array of arguments passed by the function's caller. If the
|
||||
* function takes [arbitrary
|
||||
* arguments](https://sass-lang.com/documentation/at-rules/function#taking-arbitrary-arguments),
|
||||
* the last element will be a {@link SassArgumentList}.
|
||||
*
|
||||
* @returns The function's result. This may be in the form of a `Promise`, but
|
||||
* if it is the function may only be passed to {@link compileAsync} and {@link
|
||||
* compileStringAsync}, not {@link compile} or {@link compileString}.
|
||||
*
|
||||
* @throws any - This function may throw an error, which the Sass compiler will
|
||||
* treat as the function call failing. If the exception object has a `message`
|
||||
* property, it will be used as the wrapped exception's message; otherwise, the
|
||||
* exception object's `toString()` will be used. This means it's safe for custom
|
||||
* functions to throw plain strings.
|
||||
*
|
||||
* @category Custom Function
|
||||
*/
|
||||
export type CustomFunction<sync extends 'sync' | 'async'> = (
|
||||
args: Value[]
|
||||
) => PromiseOr<Value, sync>;
|
||||
|
||||
/**
|
||||
* Options that can be passed to {@link compile}, {@link compileAsync}, {@link
|
||||
* compileString}, or {@link compileStringAsync}.
|
||||
*
|
||||
* @typeParam sync - This lets the TypeScript checker verify that asynchronous
|
||||
* {@link Importer}s, {@link FileImporter}s, and {@link CustomFunction}s aren't
|
||||
* passed to {@link compile} or {@link compileString}.
|
||||
*
|
||||
* @category Options
|
||||
*/
|
||||
export interface Options<sync extends 'sync' | 'async'> {
|
||||
/**
|
||||
* If this is `true`, the compiler will exclusively use ASCII characters in
|
||||
* its error and warning messages. Otherwise, it may use non-ASCII Unicode
|
||||
* characters as well.
|
||||
*
|
||||
* @defaultValue `false`
|
||||
* @category Messages
|
||||
*/
|
||||
alertAscii?: boolean;
|
||||
|
||||
/**
|
||||
* If this is `true`, the compiler will use ANSI color escape codes in its
|
||||
* error and warning messages. If it's `false`, it won't use these. If it's
|
||||
* undefined, the compiler will determine whether or not to use colors
|
||||
* depending on whether the user is using an interactive terminal.
|
||||
*
|
||||
* @category Messages
|
||||
*/
|
||||
alertColor?: boolean;
|
||||
|
||||
/**
|
||||
* If `true`, the compiler may prepend `@charset "UTF-8";` or U+FEFF
|
||||
* (byte-order marker) if it outputs non-ASCII CSS.
|
||||
*
|
||||
* If `false`, the compiler never emits these byte sequences. This is ideal
|
||||
* when concatenating or embedding in HTML `<style>` tags. (The output will
|
||||
* still be UTF-8.)
|
||||
*
|
||||
* @defaultValue `true`
|
||||
* @category Output
|
||||
* @compatibility dart: "1.54.0", node: false
|
||||
*/
|
||||
charset?: boolean;
|
||||
|
||||
/**
|
||||
* A set of deprecations to treat as fatal.
|
||||
*
|
||||
* If a deprecation warning of any provided type is encountered during
|
||||
* compilation, the compiler will error instead.
|
||||
*
|
||||
* If a `Version` is provided, then all deprecations that were active in that
|
||||
* compiler version will be treated as fatal.
|
||||
*
|
||||
* @category Messages
|
||||
* @compatiblity dart: "1.74.0", node: false
|
||||
*/
|
||||
fatalDeprecations?: (DeprecationOrId | Version)[];
|
||||
|
||||
/**
|
||||
* Additional built-in Sass functions that are available in all stylesheets.
|
||||
* This option takes an object whose keys are Sass function signatures like
|
||||
* you'd write for the [`@function
|
||||
* rule`](https://sass-lang.com/documentation/at-rules/function) and whose
|
||||
* values are {@link CustomFunction}s.
|
||||
*
|
||||
* Functions are passed subclasses of {@link Value}, and must return the same.
|
||||
* If the return value includes {@link SassCalculation}s they will be
|
||||
* simplified before being returned.
|
||||
*
|
||||
* When writing custom functions, it's important to make them as user-friendly
|
||||
* and as close to the standards set by Sass's core functions as possible. Some
|
||||
* good guidelines to follow include:
|
||||
*
|
||||
* * Use `Value.assert*` methods, like {@link Value.assertString}, to cast
|
||||
* untyped `Value` objects to more specific types. For values that were
|
||||
* passed directly as arguments, pass in the argument name as well. This
|
||||
* ensures that the user gets good error messages when they pass in the
|
||||
* wrong type to your function.
|
||||
*
|
||||
* * Individual classes may have more specific `assert*` methods, like {@link
|
||||
* SassNumber.assertInt}, which should be used when possible.
|
||||
*
|
||||
* * In Sass, every value counts as a list. Rather than trying to detect the
|
||||
* {@link SassList} type, you should use {@link Value.asList} to treat all
|
||||
* values as lists.
|
||||
*
|
||||
* * When manipulating values like lists, strings, and numbers that have
|
||||
* metadata (comma versus space separated, bracketed versus unbracketed,
|
||||
* quoted versus unquoted, units), the output metadata should match the
|
||||
* input metadata.
|
||||
*
|
||||
* * When in doubt, lists should default to comma-separated, strings should
|
||||
* default to quoted, and numbers should default to unitless.
|
||||
*
|
||||
* * In Sass, lists and strings use one-based indexing and use negative
|
||||
* indices to index from the end of value. Functions should follow these
|
||||
* conventions. {@link Value.sassIndexToListIndex} and {@link
|
||||
* SassString.sassIndexToStringIndex} can be used to do this automatically.
|
||||
*
|
||||
* * String indexes in Sass refer to Unicode code points while JavaScript
|
||||
* string indices refer to UTF-16 code units. For example, the character
|
||||
* U+1F60A SMILING FACE WITH SMILING EYES is a single Unicode code point but
|
||||
* is represented in UTF-16 as two code units (`0xD83D` and `0xDE0A`). So in
|
||||
* JavaScript, `"a😊b".charCodeAt(1)` returns `0xD83D`, whereas in Sass
|
||||
* `str-slice("a😊b", 1, 1)` returns `"😊"`. Functions should follow Sass's
|
||||
* convention. {@link SassString.sassIndexToStringIndex} can be used to do
|
||||
* this automatically, and the {@link SassString.sassLength} getter can be
|
||||
* used to access a string's length in code points.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* sass.compileString(`
|
||||
* h1 {
|
||||
* font-size: pow(2, 5) * 1px;
|
||||
* }`, {
|
||||
* functions: {
|
||||
* // Note: in real code, you should use `math.pow()` from the built-in
|
||||
* // `sass:math` module.
|
||||
* 'pow($base, $exponent)': function(args) {
|
||||
* const base = args[0].assertNumber('base').assertNoUnits('base');
|
||||
* const exponent =
|
||||
* args[1].assertNumber('exponent').assertNoUnits('exponent');
|
||||
*
|
||||
* return new sass.SassNumber(Math.pow(base.value, exponent.value));
|
||||
* }
|
||||
* }
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @category Plugins
|
||||
*/
|
||||
functions?: Record<string, CustomFunction<sync>>;
|
||||
|
||||
/**
|
||||
* A set of future deprecations to opt into early.
|
||||
*
|
||||
* Future deprecations passed here will be treated as active by the compiler,
|
||||
* emitting warnings as necessary.
|
||||
*
|
||||
* @category Messages
|
||||
* @compatiblity dart: "1.74.0", node: false
|
||||
*/
|
||||
futureDeprecations?: DeprecationOrId[];
|
||||
|
||||
/**
|
||||
* Custom importers that control how Sass resolves loads from rules like
|
||||
* [`@use`](https://sass-lang.com/documentation/at-rules/use) and
|
||||
* [`@import`](https://sass-lang.com/documentation/at-rules/import).
|
||||
*
|
||||
* Loads are resolved by trying, in order:
|
||||
*
|
||||
* - **For relative URLs only:** the URL resolved relative to the current
|
||||
* stylesheet's canonical URL, passed to the importer that loaded the current
|
||||
* stylesheet.
|
||||
*
|
||||
* When calling {@link compileString} or {@link compileStringAsync}, the
|
||||
* entrypoint file isn't "loaded" in the same sense as other files. In that
|
||||
* case:
|
||||
*
|
||||
* - {@link StringOptions.url} is the canonical URL and {@link
|
||||
* StringOptions.importer} is the importer that loaded it.
|
||||
*
|
||||
* - If {@link StringOptions.importer} isn't passed and {@link
|
||||
* StringOptions.url} is a `file:` URL, the URL is loaded from the
|
||||
* filesystem by default. (You can disable this by passing `{canonicalize:
|
||||
* url => null}` as {@link StringOptions.importer}.)
|
||||
*
|
||||
* - If {@link StringOptions.url} isn't passed but {@link
|
||||
* StringOptions.importer} is, the relative URL is passed to {@link
|
||||
* StringOptions.importer} as-is.
|
||||
*
|
||||
* - Each {@link Importer}, {@link FileImporter}, or
|
||||
* {@link NodePackageImporter} in {@link importers}, in order.
|
||||
*
|
||||
* - Each load path in {@link loadPaths}, in order.
|
||||
*
|
||||
* If none of these return a Sass file, the load fails and Sass throws an
|
||||
* error.
|
||||
*
|
||||
* @category Plugins
|
||||
*/
|
||||
importers?: (Importer<sync> | FileImporter<sync> | NodePackageImporter)[];
|
||||
|
||||
/**
|
||||
* Paths in which to look for stylesheets loaded by rules like
|
||||
* [`@use`](https://sass-lang.com/documentation/at-rules/use) and
|
||||
* [`@import`](https://sass-lang.com/documentation/at-rules/import).
|
||||
*
|
||||
* A load path `loadPath` is equivalent to the following {@link FileImporter}:
|
||||
*
|
||||
* ```js
|
||||
* {
|
||||
* findFileUrl(url) {
|
||||
* // Load paths only support relative URLs.
|
||||
* if (/^[a-z]+:/i.test(url)) return null;
|
||||
* return new URL(url, pathToFileURL(loadPath));
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @category Input
|
||||
*/
|
||||
loadPaths?: string[];
|
||||
|
||||
/**
|
||||
* An object to use to handle warnings and/or debug messages from Sass.
|
||||
*
|
||||
* By default, Sass emits warnings and debug messages to standard error, but
|
||||
* if {@link Logger.warn} or {@link Logger.debug} is set, this will invoke
|
||||
* them instead.
|
||||
*
|
||||
* The special value {@link Logger.silent} can be used to easily silence all
|
||||
* messages.
|
||||
*
|
||||
* @category Messages
|
||||
*/
|
||||
logger?: Logger;
|
||||
|
||||
/**
|
||||
* If this option is set to `true`, Sass won’t print warnings that are caused
|
||||
* by dependencies. A “dependency” is defined as any file that’s loaded
|
||||
* through {@link loadPaths} or {@link importers}. Stylesheets that are
|
||||
* imported relative to the entrypoint are not considered dependencies.
|
||||
*
|
||||
* This is useful for silencing deprecation warnings that you can’t fix on
|
||||
* your own. However, please <em>also</em> notify your dependencies of the deprecations
|
||||
* so that they can get fixed as soon as possible!
|
||||
*
|
||||
* **Heads up!** If {@link compileString} or {@link compileStringAsync} is
|
||||
* called without {@link StringOptions.url}, <em>all</em> stylesheets it loads
|
||||
* will be considered dependencies. Since it doesn’t have a path of its own,
|
||||
* everything it loads is coming from a load path rather than a relative
|
||||
* import.
|
||||
*
|
||||
* @defaultValue `false`
|
||||
* @category Messages
|
||||
*/
|
||||
quietDeps?: boolean;
|
||||
|
||||
/**
|
||||
* A set of active deprecations to ignore.
|
||||
*
|
||||
* If a deprecation warning of any provided type is encountered during
|
||||
* compilation, the compiler will ignore it instead.
|
||||
*
|
||||
* **Heads up!** The deprecated functionality you're depending on will
|
||||
* eventually break.
|
||||
*
|
||||
* @category Messages
|
||||
* @compatiblity dart: "1.74.0", node: false
|
||||
*/
|
||||
silenceDeprecations?: DeprecationOrId[];
|
||||
|
||||
/**
|
||||
* Whether or not Sass should generate a source map. If it does, the source
|
||||
* map will be available as {@link CompileResult.sourceMap}.
|
||||
*
|
||||
* **Heads up!** Sass doesn't automatically add a `sourceMappingURL` comment
|
||||
* to the generated CSS. It's up to callers to do that, since callers have
|
||||
* full knowledge of where the CSS and the source map will exist in relation
|
||||
* to one another and how they'll be served to the browser.
|
||||
*
|
||||
* @defaultValue `false`
|
||||
* @category Output
|
||||
*/
|
||||
sourceMap?: boolean;
|
||||
|
||||
/**
|
||||
* Whether Sass should include the sources in the generated source map.
|
||||
*
|
||||
* This option has no effect if {@link sourceMap} is `false`.
|
||||
*
|
||||
* @defaultValue `false`
|
||||
* @category Output
|
||||
*/
|
||||
sourceMapIncludeSources?: boolean;
|
||||
|
||||
/**
|
||||
* The {@link OutputStyle} of the compiled CSS.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```js
|
||||
* const source = `
|
||||
* h1 {
|
||||
* font-size: 40px;
|
||||
* code {
|
||||
* font-face: Roboto Mono;
|
||||
* }
|
||||
* }`;
|
||||
*
|
||||
* let result = sass.compileString(source, {style: "expanded"});
|
||||
* console.log(result.css.toString());
|
||||
* // h1 {
|
||||
* // font-size: 40px;
|
||||
* // }
|
||||
* // h1 code {
|
||||
* // font-face: Roboto Mono;
|
||||
* // }
|
||||
*
|
||||
* result = sass.compileString(source, {style: "compressed"})
|
||||
* console.log(result.css.toString());
|
||||
* // h1{font-size:40px}h1 code{font-face:Roboto Mono}
|
||||
* ```
|
||||
*
|
||||
* @category Output
|
||||
*/
|
||||
style?: OutputStyle;
|
||||
|
||||
/**
|
||||
* By default, Dart Sass will print only five instances of the same
|
||||
* deprecation warning per compilation to avoid deluging users in console
|
||||
* noise. If you set `verbose` to `true`, it will instead print every
|
||||
* deprecation warning it encounters.
|
||||
*
|
||||
* @defaultValue `false`
|
||||
* @category Messages
|
||||
*/
|
||||
verbose?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options that can be passed to {@link compileString} or {@link
|
||||
* compileStringAsync}.
|
||||
*
|
||||
* If the {@link StringOptions.importer} field isn't passed, the entrypoint file
|
||||
* can load files relative to itself if a `file://` URL is passed to the {@link
|
||||
* url} field. If `importer` is passed, the entrypoint file uses that importer
|
||||
* to load files relative to itself.
|
||||
*
|
||||
* @typeParam sync - This lets the TypeScript checker verify that asynchronous
|
||||
* {@link Importer}s, {@link FileImporter}s, and {@link CustomFunction}s aren't
|
||||
* passed to {@link compile} or {@link compileString}.
|
||||
*
|
||||
* @category Options
|
||||
*/
|
||||
export interface StringOptions<sync extends 'sync' | 'async'>
|
||||
extends Options<sync> {
|
||||
/**
|
||||
* The {@link Syntax} to use to parse the entrypoint stylesheet.
|
||||
*
|
||||
* @default `'scss'`
|
||||
*
|
||||
* @category Input
|
||||
*/
|
||||
syntax?: Syntax;
|
||||
|
||||
/**
|
||||
* The importer to use to handle relative URL loads in the entrypoint
|
||||
* stylesheet and stylesheets loaded relative to the entrypoint stylesheet.
|
||||
*
|
||||
* See {@link Options.importers} for details on how loads are resolved for the
|
||||
* entrypoint stylesheet.
|
||||
*
|
||||
* @category Input
|
||||
*/
|
||||
importer?: Importer<sync> | FileImporter<sync>;
|
||||
|
||||
/**
|
||||
* The canonical URL of the entrypoint stylesheet.
|
||||
*
|
||||
* See {@link Options.importers} for details on how loads are resolved for the
|
||||
* entrypoint stylesheet.
|
||||
*
|
||||
* @category Input
|
||||
* @compatibility feature: "Undefined URL with importer", dart: "1.75.0", node: false
|
||||
*
|
||||
* Earlier versions of Dart Sass required {@link url} to be defined when
|
||||
* passing {@link StringOptions.importer}.
|
||||
*/
|
||||
url?: URL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @category Options
|
||||
* @deprecated Use {@link StringOptions} instead.
|
||||
*/
|
||||
type StringOptionsWithoutImporter<sync extends 'sync' | 'async'> =
|
||||
StringOptions<sync>;
|
||||
|
||||
/**
|
||||
* @category Options
|
||||
* @deprecated Use {@link StringOptions} instead.
|
||||
*/
|
||||
type StringOptionsWithImporter<sync extends 'sync' | 'async'> =
|
||||
StringOptions<sync>;
|
||||
17
node_modules/sass/types/util/promise_or.d.ts
generated
vendored
Normal file
17
node_modules/sass/types/util/promise_or.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* A utility type for choosing between synchronous and asynchronous return
|
||||
* values.
|
||||
*
|
||||
* This is used as the return value for plugins like {@link CustomFunction},
|
||||
* {@link Importer}, and {@link FileImporter} so that TypeScript enforces that
|
||||
* asynchronous plugins are only passed to {@link compileAsync} and {@link
|
||||
* compileStringAsync}, not {@link compile} or {@link compileString}.
|
||||
*
|
||||
* @typeParam sync - If this is `'sync'`, this can only be a `T`. If it's
|
||||
* `'async'`, this can be either a `T` or a `Promise<T>`.
|
||||
*
|
||||
* @category Other
|
||||
*/
|
||||
export type PromiseOr<T, sync extends 'sync' | 'async'> = sync extends 'async'
|
||||
? T | Promise<T>
|
||||
: T;
|
||||
47
node_modules/sass/types/value/argument_list.d.ts
generated
vendored
Normal file
47
node_modules/sass/types/value/argument_list.d.ts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import {List, OrderedMap} from 'immutable';
|
||||
|
||||
import {Value} from './index';
|
||||
import {SassList, ListSeparator} from './list';
|
||||
|
||||
/**
|
||||
* Sass's [argument list
|
||||
* type](https://sass-lang.com/documentation/values/lists#argument-lists).
|
||||
*
|
||||
* An argument list comes from a rest argument. It's distinct from a normal
|
||||
* {@link SassList} in that it may contain a keyword map as well as the
|
||||
* positional arguments.
|
||||
*
|
||||
* @category Custom Function
|
||||
*/
|
||||
export class SassArgumentList extends SassList {
|
||||
/**
|
||||
* Creates a new argument list.
|
||||
*
|
||||
* @param contents - The positional arguments that make up the primary
|
||||
* contents of the list. This may be either a plain JavaScript array or an
|
||||
* immutable {@link List} from the [`immutable`
|
||||
* package](https://immutable-js.com/).
|
||||
*
|
||||
* @param keywords - The keyword arguments attached to this argument list,
|
||||
* whose names should exclude `$`. This can be either a plain JavaScript
|
||||
* object with argument names as fields, or an immutable {@link OrderedMap}
|
||||
* from the [`immutable` package](https://immutable-js.com/)
|
||||
*
|
||||
* @param separator - The separator for this list. Defaults to `','`.
|
||||
*/
|
||||
constructor(
|
||||
contents: Value[] | List<Value>,
|
||||
keywords: Record<string, Value> | OrderedMap<string, Value>,
|
||||
separator?: ListSeparator
|
||||
);
|
||||
|
||||
/**
|
||||
* The keyword arguments attached to this argument list.
|
||||
*
|
||||
* The argument names don't include `$`.
|
||||
*
|
||||
* @returns An immutable {@link OrderedMap} from the [`immutable`
|
||||
* package](https://immutable-js.com/).
|
||||
*/
|
||||
get keywords(): OrderedMap<string, Value>;
|
||||
}
|
||||
29
node_modules/sass/types/value/boolean.d.ts
generated
vendored
Normal file
29
node_modules/sass/types/value/boolean.d.ts
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
import {Value} from './index';
|
||||
|
||||
/**
|
||||
* Sass's [`true` value](https://sass-lang.com/documentation/values/booleans).
|
||||
*
|
||||
* @category Custom Function
|
||||
*/
|
||||
export const sassTrue: SassBoolean;
|
||||
|
||||
/**
|
||||
* Sass's [`false` value](https://sass-lang.com/documentation/values/booleans).
|
||||
*
|
||||
* @category Custom Function
|
||||
*/
|
||||
export const sassFalse: SassBoolean;
|
||||
|
||||
/**
|
||||
* Sass's [boolean type](https://sass-lang.com/documentation/values/booleans).
|
||||
*
|
||||
* @category Custom Function
|
||||
*/
|
||||
export class SassBoolean extends Value {
|
||||
private constructor();
|
||||
|
||||
/**
|
||||
* Whether this value is `true` or `false`.
|
||||
*/
|
||||
get value(): boolean;
|
||||
}
|
||||
137
node_modules/sass/types/value/calculation.d.ts
generated
vendored
Normal file
137
node_modules/sass/types/value/calculation.d.ts
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
import {List, ValueObject} from 'immutable';
|
||||
import {Value, SassNumber, SassString} from './index';
|
||||
|
||||
/**
|
||||
* The type of values that can be arguments to a {@link SassCalculation}.
|
||||
* @category Custom Function
|
||||
* */
|
||||
export type CalculationValue =
|
||||
| SassNumber
|
||||
| SassCalculation
|
||||
| SassString
|
||||
| CalculationOperation
|
||||
| CalculationInterpolation;
|
||||
|
||||
/**
|
||||
* Sass's [calculation
|
||||
* type](https://sass-lang.com/documentation/values/calculations).
|
||||
*
|
||||
* Note: in the JS API calculations are not simplified eagerly. This also means
|
||||
* that unsimplified calculations are not equal to the numbers they would be
|
||||
* simplified to.
|
||||
*
|
||||
* @category Custom Function
|
||||
*/
|
||||
export class SassCalculation extends Value {
|
||||
/**
|
||||
* Creates a value that represents `calc(argument)`.
|
||||
*
|
||||
* @throws `Error` if `argument` is a quoted {@link SassString}
|
||||
* @returns A calculation with the name `calc` and `argument` as its single
|
||||
* argument.
|
||||
*/
|
||||
static calc(argument: CalculationValue): SassCalculation;
|
||||
|
||||
/**
|
||||
* Creates a value that represents `min(arguments...)`.
|
||||
*
|
||||
* @throws `Error` if `arguments` contains a quoted {@link SassString}
|
||||
* @returns A calculation with the name `min` and `arguments` as its
|
||||
* arguments.
|
||||
*/
|
||||
static min(
|
||||
arguments: CalculationValue[] | List<CalculationValue>
|
||||
): SassCalculation;
|
||||
|
||||
/**
|
||||
* Creates a value that represents `max(arguments...)`.
|
||||
*
|
||||
* @throws `Error` if `arguments` contains a quoted {@link SassString}
|
||||
* @returns A calculation with the name `max` and `arguments` as its
|
||||
* arguments.
|
||||
*/
|
||||
static max(
|
||||
arguments: CalculationValue[] | List<CalculationValue>
|
||||
): SassCalculation;
|
||||
|
||||
/**
|
||||
* Creates a value that represents `clamp(value, min, max)`.
|
||||
*
|
||||
* @throws `Error` if any of `value`, `min`, or `max` are a quoted
|
||||
* {@link SassString}.
|
||||
* @throws `Error` if `value` is undefined and `max` is not undefined.
|
||||
* @throws `Error` if either `value` or `max` is undefined and neither `min`
|
||||
nor `value` is a {@link SassString} or {@link CalculationInterpolation}.
|
||||
@returns A calculation with the name `clamp` and `min`, `value`, and `max`
|
||||
as it's arguments, excluding any arguments that are undefined.
|
||||
*/
|
||||
static clamp(
|
||||
min: CalculationValue,
|
||||
value?: CalculationValue,
|
||||
max?: CalculationValue
|
||||
): SassCalculation;
|
||||
|
||||
/** Returns the calculation's `name` field. */
|
||||
get name(): string;
|
||||
|
||||
/** Returns a list of the calculation's `arguments` */
|
||||
get arguments(): List<CalculationValue>;
|
||||
}
|
||||
|
||||
/**
|
||||
* The set of possible operators in a Sass calculation.
|
||||
* @category Custom Function
|
||||
*/
|
||||
export type CalculationOperator = '+' | '-' | '*' | '/';
|
||||
|
||||
/**
|
||||
* A binary operation that can appear in a {@link SassCalculation}.
|
||||
* @category Custom Function
|
||||
*/
|
||||
export class CalculationOperation implements ValueObject {
|
||||
/**
|
||||
* Creates a Sass CalculationOperation with the given `operator`, `left`, and
|
||||
* `right` values.
|
||||
* @throws `Error` if `left` or `right` are quoted {@link SassString}s.
|
||||
*/
|
||||
constructor(
|
||||
operator: CalculationOperator,
|
||||
left: CalculationValue,
|
||||
right: CalculationValue
|
||||
);
|
||||
|
||||
/** Returns the operation's `operator` field. */
|
||||
get operator(): CalculationOperator;
|
||||
|
||||
/** Returns the operation's `left` field. */
|
||||
get left(): CalculationValue;
|
||||
|
||||
/** Returns the operation's `right` field. */
|
||||
get right(): CalculationValue;
|
||||
|
||||
equals(other: unknown): boolean;
|
||||
|
||||
hashCode(): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A string injected into a {@link SassCalculation} using interpolation. Unlike
|
||||
* unquoted strings, interpolations are always surrounded in parentheses when
|
||||
* they appear in {@link CalculationOperation}s.
|
||||
* @category Custom Function
|
||||
*/
|
||||
export class CalculationInterpolation implements ValueObject {
|
||||
/**
|
||||
* Creates a Sass CalculationInterpolation with the given `value`.
|
||||
*/
|
||||
constructor(value: string);
|
||||
|
||||
/**
|
||||
* Returns the interpolation's `value` field.
|
||||
*/
|
||||
get value(): string;
|
||||
|
||||
equals(other: unknown): boolean;
|
||||
|
||||
hashCode(): number;
|
||||
}
|
||||
566
node_modules/sass/types/value/color.d.ts
generated
vendored
Normal file
566
node_modules/sass/types/value/color.d.ts
generated
vendored
Normal file
@@ -0,0 +1,566 @@
|
||||
import {List} from 'immutable';
|
||||
|
||||
import {Value} from './index';
|
||||
|
||||
/** The HSL color space name. */
|
||||
export type ColorSpaceHsl = 'hsl';
|
||||
|
||||
/** The HSL color space channel names. */
|
||||
export type ChannelNameHsl = 'hue' | 'saturation' | 'lightness' | 'alpha';
|
||||
|
||||
/** The HWB color space name. */
|
||||
export type ColorSpaceHwb = 'hwb';
|
||||
|
||||
/** The HWB color space channel names. */
|
||||
export type ChannelNameHwb = 'hue' | 'whiteness' | 'blackness' | 'alpha';
|
||||
|
||||
/** The Lab / Oklab color space names. */
|
||||
export type ColorSpaceLab = 'lab' | 'oklab';
|
||||
|
||||
/** The Lab / Oklab color space channel names. */
|
||||
export type ChannelNameLab = 'lightness' | 'a' | 'b' | 'alpha';
|
||||
|
||||
/** The LCH / Oklch color space names. */
|
||||
export type ColorSpaceLch = 'lch' | 'oklch';
|
||||
|
||||
/** The LCH / Oklch color space channel names. */
|
||||
export type ChannelNameLch = 'lightness' | 'chroma' | 'hue' | 'alpha';
|
||||
|
||||
/** Names of color spaces with RGB channels. */
|
||||
export type ColorSpaceRgb =
|
||||
| 'a98-rgb'
|
||||
| 'display-p3'
|
||||
| 'prophoto-rgb'
|
||||
| 'rec2020'
|
||||
| 'rgb'
|
||||
| 'srgb'
|
||||
| 'srgb-linear';
|
||||
|
||||
/** RGB channel names. */
|
||||
export type ChannelNameRgb = 'red' | 'green' | 'blue' | 'alpha';
|
||||
|
||||
/** Names of color spaces with XYZ channels. */
|
||||
export type ColorSpaceXyz = 'xyz' | 'xyz-d50' | 'xyz-d65';
|
||||
|
||||
/** XYZ channel names. */
|
||||
export type ChannelNameXyz = 'x' | 'y' | 'z' | 'alpha';
|
||||
|
||||
/** All supported color space channel names. */
|
||||
export type ChannelName =
|
||||
| ChannelNameHsl
|
||||
| ChannelNameHwb
|
||||
| ChannelNameLab
|
||||
| ChannelNameLch
|
||||
| ChannelNameRgb
|
||||
| ChannelNameXyz;
|
||||
|
||||
/** All supported color space names. */
|
||||
export type KnownColorSpace =
|
||||
| ColorSpaceHsl
|
||||
| ColorSpaceHwb
|
||||
| ColorSpaceLab
|
||||
| ColorSpaceLch
|
||||
| ColorSpaceRgb
|
||||
| ColorSpaceXyz;
|
||||
|
||||
/** Polar color space names (HSL, HWB, LCH, and Oklch spaces). */
|
||||
export type PolarColorSpace = ColorSpaceHsl | ColorSpaceHwb | ColorSpaceLch;
|
||||
|
||||
/** Rectangular color space names (Lab, Oklab, RGB, and XYZ spaces). */
|
||||
export type RectangularColorSpace = Exclude<KnownColorSpace, PolarColorSpace>;
|
||||
|
||||
/**
|
||||
* Methods by which two hues are adjusted when interpolating between polar
|
||||
* colors.
|
||||
*/
|
||||
export type HueInterpolationMethod =
|
||||
| 'decreasing'
|
||||
| 'increasing'
|
||||
| 'longer'
|
||||
| 'shorter';
|
||||
|
||||
/**
|
||||
* Methods by which colors in bounded spaces can be mapped to within their
|
||||
* gamut.
|
||||
*
|
||||
* * `local-minde`: The algorithm specified in [the original Color Level 4
|
||||
* candidate recommendation]. This maps in the Oklch color space, using the
|
||||
* [deltaEOK] color difference formula and the [local-MINDE] improvement.
|
||||
*
|
||||
* * `clip`: Clamp each color channel that's outside the gamut to the minimum or
|
||||
* maximum value for that channel. This algorithm will produce poor visual
|
||||
* results, but it may be useful to match the behavior of other situations in
|
||||
* which a color can be clipped.
|
||||
*
|
||||
* [the original Color Level 4 candidate recommendation]: https://www.w3.org/TR/2024/CRD-css-color-4-20240213/#css-gamut-mapping
|
||||
* [deltaEOK]: https://www.w3.org/TR/2024/CRD-css-color-4-20240213/#color-difference-OK
|
||||
* [local-MINDE]: https://www.w3.org/TR/2024/CRD-css-color-4-20240213/#GM-chroma-local-MINDE
|
||||
*/
|
||||
export type GamutMapMethod = 'clip' | 'local-minde';
|
||||
|
||||
/**
|
||||
* Sass's [color type](https://sass-lang.com/documentation/values/colors).
|
||||
*
|
||||
* No matter what representation was originally used to create this color, all
|
||||
* of its channels are accessible.
|
||||
*
|
||||
* @category Custom Function
|
||||
*/
|
||||
export class SassColor extends Value {
|
||||
/**
|
||||
* Creates an [RGB color].
|
||||
*
|
||||
* If `space` is missing, **only** `undefined` should be used to indicate that
|
||||
* `alpha` isn't passed. If `null` is used instead, it will be treated as a
|
||||
* [missing component]. See [breaking changes] for details.
|
||||
*
|
||||
* If `space` is defined and `null` is passed for any component, it will be
|
||||
* treated as a [missing component].
|
||||
*
|
||||
* [RGB color]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb
|
||||
* [missing component]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#missing_color_components
|
||||
* [breaking changes]: /documentation/breaking-changes/null-alpha
|
||||
*
|
||||
* @throws `Error` if `alpha` is set and isn't `null` or a number between `0`
|
||||
* and `1`.
|
||||
*/
|
||||
constructor(options: {
|
||||
red: number | null;
|
||||
green: number | null;
|
||||
blue: number | null;
|
||||
alpha?: number | null;
|
||||
space?: 'rgb';
|
||||
});
|
||||
|
||||
/**
|
||||
* Creates an [HSL color].
|
||||
*
|
||||
* If `space` is missing, **only** `undefined` should be used to indicate that
|
||||
* `alpha` isn't passed. If `null` is used instead, it will be treated as a
|
||||
* [missing component]. See [breaking changes] for details.
|
||||
*
|
||||
* If `space` is defined and `null` is passed for any component, it will be
|
||||
* treated as a [missing component].
|
||||
*
|
||||
* [HSL color]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl
|
||||
* [missing component]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#missing_color_components
|
||||
* [breaking changes]: /documentation/breaking-changes/null-alpha
|
||||
*
|
||||
* @throws `Error` if `alpha` is set and isn't `null` or a number between `0`
|
||||
* and `1`.
|
||||
*/
|
||||
constructor(options: {
|
||||
hue: number | null;
|
||||
saturation: number | null;
|
||||
lightness: number | null;
|
||||
alpha?: number | null;
|
||||
space?: ColorSpaceHsl;
|
||||
});
|
||||
|
||||
/**
|
||||
* Creates an [HWB color].
|
||||
*
|
||||
* If `space` is missing, **only** `undefined` should be used to indicate that
|
||||
* `alpha` isn't passed. If `null` is used instead, it will be treated as a
|
||||
* [missing component]. See [breaking changes] for details.
|
||||
*
|
||||
* If `space` is defined and `null` is passed for any component, it will be
|
||||
* treated as a [missing component].
|
||||
*
|
||||
* [HWB color]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hwb
|
||||
* [missing component]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#missing_color_components
|
||||
* [breaking changes]: /documentation/breaking-changes/null-alpha
|
||||
*
|
||||
* @throws `Error` if `alpha` is set and isn't `null` or a number between `0`
|
||||
* and `1`.
|
||||
*/
|
||||
constructor(options: {
|
||||
hue: number | null;
|
||||
whiteness: number | null;
|
||||
blackness: number | null;
|
||||
alpha?: number | null;
|
||||
space?: ColorSpaceHwb;
|
||||
});
|
||||
|
||||
/**
|
||||
* Creates a [Lab] or [Oklab] color.
|
||||
*
|
||||
* If `null` is passed for any component, it will be treated as a [missing
|
||||
* component].
|
||||
*
|
||||
* [Lab]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lab
|
||||
* [Oklab]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/oklab
|
||||
* [missing component]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#missing_color_components
|
||||
*
|
||||
* @throws `Error` if `alpha` is set and isn't `null` or a number between `0`
|
||||
* and `1`.
|
||||
*/
|
||||
constructor(options: {
|
||||
lightness: number | null;
|
||||
a: number | null;
|
||||
b: number | null;
|
||||
alpha?: number | null;
|
||||
space: ColorSpaceLab;
|
||||
});
|
||||
|
||||
/**
|
||||
* Creates an [LCH] or [Oklch] color.
|
||||
*
|
||||
* If `null` is passed for any component, it will be treated as a [missing
|
||||
* component].
|
||||
*
|
||||
* [LCH]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lch
|
||||
* [Oklch]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/oklch
|
||||
* [missing component]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#missing_color_components
|
||||
*
|
||||
* @throws `Error` if `alpha` is set and isn't `null` or a number between `0`
|
||||
* and `1`.
|
||||
*/
|
||||
constructor(options: {
|
||||
lightness: number | null;
|
||||
chroma: number | null;
|
||||
hue: number | null;
|
||||
alpha?: number | null;
|
||||
space: ColorSpaceLch;
|
||||
});
|
||||
|
||||
/**
|
||||
* Creates a color in a predefined [RGB color space].
|
||||
*
|
||||
* If `null` is passed for any component, it will be treated as a [missing
|
||||
* component].
|
||||
*
|
||||
* [RGB color space]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color#using_predefined_colorspaces_with_color
|
||||
* [missing component]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#missing_color_components
|
||||
*
|
||||
* @throws `Error` if `alpha` is set and isn't `null` or a number between `0`
|
||||
* and `1`.
|
||||
*/
|
||||
constructor(options: {
|
||||
red: number | null;
|
||||
green: number | null;
|
||||
blue: number | null;
|
||||
alpha?: number | null;
|
||||
space: Exclude<ColorSpaceRgb, 'rgb'>;
|
||||
});
|
||||
|
||||
/**
|
||||
* Creates a color in a predefined [XYZ color space].
|
||||
*
|
||||
* If `null` is passed for any component, it will be treated as a [missing
|
||||
* component].
|
||||
*
|
||||
* [XYZ color space]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color#using_the_xyz_colorspace_with_color
|
||||
* [missing component]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#missing_color_components
|
||||
*
|
||||
* @throws `Error` if `alpha` is set and isn't `null` or a number between `0`
|
||||
* and `1`.
|
||||
*/
|
||||
constructor(options: {
|
||||
x: number | null;
|
||||
y: number | null;
|
||||
z: number | null;
|
||||
alpha?: number | null;
|
||||
space: ColorSpaceXyz;
|
||||
});
|
||||
|
||||
/** The name of this color's space. */
|
||||
get space(): KnownColorSpace;
|
||||
|
||||
/**
|
||||
* Returns a new color that's the result of converting this color to the
|
||||
* specified `space`.
|
||||
*/
|
||||
toSpace(space: KnownColorSpace): SassColor;
|
||||
|
||||
/**
|
||||
* A boolean indicating whether this color is in a legacy color space (`rgb`,
|
||||
* `hsl`, or `hwb`).
|
||||
*/
|
||||
get isLegacy(): boolean;
|
||||
|
||||
/**
|
||||
* Returns a boolean indicating whether this color is in-gamut (as opposed to
|
||||
* having one or more of its channels out of bounds) for the specified
|
||||
* `space`, or its current color space if `space` is not specified.
|
||||
*/
|
||||
isInGamut(space?: KnownColorSpace): boolean;
|
||||
|
||||
/**
|
||||
* Returns a copy of this color, modified so it is in-gamut for the specified
|
||||
* `space`—or the current color space if `space` is not specified—using
|
||||
* `method` to map out-of-gamut colors into the desired gamut.
|
||||
*/
|
||||
toGamut(options: {
|
||||
space?: KnownColorSpace;
|
||||
method: GamutMapMethod;
|
||||
}): SassColor;
|
||||
|
||||
/**
|
||||
* A list of this color's channel values (excluding alpha), with [missing
|
||||
* channels] converted to `null`.
|
||||
*
|
||||
* [missing channels]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#missing_color_components
|
||||
*/
|
||||
get channelsOrNull(): List<number | null>;
|
||||
|
||||
/**
|
||||
* A list of this color's channel values (excluding alpha), with [missing
|
||||
* channels] converted to `0`.
|
||||
*
|
||||
* [missing channels]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#missing_color_components
|
||||
*/
|
||||
get channels(): List<number>;
|
||||
|
||||
/**
|
||||
* Returns the value of a single specified `channel` of this color, with
|
||||
* [missing channels] converted to `0`.
|
||||
*
|
||||
* [missing channels]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#missing_color_components
|
||||
*
|
||||
* @throws `Error` if `channel` is not `alpha` or a channel in this color's
|
||||
* space.
|
||||
*/
|
||||
channel(channel: ChannelName): number;
|
||||
|
||||
/**
|
||||
* Returns the value of a single specified `channel` of this color after
|
||||
* converting this color to the specified `space`, with [missing channels]
|
||||
* converted to `0`.
|
||||
*
|
||||
* [missing channels]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#missing_color_components
|
||||
*
|
||||
* @throws `Error` if `channel` is not `alpha` or a channel in `space`.
|
||||
*/
|
||||
channel(channel: ChannelNameHsl, options: {space: ColorSpaceHsl}): number;
|
||||
channel(channel: ChannelNameHwb, options: {space: ColorSpaceHwb}): number;
|
||||
channel(channel: ChannelNameLab, options: {space: ColorSpaceLab}): number;
|
||||
channel(channel: ChannelNameLch, options: {space: ColorSpaceLch}): number;
|
||||
channel(channel: ChannelNameRgb, options: {space: ColorSpaceRgb}): number;
|
||||
channel(channel: ChannelNameXyz, options: {space: ColorSpaceXyz}): number;
|
||||
|
||||
/** This color's alpha channel, between `0` and `1`. */
|
||||
get alpha(): number;
|
||||
|
||||
/**
|
||||
* Returns a boolean indicating whether a given channel value is a [missing
|
||||
* channel].
|
||||
*
|
||||
* [missing channel]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#missing_color_components
|
||||
*/
|
||||
isChannelMissing(channel: ChannelName): boolean;
|
||||
|
||||
/**
|
||||
* Returns a boolean indicating whether a given `channel` is [powerless] in
|
||||
* this color. This is a special state that's defined for individual color
|
||||
* spaces, which indicates that a channel's value won't affect how a color is
|
||||
* displayed.
|
||||
*
|
||||
* [powerless]: https://www.w3.org/TR/css-color-4/#powerless
|
||||
*/
|
||||
isChannelPowerless(channel: ChannelName): boolean;
|
||||
isChannelPowerless(
|
||||
channel: ChannelNameHsl,
|
||||
options?: {space: ColorSpaceHsl}
|
||||
): boolean;
|
||||
isChannelPowerless(
|
||||
channel: ChannelNameHwb,
|
||||
options?: {space: ColorSpaceHwb}
|
||||
): boolean;
|
||||
isChannelPowerless(
|
||||
channel: ChannelNameLab,
|
||||
options?: {space: ColorSpaceLab}
|
||||
): boolean;
|
||||
isChannelPowerless(
|
||||
channel: ChannelNameLch,
|
||||
options?: {space: ColorSpaceLch}
|
||||
): boolean;
|
||||
isChannelPowerless(
|
||||
channel: ChannelNameRgb,
|
||||
options?: {space: ColorSpaceRgb}
|
||||
): boolean;
|
||||
isChannelPowerless(
|
||||
channel: ChannelNameXyz,
|
||||
options?: {space: ColorSpaceXyz}
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* Returns a color partway between this color and `color2` according to
|
||||
* `method`, as defined by the CSS Color 4 [color interpolation] procedure.
|
||||
*
|
||||
* [color interpolation]: https://www.w3.org/TR/css-color-4/#interpolation
|
||||
*
|
||||
* If `method` is missing and this color is in a rectangular color space (Lab,
|
||||
* Oklab, RGB, and XYZ spaces), `method` defaults to the color space of this
|
||||
* color. Otherwise, `method` defaults to a space separated list containing
|
||||
* the color space of this color and the string "shorter".
|
||||
*
|
||||
* The `weight` is a number between 0 and 1 that indicates how much of this
|
||||
* color should be in the resulting color. If omitted, it defaults to 0.5.
|
||||
*/
|
||||
interpolate(
|
||||
color2: SassColor,
|
||||
options?: {
|
||||
weight?: number;
|
||||
method?: HueInterpolationMethod;
|
||||
}
|
||||
): SassColor;
|
||||
|
||||
/**
|
||||
* Returns a new color that's the result of changing one or more of this
|
||||
* color's HSL channels.
|
||||
*
|
||||
* @throws `Error` if `space` is missing and this color is not in a legacy
|
||||
* color space (`rgb`, `hsl`, or `hwb`).
|
||||
* @throws `Error` if `alpha` is set and isn't `null` or a number between `0`
|
||||
* and `1`.
|
||||
*/
|
||||
change(
|
||||
options: {
|
||||
[key in ChannelNameHsl]?: number | null;
|
||||
} & {
|
||||
space?: ColorSpaceHsl;
|
||||
}
|
||||
): SassColor;
|
||||
|
||||
/**
|
||||
* Returns a new color that's the result of changing one or more of this
|
||||
* color's HWB channels.
|
||||
*
|
||||
* @throws `Error` if `space` is missing and this color is not in a legacy
|
||||
* color space (`rgb`, `hsl`, or `hwb`).
|
||||
* @throws `Error` if `alpha` is set and isn't `null` or a number between `0`
|
||||
* and `1`.
|
||||
*/
|
||||
change(
|
||||
options: {
|
||||
[key in ChannelNameHwb]?: number | null;
|
||||
} & {
|
||||
space?: ColorSpaceHwb;
|
||||
}
|
||||
): SassColor;
|
||||
|
||||
/**
|
||||
* Returns a new color that's the result of changing one or more of this
|
||||
* color's Lab channels.
|
||||
*
|
||||
* @throws `Error` if `space` is missing and this color is not in the Lab or
|
||||
* Oklab color spaces.
|
||||
* @throws `Error` if `alpha` is set and isn't `null` or a number between `0`
|
||||
* and `1`.
|
||||
*/
|
||||
change(
|
||||
options: {
|
||||
[key in ChannelNameLab]?: number | null;
|
||||
} & {
|
||||
space?: ColorSpaceLab;
|
||||
}
|
||||
): SassColor;
|
||||
|
||||
/**
|
||||
* Returns a new color that's the result of changing one or more of this
|
||||
* color's LCH channels.
|
||||
*
|
||||
* @throws `Error` if `space` is missing and this color is not in the LCH or
|
||||
* Oklch color spaces.
|
||||
* @throws `Error` if `alpha` is set and isn't `null` or a number between `0`
|
||||
* and `1`.
|
||||
*/
|
||||
change(
|
||||
options: {
|
||||
[key in ChannelNameLch]?: number | null;
|
||||
} & {
|
||||
space?: ColorSpaceLch;
|
||||
}
|
||||
): SassColor;
|
||||
|
||||
/**
|
||||
* Returns a new color that's the result of changing one or more of this
|
||||
* color's RGB channels.
|
||||
*
|
||||
* @throws `Error` if `space` is missing and this color is not in a legacy
|
||||
* color space (`rgb`, `hsl`, or `hwb`).
|
||||
* @throws `Error` if `alpha` is set and isn't `null` or a number between `0`
|
||||
* and `1`.
|
||||
*/
|
||||
change(
|
||||
options: {
|
||||
[key in ChannelNameRgb]?: number | null;
|
||||
} & {
|
||||
space?: ColorSpaceRgb;
|
||||
}
|
||||
): SassColor;
|
||||
|
||||
/**
|
||||
* Returns a new color that's the result of changing one or more of this
|
||||
* color's XYZ channels.
|
||||
*
|
||||
* @throws `Error` if `space` is missing and this color is not in an XYZ color
|
||||
* space.
|
||||
* @throws `Error` if `alpha` is set and isn't `null` or a number between `0`
|
||||
* and `1`.
|
||||
*/
|
||||
change(
|
||||
options: {
|
||||
[key in ChannelNameXyz]?: number | null;
|
||||
} & {
|
||||
space?: ColorSpaceXyz;
|
||||
}
|
||||
): SassColor;
|
||||
|
||||
/**
|
||||
* This color's red channel in the RGB color space.
|
||||
*
|
||||
* @deprecated Use {@link channel} instead.
|
||||
*/
|
||||
get red(): number;
|
||||
|
||||
/**
|
||||
* This color's green channel in the RGB color space.
|
||||
*
|
||||
* @deprecated Use {@link channel} instead.
|
||||
*/
|
||||
get green(): number;
|
||||
|
||||
/**
|
||||
* This color's blue channel in the RGB color space.
|
||||
*
|
||||
* @deprecated Use {@link channel} instead.
|
||||
*/
|
||||
get blue(): number;
|
||||
|
||||
/**
|
||||
* This color's hue in the HSL color space.
|
||||
*
|
||||
* @deprecated Use {@link channel} instead.
|
||||
*/
|
||||
get hue(): number;
|
||||
|
||||
/**
|
||||
* This color's saturation in the HSL color space.
|
||||
*
|
||||
* @deprecated Use {@link channel} instead.
|
||||
*/
|
||||
get saturation(): number;
|
||||
|
||||
/**
|
||||
* This color's lightness in the HSL color space.
|
||||
*
|
||||
* @deprecated Use {@link channel} instead.
|
||||
*/
|
||||
get lightness(): number;
|
||||
|
||||
/**
|
||||
* This color's whiteness in the HWB color space.
|
||||
*
|
||||
* @deprecated Use {@link channel} instead.
|
||||
*/
|
||||
get whiteness(): number;
|
||||
|
||||
/**
|
||||
* This color's blackness in the HWB color space.
|
||||
*
|
||||
* @deprecated Use {@link channel} instead.
|
||||
*/
|
||||
get blackness(): number;
|
||||
}
|
||||
22
node_modules/sass/types/value/function.d.ts
generated
vendored
Normal file
22
node_modules/sass/types/value/function.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import {Value} from './index';
|
||||
|
||||
/**
|
||||
* Sass's [function type](https://sass-lang.com/documentation/values/functions).
|
||||
*
|
||||
* **Heads up!** Although first-class Sass functions can be processed by custom
|
||||
* functions, there's no way to invoke them outside of a Sass stylesheet.
|
||||
*
|
||||
* @category Custom Function
|
||||
*/
|
||||
export class SassFunction extends Value {
|
||||
/**
|
||||
* Creates a new first-class function that can be invoked using
|
||||
* [`meta.call()`](https://sass-lang.com/documentation/modules/meta#call).
|
||||
*
|
||||
* @param signature - The function signature, like you'd write for the
|
||||
* [`@function rule`](https://sass-lang.com/documentation/at-rules/function).
|
||||
* @param callback - The callback that's invoked when this function is called,
|
||||
* just like for a {@link CustomFunction}.
|
||||
*/
|
||||
constructor(signature: string, callback: (args: Value[]) => Value);
|
||||
}
|
||||
219
node_modules/sass/types/value/index.d.ts
generated
vendored
Normal file
219
node_modules/sass/types/value/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
import {List, ValueObject} from 'immutable';
|
||||
|
||||
import {SassBoolean} from './boolean';
|
||||
import {SassCalculation} from './calculation';
|
||||
import {SassColor} from './color';
|
||||
import {SassFunction} from './function';
|
||||
import {ListSeparator} from './list';
|
||||
import {SassMap} from './map';
|
||||
import {SassMixin} from './mixin';
|
||||
import {SassNumber} from './number';
|
||||
import {SassString} from './string';
|
||||
|
||||
export {SassArgumentList} from './argument_list';
|
||||
export {SassBoolean, sassTrue, sassFalse} from './boolean';
|
||||
export {
|
||||
SassCalculation,
|
||||
CalculationValue,
|
||||
CalculationOperator,
|
||||
CalculationOperation,
|
||||
CalculationInterpolation,
|
||||
} from './calculation';
|
||||
export {
|
||||
SassColor,
|
||||
ColorSpaceHsl,
|
||||
ChannelNameHsl,
|
||||
ColorSpaceHwb,
|
||||
ChannelNameHwb,
|
||||
ColorSpaceLab,
|
||||
ChannelNameLab,
|
||||
ColorSpaceLch,
|
||||
ChannelNameLch,
|
||||
ColorSpaceRgb,
|
||||
ChannelNameRgb,
|
||||
ColorSpaceXyz,
|
||||
ChannelNameXyz,
|
||||
ChannelName,
|
||||
GamutMapMethod,
|
||||
KnownColorSpace,
|
||||
PolarColorSpace,
|
||||
RectangularColorSpace,
|
||||
HueInterpolationMethod,
|
||||
} from './color';
|
||||
export {SassFunction} from './function';
|
||||
export {SassList, ListSeparator} from './list';
|
||||
export {SassMap} from './map';
|
||||
export {SassMixin} from './mixin';
|
||||
export {SassNumber} from './number';
|
||||
export {SassString} from './string';
|
||||
|
||||
/**
|
||||
* Sass's [`null` value](https://sass-lang.com/documentation/values/null).
|
||||
*
|
||||
* @category Custom Function
|
||||
*/
|
||||
export const sassNull: Value;
|
||||
|
||||
/**
|
||||
* The abstract base class of Sass's value types.
|
||||
*
|
||||
* This is passed to and returned by {@link CustomFunction}s, which are passed
|
||||
* into the Sass implementation using {@link Options.functions}.
|
||||
*
|
||||
* @category Custom Function
|
||||
*/
|
||||
export abstract class Value implements ValueObject {
|
||||
protected constructor();
|
||||
|
||||
/**
|
||||
* This value as a list.
|
||||
*
|
||||
* All SassScript values can be used as lists. Maps count as lists of pairs,
|
||||
* and all other values count as single-value lists.
|
||||
*
|
||||
* @returns An immutable {@link List} from the [`immutable`
|
||||
* package](https://immutable-js.com/).
|
||||
*/
|
||||
get asList(): List<Value>;
|
||||
|
||||
/**
|
||||
* Whether this value as a list has brackets.
|
||||
*
|
||||
* All SassScript values can be used as lists. Maps count as lists of pairs,
|
||||
* and all other values count as single-value lists.
|
||||
*/
|
||||
get hasBrackets(): boolean;
|
||||
|
||||
/**
|
||||
* Whether the value counts as `true` in an `@if` statement and other
|
||||
* contexts.
|
||||
*/
|
||||
get isTruthy(): boolean;
|
||||
|
||||
/**
|
||||
* Returns JavaScript's `null` value if this is {@link sassNull}, and returns
|
||||
* `this` otherwise.
|
||||
*/
|
||||
get realNull(): null | Value;
|
||||
|
||||
/**
|
||||
* The separator for this value as a list.
|
||||
*
|
||||
* All SassScript values can be used as lists. Maps count as lists of pairs,
|
||||
* and all other values count as single-value lists.
|
||||
*/
|
||||
get separator(): ListSeparator;
|
||||
|
||||
/**
|
||||
* Converts `sassIndex` into a JavaScript-style index into the list returned
|
||||
* by {@link asList}.
|
||||
*
|
||||
* Sass indexes are one-based, while JavaScript indexes are zero-based. Sass
|
||||
* indexes may also be negative in order to index from the end of the list.
|
||||
*
|
||||
* @param sassIndex - The Sass-style index into this as a list.
|
||||
* @param name - The name of the function argument `sassIndex` came from
|
||||
* (without the `$`) if it came from an argument. Used for error reporting.
|
||||
* @throws `Error` If `sassIndex` isn't a number, if that number isn't an
|
||||
* integer, or if that integer isn't a valid index for {@link asList}.
|
||||
*/
|
||||
sassIndexToListIndex(sassIndex: Value, name?: string): number;
|
||||
|
||||
/**
|
||||
* Returns the value at index `index` in this value as a list, or `undefined`
|
||||
* if `index` isn't valid for this list.
|
||||
*
|
||||
* All SassScript values can be used as lists. Maps count as lists of pairs,
|
||||
* and all other values count as single-value lists.
|
||||
*
|
||||
* This is a shorthand for `this.asList.get(index)`, although it may be more
|
||||
* efficient in some cases.
|
||||
*
|
||||
* **Heads up!** This method uses the same indexing conventions as the
|
||||
* `immutable` package: unlike Sass the index of the first element is 0, but
|
||||
* like Sass negative numbers index from the end of the list.
|
||||
*/
|
||||
get(index: number): Value | undefined;
|
||||
|
||||
/**
|
||||
* Throws if `this` isn't a {@link SassBoolean}.
|
||||
*
|
||||
* **Heads up!** Functions should generally use {@link isTruthy} rather than
|
||||
* requiring a literal boolean.
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
assertBoolean(name?: string): SassBoolean;
|
||||
|
||||
/**
|
||||
* Throws if `this` isn't a {@link SassCalculation}.
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
assertCalculation(name?: string): SassCalculation;
|
||||
|
||||
/**
|
||||
* Throws if `this` isn't a {@link SassColor}.
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
assertColor(name?: string): SassColor;
|
||||
|
||||
/**
|
||||
* Throws if `this` isn't a {@link SassFunction}.
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
assertFunction(name?: string): SassFunction;
|
||||
|
||||
/**
|
||||
* Throws if `this` isn't a {@link SassMap}.
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
assertMap(name?: string): SassMap;
|
||||
|
||||
/**
|
||||
* Throws if `this` isn't a {@link SassMixin}.
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
assertMixin(name?: string): SassMixin;
|
||||
|
||||
/**
|
||||
* Throws if `this` isn't a {@link SassNumber}.
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
assertNumber(name?: string): SassNumber;
|
||||
|
||||
/**
|
||||
* Throws if `this` isn't a {@link SassString}.
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
assertString(name?: string): SassString;
|
||||
|
||||
/**
|
||||
* Returns `this` as a map if it counts as one (empty lists count as empty
|
||||
* maps) or `null` if it doesn't.
|
||||
*/
|
||||
tryMap(): SassMap | null;
|
||||
|
||||
/** Returns whether `this` represents the same value as `other`. */
|
||||
equals(other: Value): boolean;
|
||||
|
||||
/** Returns a hash code that can be used to store `this` in a hash map. */
|
||||
hashCode(): number;
|
||||
|
||||
/** @hidden */
|
||||
toString(): string;
|
||||
}
|
||||
54
node_modules/sass/types/value/list.d.ts
generated
vendored
Normal file
54
node_modules/sass/types/value/list.d.ts
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
import {List} from 'immutable';
|
||||
|
||||
import {Value} from './index';
|
||||
|
||||
/**
|
||||
* Possible separators used by Sass lists. The special separator `null` is only
|
||||
* used for lists with fewer than two elements, and indicates that the separator
|
||||
* has not yet been decided for this list.
|
||||
*
|
||||
* @category Custom Function
|
||||
*/
|
||||
export type ListSeparator = ',' | '/' | ' ' | null;
|
||||
|
||||
/**
|
||||
* Sass's [list type](https://sass-lang.com/documentation/values/lists).
|
||||
*
|
||||
* @category Custom Function
|
||||
*/
|
||||
export class SassList extends Value {
|
||||
/**
|
||||
* Creates a new list.
|
||||
*
|
||||
* @param contents - The contents of the list. This may be either a plain
|
||||
* JavaScript array or an immutable {@link List} from the [`immutable`
|
||||
* package](https://immutable-js.com/).
|
||||
*
|
||||
* @param options.separator - The separator to use between elements of this
|
||||
* list. Defaults to `','`.
|
||||
*
|
||||
* @param options.brackets - Whether the list has square brackets. Defaults to
|
||||
* `false`.
|
||||
*/
|
||||
constructor(
|
||||
contents: Value[] | List<Value>,
|
||||
options?: {
|
||||
separator?: ListSeparator;
|
||||
brackets?: boolean;
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Creates an empty list.
|
||||
*
|
||||
* @param options.separator - The separator to use between elements of this
|
||||
* list. Defaults to `','`.
|
||||
*
|
||||
* @param options.brackets - Whether the list has square brackets. Defaults to
|
||||
* `false`.
|
||||
*/
|
||||
constructor(options?: {separator?: ListSeparator; brackets?: boolean});
|
||||
|
||||
/** @hidden */
|
||||
get separator(): ListSeparator;
|
||||
}
|
||||
41
node_modules/sass/types/value/map.d.ts
generated
vendored
Normal file
41
node_modules/sass/types/value/map.d.ts
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
import {OrderedMap} from 'immutable';
|
||||
|
||||
import {SassList} from './list';
|
||||
import {Value} from './index';
|
||||
|
||||
/**
|
||||
* Sass's [map type](https://sass-lang.com/documentation/values/maps).
|
||||
*
|
||||
* @category Custom Function
|
||||
*/
|
||||
export class SassMap extends Value {
|
||||
/**
|
||||
* Creates a new map.
|
||||
*
|
||||
* @param contents - The contents of the map. This is an immutable
|
||||
* `OrderedMap` from the [`immutable` package](https://immutable-js.com/).
|
||||
* Defaults to an empty map.
|
||||
*/
|
||||
constructor(contents?: OrderedMap<Value, Value>);
|
||||
|
||||
/**
|
||||
* Returns the contents of this map as an immutable {@link OrderedMap} from the
|
||||
* [`immutable` package](https://immutable-js.com/).
|
||||
*/
|
||||
get contents(): OrderedMap<Value, Value>;
|
||||
|
||||
/**
|
||||
* Returns the value associated with `key` in this map, or `undefined` if
|
||||
* `key` isn't in the map.
|
||||
*
|
||||
* This is a shorthand for `this.contents.get(key)`, although it may be more
|
||||
* efficient in some cases.
|
||||
*/
|
||||
get(key: Value): Value | undefined;
|
||||
|
||||
/** Inherited from {@link Value.get}. */
|
||||
get(index: number): SassList | undefined;
|
||||
|
||||
/** @hidden */
|
||||
tryMap(): SassMap;
|
||||
}
|
||||
14
node_modules/sass/types/value/mixin.d.ts
generated
vendored
Normal file
14
node_modules/sass/types/value/mixin.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import {Value} from './index';
|
||||
|
||||
/**
|
||||
* Sass's [mixin type](https://sass-lang.com/documentation/values/mixins).
|
||||
*
|
||||
* @category Custom Function
|
||||
*/
|
||||
export class SassMixin extends Value {
|
||||
/**
|
||||
* It is not possible to construct a Sass mixin outside of Sass. Attempting to
|
||||
* construct one will throw an exception.
|
||||
*/
|
||||
constructor();
|
||||
}
|
||||
305
node_modules/sass/types/value/number.d.ts
generated
vendored
Normal file
305
node_modules/sass/types/value/number.d.ts
generated
vendored
Normal file
@@ -0,0 +1,305 @@
|
||||
import {List} from 'immutable';
|
||||
|
||||
import {Value} from './index';
|
||||
|
||||
/**
|
||||
* Sass's [number type](https://sass-lang.com/documentation/values/numbers).
|
||||
*
|
||||
* @category Custom Function
|
||||
*/
|
||||
export class SassNumber extends Value {
|
||||
/**
|
||||
* Creates a new number with more complex units than just a single numerator.
|
||||
*
|
||||
* Upon construction, any compatible numerator and denominator units are
|
||||
* simplified away according to the conversion factor between them.
|
||||
*
|
||||
* @param value - The number's numeric value.
|
||||
*
|
||||
* @param unit - If this is a string, it's used as the single numerator unit
|
||||
* for the number.
|
||||
*
|
||||
* @param unit.numeratorUnits - If passed, these are the numerator units to
|
||||
* use for the number. This may be either a plain JavaScript array or an
|
||||
* immutable {@link List} from the [`immutable`
|
||||
* package](https://immutable-js.com/).
|
||||
*
|
||||
* @param unit.denominatorUnits - If passed, these are the denominator units
|
||||
* to use for the number. This may be either a plain JavaScript array or an
|
||||
* immutable {@link List} from the [`immutable`
|
||||
* package](https://immutable-js.com/).
|
||||
*/
|
||||
constructor(
|
||||
value: number,
|
||||
unit?:
|
||||
| string
|
||||
| {
|
||||
numeratorUnits?: string[] | List<string>;
|
||||
denominatorUnits?: string[] | List<string>;
|
||||
}
|
||||
);
|
||||
|
||||
/** This number's numeric value. */
|
||||
get value(): number;
|
||||
|
||||
/** Whether {@link value} is an integer according to Sass's equality logic. */
|
||||
get isInt(): boolean;
|
||||
|
||||
/**
|
||||
* If {@link value} is an integer according to {@link isInt}, returns {@link
|
||||
* value} rounded to that integer. If it's not an integer, returns `null`.
|
||||
*/
|
||||
get asInt(): number | null;
|
||||
|
||||
/**
|
||||
* This number's numerator units as an immutable {@link List} from the
|
||||
* [`immutable` package](https://immutable-js.com/).
|
||||
*/
|
||||
get numeratorUnits(): List<string>;
|
||||
|
||||
/**
|
||||
* This number's denominator units as an immutable {@link List} from the
|
||||
* [`immutable` package](https://immutable-js.com/).
|
||||
*/
|
||||
get denominatorUnits(): List<string>;
|
||||
|
||||
/** Whether this number has any numerator or denominator units. */
|
||||
get hasUnits(): boolean;
|
||||
|
||||
/**
|
||||
* If {@link value} is an integer according to {@link isInt}, returns it
|
||||
* rounded to that integer. Otherwise, throws an error.
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
assertInt(name?: string): number;
|
||||
|
||||
/**
|
||||
* Returns {@link value} if it's within `min` and `max`. If {@link value} is
|
||||
* equal to `min` or `max` according to Sass's equality, returns `min` or
|
||||
* `max` respectively. Otherwise, throws an error.
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
assertInRange(min: number, max: number, name?: string): number;
|
||||
|
||||
/**
|
||||
* If this number has no units, returns it. Otherwise, throws an error.
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
assertNoUnits(name?: string): SassNumber;
|
||||
|
||||
/**
|
||||
* If this number has `unit` as its only unit (and as a numerator), returns
|
||||
* this number. Otherwise, throws an error.
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
assertUnit(unit: string, name?: string): SassNumber;
|
||||
|
||||
/** Whether this number has `unit` as its only unit (and as a numerator). */
|
||||
hasUnit(unit: string): boolean;
|
||||
|
||||
/**
|
||||
* Whether this has exactly one numerator unit, and that unit is compatible
|
||||
* with `unit`.
|
||||
*/
|
||||
compatibleWithUnit(unit: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns a copy of this number, converted to the units represented by
|
||||
* `newNumerators` and `newDenominators`.
|
||||
*
|
||||
* @throws `Error` if this number's units are incompatible with
|
||||
* `newNumerators` and `newDenominators`; or if this number is unitless and
|
||||
* either `newNumerators` or `newDenominators` are not empty, or vice-versa.
|
||||
*
|
||||
* @param newNumerators - The numerator units to convert this number to. This
|
||||
* may be either a plain JavaScript array or an immutable {@link List} from
|
||||
* the [`immutable` package](https://immutable-js.com/).
|
||||
*
|
||||
* @param newDenominators - The denominator units to convert this number to.
|
||||
* This may be either a plain JavaScript array or an immutable {@link List}
|
||||
* from the [`immutable` package](https://immutable-js.com/).
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
convert(
|
||||
newNumerators: string[] | List<string>,
|
||||
newDenominators: string[] | List<string>,
|
||||
name?: string
|
||||
): SassNumber;
|
||||
|
||||
/**
|
||||
* Returns a copy of this number, converted to the same units as `other`.
|
||||
*
|
||||
* @throws `Error` if this number's units are incompatible with `other`'s
|
||||
* units, or if either number is unitless but the other is not.
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*
|
||||
* @param otherName - The name of the function argument `other` came from
|
||||
* (without the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
convertToMatch(
|
||||
other: SassNumber,
|
||||
name?: string,
|
||||
otherName?: string
|
||||
): SassNumber;
|
||||
|
||||
/**
|
||||
* Returns {@link value}, converted to the units represented by
|
||||
* `newNumerators` and `newDenominators`.
|
||||
*
|
||||
* @throws `Error` if this number's units are incompatible with
|
||||
* `newNumerators` and `newDenominators`; or if this number is unitless and
|
||||
* either `newNumerators` or `newDenominators` are not empty, or vice-versa.
|
||||
*
|
||||
* @param newNumerators - The numerator units to convert {@link value} to.
|
||||
* This may be either a plain JavaScript array or an immutable {@link List}
|
||||
* from the [`immutable` package](https://immutable-js.com/).
|
||||
*
|
||||
* @param newDenominators - The denominator units to convert {@link value} to.
|
||||
* This may be either a plain JavaScript array or an immutable {@link List}
|
||||
* from the [`immutable` package](https://immutable-js.com/).
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
convertValue(
|
||||
newNumerators: string[] | List<string>,
|
||||
newDenominators: string[] | List<string>,
|
||||
name?: string
|
||||
): number;
|
||||
|
||||
/**
|
||||
* Returns {@link value}, converted to the same units as `other`.
|
||||
*
|
||||
* @throws `Error` if this number's units are incompatible with `other`'s
|
||||
* units, or if either number is unitless but the other is not.
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*
|
||||
* @param otherName - The name of the function argument `other` came from
|
||||
* (without the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
convertValueToMatch(
|
||||
other: SassNumber,
|
||||
name?: string,
|
||||
otherName?: string
|
||||
): number;
|
||||
|
||||
/**
|
||||
* Returns a copy of this number, converted to the units represented by
|
||||
* `newNumerators` and `newDenominators`.
|
||||
*
|
||||
* Unlike {@link convert} this does *not* throw an error if this number is
|
||||
* unitless and either `newNumerators` or `newDenominators` are not empty, or
|
||||
* vice-versa. Instead, it treats all unitless numbers as convertible to and
|
||||
* from all units without changing the value.
|
||||
*
|
||||
* @throws `Error` if this number's units are incompatible with
|
||||
* `newNumerators` and `newDenominators`.
|
||||
*
|
||||
* @param newNumerators - The numerator units to convert this number to. This
|
||||
* may be either a plain JavaScript array or an immutable {@link List} from
|
||||
* the [`immutable` package](https://immutable-js.com/).
|
||||
*
|
||||
* @param newDenominators - The denominator units to convert this number to.
|
||||
* This may be either a plain JavaScript array or an immutable {@link List}
|
||||
* from the [`immutable` package](https://immutable-js.com/).
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
coerce(
|
||||
newNumerators: string[] | List<string>,
|
||||
newDenominators: string[] | List<string>,
|
||||
name?: string
|
||||
): SassNumber;
|
||||
|
||||
/**
|
||||
* Returns a copy of this number, converted to the units represented by
|
||||
* `newNumerators` and `newDenominators`.
|
||||
*
|
||||
* Unlike {@link convertToMatch} this does *not* throw an error if this number
|
||||
* is unitless and either `newNumerators` or `newDenominators` are not empty,
|
||||
* or vice-versa. Instead, it treats all unitless numbers as convertible to
|
||||
* and from all units without changing the value.
|
||||
*
|
||||
* @throws `Error` if this number's units are incompatible with `other`'s
|
||||
* units.
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*
|
||||
* @param otherName - The name of the function argument `other` came from
|
||||
* (without the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
coerceToMatch(
|
||||
other: SassNumber,
|
||||
name?: string,
|
||||
otherName?: string
|
||||
): SassNumber;
|
||||
|
||||
/**
|
||||
* Returns {@link value}, converted to the units represented by
|
||||
* `newNumerators` and `newDenominators`.
|
||||
*
|
||||
* Unlike {@link convertValue} this does *not* throw an error if this number
|
||||
* is unitless and either `newNumerators` or `newDenominators` are not empty,
|
||||
* or vice-versa. Instead, it treats all unitless numbers as convertible to
|
||||
* and from all units without changing the value.
|
||||
*
|
||||
* @throws `Error` if this number's units are incompatible with
|
||||
* `newNumerators` and `newDenominators`.
|
||||
*
|
||||
* @param newNumerators - The numerator units to convert {@link value} to.
|
||||
* This may be either a plain JavaScript array or an immutable {@link List}
|
||||
* from the [`immutable` package](https://immutable-js.com/).
|
||||
*
|
||||
* @param newDenominators - The denominator units to convert {@link value} to.
|
||||
* This may be either a plain JavaScript array or an immutable {@link List}
|
||||
* from the [`immutable` package](https://immutable-js.com/).
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
coerceValue(
|
||||
newNumerators: string[] | List<string>,
|
||||
newDenominators: string[] | List<string>,
|
||||
name?: string
|
||||
): number;
|
||||
|
||||
/**
|
||||
* Returns {@link value}, converted to the units represented by
|
||||
* `newNumerators` and `newDenominators`.
|
||||
*
|
||||
* Unlike {@link convertValueToMatch} this does *not* throw an error if this
|
||||
* number is unitless and either `newNumerators` or `newDenominators` are not
|
||||
* empty, or vice-versa. Instead, it treats all unitless numbers as
|
||||
* convertible to and from all units without changing the value.
|
||||
*
|
||||
* @throws `Error` if this number's units are incompatible with `other`'s
|
||||
* units.
|
||||
*
|
||||
* @param name - The name of the function argument `this` came from (without
|
||||
* the `$`) if it came from an argument. Used for error reporting.
|
||||
*
|
||||
* @param otherName - The name of the function argument `other` came from
|
||||
* (without the `$`) if it came from an argument. Used for error reporting.
|
||||
*/
|
||||
coerceValueToMatch(
|
||||
other: SassNumber,
|
||||
name?: string,
|
||||
otherName?: string
|
||||
): number;
|
||||
}
|
||||
84
node_modules/sass/types/value/string.d.ts
generated
vendored
Normal file
84
node_modules/sass/types/value/string.d.ts
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
import {Value} from './index';
|
||||
|
||||
/**
|
||||
* Sass's [string type](https://sass-lang.com/documentation/values/strings).
|
||||
*
|
||||
* @category Custom Function
|
||||
*/
|
||||
export class SassString extends Value {
|
||||
/**
|
||||
* Creates a new string.
|
||||
*
|
||||
* @param text - The contents of the string. For quoted strings, this is the
|
||||
* semantic content—any escape sequences that were been written in the source
|
||||
* text are resolved to their Unicode values. For unquoted strings, though,
|
||||
* escape sequences are preserved as literal backslashes.
|
||||
*
|
||||
* @param options.quotes - Whether the string is quoted. Defaults to `true`.
|
||||
*/
|
||||
constructor(
|
||||
text: string,
|
||||
options?: {
|
||||
quotes?: boolean;
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Creates an empty string.
|
||||
*
|
||||
* @param options.quotes - Whether the string is quoted. Defaults to `true`.
|
||||
*/
|
||||
constructor(options?: {quotes?: boolean});
|
||||
|
||||
/**
|
||||
* The contents of the string.
|
||||
*
|
||||
* For quoted strings, this is the semantic content—any escape sequences that
|
||||
* were been written in the source text are resolved to their Unicode values.
|
||||
* For unquoted strings, though, escape sequences are preserved as literal
|
||||
* backslashes.
|
||||
*
|
||||
* This difference allows us to distinguish between identifiers with escapes,
|
||||
* such as `url\u28 http://example.com\u29`, and unquoted strings that contain
|
||||
* characters that aren't valid in identifiers, such as
|
||||
* `url(http://example.com)`. Unfortunately, it also means that we don't
|
||||
* consider `foo` and `f\6F\6F` the same string.
|
||||
*/
|
||||
get text(): string;
|
||||
|
||||
/** Whether this string has quotes. */
|
||||
get hasQuotes(): boolean;
|
||||
|
||||
/**
|
||||
* Sass's notion of this string's length.
|
||||
*
|
||||
* Sass treats strings as a series of Unicode code points while JavaScript
|
||||
* treats them as a series of UTF-16 code units. For example, the character
|
||||
* U+1F60A SMILING FACE WITH SMILING EYES is a single Unicode code point but
|
||||
* is represented in UTF-16 as two code units (`0xD83D` and `0xDE0A`). So in
|
||||
* JavaScript, `"n😊b".length` returns `4`, whereas in Sass
|
||||
* `string.length("n😊b")` returns `3`.
|
||||
*/
|
||||
get sassLength(): number;
|
||||
|
||||
/**
|
||||
* Converts `sassIndex` to a JavaScript index into {@link text}.
|
||||
*
|
||||
* Sass indices are one-based, while JavaScript indices are zero-based. Sass
|
||||
* indices may also be negative in order to index from the end of the string.
|
||||
*
|
||||
* In addition, Sass indices refer to Unicode code points while JavaScript
|
||||
* string indices refer to UTF-16 code units. For example, the character
|
||||
* U+1F60A SMILING FACE WITH SMILING EYES is a single Unicode code point but
|
||||
* is represented in UTF-16 as two code units (`0xD83D` and `0xDE0A`). So in
|
||||
* JavaScript, `"n😊b".charCodeAt(1)` returns `0xD83D`, whereas in Sass
|
||||
* `string.slice("n😊b", 1, 1)` returns `"😊"`.
|
||||
*
|
||||
* This function converts Sass's code point indices to JavaScript's code unit
|
||||
* indices. This means it's O(n) in the length of `text`.
|
||||
*
|
||||
* @throws `Error` - If `sassIndex` isn't a number, if that number isn't an
|
||||
* integer, or if that integer isn't a valid index for this string.
|
||||
*/
|
||||
sassIndexToStringIndex(sassIndex: Value, name?: string): number;
|
||||
}
|
||||
Reference in New Issue
Block a user