Updated the files.
This commit is contained in:
parent
1553e6b971
commit
753967d4f5
23418 changed files with 3784666 additions and 0 deletions
69
my-app/node_modules/resolve-url-loader/CHANGELOG.md
generated
vendored
Executable file
69
my-app/node_modules/resolve-url-loader/CHANGELOG.md
generated
vendored
Executable file
|
|
@ -0,0 +1,69 @@
|
|||
# resolve-url-loader
|
||||
|
||||
## Version 5
|
||||
|
||||
**Features**
|
||||
|
||||
* Update `postcss` and completely remove `rework` parser.
|
||||
|
||||
**Breaking Changes**
|
||||
|
||||
* Require `node@>=12`.
|
||||
* Support `webpack@>=4` (no longer tested for earlier versions).
|
||||
* The `engine` option has been removed.
|
||||
|
||||
**Migrating**
|
||||
|
||||
Remove the `engine` option if you are using it.
|
||||
|
||||
## Version 4
|
||||
|
||||
**Features**
|
||||
|
||||
* Better resolution of the original source location - You can more successfully use `url()` in variables and mixins.
|
||||
* Dependencies now accept a wider range and explicit dependency on `rework` and `rework-visit` has been removed.
|
||||
|
||||
**Breaking Changes**
|
||||
|
||||
* The `engine` option is deprecated which means the old `rework` engine is deprecated.
|
||||
* The `keepQuery` behaviour is now the default, the `keepQuery` option has been removed.
|
||||
* The `removeCR` option defaults to `true` when executing on Windows OS.
|
||||
* The `absolute` option has been removed.
|
||||
* The `join` option has changed.
|
||||
|
||||
**Migrating**
|
||||
|
||||
Remove the `engine` option if you are using it - the default "postcss" engine is much more reliable. The "rework" engine will still work for now but will be removed in the next major version.
|
||||
|
||||
Remove the `keepQuery` option if you are using it.
|
||||
|
||||
Remove the `absolute` option, webpack should work fine without it. If you have a specific need to rebase `url()` then you should use a separate loader.
|
||||
|
||||
If you use a custom `join` function then you will need to refactor it to the new API. Refer to the advanced usage documentation.
|
||||
|
||||
If you wish to still use `engine: "rework"` then note that `rework` and `rework-visit` packages are now `peerDependencies` that must be explicitly installed by you.
|
||||
|
||||
## Version 3
|
||||
|
||||
**Features**
|
||||
|
||||
* Use `postcss` parser by default. This is long overdue as the old `rework` parser doesn't cope with modern css.
|
||||
|
||||
* Lots of automated tests running actual webpack builds. If you have an interesting use-case let me know.
|
||||
|
||||
**Breaking Changes**
|
||||
|
||||
* Multiple options changed or deprecated.
|
||||
* Removed file search "magic" in favour of `join` option.
|
||||
* Errors always fail and are no longer swallowed.
|
||||
* Processing absolute asset paths requires `root` option to be set.
|
||||
|
||||
**Migrating**
|
||||
|
||||
Initially set option `engine: 'rework'` for parity with your existing build. Once working you can remove this option **or** set `engine: 'postcss'` explicitly.
|
||||
|
||||
Retain `keepQuery` option if you are already using it.
|
||||
|
||||
The `root` option now has a different meaning. Previously it limited file search. Now it is the base path for absolute or root-relative URIs, consistent with `css-loader`. If you are already using it you can probably remove it.
|
||||
|
||||
If you build on Windows platform **and** your content contains absolute asset paths, then `css-loader` could fail. The `root` option here may fix the URIs before they get to `css-loader`. Try to leave it unspecified, otherwise (windows only) set to empty string `root: ''`.
|
||||
21
my-app/node_modules/resolve-url-loader/LICENSE
generated
vendored
Executable file
21
my-app/node_modules/resolve-url-loader/LICENSE
generated
vendored
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Ben Holloway
|
||||
|
||||
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.
|
||||
136
my-app/node_modules/resolve-url-loader/README.md
generated
vendored
Executable file
136
my-app/node_modules/resolve-url-loader/README.md
generated
vendored
Executable file
|
|
@ -0,0 +1,136 @@
|
|||
# Resolve URL Loader
|
||||
|
||||
[](https://www.npmjs.com/package/resolve-url-loader)
|
||||
|
||||
This **webpack loader** allows you to have a distributed set SCSS files and assets co-located with those SCSS files.
|
||||
|
||||
## Do you organise your SCSS and assets by feature?
|
||||
|
||||
Where are your assets?
|
||||
|
||||
* ✅ I want my assets all over the place, next to my SCSS files.
|
||||
* ❌ My assets are in a single directory.
|
||||
|
||||
How complicated is your SASS?
|
||||
|
||||
* ✅ I have a deep SASS composition with partials importing other partials.
|
||||
* ✅ My asset paths are constructed by functions or `@mixin`s.
|
||||
* ❌ I have a single SCSS file. The asset paths are just explicit in that.
|
||||
|
||||
What asset paths are you using?
|
||||
|
||||
* ✅ Fully relative `url(./foo.png)` or `url(foo.png)`
|
||||
* ❌ Root relative `url(/foo.png)`
|
||||
* ❌ Relative to some package or webpack root `url(~stuff/foo.png`)
|
||||
* ❌ Relative to some variable which is your single asset directory `url($variable/foo.png)`
|
||||
|
||||
What webpack errors are you getting?
|
||||
|
||||
* ✅ Webpack can't find the relative asset `foo.png` 😞
|
||||
* ❌ Webpack says it doesn't have a loader for `fully/resolved/path/foo.png` 😕
|
||||
|
||||
If you can tick at least 1 item in **all of these questions** then use this loader. It will allow webpack to find assets with **fully relative paths**.
|
||||
|
||||
If for any question you can't tick _any_ items then webpack should be able to already find your assets. You don't need this loader. 🤷
|
||||
|
||||
Once webpack resolves your assets (even if it complains about loading them) then this loading is working correctly. 👍
|
||||
|
||||
## What's the problem with SASS?
|
||||
|
||||
When you use **fully relative paths** in `url()` statements then Webpack expects to find those assets next to the root SCSS file, regardless of where you specify the `url()`.
|
||||
|
||||
To illustrate here are 3 simple examples of SASS and Webpack _without_ `resolve-url-loader`.
|
||||
|
||||
[](docs/basic-problem.svg)
|
||||
|
||||
The first 2 cases are trivial and work fine. The asset is specified in the root SCSS file and Webpack finds it.
|
||||
|
||||
But any practical SASS composition will have nested SCSS files, as in the 3rd case. Here Webpack cannot find the asset.
|
||||
|
||||
```
|
||||
Module not found: Can't resolve './cool.png' in '/absolute/path/.../my-project/src/styles.scss'
|
||||
```
|
||||
|
||||
The path we present to Webpack really needs to be `./subdir/cool.png` but we don't want to write that in our SCSS. 😒
|
||||
|
||||
Luckily we can use `resolve-url-loader` to do the **url re-writing** and make it work. 😊🎉
|
||||
|
||||
With functions and mixins and multiple nesting it gets more complicated. Read more detail in [how the loader works](docs/how-it-works.md). 🤓
|
||||
|
||||
## Getting started
|
||||
|
||||
> **Upgrading?** the [changelog](CHANGELOG.md) shows how to migrate your webpack config.
|
||||
|
||||
### Install
|
||||
|
||||
via npm
|
||||
|
||||
```bash
|
||||
npm install resolve-url-loader --save-dev
|
||||
```
|
||||
|
||||
via yarn
|
||||
|
||||
```bash
|
||||
yarn add resolve-url-loader --dev
|
||||
```
|
||||
|
||||
### Configure Webpack
|
||||
|
||||
The typical use case is `resolve-url-loader` between `sass-loader` and `css-loader`.
|
||||
|
||||
**⚠️ IMPORTANT**
|
||||
* **source-maps required** for loaders preceding `resolve-url-loader` (regardless of `devtool`).
|
||||
* Always use **full loader package name** (don't omit `-loader`) otherwise you can get errors that are hard to debug.
|
||||
|
||||
|
||||
``` javascript
|
||||
rules: [
|
||||
{
|
||||
test: /\.scss$/,
|
||||
use: [
|
||||
...
|
||||
{
|
||||
loader: 'css-loader',
|
||||
options: {...}
|
||||
}, {
|
||||
loader: 'resolve-url-loader',
|
||||
options: {...}
|
||||
}, {
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
sourceMap: true, // <-- !!IMPORTANT!!
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
The loader should work without options but use these as required.
|
||||
|
||||
| option | type | default | | description |
|
||||
|-------------|----------|-----------------------------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `sourceMap` | boolean | `false` | | Generate an outgoing source-map. |
|
||||
| `removeCR` | boolean | `true` Windows OS<br/>`false` otherwise | | Convert orphan CR to whitespace.<br/>See known issues below. |
|
||||
| `debug` | boolean | `false` | | Display debug information. |
|
||||
| `silent` | boolean | `false` | | Do **not** display warnings or deprecation messages. |
|
||||
| `root` | string | _unset_ | | Similar to the (now defunct) option in `css-loader`.<br/>This string, possibly empty, is prepended to absolute URIs.<br/>Absolute URIs are only processed if this option is set. |
|
||||
| `join` | function | _inbuilt_ | advanced | Custom join function.<br/>Use custom javascript to fix asset paths on a per-case basis.<br/>Refer to the [advanced features](docs/advanced-features.md) docs. |
|
||||
|
||||
## Limitations
|
||||
|
||||
### Compatibility
|
||||
|
||||
Tested `macOS` and `Windows`.
|
||||
|
||||
All `webpack@4`-`webpack@5` with contemporaneous loaders/plugins using `node@12`.
|
||||
|
||||
Refer to `test` directory for full webpack configurations as used in automated tests.
|
||||
|
||||
### Known issues
|
||||
|
||||
Read the [troubleshooting](docs/troubleshooting.md) docs before raising an issue.
|
||||
397
my-app/node_modules/resolve-url-loader/docs/advanced-features.md
generated
vendored
Executable file
397
my-app/node_modules/resolve-url-loader/docs/advanced-features.md
generated
vendored
Executable file
|
|
@ -0,0 +1,397 @@
|
|||
# Advanced Features
|
||||
|
||||
All the advanced features of this loader involve customising the `join` option.
|
||||
|
||||
Jump to the **"how to"** section -
|
||||
* [How to: change precedence of source locations](#how-to-change-precedence-of-source-locations)
|
||||
* [How to: fallback to a theme or other global directory](#how-to-fallback-to-a-theme-or-other-global-directory)
|
||||
* [How to: fallback to some other asset file](#how-to-fallback-to-some-other-asset-file)
|
||||
* [How to: perform a file-system search for an asset](#how-to-perform-a-file-system-search-for-an-asset)
|
||||
|
||||
## What is the "join" function?
|
||||
|
||||
The "join" function determines how CSS URIs are combined with one of the possible base paths the algorithm has identified.
|
||||
|
||||
⚠️ **IMPORTANT** - First read how the [algorithm](./how-it-works.md#algorithm) works.
|
||||
|
||||
The "join" function is a higher-order function created using the `options` and `loader` reference. That gives a function that accepts a single `item` and synchronously returns an absolute asset path to substitute back into the original CSS.
|
||||
|
||||
```javascript
|
||||
(options:{}, loader:{}) =>
|
||||
(item:{ uri:string, query: string, isAbsolute: boolean, bases:{} }) =>
|
||||
string | null
|
||||
```
|
||||
|
||||
Where the `bases` are absolute directory paths `{ subString, value, property, selector }` per the [algorithm](./how-it-works.md#algorithm). Note that returning `null` implies no substitution, the original relative `uri` is retained.
|
||||
|
||||
The job of the "join" function is to consider possible locations for the asset based on the `bases` and determine which is most appropriate. This implies some order of precedence in these locations and some file-system operation to determine if the asset there.
|
||||
|
||||
The default implementation is suitable for most users but can be customised per the `join` option.
|
||||
|
||||
A custom `join` function from scratch is possible but we've provided some [building blocks](#building-blocks) to make the task easier.
|
||||
|
||||
## Building blocks
|
||||
|
||||
There are a number of utilities (defined in [`lib/join-function/index.js`](../lib/join-function/index.js)) to help construct a custom "join" function . These are conveniently re-exported as properties of the loader.
|
||||
|
||||
These utilities are used to create the `defaultJoin` as follows.
|
||||
|
||||
```javascript
|
||||
const {
|
||||
createJoinFunction,
|
||||
createJoinImplementation,
|
||||
defaultJoinGenerator,
|
||||
} = require('resolve-url-loader');
|
||||
|
||||
// create a join function equivalent to "defaultJoin"
|
||||
const myJoinFn = createJoinFunction(
|
||||
'myJoinFn',
|
||||
createJoinImplementation(defaultJoinGenerator),
|
||||
});
|
||||
```
|
||||
|
||||
🤓 If you have some very specific behaviour in mind you can specify your own implementation. This gives full control but still gives you `debug` logging for free.
|
||||
|
||||
```javascript
|
||||
createJoinFunction = (name:string, implementation: function): function
|
||||
```
|
||||
|
||||
For each item, the implementation needs to make multiple attempts at locating the asset. It has mixed concerns of itentifying locations to search and then evaluating those locates one by one.
|
||||
|
||||
👉 However its recommended to instead use `createJoinImplementation` to create the `implementation` using the `generator` concept.
|
||||
|
||||
```javascript
|
||||
createJoinImplementation = (generator: function*): function
|
||||
```
|
||||
|
||||
The `generator` has the single concern of identifying locations to search. The work of searching these locations is done by `createJoinImplementation`. Overall this means less boilerplate code for you to write.
|
||||
|
||||
Don't worry, you don't need to use `function*` semantics for the `generator` unless you want to.
|
||||
|
||||
## Simple customisation
|
||||
|
||||
It is relatively simple to change the precedence of values (from the [algorithm](./how-it-works.md#algorithm)) or add further locations to search for an asset. To do this we use `createJoinImplementation` and write a custom `generator`.
|
||||
|
||||
See the reference or jump directly to the [examples](#how-to-change-precedence-of-source-locations).
|
||||
|
||||
### Reference
|
||||
|
||||
The `generator` identifies `[base:string,uri:string]` tuples describing locations to search for an asset. It does **not** return the final asset path.
|
||||
|
||||
You may lazily generate tuples as `Iterator`. Refer to this [guide on Iterators and Generators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators).
|
||||
```javascript
|
||||
generator = function* (item: {}, options: {}, loader: {}): Iterator<[string,string]>
|
||||
```
|
||||
|
||||
Or it can be simpler to write a function that returns `Array` and convert it to a generator using `asGenerator`.
|
||||
|
||||
```javascript
|
||||
generator = asGenerator( function (item: {}, options: {}, loader: {}): Array<string> )
|
||||
```
|
||||
```javascript
|
||||
generator = asGenerator( function (item: {}, options: {}, loader: {}): Array<[string,string]> )
|
||||
```
|
||||
|
||||
When using `asGenerator` you may return elements as either `base:string` **or** `[base:string,uri:string]` tuples.
|
||||
|
||||
<details>
|
||||
<summary>Arguments</summary>
|
||||
|
||||
* `item` consist of -
|
||||
* `uri: string` is the argument to the `url()` as it appears in the source file.
|
||||
* `query: string` is any query or hash string starting with `?` or `#` that suffixes the `uri`
|
||||
* `isAbsolute: boolean` flag indicates whether the URI is considered an absolute file or root relative path by webpack's definition. Absolute URIs are only processed if the `root` option is specified.
|
||||
* `bases: {}` are a hash where the keys are the sourcemap evaluation locations in the [algorithm](./how-it-works.md#algorithm) and the values are absolute paths that the sourcemap reports. These directories might not actually exist.
|
||||
* `options` consist of -
|
||||
* All documented options for the loader.
|
||||
* Any other values you include in the loader configuration for your own purposes.
|
||||
* `loader` consists of the webpack loader API, useful items include -
|
||||
* `fs: {}` the virtual file-system from Webpack.
|
||||
* `resourcePath: string` the source file currently being processed.
|
||||
* returns an `Iterator` with elements of `[base:string,uri:string]` either intrinsically or by using `asGenerator`.
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>FAQ</summary>
|
||||
|
||||
* **Why a tuple?**
|
||||
|
||||
The primary pupose of this loader is to find the correct `base` path for your `uri`. By returning a list of paths to search we can better generate `debug` logging.
|
||||
|
||||
That said there are cases where you might want to amend the `uri`. The solution is to make each element a tuple of `base` and `uri` representing a potential location to find the asset.
|
||||
|
||||
If you're interested only in the `base` path and don't intend to vary the `uri` then the `asGenerator` utility saves you having to create repetative tuples (and from using `function*` semantics).
|
||||
|
||||
* **Can I vary the `query` using the tuple?**
|
||||
|
||||
No. We don't support amending the `query` in the final value. If you would like this enhancement please open an issue.
|
||||
|
||||
* **What about duplicate or falsey elements?**
|
||||
|
||||
The `createJoinImplementation` will eliminate any invalid elements regardless of whether you use `Array` or `Iterator`. This makes it possible to `&&` elements inline with a predicate value.
|
||||
|
||||
If you use `Array` then `asGenerator` will also remove duplicates.
|
||||
|
||||
* **When should I use `function*`?**
|
||||
|
||||
If you need lazy generation of values then you may return `Iterator` or use `function*` semantics. Refer to [this guide on Iterators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators).
|
||||
|
||||
But in most cases, when the values are known apriori, simply returning `Array` has simpler semantics making `asGenerator` preferable.
|
||||
|
||||
* **Why is this generator so complicated?**
|
||||
|
||||
The join function must make multiple attempts to join a `base` and `uri` and check that the file exists using webpack `fs`.
|
||||
|
||||
The `generator` is focussed on identifying locations to search. It is a more scalable concept where you wish to search many places. The traditional use case for the custom "join" function is a file-system search so the `generator` was designed to make this possible.
|
||||
|
||||
If you prefer a less abstract approach consider a full `implementation` per the [full customisation](#full-customisation) approach.
|
||||
</details>
|
||||
|
||||
### How to: change precedence of source locations
|
||||
|
||||
Source-map sampling is limited to the locations defined in the [algorithm](./how-it-works.md#algorithm). You can't change these locations but you can preference them in a different order.
|
||||
|
||||
This example shows the default order which you can easily amend. Absolute URIs are rare in most projects but can be handled for completeness.
|
||||
|
||||
**Using `asGenerator`**
|
||||
|
||||
```javascript
|
||||
const {
|
||||
createJoinFunction,
|
||||
createJoinImplementation,
|
||||
asGenerator,
|
||||
defaultJoinGenerator,
|
||||
} = require('resolve-url-loader');
|
||||
|
||||
// order source-map sampling location by your preferred precedence (matches defaultJoinGenerator)
|
||||
const myGenerator = asGenerator(
|
||||
({ isAbsolute, bases: { substring, value, property, selector} }, { root }) =>
|
||||
isAbsolute ? [root] : [subString, value, property, selector]
|
||||
);
|
||||
|
||||
const myJoinFn = createJoinFunction(
|
||||
'myJoinFn',
|
||||
createJoinImplementation(myGenerator),
|
||||
);
|
||||
```
|
||||
|
||||
**Notes**
|
||||
|
||||
* The implementation is the default behaviour, so if you want this precedence do **not** customise the `join` option.
|
||||
* Absolute URIs generally use the base path given in the `root` option as shown.
|
||||
* The `asGenerator` utility allows us to return simple `Array<string>` of potential base paths.
|
||||
|
||||
### How to: fallback to a theme or other global directory
|
||||
|
||||
Additional locations can be added by decorating the default generator. This is popular for adding some sort of "theme" directory containing assets.
|
||||
|
||||
This example appends a static theme directory as a fallback location where the asset might reside. Absolute URIs are rare in most projects but can be handled for completeness.
|
||||
|
||||
**Using `asGenerator`**
|
||||
|
||||
```javascript
|
||||
const path = require('path');
|
||||
const {
|
||||
createJoinFunction,
|
||||
createJoinImplementation,
|
||||
asGenerator,
|
||||
defaultJoinGenerator,
|
||||
} = require('resolve-url-loader');
|
||||
|
||||
const myThemeDirectory = path.resolve(...);
|
||||
|
||||
// call default generator then append any additional paths
|
||||
const myGenerator = asGenerator(
|
||||
(item, ...rest) => [
|
||||
...defaultJoinGenerator(item, ...rest),
|
||||
item.isAbsolute ? null : myThemeDirectory,
|
||||
]
|
||||
);
|
||||
|
||||
const myJoinFn = createJoinFunction(
|
||||
'myJoinFn',
|
||||
createJoinImplementation(myGenerator),
|
||||
);
|
||||
```
|
||||
|
||||
**Notes**
|
||||
|
||||
* By spreading the result of `defaultJoinGenerator` we are first trying the default behaviour. If that is unsuccessful we then try the theme location.
|
||||
* It's assumed that theming doesn't apply to absolute URIs. Since falsey elements are ignored we can easily `null` the additional theme element inline as shown.
|
||||
* The `asGenerator` utility allows us to return simple `Array<string>` of potential base paths.
|
||||
|
||||
### How to: fallback to some other asset file
|
||||
|
||||
Lets imagine we don't have high quality files for all our assets and must sometimes use a lower quality format. For each item we need to try the `uri` with different file extensions. We can do this by returning tuples of `[base:string,uri:string]`.
|
||||
|
||||
In this example we prefer the `.svg` asset we are happy to use any available `.png` or `.jpg` instead.
|
||||
|
||||
**Using `asGenerator`**
|
||||
|
||||
```javascript
|
||||
const {
|
||||
createJoinFunction,
|
||||
createJoinImplementation,
|
||||
asGenerator,
|
||||
defaultJoinGenerator,
|
||||
} = require('resolve-url-loader');
|
||||
|
||||
// call default generator then pair different variations of uri with each base
|
||||
const myGenerator = asGenerator(
|
||||
(item, ...rest) => {
|
||||
const defaultTuples = [...defaultJoinGenerator(item, ...rest)];
|
||||
return /\.svg$/.test(item.uri)
|
||||
? ['.svg', '.png', 'jpg'].flatMap((ext) =>
|
||||
defaultTuples.flatMap(([base, uri]) =>
|
||||
[base, uri.replace(/\.svg$/, ext)]
|
||||
})
|
||||
)
|
||||
: defaultTuples;
|
||||
}
|
||||
);
|
||||
|
||||
const myJoinFn = createJoinFunction(
|
||||
'myJoinFn',
|
||||
createJoinImplementation(myGenerator),
|
||||
);
|
||||
```
|
||||
|
||||
**Using `function*`**
|
||||
|
||||
```javascript
|
||||
const {
|
||||
createJoinFunction,
|
||||
createJoinImplementation,
|
||||
defaultJoinGenerator,
|
||||
} = require('resolve-url-loader');
|
||||
|
||||
// call default generator then pair different variations of uri with each base
|
||||
const myGenerator = function* (item, ...rest) {
|
||||
if (/\.svg$/.test(item.uri)) {
|
||||
for (let ext of ['.svg', '.png', 'jpg']) {
|
||||
for (let [base, uri] of defaultJoinGenerator(item, ...rest)) {
|
||||
yield [base, uri.replace(/\.svg$/, ext)];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (let value of defaultJoinGenerator(item, ...rest)) {
|
||||
yield value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const myJoinFn = createJoinFunction(
|
||||
'myJoinFn',
|
||||
createJoinImplementation(myGenerator),
|
||||
);
|
||||
```
|
||||
|
||||
**Notes**
|
||||
|
||||
* Existing generators such as `defaultJoinGenerator` will always return `[string,string]` tuples so we can destruture `base` and `uri` values with confidence.
|
||||
* This implementation attempts all extensions for a given `base` before moving to the next `base`. Obviously we may change the nesting and instead do the oposite, attempt all bases for a single extension before moving on to the next extension
|
||||
* The `asGenerator` utility allows us to return `Array<[string, string]>` but is **not** needed when we use `function*` semantics.
|
||||
|
||||
### How to: perform a file-system search for an asset
|
||||
|
||||
⚠️ **IMPORTANT** - This example is indicative only and is **not** advised.
|
||||
|
||||
When this loader was originally released it was very common for packages be broken to the point that a full file search was needed to locate assets referred to in CSS. While this was not performant some users really liked it. By customising the `generator` we can once again lazily search the file-system.
|
||||
|
||||
In this example we search the parent directories of the base paths, continuing upwards until we hit a package boundary. Absolute URIs are rare in most projects but can be handled for completeness.
|
||||
|
||||
**Using `function*`**
|
||||
|
||||
```javascript
|
||||
const path = require('path');
|
||||
const {
|
||||
createJoinFunction,
|
||||
createJoinImplementation,
|
||||
webpackExistsSync
|
||||
} = require('resolve-url-loader');
|
||||
|
||||
// search up from the initial base path until you hit a package boundary
|
||||
const myGenerator = function* (
|
||||
{ uri, isAbsolute, bases: { substring, value, property, selector } },
|
||||
{ root, attempts = 1e3 },
|
||||
{ fs },
|
||||
) {
|
||||
if (isAbsolute) {
|
||||
yield [root, uri];
|
||||
} else {
|
||||
for (let base of [subString, value, property, selector]) {
|
||||
for (let isDone = false, i = 0; !isDone && i < attempts; i++) {
|
||||
yield [base, uri];
|
||||
// unfortunately fs.existsSync() is not present so we must shim it
|
||||
const maybePkg = path.normalize(path.join(base, 'package.json'));
|
||||
try {
|
||||
isDone = fs.statSync(maybePkg).isFile();
|
||||
} catch (error) {
|
||||
isDone = false;
|
||||
}
|
||||
base = base.split(/(\\\/)/).slice(0, -2).join('');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const myJoinFn = createJoinFunction(
|
||||
'myJoinFn',
|
||||
createJoinImplementation(myGenerator),
|
||||
);
|
||||
```
|
||||
|
||||
**Notes**
|
||||
|
||||
* This implementation is nether tested nor robust, it would need further safeguards to avoid searching the entire file system.
|
||||
|
||||
* By using `function*` the generator is lazy. We only walk the file-system directory tree as necessary.
|
||||
|
||||
* The webpack file-system is provided by the `enhanced-resolver-plugin` and does **not** contain `fs.existsSync()`. We must use `fs.statsSync()` instead and catch any error where the file isn't present.
|
||||
|
||||
* You may set additional `options` when you configure the loader in webpack and then access them in your `generator`. In this case we add an `attempts` option to limit the file search.
|
||||
|
||||
|
||||
## Full customisation
|
||||
|
||||
The `createJoinFunction` can give you full control over how the `base` and `uri` are joined to create an absolute file path **and** the definitiion of success for that combination.
|
||||
|
||||
It provides additional logging when using `debug` option so is a better choice then writing a "join" function from scratch.
|
||||
|
||||
Limited documentation is given here since it is rare to require a full customisation. Refer to the source code for further information.
|
||||
|
||||
### Reference
|
||||
|
||||
The `implementation` synchronously returns the final asset path or some fallback value. It makes a number of attempts to search for the given item and returns an element describing each attempt.
|
||||
|
||||
```javascript
|
||||
implementation = function (item: {}, options: {}, loader: {}):
|
||||
Array<{
|
||||
base : string,
|
||||
uri : string,
|
||||
joined : string,
|
||||
isSuccess : boolean,
|
||||
isFallback: boolean,
|
||||
}>
|
||||
```
|
||||
<details>
|
||||
<summary>Arguments</summary>
|
||||
|
||||
* `item` consist of -
|
||||
* `uri: string` is the argument to the `url()` as it appears in the source file.
|
||||
* `query: string` is any string starting with `?` or `#` that suffixes the `uri`
|
||||
* `isAbsolute: boolean` flag indicates whether the URI is considered an absolute file or root relative path by webpack's definition. Absolute URIs are only processed if the `root` option is specified.
|
||||
* `bases: {}` are a hash where the keys are the sourcemap evaluation locations in the [algorithm](./how-it-works.md#algorithm) and the values are absolute paths that the sourcemap reports. These directories might not actually exist.
|
||||
* `options` consist of -
|
||||
* All documented options for the loader.
|
||||
* Any other values you include in the loader configuration for your own purposes.
|
||||
* `loader` consists of the webpack loader API, useful items include -
|
||||
* `fs: {}` the virtual file-system from Webpack.
|
||||
* `resourcePath: string` the source file currently being processed.
|
||||
* returns an array of attempts that were made in resolving the URI -
|
||||
* `base` the base path
|
||||
* `uri` the uri path
|
||||
* `joined` the absolute path created from the joining the `base` and `uri` paths.
|
||||
* `isSuccess` indicates the asset was found and that `joined` should be the final result
|
||||
* `isFallback` indicates the asset was not found but that `joined` kis suitable as a fallback value
|
||||
</details>
|
||||
1
my-app/node_modules/resolve-url-loader/docs/basic-problem.svg
generated
vendored
Executable file
1
my-app/node_modules/resolve-url-loader/docs/basic-problem.svg
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 19 KiB |
1
my-app/node_modules/resolve-url-loader/docs/contributing.md
generated
vendored
Executable file
1
my-app/node_modules/resolve-url-loader/docs/contributing.md
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
# Contributing
|
||||
1
my-app/node_modules/resolve-url-loader/docs/detailed-problem.svg
generated
vendored
Executable file
1
my-app/node_modules/resolve-url-loader/docs/detailed-problem.svg
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 12 KiB |
159
my-app/node_modules/resolve-url-loader/docs/how-it-works.md
generated
vendored
Executable file
159
my-app/node_modules/resolve-url-loader/docs/how-it-works.md
generated
vendored
Executable file
|
|
@ -0,0 +1,159 @@
|
|||
# How it works
|
||||
|
||||
## The problem
|
||||
|
||||
The `resolve-url-loader` is typically used where SASS source files are transpiled to CSS. CSS being a format that webpack can readily ingest. So let's look at a basic example where the structure is basically CSS but is composed using SASS features.
|
||||
|
||||
Working backwards, this is the final CSS we are after. Just a single rule with a single declaration.
|
||||
|
||||
```css
|
||||
.cool {
|
||||
background-image: url(cool.png);
|
||||
}
|
||||
```
|
||||
|
||||
When using SASS it's common for rules to come from different [partials](https://sass-lang.com/documentation/at-rules/import#partials), and for declarations to be composed using mixins and functions. Consider this more complicated project with imported files.
|
||||
|
||||
<img src="detailed-problem.svg" alt="the detailed problem" width="363px" height="651px">
|
||||
|
||||
All the subdirectories here contributed something to the rule, so we could reasonably place the asset in any of them. And any of these locations might be the "correct" to our way of thinking.
|
||||
|
||||
There could actually be a separate `cool.png` in each of the subdirectories! 🤯 In that case, which one gets used?
|
||||
|
||||
The answer: none. 😞 Webpack expects asset paths to be relative to the root SASS file `src/styles.scss`. So for the CSS `url(cool.png)` it will look for `src/cool.png` which is not present. 💥
|
||||
|
||||
All our assets are in subdirecties `src/foo/cool.png` or `src/foo/bar/cool.png` or `src/foo/bar/baz/cool.png`. We need to re-write the `url()` to point to the one we intend. But right now that's pretty ambiguous.
|
||||
|
||||
Worse still, Webpack doesn't know any of these nested SCSS files were part of the SASS composition. Meaing it doesn't know there _are_ nested directories in the first place. How do we rewite to something we don't know about?
|
||||
|
||||
**The problem:** How to identify contributing directectories and look for the asset in those directories in some well-defined priority order?
|
||||
|
||||
**The crux:** How to identify what contributed to the SASS compilation, internally and post factum, but from within Webpack? 😫
|
||||
|
||||
## The solution
|
||||
|
||||
Sourcemaps! 😃
|
||||
|
||||
Wait, don't run away! Sourcemaps might sound scary, but they solve our problem reasonably well. 👍
|
||||
|
||||
The SASS compiler source-map can tell us which original SCSS file contributed each character in the resulting CSS.
|
||||
|
||||
The SASS source-map is also something we can access from within Webpack.
|
||||
|
||||
### concept
|
||||
|
||||
Continuing with the example let's compile SASS on the command line. You can do this several different ways but I prefer [npx](https://blog.npmjs.org/post/162869356040/introducing-npx-an-npm-package-runner).
|
||||
|
||||
```sh
|
||||
> npx node-sass src/styles.scss --output . --output-style expanded --source-map true
|
||||
```
|
||||
|
||||
Using the experimental `sourcemap-to-string` package (also in this repository) we can visualise the SASS source on the left vs the output CSS on the right.
|
||||
|
||||
```
|
||||
src/styles.scss
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
src/foo/_partial.scss
|
||||
-------------------------------------------------------------------------------
|
||||
3:01 .cool░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1:01 .cool░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
||||
3:06 ░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1:06 ░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
||||
3:07 ░░░░░░{⏎ 1:07 ░░░░░░{⏎
|
||||
@include cool-background-image;⏎ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
||||
}░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
||||
-:-- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 3:02 ░⏎
|
||||
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ⏎
|
||||
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ /*# sourceMappingURL=styles.css.ma
|
||||
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ p */░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
||||
|
||||
src/foo/bar/_mixins.scss
|
||||
-------------------------------------------------------------------------------
|
||||
4:03 ░░background-image░░░░░░░░░░░░░░░░ 2:03 ░░background-image░░░░░░░░░░░░░░░░
|
||||
4:19 ░░░░░░░░░░░░░░░░░░: get-url("cool" 2:19 ░░░░░░░░░░░░░░░░░░: ░░░░░░░░░░░░░░
|
||||
);⏎ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
||||
}⏎ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
||||
|
||||
src/foo/bar/baz/_functions.scss
|
||||
-------------------------------------------------------------------------------
|
||||
2:11 ░░░░░░░░░░url(#░░░░░░░░░░░░░░░░░░░ 2:21 ░░░░░░░░░░░░░░░░░░░░url(cool.png)░
|
||||
2:16 ░░░░░░░░░░░░░░░{$temp}.png);⏎ 2:34 ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░;
|
||||
}░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ⏎
|
||||
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ }░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
||||
```
|
||||
|
||||
As expected, the pure CSS portions are essentially the same in the source and the output.
|
||||
|
||||
Meanwhile the indirect `@mixin` and `funtion` substitutes values into the output. But we can still clearly see where in the source that final value originated from.
|
||||
|
||||
### algorithm
|
||||
|
||||
Now we know the original SCSS sources we can use a CSS parser such as `postcss` to process all the declaration values that contain `url()` and rewrite any file paths we find there.
|
||||
|
||||
1. Enumerate all declaration values
|
||||
2. Split the value into path substrings
|
||||
3. Evaluate the source-map at that location, find the original source file
|
||||
4. Rebase the path to that original source file.
|
||||
|
||||
For our example, this algorithm will always give us the asset located in the `baz` subdirectory. Clearly evaluating the source-map at just one location is not enough. Any of the directories that contributed source files to the rule-set might be considered the "correct" place to store the asset and all these files contributed different parts of the rule-set, not just the declaration value.
|
||||
|
||||
We stop short of evaluating the source-map for _every characer_ in the rule-set and instead we chose a small number of meaningful points.
|
||||
|
||||
| | label | sampling location | in the example | implies asset |
|
||||
|---|-----------|------------------------------------------|---------------------------|--------------------------------------------------|
|
||||
| 1 | subString | start of **argument** to the `url()` | `c` in `cool.png` | `src/foo/bar/baz/cool.png` |
|
||||
| 2 | value | start of **value** in the declaration | `u` in `url(...)` | `src/foo/bar/baz/cool.png` |
|
||||
| 3 | property | start of **property** in the declaration | `b` in `background-image` | `src/foo/bar/cool.png` |
|
||||
| 4 | selector | start of **selector** in the rule-set | `.` in `.selector` | `src/foo/cool.png` |
|
||||
|
||||
These locations are tested in order. If an asset of the correct filename is found then we break and use that result.
|
||||
|
||||
Note it is a quirk of the example that the `value` and `subString` locations imply the same file. In a more complex example this may not be true.
|
||||
|
||||
If necessary the order can be customised or a custom file search (starting at each location) be implemented. Refer to the [advanced features](advanced-features.md).
|
||||
|
||||
|
||||
### webpack
|
||||
|
||||
To operate on the `sass-loader` output, both **CSS** and **source-map**, we introduce `resolve-url-loader` containing the algorithm above.
|
||||
|
||||
The `resolve-url-loader` rewrites asset paths found in `url()` notation using the `postcss` parser.
|
||||
|
||||
This webpack configuration outlines some important points.
|
||||
|
||||
```javascript
|
||||
rules: [
|
||||
{
|
||||
test: /\.scss$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'css-loader' // <-- assets are identified here
|
||||
}, {
|
||||
loader: 'resolve-url-loader' // <-- receives CSS and source-map from SASS compile
|
||||
}, {
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
sourceMap: true, // <-- IMPORTANT!
|
||||
sourceMapContents: false
|
||||
}
|
||||
}
|
||||
],
|
||||
},
|
||||
...
|
||||
{
|
||||
test: /\.png$/, // <-- assets needs their own loader configuration
|
||||
use: [ ... ]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Its essential to explicitly configure the `sass-loader` for `sourceMap: true`. That way we definitely get a sourcemap from upstream SASS loader all the time, not just in developement mode or where `devtool` is used.
|
||||
|
||||
Once the CSS reaches the `css-loader` webpack becomes aware of each of the asset files and will try to separately load and process them. You will need more Webpack configuration to make that work. Refer to the [troubleshooting docs](troubleshooting.md) before raising an issue.
|
||||
|
||||
### beyond...?
|
||||
|
||||
The implementation here is limited to the webpack loader but it's plausible the algorithm could be realised as a `postcss` plugin in isolation using the [root.input.map](https://postcss.org/api/#postcss-input) property to access the incomming source-map.
|
||||
|
||||
As a separate plugin it could be combined with other plugins in a single `postcss-loader` step. Processing multiple plugins together in this way without reparsing would arguably be more efficient.
|
||||
|
||||
However as a Webpack loader we have full access to the loader API and the virtual file-system. This means maximum compatibility with `webpack-dev-server` and the rest of the Webpack ecosystem.
|
||||
71
my-app/node_modules/resolve-url-loader/docs/troubleshooting.md
generated
vendored
Executable file
71
my-app/node_modules/resolve-url-loader/docs/troubleshooting.md
generated
vendored
Executable file
|
|
@ -0,0 +1,71 @@
|
|||
# Troubleshooting
|
||||
|
||||
Webpack is difficult to configure simply because it is so powerful. If you face a problem it is important to raise it in the right place.
|
||||
|
||||
Possibly whatever problem you are facing is _not_ an issue with this loader, so please work this list before raising an issue.
|
||||
|
||||
**Working with a framework**
|
||||
|
||||
1. Check to see if that framework is still using an older version with the `rework` engine. This will not support modern CSS and is the source of most problems. Usually there is an existing issue raised in that framework and there may be workarounds there.
|
||||
2. Hack the framework code in your `node_modules` to diagose the root cause.
|
||||
|
||||
**Creating your own webpack config**
|
||||
|
||||
1. Do the checklist at the top of the page - do you _need_ to use this loader?
|
||||
2. Read and understand the detail on [how the loader works](how-it-works.md).
|
||||
3. Check the known-issues below.
|
||||
4. Use the `debug` option to see where the loader is looking for your assets.
|
||||
5. Temporarily remove this loader and use non-relative asset paths to check if the problem is something else.
|
||||
6. Check [stack overflow](http://stackoverflow.com/search?q=resolve-url-loader) for an answer.
|
||||
7. Review [previous issues](/issues?utf8=%E2%9C%93&q=is%3Aissue) that may be similar.
|
||||
8. Try to recreate the problem with a minimum breaking example project.
|
||||
|
||||
I'm happy this loader helps so many people. Open-source is provided as-is and I'm currently **not** [dogfooding](https://en.wikipedia.org/wiki/Eating_your_own_dog_food) this loader in my own work, so please try not project your frustrations. There are some really great people who follow this project who can help.
|
||||
|
||||
## Known issues
|
||||
|
||||
### Support for `image-set()`
|
||||
|
||||
Right now this loader only rewrites `url()` statements.
|
||||
|
||||
If you need other statements processed, such as `image-set()`, then please upvote [issue #119](issues/119).
|
||||
|
||||
### Absolute URIs
|
||||
|
||||
By "absolute URIs" we more correctly mean assets with root-relative URLs or absolute file paths. These paths are **not** processed unless a `root` is specified.
|
||||
|
||||
However any paths that _are_ processed will have windows back-slash converted to posix forward-slash. This can be useful since some webpack loaders can choke on windows paths. By using `root: ''` then `resolve-url-loader` effectively does nothing to absolute paths except change the windows backslash.
|
||||
|
||||
**💡 Protip** In **windows** if your downstream loaders are choking on windows paths using `root: ''` can help.
|
||||
|
||||
Also it be useful to process absolute URIs if you have a custom `join` function and want to process all the paths. Although this is perhaps better done with some separate `postcss` plugin.
|
||||
|
||||
### Windows line breaks
|
||||
|
||||
Normal windows linebreaks are `CRLF`. But sometimes libsass will output single `CR` characters.
|
||||
|
||||
This problem is specific to multiline declarations. Refer to the [libsass bug #2693](https://github.com/sass/libsass/issues/2693).
|
||||
|
||||
If you have _any_ such multiline declarations preceding `url()` statements it will fail your build.
|
||||
|
||||
Libsass doesn't consider these orphan `CR` to be newlines but `postcss` engine does. The result being an offset in source-map line-numbers which crashes `resolve-url-loader`.
|
||||
|
||||
```
|
||||
Module build failed: Error: resolve-url-loader: error processing CSS
|
||||
source-map information is not available at url() declaration
|
||||
```
|
||||
|
||||
Some users find the node-sass `linefeed` option solves the problem.
|
||||
|
||||
**Solutions**
|
||||
* Try the node-sass [linefeed](https://github.com/sass/node-sass#linefeed--v300) option by way of `sass-loader`.
|
||||
|
||||
**Work arounds**
|
||||
|
||||
* Enable `removeCR` option [here](../README.md#options) (enabled by default on Window OS).
|
||||
* Remove linebreaks in declarations in your `.scss` sources.
|
||||
|
||||
**Diagnosis**
|
||||
1. Run a stand-alone sass build `npx node-sass index.scss output.css`.
|
||||
2. Use a hex editor to check line endings `Format-Hex output.css`.
|
||||
3. Expect `0DOA` (or desired) line endings. Single `0D` confirms this problem.
|
||||
292
my-app/node_modules/resolve-url-loader/index.js
generated
vendored
Executable file
292
my-app/node_modules/resolve-url-loader/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1,292 @@
|
|||
/*
|
||||
* MIT License http://opensource.org/licenses/MIT
|
||||
* Author: Ben Holloway @bholloway
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const util = require('util');
|
||||
const loaderUtils = require('loader-utils');
|
||||
const SourceMapConsumer = require('source-map').SourceMapConsumer;
|
||||
|
||||
const adjustSourceMap = require('adjust-sourcemap-loader/lib/process');
|
||||
|
||||
const valueProcessor = require('./lib/value-processor');
|
||||
const joinFn = require('./lib/join-function');
|
||||
const logToTestHarness = require('./lib/log-to-test-harness');
|
||||
|
||||
const DEPRECATED_OPTIONS = {
|
||||
engine: [
|
||||
'DEP_RESOLVE_URL_LOADER_OPTION_ENGINE',
|
||||
'"engine" option has been removed, postcss is the only parser used'
|
||||
],
|
||||
keepQuery: [
|
||||
'DEP_RESOLVE_URL_LOADER_OPTION_KEEP_QUERY',
|
||||
'"keepQuery" option has been removed, the query and/or hash are now always retained'
|
||||
],
|
||||
absolute: [
|
||||
'DEP_RESOLVE_URL_LOADER_OPTION_ABSOLUTE',
|
||||
'"absolute" option has been removed, consider the "join" option if absolute paths must be processed'
|
||||
],
|
||||
attempts: [
|
||||
'DEP_RESOLVE_URL_LOADER_OPTION_ATTEMPTS',
|
||||
'"attempts" option has been removed, consider the "join" option if search is needed'
|
||||
],
|
||||
includeRoot: [
|
||||
'DEP_RESOLVE_URL_LOADER_OPTION_INCLUDE_ROOT',
|
||||
'"includeRoot" option has been removed, consider the "join" option if search is needed'
|
||||
],
|
||||
fail: [
|
||||
'DEP_RESOLVE_URL_LOADER_OPTION_FAIL',
|
||||
'"fail" option has been removed'
|
||||
]
|
||||
};
|
||||
|
||||
/**
|
||||
* A webpack loader that resolves absolute url() paths relative to their original source file.
|
||||
* Requires source-maps to do any meaningful work.
|
||||
* @param {string} content Css content
|
||||
* @param {object} sourceMap The source-map
|
||||
* @returns {string|String}
|
||||
*/
|
||||
function resolveUrlLoader(content, sourceMap) {
|
||||
/* jshint validthis:true */
|
||||
|
||||
// details of the file being processed
|
||||
const loader = this;
|
||||
|
||||
// a relative loader.context is a problem
|
||||
if (/^\./.test(loader.context)) {
|
||||
return handleAsError(
|
||||
'webpack misconfiguration',
|
||||
'loader.context is relative, expected absolute'
|
||||
);
|
||||
}
|
||||
|
||||
// infer webpack version from new loader features
|
||||
const isWebpackGte5 = 'getOptions' in loader && typeof loader.getOptions === 'function';
|
||||
|
||||
// use loader.getOptions where available otherwise use loaderUtils
|
||||
const rawOptions = isWebpackGte5 ? loader.getOptions() : loaderUtils.getOptions(loader);
|
||||
const options = Object.assign(
|
||||
{
|
||||
sourceMap: loader.sourceMap,
|
||||
silent : false,
|
||||
removeCR : os.EOL.includes('\r'),
|
||||
root : false,
|
||||
debug : false,
|
||||
join : joinFn.defaultJoin
|
||||
},
|
||||
rawOptions,
|
||||
);
|
||||
|
||||
// maybe log options for the test harness
|
||||
if (process.env.RESOLVE_URL_LOADER_TEST_HARNESS) {
|
||||
logToTestHarness(
|
||||
process[process.env.RESOLVE_URL_LOADER_TEST_HARNESS],
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
// deprecated options
|
||||
const deprecatedItems = Object.entries(DEPRECATED_OPTIONS).filter(([key]) => key in rawOptions);
|
||||
if (deprecatedItems.length) {
|
||||
deprecatedItems.forEach(([, value]) => handleAsDeprecated(...value));
|
||||
}
|
||||
|
||||
// validate join option
|
||||
if (typeof options.join !== 'function') {
|
||||
return handleAsError(
|
||||
'loader misconfiguration',
|
||||
'"join" option must be a Function'
|
||||
);
|
||||
} else if (options.join.length !== 2) {
|
||||
return handleAsError(
|
||||
'loader misconfiguration',
|
||||
'"join" Function must take exactly 2 arguments (options, loader)'
|
||||
);
|
||||
}
|
||||
|
||||
// validate the result of calling the join option
|
||||
const joinProper = options.join(options, loader);
|
||||
if (typeof joinProper !== 'function') {
|
||||
return handleAsError(
|
||||
'loader misconfiguration',
|
||||
'"join" option must itself return a Function when it is called'
|
||||
);
|
||||
} else if (joinProper.length !== 1) {
|
||||
return handleAsError(
|
||||
'loader misconfiguration',
|
||||
'"join" Function must create a function that takes exactly 1 arguments (item)'
|
||||
);
|
||||
}
|
||||
|
||||
// validate root option
|
||||
if (typeof options.root === 'string') {
|
||||
const isValid = (options.root === '') ||
|
||||
(path.isAbsolute(options.root) && fs.existsSync(options.root) && fs.statSync(options.root).isDirectory());
|
||||
|
||||
if (!isValid) {
|
||||
return handleAsError(
|
||||
'loader misconfiguration',
|
||||
'"root" option must be an empty string or an absolute path to an existing directory'
|
||||
);
|
||||
}
|
||||
} else if (options.root !== false) {
|
||||
handleAsWarning(
|
||||
'loader misconfiguration',
|
||||
'"root" option must be string where used or false where unused'
|
||||
);
|
||||
}
|
||||
|
||||
// loader result is cacheable
|
||||
loader.cacheable();
|
||||
|
||||
// incoming source-map
|
||||
let absSourceMap = null;
|
||||
let sourceMapConsumer = null;
|
||||
if (sourceMap) {
|
||||
|
||||
// support non-standard string encoded source-map (per less-loader)
|
||||
if (typeof sourceMap === 'string') {
|
||||
try {
|
||||
sourceMap = JSON.parse(sourceMap);
|
||||
}
|
||||
catch (exception) {
|
||||
return handleAsError(
|
||||
'source-map error',
|
||||
'cannot parse source-map string (from less-loader?)'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// leverage adjust-sourcemap-loader's codecs to avoid having to make any assumptions about the sourcemap
|
||||
// historically this is a regular source of breakage
|
||||
try {
|
||||
absSourceMap = adjustSourceMap(loader, {format: 'absolute'}, sourceMap);
|
||||
}
|
||||
catch (exception) {
|
||||
return handleAsError(
|
||||
'source-map error',
|
||||
exception.message
|
||||
);
|
||||
}
|
||||
|
||||
// prepare the adjusted sass source-map for later look-ups
|
||||
sourceMapConsumer = new SourceMapConsumer(absSourceMap);
|
||||
} else {
|
||||
handleAsWarning(
|
||||
'webpack misconfiguration',
|
||||
'webpack or the upstream loader did not supply a source-map'
|
||||
);
|
||||
}
|
||||
|
||||
// allow engine to throw at initialisation
|
||||
let engine = null;
|
||||
try {
|
||||
engine = require('./lib/engine/postcss');
|
||||
} catch (error) {
|
||||
return handleAsError(
|
||||
'error initialising',
|
||||
error
|
||||
);
|
||||
}
|
||||
|
||||
// process async
|
||||
const callback = loader.async();
|
||||
Promise
|
||||
.resolve(engine(loader.resourcePath, content, {
|
||||
outputSourceMap : !!options.sourceMap,
|
||||
absSourceMap : absSourceMap,
|
||||
sourceMapConsumer : sourceMapConsumer,
|
||||
removeCR : options.removeCR,
|
||||
transformDeclaration: valueProcessor({
|
||||
join : joinProper,
|
||||
root : options.root,
|
||||
directory: path.dirname(loader.resourcePath)
|
||||
})
|
||||
}))
|
||||
.catch(onFailure)
|
||||
.then(onSuccess);
|
||||
|
||||
function onFailure(error) {
|
||||
callback(encodeError('error processing CSS', error));
|
||||
}
|
||||
|
||||
function onSuccess(result) {
|
||||
if (result) {
|
||||
// complete with source-map
|
||||
// webpack4 and earlier: source-map sources are relative to the file being processed
|
||||
// webpack5: source-map sources are relative to the project root but without a leading slash
|
||||
if (options.sourceMap) {
|
||||
const finalMap = adjustSourceMap(loader, {
|
||||
format: isWebpackGte5 ? 'projectRelative' : 'sourceRelative'
|
||||
}, result.map);
|
||||
callback(null, result.content, finalMap);
|
||||
}
|
||||
// complete without source-map
|
||||
else {
|
||||
callback(null, result.content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger a node deprecation message for the given exception and return the original content.
|
||||
* @param {string} code Deprecation code
|
||||
* @param {string} message Deprecation message
|
||||
* @returns {string} The original CSS content
|
||||
*/
|
||||
function handleAsDeprecated(code, message) {
|
||||
if (!options.silent) {
|
||||
util.deprecate(() => undefined, message, code)();
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push a warning for the given exception and return the original content.
|
||||
* @param {string} label Summary of the error
|
||||
* @param {string|Error} [exception] Optional extended error details
|
||||
* @returns {string} The original CSS content
|
||||
*/
|
||||
function handleAsWarning(label, exception) {
|
||||
if (!options.silent) {
|
||||
loader.emitWarning(encodeError(label, exception));
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push a warning for the given exception and return the original content.
|
||||
* @param {string} label Summary of the error
|
||||
* @param {string|Error} [exception] Optional extended error details
|
||||
* @returns {string} The original CSS content
|
||||
*/
|
||||
function handleAsError(label, exception) {
|
||||
loader.emitError(encodeError(label, exception));
|
||||
return content;
|
||||
}
|
||||
|
||||
function encodeError(label, exception) {
|
||||
return new Error(
|
||||
[
|
||||
'resolve-url-loader',
|
||||
': ',
|
||||
[label]
|
||||
.concat(
|
||||
(typeof exception === 'string') && exception ||
|
||||
Array.isArray(exception) && exception ||
|
||||
(exception instanceof Error) && [exception.message, exception.stack.split('\n')[1].trim()] ||
|
||||
[]
|
||||
)
|
||||
.filter(Boolean)
|
||||
.join('\n ')
|
||||
].join('')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Object.assign(resolveUrlLoader, joinFn);
|
||||
132
my-app/node_modules/resolve-url-loader/lib/engine/postcss.js
generated
vendored
Executable file
132
my-app/node_modules/resolve-url-loader/lib/engine/postcss.js
generated
vendored
Executable file
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* MIT License http://opensource.org/licenses/MIT
|
||||
* Author: Ben Holloway @bholloway
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const postcss = require('postcss');
|
||||
|
||||
const fileProtocol = require('../file-protocol');
|
||||
const algerbra = require('../position-algerbra');
|
||||
|
||||
const ORPHAN_CR_REGEX = /\r(?!\n)(.|\n)?/g;
|
||||
|
||||
/**
|
||||
* Process the given CSS content into reworked CSS content.
|
||||
*
|
||||
* @param {string} sourceFile The absolute path of the file being processed
|
||||
* @param {string} sourceContent CSS content without source-map
|
||||
* @param {{outputSourceMap: boolean, transformDeclaration:function, absSourceMap:object,
|
||||
* sourceMapConsumer:object, removeCR:boolean}} params Named parameters
|
||||
* @return {{content: string, map: object}} Reworked CSS and optional source-map
|
||||
*/
|
||||
function process(sourceFile, sourceContent, params) {
|
||||
// #107 libsass emits orphan CR not considered newline, postcss does consider newline (content vs source-map mismatch)
|
||||
const correctedContent = params.removeCR && (os.EOL !== '\r') ?
|
||||
sourceContent.replace(ORPHAN_CR_REGEX, ' $1') :
|
||||
sourceContent;
|
||||
|
||||
// IMPORTANT - prepend file protocol to all sources to avoid problems with source map
|
||||
const plugin = Object.assign(
|
||||
() => ({
|
||||
postcssPlugin: 'postcss-resolve-url',
|
||||
prepare: () => {
|
||||
const visited = new Set();
|
||||
|
||||
/**
|
||||
* Given an apparent position find the directory of the original file.
|
||||
*
|
||||
* @param startPosApparent {{line: number, column: number}}
|
||||
* @returns {false|string} Directory of original file or false on invalid
|
||||
*/
|
||||
const positionToOriginalDirectory = (startPosApparent) => {
|
||||
// reverse the original source-map to find the original source file before transpilation
|
||||
const startPosOriginal =
|
||||
!!params.sourceMapConsumer &&
|
||||
params.sourceMapConsumer.originalPositionFor(startPosApparent);
|
||||
|
||||
// we require a valid directory for the specified file
|
||||
const directory =
|
||||
!!startPosOriginal &&
|
||||
!!startPosOriginal.source &&
|
||||
fileProtocol.remove(path.dirname(startPosOriginal.source));
|
||||
|
||||
return directory;
|
||||
};
|
||||
|
||||
return {
|
||||
Declaration: (declaration) => {
|
||||
var prefix,
|
||||
isValid = declaration.value && (declaration.value.indexOf('url') >= 0) && !visited.has(declaration);
|
||||
if (isValid) {
|
||||
prefix = declaration.prop + declaration.raws.between;
|
||||
declaration.value = params.transformDeclaration(declaration.value, getPathsAtChar);
|
||||
visited.add(declaration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a hash of base path strings.
|
||||
*
|
||||
* Position in the declaration is supported by postcss at the position of the url() statement.
|
||||
*
|
||||
* @param {number} index Index in the declaration value at which to evaluate
|
||||
* @throws Error on invalid source map
|
||||
* @returns {{subString:string, value:string, property:string, selector:string}} Hash of base path strings
|
||||
*/
|
||||
function getPathsAtChar(index) {
|
||||
var subString = declaration.value.slice(0, index),
|
||||
posSelector = algerbra.sanitise(declaration.parent.source.start),
|
||||
posProperty = algerbra.sanitise(declaration.source.start),
|
||||
posValue = algerbra.add([posProperty, algerbra.strToOffset(prefix)]),
|
||||
posSubString = algerbra.add([posValue, algerbra.strToOffset(subString)]);
|
||||
|
||||
var result = {
|
||||
subString: positionToOriginalDirectory(posSubString),
|
||||
value : positionToOriginalDirectory(posValue),
|
||||
property : positionToOriginalDirectory(posProperty),
|
||||
selector : positionToOriginalDirectory(posSelector)
|
||||
};
|
||||
|
||||
var isValid = [result.subString, result.value, result.property, result.selector].every(Boolean);
|
||||
if (isValid) {
|
||||
return result;
|
||||
}
|
||||
else if (params.sourceMapConsumer) {
|
||||
throw new Error(
|
||||
'source-map information is not available at url() declaration ' + (
|
||||
ORPHAN_CR_REGEX.test(sourceContent) ?
|
||||
'(found orphan CR, try removeCR option)' :
|
||||
'(no orphan CR found)'
|
||||
)
|
||||
);
|
||||
} else {
|
||||
throw new Error('a valid source-map is not present (ensure preceding loaders output a source-map)');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}),
|
||||
{ postcss: true }
|
||||
);
|
||||
|
||||
// IMPORTANT - prepend file protocol to all sources to avoid problems with source map
|
||||
return postcss([plugin])
|
||||
.process(correctedContent, {
|
||||
from: fileProtocol.prepend(sourceFile),
|
||||
map : params.outputSourceMap && {
|
||||
prev : !!params.absSourceMap && fileProtocol.prepend(params.absSourceMap),
|
||||
inline : false,
|
||||
annotation : false,
|
||||
sourcesContent: true // #98 sourcesContent missing from output map
|
||||
}
|
||||
})
|
||||
.then(({css, map}) => ({
|
||||
content: css,
|
||||
map : params.outputSourceMap ? fileProtocol.remove(map.toJSON()) : null
|
||||
}));
|
||||
}
|
||||
|
||||
module.exports = process;
|
||||
39
my-app/node_modules/resolve-url-loader/lib/file-protocol.js
generated
vendored
Executable file
39
my-app/node_modules/resolve-url-loader/lib/file-protocol.js
generated
vendored
Executable file
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* MIT License http://opensource.org/licenses/MIT
|
||||
* Author: Ben Holloway @bholloway
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Prepend file:// protocol to source path string or source-map sources.
|
||||
*/
|
||||
function prepend(candidate) {
|
||||
if (typeof candidate === 'string') {
|
||||
return 'file://' + candidate;
|
||||
} else if (candidate && (typeof candidate === 'object') && Array.isArray(candidate.sources)) {
|
||||
return Object.assign({}, candidate, {
|
||||
sources: candidate.sources.map(prepend)
|
||||
});
|
||||
} else {
|
||||
throw new Error('expected string|object');
|
||||
}
|
||||
}
|
||||
|
||||
exports.prepend = prepend;
|
||||
|
||||
/**
|
||||
* Remove file:// protocol from source path string or source-map sources.
|
||||
*/
|
||||
function remove(candidate) {
|
||||
if (typeof candidate === 'string') {
|
||||
return candidate.replace(/^file:\/{2}/, '');
|
||||
} else if (candidate && (typeof candidate === 'object') && Array.isArray(candidate.sources)) {
|
||||
return Object.assign({}, candidate, {
|
||||
sources: candidate.sources.map(remove)
|
||||
});
|
||||
} else {
|
||||
throw new Error('expected string|object');
|
||||
}
|
||||
}
|
||||
|
||||
exports.remove = remove;
|
||||
86
my-app/node_modules/resolve-url-loader/lib/join-function/debug.js
generated
vendored
Executable file
86
my-app/node_modules/resolve-url-loader/lib/join-function/debug.js
generated
vendored
Executable file
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* MIT License http://opensource.org/licenses/MIT
|
||||
* Author: Ben Holloway @bholloway
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const PACKAGE_NAME = require('../../package.json').name;
|
||||
|
||||
/**
|
||||
* Paths are formatted to have posix style path separators and those within the CWD are made relative to CWD.
|
||||
*
|
||||
* @param {string} absolutePath An absolute path to format
|
||||
* @returns {string} the formatted path
|
||||
*/
|
||||
const pathToString = (absolutePath) => {
|
||||
if (absolutePath === '') {
|
||||
return '-empty-';
|
||||
} else {
|
||||
const relative = path.relative(process.cwd(), absolutePath).split(path.sep);
|
||||
const segments =
|
||||
(relative[0] !== '..') ? ['.'].concat(relative).filter(Boolean) :
|
||||
(relative.lastIndexOf('..') < 2) ? relative :
|
||||
absolutePath.replace(/^[A-Z]\:/, '').split(path.sep);
|
||||
return segments.join('/');
|
||||
}
|
||||
};
|
||||
|
||||
exports.pathToString = pathToString;
|
||||
|
||||
/**
|
||||
* Format a debug message.
|
||||
*
|
||||
* @param {string} filename The file being processed by webpack
|
||||
* @param {string} uri A uri path, relative or absolute
|
||||
* @param {Array<{base:string,joined:string,isSuccess:boolean}>} attempts An array of attempts, possibly empty
|
||||
* @return {string} Formatted message
|
||||
*/
|
||||
const formatJoinMessage = (filename, uri, attempts) => {
|
||||
const attemptToCells = (_, i, array) => {
|
||||
const { base: prev } = (i === 0) ? {} : array[i-1];
|
||||
const { base: curr, joined } = array[i];
|
||||
return [(curr === prev) ? '' : pathToString(curr), pathToString(joined)];
|
||||
};
|
||||
|
||||
const formatCells = (lines) => {
|
||||
const maxWidth = lines.reduce((max, [cellA]) => Math.max(max, cellA.length), 0);
|
||||
return lines.map(([cellA, cellB]) => [cellA.padEnd(maxWidth), cellB]).map((cells) => cells.join(' --> '));
|
||||
};
|
||||
|
||||
return [PACKAGE_NAME + ': ' + pathToString(filename) + ': ' + uri]
|
||||
.concat(attempts.length === 0 ? '-empty-' : formatCells(attempts.map(attemptToCells)))
|
||||
.concat(attempts.some(({ isSuccess }) => isSuccess) ? 'FOUND' : 'NOT FOUND')
|
||||
.join('\n ');
|
||||
};
|
||||
|
||||
exports.formatJoinMessage = formatJoinMessage;
|
||||
|
||||
/**
|
||||
* A factory for a log function predicated on the given debug parameter.
|
||||
*
|
||||
* The logging function created accepts a function that formats a message and parameters that the function utilises.
|
||||
* Presuming the message function may be expensive we only call it if logging is enabled.
|
||||
*
|
||||
* The log messages are de-duplicated based on the parameters, so it is assumed they are simple types that stringify
|
||||
* well.
|
||||
*
|
||||
* @param {function|boolean} debug A boolean or debug function
|
||||
* @return {function(function, array):void} A logging function possibly degenerate
|
||||
*/
|
||||
const createDebugLogger = (debug) => {
|
||||
const log = !!debug && ((typeof debug === 'function') ? debug : console.log);
|
||||
const cache = {};
|
||||
return log ?
|
||||
((msgFn, params) => {
|
||||
const key = Function.prototype.toString.call(msgFn) + JSON.stringify(params);
|
||||
if (!cache[key]) {
|
||||
cache[key] = true;
|
||||
log(msgFn.apply(null, params));
|
||||
}
|
||||
}) :
|
||||
(() => undefined);
|
||||
};
|
||||
|
||||
exports.createDebugLogger = createDebugLogger;
|
||||
24
my-app/node_modules/resolve-url-loader/lib/join-function/fs-utils.js
generated
vendored
Executable file
24
my-app/node_modules/resolve-url-loader/lib/join-function/fs-utils.js
generated
vendored
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* MIT License http://opensource.org/licenses/MIT
|
||||
* Author: Ben Holloway @bholloway
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const fsUtils = (fs) => {
|
||||
// fs from enhanced-resolver doesn't include fs.existsSync so we need to use fs.statsSync instead
|
||||
const withStats = (fn) => (absolutePath) => {
|
||||
try {
|
||||
return fn(fs.statSync(absolutePath));
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
isFileSync: withStats((stats) => stats.isFile()),
|
||||
isDirectorySync: withStats((stats) => stats.isDirectory()),
|
||||
existsSync: withStats((stats) => stats.isFile() || stats.isDirectory())
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = fsUtils;
|
||||
235
my-app/node_modules/resolve-url-loader/lib/join-function/index.js
generated
vendored
Executable file
235
my-app/node_modules/resolve-url-loader/lib/join-function/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1,235 @@
|
|||
/*
|
||||
* MIT License http://opensource.org/licenses/MIT
|
||||
* Author: Ben Holloway @bholloway
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const { createDebugLogger, formatJoinMessage } = require('./debug');
|
||||
const fsUtils = require('./fs-utils');
|
||||
|
||||
const ITERATION_SAFETY_LIMIT = 100e3;
|
||||
|
||||
/**
|
||||
* Wrap a function such that it always returns a generator of tuple elements.
|
||||
*
|
||||
* @param {function({uri:string},...):(Array|Iterator)<[string,string]|string>} fn The function to wrap
|
||||
* @returns {function({uri:string},...):(Array|Iterator)<[string,string]>} A function that always returns tuple elements
|
||||
*/
|
||||
const asGenerator = (fn) => {
|
||||
const toTuple = (defaults) => (value) => {
|
||||
const partial = [].concat(value);
|
||||
return [...partial, ...defaults.slice(partial.length)];
|
||||
};
|
||||
|
||||
const isTupleUnique = (v, i, a) => {
|
||||
const required = v.join(',');
|
||||
return a.findIndex((vv) => vv.join(',') === required) === i;
|
||||
};
|
||||
|
||||
return (item, ...rest) => {
|
||||
const {uri} = item;
|
||||
const mapTuple = toTuple([null, uri]);
|
||||
const pending = fn(item, ...rest);
|
||||
if (Array.isArray(pending)) {
|
||||
return pending.map(mapTuple).filter(isTupleUnique)[Symbol.iterator]();
|
||||
} else if (
|
||||
pending &&
|
||||
(typeof pending === 'object') &&
|
||||
(typeof pending.next === 'function') &&
|
||||
(pending.next.length === 0)
|
||||
) {
|
||||
return pending;
|
||||
} else {
|
||||
throw new TypeError(`in "join" function expected "generator" to return Array|Iterator`);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
exports.asGenerator = asGenerator;
|
||||
|
||||
/**
|
||||
* A high-level utility to create a join function.
|
||||
*
|
||||
* The `generator` is responsible for ordering possible base paths. The `operation` is responsible for joining a single
|
||||
* `base` path with the given `uri`. The `predicate` is responsible for reporting whether the single joined value is
|
||||
* successful as the overall result.
|
||||
*
|
||||
* Both the `generator` and `operation` may be `function*()` or simply `function(...):Array<string>`.
|
||||
*
|
||||
* @param {function({uri:string, isAbsolute:boolean, bases:{subString:string, value:string, property:string,
|
||||
* selector:string}}, {filename:string, fs:Object, debug:function|boolean, root:string}):
|
||||
* (Array<string>|Iterator<string>)} generator A function that takes the hash of base paths from the `engine` and
|
||||
* returns ordered iterable of paths to consider
|
||||
* @returns {function({filename:string, fs:Object, debug:function|boolean, root:string}):
|
||||
* (function({uri:string, isAbsolute:boolean, bases:{subString:string, value:string, property:string,
|
||||
* selector:string}}):string)} join implementation
|
||||
*/
|
||||
const createJoinImplementation = (generator) => (item, options, loader) => {
|
||||
const { isAbsolute } = item;
|
||||
const { root } = options;
|
||||
const { fs } = loader;
|
||||
|
||||
// generate the iterator
|
||||
const iterator = generator(item, options, loader);
|
||||
const isValidIterator = iterator && typeof iterator === 'object' && typeof iterator.next === 'function';
|
||||
if (!isValidIterator) {
|
||||
throw new Error('expected generator to return Iterator');
|
||||
}
|
||||
|
||||
// run the iterator lazily and record attempts
|
||||
const { isFileSync, isDirectorySync } = fsUtils(fs);
|
||||
const attempts = [];
|
||||
for (let i = 0; i < ITERATION_SAFETY_LIMIT; i++) {
|
||||
const { value, done } = iterator.next();
|
||||
if (done) {
|
||||
break;
|
||||
} else if (value) {
|
||||
const tuple = Array.isArray(value) && value.length === 2 ? value : null;
|
||||
if (!tuple) {
|
||||
throw new Error('expected Iterator values to be tuple of [string,string], do you need asGenerator utility?');
|
||||
}
|
||||
|
||||
// skip elements where base or uri is non-string
|
||||
// noting that we need to support base="" when root=""
|
||||
const [base, uri] = value;
|
||||
if ((typeof base === 'string') && (typeof uri === 'string')) {
|
||||
|
||||
// validate
|
||||
const isValidBase = (isAbsolute && base === root) || (path.isAbsolute(base) && isDirectorySync(base));
|
||||
if (!isValidBase) {
|
||||
throw new Error(`expected "base" to be absolute path to a valid directory, got "${base}"`);
|
||||
}
|
||||
|
||||
// make the attempt
|
||||
const joined = path.normalize(path.join(base, uri));
|
||||
const isFallback = true;
|
||||
const isSuccess = isFileSync(joined);
|
||||
attempts.push({base, uri, joined, isFallback, isSuccess});
|
||||
|
||||
if (isSuccess) {
|
||||
break;
|
||||
}
|
||||
|
||||
// validate any non-strings are falsey
|
||||
} else {
|
||||
const isValidTuple = value.every((v) => (typeof v === 'string') || !v);
|
||||
if (!isValidTuple) {
|
||||
throw new Error('expected Iterator values to be tuple of [string,string]');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return attempts;
|
||||
};
|
||||
|
||||
exports.createJoinImplementation = createJoinImplementation;
|
||||
|
||||
/**
|
||||
* A low-level utility to create a join function.
|
||||
*
|
||||
* The `implementation` function processes an individual `item` and returns an Array of attempts. Each attempt consists
|
||||
* of a `base` and a `joined` value with `isSuccessful` and `isFallback` flags.
|
||||
*
|
||||
* In the case that any attempt `isSuccessful` then its `joined` value is the outcome. Otherwise the first `isFallback`
|
||||
* attempt is used. If there is no successful or fallback attempts then `null` is returned indicating no change to the
|
||||
* original URI in the CSS.
|
||||
*
|
||||
* The `attempts` Array is logged to console when in `debug` mode.
|
||||
*
|
||||
* @param {string} name Name for the resulting join function
|
||||
* @param {function({uri:string, query:string, isAbsolute:boolean, bases:{subString:string, value:string,
|
||||
* property:string, selector:string}}, {filename:string, fs:Object, debug:function|boolean, root:string}):
|
||||
* Array<{base:string,joined:string,fallback?:string,result?:string}>} implementation A function accepts an item and
|
||||
* returns a list of attempts
|
||||
* @returns {function({filename:string, fs:Object, debug:function|boolean, root:string}):
|
||||
* (function({uri:string, isAbsolute:boolean, bases:{subString:string, value:string, property:string,
|
||||
* selector:string}}):string)} join function
|
||||
*/
|
||||
const createJoinFunction = (name, implementation) => {
|
||||
const assertAttempts = (value) => {
|
||||
const isValid =
|
||||
Array.isArray(value) && value.every((v) =>
|
||||
v &&
|
||||
(typeof v === 'object') &&
|
||||
(typeof v.base === 'string') &&
|
||||
(typeof v.uri === 'string') &&
|
||||
(typeof v.joined === 'string') &&
|
||||
(typeof v.isSuccess === 'boolean') &&
|
||||
(typeof v.isFallback === 'boolean')
|
||||
);
|
||||
if (!isValid) {
|
||||
throw new Error(`expected implementation to return Array of {base, uri, joined, isSuccess, isFallback}`);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
const assertJoined = (value) => {
|
||||
const isValid = value && (typeof value === 'string') && path.isAbsolute(value) || (value === null);
|
||||
if (!isValid) {
|
||||
throw new Error(`expected "joined" to be absolute path, got "${value}"`);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
const join = (options, loader) => {
|
||||
const { debug } = options;
|
||||
const { resourcePath } = loader;
|
||||
const log = createDebugLogger(debug);
|
||||
|
||||
return (item) => {
|
||||
const { uri } = item;
|
||||
const attempts = implementation(item, options, loader);
|
||||
assertAttempts(attempts, !!debug);
|
||||
|
||||
const { joined: fallback } = attempts.find(({ isFallback }) => isFallback) || {};
|
||||
const { joined: result } = attempts.find(({ isSuccess }) => isSuccess) || {};
|
||||
|
||||
log(formatJoinMessage, [resourcePath, uri, attempts]);
|
||||
|
||||
return assertJoined(result || fallback || null);
|
||||
};
|
||||
};
|
||||
|
||||
const toString = () => '[Function ' + name + ']';
|
||||
|
||||
return Object.assign(join, !!name && {
|
||||
toString,
|
||||
toJSON: toString
|
||||
});
|
||||
};
|
||||
|
||||
exports.createJoinFunction = createJoinFunction;
|
||||
|
||||
/**
|
||||
* The default iterable factory will order `subString` then `value` then `property` then `selector`.
|
||||
*
|
||||
* @param {string} uri The uri given in the file webpack is processing
|
||||
* @param {boolean} isAbsolute True for absolute URIs, false for relative URIs
|
||||
* @param {string} subString A possible base path
|
||||
* @param {string} value A possible base path
|
||||
* @param {string} property A possible base path
|
||||
* @param {string} selector A possible base path
|
||||
* @param {string} root The loader options.root value where given
|
||||
* @returns {Array<string>} An iterable of possible base paths in preference order
|
||||
*/
|
||||
const defaultJoinGenerator = asGenerator(
|
||||
({ uri, isAbsolute, bases: { subString, value, property, selector } }, { root }) =>
|
||||
isAbsolute ? [root] : [subString, value, property, selector]
|
||||
);
|
||||
|
||||
exports.defaultJoinGenerator = defaultJoinGenerator;
|
||||
|
||||
/**
|
||||
* @type {function({filename:string, fs:Object, debug:function|boolean, root:string}):
|
||||
* (function({uri:string, isAbsolute:boolean, bases:{subString:string, value:string, property:string,
|
||||
* selector:string}}):string)} join function
|
||||
*/
|
||||
exports.defaultJoin = createJoinFunction(
|
||||
'defaultJoin',
|
||||
createJoinImplementation(defaultJoinGenerator)
|
||||
);
|
||||
36
my-app/node_modules/resolve-url-loader/lib/log-to-test-harness.js
generated
vendored
Executable file
36
my-app/node_modules/resolve-url-loader/lib/log-to-test-harness.js
generated
vendored
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* MIT License http://opensource.org/licenses/MIT
|
||||
* Author: Ben Holloway @bholloway
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var stream = require('stream');
|
||||
|
||||
var hasLogged = false;
|
||||
|
||||
function logToTestHarness(maybeStream, options) {
|
||||
var doLogging =
|
||||
!hasLogged &&
|
||||
!!maybeStream &&
|
||||
(typeof maybeStream === 'object') &&
|
||||
(maybeStream instanceof stream.Writable);
|
||||
|
||||
if (doLogging) {
|
||||
hasLogged = true; // ensure we log only once
|
||||
Object.keys(options).forEach(eachOptionKey);
|
||||
}
|
||||
|
||||
function eachOptionKey(key) {
|
||||
maybeStream.write(key + ': ' + stringify(options[key]) + '\n');
|
||||
}
|
||||
|
||||
function stringify(value) {
|
||||
try {
|
||||
return JSON.stringify(value) || String(value);
|
||||
} catch (e) {
|
||||
return '-unstringifyable-';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = logToTestHarness;
|
||||
62
my-app/node_modules/resolve-url-loader/lib/position-algerbra.js
generated
vendored
Executable file
62
my-app/node_modules/resolve-url-loader/lib/position-algerbra.js
generated
vendored
Executable file
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* MIT License http://opensource.org/licenses/MIT
|
||||
* Author: Ben Holloway @bholloway
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Given a sourcemap position create a new maybeObject with only line and column properties.
|
||||
*
|
||||
* @param {*|{line: number, column: number}} maybeObj Possible location hash
|
||||
* @returns {{line: number, column: number}} Location hash with possible NaN values
|
||||
*/
|
||||
function sanitise(maybeObj) {
|
||||
var obj = !!maybeObj && typeof maybeObj === 'object' && maybeObj || {};
|
||||
return {
|
||||
line: isNaN(obj.line) ? NaN : obj.line,
|
||||
column: isNaN(obj.column) ? NaN : obj.column
|
||||
};
|
||||
}
|
||||
|
||||
exports.sanitise = sanitise;
|
||||
|
||||
/**
|
||||
* Infer a line and position delta based on the linebreaks in the given string.
|
||||
*
|
||||
* @param candidate {string} A string with possible linebreaks
|
||||
* @returns {{line: number, column: number}} A position object where line and column are deltas
|
||||
*/
|
||||
function strToOffset(candidate) {
|
||||
var split = candidate.split(/\r\n|\n/g);
|
||||
var last = split[split.length - 1];
|
||||
return {
|
||||
line: split.length - 1,
|
||||
column: last.length
|
||||
};
|
||||
}
|
||||
|
||||
exports.strToOffset = strToOffset;
|
||||
|
||||
/**
|
||||
* Add together a list of position elements.
|
||||
*
|
||||
* Lines are added. If the new line is zero the column is added otherwise it is overwritten.
|
||||
*
|
||||
* @param {{line: number, column: number}[]} list One or more sourcemap position elements to add
|
||||
* @returns {{line: number, column: number}} Resultant position element
|
||||
*/
|
||||
function add(list) {
|
||||
return list
|
||||
.slice(1)
|
||||
.reduce(
|
||||
function (accumulator, element) {
|
||||
return {
|
||||
line: accumulator.line + element.line,
|
||||
column: element.line > 0 ? element.column : accumulator.column + element.column,
|
||||
};
|
||||
},
|
||||
list[0]
|
||||
);
|
||||
}
|
||||
|
||||
exports.add = add;
|
||||
136
my-app/node_modules/resolve-url-loader/lib/value-processor.js
generated
vendored
Executable file
136
my-app/node_modules/resolve-url-loader/lib/value-processor.js
generated
vendored
Executable file
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* MIT License http://opensource.org/licenses/MIT
|
||||
* Author: Ben Holloway @bholloway
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var path = require('path'),
|
||||
loaderUtils = require('loader-utils');
|
||||
|
||||
/**
|
||||
* Create a value processing function for a given file path.
|
||||
*
|
||||
* @param {function(Object):string} join The inner join function
|
||||
* @param {string} root The loader options.root value where given
|
||||
* @param {string} directory The directory of the file webpack is currently processing
|
||||
* @return {function} value processing function
|
||||
*/
|
||||
function valueProcessor({ join, root, directory }) {
|
||||
var URL_STATEMENT_REGEX = /(url\s*\(\s*)(?:(['"])((?:(?!\2).)*)(\2)|([^'"](?:(?!\)).)*[^'"]))(\s*\))/g,
|
||||
QUERY_REGEX = /([?#])/g;
|
||||
|
||||
/**
|
||||
* Process the given CSS declaration value.
|
||||
*
|
||||
* @param {string} value A declaration value that may or may not contain a url() statement
|
||||
* @param {function(number):Object} getPathsAtChar Given an offset in the declaration value get a
|
||||
* list of possible absolute path strings
|
||||
*/
|
||||
return function transformValue(value, getPathsAtChar) {
|
||||
|
||||
// allow multiple url() values in the declaration
|
||||
// split by url statements and process the content
|
||||
// additional capture groups are needed to match quotations correctly
|
||||
// escaped quotations are not considered
|
||||
return value
|
||||
.split(URL_STATEMENT_REGEX)
|
||||
.map(initialise)
|
||||
.map(eachSplitOrGroup)
|
||||
.join('');
|
||||
|
||||
/**
|
||||
* Ensure all capture group tokens are a valid string.
|
||||
*
|
||||
* @param {string|void} token A capture group or uncaptured token
|
||||
* @returns {string}
|
||||
*/
|
||||
function initialise(token) {
|
||||
return typeof token === 'string' ? token : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* An Array reduce function that accumulates string length.
|
||||
*/
|
||||
function accumulateLength(accumulator, element) {
|
||||
return accumulator + element.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode the content portion of <code>url()</code> statements.
|
||||
* There are 6 capture groups in the split making every 7th unmatched.
|
||||
*
|
||||
* @param {string} element A single split item
|
||||
* @param {number} i The index of the item in the split
|
||||
* @param {Array} arr The array of split values
|
||||
* @returns {string} Every 3 or 5 items is an encoded url everything else is as is
|
||||
*/
|
||||
function eachSplitOrGroup(element, i, arr) {
|
||||
|
||||
// the content of the url() statement is either in group 3 or group 5
|
||||
var mod = i % 7;
|
||||
|
||||
// only one of the capture groups 3 or 5 will match the other will be falsey
|
||||
if (element && ((mod === 3) || (mod === 5))) {
|
||||
|
||||
// calculate the offset of the match from the front of the string
|
||||
var position = arr.slice(0, i - mod + 1).reduce(accumulateLength, 0);
|
||||
|
||||
// detect quoted url and unescape backslashes
|
||||
var before = arr[i - 1],
|
||||
after = arr[i + 1],
|
||||
isQuoted = (before === after) && ((before === '\'') || (before === '"')),
|
||||
unescaped = isQuoted ? element.replace(/\\{2}/g, '\\') : element;
|
||||
|
||||
// split into uri and query/hash and then determine if the uri is some type of file
|
||||
var split = unescaped.split(QUERY_REGEX),
|
||||
uri = split[0],
|
||||
query = split.slice(1).join(''),
|
||||
isRelative = testIsRelative(uri),
|
||||
isAbsolute = testIsAbsolute(uri);
|
||||
|
||||
// file like URIs are processed but not all URIs are files
|
||||
if (isRelative || isAbsolute) {
|
||||
var bases = getPathsAtChar(position), // construct iterator as late as possible in case sourcemap invalid
|
||||
absolute = join({ uri, query, isAbsolute, bases });
|
||||
|
||||
if (typeof absolute === 'string') {
|
||||
var relative = path.relative(directory, absolute)
|
||||
.replace(/\\/g, '/'); // #6 - backslashes are not legal in URI
|
||||
|
||||
return loaderUtils.urlToRequest(relative + query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// everything else, including parentheses and quotation (where present) and media statements
|
||||
return element;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The loaderUtils.isUrlRequest() doesn't support windows absolute paths on principle. We do not subscribe to that
|
||||
* dogma so we add path.isAbsolute() check to allow them.
|
||||
*
|
||||
* We also eliminate module relative (~) paths.
|
||||
*
|
||||
* @param {string|undefined} uri A uri string possibly empty or undefined
|
||||
* @return {boolean} True for relative uri
|
||||
*/
|
||||
function testIsRelative(uri) {
|
||||
return !!uri && loaderUtils.isUrlRequest(uri, false) && !path.isAbsolute(uri) && (uri.indexOf('~') !== 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* The loaderUtils.isUrlRequest() doesn't support windows absolute paths on principle. We do not subscribe to that
|
||||
* dogma so we add path.isAbsolute() check to allow them.
|
||||
*
|
||||
* @param {string|undefined} uri A uri string possibly empty or undefined
|
||||
* @return {boolean} True for absolute uri
|
||||
*/
|
||||
function testIsAbsolute(uri) {
|
||||
return !!uri && (typeof root === 'string') && loaderUtils.isUrlRequest(uri, root) &&
|
||||
(/^\//.test(uri) || path.isAbsolute(uri));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = valueProcessor;
|
||||
20
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/LICENSE
generated
vendored
Executable file
20
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/LICENSE
generated
vendored
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
Copyright JS Foundation and other contributors
|
||||
|
||||
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.
|
||||
275
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/README.md
generated
vendored
Executable file
275
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/README.md
generated
vendored
Executable file
|
|
@ -0,0 +1,275 @@
|
|||
# loader-utils
|
||||
|
||||
## Methods
|
||||
|
||||
### `getOptions`
|
||||
|
||||
Recommended way to retrieve the options of a loader invocation:
|
||||
|
||||
```javascript
|
||||
// inside your loader
|
||||
const options = loaderUtils.getOptions(this);
|
||||
```
|
||||
|
||||
1. If `this.query` is a string:
|
||||
- Tries to parse the query string and returns a new object
|
||||
- Throws if it's not a valid query string
|
||||
2. If `this.query` is object-like, it just returns `this.query`
|
||||
3. In any other case, it just returns `null`
|
||||
|
||||
**Please note:** The returned `options` object is *read-only*. It may be re-used across multiple invocations.
|
||||
If you pass it on to another library, make sure to make a *deep copy* of it:
|
||||
|
||||
```javascript
|
||||
const options = Object.assign(
|
||||
{},
|
||||
defaultOptions,
|
||||
loaderUtils.getOptions(this) // it is safe to pass null to Object.assign()
|
||||
);
|
||||
// don't forget nested objects or arrays
|
||||
options.obj = Object.assign({}, options.obj);
|
||||
options.arr = options.arr.slice();
|
||||
someLibrary(options);
|
||||
```
|
||||
|
||||
[clone](https://www.npmjs.com/package/clone) is a good library to make a deep copy of the options.
|
||||
|
||||
#### Options as query strings
|
||||
|
||||
If the loader options have been passed as loader query string (`loader?some¶ms`), the string is parsed by using [`parseQuery`](#parsequery).
|
||||
|
||||
### `parseQuery`
|
||||
|
||||
Parses a passed string (e.g. `loaderContext.resourceQuery`) as a query string, and returns an object.
|
||||
|
||||
``` javascript
|
||||
const params = loaderUtils.parseQuery(this.resourceQuery); // resource: `file?param1=foo`
|
||||
if (params.param1 === "foo") {
|
||||
// do something
|
||||
}
|
||||
```
|
||||
|
||||
The string is parsed like this:
|
||||
|
||||
``` text
|
||||
-> Error
|
||||
? -> {}
|
||||
?flag -> { flag: true }
|
||||
?+flag -> { flag: true }
|
||||
?-flag -> { flag: false }
|
||||
?xyz=test -> { xyz: "test" }
|
||||
?xyz=1 -> { xyz: "1" } // numbers are NOT parsed
|
||||
?xyz[]=a -> { xyz: ["a"] }
|
||||
?flag1&flag2 -> { flag1: true, flag2: true }
|
||||
?+flag1,-flag2 -> { flag1: true, flag2: false }
|
||||
?xyz[]=a,xyz[]=b -> { xyz: ["a", "b"] }
|
||||
?a%2C%26b=c%2C%26d -> { "a,&b": "c,&d" }
|
||||
?{data:{a:1},isJSON5:true} -> { data: { a: 1 }, isJSON5: true }
|
||||
```
|
||||
|
||||
### `stringifyRequest`
|
||||
|
||||
Turns a request into a string that can be used inside `require()` or `import` while avoiding absolute paths.
|
||||
Use it instead of `JSON.stringify(...)` if you're generating code inside a loader.
|
||||
|
||||
**Why is this necessary?** Since webpack calculates the hash before module paths are translated into module ids, we must avoid absolute paths to ensure
|
||||
consistent hashes across different compilations.
|
||||
|
||||
This function:
|
||||
|
||||
- resolves absolute requests into relative requests if the request and the module are on the same hard drive
|
||||
- replaces `\` with `/` if the request and the module are on the same hard drive
|
||||
- won't change the path at all if the request and the module are on different hard drives
|
||||
- applies `JSON.stringify` to the result
|
||||
|
||||
```javascript
|
||||
loaderUtils.stringifyRequest(this, "./test.js");
|
||||
// "\"./test.js\""
|
||||
|
||||
loaderUtils.stringifyRequest(this, ".\\test.js");
|
||||
// "\"./test.js\""
|
||||
|
||||
loaderUtils.stringifyRequest(this, "test");
|
||||
// "\"test\""
|
||||
|
||||
loaderUtils.stringifyRequest(this, "test/lib/index.js");
|
||||
// "\"test/lib/index.js\""
|
||||
|
||||
loaderUtils.stringifyRequest(this, "otherLoader?andConfig!test?someConfig");
|
||||
// "\"otherLoader?andConfig!test?someConfig\""
|
||||
|
||||
loaderUtils.stringifyRequest(this, require.resolve("test"));
|
||||
// "\"../node_modules/some-loader/lib/test.js\""
|
||||
|
||||
loaderUtils.stringifyRequest(this, "C:\\module\\test.js");
|
||||
// "\"../../test.js\"" (on Windows, in case the module and the request are on the same drive)
|
||||
|
||||
loaderUtils.stringifyRequest(this, "C:\\module\\test.js");
|
||||
// "\"C:\\module\\test.js\"" (on Windows, in case the module and the request are on different drives)
|
||||
|
||||
loaderUtils.stringifyRequest(this, "\\\\network-drive\\test.js");
|
||||
// "\"\\\\network-drive\\\\test.js\"" (on Windows, in case the module and the request are on different drives)
|
||||
```
|
||||
|
||||
### `urlToRequest`
|
||||
|
||||
Converts some resource URL to a webpack module request.
|
||||
|
||||
> i Before call `urlToRequest` you need call `isUrlRequest` to ensure it is requestable url
|
||||
|
||||
```javascript
|
||||
const url = "path/to/module.js";
|
||||
|
||||
if (loaderUtils.isUrlRequest(url)) {
|
||||
// Logic for requestable url
|
||||
const request = loaderUtils.urlToRequest(url);
|
||||
} else {
|
||||
// Logic for not requestable url
|
||||
}
|
||||
```
|
||||
|
||||
Simple example:
|
||||
|
||||
```javascript
|
||||
const url = "path/to/module.js";
|
||||
const request = loaderUtils.urlToRequest(url); // "./path/to/module.js"
|
||||
```
|
||||
|
||||
#### Module URLs
|
||||
|
||||
Any URL containing a `~` will be interpreted as a module request. Anything after the `~` will be considered the request path.
|
||||
|
||||
```javascript
|
||||
const url = "~path/to/module.js";
|
||||
const request = loaderUtils.urlToRequest(url); // "path/to/module.js"
|
||||
```
|
||||
|
||||
#### Root-relative URLs
|
||||
|
||||
URLs that are root-relative (start with `/`) can be resolved relative to some arbitrary path by using the `root` parameter:
|
||||
|
||||
```javascript
|
||||
const url = "/path/to/module.js";
|
||||
const root = "./root";
|
||||
const request = loaderUtils.urlToRequest(url, root); // "./root/path/to/module.js"
|
||||
```
|
||||
|
||||
To convert a root-relative URL into a module URL, specify a `root` value that starts with `~`:
|
||||
|
||||
```javascript
|
||||
const url = "/path/to/module.js";
|
||||
const root = "~";
|
||||
const request = loaderUtils.urlToRequest(url, root); // "path/to/module.js"
|
||||
```
|
||||
|
||||
### `interpolateName`
|
||||
|
||||
Interpolates a filename template using multiple placeholders and/or a regular expression.
|
||||
The template and regular expression are set as query params called `name` and `regExp` on the current loader's context.
|
||||
|
||||
```javascript
|
||||
const interpolatedName = loaderUtils.interpolateName(loaderContext, name, options);
|
||||
```
|
||||
|
||||
The following tokens are replaced in the `name` parameter:
|
||||
|
||||
* `[ext]` the extension of the resource
|
||||
* `[name]` the basename of the resource
|
||||
* `[path]` the path of the resource relative to the `context` query parameter or option.
|
||||
* `[folder]` the folder the resource is in
|
||||
* `[query]` the queryof the resource, i.e. `?foo=bar`
|
||||
* `[emoji]` a random emoji representation of `options.content`
|
||||
* `[emoji:<length>]` same as above, but with a customizable number of emojis
|
||||
* `[contenthash]` the hash of `options.content` (Buffer) (by default it's the hex digest of the md4 hash)
|
||||
* `[<hashType>:contenthash:<digestType>:<length>]` optionally one can configure
|
||||
* other `hashType`s, i. e. `sha1`, `md4`, `md5`, `sha256`, `sha512`
|
||||
* other `digestType`s, i. e. `hex`, `base26`, `base32`, `base36`, `base49`, `base52`, `base58`, `base62`, `base64`
|
||||
* and `length` the length in chars
|
||||
* `[hash]` the hash of `options.content` (Buffer) (by default it's the hex digest of the md4 hash)
|
||||
* `[<hashType>:hash:<digestType>:<length>]` optionally one can configure
|
||||
* other `hashType`s, i. e. `sha1`, `md4`, `md5`, `sha256`, `sha512`
|
||||
* other `digestType`s, i. e. `hex`, `base26`, `base32`, `base36`, `base49`, `base52`, `base58`, `base62`, `base64`
|
||||
* and `length` the length in chars
|
||||
* `[N]` the N-th match obtained from matching the current file name against `options.regExp`
|
||||
|
||||
In loader context `[hash]` and `[contenthash]` are the same, but we recommend using `[contenthash]` for avoid misleading.
|
||||
|
||||
Examples
|
||||
|
||||
``` javascript
|
||||
// loaderContext.resourcePath = "/absolute/path/to/app/js/javascript.js"
|
||||
loaderUtils.interpolateName(loaderContext, "js/[hash].script.[ext]", { content: ... });
|
||||
// => js/9473fdd0d880a43c21b7778d34872157.script.js
|
||||
|
||||
// loaderContext.resourcePath = "/absolute/path/to/app/js/javascript.js"
|
||||
// loaderContext.resourceQuery = "?foo=bar"
|
||||
loaderUtils.interpolateName(loaderContext, "js/[hash].script.[ext][query]", { content: ... });
|
||||
// => js/9473fdd0d880a43c21b7778d34872157.script.js?foo=bar
|
||||
|
||||
// loaderContext.resourcePath = "/absolute/path/to/app/js/javascript.js"
|
||||
loaderUtils.interpolateName(loaderContext, "js/[contenthash].script.[ext]", { content: ... });
|
||||
// => js/9473fdd0d880a43c21b7778d34872157.script.js
|
||||
|
||||
// loaderContext.resourcePath = "/absolute/path/to/app/page.html"
|
||||
loaderUtils.interpolateName(loaderContext, "html-[hash:6].html", { content: ... });
|
||||
// => html-9473fd.html
|
||||
|
||||
// loaderContext.resourcePath = "/absolute/path/to/app/flash.txt"
|
||||
loaderUtils.interpolateName(loaderContext, "[hash]", { content: ... });
|
||||
// => c31e9820c001c9c4a86bce33ce43b679
|
||||
|
||||
// loaderContext.resourcePath = "/absolute/path/to/app/img/image.gif"
|
||||
loaderUtils.interpolateName(loaderContext, "[emoji]", { content: ... });
|
||||
// => 👍
|
||||
|
||||
// loaderContext.resourcePath = "/absolute/path/to/app/img/image.gif"
|
||||
loaderUtils.interpolateName(loaderContext, "[emoji:4]", { content: ... });
|
||||
// => 🙍🏢📤🐝
|
||||
|
||||
// loaderContext.resourcePath = "/absolute/path/to/app/img/image.png"
|
||||
loaderUtils.interpolateName(loaderContext, "[sha512:hash:base64:7].[ext]", { content: ... });
|
||||
// => 2BKDTjl.png
|
||||
// use sha512 hash instead of md4 and with only 7 chars of base64
|
||||
|
||||
// loaderContext.resourcePath = "/absolute/path/to/app/img/myself.png"
|
||||
// loaderContext.query.name =
|
||||
loaderUtils.interpolateName(loaderContext, "picture.png");
|
||||
// => picture.png
|
||||
|
||||
// loaderContext.resourcePath = "/absolute/path/to/app/dir/file.png"
|
||||
loaderUtils.interpolateName(loaderContext, "[path][name].[ext]?[hash]", { content: ... });
|
||||
// => /app/dir/file.png?9473fdd0d880a43c21b7778d34872157
|
||||
|
||||
// loaderContext.resourcePath = "/absolute/path/to/app/js/page-home.js"
|
||||
loaderUtils.interpolateName(loaderContext, "script-[1].[ext]", { regExp: "page-(.*)\\.js", content: ... });
|
||||
// => script-home.js
|
||||
|
||||
// loaderContext.resourcePath = "/absolute/path/to/app/js/javascript.js"
|
||||
// loaderContext.resourceQuery = "?foo=bar"
|
||||
loaderUtils.interpolateName(
|
||||
loaderContext,
|
||||
(resourcePath, resourceQuery) => {
|
||||
// resourcePath - `/app/js/javascript.js`
|
||||
// resourceQuery - `?foo=bar`
|
||||
|
||||
return "js/[hash].script.[ext]";
|
||||
},
|
||||
{ content: ... }
|
||||
);
|
||||
// => js/9473fdd0d880a43c21b7778d34872157.script.js
|
||||
```
|
||||
|
||||
### `getHashDigest`
|
||||
|
||||
``` javascript
|
||||
const digestString = loaderUtils.getHashDigest(buffer, hashType, digestType, maxLength);
|
||||
```
|
||||
|
||||
* `buffer` the content that should be hashed
|
||||
* `hashType` one of `sha1`, `md4`, `md5`, `sha256`, `sha512` or any other node.js supported hash type
|
||||
* `digestType` one of `hex`, `base26`, `base32`, `base36`, `base49`, `base52`, `base58`, `base62`, `base64`
|
||||
* `maxLength` the maximum length in chars
|
||||
|
||||
## License
|
||||
|
||||
MIT (http://www.opensource.org/licenses/mit-license.php)
|
||||
16
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/getCurrentRequest.js
generated
vendored
Executable file
16
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/getCurrentRequest.js
generated
vendored
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
'use strict';
|
||||
|
||||
function getCurrentRequest(loaderContext) {
|
||||
if (loaderContext.currentRequest) {
|
||||
return loaderContext.currentRequest;
|
||||
}
|
||||
|
||||
const request = loaderContext.loaders
|
||||
.slice(loaderContext.loaderIndex)
|
||||
.map((obj) => obj.request)
|
||||
.concat([loaderContext.resource]);
|
||||
|
||||
return request.join('!');
|
||||
}
|
||||
|
||||
module.exports = getCurrentRequest;
|
||||
91
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/getHashDigest.js
generated
vendored
Executable file
91
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/getHashDigest.js
generated
vendored
Executable file
|
|
@ -0,0 +1,91 @@
|
|||
'use strict';
|
||||
|
||||
const baseEncodeTables = {
|
||||
26: 'abcdefghijklmnopqrstuvwxyz',
|
||||
32: '123456789abcdefghjkmnpqrstuvwxyz', // no 0lio
|
||||
36: '0123456789abcdefghijklmnopqrstuvwxyz',
|
||||
49: 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ', // no lIO
|
||||
52: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
||||
58: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ', // no 0lIO
|
||||
62: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
||||
64: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_',
|
||||
};
|
||||
|
||||
function encodeBufferToBase(buffer, base) {
|
||||
const encodeTable = baseEncodeTables[base];
|
||||
if (!encodeTable) {
|
||||
throw new Error('Unknown encoding base' + base);
|
||||
}
|
||||
|
||||
const readLength = buffer.length;
|
||||
const Big = require('big.js');
|
||||
|
||||
Big.RM = Big.DP = 0;
|
||||
let b = new Big(0);
|
||||
|
||||
for (let i = readLength - 1; i >= 0; i--) {
|
||||
b = b.times(256).plus(buffer[i]);
|
||||
}
|
||||
|
||||
let output = '';
|
||||
while (b.gt(0)) {
|
||||
output = encodeTable[b.mod(base)] + output;
|
||||
b = b.div(base);
|
||||
}
|
||||
|
||||
Big.DP = 20;
|
||||
Big.RM = 1;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
let createMd4 = undefined;
|
||||
let BatchedHash = undefined;
|
||||
|
||||
function getHashDigest(buffer, hashType, digestType, maxLength) {
|
||||
hashType = hashType || 'md4';
|
||||
maxLength = maxLength || 9999;
|
||||
|
||||
let hash;
|
||||
|
||||
try {
|
||||
hash = require('crypto').createHash(hashType);
|
||||
} catch (error) {
|
||||
if (error.code === 'ERR_OSSL_EVP_UNSUPPORTED' && hashType === 'md4') {
|
||||
if (createMd4 === undefined) {
|
||||
createMd4 = require('./hash/md4');
|
||||
|
||||
if (BatchedHash === undefined) {
|
||||
BatchedHash = require('./hash/BatchedHash');
|
||||
}
|
||||
}
|
||||
|
||||
hash = new BatchedHash(createMd4());
|
||||
}
|
||||
|
||||
if (!hash) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
hash.update(buffer);
|
||||
|
||||
if (
|
||||
digestType === 'base26' ||
|
||||
digestType === 'base32' ||
|
||||
digestType === 'base36' ||
|
||||
digestType === 'base49' ||
|
||||
digestType === 'base52' ||
|
||||
digestType === 'base58' ||
|
||||
digestType === 'base62'
|
||||
) {
|
||||
return encodeBufferToBase(hash.digest(), digestType.substr(4)).substr(
|
||||
0,
|
||||
maxLength
|
||||
);
|
||||
} else {
|
||||
return hash.digest(digestType || 'hex').substr(0, maxLength);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = getHashDigest;
|
||||
20
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/getOptions.js
generated
vendored
Executable file
20
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/getOptions.js
generated
vendored
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
'use strict';
|
||||
|
||||
const parseQuery = require('./parseQuery');
|
||||
|
||||
function getOptions(loaderContext) {
|
||||
const query = loaderContext.query;
|
||||
|
||||
if (typeof query === 'string' && query !== '') {
|
||||
return parseQuery(loaderContext.query);
|
||||
}
|
||||
|
||||
if (!query || typeof query !== 'object') {
|
||||
// Not object-like queries are not supported.
|
||||
return {};
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
module.exports = getOptions;
|
||||
16
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/getRemainingRequest.js
generated
vendored
Executable file
16
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/getRemainingRequest.js
generated
vendored
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
'use strict';
|
||||
|
||||
function getRemainingRequest(loaderContext) {
|
||||
if (loaderContext.remainingRequest) {
|
||||
return loaderContext.remainingRequest;
|
||||
}
|
||||
|
||||
const request = loaderContext.loaders
|
||||
.slice(loaderContext.loaderIndex + 1)
|
||||
.map((obj) => obj.request)
|
||||
.concat([loaderContext.resource]);
|
||||
|
||||
return request.join('!');
|
||||
}
|
||||
|
||||
module.exports = getRemainingRequest;
|
||||
64
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/hash/BatchedHash.js
generated
vendored
Executable file
64
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/hash/BatchedHash.js
generated
vendored
Executable file
|
|
@ -0,0 +1,64 @@
|
|||
const MAX_SHORT_STRING = require('./wasm-hash').MAX_SHORT_STRING;
|
||||
|
||||
class BatchedHash {
|
||||
constructor(hash) {
|
||||
this.string = undefined;
|
||||
this.encoding = undefined;
|
||||
this.hash = hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
||||
* @param {string|Buffer} data data
|
||||
* @param {string=} inputEncoding data encoding
|
||||
* @returns {this} updated hash
|
||||
*/
|
||||
update(data, inputEncoding) {
|
||||
if (this.string !== undefined) {
|
||||
if (
|
||||
typeof data === 'string' &&
|
||||
inputEncoding === this.encoding &&
|
||||
this.string.length + data.length < MAX_SHORT_STRING
|
||||
) {
|
||||
this.string += data;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
this.hash.update(this.string, this.encoding);
|
||||
this.string = undefined;
|
||||
}
|
||||
|
||||
if (typeof data === 'string') {
|
||||
if (
|
||||
data.length < MAX_SHORT_STRING &&
|
||||
// base64 encoding is not valid since it may contain padding chars
|
||||
(!inputEncoding || !inputEncoding.startsWith('ba'))
|
||||
) {
|
||||
this.string = data;
|
||||
this.encoding = inputEncoding;
|
||||
} else {
|
||||
this.hash.update(data, inputEncoding);
|
||||
}
|
||||
} else {
|
||||
this.hash.update(data);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
||||
* @param {string=} encoding encoding of the return value
|
||||
* @returns {string|Buffer} digest
|
||||
*/
|
||||
digest(encoding) {
|
||||
if (this.string !== undefined) {
|
||||
this.hash.update(this.string, this.encoding);
|
||||
}
|
||||
|
||||
return this.hash.digest(encoding);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BatchedHash;
|
||||
20
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/hash/md4.js
generated
vendored
Executable file
20
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/hash/md4.js
generated
vendored
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const create = require('./wasm-hash');
|
||||
|
||||
//#region wasm code: md4 (../../../assembly/hash/md4.asm.ts) --initialMemory 1
|
||||
const md4 = new WebAssembly.Module(
|
||||
Buffer.from(
|
||||
// 2150 bytes
|
||||
'AGFzbQEAAAABCAJgAX8AYAAAAwUEAQAAAAUDAQABBhoFfwFBAAt/AUEAC38BQQALfwFBAAt/AUEACwciBARpbml0AAAGdXBkYXRlAAIFZmluYWwAAwZtZW1vcnkCAAqFEAQmAEGBxpS6BiQBQYnXtv5+JAJB/rnrxXkkA0H2qMmBASQEQQAkAAvMCgEYfyMBIQojAiEGIwMhByMEIQgDQCAAIAVLBEAgBSgCCCINIAcgBiAFKAIEIgsgCCAHIAUoAgAiDCAKIAggBiAHIAhzcXNqakEDdyIDIAYgB3Nxc2pqQQd3IgEgAyAGc3FzampBC3chAiAFKAIUIg8gASACIAUoAhAiCSADIAEgBSgCDCIOIAYgAyACIAEgA3Nxc2pqQRN3IgQgASACc3FzampBA3ciAyACIARzcXNqakEHdyEBIAUoAiAiEiADIAEgBSgCHCIRIAQgAyAFKAIYIhAgAiAEIAEgAyAEc3FzampBC3ciAiABIANzcXNqakETdyIEIAEgAnNxc2pqQQN3IQMgBSgCLCIVIAQgAyAFKAIoIhQgAiAEIAUoAiQiEyABIAIgAyACIARzcXNqakEHdyIBIAMgBHNxc2pqQQt3IgIgASADc3FzampBE3chBCAPIBAgCSAVIBQgEyAFKAI4IhYgAiAEIAUoAjQiFyABIAIgBSgCMCIYIAMgASAEIAEgAnNxc2pqQQN3IgEgAiAEc3FzampBB3ciAiABIARzcXNqakELdyIDIAkgAiAMIAEgBSgCPCIJIAQgASADIAEgAnNxc2pqQRN3IgEgAiADcnEgAiADcXJqakGZ84nUBWpBA3ciAiABIANycSABIANxcmpqQZnzidQFakEFdyIEIAEgAnJxIAEgAnFyaiASakGZ84nUBWpBCXciAyAPIAQgCyACIBggASADIAIgBHJxIAIgBHFyampBmfOJ1AVqQQ13IgEgAyAEcnEgAyAEcXJqakGZ84nUBWpBA3ciAiABIANycSABIANxcmpqQZnzidQFakEFdyIEIAEgAnJxIAEgAnFyampBmfOJ1AVqQQl3IgMgECAEIAIgFyABIAMgAiAEcnEgAiAEcXJqakGZ84nUBWpBDXciASADIARycSADIARxcmogDWpBmfOJ1AVqQQN3IgIgASADcnEgASADcXJqakGZ84nUBWpBBXciBCABIAJycSABIAJxcmpqQZnzidQFakEJdyIDIBEgBCAOIAIgFiABIAMgAiAEcnEgAiAEcXJqakGZ84nUBWpBDXciASADIARycSADIARxcmpqQZnzidQFakEDdyICIAEgA3JxIAEgA3FyampBmfOJ1AVqQQV3IgQgASACcnEgASACcXJqakGZ84nUBWpBCXciAyAMIAIgAyAJIAEgAyACIARycSACIARxcmpqQZnzidQFakENdyIBcyAEc2pqQaHX5/YGakEDdyICIAQgASACcyADc2ogEmpBodfn9gZqQQl3IgRzIAFzampBodfn9gZqQQt3IgMgAiADIBggASADIARzIAJzampBodfn9gZqQQ93IgFzIARzaiANakGh1+f2BmpBA3ciAiAUIAQgASACcyADc2pqQaHX5/YGakEJdyIEcyABc2pqQaHX5/YGakELdyIDIAsgAiADIBYgASADIARzIAJzampBodfn9gZqQQ93IgFzIARzampBodfn9gZqQQN3IgIgEyAEIAEgAnMgA3NqakGh1+f2BmpBCXciBHMgAXNqakGh1+f2BmpBC3chAyAKIA4gAiADIBcgASADIARzIAJzampBodfn9gZqQQ93IgFzIARzampBodfn9gZqQQN3IgJqIQogBiAJIAEgESADIAIgFSAEIAEgAnMgA3NqakGh1+f2BmpBCXciBHMgAXNqakGh1+f2BmpBC3ciAyAEcyACc2pqQaHX5/YGakEPd2ohBiADIAdqIQcgBCAIaiEIIAVBQGshBQwBCwsgCiQBIAYkAiAHJAMgCCQECw0AIAAQASMAIABqJAAL/wQCA38BfiMAIABqrUIDhiEEIABByABqQUBxIgJBCGshAyAAIgFBAWohACABQYABOgAAA0AgACACSUEAIABBB3EbBEAgAEEAOgAAIABBAWohAAwBCwsDQCAAIAJJBEAgAEIANwMAIABBCGohAAwBCwsgAyAENwMAIAIQAUEAIwGtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEIIwKtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEQIwOtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEYIwStIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAAs=',
|
||||
'base64'
|
||||
)
|
||||
);
|
||||
//#endregion
|
||||
|
||||
module.exports = create.bind(null, md4, [], 64, 32);
|
||||
208
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/hash/wasm-hash.js
generated
vendored
Executable file
208
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/hash/wasm-hash.js
generated
vendored
Executable file
|
|
@ -0,0 +1,208 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// 65536 is the size of a wasm memory page
|
||||
// 64 is the maximum chunk size for every possible wasm hash implementation
|
||||
// 4 is the maximum number of bytes per char for string encoding (max is utf-8)
|
||||
// ~3 makes sure that it's always a block of 4 chars, so avoid partially encoded bytes for base64
|
||||
const MAX_SHORT_STRING = Math.floor((65536 - 64) / 4) & ~3;
|
||||
|
||||
class WasmHash {
|
||||
/**
|
||||
* @param {WebAssembly.Instance} instance wasm instance
|
||||
* @param {WebAssembly.Instance[]} instancesPool pool of instances
|
||||
* @param {number} chunkSize size of data chunks passed to wasm
|
||||
* @param {number} digestSize size of digest returned by wasm
|
||||
*/
|
||||
constructor(instance, instancesPool, chunkSize, digestSize) {
|
||||
const exports = /** @type {any} */ (instance.exports);
|
||||
|
||||
exports.init();
|
||||
|
||||
this.exports = exports;
|
||||
this.mem = Buffer.from(exports.memory.buffer, 0, 65536);
|
||||
this.buffered = 0;
|
||||
this.instancesPool = instancesPool;
|
||||
this.chunkSize = chunkSize;
|
||||
this.digestSize = digestSize;
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.buffered = 0;
|
||||
this.exports.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Buffer | string} data data
|
||||
* @param {BufferEncoding=} encoding encoding
|
||||
* @returns {this} itself
|
||||
*/
|
||||
update(data, encoding) {
|
||||
if (typeof data === 'string') {
|
||||
while (data.length > MAX_SHORT_STRING) {
|
||||
this._updateWithShortString(data.slice(0, MAX_SHORT_STRING), encoding);
|
||||
data = data.slice(MAX_SHORT_STRING);
|
||||
}
|
||||
|
||||
this._updateWithShortString(data, encoding);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
this._updateWithBuffer(data);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} data data
|
||||
* @param {BufferEncoding=} encoding encoding
|
||||
* @returns {void}
|
||||
*/
|
||||
_updateWithShortString(data, encoding) {
|
||||
const { exports, buffered, mem, chunkSize } = this;
|
||||
|
||||
let endPos;
|
||||
|
||||
if (data.length < 70) {
|
||||
if (!encoding || encoding === 'utf-8' || encoding === 'utf8') {
|
||||
endPos = buffered;
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const cc = data.charCodeAt(i);
|
||||
|
||||
if (cc < 0x80) {
|
||||
mem[endPos++] = cc;
|
||||
} else if (cc < 0x800) {
|
||||
mem[endPos] = (cc >> 6) | 0xc0;
|
||||
mem[endPos + 1] = (cc & 0x3f) | 0x80;
|
||||
endPos += 2;
|
||||
} else {
|
||||
// bail-out for weird chars
|
||||
endPos += mem.write(data.slice(i), endPos, encoding);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (encoding === 'latin1') {
|
||||
endPos = buffered;
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const cc = data.charCodeAt(i);
|
||||
|
||||
mem[endPos++] = cc;
|
||||
}
|
||||
} else {
|
||||
endPos = buffered + mem.write(data, buffered, encoding);
|
||||
}
|
||||
} else {
|
||||
endPos = buffered + mem.write(data, buffered, encoding);
|
||||
}
|
||||
|
||||
if (endPos < chunkSize) {
|
||||
this.buffered = endPos;
|
||||
} else {
|
||||
const l = endPos & ~(this.chunkSize - 1);
|
||||
|
||||
exports.update(l);
|
||||
|
||||
const newBuffered = endPos - l;
|
||||
|
||||
this.buffered = newBuffered;
|
||||
|
||||
if (newBuffered > 0) {
|
||||
mem.copyWithin(0, l, endPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Buffer} data data
|
||||
* @returns {void}
|
||||
*/
|
||||
_updateWithBuffer(data) {
|
||||
const { exports, buffered, mem } = this;
|
||||
const length = data.length;
|
||||
|
||||
if (buffered + length < this.chunkSize) {
|
||||
data.copy(mem, buffered, 0, length);
|
||||
|
||||
this.buffered += length;
|
||||
} else {
|
||||
const l = (buffered + length) & ~(this.chunkSize - 1);
|
||||
|
||||
if (l > 65536) {
|
||||
let i = 65536 - buffered;
|
||||
|
||||
data.copy(mem, buffered, 0, i);
|
||||
exports.update(65536);
|
||||
|
||||
const stop = l - buffered - 65536;
|
||||
|
||||
while (i < stop) {
|
||||
data.copy(mem, 0, i, i + 65536);
|
||||
exports.update(65536);
|
||||
i += 65536;
|
||||
}
|
||||
|
||||
data.copy(mem, 0, i, l - buffered);
|
||||
|
||||
exports.update(l - buffered - i);
|
||||
} else {
|
||||
data.copy(mem, buffered, 0, l - buffered);
|
||||
|
||||
exports.update(l);
|
||||
}
|
||||
|
||||
const newBuffered = length + buffered - l;
|
||||
|
||||
this.buffered = newBuffered;
|
||||
|
||||
if (newBuffered > 0) {
|
||||
data.copy(mem, 0, length - newBuffered, length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
digest(type) {
|
||||
const { exports, buffered, mem, digestSize } = this;
|
||||
|
||||
exports.final(buffered);
|
||||
|
||||
this.instancesPool.push(this);
|
||||
|
||||
const hex = mem.toString('latin1', 0, digestSize);
|
||||
|
||||
if (type === 'hex') {
|
||||
return hex;
|
||||
}
|
||||
|
||||
if (type === 'binary' || !type) {
|
||||
return Buffer.from(hex, 'hex');
|
||||
}
|
||||
|
||||
return Buffer.from(hex, 'hex').toString(type);
|
||||
}
|
||||
}
|
||||
|
||||
const create = (wasmModule, instancesPool, chunkSize, digestSize) => {
|
||||
if (instancesPool.length > 0) {
|
||||
const old = instancesPool.pop();
|
||||
|
||||
old.reset();
|
||||
|
||||
return old;
|
||||
} else {
|
||||
return new WasmHash(
|
||||
new WebAssembly.Instance(wasmModule),
|
||||
instancesPool,
|
||||
chunkSize,
|
||||
digestSize
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = create;
|
||||
module.exports.MAX_SHORT_STRING = MAX_SHORT_STRING;
|
||||
23
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/index.js
generated
vendored
Executable file
23
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
'use strict';
|
||||
|
||||
const getOptions = require('./getOptions');
|
||||
const parseQuery = require('./parseQuery');
|
||||
const stringifyRequest = require('./stringifyRequest');
|
||||
const getRemainingRequest = require('./getRemainingRequest');
|
||||
const getCurrentRequest = require('./getCurrentRequest');
|
||||
const isUrlRequest = require('./isUrlRequest');
|
||||
const urlToRequest = require('./urlToRequest');
|
||||
const parseString = require('./parseString');
|
||||
const getHashDigest = require('./getHashDigest');
|
||||
const interpolateName = require('./interpolateName');
|
||||
|
||||
exports.getOptions = getOptions;
|
||||
exports.parseQuery = parseQuery;
|
||||
exports.stringifyRequest = stringifyRequest;
|
||||
exports.getRemainingRequest = getRemainingRequest;
|
||||
exports.getCurrentRequest = getCurrentRequest;
|
||||
exports.isUrlRequest = isUrlRequest;
|
||||
exports.urlToRequest = urlToRequest;
|
||||
exports.parseString = parseString;
|
||||
exports.getHashDigest = getHashDigest;
|
||||
exports.interpolateName = interpolateName;
|
||||
151
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/interpolateName.js
generated
vendored
Executable file
151
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/interpolateName.js
generated
vendored
Executable file
|
|
@ -0,0 +1,151 @@
|
|||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const emojisList = require('emojis-list');
|
||||
const getHashDigest = require('./getHashDigest');
|
||||
|
||||
const emojiRegex = /[\uD800-\uDFFF]./;
|
||||
const emojiList = emojisList.filter((emoji) => emojiRegex.test(emoji));
|
||||
const emojiCache = {};
|
||||
|
||||
function encodeStringToEmoji(content, length) {
|
||||
if (emojiCache[content]) {
|
||||
return emojiCache[content];
|
||||
}
|
||||
|
||||
length = length || 1;
|
||||
|
||||
const emojis = [];
|
||||
|
||||
do {
|
||||
if (!emojiList.length) {
|
||||
throw new Error('Ran out of emoji');
|
||||
}
|
||||
|
||||
const index = Math.floor(Math.random() * emojiList.length);
|
||||
|
||||
emojis.push(emojiList[index]);
|
||||
emojiList.splice(index, 1);
|
||||
} while (--length > 0);
|
||||
|
||||
const emojiEncoding = emojis.join('');
|
||||
|
||||
emojiCache[content] = emojiEncoding;
|
||||
|
||||
return emojiEncoding;
|
||||
}
|
||||
|
||||
function interpolateName(loaderContext, name, options) {
|
||||
let filename;
|
||||
|
||||
const hasQuery =
|
||||
loaderContext.resourceQuery && loaderContext.resourceQuery.length > 1;
|
||||
|
||||
if (typeof name === 'function') {
|
||||
filename = name(
|
||||
loaderContext.resourcePath,
|
||||
hasQuery ? loaderContext.resourceQuery : undefined
|
||||
);
|
||||
} else {
|
||||
filename = name || '[hash].[ext]';
|
||||
}
|
||||
|
||||
const context = options.context;
|
||||
const content = options.content;
|
||||
const regExp = options.regExp;
|
||||
|
||||
let ext = 'bin';
|
||||
let basename = 'file';
|
||||
let directory = '';
|
||||
let folder = '';
|
||||
let query = '';
|
||||
|
||||
if (loaderContext.resourcePath) {
|
||||
const parsed = path.parse(loaderContext.resourcePath);
|
||||
let resourcePath = loaderContext.resourcePath;
|
||||
|
||||
if (parsed.ext) {
|
||||
ext = parsed.ext.substr(1);
|
||||
}
|
||||
|
||||
if (parsed.dir) {
|
||||
basename = parsed.name;
|
||||
resourcePath = parsed.dir + path.sep;
|
||||
}
|
||||
|
||||
if (typeof context !== 'undefined') {
|
||||
directory = path
|
||||
.relative(context, resourcePath + '_')
|
||||
.replace(/\\/g, '/')
|
||||
.replace(/\.\.(\/)?/g, '_$1');
|
||||
directory = directory.substr(0, directory.length - 1);
|
||||
} else {
|
||||
directory = resourcePath.replace(/\\/g, '/').replace(/\.\.(\/)?/g, '_$1');
|
||||
}
|
||||
|
||||
if (directory.length === 1) {
|
||||
directory = '';
|
||||
} else if (directory.length > 1) {
|
||||
folder = path.basename(directory);
|
||||
}
|
||||
}
|
||||
|
||||
if (loaderContext.resourceQuery && loaderContext.resourceQuery.length > 1) {
|
||||
query = loaderContext.resourceQuery;
|
||||
|
||||
const hashIdx = query.indexOf('#');
|
||||
|
||||
if (hashIdx >= 0) {
|
||||
query = query.substr(0, hashIdx);
|
||||
}
|
||||
}
|
||||
|
||||
let url = filename;
|
||||
|
||||
if (content) {
|
||||
// Match hash template
|
||||
url = url
|
||||
// `hash` and `contenthash` are same in `loader-utils` context
|
||||
// let's keep `hash` for backward compatibility
|
||||
.replace(
|
||||
/\[(?:([^[:\]]+):)?(?:hash|contenthash)(?::([a-z]+\d*))?(?::(\d+))?\]/gi,
|
||||
(all, hashType, digestType, maxLength) =>
|
||||
getHashDigest(content, hashType, digestType, parseInt(maxLength, 10))
|
||||
)
|
||||
.replace(/\[emoji(?::(\d+))?\]/gi, (all, length) =>
|
||||
encodeStringToEmoji(content, parseInt(length, 10))
|
||||
);
|
||||
}
|
||||
|
||||
url = url
|
||||
.replace(/\[ext\]/gi, () => ext)
|
||||
.replace(/\[name\]/gi, () => basename)
|
||||
.replace(/\[path\]/gi, () => directory)
|
||||
.replace(/\[folder\]/gi, () => folder)
|
||||
.replace(/\[query\]/gi, () => query);
|
||||
|
||||
if (regExp && loaderContext.resourcePath) {
|
||||
const match = loaderContext.resourcePath.match(new RegExp(regExp));
|
||||
|
||||
match &&
|
||||
match.forEach((matched, i) => {
|
||||
url = url.replace(new RegExp('\\[' + i + '\\]', 'ig'), matched);
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
typeof loaderContext.options === 'object' &&
|
||||
typeof loaderContext.options.customInterpolateName === 'function'
|
||||
) {
|
||||
url = loaderContext.options.customInterpolateName.call(
|
||||
loaderContext,
|
||||
url,
|
||||
name,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
module.exports = interpolateName;
|
||||
31
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/isUrlRequest.js
generated
vendored
Executable file
31
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/isUrlRequest.js
generated
vendored
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
|
||||
function isUrlRequest(url, root) {
|
||||
// An URL is not an request if
|
||||
|
||||
// 1. It's an absolute url and it is not `windows` path like `C:\dir\file`
|
||||
if (/^[a-z][a-z0-9+.-]*:/i.test(url) && !path.win32.isAbsolute(url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 2. It's a protocol-relative
|
||||
if (/^\/\//.test(url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 3. It's some kind of url for a template
|
||||
if (/^[{}[\]#*;,'§$%&(=?`´^°<>]/.test(url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 4. It's also not an request if root isn't set and it's a root-relative url
|
||||
if ((root === undefined || root === false) && /^\//.test(url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = isUrlRequest;
|
||||
69
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/parseQuery.js
generated
vendored
Executable file
69
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/parseQuery.js
generated
vendored
Executable file
|
|
@ -0,0 +1,69 @@
|
|||
'use strict';
|
||||
|
||||
const JSON5 = require('json5');
|
||||
|
||||
const specialValues = {
|
||||
null: null,
|
||||
true: true,
|
||||
false: false,
|
||||
};
|
||||
|
||||
function parseQuery(query) {
|
||||
if (query.substr(0, 1) !== '?') {
|
||||
throw new Error(
|
||||
"A valid query string passed to parseQuery should begin with '?'"
|
||||
);
|
||||
}
|
||||
|
||||
query = query.substr(1);
|
||||
|
||||
if (!query) {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (query.substr(0, 1) === '{' && query.substr(-1) === '}') {
|
||||
return JSON5.parse(query);
|
||||
}
|
||||
|
||||
const queryArgs = query.split(/[,&]/g);
|
||||
const result = Object.create(null);
|
||||
|
||||
queryArgs.forEach((arg) => {
|
||||
const idx = arg.indexOf('=');
|
||||
|
||||
if (idx >= 0) {
|
||||
let name = arg.substr(0, idx);
|
||||
let value = decodeURIComponent(arg.substr(idx + 1));
|
||||
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
if (specialValues.hasOwnProperty(value)) {
|
||||
value = specialValues[value];
|
||||
}
|
||||
|
||||
if (name.substr(-2) === '[]') {
|
||||
name = decodeURIComponent(name.substr(0, name.length - 2));
|
||||
|
||||
if (!Array.isArray(result[name])) {
|
||||
result[name] = [];
|
||||
}
|
||||
|
||||
result[name].push(value);
|
||||
} else {
|
||||
name = decodeURIComponent(name);
|
||||
result[name] = value;
|
||||
}
|
||||
} else {
|
||||
if (arg.substr(0, 1) === '-') {
|
||||
result[decodeURIComponent(arg.substr(1))] = false;
|
||||
} else if (arg.substr(0, 1) === '+') {
|
||||
result[decodeURIComponent(arg.substr(1))] = true;
|
||||
} else {
|
||||
result[decodeURIComponent(arg)] = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = parseQuery;
|
||||
23
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/parseString.js
generated
vendored
Executable file
23
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/parseString.js
generated
vendored
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
'use strict';
|
||||
|
||||
function parseString(str) {
|
||||
try {
|
||||
if (str[0] === '"') {
|
||||
return JSON.parse(str);
|
||||
}
|
||||
|
||||
if (str[0] === "'" && str.substr(str.length - 1) === "'") {
|
||||
return parseString(
|
||||
str
|
||||
.replace(/\\.|"/g, (x) => (x === '"' ? '\\"' : x))
|
||||
.replace(/^'|'$/g, '"')
|
||||
);
|
||||
}
|
||||
|
||||
return JSON.parse('"' + str + '"');
|
||||
} catch (e) {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = parseString;
|
||||
51
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/stringifyRequest.js
generated
vendored
Executable file
51
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/stringifyRequest.js
generated
vendored
Executable file
|
|
@ -0,0 +1,51 @@
|
|||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const matchRelativePath = /^\.\.?[/\\]/;
|
||||
|
||||
function isAbsolutePath(str) {
|
||||
return path.posix.isAbsolute(str) || path.win32.isAbsolute(str);
|
||||
}
|
||||
|
||||
function isRelativePath(str) {
|
||||
return matchRelativePath.test(str);
|
||||
}
|
||||
|
||||
function stringifyRequest(loaderContext, request) {
|
||||
const splitted = request.split('!');
|
||||
const context =
|
||||
loaderContext.context ||
|
||||
(loaderContext.options && loaderContext.options.context);
|
||||
|
||||
return JSON.stringify(
|
||||
splitted
|
||||
.map((part) => {
|
||||
// First, separate singlePath from query, because the query might contain paths again
|
||||
const splittedPart = part.match(/^(.*?)(\?.*)/);
|
||||
const query = splittedPart ? splittedPart[2] : '';
|
||||
let singlePath = splittedPart ? splittedPart[1] : part;
|
||||
|
||||
if (isAbsolutePath(singlePath) && context) {
|
||||
singlePath = path.relative(context, singlePath);
|
||||
|
||||
if (isAbsolutePath(singlePath)) {
|
||||
// If singlePath still matches an absolute path, singlePath was on a different drive than context.
|
||||
// In this case, we leave the path platform-specific without replacing any separators.
|
||||
// @see https://github.com/webpack/loader-utils/pull/14
|
||||
return singlePath + query;
|
||||
}
|
||||
|
||||
if (isRelativePath(singlePath) === false) {
|
||||
// Ensure that the relative path starts at least with ./ otherwise it would be a request into the modules directory (like node_modules).
|
||||
singlePath = './' + singlePath;
|
||||
}
|
||||
}
|
||||
|
||||
return singlePath.replace(/\\/g, '/') + query;
|
||||
})
|
||||
.join('!')
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = stringifyRequest;
|
||||
60
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/urlToRequest.js
generated
vendored
Executable file
60
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/lib/urlToRequest.js
generated
vendored
Executable file
|
|
@ -0,0 +1,60 @@
|
|||
'use strict';
|
||||
|
||||
// we can't use path.win32.isAbsolute because it also matches paths starting with a forward slash
|
||||
const matchNativeWin32Path = /^[A-Z]:[/\\]|^\\\\/i;
|
||||
|
||||
function urlToRequest(url, root) {
|
||||
// Do not rewrite an empty url
|
||||
if (url === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
const moduleRequestRegex = /^[^?]*~/;
|
||||
let request;
|
||||
|
||||
if (matchNativeWin32Path.test(url)) {
|
||||
// absolute windows path, keep it
|
||||
request = url;
|
||||
} else if (root !== undefined && root !== false && /^\//.test(url)) {
|
||||
// if root is set and the url is root-relative
|
||||
switch (typeof root) {
|
||||
// 1. root is a string: root is prefixed to the url
|
||||
case 'string':
|
||||
// special case: `~` roots convert to module request
|
||||
if (moduleRequestRegex.test(root)) {
|
||||
request = root.replace(/([^~/])$/, '$1/') + url.slice(1);
|
||||
} else {
|
||||
request = root + url;
|
||||
}
|
||||
break;
|
||||
// 2. root is `true`: absolute paths are allowed
|
||||
// *nix only, windows-style absolute paths are always allowed as they doesn't start with a `/`
|
||||
case 'boolean':
|
||||
request = url;
|
||||
break;
|
||||
default:
|
||||
throw new Error(
|
||||
"Unexpected parameters to loader-utils 'urlToRequest': url = " +
|
||||
url +
|
||||
', root = ' +
|
||||
root +
|
||||
'.'
|
||||
);
|
||||
}
|
||||
} else if (/^\.\.?\//.test(url)) {
|
||||
// A relative url stays
|
||||
request = url;
|
||||
} else {
|
||||
// every other url is threaded like a relative url
|
||||
request = './' + url;
|
||||
}
|
||||
|
||||
// A `~` makes the url an module
|
||||
if (moduleRequestRegex.test(request)) {
|
||||
request = request.replace(moduleRequestRegex, '');
|
||||
}
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
module.exports = urlToRequest;
|
||||
39
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/package.json
generated
vendored
Executable file
39
my-app/node_modules/resolve-url-loader/node_modules/loader-utils/package.json
generated
vendored
Executable file
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"name": "loader-utils",
|
||||
"version": "2.0.4",
|
||||
"author": "Tobias Koppers @sokra",
|
||||
"description": "utils for webpack loaders",
|
||||
"dependencies": {
|
||||
"big.js": "^5.2.2",
|
||||
"emojis-list": "^3.0.0",
|
||||
"json5": "^2.1.2"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint lib test",
|
||||
"pretest": "yarn lint",
|
||||
"test": "jest",
|
||||
"test:ci": "jest --coverage",
|
||||
"release": "yarn test && standard-version"
|
||||
},
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/webpack/loader-utils.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.9.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"coveralls": "^3.0.9",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-plugin-node": "^11.0.0",
|
||||
"eslint-plugin-prettier": "^3.1.2",
|
||||
"jest": "^25.1.0",
|
||||
"prettier": "^1.19.1",
|
||||
"standard-version": "^7.1.0"
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"files": [
|
||||
"lib"
|
||||
]
|
||||
}
|
||||
301
my-app/node_modules/resolve-url-loader/node_modules/source-map/CHANGELOG.md
generated
vendored
Executable file
301
my-app/node_modules/resolve-url-loader/node_modules/source-map/CHANGELOG.md
generated
vendored
Executable file
|
|
@ -0,0 +1,301 @@
|
|||
# Change Log
|
||||
|
||||
## 0.5.6
|
||||
|
||||
* Fix for regression when people were using numbers as names in source maps. See
|
||||
#236.
|
||||
|
||||
## 0.5.5
|
||||
|
||||
* Fix "regression" of unsupported, implementation behavior that half the world
|
||||
happens to have come to depend on. See #235.
|
||||
|
||||
* Fix regression involving function hoisting in SpiderMonkey. See #233.
|
||||
|
||||
## 0.5.4
|
||||
|
||||
* Large performance improvements to source-map serialization. See #228 and #229.
|
||||
|
||||
## 0.5.3
|
||||
|
||||
* Do not include unnecessary distribution files. See
|
||||
commit ef7006f8d1647e0a83fdc60f04f5a7ca54886f86.
|
||||
|
||||
## 0.5.2
|
||||
|
||||
* Include browser distributions of the library in package.json's `files`. See
|
||||
issue #212.
|
||||
|
||||
## 0.5.1
|
||||
|
||||
* Fix latent bugs in IndexedSourceMapConsumer.prototype._parseMappings. See
|
||||
ff05274becc9e6e1295ed60f3ea090d31d843379.
|
||||
|
||||
## 0.5.0
|
||||
|
||||
* Node 0.8 is no longer supported.
|
||||
|
||||
* Use webpack instead of dryice for bundling.
|
||||
|
||||
* Big speedups serializing source maps. See pull request #203.
|
||||
|
||||
* Fix a bug with `SourceMapConsumer.prototype.sourceContentFor` and sources that
|
||||
explicitly start with the source root. See issue #199.
|
||||
|
||||
## 0.4.4
|
||||
|
||||
* Fix an issue where using a `SourceMapGenerator` after having created a
|
||||
`SourceMapConsumer` from it via `SourceMapConsumer.fromSourceMap` failed. See
|
||||
issue #191.
|
||||
|
||||
* Fix an issue with where `SourceMapGenerator` would mistakenly consider
|
||||
different mappings as duplicates of each other and avoid generating them. See
|
||||
issue #192.
|
||||
|
||||
## 0.4.3
|
||||
|
||||
* A very large number of performance improvements, particularly when parsing
|
||||
source maps. Collectively about 75% of time shaved off of the source map
|
||||
parsing benchmark!
|
||||
|
||||
* Fix a bug in `SourceMapConsumer.prototype.allGeneratedPositionsFor` and fuzzy
|
||||
searching in the presence of a column option. See issue #177.
|
||||
|
||||
* Fix a bug with joining a source and its source root when the source is above
|
||||
the root. See issue #182.
|
||||
|
||||
* Add the `SourceMapConsumer.prototype.hasContentsOfAllSources` method to
|
||||
determine when all sources' contents are inlined into the source map. See
|
||||
issue #190.
|
||||
|
||||
## 0.4.2
|
||||
|
||||
* Add an `.npmignore` file so that the benchmarks aren't pulled down by
|
||||
dependent projects. Issue #169.
|
||||
|
||||
* Add an optional `column` argument to
|
||||
`SourceMapConsumer.prototype.allGeneratedPositionsFor` and better handle lines
|
||||
with no mappings. Issues #172 and #173.
|
||||
|
||||
## 0.4.1
|
||||
|
||||
* Fix accidentally defining a global variable. #170.
|
||||
|
||||
## 0.4.0
|
||||
|
||||
* The default direction for fuzzy searching was changed back to its original
|
||||
direction. See #164.
|
||||
|
||||
* There is now a `bias` option you can supply to `SourceMapConsumer` to control
|
||||
the fuzzy searching direction. See #167.
|
||||
|
||||
* About an 8% speed up in parsing source maps. See #159.
|
||||
|
||||
* Added a benchmark for parsing and generating source maps.
|
||||
|
||||
## 0.3.0
|
||||
|
||||
* Change the default direction that searching for positions fuzzes when there is
|
||||
not an exact match. See #154.
|
||||
|
||||
* Support for environments using json2.js for JSON serialization. See #156.
|
||||
|
||||
## 0.2.0
|
||||
|
||||
* Support for consuming "indexed" source maps which do not have any remote
|
||||
sections. See pull request #127. This introduces a minor backwards
|
||||
incompatibility if you are monkey patching `SourceMapConsumer.prototype`
|
||||
methods.
|
||||
|
||||
## 0.1.43
|
||||
|
||||
* Performance improvements for `SourceMapGenerator` and `SourceNode`. See issue
|
||||
#148 for some discussion and issues #150, #151, and #152 for implementations.
|
||||
|
||||
## 0.1.42
|
||||
|
||||
* Fix an issue where `SourceNode`s from different versions of the source-map
|
||||
library couldn't be used in conjunction with each other. See issue #142.
|
||||
|
||||
## 0.1.41
|
||||
|
||||
* Fix a bug with getting the source content of relative sources with a "./"
|
||||
prefix. See issue #145 and [Bug 1090768](bugzil.la/1090768).
|
||||
|
||||
* Add the `SourceMapConsumer.prototype.computeColumnSpans` method to compute the
|
||||
column span of each mapping.
|
||||
|
||||
* Add the `SourceMapConsumer.prototype.allGeneratedPositionsFor` method to find
|
||||
all generated positions associated with a given original source and line.
|
||||
|
||||
## 0.1.40
|
||||
|
||||
* Performance improvements for parsing source maps in SourceMapConsumer.
|
||||
|
||||
## 0.1.39
|
||||
|
||||
* Fix a bug where setting a source's contents to null before any source content
|
||||
had been set before threw a TypeError. See issue #131.
|
||||
|
||||
## 0.1.38
|
||||
|
||||
* Fix a bug where finding relative paths from an empty path were creating
|
||||
absolute paths. See issue #129.
|
||||
|
||||
## 0.1.37
|
||||
|
||||
* Fix a bug where if the source root was an empty string, relative source paths
|
||||
would turn into absolute source paths. Issue #124.
|
||||
|
||||
## 0.1.36
|
||||
|
||||
* Allow the `names` mapping property to be an empty string. Issue #121.
|
||||
|
||||
## 0.1.35
|
||||
|
||||
* A third optional parameter was added to `SourceNode.fromStringWithSourceMap`
|
||||
to specify a path that relative sources in the second parameter should be
|
||||
relative to. Issue #105.
|
||||
|
||||
* If no file property is given to a `SourceMapGenerator`, then the resulting
|
||||
source map will no longer have a `null` file property. The property will
|
||||
simply not exist. Issue #104.
|
||||
|
||||
* Fixed a bug where consecutive newlines were ignored in `SourceNode`s.
|
||||
Issue #116.
|
||||
|
||||
## 0.1.34
|
||||
|
||||
* Make `SourceNode` work with windows style ("\r\n") newlines. Issue #103.
|
||||
|
||||
* Fix bug involving source contents and the
|
||||
`SourceMapGenerator.prototype.applySourceMap`. Issue #100.
|
||||
|
||||
## 0.1.33
|
||||
|
||||
* Fix some edge cases surrounding path joining and URL resolution.
|
||||
|
||||
* Add a third parameter for relative path to
|
||||
`SourceMapGenerator.prototype.applySourceMap`.
|
||||
|
||||
* Fix issues with mappings and EOLs.
|
||||
|
||||
## 0.1.32
|
||||
|
||||
* Fixed a bug where SourceMapConsumer couldn't handle negative relative columns
|
||||
(issue 92).
|
||||
|
||||
* Fixed test runner to actually report number of failed tests as its process
|
||||
exit code.
|
||||
|
||||
* Fixed a typo when reporting bad mappings (issue 87).
|
||||
|
||||
## 0.1.31
|
||||
|
||||
* Delay parsing the mappings in SourceMapConsumer until queried for a source
|
||||
location.
|
||||
|
||||
* Support Sass source maps (which at the time of writing deviate from the spec
|
||||
in small ways) in SourceMapConsumer.
|
||||
|
||||
## 0.1.30
|
||||
|
||||
* Do not join source root with a source, when the source is a data URI.
|
||||
|
||||
* Extend the test runner to allow running single specific test files at a time.
|
||||
|
||||
* Performance improvements in `SourceNode.prototype.walk` and
|
||||
`SourceMapConsumer.prototype.eachMapping`.
|
||||
|
||||
* Source map browser builds will now work inside Workers.
|
||||
|
||||
* Better error messages when attempting to add an invalid mapping to a
|
||||
`SourceMapGenerator`.
|
||||
|
||||
## 0.1.29
|
||||
|
||||
* Allow duplicate entries in the `names` and `sources` arrays of source maps
|
||||
(usually from TypeScript) we are parsing. Fixes github issue 72.
|
||||
|
||||
## 0.1.28
|
||||
|
||||
* Skip duplicate mappings when creating source maps from SourceNode; github
|
||||
issue 75.
|
||||
|
||||
## 0.1.27
|
||||
|
||||
* Don't throw an error when the `file` property is missing in SourceMapConsumer,
|
||||
we don't use it anyway.
|
||||
|
||||
## 0.1.26
|
||||
|
||||
* Fix SourceNode.fromStringWithSourceMap for empty maps. Fixes github issue 70.
|
||||
|
||||
## 0.1.25
|
||||
|
||||
* Make compatible with browserify
|
||||
|
||||
## 0.1.24
|
||||
|
||||
* Fix issue with absolute paths and `file://` URIs. See
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=885597
|
||||
|
||||
## 0.1.23
|
||||
|
||||
* Fix issue with absolute paths and sourcesContent, github issue 64.
|
||||
|
||||
## 0.1.22
|
||||
|
||||
* Ignore duplicate mappings in SourceMapGenerator. Fixes github issue 21.
|
||||
|
||||
## 0.1.21
|
||||
|
||||
* Fixed handling of sources that start with a slash so that they are relative to
|
||||
the source root's host.
|
||||
|
||||
## 0.1.20
|
||||
|
||||
* Fixed github issue #43: absolute URLs aren't joined with the source root
|
||||
anymore.
|
||||
|
||||
## 0.1.19
|
||||
|
||||
* Using Travis CI to run tests.
|
||||
|
||||
## 0.1.18
|
||||
|
||||
* Fixed a bug in the handling of sourceRoot.
|
||||
|
||||
## 0.1.17
|
||||
|
||||
* Added SourceNode.fromStringWithSourceMap.
|
||||
|
||||
## 0.1.16
|
||||
|
||||
* Added missing documentation.
|
||||
|
||||
* Fixed the generating of empty mappings in SourceNode.
|
||||
|
||||
## 0.1.15
|
||||
|
||||
* Added SourceMapGenerator.applySourceMap.
|
||||
|
||||
## 0.1.14
|
||||
|
||||
* The sourceRoot is now handled consistently.
|
||||
|
||||
## 0.1.13
|
||||
|
||||
* Added SourceMapGenerator.fromSourceMap.
|
||||
|
||||
## 0.1.12
|
||||
|
||||
* SourceNode now generates empty mappings too.
|
||||
|
||||
## 0.1.11
|
||||
|
||||
* Added name support to SourceNode.
|
||||
|
||||
## 0.1.10
|
||||
|
||||
* Added sourcesContent support to the customer and generator.
|
||||
28
my-app/node_modules/resolve-url-loader/node_modules/source-map/LICENSE
generated
vendored
Executable file
28
my-app/node_modules/resolve-url-loader/node_modules/source-map/LICENSE
generated
vendored
Executable file
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
Copyright (c) 2009-2011, Mozilla Foundation and contributors
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the names of the Mozilla Foundation nor the names of project
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
742
my-app/node_modules/resolve-url-loader/node_modules/source-map/README.md
generated
vendored
Executable file
742
my-app/node_modules/resolve-url-loader/node_modules/source-map/README.md
generated
vendored
Executable file
|
|
@ -0,0 +1,742 @@
|
|||
# Source Map
|
||||
|
||||
[](https://travis-ci.org/mozilla/source-map)
|
||||
|
||||
[](https://www.npmjs.com/package/source-map)
|
||||
|
||||
This is a library to generate and consume the source map format
|
||||
[described here][format].
|
||||
|
||||
[format]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit
|
||||
|
||||
## Use with Node
|
||||
|
||||
$ npm install source-map
|
||||
|
||||
## Use on the Web
|
||||
|
||||
<script src="https://raw.githubusercontent.com/mozilla/source-map/master/dist/source-map.min.js" defer></script>
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
<!-- `npm run toc` to regenerate the Table of Contents -->
|
||||
|
||||
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||
## Table of Contents
|
||||
|
||||
- [Examples](#examples)
|
||||
- [Consuming a source map](#consuming-a-source-map)
|
||||
- [Generating a source map](#generating-a-source-map)
|
||||
- [With SourceNode (high level API)](#with-sourcenode-high-level-api)
|
||||
- [With SourceMapGenerator (low level API)](#with-sourcemapgenerator-low-level-api)
|
||||
- [API](#api)
|
||||
- [SourceMapConsumer](#sourcemapconsumer)
|
||||
- [new SourceMapConsumer(rawSourceMap)](#new-sourcemapconsumerrawsourcemap)
|
||||
- [SourceMapConsumer.prototype.computeColumnSpans()](#sourcemapconsumerprototypecomputecolumnspans)
|
||||
- [SourceMapConsumer.prototype.originalPositionFor(generatedPosition)](#sourcemapconsumerprototypeoriginalpositionforgeneratedposition)
|
||||
- [SourceMapConsumer.prototype.generatedPositionFor(originalPosition)](#sourcemapconsumerprototypegeneratedpositionfororiginalposition)
|
||||
- [SourceMapConsumer.prototype.allGeneratedPositionsFor(originalPosition)](#sourcemapconsumerprototypeallgeneratedpositionsfororiginalposition)
|
||||
- [SourceMapConsumer.prototype.hasContentsOfAllSources()](#sourcemapconsumerprototypehascontentsofallsources)
|
||||
- [SourceMapConsumer.prototype.sourceContentFor(source[, returnNullOnMissing])](#sourcemapconsumerprototypesourcecontentforsource-returnnullonmissing)
|
||||
- [SourceMapConsumer.prototype.eachMapping(callback, context, order)](#sourcemapconsumerprototypeeachmappingcallback-context-order)
|
||||
- [SourceMapGenerator](#sourcemapgenerator)
|
||||
- [new SourceMapGenerator([startOfSourceMap])](#new-sourcemapgeneratorstartofsourcemap)
|
||||
- [SourceMapGenerator.fromSourceMap(sourceMapConsumer)](#sourcemapgeneratorfromsourcemapsourcemapconsumer)
|
||||
- [SourceMapGenerator.prototype.addMapping(mapping)](#sourcemapgeneratorprototypeaddmappingmapping)
|
||||
- [SourceMapGenerator.prototype.setSourceContent(sourceFile, sourceContent)](#sourcemapgeneratorprototypesetsourcecontentsourcefile-sourcecontent)
|
||||
- [SourceMapGenerator.prototype.applySourceMap(sourceMapConsumer[, sourceFile[, sourceMapPath]])](#sourcemapgeneratorprototypeapplysourcemapsourcemapconsumer-sourcefile-sourcemappath)
|
||||
- [SourceMapGenerator.prototype.toString()](#sourcemapgeneratorprototypetostring)
|
||||
- [SourceNode](#sourcenode)
|
||||
- [new SourceNode([line, column, source[, chunk[, name]]])](#new-sourcenodeline-column-source-chunk-name)
|
||||
- [SourceNode.fromStringWithSourceMap(code, sourceMapConsumer[, relativePath])](#sourcenodefromstringwithsourcemapcode-sourcemapconsumer-relativepath)
|
||||
- [SourceNode.prototype.add(chunk)](#sourcenodeprototypeaddchunk)
|
||||
- [SourceNode.prototype.prepend(chunk)](#sourcenodeprototypeprependchunk)
|
||||
- [SourceNode.prototype.setSourceContent(sourceFile, sourceContent)](#sourcenodeprototypesetsourcecontentsourcefile-sourcecontent)
|
||||
- [SourceNode.prototype.walk(fn)](#sourcenodeprototypewalkfn)
|
||||
- [SourceNode.prototype.walkSourceContents(fn)](#sourcenodeprototypewalksourcecontentsfn)
|
||||
- [SourceNode.prototype.join(sep)](#sourcenodeprototypejoinsep)
|
||||
- [SourceNode.prototype.replaceRight(pattern, replacement)](#sourcenodeprototypereplacerightpattern-replacement)
|
||||
- [SourceNode.prototype.toString()](#sourcenodeprototypetostring)
|
||||
- [SourceNode.prototype.toStringWithSourceMap([startOfSourceMap])](#sourcenodeprototypetostringwithsourcemapstartofsourcemap)
|
||||
|
||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||
|
||||
## Examples
|
||||
|
||||
### Consuming a source map
|
||||
|
||||
```js
|
||||
var rawSourceMap = {
|
||||
version: 3,
|
||||
file: 'min.js',
|
||||
names: ['bar', 'baz', 'n'],
|
||||
sources: ['one.js', 'two.js'],
|
||||
sourceRoot: 'http://example.com/www/js/',
|
||||
mappings: 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA'
|
||||
};
|
||||
|
||||
var smc = new SourceMapConsumer(rawSourceMap);
|
||||
|
||||
console.log(smc.sources);
|
||||
// [ 'http://example.com/www/js/one.js',
|
||||
// 'http://example.com/www/js/two.js' ]
|
||||
|
||||
console.log(smc.originalPositionFor({
|
||||
line: 2,
|
||||
column: 28
|
||||
}));
|
||||
// { source: 'http://example.com/www/js/two.js',
|
||||
// line: 2,
|
||||
// column: 10,
|
||||
// name: 'n' }
|
||||
|
||||
console.log(smc.generatedPositionFor({
|
||||
source: 'http://example.com/www/js/two.js',
|
||||
line: 2,
|
||||
column: 10
|
||||
}));
|
||||
// { line: 2, column: 28 }
|
||||
|
||||
smc.eachMapping(function (m) {
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
### Generating a source map
|
||||
|
||||
In depth guide:
|
||||
[**Compiling to JavaScript, and Debugging with Source Maps**](https://hacks.mozilla.org/2013/05/compiling-to-javascript-and-debugging-with-source-maps/)
|
||||
|
||||
#### With SourceNode (high level API)
|
||||
|
||||
```js
|
||||
function compile(ast) {
|
||||
switch (ast.type) {
|
||||
case 'BinaryExpression':
|
||||
return new SourceNode(
|
||||
ast.location.line,
|
||||
ast.location.column,
|
||||
ast.location.source,
|
||||
[compile(ast.left), " + ", compile(ast.right)]
|
||||
);
|
||||
case 'Literal':
|
||||
return new SourceNode(
|
||||
ast.location.line,
|
||||
ast.location.column,
|
||||
ast.location.source,
|
||||
String(ast.value)
|
||||
);
|
||||
// ...
|
||||
default:
|
||||
throw new Error("Bad AST");
|
||||
}
|
||||
}
|
||||
|
||||
var ast = parse("40 + 2", "add.js");
|
||||
console.log(compile(ast).toStringWithSourceMap({
|
||||
file: 'add.js'
|
||||
}));
|
||||
// { code: '40 + 2',
|
||||
// map: [object SourceMapGenerator] }
|
||||
```
|
||||
|
||||
#### With SourceMapGenerator (low level API)
|
||||
|
||||
```js
|
||||
var map = new SourceMapGenerator({
|
||||
file: "source-mapped.js"
|
||||
});
|
||||
|
||||
map.addMapping({
|
||||
generated: {
|
||||
line: 10,
|
||||
column: 35
|
||||
},
|
||||
source: "foo.js",
|
||||
original: {
|
||||
line: 33,
|
||||
column: 2
|
||||
},
|
||||
name: "christopher"
|
||||
});
|
||||
|
||||
console.log(map.toString());
|
||||
// '{"version":3,"file":"source-mapped.js","sources":["foo.js"],"names":["christopher"],"mappings":";;;;;;;;;mCAgCEA"}'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
Get a reference to the module:
|
||||
|
||||
```js
|
||||
// Node.js
|
||||
var sourceMap = require('source-map');
|
||||
|
||||
// Browser builds
|
||||
var sourceMap = window.sourceMap;
|
||||
|
||||
// Inside Firefox
|
||||
const sourceMap = require("devtools/toolkit/sourcemap/source-map.js");
|
||||
```
|
||||
|
||||
### SourceMapConsumer
|
||||
|
||||
A SourceMapConsumer instance represents a parsed source map which we can query
|
||||
for information about the original file positions by giving it a file position
|
||||
in the generated source.
|
||||
|
||||
#### new SourceMapConsumer(rawSourceMap)
|
||||
|
||||
The only parameter is the raw source map (either as a string which can be
|
||||
`JSON.parse`'d, or an object). According to the spec, source maps have the
|
||||
following attributes:
|
||||
|
||||
* `version`: Which version of the source map spec this map is following.
|
||||
|
||||
* `sources`: An array of URLs to the original source files.
|
||||
|
||||
* `names`: An array of identifiers which can be referenced by individual
|
||||
mappings.
|
||||
|
||||
* `sourceRoot`: Optional. The URL root from which all sources are relative.
|
||||
|
||||
* `sourcesContent`: Optional. An array of contents of the original source files.
|
||||
|
||||
* `mappings`: A string of base64 VLQs which contain the actual mappings.
|
||||
|
||||
* `file`: Optional. The generated filename this source map is associated with.
|
||||
|
||||
```js
|
||||
var consumer = new sourceMap.SourceMapConsumer(rawSourceMapJsonData);
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.computeColumnSpans()
|
||||
|
||||
Compute the last column for each generated mapping. The last column is
|
||||
inclusive.
|
||||
|
||||
```js
|
||||
// Before:
|
||||
consumer.allGeneratedPositionsFor({ line: 2, source: "foo.coffee" })
|
||||
// [ { line: 2,
|
||||
// column: 1 },
|
||||
// { line: 2,
|
||||
// column: 10 },
|
||||
// { line: 2,
|
||||
// column: 20 } ]
|
||||
|
||||
consumer.computeColumnSpans();
|
||||
|
||||
// After:
|
||||
consumer.allGeneratedPositionsFor({ line: 2, source: "foo.coffee" })
|
||||
// [ { line: 2,
|
||||
// column: 1,
|
||||
// lastColumn: 9 },
|
||||
// { line: 2,
|
||||
// column: 10,
|
||||
// lastColumn: 19 },
|
||||
// { line: 2,
|
||||
// column: 20,
|
||||
// lastColumn: Infinity } ]
|
||||
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.originalPositionFor(generatedPosition)
|
||||
|
||||
Returns the original source, line, and column information for the generated
|
||||
source's line and column positions provided. The only argument is an object with
|
||||
the following properties:
|
||||
|
||||
* `line`: The line number in the generated source. Line numbers in
|
||||
this library are 1-based (note that the underlying source map
|
||||
specification uses 0-based line numbers -- this library handles the
|
||||
translation).
|
||||
|
||||
* `column`: The column number in the generated source. Column numbers
|
||||
in this library are 0-based.
|
||||
|
||||
* `bias`: Either `SourceMapConsumer.GREATEST_LOWER_BOUND` or
|
||||
`SourceMapConsumer.LEAST_UPPER_BOUND`. Specifies whether to return the closest
|
||||
element that is smaller than or greater than the one we are searching for,
|
||||
respectively, if the exact element cannot be found. Defaults to
|
||||
`SourceMapConsumer.GREATEST_LOWER_BOUND`.
|
||||
|
||||
and an object is returned with the following properties:
|
||||
|
||||
* `source`: The original source file, or null if this information is not
|
||||
available.
|
||||
|
||||
* `line`: The line number in the original source, or null if this information is
|
||||
not available. The line number is 1-based.
|
||||
|
||||
* `column`: The column number in the original source, or null if this
|
||||
information is not available. The column number is 0-based.
|
||||
|
||||
* `name`: The original identifier, or null if this information is not available.
|
||||
|
||||
```js
|
||||
consumer.originalPositionFor({ line: 2, column: 10 })
|
||||
// { source: 'foo.coffee',
|
||||
// line: 2,
|
||||
// column: 2,
|
||||
// name: null }
|
||||
|
||||
consumer.originalPositionFor({ line: 99999999999999999, column: 999999999999999 })
|
||||
// { source: null,
|
||||
// line: null,
|
||||
// column: null,
|
||||
// name: null }
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.generatedPositionFor(originalPosition)
|
||||
|
||||
Returns the generated line and column information for the original source,
|
||||
line, and column positions provided. The only argument is an object with
|
||||
the following properties:
|
||||
|
||||
* `source`: The filename of the original source.
|
||||
|
||||
* `line`: The line number in the original source. The line number is
|
||||
1-based.
|
||||
|
||||
* `column`: The column number in the original source. The column
|
||||
number is 0-based.
|
||||
|
||||
and an object is returned with the following properties:
|
||||
|
||||
* `line`: The line number in the generated source, or null. The line
|
||||
number is 1-based.
|
||||
|
||||
* `column`: The column number in the generated source, or null. The
|
||||
column number is 0-based.
|
||||
|
||||
```js
|
||||
consumer.generatedPositionFor({ source: "example.js", line: 2, column: 10 })
|
||||
// { line: 1,
|
||||
// column: 56 }
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.allGeneratedPositionsFor(originalPosition)
|
||||
|
||||
Returns all generated line and column information for the original source, line,
|
||||
and column provided. If no column is provided, returns all mappings
|
||||
corresponding to a either the line we are searching for or the next closest line
|
||||
that has any mappings. Otherwise, returns all mappings corresponding to the
|
||||
given line and either the column we are searching for or the next closest column
|
||||
that has any offsets.
|
||||
|
||||
The only argument is an object with the following properties:
|
||||
|
||||
* `source`: The filename of the original source.
|
||||
|
||||
* `line`: The line number in the original source. The line number is
|
||||
1-based.
|
||||
|
||||
* `column`: Optional. The column number in the original source. The
|
||||
column number is 0-based.
|
||||
|
||||
and an array of objects is returned, each with the following properties:
|
||||
|
||||
* `line`: The line number in the generated source, or null. The line
|
||||
number is 1-based.
|
||||
|
||||
* `column`: The column number in the generated source, or null. The
|
||||
column number is 0-based.
|
||||
|
||||
```js
|
||||
consumer.allGeneratedpositionsfor({ line: 2, source: "foo.coffee" })
|
||||
// [ { line: 2,
|
||||
// column: 1 },
|
||||
// { line: 2,
|
||||
// column: 10 },
|
||||
// { line: 2,
|
||||
// column: 20 } ]
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.hasContentsOfAllSources()
|
||||
|
||||
Return true if we have the embedded source content for every source listed in
|
||||
the source map, false otherwise.
|
||||
|
||||
In other words, if this method returns `true`, then
|
||||
`consumer.sourceContentFor(s)` will succeed for every source `s` in
|
||||
`consumer.sources`.
|
||||
|
||||
```js
|
||||
// ...
|
||||
if (consumer.hasContentsOfAllSources()) {
|
||||
consumerReadyCallback(consumer);
|
||||
} else {
|
||||
fetchSources(consumer, consumerReadyCallback);
|
||||
}
|
||||
// ...
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.sourceContentFor(source[, returnNullOnMissing])
|
||||
|
||||
Returns the original source content for the source provided. The only
|
||||
argument is the URL of the original source file.
|
||||
|
||||
If the source content for the given source is not found, then an error is
|
||||
thrown. Optionally, pass `true` as the second param to have `null` returned
|
||||
instead.
|
||||
|
||||
```js
|
||||
consumer.sources
|
||||
// [ "my-cool-lib.clj" ]
|
||||
|
||||
consumer.sourceContentFor("my-cool-lib.clj")
|
||||
// "..."
|
||||
|
||||
consumer.sourceContentFor("this is not in the source map");
|
||||
// Error: "this is not in the source map" is not in the source map
|
||||
|
||||
consumer.sourceContentFor("this is not in the source map", true);
|
||||
// null
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.eachMapping(callback, context, order)
|
||||
|
||||
Iterate over each mapping between an original source/line/column and a
|
||||
generated line/column in this source map.
|
||||
|
||||
* `callback`: The function that is called with each mapping. Mappings have the
|
||||
form `{ source, generatedLine, generatedColumn, originalLine, originalColumn,
|
||||
name }`
|
||||
|
||||
* `context`: Optional. If specified, this object will be the value of `this`
|
||||
every time that `callback` is called.
|
||||
|
||||
* `order`: Either `SourceMapConsumer.GENERATED_ORDER` or
|
||||
`SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to iterate over
|
||||
the mappings sorted by the generated file's line/column order or the
|
||||
original's source/line/column order, respectively. Defaults to
|
||||
`SourceMapConsumer.GENERATED_ORDER`.
|
||||
|
||||
```js
|
||||
consumer.eachMapping(function (m) { console.log(m); })
|
||||
// ...
|
||||
// { source: 'illmatic.js',
|
||||
// generatedLine: 1,
|
||||
// generatedColumn: 0,
|
||||
// originalLine: 1,
|
||||
// originalColumn: 0,
|
||||
// name: null }
|
||||
// { source: 'illmatic.js',
|
||||
// generatedLine: 2,
|
||||
// generatedColumn: 0,
|
||||
// originalLine: 2,
|
||||
// originalColumn: 0,
|
||||
// name: null }
|
||||
// ...
|
||||
```
|
||||
### SourceMapGenerator
|
||||
|
||||
An instance of the SourceMapGenerator represents a source map which is being
|
||||
built incrementally.
|
||||
|
||||
#### new SourceMapGenerator([startOfSourceMap])
|
||||
|
||||
You may pass an object with the following properties:
|
||||
|
||||
* `file`: The filename of the generated source that this source map is
|
||||
associated with.
|
||||
|
||||
* `sourceRoot`: A root for all relative URLs in this source map.
|
||||
|
||||
* `skipValidation`: Optional. When `true`, disables validation of mappings as
|
||||
they are added. This can improve performance but should be used with
|
||||
discretion, as a last resort. Even then, one should avoid using this flag when
|
||||
running tests, if possible.
|
||||
|
||||
```js
|
||||
var generator = new sourceMap.SourceMapGenerator({
|
||||
file: "my-generated-javascript-file.js",
|
||||
sourceRoot: "http://example.com/app/js/"
|
||||
});
|
||||
```
|
||||
|
||||
#### SourceMapGenerator.fromSourceMap(sourceMapConsumer)
|
||||
|
||||
Creates a new `SourceMapGenerator` from an existing `SourceMapConsumer` instance.
|
||||
|
||||
* `sourceMapConsumer` The SourceMap.
|
||||
|
||||
```js
|
||||
var generator = sourceMap.SourceMapGenerator.fromSourceMap(consumer);
|
||||
```
|
||||
|
||||
#### SourceMapGenerator.prototype.addMapping(mapping)
|
||||
|
||||
Add a single mapping from original source line and column to the generated
|
||||
source's line and column for this source map being created. The mapping object
|
||||
should have the following properties:
|
||||
|
||||
* `generated`: An object with the generated line and column positions.
|
||||
|
||||
* `original`: An object with the original line and column positions.
|
||||
|
||||
* `source`: The original source file (relative to the sourceRoot).
|
||||
|
||||
* `name`: An optional original token name for this mapping.
|
||||
|
||||
```js
|
||||
generator.addMapping({
|
||||
source: "module-one.scm",
|
||||
original: { line: 128, column: 0 },
|
||||
generated: { line: 3, column: 456 }
|
||||
})
|
||||
```
|
||||
|
||||
#### SourceMapGenerator.prototype.setSourceContent(sourceFile, sourceContent)
|
||||
|
||||
Set the source content for an original source file.
|
||||
|
||||
* `sourceFile` the URL of the original source file.
|
||||
|
||||
* `sourceContent` the content of the source file.
|
||||
|
||||
```js
|
||||
generator.setSourceContent("module-one.scm",
|
||||
fs.readFileSync("path/to/module-one.scm"))
|
||||
```
|
||||
|
||||
#### SourceMapGenerator.prototype.applySourceMap(sourceMapConsumer[, sourceFile[, sourceMapPath]])
|
||||
|
||||
Applies a SourceMap for a source file to the SourceMap.
|
||||
Each mapping to the supplied source file is rewritten using the
|
||||
supplied SourceMap. Note: The resolution for the resulting mappings
|
||||
is the minimum of this map and the supplied map.
|
||||
|
||||
* `sourceMapConsumer`: The SourceMap to be applied.
|
||||
|
||||
* `sourceFile`: Optional. The filename of the source file.
|
||||
If omitted, sourceMapConsumer.file will be used, if it exists.
|
||||
Otherwise an error will be thrown.
|
||||
|
||||
* `sourceMapPath`: Optional. The dirname of the path to the SourceMap
|
||||
to be applied. If relative, it is relative to the SourceMap.
|
||||
|
||||
This parameter is needed when the two SourceMaps aren't in the same
|
||||
directory, and the SourceMap to be applied contains relative source
|
||||
paths. If so, those relative source paths need to be rewritten
|
||||
relative to the SourceMap.
|
||||
|
||||
If omitted, it is assumed that both SourceMaps are in the same directory,
|
||||
thus not needing any rewriting. (Supplying `'.'` has the same effect.)
|
||||
|
||||
#### SourceMapGenerator.prototype.toString()
|
||||
|
||||
Renders the source map being generated to a string.
|
||||
|
||||
```js
|
||||
generator.toString()
|
||||
// '{"version":3,"sources":["module-one.scm"],"names":[],"mappings":"...snip...","file":"my-generated-javascript-file.js","sourceRoot":"http://example.com/app/js/"}'
|
||||
```
|
||||
|
||||
### SourceNode
|
||||
|
||||
SourceNodes provide a way to abstract over interpolating and/or concatenating
|
||||
snippets of generated JavaScript source code, while maintaining the line and
|
||||
column information associated between those snippets and the original source
|
||||
code. This is useful as the final intermediate representation a compiler might
|
||||
use before outputting the generated JS and source map.
|
||||
|
||||
#### new SourceNode([line, column, source[, chunk[, name]]])
|
||||
|
||||
* `line`: The original line number associated with this source node, or null if
|
||||
it isn't associated with an original line. The line number is 1-based.
|
||||
|
||||
* `column`: The original column number associated with this source node, or null
|
||||
if it isn't associated with an original column. The column number
|
||||
is 0-based.
|
||||
|
||||
* `source`: The original source's filename; null if no filename is provided.
|
||||
|
||||
* `chunk`: Optional. Is immediately passed to `SourceNode.prototype.add`, see
|
||||
below.
|
||||
|
||||
* `name`: Optional. The original identifier.
|
||||
|
||||
```js
|
||||
var node = new SourceNode(1, 2, "a.cpp", [
|
||||
new SourceNode(3, 4, "b.cpp", "extern int status;\n"),
|
||||
new SourceNode(5, 6, "c.cpp", "std::string* make_string(size_t n);\n"),
|
||||
new SourceNode(7, 8, "d.cpp", "int main(int argc, char** argv) {}\n"),
|
||||
]);
|
||||
```
|
||||
|
||||
#### SourceNode.fromStringWithSourceMap(code, sourceMapConsumer[, relativePath])
|
||||
|
||||
Creates a SourceNode from generated code and a SourceMapConsumer.
|
||||
|
||||
* `code`: The generated code
|
||||
|
||||
* `sourceMapConsumer` The SourceMap for the generated code
|
||||
|
||||
* `relativePath` The optional path that relative sources in `sourceMapConsumer`
|
||||
should be relative to.
|
||||
|
||||
```js
|
||||
var consumer = new SourceMapConsumer(fs.readFileSync("path/to/my-file.js.map", "utf8"));
|
||||
var node = SourceNode.fromStringWithSourceMap(fs.readFileSync("path/to/my-file.js"),
|
||||
consumer);
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.add(chunk)
|
||||
|
||||
Add a chunk of generated JS to this source node.
|
||||
|
||||
* `chunk`: A string snippet of generated JS code, another instance of
|
||||
`SourceNode`, or an array where each member is one of those things.
|
||||
|
||||
```js
|
||||
node.add(" + ");
|
||||
node.add(otherNode);
|
||||
node.add([leftHandOperandNode, " + ", rightHandOperandNode]);
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.prepend(chunk)
|
||||
|
||||
Prepend a chunk of generated JS to this source node.
|
||||
|
||||
* `chunk`: A string snippet of generated JS code, another instance of
|
||||
`SourceNode`, or an array where each member is one of those things.
|
||||
|
||||
```js
|
||||
node.prepend("/** Build Id: f783haef86324gf **/\n\n");
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.setSourceContent(sourceFile, sourceContent)
|
||||
|
||||
Set the source content for a source file. This will be added to the
|
||||
`SourceMap` in the `sourcesContent` field.
|
||||
|
||||
* `sourceFile`: The filename of the source file
|
||||
|
||||
* `sourceContent`: The content of the source file
|
||||
|
||||
```js
|
||||
node.setSourceContent("module-one.scm",
|
||||
fs.readFileSync("path/to/module-one.scm"))
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.walk(fn)
|
||||
|
||||
Walk over the tree of JS snippets in this node and its children. The walking
|
||||
function is called once for each snippet of JS and is passed that snippet and
|
||||
the its original associated source's line/column location.
|
||||
|
||||
* `fn`: The traversal function.
|
||||
|
||||
```js
|
||||
var node = new SourceNode(1, 2, "a.js", [
|
||||
new SourceNode(3, 4, "b.js", "uno"),
|
||||
"dos",
|
||||
[
|
||||
"tres",
|
||||
new SourceNode(5, 6, "c.js", "quatro")
|
||||
]
|
||||
]);
|
||||
|
||||
node.walk(function (code, loc) { console.log("WALK:", code, loc); })
|
||||
// WALK: uno { source: 'b.js', line: 3, column: 4, name: null }
|
||||
// WALK: dos { source: 'a.js', line: 1, column: 2, name: null }
|
||||
// WALK: tres { source: 'a.js', line: 1, column: 2, name: null }
|
||||
// WALK: quatro { source: 'c.js', line: 5, column: 6, name: null }
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.walkSourceContents(fn)
|
||||
|
||||
Walk over the tree of SourceNodes. The walking function is called for each
|
||||
source file content and is passed the filename and source content.
|
||||
|
||||
* `fn`: The traversal function.
|
||||
|
||||
```js
|
||||
var a = new SourceNode(1, 2, "a.js", "generated from a");
|
||||
a.setSourceContent("a.js", "original a");
|
||||
var b = new SourceNode(1, 2, "b.js", "generated from b");
|
||||
b.setSourceContent("b.js", "original b");
|
||||
var c = new SourceNode(1, 2, "c.js", "generated from c");
|
||||
c.setSourceContent("c.js", "original c");
|
||||
|
||||
var node = new SourceNode(null, null, null, [a, b, c]);
|
||||
node.walkSourceContents(function (source, contents) { console.log("WALK:", source, ":", contents); })
|
||||
// WALK: a.js : original a
|
||||
// WALK: b.js : original b
|
||||
// WALK: c.js : original c
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.join(sep)
|
||||
|
||||
Like `Array.prototype.join` except for SourceNodes. Inserts the separator
|
||||
between each of this source node's children.
|
||||
|
||||
* `sep`: The separator.
|
||||
|
||||
```js
|
||||
var lhs = new SourceNode(1, 2, "a.rs", "my_copy");
|
||||
var operand = new SourceNode(3, 4, "a.rs", "=");
|
||||
var rhs = new SourceNode(5, 6, "a.rs", "orig.clone()");
|
||||
|
||||
var node = new SourceNode(null, null, null, [ lhs, operand, rhs ]);
|
||||
var joinedNode = node.join(" ");
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.replaceRight(pattern, replacement)
|
||||
|
||||
Call `String.prototype.replace` on the very right-most source snippet. Useful
|
||||
for trimming white space from the end of a source node, etc.
|
||||
|
||||
* `pattern`: The pattern to replace.
|
||||
|
||||
* `replacement`: The thing to replace the pattern with.
|
||||
|
||||
```js
|
||||
// Trim trailing white space.
|
||||
node.replaceRight(/\s*$/, "");
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.toString()
|
||||
|
||||
Return the string representation of this source node. Walks over the tree and
|
||||
concatenates all the various snippets together to one string.
|
||||
|
||||
```js
|
||||
var node = new SourceNode(1, 2, "a.js", [
|
||||
new SourceNode(3, 4, "b.js", "uno"),
|
||||
"dos",
|
||||
[
|
||||
"tres",
|
||||
new SourceNode(5, 6, "c.js", "quatro")
|
||||
]
|
||||
]);
|
||||
|
||||
node.toString()
|
||||
// 'unodostresquatro'
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.toStringWithSourceMap([startOfSourceMap])
|
||||
|
||||
Returns the string representation of this tree of source nodes, plus a
|
||||
SourceMapGenerator which contains all the mappings between the generated and
|
||||
original sources.
|
||||
|
||||
The arguments are the same as those to `new SourceMapGenerator`.
|
||||
|
||||
```js
|
||||
var node = new SourceNode(1, 2, "a.js", [
|
||||
new SourceNode(3, 4, "b.js", "uno"),
|
||||
"dos",
|
||||
[
|
||||
"tres",
|
||||
new SourceNode(5, 6, "c.js", "quatro")
|
||||
]
|
||||
]);
|
||||
|
||||
node.toStringWithSourceMap({ file: "my-output-file.js" })
|
||||
// { code: 'unodostresquatro',
|
||||
// map: [object SourceMapGenerator] }
|
||||
```
|
||||
3234
my-app/node_modules/resolve-url-loader/node_modules/source-map/dist/source-map.debug.js
generated
vendored
Executable file
3234
my-app/node_modules/resolve-url-loader/node_modules/source-map/dist/source-map.debug.js
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
3233
my-app/node_modules/resolve-url-loader/node_modules/source-map/dist/source-map.js
generated
vendored
Executable file
3233
my-app/node_modules/resolve-url-loader/node_modules/source-map/dist/source-map.js
generated
vendored
Executable file
File diff suppressed because it is too large
Load diff
2
my-app/node_modules/resolve-url-loader/node_modules/source-map/dist/source-map.min.js
generated
vendored
Executable file
2
my-app/node_modules/resolve-url-loader/node_modules/source-map/dist/source-map.min.js
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
1
my-app/node_modules/resolve-url-loader/node_modules/source-map/dist/source-map.min.js.map
generated
vendored
Executable file
1
my-app/node_modules/resolve-url-loader/node_modules/source-map/dist/source-map.min.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
121
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/array-set.js
generated
vendored
Executable file
121
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/array-set.js
generated
vendored
Executable file
|
|
@ -0,0 +1,121 @@
|
|||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
var util = require('./util');
|
||||
var has = Object.prototype.hasOwnProperty;
|
||||
var hasNativeMap = typeof Map !== "undefined";
|
||||
|
||||
/**
|
||||
* A data structure which is a combination of an array and a set. Adding a new
|
||||
* member is O(1), testing for membership is O(1), and finding the index of an
|
||||
* element is O(1). Removing elements from the set is not supported. Only
|
||||
* strings are supported for membership.
|
||||
*/
|
||||
function ArraySet() {
|
||||
this._array = [];
|
||||
this._set = hasNativeMap ? new Map() : Object.create(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Static method for creating ArraySet instances from an existing array.
|
||||
*/
|
||||
ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
|
||||
var set = new ArraySet();
|
||||
for (var i = 0, len = aArray.length; i < len; i++) {
|
||||
set.add(aArray[i], aAllowDuplicates);
|
||||
}
|
||||
return set;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return how many unique items are in this ArraySet. If duplicates have been
|
||||
* added, than those do not count towards the size.
|
||||
*
|
||||
* @returns Number
|
||||
*/
|
||||
ArraySet.prototype.size = function ArraySet_size() {
|
||||
return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add the given string to this set.
|
||||
*
|
||||
* @param String aStr
|
||||
*/
|
||||
ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
|
||||
var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
|
||||
var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
|
||||
var idx = this._array.length;
|
||||
if (!isDuplicate || aAllowDuplicates) {
|
||||
this._array.push(aStr);
|
||||
}
|
||||
if (!isDuplicate) {
|
||||
if (hasNativeMap) {
|
||||
this._set.set(aStr, idx);
|
||||
} else {
|
||||
this._set[sStr] = idx;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Is the given string a member of this set?
|
||||
*
|
||||
* @param String aStr
|
||||
*/
|
||||
ArraySet.prototype.has = function ArraySet_has(aStr) {
|
||||
if (hasNativeMap) {
|
||||
return this._set.has(aStr);
|
||||
} else {
|
||||
var sStr = util.toSetString(aStr);
|
||||
return has.call(this._set, sStr);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* What is the index of the given string in the array?
|
||||
*
|
||||
* @param String aStr
|
||||
*/
|
||||
ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
|
||||
if (hasNativeMap) {
|
||||
var idx = this._set.get(aStr);
|
||||
if (idx >= 0) {
|
||||
return idx;
|
||||
}
|
||||
} else {
|
||||
var sStr = util.toSetString(aStr);
|
||||
if (has.call(this._set, sStr)) {
|
||||
return this._set[sStr];
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error('"' + aStr + '" is not in the set.');
|
||||
};
|
||||
|
||||
/**
|
||||
* What is the element at the given index?
|
||||
*
|
||||
* @param Number aIdx
|
||||
*/
|
||||
ArraySet.prototype.at = function ArraySet_at(aIdx) {
|
||||
if (aIdx >= 0 && aIdx < this._array.length) {
|
||||
return this._array[aIdx];
|
||||
}
|
||||
throw new Error('No element indexed by ' + aIdx);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the array representation of this set (which has the proper indices
|
||||
* indicated by indexOf). Note that this is a copy of the internal array used
|
||||
* for storing the members so that no one can mess with internal state.
|
||||
*/
|
||||
ArraySet.prototype.toArray = function ArraySet_toArray() {
|
||||
return this._array.slice();
|
||||
};
|
||||
|
||||
exports.ArraySet = ArraySet;
|
||||
140
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/base64-vlq.js
generated
vendored
Executable file
140
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/base64-vlq.js
generated
vendored
Executable file
|
|
@ -0,0 +1,140 @@
|
|||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* Based on the Base 64 VLQ implementation in Closure Compiler:
|
||||
* https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
|
||||
*
|
||||
* Copyright 2011 The Closure Compiler Authors. All rights reserved.
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
var base64 = require('./base64');
|
||||
|
||||
// A single base 64 digit can contain 6 bits of data. For the base 64 variable
|
||||
// length quantities we use in the source map spec, the first bit is the sign,
|
||||
// the next four bits are the actual value, and the 6th bit is the
|
||||
// continuation bit. The continuation bit tells us whether there are more
|
||||
// digits in this value following this digit.
|
||||
//
|
||||
// Continuation
|
||||
// | Sign
|
||||
// | |
|
||||
// V V
|
||||
// 101011
|
||||
|
||||
var VLQ_BASE_SHIFT = 5;
|
||||
|
||||
// binary: 100000
|
||||
var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
|
||||
|
||||
// binary: 011111
|
||||
var VLQ_BASE_MASK = VLQ_BASE - 1;
|
||||
|
||||
// binary: 100000
|
||||
var VLQ_CONTINUATION_BIT = VLQ_BASE;
|
||||
|
||||
/**
|
||||
* Converts from a two-complement value to a value where the sign bit is
|
||||
* placed in the least significant bit. For example, as decimals:
|
||||
* 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
|
||||
* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
|
||||
*/
|
||||
function toVLQSigned(aValue) {
|
||||
return aValue < 0
|
||||
? ((-aValue) << 1) + 1
|
||||
: (aValue << 1) + 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts to a two-complement value from a value where the sign bit is
|
||||
* placed in the least significant bit. For example, as decimals:
|
||||
* 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
|
||||
* 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
|
||||
*/
|
||||
function fromVLQSigned(aValue) {
|
||||
var isNegative = (aValue & 1) === 1;
|
||||
var shifted = aValue >> 1;
|
||||
return isNegative
|
||||
? -shifted
|
||||
: shifted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base 64 VLQ encoded value.
|
||||
*/
|
||||
exports.encode = function base64VLQ_encode(aValue) {
|
||||
var encoded = "";
|
||||
var digit;
|
||||
|
||||
var vlq = toVLQSigned(aValue);
|
||||
|
||||
do {
|
||||
digit = vlq & VLQ_BASE_MASK;
|
||||
vlq >>>= VLQ_BASE_SHIFT;
|
||||
if (vlq > 0) {
|
||||
// There are still more digits in this value, so we must make sure the
|
||||
// continuation bit is marked.
|
||||
digit |= VLQ_CONTINUATION_BIT;
|
||||
}
|
||||
encoded += base64.encode(digit);
|
||||
} while (vlq > 0);
|
||||
|
||||
return encoded;
|
||||
};
|
||||
|
||||
/**
|
||||
* Decodes the next base 64 VLQ value from the given string and returns the
|
||||
* value and the rest of the string via the out parameter.
|
||||
*/
|
||||
exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
|
||||
var strLen = aStr.length;
|
||||
var result = 0;
|
||||
var shift = 0;
|
||||
var continuation, digit;
|
||||
|
||||
do {
|
||||
if (aIndex >= strLen) {
|
||||
throw new Error("Expected more digits in base 64 VLQ value.");
|
||||
}
|
||||
|
||||
digit = base64.decode(aStr.charCodeAt(aIndex++));
|
||||
if (digit === -1) {
|
||||
throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
|
||||
}
|
||||
|
||||
continuation = !!(digit & VLQ_CONTINUATION_BIT);
|
||||
digit &= VLQ_BASE_MASK;
|
||||
result = result + (digit << shift);
|
||||
shift += VLQ_BASE_SHIFT;
|
||||
} while (continuation);
|
||||
|
||||
aOutParam.value = fromVLQSigned(result);
|
||||
aOutParam.rest = aIndex;
|
||||
};
|
||||
67
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/base64.js
generated
vendored
Executable file
67
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/base64.js
generated
vendored
Executable file
|
|
@ -0,0 +1,67 @@
|
|||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
|
||||
|
||||
/**
|
||||
* Encode an integer in the range of 0 to 63 to a single base 64 digit.
|
||||
*/
|
||||
exports.encode = function (number) {
|
||||
if (0 <= number && number < intToCharMap.length) {
|
||||
return intToCharMap[number];
|
||||
}
|
||||
throw new TypeError("Must be between 0 and 63: " + number);
|
||||
};
|
||||
|
||||
/**
|
||||
* Decode a single base 64 character code digit to an integer. Returns -1 on
|
||||
* failure.
|
||||
*/
|
||||
exports.decode = function (charCode) {
|
||||
var bigA = 65; // 'A'
|
||||
var bigZ = 90; // 'Z'
|
||||
|
||||
var littleA = 97; // 'a'
|
||||
var littleZ = 122; // 'z'
|
||||
|
||||
var zero = 48; // '0'
|
||||
var nine = 57; // '9'
|
||||
|
||||
var plus = 43; // '+'
|
||||
var slash = 47; // '/'
|
||||
|
||||
var littleOffset = 26;
|
||||
var numberOffset = 52;
|
||||
|
||||
// 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||
if (bigA <= charCode && charCode <= bigZ) {
|
||||
return (charCode - bigA);
|
||||
}
|
||||
|
||||
// 26 - 51: abcdefghijklmnopqrstuvwxyz
|
||||
if (littleA <= charCode && charCode <= littleZ) {
|
||||
return (charCode - littleA + littleOffset);
|
||||
}
|
||||
|
||||
// 52 - 61: 0123456789
|
||||
if (zero <= charCode && charCode <= nine) {
|
||||
return (charCode - zero + numberOffset);
|
||||
}
|
||||
|
||||
// 62: +
|
||||
if (charCode == plus) {
|
||||
return 62;
|
||||
}
|
||||
|
||||
// 63: /
|
||||
if (charCode == slash) {
|
||||
return 63;
|
||||
}
|
||||
|
||||
// Invalid base64 digit.
|
||||
return -1;
|
||||
};
|
||||
111
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/binary-search.js
generated
vendored
Executable file
111
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/binary-search.js
generated
vendored
Executable file
|
|
@ -0,0 +1,111 @@
|
|||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
exports.GREATEST_LOWER_BOUND = 1;
|
||||
exports.LEAST_UPPER_BOUND = 2;
|
||||
|
||||
/**
|
||||
* Recursive implementation of binary search.
|
||||
*
|
||||
* @param aLow Indices here and lower do not contain the needle.
|
||||
* @param aHigh Indices here and higher do not contain the needle.
|
||||
* @param aNeedle The element being searched for.
|
||||
* @param aHaystack The non-empty array being searched.
|
||||
* @param aCompare Function which takes two elements and returns -1, 0, or 1.
|
||||
* @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
|
||||
* 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
|
||||
* closest element that is smaller than or greater than the one we are
|
||||
* searching for, respectively, if the exact element cannot be found.
|
||||
*/
|
||||
function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
|
||||
// This function terminates when one of the following is true:
|
||||
//
|
||||
// 1. We find the exact element we are looking for.
|
||||
//
|
||||
// 2. We did not find the exact element, but we can return the index of
|
||||
// the next-closest element.
|
||||
//
|
||||
// 3. We did not find the exact element, and there is no next-closest
|
||||
// element than the one we are searching for, so we return -1.
|
||||
var mid = Math.floor((aHigh - aLow) / 2) + aLow;
|
||||
var cmp = aCompare(aNeedle, aHaystack[mid], true);
|
||||
if (cmp === 0) {
|
||||
// Found the element we are looking for.
|
||||
return mid;
|
||||
}
|
||||
else if (cmp > 0) {
|
||||
// Our needle is greater than aHaystack[mid].
|
||||
if (aHigh - mid > 1) {
|
||||
// The element is in the upper half.
|
||||
return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
|
||||
}
|
||||
|
||||
// The exact needle element was not found in this haystack. Determine if
|
||||
// we are in termination case (3) or (2) and return the appropriate thing.
|
||||
if (aBias == exports.LEAST_UPPER_BOUND) {
|
||||
return aHigh < aHaystack.length ? aHigh : -1;
|
||||
} else {
|
||||
return mid;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Our needle is less than aHaystack[mid].
|
||||
if (mid - aLow > 1) {
|
||||
// The element is in the lower half.
|
||||
return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
|
||||
}
|
||||
|
||||
// we are in termination case (3) or (2) and return the appropriate thing.
|
||||
if (aBias == exports.LEAST_UPPER_BOUND) {
|
||||
return mid;
|
||||
} else {
|
||||
return aLow < 0 ? -1 : aLow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an implementation of binary search which will always try and return
|
||||
* the index of the closest element if there is no exact hit. This is because
|
||||
* mappings between original and generated line/col pairs are single points,
|
||||
* and there is an implicit region between each of them, so a miss just means
|
||||
* that you aren't on the very start of a region.
|
||||
*
|
||||
* @param aNeedle The element you are looking for.
|
||||
* @param aHaystack The array that is being searched.
|
||||
* @param aCompare A function which takes the needle and an element in the
|
||||
* array and returns -1, 0, or 1 depending on whether the needle is less
|
||||
* than, equal to, or greater than the element, respectively.
|
||||
* @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
|
||||
* 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
|
||||
* closest element that is smaller than or greater than the one we are
|
||||
* searching for, respectively, if the exact element cannot be found.
|
||||
* Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
|
||||
*/
|
||||
exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
|
||||
if (aHaystack.length === 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
|
||||
aCompare, aBias || exports.GREATEST_LOWER_BOUND);
|
||||
if (index < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// We have found either the exact element, or the next-closest element than
|
||||
// the one we are searching for. However, there may be more than one such
|
||||
// element. Make sure we always return the smallest of these.
|
||||
while (index - 1 >= 0) {
|
||||
if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
|
||||
break;
|
||||
}
|
||||
--index;
|
||||
}
|
||||
|
||||
return index;
|
||||
};
|
||||
79
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/mapping-list.js
generated
vendored
Executable file
79
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/mapping-list.js
generated
vendored
Executable file
|
|
@ -0,0 +1,79 @@
|
|||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2014 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
var util = require('./util');
|
||||
|
||||
/**
|
||||
* Determine whether mappingB is after mappingA with respect to generated
|
||||
* position.
|
||||
*/
|
||||
function generatedPositionAfter(mappingA, mappingB) {
|
||||
// Optimized for most common case
|
||||
var lineA = mappingA.generatedLine;
|
||||
var lineB = mappingB.generatedLine;
|
||||
var columnA = mappingA.generatedColumn;
|
||||
var columnB = mappingB.generatedColumn;
|
||||
return lineB > lineA || lineB == lineA && columnB >= columnA ||
|
||||
util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* A data structure to provide a sorted view of accumulated mappings in a
|
||||
* performance conscious manner. It trades a neglibable overhead in general
|
||||
* case for a large speedup in case of mappings being added in order.
|
||||
*/
|
||||
function MappingList() {
|
||||
this._array = [];
|
||||
this._sorted = true;
|
||||
// Serves as infimum
|
||||
this._last = {generatedLine: -1, generatedColumn: 0};
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate through internal items. This method takes the same arguments that
|
||||
* `Array.prototype.forEach` takes.
|
||||
*
|
||||
* NOTE: The order of the mappings is NOT guaranteed.
|
||||
*/
|
||||
MappingList.prototype.unsortedForEach =
|
||||
function MappingList_forEach(aCallback, aThisArg) {
|
||||
this._array.forEach(aCallback, aThisArg);
|
||||
};
|
||||
|
||||
/**
|
||||
* Add the given source mapping.
|
||||
*
|
||||
* @param Object aMapping
|
||||
*/
|
||||
MappingList.prototype.add = function MappingList_add(aMapping) {
|
||||
if (generatedPositionAfter(this._last, aMapping)) {
|
||||
this._last = aMapping;
|
||||
this._array.push(aMapping);
|
||||
} else {
|
||||
this._sorted = false;
|
||||
this._array.push(aMapping);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the flat, sorted array of mappings. The mappings are sorted by
|
||||
* generated position.
|
||||
*
|
||||
* WARNING: This method returns internal data without copying, for
|
||||
* performance. The return value must NOT be mutated, and should be treated as
|
||||
* an immutable borrow. If you want to take ownership, you must make your own
|
||||
* copy.
|
||||
*/
|
||||
MappingList.prototype.toArray = function MappingList_toArray() {
|
||||
if (!this._sorted) {
|
||||
this._array.sort(util.compareByGeneratedPositionsInflated);
|
||||
this._sorted = true;
|
||||
}
|
||||
return this._array;
|
||||
};
|
||||
|
||||
exports.MappingList = MappingList;
|
||||
114
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/quick-sort.js
generated
vendored
Executable file
114
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/quick-sort.js
generated
vendored
Executable file
|
|
@ -0,0 +1,114 @@
|
|||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
// It turns out that some (most?) JavaScript engines don't self-host
|
||||
// `Array.prototype.sort`. This makes sense because C++ will likely remain
|
||||
// faster than JS when doing raw CPU-intensive sorting. However, when using a
|
||||
// custom comparator function, calling back and forth between the VM's C++ and
|
||||
// JIT'd JS is rather slow *and* loses JIT type information, resulting in
|
||||
// worse generated code for the comparator function than would be optimal. In
|
||||
// fact, when sorting with a comparator, these costs outweigh the benefits of
|
||||
// sorting in C++. By using our own JS-implemented Quick Sort (below), we get
|
||||
// a ~3500ms mean speed-up in `bench/bench.html`.
|
||||
|
||||
/**
|
||||
* Swap the elements indexed by `x` and `y` in the array `ary`.
|
||||
*
|
||||
* @param {Array} ary
|
||||
* The array.
|
||||
* @param {Number} x
|
||||
* The index of the first item.
|
||||
* @param {Number} y
|
||||
* The index of the second item.
|
||||
*/
|
||||
function swap(ary, x, y) {
|
||||
var temp = ary[x];
|
||||
ary[x] = ary[y];
|
||||
ary[y] = temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a random integer within the range `low .. high` inclusive.
|
||||
*
|
||||
* @param {Number} low
|
||||
* The lower bound on the range.
|
||||
* @param {Number} high
|
||||
* The upper bound on the range.
|
||||
*/
|
||||
function randomIntInRange(low, high) {
|
||||
return Math.round(low + (Math.random() * (high - low)));
|
||||
}
|
||||
|
||||
/**
|
||||
* The Quick Sort algorithm.
|
||||
*
|
||||
* @param {Array} ary
|
||||
* An array to sort.
|
||||
* @param {function} comparator
|
||||
* Function to use to compare two items.
|
||||
* @param {Number} p
|
||||
* Start index of the array
|
||||
* @param {Number} r
|
||||
* End index of the array
|
||||
*/
|
||||
function doQuickSort(ary, comparator, p, r) {
|
||||
// If our lower bound is less than our upper bound, we (1) partition the
|
||||
// array into two pieces and (2) recurse on each half. If it is not, this is
|
||||
// the empty array and our base case.
|
||||
|
||||
if (p < r) {
|
||||
// (1) Partitioning.
|
||||
//
|
||||
// The partitioning chooses a pivot between `p` and `r` and moves all
|
||||
// elements that are less than or equal to the pivot to the before it, and
|
||||
// all the elements that are greater than it after it. The effect is that
|
||||
// once partition is done, the pivot is in the exact place it will be when
|
||||
// the array is put in sorted order, and it will not need to be moved
|
||||
// again. This runs in O(n) time.
|
||||
|
||||
// Always choose a random pivot so that an input array which is reverse
|
||||
// sorted does not cause O(n^2) running time.
|
||||
var pivotIndex = randomIntInRange(p, r);
|
||||
var i = p - 1;
|
||||
|
||||
swap(ary, pivotIndex, r);
|
||||
var pivot = ary[r];
|
||||
|
||||
// Immediately after `j` is incremented in this loop, the following hold
|
||||
// true:
|
||||
//
|
||||
// * Every element in `ary[p .. i]` is less than or equal to the pivot.
|
||||
//
|
||||
// * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
|
||||
for (var j = p; j < r; j++) {
|
||||
if (comparator(ary[j], pivot) <= 0) {
|
||||
i += 1;
|
||||
swap(ary, i, j);
|
||||
}
|
||||
}
|
||||
|
||||
swap(ary, i + 1, j);
|
||||
var q = i + 1;
|
||||
|
||||
// (2) Recurse on each half.
|
||||
|
||||
doQuickSort(ary, comparator, p, q - 1);
|
||||
doQuickSort(ary, comparator, q + 1, r);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the given array in-place with the given comparator function.
|
||||
*
|
||||
* @param {Array} ary
|
||||
* An array to sort.
|
||||
* @param {function} comparator
|
||||
* Function to use to compare two items.
|
||||
*/
|
||||
exports.quickSort = function (ary, comparator) {
|
||||
doQuickSort(ary, comparator, 0, ary.length - 1);
|
||||
};
|
||||
1145
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/source-map-consumer.js
generated
vendored
Executable file
1145
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/source-map-consumer.js
generated
vendored
Executable file
File diff suppressed because it is too large
Load diff
425
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/source-map-generator.js
generated
vendored
Executable file
425
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/source-map-generator.js
generated
vendored
Executable file
|
|
@ -0,0 +1,425 @@
|
|||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
var base64VLQ = require('./base64-vlq');
|
||||
var util = require('./util');
|
||||
var ArraySet = require('./array-set').ArraySet;
|
||||
var MappingList = require('./mapping-list').MappingList;
|
||||
|
||||
/**
|
||||
* An instance of the SourceMapGenerator represents a source map which is
|
||||
* being built incrementally. You may pass an object with the following
|
||||
* properties:
|
||||
*
|
||||
* - file: The filename of the generated source.
|
||||
* - sourceRoot: A root for all relative URLs in this source map.
|
||||
*/
|
||||
function SourceMapGenerator(aArgs) {
|
||||
if (!aArgs) {
|
||||
aArgs = {};
|
||||
}
|
||||
this._file = util.getArg(aArgs, 'file', null);
|
||||
this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
|
||||
this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
|
||||
this._sources = new ArraySet();
|
||||
this._names = new ArraySet();
|
||||
this._mappings = new MappingList();
|
||||
this._sourcesContents = null;
|
||||
}
|
||||
|
||||
SourceMapGenerator.prototype._version = 3;
|
||||
|
||||
/**
|
||||
* Creates a new SourceMapGenerator based on a SourceMapConsumer
|
||||
*
|
||||
* @param aSourceMapConsumer The SourceMap.
|
||||
*/
|
||||
SourceMapGenerator.fromSourceMap =
|
||||
function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
|
||||
var sourceRoot = aSourceMapConsumer.sourceRoot;
|
||||
var generator = new SourceMapGenerator({
|
||||
file: aSourceMapConsumer.file,
|
||||
sourceRoot: sourceRoot
|
||||
});
|
||||
aSourceMapConsumer.eachMapping(function (mapping) {
|
||||
var newMapping = {
|
||||
generated: {
|
||||
line: mapping.generatedLine,
|
||||
column: mapping.generatedColumn
|
||||
}
|
||||
};
|
||||
|
||||
if (mapping.source != null) {
|
||||
newMapping.source = mapping.source;
|
||||
if (sourceRoot != null) {
|
||||
newMapping.source = util.relative(sourceRoot, newMapping.source);
|
||||
}
|
||||
|
||||
newMapping.original = {
|
||||
line: mapping.originalLine,
|
||||
column: mapping.originalColumn
|
||||
};
|
||||
|
||||
if (mapping.name != null) {
|
||||
newMapping.name = mapping.name;
|
||||
}
|
||||
}
|
||||
|
||||
generator.addMapping(newMapping);
|
||||
});
|
||||
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
||||
var sourceRelative = sourceFile;
|
||||
if (sourceRoot !== null) {
|
||||
sourceRelative = util.relative(sourceRoot, sourceFile);
|
||||
}
|
||||
|
||||
if (!generator._sources.has(sourceRelative)) {
|
||||
generator._sources.add(sourceRelative);
|
||||
}
|
||||
|
||||
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
||||
if (content != null) {
|
||||
generator.setSourceContent(sourceFile, content);
|
||||
}
|
||||
});
|
||||
return generator;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a single mapping from original source line and column to the generated
|
||||
* source's line and column for this source map being created. The mapping
|
||||
* object should have the following properties:
|
||||
*
|
||||
* - generated: An object with the generated line and column positions.
|
||||
* - original: An object with the original line and column positions.
|
||||
* - source: The original source file (relative to the sourceRoot).
|
||||
* - name: An optional original token name for this mapping.
|
||||
*/
|
||||
SourceMapGenerator.prototype.addMapping =
|
||||
function SourceMapGenerator_addMapping(aArgs) {
|
||||
var generated = util.getArg(aArgs, 'generated');
|
||||
var original = util.getArg(aArgs, 'original', null);
|
||||
var source = util.getArg(aArgs, 'source', null);
|
||||
var name = util.getArg(aArgs, 'name', null);
|
||||
|
||||
if (!this._skipValidation) {
|
||||
this._validateMapping(generated, original, source, name);
|
||||
}
|
||||
|
||||
if (source != null) {
|
||||
source = String(source);
|
||||
if (!this._sources.has(source)) {
|
||||
this._sources.add(source);
|
||||
}
|
||||
}
|
||||
|
||||
if (name != null) {
|
||||
name = String(name);
|
||||
if (!this._names.has(name)) {
|
||||
this._names.add(name);
|
||||
}
|
||||
}
|
||||
|
||||
this._mappings.add({
|
||||
generatedLine: generated.line,
|
||||
generatedColumn: generated.column,
|
||||
originalLine: original != null && original.line,
|
||||
originalColumn: original != null && original.column,
|
||||
source: source,
|
||||
name: name
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the source content for a source file.
|
||||
*/
|
||||
SourceMapGenerator.prototype.setSourceContent =
|
||||
function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
|
||||
var source = aSourceFile;
|
||||
if (this._sourceRoot != null) {
|
||||
source = util.relative(this._sourceRoot, source);
|
||||
}
|
||||
|
||||
if (aSourceContent != null) {
|
||||
// Add the source content to the _sourcesContents map.
|
||||
// Create a new _sourcesContents map if the property is null.
|
||||
if (!this._sourcesContents) {
|
||||
this._sourcesContents = Object.create(null);
|
||||
}
|
||||
this._sourcesContents[util.toSetString(source)] = aSourceContent;
|
||||
} else if (this._sourcesContents) {
|
||||
// Remove the source file from the _sourcesContents map.
|
||||
// If the _sourcesContents map is empty, set the property to null.
|
||||
delete this._sourcesContents[util.toSetString(source)];
|
||||
if (Object.keys(this._sourcesContents).length === 0) {
|
||||
this._sourcesContents = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Applies the mappings of a sub-source-map for a specific source file to the
|
||||
* source map being generated. Each mapping to the supplied source file is
|
||||
* rewritten using the supplied source map. Note: The resolution for the
|
||||
* resulting mappings is the minimium of this map and the supplied map.
|
||||
*
|
||||
* @param aSourceMapConsumer The source map to be applied.
|
||||
* @param aSourceFile Optional. The filename of the source file.
|
||||
* If omitted, SourceMapConsumer's file property will be used.
|
||||
* @param aSourceMapPath Optional. The dirname of the path to the source map
|
||||
* to be applied. If relative, it is relative to the SourceMapConsumer.
|
||||
* This parameter is needed when the two source maps aren't in the same
|
||||
* directory, and the source map to be applied contains relative source
|
||||
* paths. If so, those relative source paths need to be rewritten
|
||||
* relative to the SourceMapGenerator.
|
||||
*/
|
||||
SourceMapGenerator.prototype.applySourceMap =
|
||||
function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
|
||||
var sourceFile = aSourceFile;
|
||||
// If aSourceFile is omitted, we will use the file property of the SourceMap
|
||||
if (aSourceFile == null) {
|
||||
if (aSourceMapConsumer.file == null) {
|
||||
throw new Error(
|
||||
'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
|
||||
'or the source map\'s "file" property. Both were omitted.'
|
||||
);
|
||||
}
|
||||
sourceFile = aSourceMapConsumer.file;
|
||||
}
|
||||
var sourceRoot = this._sourceRoot;
|
||||
// Make "sourceFile" relative if an absolute Url is passed.
|
||||
if (sourceRoot != null) {
|
||||
sourceFile = util.relative(sourceRoot, sourceFile);
|
||||
}
|
||||
// Applying the SourceMap can add and remove items from the sources and
|
||||
// the names array.
|
||||
var newSources = new ArraySet();
|
||||
var newNames = new ArraySet();
|
||||
|
||||
// Find mappings for the "sourceFile"
|
||||
this._mappings.unsortedForEach(function (mapping) {
|
||||
if (mapping.source === sourceFile && mapping.originalLine != null) {
|
||||
// Check if it can be mapped by the source map, then update the mapping.
|
||||
var original = aSourceMapConsumer.originalPositionFor({
|
||||
line: mapping.originalLine,
|
||||
column: mapping.originalColumn
|
||||
});
|
||||
if (original.source != null) {
|
||||
// Copy mapping
|
||||
mapping.source = original.source;
|
||||
if (aSourceMapPath != null) {
|
||||
mapping.source = util.join(aSourceMapPath, mapping.source)
|
||||
}
|
||||
if (sourceRoot != null) {
|
||||
mapping.source = util.relative(sourceRoot, mapping.source);
|
||||
}
|
||||
mapping.originalLine = original.line;
|
||||
mapping.originalColumn = original.column;
|
||||
if (original.name != null) {
|
||||
mapping.name = original.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var source = mapping.source;
|
||||
if (source != null && !newSources.has(source)) {
|
||||
newSources.add(source);
|
||||
}
|
||||
|
||||
var name = mapping.name;
|
||||
if (name != null && !newNames.has(name)) {
|
||||
newNames.add(name);
|
||||
}
|
||||
|
||||
}, this);
|
||||
this._sources = newSources;
|
||||
this._names = newNames;
|
||||
|
||||
// Copy sourcesContents of applied map.
|
||||
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
||||
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
||||
if (content != null) {
|
||||
if (aSourceMapPath != null) {
|
||||
sourceFile = util.join(aSourceMapPath, sourceFile);
|
||||
}
|
||||
if (sourceRoot != null) {
|
||||
sourceFile = util.relative(sourceRoot, sourceFile);
|
||||
}
|
||||
this.setSourceContent(sourceFile, content);
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
|
||||
/**
|
||||
* A mapping can have one of the three levels of data:
|
||||
*
|
||||
* 1. Just the generated position.
|
||||
* 2. The Generated position, original position, and original source.
|
||||
* 3. Generated and original position, original source, as well as a name
|
||||
* token.
|
||||
*
|
||||
* To maintain consistency, we validate that any new mapping being added falls
|
||||
* in to one of these categories.
|
||||
*/
|
||||
SourceMapGenerator.prototype._validateMapping =
|
||||
function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
|
||||
aName) {
|
||||
// When aOriginal is truthy but has empty values for .line and .column,
|
||||
// it is most likely a programmer error. In this case we throw a very
|
||||
// specific error message to try to guide them the right way.
|
||||
// For example: https://github.com/Polymer/polymer-bundler/pull/519
|
||||
if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
|
||||
throw new Error(
|
||||
'original.line and original.column are not numbers -- you probably meant to omit ' +
|
||||
'the original mapping entirely and only map the generated position. If so, pass ' +
|
||||
'null for the original mapping instead of an object with empty or null values.'
|
||||
);
|
||||
}
|
||||
|
||||
if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
|
||||
&& aGenerated.line > 0 && aGenerated.column >= 0
|
||||
&& !aOriginal && !aSource && !aName) {
|
||||
// Case 1.
|
||||
return;
|
||||
}
|
||||
else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
|
||||
&& aOriginal && 'line' in aOriginal && 'column' in aOriginal
|
||||
&& aGenerated.line > 0 && aGenerated.column >= 0
|
||||
&& aOriginal.line > 0 && aOriginal.column >= 0
|
||||
&& aSource) {
|
||||
// Cases 2 and 3.
|
||||
return;
|
||||
}
|
||||
else {
|
||||
throw new Error('Invalid mapping: ' + JSON.stringify({
|
||||
generated: aGenerated,
|
||||
source: aSource,
|
||||
original: aOriginal,
|
||||
name: aName
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Serialize the accumulated mappings in to the stream of base 64 VLQs
|
||||
* specified by the source map format.
|
||||
*/
|
||||
SourceMapGenerator.prototype._serializeMappings =
|
||||
function SourceMapGenerator_serializeMappings() {
|
||||
var previousGeneratedColumn = 0;
|
||||
var previousGeneratedLine = 1;
|
||||
var previousOriginalColumn = 0;
|
||||
var previousOriginalLine = 0;
|
||||
var previousName = 0;
|
||||
var previousSource = 0;
|
||||
var result = '';
|
||||
var next;
|
||||
var mapping;
|
||||
var nameIdx;
|
||||
var sourceIdx;
|
||||
|
||||
var mappings = this._mappings.toArray();
|
||||
for (var i = 0, len = mappings.length; i < len; i++) {
|
||||
mapping = mappings[i];
|
||||
next = ''
|
||||
|
||||
if (mapping.generatedLine !== previousGeneratedLine) {
|
||||
previousGeneratedColumn = 0;
|
||||
while (mapping.generatedLine !== previousGeneratedLine) {
|
||||
next += ';';
|
||||
previousGeneratedLine++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (i > 0) {
|
||||
if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
|
||||
continue;
|
||||
}
|
||||
next += ',';
|
||||
}
|
||||
}
|
||||
|
||||
next += base64VLQ.encode(mapping.generatedColumn
|
||||
- previousGeneratedColumn);
|
||||
previousGeneratedColumn = mapping.generatedColumn;
|
||||
|
||||
if (mapping.source != null) {
|
||||
sourceIdx = this._sources.indexOf(mapping.source);
|
||||
next += base64VLQ.encode(sourceIdx - previousSource);
|
||||
previousSource = sourceIdx;
|
||||
|
||||
// lines are stored 0-based in SourceMap spec version 3
|
||||
next += base64VLQ.encode(mapping.originalLine - 1
|
||||
- previousOriginalLine);
|
||||
previousOriginalLine = mapping.originalLine - 1;
|
||||
|
||||
next += base64VLQ.encode(mapping.originalColumn
|
||||
- previousOriginalColumn);
|
||||
previousOriginalColumn = mapping.originalColumn;
|
||||
|
||||
if (mapping.name != null) {
|
||||
nameIdx = this._names.indexOf(mapping.name);
|
||||
next += base64VLQ.encode(nameIdx - previousName);
|
||||
previousName = nameIdx;
|
||||
}
|
||||
}
|
||||
|
||||
result += next;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
SourceMapGenerator.prototype._generateSourcesContent =
|
||||
function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
|
||||
return aSources.map(function (source) {
|
||||
if (!this._sourcesContents) {
|
||||
return null;
|
||||
}
|
||||
if (aSourceRoot != null) {
|
||||
source = util.relative(aSourceRoot, source);
|
||||
}
|
||||
var key = util.toSetString(source);
|
||||
return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
|
||||
? this._sourcesContents[key]
|
||||
: null;
|
||||
}, this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Externalize the source map.
|
||||
*/
|
||||
SourceMapGenerator.prototype.toJSON =
|
||||
function SourceMapGenerator_toJSON() {
|
||||
var map = {
|
||||
version: this._version,
|
||||
sources: this._sources.toArray(),
|
||||
names: this._names.toArray(),
|
||||
mappings: this._serializeMappings()
|
||||
};
|
||||
if (this._file != null) {
|
||||
map.file = this._file;
|
||||
}
|
||||
if (this._sourceRoot != null) {
|
||||
map.sourceRoot = this._sourceRoot;
|
||||
}
|
||||
if (this._sourcesContents) {
|
||||
map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
|
||||
}
|
||||
|
||||
return map;
|
||||
};
|
||||
|
||||
/**
|
||||
* Render the source map being generated to a string.
|
||||
*/
|
||||
SourceMapGenerator.prototype.toString =
|
||||
function SourceMapGenerator_toString() {
|
||||
return JSON.stringify(this.toJSON());
|
||||
};
|
||||
|
||||
exports.SourceMapGenerator = SourceMapGenerator;
|
||||
413
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/source-node.js
generated
vendored
Executable file
413
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/source-node.js
generated
vendored
Executable file
|
|
@ -0,0 +1,413 @@
|
|||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator;
|
||||
var util = require('./util');
|
||||
|
||||
// Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
|
||||
// operating systems these days (capturing the result).
|
||||
var REGEX_NEWLINE = /(\r?\n)/;
|
||||
|
||||
// Newline character code for charCodeAt() comparisons
|
||||
var NEWLINE_CODE = 10;
|
||||
|
||||
// Private symbol for identifying `SourceNode`s when multiple versions of
|
||||
// the source-map library are loaded. This MUST NOT CHANGE across
|
||||
// versions!
|
||||
var isSourceNode = "$$$isSourceNode$$$";
|
||||
|
||||
/**
|
||||
* SourceNodes provide a way to abstract over interpolating/concatenating
|
||||
* snippets of generated JavaScript source code while maintaining the line and
|
||||
* column information associated with the original source code.
|
||||
*
|
||||
* @param aLine The original line number.
|
||||
* @param aColumn The original column number.
|
||||
* @param aSource The original source's filename.
|
||||
* @param aChunks Optional. An array of strings which are snippets of
|
||||
* generated JS, or other SourceNodes.
|
||||
* @param aName The original identifier.
|
||||
*/
|
||||
function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
|
||||
this.children = [];
|
||||
this.sourceContents = {};
|
||||
this.line = aLine == null ? null : aLine;
|
||||
this.column = aColumn == null ? null : aColumn;
|
||||
this.source = aSource == null ? null : aSource;
|
||||
this.name = aName == null ? null : aName;
|
||||
this[isSourceNode] = true;
|
||||
if (aChunks != null) this.add(aChunks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a SourceNode from generated code and a SourceMapConsumer.
|
||||
*
|
||||
* @param aGeneratedCode The generated code
|
||||
* @param aSourceMapConsumer The SourceMap for the generated code
|
||||
* @param aRelativePath Optional. The path that relative sources in the
|
||||
* SourceMapConsumer should be relative to.
|
||||
*/
|
||||
SourceNode.fromStringWithSourceMap =
|
||||
function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
|
||||
// The SourceNode we want to fill with the generated code
|
||||
// and the SourceMap
|
||||
var node = new SourceNode();
|
||||
|
||||
// All even indices of this array are one line of the generated code,
|
||||
// while all odd indices are the newlines between two adjacent lines
|
||||
// (since `REGEX_NEWLINE` captures its match).
|
||||
// Processed fragments are accessed by calling `shiftNextLine`.
|
||||
var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
|
||||
var remainingLinesIndex = 0;
|
||||
var shiftNextLine = function() {
|
||||
var lineContents = getNextLine();
|
||||
// The last line of a file might not have a newline.
|
||||
var newLine = getNextLine() || "";
|
||||
return lineContents + newLine;
|
||||
|
||||
function getNextLine() {
|
||||
return remainingLinesIndex < remainingLines.length ?
|
||||
remainingLines[remainingLinesIndex++] : undefined;
|
||||
}
|
||||
};
|
||||
|
||||
// We need to remember the position of "remainingLines"
|
||||
var lastGeneratedLine = 1, lastGeneratedColumn = 0;
|
||||
|
||||
// The generate SourceNodes we need a code range.
|
||||
// To extract it current and last mapping is used.
|
||||
// Here we store the last mapping.
|
||||
var lastMapping = null;
|
||||
|
||||
aSourceMapConsumer.eachMapping(function (mapping) {
|
||||
if (lastMapping !== null) {
|
||||
// We add the code from "lastMapping" to "mapping":
|
||||
// First check if there is a new line in between.
|
||||
if (lastGeneratedLine < mapping.generatedLine) {
|
||||
// Associate first line with "lastMapping"
|
||||
addMappingWithCode(lastMapping, shiftNextLine());
|
||||
lastGeneratedLine++;
|
||||
lastGeneratedColumn = 0;
|
||||
// The remaining code is added without mapping
|
||||
} else {
|
||||
// There is no new line in between.
|
||||
// Associate the code between "lastGeneratedColumn" and
|
||||
// "mapping.generatedColumn" with "lastMapping"
|
||||
var nextLine = remainingLines[remainingLinesIndex] || '';
|
||||
var code = nextLine.substr(0, mapping.generatedColumn -
|
||||
lastGeneratedColumn);
|
||||
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
|
||||
lastGeneratedColumn);
|
||||
lastGeneratedColumn = mapping.generatedColumn;
|
||||
addMappingWithCode(lastMapping, code);
|
||||
// No more remaining code, continue
|
||||
lastMapping = mapping;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// We add the generated code until the first mapping
|
||||
// to the SourceNode without any mapping.
|
||||
// Each line is added as separate string.
|
||||
while (lastGeneratedLine < mapping.generatedLine) {
|
||||
node.add(shiftNextLine());
|
||||
lastGeneratedLine++;
|
||||
}
|
||||
if (lastGeneratedColumn < mapping.generatedColumn) {
|
||||
var nextLine = remainingLines[remainingLinesIndex] || '';
|
||||
node.add(nextLine.substr(0, mapping.generatedColumn));
|
||||
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
|
||||
lastGeneratedColumn = mapping.generatedColumn;
|
||||
}
|
||||
lastMapping = mapping;
|
||||
}, this);
|
||||
// We have processed all mappings.
|
||||
if (remainingLinesIndex < remainingLines.length) {
|
||||
if (lastMapping) {
|
||||
// Associate the remaining code in the current line with "lastMapping"
|
||||
addMappingWithCode(lastMapping, shiftNextLine());
|
||||
}
|
||||
// and add the remaining lines without any mapping
|
||||
node.add(remainingLines.splice(remainingLinesIndex).join(""));
|
||||
}
|
||||
|
||||
// Copy sourcesContent into SourceNode
|
||||
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
||||
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
||||
if (content != null) {
|
||||
if (aRelativePath != null) {
|
||||
sourceFile = util.join(aRelativePath, sourceFile);
|
||||
}
|
||||
node.setSourceContent(sourceFile, content);
|
||||
}
|
||||
});
|
||||
|
||||
return node;
|
||||
|
||||
function addMappingWithCode(mapping, code) {
|
||||
if (mapping === null || mapping.source === undefined) {
|
||||
node.add(code);
|
||||
} else {
|
||||
var source = aRelativePath
|
||||
? util.join(aRelativePath, mapping.source)
|
||||
: mapping.source;
|
||||
node.add(new SourceNode(mapping.originalLine,
|
||||
mapping.originalColumn,
|
||||
source,
|
||||
code,
|
||||
mapping.name));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a chunk of generated JS to this source node.
|
||||
*
|
||||
* @param aChunk A string snippet of generated JS code, another instance of
|
||||
* SourceNode, or an array where each member is one of those things.
|
||||
*/
|
||||
SourceNode.prototype.add = function SourceNode_add(aChunk) {
|
||||
if (Array.isArray(aChunk)) {
|
||||
aChunk.forEach(function (chunk) {
|
||||
this.add(chunk);
|
||||
}, this);
|
||||
}
|
||||
else if (aChunk[isSourceNode] || typeof aChunk === "string") {
|
||||
if (aChunk) {
|
||||
this.children.push(aChunk);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new TypeError(
|
||||
"Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
|
||||
);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a chunk of generated JS to the beginning of this source node.
|
||||
*
|
||||
* @param aChunk A string snippet of generated JS code, another instance of
|
||||
* SourceNode, or an array where each member is one of those things.
|
||||
*/
|
||||
SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
|
||||
if (Array.isArray(aChunk)) {
|
||||
for (var i = aChunk.length-1; i >= 0; i--) {
|
||||
this.prepend(aChunk[i]);
|
||||
}
|
||||
}
|
||||
else if (aChunk[isSourceNode] || typeof aChunk === "string") {
|
||||
this.children.unshift(aChunk);
|
||||
}
|
||||
else {
|
||||
throw new TypeError(
|
||||
"Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
|
||||
);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Walk over the tree of JS snippets in this node and its children. The
|
||||
* walking function is called once for each snippet of JS and is passed that
|
||||
* snippet and the its original associated source's line/column location.
|
||||
*
|
||||
* @param aFn The traversal function.
|
||||
*/
|
||||
SourceNode.prototype.walk = function SourceNode_walk(aFn) {
|
||||
var chunk;
|
||||
for (var i = 0, len = this.children.length; i < len; i++) {
|
||||
chunk = this.children[i];
|
||||
if (chunk[isSourceNode]) {
|
||||
chunk.walk(aFn);
|
||||
}
|
||||
else {
|
||||
if (chunk !== '') {
|
||||
aFn(chunk, { source: this.source,
|
||||
line: this.line,
|
||||
column: this.column,
|
||||
name: this.name });
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
|
||||
* each of `this.children`.
|
||||
*
|
||||
* @param aSep The separator.
|
||||
*/
|
||||
SourceNode.prototype.join = function SourceNode_join(aSep) {
|
||||
var newChildren;
|
||||
var i;
|
||||
var len = this.children.length;
|
||||
if (len > 0) {
|
||||
newChildren = [];
|
||||
for (i = 0; i < len-1; i++) {
|
||||
newChildren.push(this.children[i]);
|
||||
newChildren.push(aSep);
|
||||
}
|
||||
newChildren.push(this.children[i]);
|
||||
this.children = newChildren;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Call String.prototype.replace on the very right-most source snippet. Useful
|
||||
* for trimming whitespace from the end of a source node, etc.
|
||||
*
|
||||
* @param aPattern The pattern to replace.
|
||||
* @param aReplacement The thing to replace the pattern with.
|
||||
*/
|
||||
SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
|
||||
var lastChild = this.children[this.children.length - 1];
|
||||
if (lastChild[isSourceNode]) {
|
||||
lastChild.replaceRight(aPattern, aReplacement);
|
||||
}
|
||||
else if (typeof lastChild === 'string') {
|
||||
this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
|
||||
}
|
||||
else {
|
||||
this.children.push(''.replace(aPattern, aReplacement));
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the source content for a source file. This will be added to the SourceMapGenerator
|
||||
* in the sourcesContent field.
|
||||
*
|
||||
* @param aSourceFile The filename of the source file
|
||||
* @param aSourceContent The content of the source file
|
||||
*/
|
||||
SourceNode.prototype.setSourceContent =
|
||||
function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
|
||||
this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
|
||||
};
|
||||
|
||||
/**
|
||||
* Walk over the tree of SourceNodes. The walking function is called for each
|
||||
* source file content and is passed the filename and source content.
|
||||
*
|
||||
* @param aFn The traversal function.
|
||||
*/
|
||||
SourceNode.prototype.walkSourceContents =
|
||||
function SourceNode_walkSourceContents(aFn) {
|
||||
for (var i = 0, len = this.children.length; i < len; i++) {
|
||||
if (this.children[i][isSourceNode]) {
|
||||
this.children[i].walkSourceContents(aFn);
|
||||
}
|
||||
}
|
||||
|
||||
var sources = Object.keys(this.sourceContents);
|
||||
for (var i = 0, len = sources.length; i < len; i++) {
|
||||
aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the string representation of this source node. Walks over the tree
|
||||
* and concatenates all the various snippets together to one string.
|
||||
*/
|
||||
SourceNode.prototype.toString = function SourceNode_toString() {
|
||||
var str = "";
|
||||
this.walk(function (chunk) {
|
||||
str += chunk;
|
||||
});
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the string representation of this source node along with a source
|
||||
* map.
|
||||
*/
|
||||
SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
|
||||
var generated = {
|
||||
code: "",
|
||||
line: 1,
|
||||
column: 0
|
||||
};
|
||||
var map = new SourceMapGenerator(aArgs);
|
||||
var sourceMappingActive = false;
|
||||
var lastOriginalSource = null;
|
||||
var lastOriginalLine = null;
|
||||
var lastOriginalColumn = null;
|
||||
var lastOriginalName = null;
|
||||
this.walk(function (chunk, original) {
|
||||
generated.code += chunk;
|
||||
if (original.source !== null
|
||||
&& original.line !== null
|
||||
&& original.column !== null) {
|
||||
if(lastOriginalSource !== original.source
|
||||
|| lastOriginalLine !== original.line
|
||||
|| lastOriginalColumn !== original.column
|
||||
|| lastOriginalName !== original.name) {
|
||||
map.addMapping({
|
||||
source: original.source,
|
||||
original: {
|
||||
line: original.line,
|
||||
column: original.column
|
||||
},
|
||||
generated: {
|
||||
line: generated.line,
|
||||
column: generated.column
|
||||
},
|
||||
name: original.name
|
||||
});
|
||||
}
|
||||
lastOriginalSource = original.source;
|
||||
lastOriginalLine = original.line;
|
||||
lastOriginalColumn = original.column;
|
||||
lastOriginalName = original.name;
|
||||
sourceMappingActive = true;
|
||||
} else if (sourceMappingActive) {
|
||||
map.addMapping({
|
||||
generated: {
|
||||
line: generated.line,
|
||||
column: generated.column
|
||||
}
|
||||
});
|
||||
lastOriginalSource = null;
|
||||
sourceMappingActive = false;
|
||||
}
|
||||
for (var idx = 0, length = chunk.length; idx < length; idx++) {
|
||||
if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
|
||||
generated.line++;
|
||||
generated.column = 0;
|
||||
// Mappings end at eol
|
||||
if (idx + 1 === length) {
|
||||
lastOriginalSource = null;
|
||||
sourceMappingActive = false;
|
||||
} else if (sourceMappingActive) {
|
||||
map.addMapping({
|
||||
source: original.source,
|
||||
original: {
|
||||
line: original.line,
|
||||
column: original.column
|
||||
},
|
||||
generated: {
|
||||
line: generated.line,
|
||||
column: generated.column
|
||||
},
|
||||
name: original.name
|
||||
});
|
||||
}
|
||||
} else {
|
||||
generated.column++;
|
||||
}
|
||||
}
|
||||
});
|
||||
this.walkSourceContents(function (sourceFile, sourceContent) {
|
||||
map.setSourceContent(sourceFile, sourceContent);
|
||||
});
|
||||
|
||||
return { code: generated.code, map: map };
|
||||
};
|
||||
|
||||
exports.SourceNode = SourceNode;
|
||||
488
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/util.js
generated
vendored
Executable file
488
my-app/node_modules/resolve-url-loader/node_modules/source-map/lib/util.js
generated
vendored
Executable file
|
|
@ -0,0 +1,488 @@
|
|||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a helper function for getting values from parameter/options
|
||||
* objects.
|
||||
*
|
||||
* @param args The object we are extracting values from
|
||||
* @param name The name of the property we are getting.
|
||||
* @param defaultValue An optional value to return if the property is missing
|
||||
* from the object. If this is not specified and the property is missing, an
|
||||
* error will be thrown.
|
||||
*/
|
||||
function getArg(aArgs, aName, aDefaultValue) {
|
||||
if (aName in aArgs) {
|
||||
return aArgs[aName];
|
||||
} else if (arguments.length === 3) {
|
||||
return aDefaultValue;
|
||||
} else {
|
||||
throw new Error('"' + aName + '" is a required argument.');
|
||||
}
|
||||
}
|
||||
exports.getArg = getArg;
|
||||
|
||||
var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
|
||||
var dataUrlRegexp = /^data:.+\,.+$/;
|
||||
|
||||
function urlParse(aUrl) {
|
||||
var match = aUrl.match(urlRegexp);
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
scheme: match[1],
|
||||
auth: match[2],
|
||||
host: match[3],
|
||||
port: match[4],
|
||||
path: match[5]
|
||||
};
|
||||
}
|
||||
exports.urlParse = urlParse;
|
||||
|
||||
function urlGenerate(aParsedUrl) {
|
||||
var url = '';
|
||||
if (aParsedUrl.scheme) {
|
||||
url += aParsedUrl.scheme + ':';
|
||||
}
|
||||
url += '//';
|
||||
if (aParsedUrl.auth) {
|
||||
url += aParsedUrl.auth + '@';
|
||||
}
|
||||
if (aParsedUrl.host) {
|
||||
url += aParsedUrl.host;
|
||||
}
|
||||
if (aParsedUrl.port) {
|
||||
url += ":" + aParsedUrl.port
|
||||
}
|
||||
if (aParsedUrl.path) {
|
||||
url += aParsedUrl.path;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
exports.urlGenerate = urlGenerate;
|
||||
|
||||
/**
|
||||
* Normalizes a path, or the path portion of a URL:
|
||||
*
|
||||
* - Replaces consecutive slashes with one slash.
|
||||
* - Removes unnecessary '.' parts.
|
||||
* - Removes unnecessary '<dir>/..' parts.
|
||||
*
|
||||
* Based on code in the Node.js 'path' core module.
|
||||
*
|
||||
* @param aPath The path or url to normalize.
|
||||
*/
|
||||
function normalize(aPath) {
|
||||
var path = aPath;
|
||||
var url = urlParse(aPath);
|
||||
if (url) {
|
||||
if (!url.path) {
|
||||
return aPath;
|
||||
}
|
||||
path = url.path;
|
||||
}
|
||||
var isAbsolute = exports.isAbsolute(path);
|
||||
|
||||
var parts = path.split(/\/+/);
|
||||
for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
|
||||
part = parts[i];
|
||||
if (part === '.') {
|
||||
parts.splice(i, 1);
|
||||
} else if (part === '..') {
|
||||
up++;
|
||||
} else if (up > 0) {
|
||||
if (part === '') {
|
||||
// The first part is blank if the path is absolute. Trying to go
|
||||
// above the root is a no-op. Therefore we can remove all '..' parts
|
||||
// directly after the root.
|
||||
parts.splice(i + 1, up);
|
||||
up = 0;
|
||||
} else {
|
||||
parts.splice(i, 2);
|
||||
up--;
|
||||
}
|
||||
}
|
||||
}
|
||||
path = parts.join('/');
|
||||
|
||||
if (path === '') {
|
||||
path = isAbsolute ? '/' : '.';
|
||||
}
|
||||
|
||||
if (url) {
|
||||
url.path = path;
|
||||
return urlGenerate(url);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
exports.normalize = normalize;
|
||||
|
||||
/**
|
||||
* Joins two paths/URLs.
|
||||
*
|
||||
* @param aRoot The root path or URL.
|
||||
* @param aPath The path or URL to be joined with the root.
|
||||
*
|
||||
* - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
|
||||
* scheme-relative URL: Then the scheme of aRoot, if any, is prepended
|
||||
* first.
|
||||
* - Otherwise aPath is a path. If aRoot is a URL, then its path portion
|
||||
* is updated with the result and aRoot is returned. Otherwise the result
|
||||
* is returned.
|
||||
* - If aPath is absolute, the result is aPath.
|
||||
* - Otherwise the two paths are joined with a slash.
|
||||
* - Joining for example 'http://' and 'www.example.com' is also supported.
|
||||
*/
|
||||
function join(aRoot, aPath) {
|
||||
if (aRoot === "") {
|
||||
aRoot = ".";
|
||||
}
|
||||
if (aPath === "") {
|
||||
aPath = ".";
|
||||
}
|
||||
var aPathUrl = urlParse(aPath);
|
||||
var aRootUrl = urlParse(aRoot);
|
||||
if (aRootUrl) {
|
||||
aRoot = aRootUrl.path || '/';
|
||||
}
|
||||
|
||||
// `join(foo, '//www.example.org')`
|
||||
if (aPathUrl && !aPathUrl.scheme) {
|
||||
if (aRootUrl) {
|
||||
aPathUrl.scheme = aRootUrl.scheme;
|
||||
}
|
||||
return urlGenerate(aPathUrl);
|
||||
}
|
||||
|
||||
if (aPathUrl || aPath.match(dataUrlRegexp)) {
|
||||
return aPath;
|
||||
}
|
||||
|
||||
// `join('http://', 'www.example.com')`
|
||||
if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
|
||||
aRootUrl.host = aPath;
|
||||
return urlGenerate(aRootUrl);
|
||||
}
|
||||
|
||||
var joined = aPath.charAt(0) === '/'
|
||||
? aPath
|
||||
: normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
|
||||
|
||||
if (aRootUrl) {
|
||||
aRootUrl.path = joined;
|
||||
return urlGenerate(aRootUrl);
|
||||
}
|
||||
return joined;
|
||||
}
|
||||
exports.join = join;
|
||||
|
||||
exports.isAbsolute = function (aPath) {
|
||||
return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
|
||||
};
|
||||
|
||||
/**
|
||||
* Make a path relative to a URL or another path.
|
||||
*
|
||||
* @param aRoot The root path or URL.
|
||||
* @param aPath The path or URL to be made relative to aRoot.
|
||||
*/
|
||||
function relative(aRoot, aPath) {
|
||||
if (aRoot === "") {
|
||||
aRoot = ".";
|
||||
}
|
||||
|
||||
aRoot = aRoot.replace(/\/$/, '');
|
||||
|
||||
// It is possible for the path to be above the root. In this case, simply
|
||||
// checking whether the root is a prefix of the path won't work. Instead, we
|
||||
// need to remove components from the root one by one, until either we find
|
||||
// a prefix that fits, or we run out of components to remove.
|
||||
var level = 0;
|
||||
while (aPath.indexOf(aRoot + '/') !== 0) {
|
||||
var index = aRoot.lastIndexOf("/");
|
||||
if (index < 0) {
|
||||
return aPath;
|
||||
}
|
||||
|
||||
// If the only part of the root that is left is the scheme (i.e. http://,
|
||||
// file:///, etc.), one or more slashes (/), or simply nothing at all, we
|
||||
// have exhausted all components, so the path is not relative to the root.
|
||||
aRoot = aRoot.slice(0, index);
|
||||
if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
|
||||
return aPath;
|
||||
}
|
||||
|
||||
++level;
|
||||
}
|
||||
|
||||
// Make sure we add a "../" for each component we removed from the root.
|
||||
return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
|
||||
}
|
||||
exports.relative = relative;
|
||||
|
||||
var supportsNullProto = (function () {
|
||||
var obj = Object.create(null);
|
||||
return !('__proto__' in obj);
|
||||
}());
|
||||
|
||||
function identity (s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Because behavior goes wacky when you set `__proto__` on objects, we
|
||||
* have to prefix all the strings in our set with an arbitrary character.
|
||||
*
|
||||
* See https://github.com/mozilla/source-map/pull/31 and
|
||||
* https://github.com/mozilla/source-map/issues/30
|
||||
*
|
||||
* @param String aStr
|
||||
*/
|
||||
function toSetString(aStr) {
|
||||
if (isProtoString(aStr)) {
|
||||
return '$' + aStr;
|
||||
}
|
||||
|
||||
return aStr;
|
||||
}
|
||||
exports.toSetString = supportsNullProto ? identity : toSetString;
|
||||
|
||||
function fromSetString(aStr) {
|
||||
if (isProtoString(aStr)) {
|
||||
return aStr.slice(1);
|
||||
}
|
||||
|
||||
return aStr;
|
||||
}
|
||||
exports.fromSetString = supportsNullProto ? identity : fromSetString;
|
||||
|
||||
function isProtoString(s) {
|
||||
if (!s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var length = s.length;
|
||||
|
||||
if (length < 9 /* "__proto__".length */) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
|
||||
s.charCodeAt(length - 2) !== 95 /* '_' */ ||
|
||||
s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
|
||||
s.charCodeAt(length - 4) !== 116 /* 't' */ ||
|
||||
s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
|
||||
s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
|
||||
s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
|
||||
s.charCodeAt(length - 8) !== 95 /* '_' */ ||
|
||||
s.charCodeAt(length - 9) !== 95 /* '_' */) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = length - 10; i >= 0; i--) {
|
||||
if (s.charCodeAt(i) !== 36 /* '$' */) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparator between two mappings where the original positions are compared.
|
||||
*
|
||||
* Optionally pass in `true` as `onlyCompareGenerated` to consider two
|
||||
* mappings with the same original source/line/column, but different generated
|
||||
* line and column the same. Useful when searching for a mapping with a
|
||||
* stubbed out mapping.
|
||||
*/
|
||||
function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
|
||||
var cmp = strcmp(mappingA.source, mappingB.source);
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.originalLine - mappingB.originalLine;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
||||
if (cmp !== 0 || onlyCompareOriginal) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.generatedLine - mappingB.generatedLine;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
return strcmp(mappingA.name, mappingB.name);
|
||||
}
|
||||
exports.compareByOriginalPositions = compareByOriginalPositions;
|
||||
|
||||
/**
|
||||
* Comparator between two mappings with deflated source and name indices where
|
||||
* the generated positions are compared.
|
||||
*
|
||||
* Optionally pass in `true` as `onlyCompareGenerated` to consider two
|
||||
* mappings with the same generated line and column, but different
|
||||
* source/name/original line and column the same. Useful when searching for a
|
||||
* mapping with a stubbed out mapping.
|
||||
*/
|
||||
function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
|
||||
var cmp = mappingA.generatedLine - mappingB.generatedLine;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
||||
if (cmp !== 0 || onlyCompareGenerated) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = strcmp(mappingA.source, mappingB.source);
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.originalLine - mappingB.originalLine;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
return strcmp(mappingA.name, mappingB.name);
|
||||
}
|
||||
exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
|
||||
|
||||
function strcmp(aStr1, aStr2) {
|
||||
if (aStr1 === aStr2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (aStr1 === null) {
|
||||
return 1; // aStr2 !== null
|
||||
}
|
||||
|
||||
if (aStr2 === null) {
|
||||
return -1; // aStr1 !== null
|
||||
}
|
||||
|
||||
if (aStr1 > aStr2) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparator between two mappings with inflated source and name strings where
|
||||
* the generated positions are compared.
|
||||
*/
|
||||
function compareByGeneratedPositionsInflated(mappingA, mappingB) {
|
||||
var cmp = mappingA.generatedLine - mappingB.generatedLine;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = strcmp(mappingA.source, mappingB.source);
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.originalLine - mappingB.originalLine;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
return strcmp(mappingA.name, mappingB.name);
|
||||
}
|
||||
exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
|
||||
|
||||
/**
|
||||
* Strip any JSON XSSI avoidance prefix from the string (as documented
|
||||
* in the source maps specification), and then parse the string as
|
||||
* JSON.
|
||||
*/
|
||||
function parseSourceMapInput(str) {
|
||||
return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
|
||||
}
|
||||
exports.parseSourceMapInput = parseSourceMapInput;
|
||||
|
||||
/**
|
||||
* Compute the URL of a source given the the source root, the source's
|
||||
* URL, and the source map's URL.
|
||||
*/
|
||||
function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
|
||||
sourceURL = sourceURL || '';
|
||||
|
||||
if (sourceRoot) {
|
||||
// This follows what Chrome does.
|
||||
if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
|
||||
sourceRoot += '/';
|
||||
}
|
||||
// The spec says:
|
||||
// Line 4: An optional source root, useful for relocating source
|
||||
// files on a server or removing repeated values in the
|
||||
// “sources” entry. This value is prepended to the individual
|
||||
// entries in the “source” field.
|
||||
sourceURL = sourceRoot + sourceURL;
|
||||
}
|
||||
|
||||
// Historically, SourceMapConsumer did not take the sourceMapURL as
|
||||
// a parameter. This mode is still somewhat supported, which is why
|
||||
// this code block is conditional. However, it's preferable to pass
|
||||
// the source map URL to SourceMapConsumer, so that this function
|
||||
// can implement the source URL resolution algorithm as outlined in
|
||||
// the spec. This block is basically the equivalent of:
|
||||
// new URL(sourceURL, sourceMapURL).toString()
|
||||
// ... except it avoids using URL, which wasn't available in the
|
||||
// older releases of node still supported by this library.
|
||||
//
|
||||
// The spec says:
|
||||
// If the sources are not absolute URLs after prepending of the
|
||||
// “sourceRoot”, the sources are resolved relative to the
|
||||
// SourceMap (like resolving script src in a html document).
|
||||
if (sourceMapURL) {
|
||||
var parsed = urlParse(sourceMapURL);
|
||||
if (!parsed) {
|
||||
throw new Error("sourceMapURL could not be parsed");
|
||||
}
|
||||
if (parsed.path) {
|
||||
// Strip the last path component, but keep the "/".
|
||||
var index = parsed.path.lastIndexOf('/');
|
||||
if (index >= 0) {
|
||||
parsed.path = parsed.path.substring(0, index + 1);
|
||||
}
|
||||
}
|
||||
sourceURL = join(urlGenerate(parsed), sourceURL);
|
||||
}
|
||||
|
||||
return normalize(sourceURL);
|
||||
}
|
||||
exports.computeSourceURL = computeSourceURL;
|
||||
73
my-app/node_modules/resolve-url-loader/node_modules/source-map/package.json
generated
vendored
Executable file
73
my-app/node_modules/resolve-url-loader/node_modules/source-map/package.json
generated
vendored
Executable file
|
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
"name": "source-map",
|
||||
"description": "Generates and consumes source maps",
|
||||
"version": "0.6.1",
|
||||
"homepage": "https://github.com/mozilla/source-map",
|
||||
"author": "Nick Fitzgerald <nfitzgerald@mozilla.com>",
|
||||
"contributors": [
|
||||
"Tobias Koppers <tobias.koppers@googlemail.com>",
|
||||
"Duncan Beevers <duncan@dweebd.com>",
|
||||
"Stephen Crane <scrane@mozilla.com>",
|
||||
"Ryan Seddon <seddon.ryan@gmail.com>",
|
||||
"Miles Elam <miles.elam@deem.com>",
|
||||
"Mihai Bazon <mihai.bazon@gmail.com>",
|
||||
"Michael Ficarra <github.public.email@michael.ficarra.me>",
|
||||
"Todd Wolfson <todd@twolfson.com>",
|
||||
"Alexander Solovyov <alexander@solovyov.net>",
|
||||
"Felix Gnass <fgnass@gmail.com>",
|
||||
"Conrad Irwin <conrad.irwin@gmail.com>",
|
||||
"usrbincc <usrbincc@yahoo.com>",
|
||||
"David Glasser <glasser@davidglasser.net>",
|
||||
"Chase Douglas <chase@newrelic.com>",
|
||||
"Evan Wallace <evan.exe@gmail.com>",
|
||||
"Heather Arthur <fayearthur@gmail.com>",
|
||||
"Hugh Kennedy <hughskennedy@gmail.com>",
|
||||
"David Glasser <glasser@davidglasser.net>",
|
||||
"Simon Lydell <simon.lydell@gmail.com>",
|
||||
"Jmeas Smith <jellyes2@gmail.com>",
|
||||
"Michael Z Goddard <mzgoddard@gmail.com>",
|
||||
"azu <azu@users.noreply.github.com>",
|
||||
"John Gozde <john@gozde.ca>",
|
||||
"Adam Kirkton <akirkton@truefitinnovation.com>",
|
||||
"Chris Montgomery <christopher.montgomery@dowjones.com>",
|
||||
"J. Ryan Stinnett <jryans@gmail.com>",
|
||||
"Jack Herrington <jherrington@walmartlabs.com>",
|
||||
"Chris Truter <jeffpalentine@gmail.com>",
|
||||
"Daniel Espeset <daniel@danielespeset.com>",
|
||||
"Jamie Wong <jamie.lf.wong@gmail.com>",
|
||||
"Eddy Bruël <ejpbruel@mozilla.com>",
|
||||
"Hawken Rives <hawkrives@gmail.com>",
|
||||
"Gilad Peleg <giladp007@gmail.com>",
|
||||
"djchie <djchie.dev@gmail.com>",
|
||||
"Gary Ye <garysye@gmail.com>",
|
||||
"Nicolas Lalevée <nicolas.lalevee@hibnet.org>"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/mozilla/source-map.git"
|
||||
},
|
||||
"main": "./source-map.js",
|
||||
"files": [
|
||||
"source-map.js",
|
||||
"source-map.d.ts",
|
||||
"lib/",
|
||||
"dist/source-map.debug.js",
|
||||
"dist/source-map.js",
|
||||
"dist/source-map.min.js",
|
||||
"dist/source-map.min.js.map"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"license": "BSD-3-Clause",
|
||||
"scripts": {
|
||||
"test": "npm run build && node test/run-tests.js",
|
||||
"build": "webpack --color",
|
||||
"toc": "doctoc --title '## Table of Contents' README.md && doctoc --title '## Table of Contents' CONTRIBUTING.md"
|
||||
},
|
||||
"devDependencies": {
|
||||
"doctoc": "^0.15.0",
|
||||
"webpack": "^1.12.0"
|
||||
},
|
||||
"typings": "source-map"
|
||||
}
|
||||
98
my-app/node_modules/resolve-url-loader/node_modules/source-map/source-map.d.ts
generated
vendored
Executable file
98
my-app/node_modules/resolve-url-loader/node_modules/source-map/source-map.d.ts
generated
vendored
Executable file
|
|
@ -0,0 +1,98 @@
|
|||
export interface StartOfSourceMap {
|
||||
file?: string;
|
||||
sourceRoot?: string;
|
||||
}
|
||||
|
||||
export interface RawSourceMap extends StartOfSourceMap {
|
||||
version: string;
|
||||
sources: string[];
|
||||
names: string[];
|
||||
sourcesContent?: string[];
|
||||
mappings: string;
|
||||
}
|
||||
|
||||
export interface Position {
|
||||
line: number;
|
||||
column: number;
|
||||
}
|
||||
|
||||
export interface LineRange extends Position {
|
||||
lastColumn: number;
|
||||
}
|
||||
|
||||
export interface FindPosition extends Position {
|
||||
// SourceMapConsumer.GREATEST_LOWER_BOUND or SourceMapConsumer.LEAST_UPPER_BOUND
|
||||
bias?: number;
|
||||
}
|
||||
|
||||
export interface SourceFindPosition extends FindPosition {
|
||||
source: string;
|
||||
}
|
||||
|
||||
export interface MappedPosition extends Position {
|
||||
source: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface MappingItem {
|
||||
source: string;
|
||||
generatedLine: number;
|
||||
generatedColumn: number;
|
||||
originalLine: number;
|
||||
originalColumn: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export class SourceMapConsumer {
|
||||
static GENERATED_ORDER: number;
|
||||
static ORIGINAL_ORDER: number;
|
||||
|
||||
static GREATEST_LOWER_BOUND: number;
|
||||
static LEAST_UPPER_BOUND: number;
|
||||
|
||||
constructor(rawSourceMap: RawSourceMap);
|
||||
computeColumnSpans(): void;
|
||||
originalPositionFor(generatedPosition: FindPosition): MappedPosition;
|
||||
generatedPositionFor(originalPosition: SourceFindPosition): LineRange;
|
||||
allGeneratedPositionsFor(originalPosition: MappedPosition): Position[];
|
||||
hasContentsOfAllSources(): boolean;
|
||||
sourceContentFor(source: string, returnNullOnMissing?: boolean): string;
|
||||
eachMapping(callback: (mapping: MappingItem) => void, context?: any, order?: number): void;
|
||||
}
|
||||
|
||||
export interface Mapping {
|
||||
generated: Position;
|
||||
original: Position;
|
||||
source: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export class SourceMapGenerator {
|
||||
constructor(startOfSourceMap?: StartOfSourceMap);
|
||||
static fromSourceMap(sourceMapConsumer: SourceMapConsumer): SourceMapGenerator;
|
||||
addMapping(mapping: Mapping): void;
|
||||
setSourceContent(sourceFile: string, sourceContent: string): void;
|
||||
applySourceMap(sourceMapConsumer: SourceMapConsumer, sourceFile?: string, sourceMapPath?: string): void;
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
export interface CodeWithSourceMap {
|
||||
code: string;
|
||||
map: SourceMapGenerator;
|
||||
}
|
||||
|
||||
export class SourceNode {
|
||||
constructor();
|
||||
constructor(line: number, column: number, source: string);
|
||||
constructor(line: number, column: number, source: string, chunk?: string, name?: string);
|
||||
static fromStringWithSourceMap(code: string, sourceMapConsumer: SourceMapConsumer, relativePath?: string): SourceNode;
|
||||
add(chunk: string): void;
|
||||
prepend(chunk: string): void;
|
||||
setSourceContent(sourceFile: string, sourceContent: string): void;
|
||||
walk(fn: (chunk: string, mapping: MappedPosition) => void): void;
|
||||
walkSourceContents(fn: (file: string, content: string) => void): void;
|
||||
join(sep: string): SourceNode;
|
||||
replaceRight(pattern: string, replacement: string): SourceNode;
|
||||
toString(): string;
|
||||
toStringWithSourceMap(startOfSourceMap?: StartOfSourceMap): CodeWithSourceMap;
|
||||
}
|
||||
8
my-app/node_modules/resolve-url-loader/node_modules/source-map/source-map.js
generated
vendored
Executable file
8
my-app/node_modules/resolve-url-loader/node_modules/source-map/source-map.js
generated
vendored
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* Copyright 2009-2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE.txt or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
exports.SourceMapGenerator = require('./lib/source-map-generator').SourceMapGenerator;
|
||||
exports.SourceMapConsumer = require('./lib/source-map-consumer').SourceMapConsumer;
|
||||
exports.SourceNode = require('./lib/source-node').SourceNode;
|
||||
44
my-app/node_modules/resolve-url-loader/package.json
generated
vendored
Executable file
44
my-app/node_modules/resolve-url-loader/package.json
generated
vendored
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"name": "resolve-url-loader",
|
||||
"version": "5.0.0",
|
||||
"description": "Webpack loader that resolves relative paths in url() statements based on the original source file",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/bholloway/resolve-url-loader.git",
|
||||
"directory": "packages/resolve-url-loader"
|
||||
},
|
||||
"keywords": [
|
||||
"webpack",
|
||||
"loader",
|
||||
"css",
|
||||
"normalize",
|
||||
"rewrite",
|
||||
"resolve",
|
||||
"url",
|
||||
"sass",
|
||||
"relative",
|
||||
"file"
|
||||
],
|
||||
"author": "bholloway",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/bholloway/resolve-url-loader/issues"
|
||||
},
|
||||
"homepage": "https://github.com/bholloway/resolve-url-loader/tree/v5/packages/resolve-url-loader",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib/**/+([a-z-]).js",
|
||||
"docs/**/*.*"
|
||||
],
|
||||
"dependencies": {
|
||||
"adjust-sourcemap-loader": "^4.0.0",
|
||||
"convert-source-map": "^1.7.0",
|
||||
"loader-utils": "^2.0.0",
|
||||
"postcss": "^8.2.14",
|
||||
"source-map": "0.6.1"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue