This commit is contained in:
20
node_modules/tinycolor2/LICENSE
generated
vendored
Normal file
20
node_modules/tinycolor2/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright (c), Brian Grinstead, http://briangrinstead.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
492
node_modules/tinycolor2/README.md
generated
vendored
Normal file
492
node_modules/tinycolor2/README.md
generated
vendored
Normal file
@@ -0,0 +1,492 @@
|
||||
# TinyColor
|
||||
|
||||
## JavaScript color tooling
|
||||
|
||||
TinyColor is a small, fast library for color manipulation and conversion in JavaScript. It allows many forms of input, while providing color conversions and other color utility functions. It has no dependencies.
|
||||
|
||||
## Including in node
|
||||
|
||||
`tinycolor` can be installed from npm:
|
||||
|
||||
npm install tinycolor2
|
||||
|
||||
Then it can be used in your script like so:
|
||||
|
||||
```js
|
||||
var tinycolor = require("tinycolor2");
|
||||
var color = tinycolor("red");
|
||||
```
|
||||
|
||||
Or in a module like so:
|
||||
|
||||
```js
|
||||
import tinycolor from "tinycolor2";
|
||||
var color = tinycolor("red");
|
||||
```
|
||||
|
||||
## Including in a browser
|
||||
|
||||
The package can be bundled from npm, but if you prefer to download it locally you have two choices:
|
||||
|
||||
### ESM
|
||||
|
||||
It can be used as a module by downloading [npm/esm/tinycolor.js](https://github.com/bgrins/TinyColor/blob/master/npm/esm/tinycolor.js) or using https://esm.sh/tinycolor2.
|
||||
|
||||
```html
|
||||
<script type='module'>
|
||||
import tinycolor from "https://esm.sh/tinycolor2";
|
||||
var color = tinycolor("red");
|
||||
</script>
|
||||
```
|
||||
|
||||
### UMD
|
||||
|
||||
You can use it directly in a script tag by downloading the UMD file from [npm/cjs/tinycolor.js](https://github.com/bgrins/TinyColor/blob/master/npm/cjs/tinycolor.js):
|
||||
|
||||
```html
|
||||
<script type='text/javascript' src='tinycolor.js'></script>
|
||||
<script type='text/javascript'>
|
||||
var color = tinycolor("red");
|
||||
</script>
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Call `tinycolor(input)` or `new tinycolor(input)`, and you will have an object with the following properties. See Accepted String Input and Accepted Object Input below for more information about what is accepted.
|
||||
|
||||
## Accepted String Input
|
||||
|
||||
The string parsing is very permissive. It is meant to make typing a color as input as easy as possible. All commas, percentages, parenthesis are optional, and most input allow either 0-1, 0%-100%, or 0-n (where n is either 100, 255, or 360 depending on the value).
|
||||
|
||||
HSL and HSV both require either 0%-100% or 0-1 for the `S`/`L`/`V` properties. The `H` (hue) can have values between 0%-100% or 0-360.
|
||||
|
||||
RGB input requires either 0-255 or 0%-100%.
|
||||
|
||||
If you call `tinycolor.fromRatio`, RGB and Hue input can also accept 0-1.
|
||||
|
||||
Here are some examples of string input:
|
||||
|
||||
### Hex, 8-digit (RGBA) Hex
|
||||
```js
|
||||
tinycolor("#000");
|
||||
tinycolor("000");
|
||||
tinycolor("#369C");
|
||||
tinycolor("369C");
|
||||
tinycolor("#f0f0f6");
|
||||
tinycolor("f0f0f6");
|
||||
tinycolor("#f0f0f688");
|
||||
tinycolor("f0f0f688");
|
||||
```
|
||||
### RGB, RGBA
|
||||
```js
|
||||
tinycolor("rgb (255, 0, 0)");
|
||||
tinycolor("rgb 255 0 0");
|
||||
tinycolor("rgba (255, 0, 0, .5)");
|
||||
tinycolor({ r: 255, g: 0, b: 0 });
|
||||
tinycolor.fromRatio({ r: 1, g: 0, b: 0 });
|
||||
tinycolor.fromRatio({ r: .5, g: .5, b: .5 });
|
||||
```
|
||||
### HSL, HSLA
|
||||
```js
|
||||
tinycolor("hsl(0, 100%, 50%)");
|
||||
tinycolor("hsla(0, 100%, 50%, .5)");
|
||||
tinycolor("hsl(0, 100%, 50%)");
|
||||
tinycolor("hsl 0 1.0 0.5");
|
||||
tinycolor({ h: 0, s: 1, l: .5 });
|
||||
tinycolor.fromRatio({ h: 1, s: 0, l: 0 });
|
||||
tinycolor.fromRatio({ h: .5, s: .5, l: .5 });
|
||||
```
|
||||
### HSV, HSVA
|
||||
```js
|
||||
tinycolor("hsv(0, 100%, 100%)");
|
||||
tinycolor("hsva(0, 100%, 100%, .5)");
|
||||
tinycolor("hsv (0 100% 100%)");
|
||||
tinycolor("hsv 0 1 1");
|
||||
tinycolor({ h: 0, s: 100, v: 100 });
|
||||
tinycolor.fromRatio({ h: 1, s: 0, v: 0 });
|
||||
tinycolor.fromRatio({ h: .5, s: .5, v: .5 });
|
||||
```
|
||||
### Named
|
||||
|
||||
Case insenstive names are accepted, using the [list of colors in the CSS spec](https://www.w3.org/TR/css-color-4/#named-colors).
|
||||
|
||||
```js
|
||||
tinycolor("RED");
|
||||
tinycolor("blanchedalmond");
|
||||
tinycolor("darkblue");
|
||||
```
|
||||
### Accepted Object Input
|
||||
|
||||
If you are calling this from code, you may want to use object input. Here are some examples of the different types of accepted object inputs:
|
||||
|
||||
{ r: 255, g: 0, b: 0 }
|
||||
{ r: 255, g: 0, b: 0, a: .5 }
|
||||
{ h: 0, s: 100, l: 50 }
|
||||
{ h: 0, s: 100, v: 100 }
|
||||
|
||||
## Methods
|
||||
|
||||
### getFormat
|
||||
|
||||
Returns the format used to create the tinycolor instance
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.getFormat(); // "name"
|
||||
color = tinycolor({r:255, g:255, b:255});
|
||||
color.getFormat(); // "rgb"
|
||||
```
|
||||
|
||||
### getOriginalInput
|
||||
|
||||
Returns the input passed into the constructor used to create the tinycolor instance
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.getOriginalInput(); // "red"
|
||||
color = tinycolor({r:255, g:255, b:255});
|
||||
color.getOriginalInput(); // "{r: 255, g: 255, b: 255}"
|
||||
```
|
||||
|
||||
### isValid
|
||||
|
||||
Return a boolean indicating whether the color was successfully parsed. Note: if the color is not valid then it will act like `black` when being used with other methods.
|
||||
```js
|
||||
var color1 = tinycolor("red");
|
||||
color1.isValid(); // true
|
||||
color1.toHexString(); // "#ff0000"
|
||||
|
||||
var color2 = tinycolor("not a color");
|
||||
color2.isValid(); // false
|
||||
color2.toString(); // "#000000"
|
||||
```
|
||||
### getBrightness
|
||||
|
||||
Returns the perceived brightness of a color, from `0-255`, as defined by [Web Content Accessibility Guidelines (Version 1.0)](http://www.w3.org/TR/AERT#color-contrast).
|
||||
```js
|
||||
var color1 = tinycolor("#fff");
|
||||
color1.getBrightness(); // 255
|
||||
|
||||
var color2 = tinycolor("#000");
|
||||
color2.getBrightness(); // 0
|
||||
```
|
||||
### isLight
|
||||
|
||||
Return a boolean indicating whether the color's perceived brightness is light.
|
||||
```js
|
||||
var color1 = tinycolor("#fff");
|
||||
color1.isLight(); // true
|
||||
|
||||
var color2 = tinycolor("#000");
|
||||
color2.isLight(); // false
|
||||
```
|
||||
### isDark
|
||||
|
||||
Return a boolean indicating whether the color's perceived brightness is dark.
|
||||
```js
|
||||
var color1 = tinycolor("#fff");
|
||||
color1.isDark(); // false
|
||||
|
||||
var color2 = tinycolor("#000");
|
||||
color2.isDark(); // true
|
||||
```
|
||||
### getLuminance
|
||||
|
||||
Returns the perceived luminance of a color, from `0-1` as defined by [Web Content Accessibility Guidelines (Version 2.0).](http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef)
|
||||
```js
|
||||
var color1 = tinycolor("#fff");
|
||||
color1.getLuminance(); // 1
|
||||
|
||||
var color2 = tinycolor("#000");
|
||||
color2.getLuminance(); // 0
|
||||
```
|
||||
### getAlpha
|
||||
|
||||
Returns the alpha value of a color, from `0-1`.
|
||||
```js
|
||||
var color1 = tinycolor("rgba(255, 0, 0, .5)");
|
||||
color1.getAlpha(); // 0.5
|
||||
|
||||
var color2 = tinycolor("rgb(255, 0, 0)");
|
||||
color2.getAlpha(); // 1
|
||||
|
||||
var color3 = tinycolor("transparent");
|
||||
color3.getAlpha(); // 0
|
||||
```
|
||||
### setAlpha
|
||||
|
||||
Sets the alpha value on a current color. Accepted range is in between `0-1`.
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.getAlpha(); // 1
|
||||
color.setAlpha(.5);
|
||||
color.getAlpha(); // .5
|
||||
color.toRgbString(); // "rgba(255, 0, 0, .5)"
|
||||
```
|
||||
### String Representations
|
||||
|
||||
The following methods will return a property for the `alpha` value, which can be ignored: `toHsv`, `toHsl`, `toRgb`
|
||||
|
||||
### toHsv
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toHsv(); // { h: 0, s: 1, v: 1, a: 1 }
|
||||
```
|
||||
### toHsvString
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toHsvString(); // "hsv(0, 100%, 100%)"
|
||||
color.setAlpha(0.5);
|
||||
color.toHsvString(); // "hsva(0, 100%, 100%, 0.5)"
|
||||
```
|
||||
### toHsl
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toHsl(); // { h: 0, s: 1, l: 0.5, a: 1 }
|
||||
```
|
||||
### toHslString
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toHslString(); // "hsl(0, 100%, 50%)"
|
||||
color.setAlpha(0.5);
|
||||
color.toHslString(); // "hsla(0, 100%, 50%, 0.5)"
|
||||
```
|
||||
### toHex
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toHex(); // "ff0000"
|
||||
```
|
||||
### toHexString
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toHexString(); // "#ff0000"
|
||||
```
|
||||
### toHex8
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toHex8(); // "ff0000ff"
|
||||
```
|
||||
### toHex8String
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toHex8String(); // "#ff0000ff"
|
||||
```
|
||||
### toRgb
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toRgb(); // { r: 255, g: 0, b: 0, a: 1 }
|
||||
```
|
||||
### toRgbString
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toRgbString(); // "rgb(255, 0, 0)"
|
||||
color.setAlpha(0.5);
|
||||
color.toRgbString(); // "rgba(255, 0, 0, 0.5)"
|
||||
```
|
||||
### toPercentageRgb
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toPercentageRgb() // { r: "100%", g: "0%", b: "0%", a: 1 }
|
||||
```
|
||||
### toPercentageRgbString
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toPercentageRgbString(); // "rgb(100%, 0%, 0%)"
|
||||
color.setAlpha(0.5);
|
||||
color.toPercentageRgbString(); // "rgba(100%, 0%, 0%, 0.5)"
|
||||
```
|
||||
### toName
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toName(); // "red"
|
||||
```
|
||||
### toFilter
|
||||
```
|
||||
var color = tinycolor("red");
|
||||
color.toFilter(); // "progid:DXImageTransform.Microsoft.gradient(startColorstr=#ffff0000,endColorstr=#ffff0000)"
|
||||
```
|
||||
### toString
|
||||
|
||||
Print to a string, depending on the input format. You can also override this by passing one of `"rgb", "prgb", "hex6", "hex3", "hex8", "name", "hsl", "hsv"` into the function.
|
||||
```js
|
||||
var color1 = tinycolor("red");
|
||||
color1.toString(); // "red"
|
||||
color1.toString("hsv"); // "hsv(0, 100%, 100%)"
|
||||
|
||||
var color2 = tinycolor("rgb(255, 0, 0)");
|
||||
color2.toString(); // "rgb(255, 0, 0)"
|
||||
color2.setAlpha(.5);
|
||||
color2.toString(); // "rgba(255, 0, 0, 0.5)"
|
||||
```
|
||||
### Color Modification
|
||||
|
||||
These methods manipulate the current color, and return it for chaining. For instance:
|
||||
```js
|
||||
tinycolor("red").lighten().desaturate().toHexString() // "#f53d3d"
|
||||
```
|
||||
### lighten
|
||||
|
||||
`lighten: function(amount = 10) -> TinyColor`. Lighten the color a given amount, from 0 to 100. Providing 100 will always return white.
|
||||
```js
|
||||
tinycolor("#f00").lighten().toString(); // "#ff3333"
|
||||
tinycolor("#f00").lighten(100).toString(); // "#ffffff"
|
||||
```
|
||||
### brighten
|
||||
|
||||
`brighten: function(amount = 10) -> TinyColor`. Brighten the color a given amount, from 0 to 100.
|
||||
```js
|
||||
tinycolor("#f00").brighten().toString(); // "#ff1919"
|
||||
```
|
||||
### darken
|
||||
|
||||
`darken: function(amount = 10) -> TinyColor`. Darken the color a given amount, from 0 to 100. Providing 100 will always return black.
|
||||
```js
|
||||
tinycolor("#f00").darken().toString(); // "#cc0000"
|
||||
tinycolor("#f00").darken(100).toString(); // "#000000"
|
||||
```
|
||||
### desaturate
|
||||
|
||||
`desaturate: function(amount = 10) -> TinyColor`. Desaturate the color a given amount, from 0 to 100. Providing 100 will is the same as calling `greyscale`.
|
||||
```js
|
||||
tinycolor("#f00").desaturate().toString(); // "#f20d0d"
|
||||
tinycolor("#f00").desaturate(100).toString(); // "#808080"
|
||||
```
|
||||
### saturate
|
||||
|
||||
`saturate: function(amount = 10) -> TinyColor`. Saturate the color a given amount, from 0 to 100.
|
||||
```js
|
||||
tinycolor("hsl(0, 10%, 50%)").saturate().toString(); // "hsl(0, 20%, 50%)"
|
||||
```
|
||||
### greyscale
|
||||
|
||||
`greyscale: function() -> TinyColor`. Completely desaturates a color into greyscale. Same as calling `desaturate(100)`.
|
||||
```js
|
||||
tinycolor("#f00").greyscale().toString(); // "#808080"
|
||||
```
|
||||
### spin
|
||||
|
||||
`spin: function(amount = 0) -> TinyColor`. Spin the hue a given amount, from -360 to 360. Calling with 0, 360, or -360 will do nothing (since it sets the hue back to what it was before).
|
||||
```js
|
||||
tinycolor("#f00").spin(180).toString(); // "#00ffff"
|
||||
tinycolor("#f00").spin(-90).toString(); // "#7f00ff"
|
||||
tinycolor("#f00").spin(90).toString(); // "#80ff00"
|
||||
|
||||
// spin(0) and spin(360) do nothing
|
||||
tinycolor("#f00").spin(0).toString(); // "#ff0000"
|
||||
tinycolor("#f00").spin(360).toString(); // "#ff0000"
|
||||
```
|
||||
### Color Combinations
|
||||
|
||||
Combination functions return an array of TinyColor objects unless otherwise noted.
|
||||
|
||||
### analogous
|
||||
|
||||
`analogous: function(, results = 6, slices = 30) -> array<TinyColor>`.
|
||||
```js
|
||||
var colors = tinycolor("#f00").analogous();
|
||||
|
||||
colors.map(function(t) { return t.toHexString(); }); // [ "#ff0000", "#ff0066", "#ff0033", "#ff0000", "#ff3300", "#ff6600" ]
|
||||
```
|
||||
### monochromatic
|
||||
|
||||
`monochromatic: function(, results = 6) -> array<TinyColor>`.
|
||||
```js
|
||||
var colors = tinycolor("#f00").monochromatic();
|
||||
|
||||
colors.map(function(t) { return t.toHexString(); }); // [ "#ff0000", "#2a0000", "#550000", "#800000", "#aa0000", "#d40000" ]
|
||||
```
|
||||
### splitcomplement
|
||||
|
||||
`splitcomplement: function() -> array<TinyColor>`.
|
||||
```js
|
||||
var colors = tinycolor("#f00").splitcomplement();
|
||||
|
||||
colors.map(function(t) { return t.toHexString(); }); // [ "#ff0000", "#ccff00", "#0066ff" ]
|
||||
```
|
||||
### triad
|
||||
|
||||
`triad: function() -> array<TinyColor>`.
|
||||
```js
|
||||
var colors = tinycolor("#f00").triad();
|
||||
|
||||
colors.map(function(t) { return t.toHexString(); }); // [ "#ff0000", "#00ff00", "#0000ff" ]
|
||||
```
|
||||
### tetrad
|
||||
|
||||
`tetrad: function() -> array<TinyColor>`.
|
||||
```js
|
||||
var colors = tinycolor("#f00").tetrad();
|
||||
|
||||
colors.map(function(t) { return t.toHexString(); }); // [ "#ff0000", "#80ff00", "#00ffff", "#7f00ff" ]
|
||||
|
||||
```
|
||||
### complement
|
||||
|
||||
`complement: function() -> TinyColor`.
|
||||
```js
|
||||
tinycolor("#f00").complement().toHexString(); // "#00ffff"
|
||||
```
|
||||
## Color Utilities
|
||||
```js
|
||||
tinycolor.equals(color1, color2)
|
||||
tinycolor.mix(color1, color2, amount = 50)
|
||||
```
|
||||
### random
|
||||
|
||||
Returns a random color.
|
||||
```js
|
||||
var color = tinycolor.random();
|
||||
color.toRgb(); // "{r: 145, g: 40, b: 198, a: 1}"
|
||||
```
|
||||
|
||||
### Readability
|
||||
|
||||
TinyColor assesses readability based on the [Web Content Accessibility Guidelines (Version 2.0)](http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef).
|
||||
|
||||
#### readability
|
||||
|
||||
`readability: function(TinyColor, TinyColor) -> Object`.
|
||||
Returns the contrast ratio between two colors.
|
||||
```js
|
||||
tinycolor.readability("#000", "#000"); // 1
|
||||
tinycolor.readability("#000", "#111"); // 1.1121078324840545
|
||||
tinycolor.readability("#000", "#fff"); // 21
|
||||
```
|
||||
Use the values in your own calculations, or use one of the convenience functions below.
|
||||
|
||||
#### isReadable
|
||||
|
||||
`isReadable: function(TinyColor, TinyColor, Object) -> Boolean`. Ensure that foreground and background color combinations meet WCAG guidelines. `Object` is optional, defaulting to `{level: "AA",size: "small"}`. `level` can be `"AA"` or "AAA" and `size` can be `"small"` or `"large"`.
|
||||
|
||||
Here are links to read more about the [AA](http://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html) and [AAA](http://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast7.html) requirements.
|
||||
```js
|
||||
tinycolor.isReadable("#000", "#111", {}); // false
|
||||
tinycolor.isReadable("#ff0088", "#5c1a72",{level:"AA",size:"small"}); //false
|
||||
tinycolor.isReadable("#ff0088", "#5c1a72",{level:"AA",size:"large"}), //true
|
||||
```
|
||||
#### mostReadable
|
||||
|
||||
`mostReadable: function(TinyColor, [TinyColor, Tinycolor ...], Object) -> Boolean`.
|
||||
Given a base color and a list of possible foreground or background colors for that base, returns the most readable color.
|
||||
If none of the colors in the list is readable, `mostReadable` will return the better of black or white if `includeFallbackColors:true`.
|
||||
```js
|
||||
tinycolor.mostReadable("#000", ["#f00", "#0f0", "#00f"]).toHexString(); // "#00ff00"
|
||||
tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255"
|
||||
tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff"
|
||||
tinycolor.mostReadable("#ff0088", ["#2e0c3a"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString() // "#2e0c3a",
|
||||
tinycolor.mostReadable("#ff0088", ["#2e0c3a"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString() // "#000000",
|
||||
```
|
||||
See [index.html](https://github.com/bgrins/TinyColor/blob/master/index.html) in the project for a demo.
|
||||
|
||||
## Common operations
|
||||
|
||||
### clone
|
||||
|
||||
`clone: function() -> TinyColor`.
|
||||
Instantiate a new TinyColor object with the same color. Any changes to the new one won't affect the old one.
|
||||
```js
|
||||
var color1 = tinycolor("#F00");
|
||||
var color2 = color1.clone();
|
||||
color2.setAlpha(.5);
|
||||
|
||||
color1.toString(); // "#ff0000"
|
||||
color2.toString(); // "rgba(255, 0, 0, 0.5)"
|
||||
```
|
||||
3
node_modules/tinycolor2/cjs/package.json
generated
vendored
Normal file
3
node_modules/tinycolor2/cjs/package.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
||||
2191
node_modules/tinycolor2/cjs/test.js
generated
vendored
Normal file
2191
node_modules/tinycolor2/cjs/test.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
26
node_modules/tinycolor2/cjs/test_template.js
generated
vendored
Normal file
26
node_modules/tinycolor2/cjs/test_template.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
// This file is autogenerated.
|
||||
// Ideally it wouldn't exist, but it's here to test cjs in node
|
||||
// Changes should go into ./test.js, and if new assertions are needed
|
||||
// they'll need to be shimmed here as well
|
||||
const tinycolor = require("./tinycolor.js");
|
||||
const { Deno, testDefinitions } = require("@deno/shim-deno-test");
|
||||
async function runDenoTests() {
|
||||
for (const test of testDefinitions) {
|
||||
if (test.ignore) {
|
||||
console.log(`Ignoring ${test.name}`);
|
||||
continue;
|
||||
}
|
||||
console.log(`Running ${test.name}`);
|
||||
await test.fn();
|
||||
console.log(`> Passed ${test.name}`);
|
||||
}
|
||||
}
|
||||
(async () => {
|
||||
const { assertEquals, assert, assertThrows } = await import(
|
||||
"../deno_asserts@0.168.0.mjs"
|
||||
);
|
||||
|
||||
// CONTENT_GOES_HERE
|
||||
|
||||
runDenoTests();
|
||||
})();
|
||||
1188
node_modules/tinycolor2/cjs/tinycolor.js
generated
vendored
Normal file
1188
node_modules/tinycolor2/cjs/tinycolor.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
807
node_modules/tinycolor2/deno_asserts@0.168.0.mjs
generated
vendored
Normal file
807
node_modules/tinycolor2/deno_asserts@0.168.0.mjs
generated
vendored
Normal file
@@ -0,0 +1,807 @@
|
||||
// deno-fmt-ignore-file
|
||||
// deno-lint-ignore-file
|
||||
// This code was bundled using `deno bundle` and it's not recommended to edit it manually
|
||||
// Using `deno bundle https://deno.land/std@0.168.0/testing/asserts.ts > npm/deno_asserts@0.168.0.mjs`
|
||||
|
||||
const { Deno } = globalThis;
|
||||
const noColor = typeof Deno?.noColor === "boolean" ? Deno.noColor : true;
|
||||
let enabled = !noColor;
|
||||
function code(open, close) {
|
||||
return {
|
||||
open: `\x1b[${open.join(";")}m`,
|
||||
close: `\x1b[${close}m`,
|
||||
regexp: new RegExp(`\\x1b\\[${close}m`, "g")
|
||||
};
|
||||
}
|
||||
function run(str, code) {
|
||||
return enabled ? `${code.open}${str.replace(code.regexp, code.open)}${code.close}` : str;
|
||||
}
|
||||
function bold(str) {
|
||||
return run(str, code([
|
||||
1
|
||||
], 22));
|
||||
}
|
||||
function red(str) {
|
||||
return run(str, code([
|
||||
31
|
||||
], 39));
|
||||
}
|
||||
function green(str) {
|
||||
return run(str, code([
|
||||
32
|
||||
], 39));
|
||||
}
|
||||
function white(str) {
|
||||
return run(str, code([
|
||||
37
|
||||
], 39));
|
||||
}
|
||||
function gray(str) {
|
||||
return brightBlack(str);
|
||||
}
|
||||
function brightBlack(str) {
|
||||
return run(str, code([
|
||||
90
|
||||
], 39));
|
||||
}
|
||||
function bgRed(str) {
|
||||
return run(str, code([
|
||||
41
|
||||
], 49));
|
||||
}
|
||||
function bgGreen(str) {
|
||||
return run(str, code([
|
||||
42
|
||||
], 49));
|
||||
}
|
||||
const ANSI_PATTERN = new RegExp([
|
||||
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
||||
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
|
||||
].join("|"), "g");
|
||||
function stripColor(string) {
|
||||
return string.replace(ANSI_PATTERN, "");
|
||||
}
|
||||
var DiffType;
|
||||
(function(DiffType) {
|
||||
DiffType["removed"] = "removed";
|
||||
DiffType["common"] = "common";
|
||||
DiffType["added"] = "added";
|
||||
})(DiffType || (DiffType = {}));
|
||||
const REMOVED = 1;
|
||||
const COMMON = 2;
|
||||
const ADDED = 3;
|
||||
function createCommon(A, B, reverse) {
|
||||
const common = [];
|
||||
if (A.length === 0 || B.length === 0) return [];
|
||||
for(let i = 0; i < Math.min(A.length, B.length); i += 1){
|
||||
if (A[reverse ? A.length - i - 1 : i] === B[reverse ? B.length - i - 1 : i]) {
|
||||
common.push(A[reverse ? A.length - i - 1 : i]);
|
||||
} else {
|
||||
return common;
|
||||
}
|
||||
}
|
||||
return common;
|
||||
}
|
||||
function diff(A, B) {
|
||||
const prefixCommon = createCommon(A, B);
|
||||
const suffixCommon = createCommon(A.slice(prefixCommon.length), B.slice(prefixCommon.length), true).reverse();
|
||||
A = suffixCommon.length ? A.slice(prefixCommon.length, -suffixCommon.length) : A.slice(prefixCommon.length);
|
||||
B = suffixCommon.length ? B.slice(prefixCommon.length, -suffixCommon.length) : B.slice(prefixCommon.length);
|
||||
const swapped = B.length > A.length;
|
||||
[A, B] = swapped ? [
|
||||
B,
|
||||
A
|
||||
] : [
|
||||
A,
|
||||
B
|
||||
];
|
||||
const M = A.length;
|
||||
const N = B.length;
|
||||
if (!M && !N && !suffixCommon.length && !prefixCommon.length) return [];
|
||||
if (!N) {
|
||||
return [
|
||||
...prefixCommon.map((c)=>({
|
||||
type: DiffType.common,
|
||||
value: c
|
||||
})),
|
||||
...A.map((a)=>({
|
||||
type: swapped ? DiffType.added : DiffType.removed,
|
||||
value: a
|
||||
})),
|
||||
...suffixCommon.map((c)=>({
|
||||
type: DiffType.common,
|
||||
value: c
|
||||
}))
|
||||
];
|
||||
}
|
||||
const offset = N;
|
||||
const delta = M - N;
|
||||
const size = M + N + 1;
|
||||
const fp = Array.from({
|
||||
length: size
|
||||
}, ()=>({
|
||||
y: -1,
|
||||
id: -1
|
||||
}));
|
||||
const routes = new Uint32Array((M * N + size + 1) * 2);
|
||||
const diffTypesPtrOffset = routes.length / 2;
|
||||
let ptr = 0;
|
||||
let p = -1;
|
||||
function backTrace(A, B, current, swapped) {
|
||||
const M = A.length;
|
||||
const N = B.length;
|
||||
const result = [];
|
||||
let a = M - 1;
|
||||
let b = N - 1;
|
||||
let j = routes[current.id];
|
||||
let type = routes[current.id + diffTypesPtrOffset];
|
||||
while(true){
|
||||
if (!j && !type) break;
|
||||
const prev = j;
|
||||
if (type === 1) {
|
||||
result.unshift({
|
||||
type: swapped ? DiffType.removed : DiffType.added,
|
||||
value: B[b]
|
||||
});
|
||||
b -= 1;
|
||||
} else if (type === 3) {
|
||||
result.unshift({
|
||||
type: swapped ? DiffType.added : DiffType.removed,
|
||||
value: A[a]
|
||||
});
|
||||
a -= 1;
|
||||
} else {
|
||||
result.unshift({
|
||||
type: DiffType.common,
|
||||
value: A[a]
|
||||
});
|
||||
a -= 1;
|
||||
b -= 1;
|
||||
}
|
||||
j = routes[prev];
|
||||
type = routes[prev + diffTypesPtrOffset];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function createFP(slide, down, k, M) {
|
||||
if (slide && slide.y === -1 && down && down.y === -1) {
|
||||
return {
|
||||
y: 0,
|
||||
id: 0
|
||||
};
|
||||
}
|
||||
if (down && down.y === -1 || k === M || (slide && slide.y) > (down && down.y) + 1) {
|
||||
const prev = slide.id;
|
||||
ptr++;
|
||||
routes[ptr] = prev;
|
||||
routes[ptr + diffTypesPtrOffset] = ADDED;
|
||||
return {
|
||||
y: slide.y,
|
||||
id: ptr
|
||||
};
|
||||
} else {
|
||||
const prev1 = down.id;
|
||||
ptr++;
|
||||
routes[ptr] = prev1;
|
||||
routes[ptr + diffTypesPtrOffset] = REMOVED;
|
||||
return {
|
||||
y: down.y + 1,
|
||||
id: ptr
|
||||
};
|
||||
}
|
||||
}
|
||||
function snake(k, slide, down, _offset, A, B) {
|
||||
const M = A.length;
|
||||
const N = B.length;
|
||||
if (k < -N || M < k) return {
|
||||
y: -1,
|
||||
id: -1
|
||||
};
|
||||
const fp = createFP(slide, down, k, M);
|
||||
while(fp.y + k < M && fp.y < N && A[fp.y + k] === B[fp.y]){
|
||||
const prev = fp.id;
|
||||
ptr++;
|
||||
fp.id = ptr;
|
||||
fp.y += 1;
|
||||
routes[ptr] = prev;
|
||||
routes[ptr + diffTypesPtrOffset] = COMMON;
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
while(fp[delta + offset].y < N){
|
||||
p = p + 1;
|
||||
for(let k = -p; k < delta; ++k){
|
||||
fp[k + offset] = snake(k, fp[k - 1 + offset], fp[k + 1 + offset], offset, A, B);
|
||||
}
|
||||
for(let k1 = delta + p; k1 > delta; --k1){
|
||||
fp[k1 + offset] = snake(k1, fp[k1 - 1 + offset], fp[k1 + 1 + offset], offset, A, B);
|
||||
}
|
||||
fp[delta + offset] = snake(delta, fp[delta - 1 + offset], fp[delta + 1 + offset], offset, A, B);
|
||||
}
|
||||
return [
|
||||
...prefixCommon.map((c)=>({
|
||||
type: DiffType.common,
|
||||
value: c
|
||||
})),
|
||||
...backTrace(A, B, fp[delta + offset], swapped),
|
||||
...suffixCommon.map((c)=>({
|
||||
type: DiffType.common,
|
||||
value: c
|
||||
}))
|
||||
];
|
||||
}
|
||||
function diffstr(A, B) {
|
||||
function unescape(string) {
|
||||
return string.replaceAll("\b", "\\b").replaceAll("\f", "\\f").replaceAll("\t", "\\t").replaceAll("\v", "\\v").replaceAll(/\r\n|\r|\n/g, (str)=>str === "\r" ? "\\r" : str === "\n" ? "\\n\n" : "\\r\\n\r\n");
|
||||
}
|
||||
function tokenize(string, { wordDiff =false } = {}) {
|
||||
if (wordDiff) {
|
||||
const tokens = string.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/);
|
||||
const words = /^[a-zA-Z\u{C0}-\u{FF}\u{D8}-\u{F6}\u{F8}-\u{2C6}\u{2C8}-\u{2D7}\u{2DE}-\u{2FF}\u{1E00}-\u{1EFF}]+$/u;
|
||||
for(let i = 0; i < tokens.length - 1; i++){
|
||||
if (!tokens[i + 1] && tokens[i + 2] && words.test(tokens[i]) && words.test(tokens[i + 2])) {
|
||||
tokens[i] += tokens[i + 2];
|
||||
tokens.splice(i + 1, 2);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
return tokens.filter((token)=>token);
|
||||
} else {
|
||||
const tokens1 = [], lines = string.split(/(\n|\r\n)/);
|
||||
if (!lines[lines.length - 1]) {
|
||||
lines.pop();
|
||||
}
|
||||
for(let i1 = 0; i1 < lines.length; i1++){
|
||||
if (i1 % 2) {
|
||||
tokens1[tokens1.length - 1] += lines[i1];
|
||||
} else {
|
||||
tokens1.push(lines[i1]);
|
||||
}
|
||||
}
|
||||
return tokens1;
|
||||
}
|
||||
}
|
||||
function createDetails(line, tokens) {
|
||||
return tokens.filter(({ type })=>type === line.type || type === DiffType.common).map((result, i, t)=>{
|
||||
if (result.type === DiffType.common && t[i - 1] && t[i - 1]?.type === t[i + 1]?.type && /\s+/.test(result.value)) {
|
||||
result.type = t[i - 1].type;
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
const diffResult = diff(tokenize(`${unescape(A)}\n`), tokenize(`${unescape(B)}\n`));
|
||||
const added = [], removed = [];
|
||||
for (const result of diffResult){
|
||||
if (result.type === DiffType.added) {
|
||||
added.push(result);
|
||||
}
|
||||
if (result.type === DiffType.removed) {
|
||||
removed.push(result);
|
||||
}
|
||||
}
|
||||
const aLines = added.length < removed.length ? added : removed;
|
||||
const bLines = aLines === removed ? added : removed;
|
||||
for (const a of aLines){
|
||||
let tokens = [], b;
|
||||
while(bLines.length){
|
||||
b = bLines.shift();
|
||||
tokens = diff(tokenize(a.value, {
|
||||
wordDiff: true
|
||||
}), tokenize(b?.value ?? "", {
|
||||
wordDiff: true
|
||||
}));
|
||||
if (tokens.some(({ type , value })=>type === DiffType.common && value.trim().length)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
a.details = createDetails(a, tokens);
|
||||
if (b) {
|
||||
b.details = createDetails(b, tokens);
|
||||
}
|
||||
}
|
||||
return diffResult;
|
||||
}
|
||||
function createColor(diffType, { background =false } = {}) {
|
||||
background = false;
|
||||
switch(diffType){
|
||||
case DiffType.added:
|
||||
return (s)=>background ? bgGreen(white(s)) : green(bold(s));
|
||||
case DiffType.removed:
|
||||
return (s)=>background ? bgRed(white(s)) : red(bold(s));
|
||||
default:
|
||||
return white;
|
||||
}
|
||||
}
|
||||
function createSign(diffType) {
|
||||
switch(diffType){
|
||||
case DiffType.added:
|
||||
return "+ ";
|
||||
case DiffType.removed:
|
||||
return "- ";
|
||||
default:
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
function buildMessage(diffResult, { stringDiff =false } = {}) {
|
||||
const messages = [], diffMessages = [];
|
||||
messages.push("");
|
||||
messages.push("");
|
||||
messages.push(` ${gray(bold("[Diff]"))} ${red(bold("Actual"))} / ${green(bold("Expected"))}`);
|
||||
messages.push("");
|
||||
messages.push("");
|
||||
diffResult.forEach((result)=>{
|
||||
const c = createColor(result.type);
|
||||
const line = result.details?.map((detail)=>detail.type !== DiffType.common ? createColor(detail.type, {
|
||||
background: true
|
||||
})(detail.value) : detail.value).join("") ?? result.value;
|
||||
diffMessages.push(c(`${createSign(result.type)}${line}`));
|
||||
});
|
||||
messages.push(...stringDiff ? [
|
||||
diffMessages.join("")
|
||||
] : diffMessages);
|
||||
messages.push("");
|
||||
return messages;
|
||||
}
|
||||
function format(v) {
|
||||
const { Deno } = globalThis;
|
||||
return typeof Deno?.inspect === "function" ? Deno.inspect(v, {
|
||||
depth: Infinity,
|
||||
sorted: true,
|
||||
trailingComma: true,
|
||||
compact: false,
|
||||
iterableLimit: Infinity,
|
||||
getters: true
|
||||
}) : `"${String(v).replace(/(?=["\\])/g, "\\")}"`;
|
||||
}
|
||||
const CAN_NOT_DISPLAY = "[Cannot display]";
|
||||
class AssertionError extends Error {
|
||||
name = "AssertionError";
|
||||
constructor(message){
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
function isKeyedCollection(x) {
|
||||
return [
|
||||
Symbol.iterator,
|
||||
"size"
|
||||
].every((k)=>k in x);
|
||||
}
|
||||
function equal(c, d) {
|
||||
const seen = new Map();
|
||||
return function compare(a, b) {
|
||||
if (a && b && (a instanceof RegExp && b instanceof RegExp || a instanceof URL && b instanceof URL)) {
|
||||
return String(a) === String(b);
|
||||
}
|
||||
if (a instanceof Date && b instanceof Date) {
|
||||
const aTime = a.getTime();
|
||||
const bTime = b.getTime();
|
||||
if (Number.isNaN(aTime) && Number.isNaN(bTime)) {
|
||||
return true;
|
||||
}
|
||||
return aTime === bTime;
|
||||
}
|
||||
if (typeof a === "number" && typeof b === "number") {
|
||||
return Number.isNaN(a) && Number.isNaN(b) || a === b;
|
||||
}
|
||||
if (Object.is(a, b)) {
|
||||
return true;
|
||||
}
|
||||
if (a && typeof a === "object" && b && typeof b === "object") {
|
||||
if (a && b && !constructorsEqual(a, b)) {
|
||||
return false;
|
||||
}
|
||||
if (a instanceof WeakMap || b instanceof WeakMap) {
|
||||
if (!(a instanceof WeakMap && b instanceof WeakMap)) return false;
|
||||
throw new TypeError("cannot compare WeakMap instances");
|
||||
}
|
||||
if (a instanceof WeakSet || b instanceof WeakSet) {
|
||||
if (!(a instanceof WeakSet && b instanceof WeakSet)) return false;
|
||||
throw new TypeError("cannot compare WeakSet instances");
|
||||
}
|
||||
if (seen.get(a) === b) {
|
||||
return true;
|
||||
}
|
||||
if (Object.keys(a || {}).length !== Object.keys(b || {}).length) {
|
||||
return false;
|
||||
}
|
||||
seen.set(a, b);
|
||||
if (isKeyedCollection(a) && isKeyedCollection(b)) {
|
||||
if (a.size !== b.size) {
|
||||
return false;
|
||||
}
|
||||
let unmatchedEntries = a.size;
|
||||
for (const [aKey, aValue] of a.entries()){
|
||||
for (const [bKey, bValue] of b.entries()){
|
||||
if (aKey === aValue && bKey === bValue && compare(aKey, bKey) || compare(aKey, bKey) && compare(aValue, bValue)) {
|
||||
unmatchedEntries--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return unmatchedEntries === 0;
|
||||
}
|
||||
const merged = {
|
||||
...a,
|
||||
...b
|
||||
};
|
||||
for (const key of [
|
||||
...Object.getOwnPropertyNames(merged),
|
||||
...Object.getOwnPropertySymbols(merged)
|
||||
]){
|
||||
if (!compare(a && a[key], b && b[key])) {
|
||||
return false;
|
||||
}
|
||||
if (key in a && !(key in b) || key in b && !(key in a)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (a instanceof WeakRef || b instanceof WeakRef) {
|
||||
if (!(a instanceof WeakRef && b instanceof WeakRef)) return false;
|
||||
return compare(a.deref(), b.deref());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}(c, d);
|
||||
}
|
||||
function constructorsEqual(a, b) {
|
||||
return a.constructor === b.constructor || a.constructor === Object && !b.constructor || !a.constructor && b.constructor === Object;
|
||||
}
|
||||
function assert(expr, msg = "") {
|
||||
if (!expr) {
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
}
|
||||
function assertFalse(expr, msg = "") {
|
||||
if (expr) {
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
}
|
||||
function assertEquals(actual, expected, msg) {
|
||||
if (equal(actual, expected)) {
|
||||
return;
|
||||
}
|
||||
let message = "";
|
||||
const actualString = format(actual);
|
||||
const expectedString = format(expected);
|
||||
try {
|
||||
const stringDiff = typeof actual === "string" && typeof expected === "string";
|
||||
const diffResult = stringDiff ? diffstr(actual, expected) : diff(actualString.split("\n"), expectedString.split("\n"));
|
||||
const diffMsg = buildMessage(diffResult, {
|
||||
stringDiff
|
||||
}).join("\n");
|
||||
message = `Values are not equal:\n${diffMsg}`;
|
||||
} catch {
|
||||
message = `\n${red(CAN_NOT_DISPLAY)} + \n\n`;
|
||||
}
|
||||
if (msg) {
|
||||
message = msg;
|
||||
}
|
||||
throw new AssertionError(message);
|
||||
}
|
||||
function assertNotEquals(actual, expected, msg) {
|
||||
if (!equal(actual, expected)) {
|
||||
return;
|
||||
}
|
||||
let actualString;
|
||||
let expectedString;
|
||||
try {
|
||||
actualString = String(actual);
|
||||
} catch {
|
||||
actualString = "[Cannot display]";
|
||||
}
|
||||
try {
|
||||
expectedString = String(expected);
|
||||
} catch {
|
||||
expectedString = "[Cannot display]";
|
||||
}
|
||||
if (!msg) {
|
||||
msg = `actual: ${actualString} expected not to be: ${expectedString}`;
|
||||
}
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
function assertStrictEquals(actual, expected, msg) {
|
||||
if (Object.is(actual, expected)) {
|
||||
return;
|
||||
}
|
||||
let message;
|
||||
if (msg) {
|
||||
message = msg;
|
||||
} else {
|
||||
const actualString = format(actual);
|
||||
const expectedString = format(expected);
|
||||
if (actualString === expectedString) {
|
||||
const withOffset = actualString.split("\n").map((l)=>` ${l}`).join("\n");
|
||||
message = `Values have the same structure but are not reference-equal:\n\n${red(withOffset)}\n`;
|
||||
} else {
|
||||
try {
|
||||
const stringDiff = typeof actual === "string" && typeof expected === "string";
|
||||
const diffResult = stringDiff ? diffstr(actual, expected) : diff(actualString.split("\n"), expectedString.split("\n"));
|
||||
const diffMsg = buildMessage(diffResult, {
|
||||
stringDiff
|
||||
}).join("\n");
|
||||
message = `Values are not strictly equal:\n${diffMsg}`;
|
||||
} catch {
|
||||
message = `\n${red(CAN_NOT_DISPLAY)} + \n\n`;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new AssertionError(message);
|
||||
}
|
||||
function assertNotStrictEquals(actual, expected, msg) {
|
||||
if (!Object.is(actual, expected)) {
|
||||
return;
|
||||
}
|
||||
throw new AssertionError(msg ?? `Expected "actual" to be strictly unequal to: ${format(actual)}\n`);
|
||||
}
|
||||
function assertAlmostEquals(actual, expected, tolerance = 1e-7, msg) {
|
||||
if (Object.is(actual, expected)) {
|
||||
return;
|
||||
}
|
||||
const delta = Math.abs(expected - actual);
|
||||
if (delta <= tolerance) {
|
||||
return;
|
||||
}
|
||||
const f = (n)=>Number.isInteger(n) ? n : n.toExponential();
|
||||
throw new AssertionError(msg ?? `actual: "${f(actual)}" expected to be close to "${f(expected)}": \
|
||||
delta "${f(delta)}" is greater than "${f(tolerance)}"`);
|
||||
}
|
||||
function assertInstanceOf(actual, expectedType, msg = "") {
|
||||
if (!msg) {
|
||||
const expectedTypeStr = expectedType.name;
|
||||
let actualTypeStr = "";
|
||||
if (actual === null) {
|
||||
actualTypeStr = "null";
|
||||
} else if (actual === undefined) {
|
||||
actualTypeStr = "undefined";
|
||||
} else if (typeof actual === "object") {
|
||||
actualTypeStr = actual.constructor?.name ?? "Object";
|
||||
} else {
|
||||
actualTypeStr = typeof actual;
|
||||
}
|
||||
if (expectedTypeStr == actualTypeStr) {
|
||||
msg = `Expected object to be an instance of "${expectedTypeStr}".`;
|
||||
} else if (actualTypeStr == "function") {
|
||||
msg = `Expected object to be an instance of "${expectedTypeStr}" but was not an instanced object.`;
|
||||
} else {
|
||||
msg = `Expected object to be an instance of "${expectedTypeStr}" but was "${actualTypeStr}".`;
|
||||
}
|
||||
}
|
||||
assert(actual instanceof expectedType, msg);
|
||||
}
|
||||
function assertNotInstanceOf(actual, unexpectedType, msg = `Expected object to not be an instance of "${typeof unexpectedType}"`) {
|
||||
assertFalse(actual instanceof unexpectedType, msg);
|
||||
}
|
||||
function assertExists(actual, msg) {
|
||||
if (actual === undefined || actual === null) {
|
||||
if (!msg) {
|
||||
msg = `actual: "${actual}" expected to not be null or undefined`;
|
||||
}
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
}
|
||||
function assertStringIncludes(actual, expected, msg) {
|
||||
if (!actual.includes(expected)) {
|
||||
if (!msg) {
|
||||
msg = `actual: "${actual}" expected to contain: "${expected}"`;
|
||||
}
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
}
|
||||
function assertArrayIncludes(actual, expected, msg) {
|
||||
const missing = [];
|
||||
for(let i = 0; i < expected.length; i++){
|
||||
let found = false;
|
||||
for(let j = 0; j < actual.length; j++){
|
||||
if (equal(expected[i], actual[j])) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
missing.push(expected[i]);
|
||||
}
|
||||
}
|
||||
if (missing.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (!msg) {
|
||||
msg = `actual: "${format(actual)}" expected to include: "${format(expected)}"\nmissing: ${format(missing)}`;
|
||||
}
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
function assertMatch(actual, expected, msg) {
|
||||
if (!expected.test(actual)) {
|
||||
if (!msg) {
|
||||
msg = `actual: "${actual}" expected to match: "${expected}"`;
|
||||
}
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
}
|
||||
function assertNotMatch(actual, expected, msg) {
|
||||
if (expected.test(actual)) {
|
||||
if (!msg) {
|
||||
msg = `actual: "${actual}" expected to not match: "${expected}"`;
|
||||
}
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
}
|
||||
function assertObjectMatch(actual, expected) {
|
||||
function filter(a, b) {
|
||||
const seen = new WeakMap();
|
||||
return fn(a, b);
|
||||
function fn(a, b) {
|
||||
if (seen.has(a) && seen.get(a) === b) {
|
||||
return a;
|
||||
}
|
||||
seen.set(a, b);
|
||||
const filtered = {};
|
||||
const entries = [
|
||||
...Object.getOwnPropertyNames(a),
|
||||
...Object.getOwnPropertySymbols(a)
|
||||
].filter((key)=>key in b).map((key)=>[
|
||||
key,
|
||||
a[key]
|
||||
]);
|
||||
for (const [key, value] of entries){
|
||||
if (Array.isArray(value)) {
|
||||
const subset = b[key];
|
||||
if (Array.isArray(subset)) {
|
||||
filtered[key] = fn({
|
||||
...value
|
||||
}, {
|
||||
...subset
|
||||
});
|
||||
continue;
|
||||
}
|
||||
} else if (value instanceof RegExp) {
|
||||
filtered[key] = value;
|
||||
continue;
|
||||
} else if (typeof value === "object") {
|
||||
const subset1 = b[key];
|
||||
if (typeof subset1 === "object" && subset1) {
|
||||
if (value instanceof Map && subset1 instanceof Map) {
|
||||
filtered[key] = new Map([
|
||||
...value
|
||||
].filter(([k])=>subset1.has(k)).map(([k, v])=>[
|
||||
k,
|
||||
typeof v === "object" ? fn(v, subset1.get(k)) : v
|
||||
]));
|
||||
continue;
|
||||
}
|
||||
if (value instanceof Set && subset1 instanceof Set) {
|
||||
filtered[key] = new Set([
|
||||
...value
|
||||
].filter((v)=>subset1.has(v)));
|
||||
continue;
|
||||
}
|
||||
filtered[key] = fn(value, subset1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
filtered[key] = value;
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
}
|
||||
return assertEquals(filter(actual, expected), filter(expected, expected));
|
||||
}
|
||||
function fail(msg) {
|
||||
assert(false, `Failed assertion${msg ? `: ${msg}` : "."}`);
|
||||
}
|
||||
function assertIsError(error, ErrorClass, msgIncludes, msg) {
|
||||
if (error instanceof Error === false) {
|
||||
throw new AssertionError(`Expected "error" to be an Error object.`);
|
||||
}
|
||||
if (ErrorClass && !(error instanceof ErrorClass)) {
|
||||
msg = `Expected error to be instance of "${ErrorClass.name}", but was "${typeof error === "object" ? error?.constructor?.name : "[not an object]"}"${msg ? `: ${msg}` : "."}`;
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
if (msgIncludes && (!(error instanceof Error) || !stripColor(error.message).includes(stripColor(msgIncludes)))) {
|
||||
msg = `Expected error message to include "${msgIncludes}", but got "${error instanceof Error ? error.message : "[not an Error]"}"${msg ? `: ${msg}` : "."}`;
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
}
|
||||
function assertThrows(fn, errorClassOrMsg, msgIncludesOrMsg, msg) {
|
||||
let ErrorClass = undefined;
|
||||
let msgIncludes = undefined;
|
||||
let err;
|
||||
if (typeof errorClassOrMsg !== "string") {
|
||||
if (errorClassOrMsg === undefined || errorClassOrMsg.prototype instanceof Error || errorClassOrMsg.prototype === Error.prototype) {
|
||||
ErrorClass = errorClassOrMsg;
|
||||
msgIncludes = msgIncludesOrMsg;
|
||||
} else {
|
||||
msg = msgIncludesOrMsg;
|
||||
}
|
||||
} else {
|
||||
msg = errorClassOrMsg;
|
||||
}
|
||||
let doesThrow = false;
|
||||
const msgToAppendToError = msg ? `: ${msg}` : ".";
|
||||
try {
|
||||
fn();
|
||||
} catch (error) {
|
||||
if (ErrorClass) {
|
||||
if (error instanceof Error === false) {
|
||||
throw new AssertionError("A non-Error object was thrown.");
|
||||
}
|
||||
assertIsError(error, ErrorClass, msgIncludes, msg);
|
||||
}
|
||||
err = error;
|
||||
doesThrow = true;
|
||||
}
|
||||
if (!doesThrow) {
|
||||
msg = `Expected function to throw${msgToAppendToError}`;
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
async function assertRejects(fn, errorClassOrMsg, msgIncludesOrMsg, msg) {
|
||||
let ErrorClass = undefined;
|
||||
let msgIncludes = undefined;
|
||||
let err;
|
||||
if (typeof errorClassOrMsg !== "string") {
|
||||
if (errorClassOrMsg === undefined || errorClassOrMsg.prototype instanceof Error || errorClassOrMsg.prototype === Error.prototype) {
|
||||
ErrorClass = errorClassOrMsg;
|
||||
msgIncludes = msgIncludesOrMsg;
|
||||
}
|
||||
} else {
|
||||
msg = errorClassOrMsg;
|
||||
}
|
||||
let doesThrow = false;
|
||||
let isPromiseReturned = false;
|
||||
const msgToAppendToError = msg ? `: ${msg}` : ".";
|
||||
try {
|
||||
const possiblePromise = fn();
|
||||
if (possiblePromise && typeof possiblePromise === "object" && typeof possiblePromise.then === "function") {
|
||||
isPromiseReturned = true;
|
||||
await possiblePromise;
|
||||
}
|
||||
} catch (error) {
|
||||
if (!isPromiseReturned) {
|
||||
throw new AssertionError(`Function throws when expected to reject${msgToAppendToError}`);
|
||||
}
|
||||
if (ErrorClass) {
|
||||
if (error instanceof Error === false) {
|
||||
throw new AssertionError("A non-Error object was rejected.");
|
||||
}
|
||||
assertIsError(error, ErrorClass, msgIncludes, msg);
|
||||
}
|
||||
err = error;
|
||||
doesThrow = true;
|
||||
}
|
||||
if (!doesThrow) {
|
||||
throw new AssertionError(`Expected function to reject${msgToAppendToError}`);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
function unimplemented(msg) {
|
||||
throw new AssertionError(msg || "unimplemented");
|
||||
}
|
||||
function unreachable() {
|
||||
throw new AssertionError("unreachable");
|
||||
}
|
||||
export { AssertionError as AssertionError };
|
||||
export { equal as equal };
|
||||
export { assert as assert };
|
||||
export { assertFalse as assertFalse };
|
||||
export { assertEquals as assertEquals };
|
||||
export { assertNotEquals as assertNotEquals };
|
||||
export { assertStrictEquals as assertStrictEquals };
|
||||
export { assertNotStrictEquals as assertNotStrictEquals };
|
||||
export { assertAlmostEquals as assertAlmostEquals };
|
||||
export { assertInstanceOf as assertInstanceOf };
|
||||
export { assertNotInstanceOf as assertNotInstanceOf };
|
||||
export { assertExists as assertExists };
|
||||
export { assertStringIncludes as assertStringIncludes };
|
||||
export { assertArrayIncludes as assertArrayIncludes };
|
||||
export { assertMatch as assertMatch };
|
||||
export { assertNotMatch as assertNotMatch };
|
||||
export { assertObjectMatch as assertObjectMatch };
|
||||
export { fail as fail };
|
||||
export { assertIsError as assertIsError };
|
||||
export { assertThrows as assertThrows };
|
||||
export { assertRejects as assertRejects };
|
||||
export { unimplemented as unimplemented };
|
||||
export { unreachable as unreachable };
|
||||
|
||||
5
node_modules/tinycolor2/dist/tinycolor-min.js
generated
vendored
Normal file
5
node_modules/tinycolor2/dist/tinycolor-min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/tinycolor2/esm/package.json
generated
vendored
Normal file
3
node_modules/tinycolor2/esm/package.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
2189
node_modules/tinycolor2/esm/test.js
generated
vendored
Normal file
2189
node_modules/tinycolor2/esm/test.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
24
node_modules/tinycolor2/esm/test_template.js
generated
vendored
Normal file
24
node_modules/tinycolor2/esm/test_template.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
// This file is autogenerated.
|
||||
// Ideally it wouldn't exist, but it's here to test cjs in node
|
||||
// Changes should go into ./test.js, and if new assertions are needed
|
||||
// they'll need to be shimmed here as well
|
||||
import tinycolor from "./tinycolor.js";
|
||||
import { Deno, testDefinitions } from "@deno/shim-deno-test";
|
||||
const { assertEquals, assert, assertThrows } = await import(
|
||||
"../deno_asserts@0.168.0.mjs"
|
||||
);
|
||||
async function runDenoTests() {
|
||||
for (const test of testDefinitions) {
|
||||
if (test.ignore) {
|
||||
console.log(`Ignoring ${test.name}`);
|
||||
continue;
|
||||
}
|
||||
console.log(`Running ${test.name}`);
|
||||
await test.fn();
|
||||
console.log(`> Passed ${test.name}`);
|
||||
}
|
||||
}
|
||||
|
||||
// CONTENT_GOES_HERE
|
||||
|
||||
runDenoTests();
|
||||
1180
node_modules/tinycolor2/esm/tinycolor.js
generated
vendored
Normal file
1180
node_modules/tinycolor2/esm/tinycolor.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
35
node_modules/tinycolor2/package.json
generated
vendored
Normal file
35
node_modules/tinycolor2/package.json
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"version": "1.6.0",
|
||||
"name": "tinycolor2",
|
||||
"description": "Fast Color Parsing and Manipulation",
|
||||
"url": "http://bgrins.github.com/TinyColor",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/bgrins/TinyColor.git"
|
||||
},
|
||||
"keywords": [
|
||||
"color",
|
||||
"parser",
|
||||
"tinycolor"
|
||||
],
|
||||
"author": "Brian Grinstead <briangrinstead@gmail.com> (http://briangrinstead.com)",
|
||||
"bugs": {
|
||||
"url": "https://github.com/bgrins/TinyColor/issues"
|
||||
},
|
||||
"module": "./esm/tinycolor.js",
|
||||
"main": "./cjs/tinycolor.js",
|
||||
"browser": "./cjs/tinycolor.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./esm/tinycolor.js",
|
||||
"require": "./cjs/tinycolor.js"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node cjs/test.js && node esm/test.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@deno/shim-deno-test": "^0.4.0"
|
||||
}
|
||||
}
|
||||
1191
node_modules/tinycolor2/tinycolor.js
generated
vendored
Normal file
1191
node_modules/tinycolor2/tinycolor.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user