Added some boilerplate

This commit is contained in:
xeovalyte 2024-06-04 13:41:33 +02:00
commit 38109d8108
No known key found for this signature in database
351 changed files with 111806 additions and 0 deletions

9
.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
# Generated by Cargo
# will have compiled files and executables
/target/
/dist/
/static/
/.dioxus/
# These are backup files generated by rustfmt
**/*.rs.bk

2930
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

21
Cargo.toml Normal file
View File

@ -0,0 +1,21 @@
[package]
name = "xvmcmm"
version = "0.1.0"
authors = ["xeovalyte <me+gitea@xeovalyte.dev>"]
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = { version = "1.0.197", features = ["derive"] }
dioxus = { version = "0.5", features = ["fullstack", "router"] }
# Debug
tracing = "0.1.40"
dioxus-logger = "0.5.0"
[features]
default = []
server = ["dioxus/axum"]
web = ["dioxus/web"]

43
Dioxus.toml Normal file
View File

@ -0,0 +1,43 @@
[application]
# App (Project) Name
name = "xvmcmm"
# Dioxus App Default Platform
# desktop, web
default_platform = "web"
# `build` & `serve` dist path
out_dir = "dist"
# resource (assets) file folder
asset_dir = "assets"
[web.app]
# HTML title tag content
title = "xvmcmm"
[web.watcher]
# when watcher trigger, regenerate the `index.html`
reload_html = true
# which files or dirs will be watcher monitoring
watch_path = ["src", "assets"]
# include `assets` in web platform
[web.resource]
# CSS style file
style = ["tailwind.css"]
# Javascript code file
script = []
[web.resource.dev]
# Javascript code file
# serve: [dev-server] only
script = []

14
README.md Normal file
View File

@ -0,0 +1,14 @@
1. Install npm: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
2. Install the tailwind css cli: https://tailwindcss.com/docs/installation
3. Run the following command in the root of the project to start the tailwind CSS compiler:
```bash
npx tailwindcss -i ./input.css -o ./assets/tailwind.css --watch
```
Launch the Dioxus Fullstack app:
```bash
dx serve --platform fullstack
```

BIN
assets/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

20
assets/header.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 23 KiB

40
assets/main.css Normal file
View File

@ -0,0 +1,40 @@
body {
background-color: #111216;
}
#main {
margin: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif
}
#links {
width: 400px;
text-align: left;
font-size: x-large;
color: white;
display: flex;
flex-direction: column;
}
#links a {
color: white;
text-decoration: none;
margin-top: 20px;
margin: 10px;
border: white 1px solid;
border-radius: 5px;
padding: 10px;
}
#links a:hover {
background-color: #1f1f1f;
cursor: pointer;
}
#header {
max-width: 1200px;
}

1978
assets/tailwind.css Normal file

File diff suppressed because it is too large Load Diff

147
flake.lock generated Normal file
View File

@ -0,0 +1,147 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1717159533,
"narHash": "sha256-oamiKNfr2MS6yH64rUn99mIZjc45nGJlj9eGth/3Xuw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a62e6edd6d5e1fa0329b8653c801147986f8d446",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1717196966,
"narHash": "sha256-yZKhxVIKd2lsbOqYd5iDoUIwsRZFqE87smE2Vzf6Ck0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "57610d2f8f0937f39dbd72251e9614b1561942d8",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1706487304,
"narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "90f456026d284c22b3e3497be980b2e47d0b28ac",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1717467480,
"narHash": "sha256-9Fbar+ycxdfZ6HbwOCgD+jWG3du/12TFisKRQm4Zhfc=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "260ff391290a2b23958d04db0d3e7015c8417401",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

57
flake.nix Normal file
View File

@ -0,0 +1,57 @@
{
description = "A basic Rust devshell";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, nixpkgs-unstable, rust-overlay, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlay-unstable = final: prev: {
unstable = import nixpkgs-unstable {
localSystem = { inherit system; };
};
};
overlays = [ (import rust-overlay) overlay-unstable ];
pkgs = import nixpkgs {
inherit system overlays;
};
in
with pkgs;
{
devShells.default = mkShell {
buildInputs = [
trunk
dart-sass
unstable.rust-analyzer
llvmPackages.libclang
llvmPackages.lld
clang
cargo-generate
openssl
pkg-config
dap
(rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override {
extensions = [ "rust-src" "rust-analyzer" ];
targets = [ "wasm32-unknown-unknown" ];
}))
];
shellHook = ''
alias grep=ripgrep
export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin
# export CC=clang
export CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_LINKER=lld
export LIBCLANG_PATH=${pkgs.llvmPackages.libclang.lib}/lib
export BINDGEN_EXTRA_CLANG_ARGS="-I ${pkgs.llvmPackages.libclang.lib}/lib/clang/16/include"
'';
};
}
);
}

3
input.css Normal file
View File

@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

1
node_modules/.bin/cssesc generated vendored Symbolic link
View File

@ -0,0 +1 @@
../cssesc/bin/cssesc

1
node_modules/.bin/nanoid generated vendored Symbolic link
View File

@ -0,0 +1 @@
../nanoid/bin/nanoid.cjs

155
node_modules/.package-lock.json generated vendored Normal file
View File

@ -0,0 +1,155 @@
{
"name": "xvmcmm",
"lockfileVersion": 3,
"requires": true,
"packages": {
"node_modules/camelcase-css": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/camelcase-css/-/camelcase-css-2.0.1.tgz",
"integrity": "sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==",
"dev": true,
"engines": {
"node": ">= 6"
}
},
"node_modules/css-selector-tokenizer": {
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/css-selector-tokenizer/-/css-selector-tokenizer-0.8.0.tgz",
"integrity": "sha512-Jd6Ig3/pe62/qe5SBPTN8h8LeUg/pT4lLgtavPf7updwwHpvFzxvOQBHYj2LZDMjUnBzgvIUSjRcf6oT5HzHFg==",
"dev": true,
"dependencies": {
"cssesc": "^3.0.0",
"fastparse": "^1.1.2"
}
},
"node_modules/cssesc": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz",
"integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==",
"dev": true,
"bin": {
"cssesc": "bin/cssesc"
},
"engines": {
"node": ">=4"
}
},
"node_modules/culori": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/culori/-/culori-3.3.0.tgz",
"integrity": "sha512-pHJg+jbuFsCjz9iclQBqyL3B2HLCBF71BwVNujUYEvCeQMvV97R59MNK3R2+jgJ3a1fcZgI9B3vYgz8lzr/BFQ==",
"dev": true,
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
}
},
"node_modules/daisyui": {
"version": "4.11.1",
"resolved": "https://registry.npmjs.org/daisyui/-/daisyui-4.11.1.tgz",
"integrity": "sha512-obT9CUbQdW6eoHwSeT5VwaRrWlwrM4OT5qlfdJ0oQlSIEYhwnEl2+L2fwu5PioLbitwuMdYC2X8I1cyy8Pf6LQ==",
"dev": true,
"dependencies": {
"css-selector-tokenizer": "^0.8",
"culori": "^3",
"picocolors": "^1",
"postcss-js": "^4"
},
"engines": {
"node": ">=16.9.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/daisyui"
}
},
"node_modules/fastparse": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/fastparse/-/fastparse-1.1.2.tgz",
"integrity": "sha512-483XLLxTVIwWK3QTrMGRqUfUpoOs/0hbQrl2oz4J0pAcm3A3bu84wxTFqGqkJzewCLdME38xJLJAxBABfQT8sQ==",
"dev": true
},
"node_modules/nanoid": {
"version": "3.3.7",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz",
"integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"peer": true,
"bin": {
"nanoid": "bin/nanoid.cjs"
},
"engines": {
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
}
},
"node_modules/picocolors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz",
"integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==",
"dev": true
},
"node_modules/postcss": {
"version": "8.4.38",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz",
"integrity": "sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==",
"dev": true,
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/postcss/"
},
{
"type": "tidelift",
"url": "https://tidelift.com/funding/github/npm/postcss"
},
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"peer": true,
"dependencies": {
"nanoid": "^3.3.7",
"picocolors": "^1.0.0",
"source-map-js": "^1.2.0"
},
"engines": {
"node": "^10 || ^12 || >=14"
}
},
"node_modules/postcss-js": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/postcss-js/-/postcss-js-4.0.1.tgz",
"integrity": "sha512-dDLF8pEO191hJMtlHFPRa8xsizHaM82MLfNkUHdUtVEV3tgTp5oj+8qbEqYM57SLfc74KSbw//4SeJma2LRVIw==",
"dev": true,
"dependencies": {
"camelcase-css": "^2.0.1"
},
"engines": {
"node": "^12 || ^14 || >= 16"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/postcss/"
},
"peerDependencies": {
"postcss": "^8.4.21"
}
},
"node_modules/source-map-js": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz",
"integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==",
"dev": true,
"peer": true,
"engines": {
"node": ">=0.10.0"
}
}
}
}

27
node_modules/camelcase-css/README.md generated vendored Normal file
View File

@ -0,0 +1,27 @@
# camelcase-css [![NPM Version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url]
> Convert a kebab-cased CSS property into a camelCased DOM property.
## Installation
[Node.js](http://nodejs.org/) `>= 6` is required. Type this at the command line:
```shell
npm install camelcase-css
```
## Usage
```js
const camelCaseCSS = require('camelcase-css');
camelCaseCSS('-webkit-border-radius'); //-> WebkitBorderRadius
camelCaseCSS('-moz-border-radius'); //-> MozBorderRadius
camelCaseCSS('-ms-border-radius'); //-> msBorderRadius
camelCaseCSS('border-radius'); //-> borderRadius
```
[npm-image]: https://img.shields.io/npm/v/camelcase-css.svg
[npm-url]: https://npmjs.org/package/camelcase-css
[travis-image]: https://img.shields.io/travis/stevenvachon/camelcase-css.svg
[travis-url]: https://travis-ci.org/stevenvachon/camelcase-css

24
node_modules/camelcase-css/index-es5.js generated vendored Normal file
View File

@ -0,0 +1,24 @@
"use strict";
var pattern = /-(\w|$)/g;
var callback = function callback(dashChar, char) {
return char.toUpperCase();
};
var camelCaseCSS = function camelCaseCSS(property) {
property = property.toLowerCase();
// NOTE :: IE8's "styleFloat" is intentionally not supported
if (property === "float") {
return "cssFloat";
}
// Microsoft vendor-prefixes are uniquely cased
else if (property.charCodeAt(0) === 45&& property.charCodeAt(1) === 109&& property.charCodeAt(2) === 115&& property.charCodeAt(3) === 45) {
return property.substr(1).replace(pattern, callback);
} else {
return property.replace(pattern, callback);
}
};
module.exports = camelCaseCSS;

30
node_modules/camelcase-css/index.js generated vendored Normal file
View File

@ -0,0 +1,30 @@
"use strict";
const pattern = /-(\w|$)/g;
const callback = (dashChar, char) => char.toUpperCase();
const camelCaseCSS = property =>
{
property = property.toLowerCase();
// NOTE :: IE8's "styleFloat" is intentionally not supported
if (property === "float")
{
return "cssFloat";
}
// Microsoft vendor-prefixes are uniquely cased
else if (property.startsWith("-ms-"))
{
return property.substr(1).replace(pattern, callback);
}
else
{
return property.replace(pattern, callback);
}
};
module.exports = camelCaseCSS;

21
node_modules/camelcase-css/license generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Steven Vachon <contact@svachon.com> (svachon.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.

34
node_modules/camelcase-css/package.json generated vendored Normal file
View File

@ -0,0 +1,34 @@
{
"name": "camelcase-css",
"description": "Convert a kebab-cased CSS property into a camelCased DOM property.",
"version": "2.0.1",
"license": "MIT",
"author": "Steven Vachon <contact@svachon.com> (https://www.svachon.com/)",
"repository": "stevenvachon/camelcase-css",
"browser": "index-es5.js",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-plugin-optimize-starts-with": "^1.0.1",
"babel-preset-env": "^1.7.0",
"chai": "^4.1.2",
"mocha": "^5.2.0"
},
"engines": {
"node": ">= 6"
},
"scripts": {
"pretest": "babel index.js --out-file=index-es5.js --presets=env --plugins=optimize-starts-with",
"test": "mocha test.js --check-leaks --bail"
},
"files": [
"index.js",
"index-es5.js"
],
"keywords": [
"camelcase",
"case",
"css",
"dom"
]
}

7
node_modules/css-selector-tokenizer/LICENSE generated vendored Normal file
View File

@ -0,0 +1,7 @@
Copyright 2015 Tobias Koppers
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.

92
node_modules/css-selector-tokenizer/README.md generated vendored Normal file
View File

@ -0,0 +1,92 @@
# CSS Modules: css-selector-tokenizer
[![Build Status](https://travis-ci.org/css-modules/css-selector-tokenizer.svg?branch=master)](https://travis-ci.org/css-modules/css-selector-tokenizer)
[![coveralls.io](https://coveralls.io/repos/css-modules/css-selector-tokenizer/badge.svg?branch=master)](https://coveralls.io/r/css-modules/css-selector-tokenizer?branch=master)
[![codecov.io](https://codecov.io/github/css-modules/css-selector-tokenizer/coverage.svg?branch=master)](https://codecov.io/github/css-modules/css-selector-tokenizer?branch=master)
Parses and stringifies CSS selectors.
``` js
import Tokenizer from "css-selector-tokenizer";
let input = "a#content.active > div::first-line [data-content], a:not(:visited)";
Tokenizer.parse(input); // === expected
let expected = {
type: "selectors",
nodes: [
{
type: "selector",
nodes: [
{ type: "element", name: "a" },
{ type: "id", name: "content" },
{ type: "class", name: "active" },
{ type: "operator", operator: ">", before: " ", after: " " },
{ type: "element", name: "div" },
{ type: "pseudo-element", name: "first-line" },
{ type: "spacing", value: " " },
{ type: "attribute", content: "data-content" },
]
},
{
type: "selector",
nodes: [
{ type: "element", name: "a" },
{ type: "nested-pseudo-class", name: "not", nodes: [
{
type: "selector",
nodes: [
{ type: "pseudo-class", name: "visited" }
]
}
] }
],
before: " "
}
]
}
Tokenizer.stringify(expected) // === input
// * => { type: "universal" }
// foo|element = { type: "element", name: "element", namespace: "foo" }
// *|* = { type: "universal", namespace: "*" }
// :has(h1, h2) => { type: "nested-pseudo-class", name: "has", nodes: [
// {
// type: "selector",
// nodes: [
// { type: "element", name: "h1" }
// ]
// },
// {
// type: "selector",
// nodes: [
// { type: "element", name: "h2" }
// ],
// before: " "
// }
// ] }
```
## Building
```
npm install
npm test
```
## Development
- `npm test -- -w` will watch `lib` and `test` for changes and retest
## License
MIT
## With thanks
- Mark Dalgleish
- Glen Maddern
- Guy Bedford
---
Tobias Koppers, 2015.

4
node_modules/css-selector-tokenizer/lib/index.js generated vendored Normal file
View File

@ -0,0 +1,4 @@
exports.parse = require("./parse");
exports.stringify = require("./stringify");
exports.parseValues = require("./parseValues");
exports.stringifyValues = require("./stringifyValues");

239
node_modules/css-selector-tokenizer/lib/parse.js generated vendored Normal file
View File

@ -0,0 +1,239 @@
"use strict";
var Parser = require("fastparse");
var uniRegexp = require("./uni-regexp");
function unescape(str) {
return str.replace(/\\(.)/g, "$1");
}
function commentMatch(match, content) {
this.selector.nodes.push({
type: "comment",
content: content
});
}
function typeMatch(type) {
return function(match, name) {
this.selector.nodes.push({
type: type,
name: unescape(name)
});
};
}
function pseudoClassStartMatch(match, name) {
var newToken = {
type: "pseudo-class",
name: unescape(name),
content: ""
};
this.selector.nodes.push(newToken);
this.token = newToken;
this.brackets = 1;
return "inBrackets";
}
function nestedPseudoClassStartMatch(match, name, after) {
var newSelector = {
type: "selector",
nodes: []
};
var newToken = {
type: "nested-pseudo-class",
name: unescape(name),
nodes: [newSelector]
};
if(after) {
newSelector.before = after;
}
this.selector.nodes.push(newToken);
this.stack.push(this.root);
this.root = newToken;
this.selector = newSelector;
}
function nestedEnd(match, before) {
if(this.stack.length > 0) {
if(before) {
this.selector.after = before;
}
this.root = this.stack.pop();
this.selector = this.root.nodes[this.root.nodes.length - 1];
} else {
this.selector.nodes.push({
type: "invalid",
value: match
});
}
}
function operatorMatch(match, before, operator, after) {
var token = {
type: "operator",
operator: operator
};
if(before) {
token.before = before;
}
if(after) {
token.after = after;
}
this.selector.nodes.push(token);
}
function spacingMatch(match) {
this.selector.nodes.push({
type: "spacing",
value: match
});
}
function elementMatch(match, namespace, name) {
var newToken = {
type: "element",
name: unescape(name)
};
if(namespace) {
newToken.namespace = unescape(namespace.substr(0, namespace.length - 1));
}
this.selector.nodes.push(newToken);
}
function universalMatch(match, namespace) {
var newToken = {
type: "universal"
};
if(namespace) {
newToken.namespace = unescape(namespace.substr(0, namespace.length - 1));
}
this.selector.nodes.push(newToken);
}
function attributeMatch(match, content) {
this.selector.nodes.push({
type: "attribute",
content: content
});
}
function invalidMatch(match) {
this.selector.nodes.push({
type: "invalid",
value: match
});
}
function irrelevantSpacingStartMatch(match) {
this.selector.before = match;
}
function irrelevantSpacingEndMatch(match) {
this.selector.after = match;
}
function nextSelectorMatch(match, before, after) {
var newSelector = {
type: "selector",
nodes: []
};
if(before) {
this.selector.after = before;
}
if(after) {
newSelector.before = after;
}
this.root.nodes.push(newSelector);
this.selector = newSelector;
}
function addToCurrent(match) {
this.token.content += match;
}
function bracketStart(match) {
this.token.content += match;
this.brackets++;
}
function bracketEnd(match) {
if(--this.brackets === 0) {
return "selector";
}
this.token.content += match;
}
function getSelectors() {
// The assignment here is split to preserve the property enumeration order.
var selectors = {
"/\\*([\\s\\S]*?)\\*/": commentMatch
};
// https://www.w3.org/TR/CSS21/syndata.html#characters
// 4.1.3: identifiers (...) can contain only the characters [a-zA-Z0-9] and
// ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_)
//
// 10ffff is the maximum allowed in current Unicode
selectors[uniRegexp.typeMatchClass] = typeMatch("class");
selectors[uniRegexp.typeMatchId] = typeMatch("id");
var selectorsSecondHalf = {
":(not|any|-\\w+?-any|matches|is|where|has|local|global)\\((\\s*)": nestedPseudoClassStartMatch,
":((?:\\\\.|[A-Za-z_\\-0-9])+)\\(": pseudoClassStartMatch,
":((?:\\\\.|[A-Za-z_\\-0-9])+)": typeMatch("pseudo-class"),
"::((?:\\\\.|[A-Za-z_\\-0-9])+)": typeMatch("pseudo-element"),
"(\\*\\|)((?:\\\\.|[A-Za-z_\\-0-9])+)": elementMatch,
"(\\*\\|)\\*": universalMatch,
"((?:\\\\.|[A-Za-z_\\-0-9])*\\|)?\\*": universalMatch,
"((?:\\\\.|[A-Za-z_\\-0-9])*\\|)?((?:\\\\.|[A-Za-z_\\-])(?:\\\\.|[A-Za-z_\\-0-9])*)": elementMatch,
"\\[([^\\]]+)\\]": attributeMatch,
"(\\s*)\\)": nestedEnd,
"(\\s*)((?:\\|\\|)|(?:>>)|[>+~])(\\s*)": operatorMatch,
"(\\s*),(\\s*)": nextSelectorMatch,
"\\s+$": irrelevantSpacingEndMatch,
"^\\s+": irrelevantSpacingStartMatch,
"\\s+": spacingMatch,
".": invalidMatch
};
var selector;
for (selector in selectorsSecondHalf) {
if (Object.prototype.hasOwnProperty.call(selectorsSecondHalf, selector)) {
selectors[selector] = selectorsSecondHalf[selector];
}
}
return selectors;
}
var parser = new Parser({
selector: getSelectors(),
inBrackets: {
"/\\*[\\s\\S]*?\\*/": addToCurrent,
"\"([^\\\\\"]|\\\\.)*\"": addToCurrent,
"'([^\\\\']|\\\\.)*'": addToCurrent,
"[^()'\"/]+": addToCurrent,
"\\(": bracketStart,
"\\)": bracketEnd,
".": addToCurrent
}
});
function parse(str) {
var selectorNode = {
type: "selector",
nodes: []
};
var rootNode = {
type: "selectors",
nodes: [
selectorNode
]
};
parser.parse("selector", str, {
stack: [],
root: rootNode,
selector: selectorNode
});
return rootNode;
}
module.exports = parse;

167
node_modules/css-selector-tokenizer/lib/parseValues.js generated vendored Normal file
View File

@ -0,0 +1,167 @@
"use strict";
var Parser = require("fastparse");
function commentMatch(match, content) {
this.value.nodes.push({
type: "comment",
content: content
});
}
function spacingMatch(match) {
var item = this.value.nodes[this.value.nodes.length - 1];
item.after = (item.after || "") + match;
}
function initialSpacingMatch(match) {
this.value.before = match;
}
function endSpacingMatch(match) {
this.value.after = match;
}
function unescapeString(content) {
return content.replace(/\\(?:([a-fA-F0-9]{1,6})|(.))/g, function(all, unicode, otherCharacter) {
if (otherCharacter) {
return otherCharacter;
}
var C = parseInt(unicode, 16);
if(C < 0x10000) {
return String.fromCharCode(C);
} else {
return String.fromCharCode(Math.floor((C - 0x10000) / 0x400) + 0xD800) +
String.fromCharCode((C - 0x10000) % 0x400 + 0xDC00);
}
});
}
function stringMatch(match, content) {
var value = unescapeString(content);
this.value.nodes.push({
type: "string",
value: value,
stringType: match[0]
});
}
function commaMatch(match, spacing) {
var newValue = {
type: "value",
nodes: []
};
if(spacing) {
newValue.before = spacing;
}
this.root.nodes.push(newValue);
this.value = newValue;
}
function itemMatch(match) {
this.value.nodes.push({
type: "item",
name: match
});
}
function nestedItemMatch(match, name, spacing) {
this.stack.push(this.root);
this.root = {
type: "nested-item",
name: name,
nodes: [
{ type: "value", nodes: [] }
]
};
if(spacing) {
this.root.nodes[0].before = spacing;
}
this.value.nodes.push(this.root);
this.value = this.root.nodes[0];
}
function nestedItemEndMatch(match, spacing, remaining) {
if(this.stack.length === 0) {
if(spacing) {
var item = this.value.nodes[this.value.nodes.length - 1];
item.after = (item.after || "") + spacing;
}
this.value.nodes.push({
type: "invalid",
value: remaining
});
} else {
if(spacing) {
this.value.after = spacing;
}
this.root = this.stack.pop();
this.value = this.root.nodes[this.root.nodes.length - 1];
}
}
function urlMatch(match, innerSpacingBefore, content, innerSpacingAfter) {
var item = {
type: "url"
};
if(innerSpacingBefore) {
item.innerSpacingBefore = innerSpacingBefore;
}
if(innerSpacingAfter) {
item.innerSpacingAfter = innerSpacingAfter;
}
switch(content[0]) {
case "\"":
item.stringType = "\"";
item.url = unescapeString(content.substr(1, content.length - 2));
break;
case "'":
item.stringType = "'";
item.url = unescapeString(content.substr(1, content.length - 2));
break;
default:
item.url = unescapeString(content);
break;
}
this.value.nodes.push(item);
}
var parser = new Parser({
decl: {
"^\\s+": initialSpacingMatch,
"/\\*([\\s\\S]*?)\\*/": commentMatch,
"\"((?:[^\\\\\"]|\\\\.)*)\"": stringMatch,
"'((?:[^\\\\']|\\\\.)*)'": stringMatch,
"url\\((\\s*)(\"(?:[^\\\\\"]|\\\\.)*\")(\\s*)\\)": urlMatch,
"url\\((\\s*)('(?:[^\\\\']|\\\\.)*')(\\s*)\\)": urlMatch,
"url\\((\\s*)((?:[^\\\\)'\"]|\\\\.)*)(\\s*)\\)": urlMatch,
"([\\w-]+)\\((\\s*)": nestedItemMatch,
"(\\s*)(\\))": nestedItemEndMatch,
",(\\s*)": commaMatch,
"\\s+$": endSpacingMatch,
"\\s+": spacingMatch,
"[^\\s,)]+": itemMatch
}
});
function parseValues(str) {
var valueNode = {
type: "value",
nodes: []
};
var rootNode = {
type: "values",
nodes: [
valueNode
]
};
parser.parse("decl", str, {
stack: [],
root: rootNode,
value: valueNode
});
return rootNode;
}
module.exports = parseValues;

62
node_modules/css-selector-tokenizer/lib/stringify.js generated vendored Normal file
View File

@ -0,0 +1,62 @@
"use strict";
var uniRegexp = require("./uni-regexp");
var identifierEscapeRegexp = new RegExp(uniRegexp.identifierEscapeRegexp, "g");
function escape(str, identifier) {
if(str === "*") {
return "*";
}
if (identifier) {
return str.replace(identifierEscapeRegexp, "\\$1");
} else {
return str.replace(/(^[^A-Za-z_\\-]|^--|[^A-Za-z_0-9\\-])/g, "\\$1");
}
}
function stringifyWithoutBeforeAfter(tree) {
switch(tree.type) {
case "selectors":
return tree.nodes.map(stringify).join(",");
case "selector":
return tree.nodes.map(stringify).join("");
case "element":
return (typeof tree.namespace === "string" ? escape(tree.namespace) + "|" : "") + escape(tree.name);
case "class":
return "." + escape(tree.name, true);
case "id":
return "#" + escape(tree.name, true);
case "attribute":
return "[" + tree.content + "]";
case "spacing":
return tree.value;
case "pseudo-class":
return ":" + escape(tree.name) + (typeof tree.content === "string" ? "(" + tree.content + ")" : "");
case "nested-pseudo-class":
return ":" + escape(tree.name) + "(" + tree.nodes.map(stringify).join(",") + ")";
case "pseudo-element":
return "::" + escape(tree.name);
case "universal":
return (typeof tree.namespace === "string" ? escape(tree.namespace) + "|" : "") + "*";
case "operator":
return tree.operator;
case "comment":
return "/*" + tree.content + "*/";
case "invalid":
return tree.value;
}
}
function stringify(tree) {
var str = stringifyWithoutBeforeAfter(tree);
if(tree.before) {
str = tree.before + str;
}
if(tree.after) {
str = str + tree.after;
}
return str;
}
module.exports = stringify;

View File

@ -0,0 +1,62 @@
"use strict";
var cssesc = require("cssesc");
var stringify;
function escape(str, stringType) {
return cssesc(str, {
quotes: stringType === "\"" ? "double" : "single"
});
}
function stringifyWithoutBeforeAfter(tree) {
switch(tree.type) {
case "values":
return tree.nodes.map(stringify).join(",");
case "value":
return tree.nodes.map(stringify).join("");
case "item":
return tree.name;
case "nested-item":
return tree.name + "(" + tree.nodes.map(stringify).join(",") + ")";
case "invalid":
return tree.value;
case "comment":
return "/*" + tree.content + "*/";
case "string":
switch(tree.stringType) {
case "'":
return "'" + escape(tree.value, "'") + "'";
case "\"":
return "\"" + escape(tree.value, "\"") + "\"";
}
/* istanbul ignore next */
throw new Error("Invalid stringType");
case "url":
var start = "url(" + (tree.innerSpacingBefore || "");
var end = (tree.innerSpacingAfter || "") + ")";
switch(tree.stringType) {
case "'":
return start + "'" + tree.url.replace(/(\\)/g, "\\$1").replace(/'/g, "\\'") + "'" + end;
case "\"":
return start + "\"" + tree.url.replace(/(\\)/g, "\\$1").replace(/"/g, "\\\"") + "\"" + end;
default:
return start + tree.url.replace(/("|'|\)|\\)/g, "\\$1") + end;
}
}
}
stringify = function stringify(tree) {
var str = stringifyWithoutBeforeAfter(tree);
if(tree.before) {
str = tree.before + str;
}
if(tree.after) {
str = str + tree.after;
}
return str;
};
module.exports = stringify;

View File

@ -0,0 +1,6 @@
/* AUTO GENERATED */
module.exports = {
"typeMatchClass": "\\.((?:\\\\(?:[\\0-\\t\\x0B\\f\\x0E-\\u2027\\u202A-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF])|(?:[\\x2DA-Z_a-z\\xA0-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF]))(?:\\\\(?:[\\0-\\t\\x0B\\f\\x0E-\\u2027\\u202A-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF])|(?:[\\x2D0-9A-Z_a-z\\xA0-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF]))*)",
"typeMatchId": "#((?:\\\\(?:[\\0-\\t\\x0B\\f\\x0E-\\u2027\\u202A-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF])|(?:[\\x2DA-Z_a-z\\xA0-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF]))(?:\\\\(?:[\\0-\\t\\x0B\\f\\x0E-\\u2027\\u202A-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF])|(?:[\\x2D0-9A-Z_a-z\\xA0-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF]))*)",
"identifierEscapeRegexp": "(^[\\0-,\\.-@\\[-\\^`\\{-\\x9F]|^\\x2D\\x2D|[\\0-,\\.\\/:-@\\[-\\^`\\{-\\x9F])"
}

48
node_modules/css-selector-tokenizer/package.json generated vendored Normal file
View File

@ -0,0 +1,48 @@
{
"name": "css-selector-tokenizer",
"version": "0.8.0",
"description": "Parses and stringifies CSS selectors",
"main": "lib/index.js",
"scripts": {
"lint": "eslint .",
"pretest": "npm run lint",
"test": "mocha",
"cover": "nyc npm test",
"build-regexpu": "node scripts/build-regexpu.js",
"report:coveralls": "nyc report --reporter=text-lcov | coveralls",
"report:codecov": "nyc report --reporter=text-lcov | codecov --pipe",
"publish-patch": "npm test && npm version patch && git push && git push --tags && npm publish"
},
"repository": {
"type": "git",
"url": "https://github.com/css-modules/css-selector-tokenizer.git"
},
"keywords": [
"css-modules",
"selectors"
],
"files": [
"lib"
],
"author": "Tobias Koppers @sokra",
"license": "MIT",
"bugs": {
"url": "https://github.com/css-modules/css-selector-tokenizer/issues"
},
"homepage": "https://github.com/css-modules/css-selector-tokenizer",
"dependencies": {
"cssesc": "^3.0.0",
"fastparse": "^1.1.2"
},
"devDependencies": {
"codecov": "^3.6.5",
"coveralls": "^3.0.9",
"eslint": "^6.8.0",
"mocha": "^7.1.0",
"nyc": "^15.0.0",
"regexpu-core": "^4.6.0"
},
"directories": {
"test": "test"
}
}

20
node_modules/cssesc/LICENSE-MIT.txt generated vendored Normal file
View File

@ -0,0 +1,20 @@
Copyright Mathias Bynens <https://mathiasbynens.be/>
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.

201
node_modules/cssesc/README.md generated vendored Normal file
View File

@ -0,0 +1,201 @@
# cssesc [![Build status](https://travis-ci.org/mathiasbynens/cssesc.svg?branch=master)](https://travis-ci.org/mathiasbynens/cssesc) [![Code coverage status](https://img.shields.io/codecov/c/github/mathiasbynens/cssesc.svg)](https://codecov.io/gh/mathiasbynens/cssesc)
A JavaScript library for escaping CSS strings and identifiers while generating the shortest possible ASCII-only output.
This is a JavaScript library for [escaping text for use in CSS strings or identifiers](https://mathiasbynens.be/notes/css-escapes) while generating the shortest possible valid ASCII-only output. [Heres an online demo.](https://mothereff.in/css-escapes)
[A polyfill for the CSSOM `CSS.escape()` method is available in a separate repository.](https://mths.be/cssescape) (In comparison, _cssesc_ is much more powerful.)
Feel free to fork if you see possible improvements!
## Installation
Via [npm](https://www.npmjs.com/):
```bash
npm install cssesc
```
In a browser:
```html
<script src="cssesc.js"></script>
```
In [Node.js](https://nodejs.org/):
```js
const cssesc = require('cssesc');
```
In Ruby using [the `ruby-cssesc` wrapper gem](https://github.com/borodean/ruby-cssesc):
```bash
gem install ruby-cssesc
```
```ruby
require 'ruby-cssesc'
CSSEsc.escape('I ♥ Ruby', is_identifier: true)
```
In Sass using [`sassy-escape`](https://github.com/borodean/sassy-escape):
```bash
gem install sassy-escape
```
```scss
body {
content: escape('I ♥ Sass', $is-identifier: true);
}
```
## API
### `cssesc(value, options)`
This function takes a value and returns an escaped version of the value where any characters that are not printable ASCII symbols are escaped using the shortest possible (but valid) [escape sequences for use in CSS strings or identifiers](https://mathiasbynens.be/notes/css-escapes).
```js
cssesc('Ich ♥ Bücher');
// → 'Ich \\2665 B\\FC cher'
cssesc('foo 𝌆 bar');
// → 'foo \\1D306 bar'
```
By default, `cssesc` returns a string that can be used as part of a CSS string. If the target is a CSS identifier rather than a CSS string, use the `isIdentifier: true` setting (see below).
The optional `options` argument accepts an object with the following options:
#### `isIdentifier`
The default value for the `isIdentifier` option is `false`. This means that the input text will be escaped for use in a CSS string literal. If you want to use the result as a CSS identifier instead (in a selector, for example), set this option to `true`.
```js
cssesc('123a2b');
// → '123a2b'
cssesc('123a2b', {
'isIdentifier': true
});
// → '\\31 23a2b'
```
#### `quotes`
The default value for the `quotes` option is `'single'`. This means that any occurences of `'` in the input text will be escaped as `\'`, so that the output can be used in a CSS string literal wrapped in single quotes.
```js
cssesc('Lorem ipsum "dolor" sit \'amet\' etc.');
// → 'Lorem ipsum "dolor" sit \\\'amet\\\' etc.'
// → "Lorem ipsum \"dolor\" sit \\'amet\\' etc."
cssesc('Lorem ipsum "dolor" sit \'amet\' etc.', {
'quotes': 'single'
});
// → 'Lorem ipsum "dolor" sit \\\'amet\\\' etc.'
// → "Lorem ipsum \"dolor\" sit \\'amet\\' etc."
```
If you want to use the output as part of a CSS string literal wrapped in double quotes, set the `quotes` option to `'double'`.
```js
cssesc('Lorem ipsum "dolor" sit \'amet\' etc.', {
'quotes': 'double'
});
// → 'Lorem ipsum \\"dolor\\" sit \'amet\' etc.'
// → "Lorem ipsum \\\"dolor\\\" sit 'amet' etc."
```
#### `wrap`
The `wrap` option takes a boolean value (`true` or `false`), and defaults to `false` (disabled). When enabled, the output will be a valid CSS string literal wrapped in quotes. The type of quotes can be specified through the `quotes` setting.
```js
cssesc('Lorem ipsum "dolor" sit \'amet\' etc.', {
'quotes': 'single',
'wrap': true
});
// → '\'Lorem ipsum "dolor" sit \\\'amet\\\' etc.\''
// → "\'Lorem ipsum \"dolor\" sit \\\'amet\\\' etc.\'"
cssesc('Lorem ipsum "dolor" sit \'amet\' etc.', {
'quotes': 'double',
'wrap': true
});
// → '"Lorem ipsum \\"dolor\\" sit \'amet\' etc."'
// → "\"Lorem ipsum \\\"dolor\\\" sit \'amet\' etc.\""
```
#### `escapeEverything`
The `escapeEverything` option takes a boolean value (`true` or `false`), and defaults to `false` (disabled). When enabled, all the symbols in the output will be escaped, even printable ASCII symbols.
```js
cssesc('lolwat"foo\'bar', {
'escapeEverything': true
});
// → '\\6C\\6F\\6C\\77\\61\\74\\"\\66\\6F\\6F\\\'\\62\\61\\72'
// → "\\6C\\6F\\6C\\77\\61\\74\\\"\\66\\6F\\6F\\'\\62\\61\\72"
```
#### Overriding the default options globally
The global default settings can be overridden by modifying the `css.options` object. This saves you from passing in an `options` object for every call to `encode` if you want to use the non-default setting.
```js
// Read the global default setting for `escapeEverything`:
cssesc.options.escapeEverything;
// → `false` by default
// Override the global default setting for `escapeEverything`:
cssesc.options.escapeEverything = true;
// Using the global default setting for `escapeEverything`, which is now `true`:
cssesc('foo © bar ≠ baz 𝌆 qux');
// → '\\66\\6F\\6F\\ \\A9\\ \\62\\61\\72\\ \\2260\\ \\62\\61\\7A\\ \\1D306\\ \\71\\75\\78'
```
### `cssesc.version`
A string representing the semantic version number.
### Using the `cssesc` binary
To use the `cssesc` binary in your shell, simply install cssesc globally using npm:
```bash
npm install -g cssesc
```
After that you will be able to escape text for use in CSS strings or identifiers from the command line:
```bash
$ cssesc 'föo ♥ bår 𝌆 baz'
f\F6o \2665 b\E5r \1D306 baz
```
If the output needs to be a CSS identifier rather than part of a string literal, use the `-i`/`--identifier` option:
```bash
$ cssesc --identifier 'föo ♥ bår 𝌆 baz'
f\F6o\ \2665\ b\E5r\ \1D306\ baz
```
See `cssesc --help` for the full list of options.
## Support
This library supports the Node.js and browser versions mentioned in [`.babelrc`](https://github.com/mathiasbynens/cssesc/blob/master/.babelrc). For a version that supports a wider variety of legacy browsers and environments out-of-the-box, [see v0.1.0](https://github.com/mathiasbynens/cssesc/releases/tag/v0.1.0).
## Author
| [![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") |
|---|
| [Mathias Bynens](https://mathiasbynens.be/) |
## License
This library is available under the [MIT](https://mths.be/mit) license.

116
node_modules/cssesc/bin/cssesc generated vendored Executable file
View File

@ -0,0 +1,116 @@
#!/usr/bin/env node
const fs = require('fs');
const cssesc = require('../cssesc.js');
const strings = process.argv.splice(2);
const stdin = process.stdin;
const options = {};
const log = console.log;
const main = function() {
const option = strings[0];
if (/^(?:-h|--help|undefined)$/.test(option)) {
log(
'cssesc v%s - https://mths.be/cssesc',
cssesc.version
);
log([
'\nUsage:\n',
'\tcssesc [string]',
'\tcssesc [-i | --identifier] [string]',
'\tcssesc [-s | --single-quotes] [string]',
'\tcssesc [-d | --double-quotes] [string]',
'\tcssesc [-w | --wrap] [string]',
'\tcssesc [-e | --escape-everything] [string]',
'\tcssesc [-v | --version]',
'\tcssesc [-h | --help]',
'\nExamples:\n',
'\tcssesc \'f\xF6o \u2665 b\xE5r \uD834\uDF06 baz\'',
'\tcssesc --identifier \'f\xF6o \u2665 b\xE5r \uD834\uDF06 baz\'',
'\tcssesc --escape-everything \'f\xF6o \u2665 b\xE5r \uD834\uDF06 baz\'',
'\tcssesc --double-quotes --wrap \'f\xF6o \u2665 b\xE5r \uD834\uDF06 baz\'',
'\techo \'f\xF6o \u2665 b\xE5r \uD834\uDF06 baz\' | cssesc'
].join('\n'));
return process.exit(1);
}
if (/^(?:-v|--version)$/.test(option)) {
log('v%s', cssesc.version);
return process.exit(1);
}
strings.forEach(function(string) {
// Process options
if (/^(?:-i|--identifier)$/.test(string)) {
options.isIdentifier = true;
return;
}
if (/^(?:-s|--single-quotes)$/.test(string)) {
options.quotes = 'single';
return;
}
if (/^(?:-d|--double-quotes)$/.test(string)) {
options.quotes = 'double';
return;
}
if (/^(?:-w|--wrap)$/.test(string)) {
options.wrap = true;
return;
}
if (/^(?:-e|--escape-everything)$/.test(string)) {
options.escapeEverything = true;
return;
}
// Process string(s)
let result;
try {
result = cssesc(string, options);
log(result);
} catch (exception) {
log(exception.message + '\n');
log('Error: failed to escape.');
log('If you think this is a bug in cssesc, please report it:');
log('https://github.com/mathiasbynens/cssesc/issues/new');
log(
'\nStack trace using cssesc@%s:\n',
cssesc.version
);
log(exception.stack);
return process.exit(1);
}
});
// Return with exit status 0 outside of the `forEach` loop, in case
// multiple strings were passed in.
return process.exit(0);
};
if (stdin.isTTY) {
// handle shell arguments
main();
} else {
let timeout;
// Either the script is called from within a non-TTY context, or `stdin`
// content is being piped in.
if (!process.stdout.isTTY) {
// The script was called from a non-TTY context. This is a rather uncommon
// use case we dont actively support. However, we dont want the script
// to wait forever in such cases, so…
timeout = setTimeout(function() {
// …if no piped data arrived after a whole minute, handle shell
// arguments instead.
main();
}, 60000);
}
let data = '';
stdin.on('data', function(chunk) {
clearTimeout(timeout);
data += chunk;
});
stdin.on('end', function() {
strings.push(data.trim());
main();
});
stdin.resume();
}

110
node_modules/cssesc/cssesc.js generated vendored Normal file
View File

@ -0,0 +1,110 @@
/*! https://mths.be/cssesc v3.0.0 by @mathias */
'use strict';
var object = {};
var hasOwnProperty = object.hasOwnProperty;
var merge = function merge(options, defaults) {
if (!options) {
return defaults;
}
var result = {};
for (var key in defaults) {
// `if (defaults.hasOwnProperty(key) { … }` is not needed here, since
// only recognized option names are used.
result[key] = hasOwnProperty.call(options, key) ? options[key] : defaults[key];
}
return result;
};
var regexAnySingleEscape = /[ -,\.\/:-@\[-\^`\{-~]/;
var regexSingleEscape = /[ -,\.\/:-@\[\]\^`\{-~]/;
var regexAlwaysEscape = /['"\\]/;
var regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
// https://mathiasbynens.be/notes/css-escapes#css
var cssesc = function cssesc(string, options) {
options = merge(options, cssesc.options);
if (options.quotes != 'single' && options.quotes != 'double') {
options.quotes = 'single';
}
var quote = options.quotes == 'double' ? '"' : '\'';
var isIdentifier = options.isIdentifier;
var firstChar = string.charAt(0);
var output = '';
var counter = 0;
var length = string.length;
while (counter < length) {
var character = string.charAt(counter++);
var codePoint = character.charCodeAt();
var value = void 0;
// If its not a printable ASCII character…
if (codePoint < 0x20 || codePoint > 0x7E) {
if (codePoint >= 0xD800 && codePoint <= 0xDBFF && counter < length) {
// Its a high surrogate, and there is a next character.
var extra = string.charCodeAt(counter++);
if ((extra & 0xFC00) == 0xDC00) {
// next character is low surrogate
codePoint = ((codePoint & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
} else {
// Its an unmatched surrogate; only append this code unit, in case
// the next code unit is the high surrogate of a surrogate pair.
counter--;
}
}
value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
} else {
if (options.escapeEverything) {
if (regexAnySingleEscape.test(character)) {
value = '\\' + character;
} else {
value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
}
} else if (/[\t\n\f\r\x0B]/.test(character)) {
value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
} else if (character == '\\' || !isIdentifier && (character == '"' && quote == character || character == '\'' && quote == character) || isIdentifier && regexSingleEscape.test(character)) {
value = '\\' + character;
} else {
value = character;
}
}
output += value;
}
if (isIdentifier) {
if (/^-[-\d]/.test(output)) {
output = '\\-' + output.slice(1);
} else if (/\d/.test(firstChar)) {
output = '\\3' + firstChar + ' ' + output.slice(1);
}
}
// Remove spaces after `\HEX` escapes that are not followed by a hex digit,
// since theyre redundant. Note that this is only possible if the escape
// sequence isnt preceded by an odd number of backslashes.
output = output.replace(regexExcessiveSpaces, function ($0, $1, $2) {
if ($1 && $1.length % 2) {
// Its not safe to remove the space, so dont.
return $0;
}
// Strip the space.
return ($1 || '') + $2;
});
if (!isIdentifier && options.wrap) {
return quote + output + quote;
}
return output;
};
// Expose default options (so they can be overridden globally).
cssesc.options = {
'escapeEverything': false,
'isIdentifier': false,
'quotes': 'single',
'wrap': false
};
cssesc.version = '3.0.0';
module.exports = cssesc;

70
node_modules/cssesc/man/cssesc.1 generated vendored Normal file
View File

@ -0,0 +1,70 @@
.Dd August 9, 2013
.Dt cssesc 1
.Sh NAME
.Nm cssesc
.Nd escape text for use in CSS string literals or identifiers
.Sh SYNOPSIS
.Nm
.Op Fl i | -identifier Ar string
.br
.Op Fl s | -single-quotes Ar string
.br
.Op Fl d | -double-quotes Ar string
.br
.Op Fl w | -wrap Ar string
.br
.Op Fl e | -escape-everything Ar string
.br
.Op Fl v | -version
.br
.Op Fl h | -help
.Sh DESCRIPTION
.Nm
escapes strings for use in CSS string literals or identifiers while generating the shortest possible valid ASCII-only output.
.Sh OPTIONS
.Bl -ohang -offset
.It Sy "-s, --single-quotes"
Escape any occurences of ' in the input string as \\', so that the output can be used in a CSS string literal wrapped in single quotes.
.It Sy "-d, --double-quotes"
Escape any occurences of " in the input string as \\", so that the output can be used in a CSS string literal wrapped in double quotes.
.It Sy "-w, --wrap"
Make sure the output is a valid CSS string literal wrapped in quotes. The type of quotes can be specified using the
.Ar -s | --single-quotes
or
.Ar -d | --double-quotes
settings.
.It Sy "-e, --escape-everything"
Escape all the symbols in the output, even printable ASCII symbols.
.It Sy "-v, --version"
Print cssesc's version.
.It Sy "-h, --help"
Show the help screen.
.El
.Sh EXIT STATUS
The
.Nm cssesc
utility exits with one of the following values:
.Pp
.Bl -tag -width flag -compact
.It Li 0
.Nm
successfully escaped the given text and printed the result.
.It Li 1
.Nm
wasn't instructed to escape anything (for example, the
.Ar --help
flag was set); or, an error occurred.
.El
.Sh EXAMPLES
.Bl -ohang -offset
.It Sy "cssesc 'foo bar baz'"
Print an escaped version of the given text.
.It Sy echo\ 'foo bar baz'\ |\ cssesc
Print an escaped version of the text that gets piped in.
.El
.Sh BUGS
cssesc's bug tracker is located at <https://github.com/mathiasbynens/cssesc/issues>.
.Sh AUTHOR
Mathias Bynens <https://mathiasbynens.be/>
.Sh WWW
<https://mths.be/cssesc>

51
node_modules/cssesc/package.json generated vendored Normal file
View File

@ -0,0 +1,51 @@
{
"name": "cssesc",
"version": "3.0.0",
"description": "A JavaScript library for escaping CSS strings and identifiers while generating the shortest possible ASCII-only output.",
"homepage": "https://mths.be/cssesc",
"engines": {
"node": ">=4"
},
"main": "cssesc.js",
"bin": "bin/cssesc",
"man": "man/cssesc.1",
"keywords": [
"css",
"escape",
"identifier",
"string",
"tool"
],
"license": "MIT",
"author": {
"name": "Mathias Bynens",
"url": "https://mathiasbynens.be/"
},
"repository": {
"type": "git",
"url": "https://github.com/mathiasbynens/cssesc.git"
},
"bugs": "https://github.com/mathiasbynens/cssesc/issues",
"files": [
"LICENSE-MIT.txt",
"cssesc.js",
"bin/",
"man/"
],
"scripts": {
"build": "grunt template && babel cssesc.js -o cssesc.js",
"test": "mocha tests",
"cover": "istanbul cover --report html node_modules/.bin/_mocha tests -- -u exports -R spec"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.6.1",
"codecov": "^1.0.1",
"grunt": "^1.0.1",
"grunt-template": "^1.0.0",
"istanbul": "^0.4.4",
"mocha": "^2.5.3",
"regenerate": "^1.2.1",
"requirejs": "^2.1.16"
}
}

21
node_modules/culori/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Dan Burzo
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.

19
node_modules/culori/README.md generated vendored Normal file
View File

@ -0,0 +1,19 @@
![culori](./docs/img/culori.svg)
<a href="https://www.npmjs.org/package/culori"><img src="https://img.shields.io/npm/v/culori.svg?style=flat-square&labelColor=d84f4c&color=black" alt="npm version"></a> <a href="https://bundlephobia.com/result?p=culori"><img src="https://img.shields.io/bundlephobia/minzip/culori?style=flat-square&labelColor=d84f4c&color=black" alt="bundle size"></a>
Culori is a comprehensive color library for JavaScript that works across many color spaces to offer conversion, interpolation, color difference formulas, blending functions, and more. It provides up-to-date support for the color spaces defined in [CSS Color Module Level 4](https://drafts.csswg.org/css-color/) specification.
```bash
npm install culori
```
The full documentation is published on [culorijs.org](https://culorijs.org). Some quick entry points:
- [Getting started](https://culorijs.org/getting-started)
- [API References](https://culorijs.org/api/)
- [Supported color spaces](https://culorijs.org/color-spaces/)
## Contributing
Contributions of any kind (feedback, ideas, bug fixes) are welcome. Please open a GitHub issue before starting work on anything that's not straightforward.

4787
node_modules/culori/bundled/culori.cjs generated vendored Normal file

File diff suppressed because it is too large Load Diff

1
node_modules/culori/bundled/culori.cjs.map generated vendored Normal file

File diff suppressed because one or more lines are too long

4789
node_modules/culori/bundled/culori.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

4
node_modules/culori/bundled/culori.min.cjs generated vendored Normal file

File diff suppressed because one or more lines are too long

4
node_modules/culori/bundled/culori.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

4
node_modules/culori/bundled/culori.min.mjs generated vendored Normal file

File diff suppressed because one or more lines are too long

1
node_modules/culori/bundled/culori.min.mjs.map generated vendored Normal file

File diff suppressed because one or more lines are too long

4765
node_modules/culori/bundled/culori.mjs generated vendored Normal file

File diff suppressed because it is too large Load Diff

4800
node_modules/culori/bundled/culori.umd.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

3688
node_modules/culori/bundled/meta.json generated vendored Normal file

File diff suppressed because it is too large Load Diff

88
node_modules/culori/package.json generated vendored Normal file
View File

@ -0,0 +1,88 @@
{
"name": "culori",
"version": "3.3.0",
"type": "module",
"main": "./bundled/culori.cjs",
"module": "./bundled/culori.min.mjs",
"browser": "./bundled/culori.min.js",
"jsdelivr": "./bundled/culori.umd.js",
"exports": {
"./require": "./bundled/culori.cjs",
".": "./src/index.js",
"./css": "./src/bootstrap/css.js",
"./all": "./src/bootstrap/all.js",
"./fn": "./src/index-fn.js",
"./package.json": "./package.json"
},
"repository": "git@github.com:Evercoder/culori.git",
"author": "Dan Burzo <dan@danburzo.ro>",
"description": "A general-purpose color library for JavaScript",
"keywords": [
"blend",
"ciede2000",
"cielab",
"color",
"color-difference",
"cubehelix",
"din99",
"gradients",
"hsi",
"hsl",
"hsv",
"hwb",
"interpolation",
"lab",
"lch",
"lrgb",
"mix",
"rgb",
"yiq"
],
"license": "MIT",
"files": [
"bundled",
"src"
],
"devDependencies": {
"@11ty/eleventy": "^2.0.1",
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
"esbuild": "^0.17.19",
"eslint": "^8.41.0",
"eslint-plugin-import": "^2.27.5",
"gh-pages": "^5.0.0",
"prettier": "^2.8.8",
"pretty-quick": "^3.1.3",
"tap-spec": "^5.0.0",
"tape": "^5.6.3"
},
"scripts": {
"prepare": "git config core.hooksPath .git-hooks",
"test": "tape 'test/**/*.test.js' | tap-spec",
"start": "npx esbuild --servedir=.",
"build": "node build.js",
"benchmark": "node benchmark/index.js",
"prepublishOnly": "npm run lint && npm run build && npm run test",
"docs:start": "eleventy --config=eleventy.config.cjs --serve",
"docs:build": "npm run build && rm -rf www && eleventy --config=eleventy.config.cjs && cp bundled/culori.min.mjs www/",
"docs:deploy": "npm run docs:build && gh-pages -d www --dotfiles",
"lint": "eslint '{src,test}/**/*.js'"
},
"prettier": {
"bracketSpacing": true,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"useTabs": true,
"tabWidth": 4,
"arrowParens": "avoid",
"printWidth": 80
},
"sideEffects": [
"src/index.js",
"src/bootstrap/all.js",
"src/bootstrap/css.js"
],
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
}
}

14
node_modules/culori/src/_prepare.js generated vendored Normal file
View File

@ -0,0 +1,14 @@
import parse from './parse.js';
const prepare = (color, mode) =>
color === undefined
? undefined
: typeof color !== 'object'
? parse(color)
: color.mode !== undefined
? color
: mode
? { ...color, mode }
: undefined;
export default prepare;

37
node_modules/culori/src/a98/convertA98ToXyz65.js generated vendored Normal file
View File

@ -0,0 +1,37 @@
/*
Convert A98 RGB values to CIE XYZ D65
References:
* https://drafts.csswg.org/css-color/#color-conversion-code
* http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
* https://www.adobe.com/digitalimag/pdfs/AdobeRGB1998.pdf
*/
const linearize = v => Math.pow(Math.abs(v), 563 / 256) * Math.sign(v);
const convertA98ToXyz65 = a98 => {
let r = linearize(a98.r);
let g = linearize(a98.g);
let b = linearize(a98.b);
let res = {
mode: 'xyz65',
x:
0.5766690429101305 * r +
0.1855582379065463 * g +
0.1882286462349947 * b,
y:
0.297344975250536 * r +
0.6273635662554661 * g +
0.0752914584939979 * b,
z:
0.0270313613864123 * r +
0.0706888525358272 * g +
0.9913375368376386 * b
};
if (a98.alpha !== undefined) {
res.alpha = a98.alpha;
}
return res;
};
export default convertA98ToXyz65;

36
node_modules/culori/src/a98/convertXyz65ToA98.js generated vendored Normal file
View File

@ -0,0 +1,36 @@
/*
Convert CIE XYZ D65 values to A98 RGB
References:
* https://drafts.csswg.org/css-color/#color-conversion-code
* http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
*/
const gamma = v => Math.pow(Math.abs(v), 256 / 563) * Math.sign(v);
const convertXyz65ToA98 = ({ x, y, z, alpha }) => {
let res = {
mode: 'a98',
r: gamma(
x * 2.0415879038107465 -
y * 0.5650069742788597 -
0.3447313507783297 * z
),
g: gamma(
x * -0.9692436362808798 +
y * 1.8759675015077206 +
0.0415550574071756 * z
),
b: gamma(
x * 0.0134442806320312 -
y * 0.1183623922310184 +
1.0151749943912058 * z
)
};
if (alpha !== undefined) {
res.alpha = alpha;
}
return res;
};
export default convertXyz65ToA98;

25
node_modules/culori/src/a98/definition.js generated vendored Normal file
View File

@ -0,0 +1,25 @@
import rgb from '../rgb/definition.js';
import convertA98ToXyz65 from './convertA98ToXyz65.js';
import convertXyz65ToA98 from './convertXyz65ToA98.js';
import convertRgbToXyz65 from '../xyz65/convertRgbToXyz65.js';
import convertXyz65ToRgb from '../xyz65/convertXyz65ToRgb.js';
const definition = {
...rgb,
mode: 'a98',
parse: ['a98-rgb'],
serialize: 'a98-rgb',
fromMode: {
rgb: color => convertXyz65ToA98(convertRgbToXyz65(color)),
xyz65: convertXyz65ToA98
},
toMode: {
rgb: color => convertXyz65ToRgb(convertA98ToXyz65(color)),
xyz65: convertA98ToXyz65
}
};
export default definition;

52
node_modules/culori/src/average.js generated vendored Normal file
View File

@ -0,0 +1,52 @@
import converter from './converter.js';
import { getMode } from './modes.js';
const averageAngle = val => {
// See: https://en.wikipedia.org/wiki/Mean_of_circular_quantities
let sum = val.reduce(
(sum, val) => {
if (val !== undefined) {
let rad = (val * Math.PI) / 180;
sum.sin += Math.sin(rad);
sum.cos += Math.cos(rad);
}
return sum;
},
{ sin: 0, cos: 0 }
);
return (Math.atan2(sum.sin, sum.cos) * 180) / Math.PI;
};
const averageNumber = val => {
let a = val.filter(v => v !== undefined);
return a.length ? a.reduce((sum, v) => sum + v, 0) / a.length : undefined;
};
const isfn = o => typeof o === 'function';
function average(colors, mode = 'rgb', overrides) {
let def = getMode(mode);
let cc = colors.map(converter(mode));
return def.channels.reduce(
(res, ch) => {
let arr = cc.map(c => c[ch]).filter(val => val !== undefined);
if (arr.length) {
let fn;
if (isfn(overrides)) {
fn = overrides;
} else if (overrides && isfn(overrides[ch])) {
fn = overrides[ch];
} else if (def.average && isfn(def.average[ch])) {
fn = def.average[ch];
} else {
fn = averageNumber;
}
res[ch] = fn(arr, ch);
}
return res;
},
{ mode }
);
}
export { average, averageAngle, averageNumber };

81
node_modules/culori/src/blend.js generated vendored Normal file
View File

@ -0,0 +1,81 @@
/*
Color blend modes, as defined in the
CSS Compositing Level 4 spec
https://drafts.fxtf.org/compositing-2/
https://en.wikipedia.org/wiki/Blend_modes
https://en.wikipedia.org/wiki/Alpha_compositing
https://keithp.com/~keithp/porterduff/p253-porter.pdf
*/
import converter from './converter.js';
import { getMode } from './modes.js';
const BLENDS = {
normal: (b, s) => s,
multiply: (b, s) => b * s,
screen: (b, s) => b + s - b * s,
'hard-light': (b, s) => (s < 0.5 ? b * 2 * s : 2 * s * (1 - b) - 1),
overlay: (b, s) => (b < 0.5 ? s * 2 * b : 2 * b * (1 - s) - 1),
darken: (b, s) => Math.min(b, s),
lighten: (b, s) => Math.max(b, s),
'color-dodge': (b, s) =>
b === 0 ? 0 : s === 1 ? 1 : Math.min(1, b / (1 - s)),
'color-burn': (b, s) =>
b === 1 ? 1 : s === 0 ? 0 : 1 - Math.min(1, (1 - b) / s),
'soft-light': (b, s) =>
s < 0.5
? b - (1 - 2 * s) * b * (1 - b)
: b +
(2 * s - 1) *
((b < 0.25 ? ((16 * b - 12) * b + 4) * b : Math.sqrt(b)) -
b),
difference: (b, s) => Math.abs(b - s),
exclusion: (b, s) => b + s - 2 * b * s
};
const blend = (colors, type = 'normal', mode = 'rgb') => {
let fn = typeof type === 'function' ? type : BLENDS[type];
let conv = converter(mode);
// get mode channels
let channels = getMode(mode).channels;
// convert all colors to the mode
// and assume undefined alphas are 1
let converted = colors.map(c => {
let cc = conv(c);
if (cc.alpha === undefined) {
cc.alpha = 1;
}
return cc;
});
return converted.reduce((b, s) => {
if (b === undefined) return s;
// blend backdrop and source
let alpha = s.alpha + b.alpha * (1 - s.alpha);
return channels.reduce(
(res, ch) => {
if (ch !== 'alpha') {
if (alpha === 0) {
res[ch] = 0;
} else {
res[ch] =
s.alpha * (1 - b.alpha) * s[ch] +
s.alpha * b.alpha * fn(b[ch], s[ch]) +
(1 - s.alpha) * b.alpha * b[ch];
// TODO fix() assumes [0, 1] colors
// and is only true for RGB / LRGB
res[ch] = Math.max(0, Math.min(1, res[ch] / alpha));
}
}
return res;
},
{ mode, alpha }
);
});
};
export default blend;

61
node_modules/culori/src/bootstrap/all.js generated vendored Normal file
View File

@ -0,0 +1,61 @@
// Color space definitions
import modeA98 from '../a98/definition.js';
import modeCubehelix from '../cubehelix/definition.js';
import modeDlab from '../dlab/definition.js';
import modeDlch from '../dlch/definition.js';
import modeHsi from '../hsi/definition.js';
import modeHsl from '../hsl/definition.js';
import modeHsv from '../hsv/definition.js';
import modeHwb from '../hwb/definition.js';
import modeJab from '../jab/definition.js';
import modeJch from '../jch/definition.js';
import modeLab from '../lab/definition.js';
import modeLab65 from '../lab65/definition.js';
import modeLch from '../lch/definition.js';
import modeLch65 from '../lch65/definition.js';
import modeLchuv from '../lchuv/definition.js';
import modeLrgb from '../lrgb/definition.js';
import modeLuv from '../luv/definition.js';
import modeOkhsl from '../okhsl/modeOkhsl.js';
import modeOkhsv from '../okhsv/modeOkhsv.js';
import modeOklab from '../oklab/definition.js';
import modeOklch from '../oklch/definition.js';
import modeP3 from '../p3/definition.js';
import modeProphoto from '../prophoto/definition.js';
import modeRec2020 from '../rec2020/definition.js';
import modeRgb from '../rgb/definition.js';
import modeXyb from '../xyb/definition.js';
import modeXyz50 from '../xyz50/definition.js';
import modeXyz65 from '../xyz65/definition.js';
import modeYiq from '../yiq/definition.js';
import { useMode } from '../modes.js';
export const a98 = useMode(modeA98);
export const cubehelix = useMode(modeCubehelix);
export const dlab = useMode(modeDlab);
export const dlch = useMode(modeDlch);
export const hsi = useMode(modeHsi);
export const hsl = useMode(modeHsl);
export const hsv = useMode(modeHsv);
export const hwb = useMode(modeHwb);
export const jab = useMode(modeJab);
export const jch = useMode(modeJch);
export const lab = useMode(modeLab);
export const lab65 = useMode(modeLab65);
export const lch = useMode(modeLch);
export const lch65 = useMode(modeLch65);
export const lchuv = useMode(modeLchuv);
export const lrgb = useMode(modeLrgb);
export const luv = useMode(modeLuv);
export const okhsl = useMode(modeOkhsl);
export const okhsv = useMode(modeOkhsv);
export const oklab = useMode(modeOklab);
export const oklch = useMode(modeOklch);
export const p3 = useMode(modeP3);
export const prophoto = useMode(modeProphoto);
export const rec2020 = useMode(modeRec2020);
export const rgb = useMode(modeRgb);
export const xyb = useMode(modeXyb);
export const xyz50 = useMode(modeXyz50);
export const xyz65 = useMode(modeXyz65);
export const yiq = useMode(modeYiq);

37
node_modules/culori/src/bootstrap/css.js generated vendored Normal file
View File

@ -0,0 +1,37 @@
// Color space definitions
import modeA98 from '../a98/definition.js';
import modeHsl from '../hsl/definition.js';
import modeHsv from '../hsv/definition.js';
import modeHwb from '../hwb/definition.js';
import modeLab from '../lab/definition.js';
import modeLab65 from '../lab65/definition.js';
import modeLch from '../lch/definition.js';
import modeLch65 from '../lch65/definition.js';
import modeLrgb from '../lrgb/definition.js';
import modeOklab from '../oklab/definition.js';
import modeOklch from '../oklch/definition.js';
import modeP3 from '../p3/definition.js';
import modeProphoto from '../prophoto/definition.js';
import modeRec2020 from '../rec2020/definition.js';
import modeRgb from '../rgb/definition.js';
import modeXyz50 from '../xyz50/definition.js';
import modeXyz65 from '../xyz65/definition.js';
import { useMode } from '../modes.js';
export const a98 = useMode(modeA98);
export const hsl = useMode(modeHsl);
export const hsv = useMode(modeHsv);
export const hwb = useMode(modeHwb);
export const lab = useMode(modeLab);
export const lab65 = useMode(modeLab65);
export const lch = useMode(modeLch);
export const lch65 = useMode(modeLch65);
export const lrgb = useMode(modeLrgb);
export const oklab = useMode(modeOklab);
export const oklch = useMode(modeOklch);
export const p3 = useMode(modeP3);
export const prophoto = useMode(modeProphoto);
export const rec2020 = useMode(modeRec2020);
export const rgb = useMode(modeRgb);
export const xyz50 = useMode(modeXyz50);
export const xyz65 = useMode(modeXyz65);

255
node_modules/culori/src/clamp.js generated vendored Normal file
View File

@ -0,0 +1,255 @@
import converter from './converter.js';
import prepare from './_prepare.js';
import { getMode } from './modes.js';
import { differenceEuclidean } from './difference.js';
const rgb = converter('rgb');
const fixup_rgb = c => {
const res = {
mode: c.mode,
r: Math.max(0, Math.min(c.r, 1)),
g: Math.max(0, Math.min(c.g, 1)),
b: Math.max(0, Math.min(c.b, 1))
};
if (c.alpha !== undefined) {
res.alpha = c.alpha;
}
return res;
};
const to_displayable_srgb = c => fixup_rgb(rgb(c));
const inrange_rgb = c => {
return (
c !== undefined &&
c.r >= 0 &&
c.r <= 1 &&
c.g >= 0 &&
c.g <= 1 &&
c.b >= 0 &&
c.b <= 1
);
};
/*
Returns whether the color is in the sRGB gamut.
*/
export function displayable(color) {
return inrange_rgb(rgb(color));
}
/*
Given a color space `mode`, returns a function
with which to check whether a color is
in that color space's gamut.
*/
export function inGamut(mode = 'rgb') {
const { gamut } = getMode(mode);
if (!gamut) {
return color => true;
}
const conv = converter(typeof gamut === 'string' ? gamut : mode);
return color => inrange_rgb(conv(color));
}
/*
Obtain a color that's in the sRGB gamut
by converting it to sRGB and clipping the channel values
so that they're within the [0, 1] range.
The result is returned in the color's original color space.
*/
export function clampRgb(color) {
color = prepare(color);
// if the color is undefined or displayable, return it directly
if (color === undefined || displayable(color)) return color;
// keep track of color's original mode
let conv = converter(color.mode);
return conv(to_displayable_srgb(color));
}
/*
Given the `mode` color space, returns a function
with which to obtain a color that's in gamut for
the `mode` color space by clipping the channel values
so that they fit in their respective ranges.
It's similar to `clampRgb`, but works for any
bounded color space (RGB or not) for which
any combination of in-range channel values
produces an in-gamut color.
*/
export function clampGamut(mode = 'rgb') {
const { gamut } = getMode(mode);
if (!gamut) {
return color => prepare(color);
}
const destMode = typeof gamut === 'string' ? gamut : mode;
const destConv = converter(destMode);
const inDestGamut = inGamut(destMode);
return color => {
const original = prepare(color);
if (!original) {
return undefined;
}
const converted = destConv(original);
if (inDestGamut(converted)) {
return original;
}
const clamped = fixup_rgb(converted);
if (original.mode === clamped.mode) {
return clamped;
}
return converter(original.mode)(clamped);
};
}
/*
Obtain a color thats in a RGB gamut (by default sRGB)
by first converting it to `mode` and then finding
the greatest chroma value that fits the gamut.
By default, the CIELCh color space is used,
but any color that has a chroma component will do.
The result is returned in the color's original color space.
*/
export function clampChroma(color, mode = 'lch', rgbGamut = 'rgb') {
color = prepare(color);
let inDestinationGamut =
rgbGamut === 'rgb' ? displayable : inGamut(rgbGamut);
let clipToGamut =
rgbGamut === 'rgb' ? to_displayable_srgb : clampGamut(rgbGamut);
// if the color is undefined or displayable, return it directly
if (color === undefined || inDestinationGamut(color)) return color;
// keep track of color's original mode
let conv = converter(color.mode);
// convert to the provided `mode` for clamping
color = converter(mode)(color);
// try with chroma = 0
let clamped = { ...color, c: 0 };
// if not even chroma = 0 is displayable
// fall back to RGB clamping
if (!inDestinationGamut(clamped)) {
return conv(clipToGamut(clamped));
}
// By this time we know chroma = 0 is displayable and our current chroma is not.
// Find the displayable chroma through the bisection method.
let start = 0;
let end = color.c;
let range = getMode(mode).ranges.c;
let resolution = (range[1] - range[0]) / Math.pow(2, 13);
let _last_good_c;
while (end - start > resolution) {
clamped.c = start + (end - start) * 0.5;
if (inDestinationGamut(clamped)) {
_last_good_c = clamped.c;
start = clamped.c;
} else {
end = clamped.c;
}
}
return conv(
inDestinationGamut(clamped) ? clamped : { ...clamped, c: _last_good_c }
);
}
/*
Obtain a color that's in the `dest` gamut,
by first converting it to the `mode` color space
and then finding the largest chroma that's in gamut,
similar to `clampChroma`.
The color returned is in the `dest` color space.
To address the shortcomings of `clampChroma`, which can
sometimes produce colors more desaturated than necessary,
the test used in the binary search is replaced with
"is color is roughly in gamut", by comparing the candidate
to the clipped version (obtained with `clampGamut`).
The test passes if the colors are not too dissimilar,
judged by the `delta` color difference function
and an associated `jnd` just-noticeable difference value.
The default arguments for this function correspond to the
gamut mapping algorithm defined in CSS Color Level 4:
https://drafts.csswg.org/css-color/#css-gamut-mapping
To disable the roughly in gamut part, pass either
`null` for the `delta` parameter, or zero for `jnd`.
*/
export function toGamut(
dest = 'rgb',
mode = 'oklch',
delta = differenceEuclidean('oklch'),
jnd = 0.02
) {
const destConv = converter(dest);
if (!getMode(dest).gamut) {
return color => destConv(color);
}
const inDestinationGamut = inGamut(dest);
const clipToGamut = clampGamut(dest);
const ucs = converter(mode);
const { ranges } = getMode(mode);
const White = destConv('white');
const Black = destConv('black');
return color => {
color = prepare(color);
if (color === undefined) {
return undefined;
}
const candidate = { ...ucs(color) };
if (candidate.l >= ranges.l[1]) {
const res = { ...White };
if (color.alpha !== undefined) {
res.alpha = color.alpha;
}
return res;
}
if (candidate.l <= ranges.l[0]) {
const res = { ...Black };
if (color.alpha !== undefined) {
res.alpha = color.alpha;
}
return res;
}
if (inDestinationGamut(candidate)) {
return destConv(candidate);
}
let start = 0;
let end = candidate.c;
let epsilon = (ranges.c[1] - ranges.c[0]) / 4000; // 0.0001 for oklch()
let clipped = clipToGamut(candidate);
while (end - start > epsilon) {
candidate.c = (start + end) * 0.5;
clipped = clipToGamut(candidate);
if (
inDestinationGamut(candidate) ||
(delta && jnd > 0 && delta(candidate, clipped) <= jnd)
) {
start = candidate.c;
} else {
end = candidate.c;
}
}
return destConv(inDestinationGamut(candidate) ? candidate : clipped);
};
}

156
node_modules/culori/src/colors/named.js generated vendored Normal file
View File

@ -0,0 +1,156 @@
const named = {
aliceblue: 0xf0f8ff,
antiquewhite: 0xfaebd7,
aqua: 0x00ffff,
aquamarine: 0x7fffd4,
azure: 0xf0ffff,
beige: 0xf5f5dc,
bisque: 0xffe4c4,
black: 0x000000,
blanchedalmond: 0xffebcd,
blue: 0x0000ff,
blueviolet: 0x8a2be2,
brown: 0xa52a2a,
burlywood: 0xdeb887,
cadetblue: 0x5f9ea0,
chartreuse: 0x7fff00,
chocolate: 0xd2691e,
coral: 0xff7f50,
cornflowerblue: 0x6495ed,
cornsilk: 0xfff8dc,
crimson: 0xdc143c,
cyan: 0x00ffff,
darkblue: 0x00008b,
darkcyan: 0x008b8b,
darkgoldenrod: 0xb8860b,
darkgray: 0xa9a9a9,
darkgreen: 0x006400,
darkgrey: 0xa9a9a9,
darkkhaki: 0xbdb76b,
darkmagenta: 0x8b008b,
darkolivegreen: 0x556b2f,
darkorange: 0xff8c00,
darkorchid: 0x9932cc,
darkred: 0x8b0000,
darksalmon: 0xe9967a,
darkseagreen: 0x8fbc8f,
darkslateblue: 0x483d8b,
darkslategray: 0x2f4f4f,
darkslategrey: 0x2f4f4f,
darkturquoise: 0x00ced1,
darkviolet: 0x9400d3,
deeppink: 0xff1493,
deepskyblue: 0x00bfff,
dimgray: 0x696969,
dimgrey: 0x696969,
dodgerblue: 0x1e90ff,
firebrick: 0xb22222,
floralwhite: 0xfffaf0,
forestgreen: 0x228b22,
fuchsia: 0xff00ff,
gainsboro: 0xdcdcdc,
ghostwhite: 0xf8f8ff,
gold: 0xffd700,
goldenrod: 0xdaa520,
gray: 0x808080,
green: 0x008000,
greenyellow: 0xadff2f,
grey: 0x808080,
honeydew: 0xf0fff0,
hotpink: 0xff69b4,
indianred: 0xcd5c5c,
indigo: 0x4b0082,
ivory: 0xfffff0,
khaki: 0xf0e68c,
lavender: 0xe6e6fa,
lavenderblush: 0xfff0f5,
lawngreen: 0x7cfc00,
lemonchiffon: 0xfffacd,
lightblue: 0xadd8e6,
lightcoral: 0xf08080,
lightcyan: 0xe0ffff,
lightgoldenrodyellow: 0xfafad2,
lightgray: 0xd3d3d3,
lightgreen: 0x90ee90,
lightgrey: 0xd3d3d3,
lightpink: 0xffb6c1,
lightsalmon: 0xffa07a,
lightseagreen: 0x20b2aa,
lightskyblue: 0x87cefa,
lightslategray: 0x778899,
lightslategrey: 0x778899,
lightsteelblue: 0xb0c4de,
lightyellow: 0xffffe0,
lime: 0x00ff00,
limegreen: 0x32cd32,
linen: 0xfaf0e6,
magenta: 0xff00ff,
maroon: 0x800000,
mediumaquamarine: 0x66cdaa,
mediumblue: 0x0000cd,
mediumorchid: 0xba55d3,
mediumpurple: 0x9370db,
mediumseagreen: 0x3cb371,
mediumslateblue: 0x7b68ee,
mediumspringgreen: 0x00fa9a,
mediumturquoise: 0x48d1cc,
mediumvioletred: 0xc71585,
midnightblue: 0x191970,
mintcream: 0xf5fffa,
mistyrose: 0xffe4e1,
moccasin: 0xffe4b5,
navajowhite: 0xffdead,
navy: 0x000080,
oldlace: 0xfdf5e6,
olive: 0x808000,
olivedrab: 0x6b8e23,
orange: 0xffa500,
orangered: 0xff4500,
orchid: 0xda70d6,
palegoldenrod: 0xeee8aa,
palegreen: 0x98fb98,
paleturquoise: 0xafeeee,
palevioletred: 0xdb7093,
papayawhip: 0xffefd5,
peachpuff: 0xffdab9,
peru: 0xcd853f,
pink: 0xffc0cb,
plum: 0xdda0dd,
powderblue: 0xb0e0e6,
purple: 0x800080,
// Added in CSS Colors Level 4:
// https://drafts.csswg.org/css-color/#changes-from-3
rebeccapurple: 0x663399,
red: 0xff0000,
rosybrown: 0xbc8f8f,
royalblue: 0x4169e1,
saddlebrown: 0x8b4513,
salmon: 0xfa8072,
sandybrown: 0xf4a460,
seagreen: 0x2e8b57,
seashell: 0xfff5ee,
sienna: 0xa0522d,
silver: 0xc0c0c0,
skyblue: 0x87ceeb,
slateblue: 0x6a5acd,
slategray: 0x708090,
slategrey: 0x708090,
snow: 0xfffafa,
springgreen: 0x00ff7f,
steelblue: 0x4682b4,
tan: 0xd2b48c,
teal: 0x008080,
thistle: 0xd8bfd8,
tomato: 0xff6347,
turquoise: 0x40e0d0,
violet: 0xee82ee,
wheat: 0xf5deb3,
white: 0xffffff,
whitesmoke: 0xf5f5f5,
yellow: 0xffff00,
yellowgreen: 0x9acd32
};
export default named;

22
node_modules/culori/src/constants.js generated vendored Normal file
View File

@ -0,0 +1,22 @@
/*
The XYZ tristimulus values (white point)
of standard illuminants for the CIE 1931 2°
standard observer.
See: https://en.wikipedia.org/wiki/Standard_illuminant
*/
export const D50 = {
X: 0.3457 / 0.3585,
Y: 1,
Z: (1 - 0.3457 - 0.3585) / 0.3585
};
export const D65 = {
X: 0.3127 / 0.329,
Y: 1,
Z: (1 - 0.3127 - 0.329) / 0.329
};
export const k = Math.pow(29, 3) / Math.pow(3, 3);
export const e = Math.pow(6, 3) / Math.pow(29, 3);

26
node_modules/culori/src/converter.js generated vendored Normal file
View File

@ -0,0 +1,26 @@
import { converters } from './modes.js';
import prepare from './_prepare.js';
const converter =
(target_mode = 'rgb') =>
color =>
(color = prepare(color, target_mode)) !== undefined
? // if the color's mode corresponds to our target mode
color.mode === target_mode
? // then just return the color
color
: // otherwise check to see if we have a dedicated
// converter for the target mode
converters[color.mode][target_mode]
? // and return its result...
converters[color.mode][target_mode](color)
: // ...otherwise pass through RGB as an intermediary step.
// if the target mode is RGB...
target_mode === 'rgb'
? // just return the RGB
converters[color.mode].rgb(color)
: // otherwise convert color.mode -> RGB -> target_mode
converters.rgb[target_mode](converters[color.mode].rgb(color))
: undefined;
export default converter;

4
node_modules/culori/src/cubehelix/constants.js generated vendored Normal file
View File

@ -0,0 +1,4 @@
export const M = [-0.14861, 1.78277, -0.29227, -0.90649, 1.97294, 0];
export const degToRad = Math.PI / 180;
export const radToDeg = 180 / Math.PI;

View File

@ -0,0 +1,21 @@
import { degToRad, M } from './constants.js';
const convertCubehelixToRgb = ({ h, s, l, alpha }) => {
let res = { mode: 'rgb' };
h = (h === undefined ? 0 : h + 120) * degToRad;
let amp = s === undefined ? 0 : s * l * (1 - l);
let cosh = Math.cos(h);
let sinh = Math.sin(h);
res.r = l + amp * (M[0] * cosh + M[1] * sinh);
res.g = l + amp * (M[2] * cosh + M[3] * sinh);
res.b = l + amp * (M[4] * cosh + M[5] * sinh);
if (alpha !== undefined) res.alpha = alpha;
return res;
};
export default convertCubehelixToRgb;

View File

@ -0,0 +1,40 @@
/*
Convert a RGB color to the Cubehelix HSL color space.
This computation is not present in Green's paper:
https://arxiv.org/pdf/1108.5083.pdf
...but can be derived from the inverse, HSL to RGB conversion.
It matches the math in Mike Bostock's D3 implementation:
https://github.com/d3/d3-color/blob/master/src/cubehelix.js
*/
import { radToDeg, M } from './constants.js';
let DE = M[3] * M[4];
let BE = M[1] * M[4];
let BCAD = M[1] * M[2] - M[0] * M[3];
const convertRgbToCubehelix = ({ r, g, b, alpha }) => {
let l = (BCAD * b + r * DE - g * BE) / (BCAD + DE - BE);
let x = b - l;
let y = (M[4] * (g - l) - M[2] * x) / M[3];
let res = {
mode: 'cubehelix',
l: l,
s:
l === 0 || l === 1
? undefined
: Math.sqrt(x * x + y * y) / (M[4] * l * (1 - l))
};
if (res.s) res.h = Math.atan2(y, x) * radToDeg - 120;
if (alpha !== undefined) res.alpha = alpha;
return res;
};
export default convertRgbToCubehelix;

84
node_modules/culori/src/cubehelix/definition.js generated vendored Normal file
View File

@ -0,0 +1,84 @@
/*
Dave Green's Cubehelix
----------------------
Green, D. A., 2011, "A colour scheme for the display of astronomical intensity images",
Bulletin of the Astronomical Society of India, 39, 289. (2011BASI...39..289G at ADS.)
https://www.mrao.cam.ac.uk/%7Edag/CUBEHELIX/
https://arxiv.org/pdf/1108.5083.pdf
Although Cubehelix was defined to be a method to obtain a colour scheme,
it actually contains a definition of a colour space, as identified by
Mike Bostock and implemented in D3.js.
Green's paper introduces the following terminology:
* a `lightness` dimension in the interval [0, 1]
on which we interpolate to obtain the colour scheme
* a `start` colour that is analogous to a Hue in HSL space
* a number of `rotations` around the Hue cylinder.
* a `hue` parameter which should more appropriately be called `saturation`
As such, the original definition of the Cubehelix scheme is actually an
interpolation between two colors in the Cubehelix space:
H: start H: start + 360 * rotations
S: hue -> S: hue
L: 0 L: 1
We can therefore extend the interpolation to any two colors in this space,
with a variable Saturation and a Lightness interval other than the fixed 0 -> 1.
*/
import { fixupHueShorter } from '../fixup/hue.js';
import { fixupAlpha } from '../fixup/alpha.js';
import { interpolatorLinear } from '../interpolate/linear.js';
import convertRgbToCubehelix from './convertRgbToCubehelix.js';
import convertCubehelixToRgb from './convertCubehelixToRgb.js';
import { differenceHueSaturation } from '../difference.js';
import { averageAngle } from '../average.js';
const definition = {
mode: 'cubehelix',
channels: ['h', 's', 'l', 'alpha'],
parse: ['--cubehelix'],
serialize: '--cubehelix',
ranges: {
h: [0, 360],
s: [0, 4.614],
l: [0, 1]
},
fromMode: {
rgb: convertRgbToCubehelix
},
toMode: {
rgb: convertCubehelixToRgb
},
interpolate: {
h: {
use: interpolatorLinear,
fixup: fixupHueShorter
},
s: interpolatorLinear,
l: interpolatorLinear,
alpha: {
use: interpolatorLinear,
fixup: fixupAlpha
}
},
difference: {
h: differenceHueSaturation
},
average: {
h: averageAngle
}
};
export default definition;

190
node_modules/culori/src/deficiency.js generated vendored Normal file
View File

@ -0,0 +1,190 @@
import converter from './converter.js';
import prepare from './_prepare.js';
import { lerp } from './interpolate/lerp.js';
let rgb = converter('rgb');
/*
Color vision deficiency (CVD) simulation based on:
G. M. Machado, M. M. Oliveira and L. A. F. Fernandes,
"A Physiologically-based Model for Simulation of Color Vision Deficiency"
in IEEE Transactions on Visualization and Computer Graphics,
vol. 15, no. 6, pp. 1291-1298, Nov.-Dec. 2009,
doi: 10.1109/TVCG.2009.113.
Functions use precomputed matrices from:
https://www.inf.ufrgs.br/~oliveira/pubs_files/CVD_Simulation/CVD_Simulation.html
Via the `colorspace` R package documentation:
http://colorspace.r-forge.r-project.org/reference/simulate_cvd.html
*/
const PROT = [
[1.0, 0.0, -0.0, 0.0, 1.0, 0.0, -0.0, -0.0, 1.0],
[
0.856167, 0.182038, -0.038205, 0.029342, 0.955115, 0.015544, -0.00288,
-0.001563, 1.004443
],
[
0.734766, 0.334872, -0.069637, 0.05184, 0.919198, 0.028963, -0.004928,
-0.004209, 1.009137
],
[
0.630323, 0.465641, -0.095964, 0.069181, 0.890046, 0.040773, -0.006308,
-0.007724, 1.014032
],
[
0.539009, 0.579343, -0.118352, 0.082546, 0.866121, 0.051332, -0.007136,
-0.011959, 1.019095
],
[
0.458064, 0.679578, -0.137642, 0.092785, 0.846313, 0.060902, -0.007494,
-0.016807, 1.024301
],
[
0.38545, 0.769005, -0.154455, 0.100526, 0.829802, 0.069673, -0.007442,
-0.02219, 1.029632
],
[
0.319627, 0.849633, -0.169261, 0.106241, 0.815969, 0.07779, -0.007025,
-0.028051, 1.035076
],
[
0.259411, 0.923008, -0.18242, 0.110296, 0.80434, 0.085364, -0.006276,
-0.034346, 1.040622
],
[
0.203876, 0.990338, -0.194214, 0.112975, 0.794542, 0.092483, -0.005222,
-0.041043, 1.046265
],
[
0.152286, 1.052583, -0.204868, 0.114503, 0.786281, 0.099216, -0.003882,
-0.048116, 1.051998
]
];
const DEUTER = [
[1.0, 0.0, -0.0, 0.0, 1.0, 0.0, -0.0, -0.0, 1.0],
[
0.866435, 0.177704, -0.044139, 0.049567, 0.939063, 0.01137, -0.003453,
0.007233, 0.99622
],
[
0.760729, 0.319078, -0.079807, 0.090568, 0.889315, 0.020117, -0.006027,
0.013325, 0.992702
],
[
0.675425, 0.43385, -0.109275, 0.125303, 0.847755, 0.026942, -0.00795,
0.018572, 0.989378
],
[
0.605511, 0.52856, -0.134071, 0.155318, 0.812366, 0.032316, -0.009376,
0.023176, 0.9862
],
[
0.547494, 0.607765, -0.155259, 0.181692, 0.781742, 0.036566, -0.01041,
0.027275, 0.983136
],
[
0.498864, 0.674741, -0.173604, 0.205199, 0.754872, 0.039929, -0.011131,
0.030969, 0.980162
],
[
0.457771, 0.731899, -0.18967, 0.226409, 0.731012, 0.042579, -0.011595,
0.034333, 0.977261
],
[
0.422823, 0.781057, -0.203881, 0.245752, 0.709602, 0.044646, -0.011843,
0.037423, 0.974421
],
[
0.392952, 0.82361, -0.216562, 0.263559, 0.69021, 0.046232, -0.01191,
0.040281, 0.97163
],
[
0.367322, 0.860646, -0.227968, 0.280085, 0.672501, 0.047413, -0.01182,
0.04294, 0.968881
]
];
const TRIT = [
[1.0, 0.0, -0.0, 0.0, 1.0, 0.0, -0.0, -0.0, 1.0],
[
0.92667, 0.092514, -0.019184, 0.021191, 0.964503, 0.014306, 0.008437,
0.054813, 0.93675
],
[
0.89572, 0.13333, -0.02905, 0.029997, 0.9454, 0.024603, 0.013027,
0.104707, 0.882266
],
[
0.905871, 0.127791, -0.033662, 0.026856, 0.941251, 0.031893, 0.01341,
0.148296, 0.838294
],
[
0.948035, 0.08949, -0.037526, 0.014364, 0.946792, 0.038844, 0.010853,
0.193991, 0.795156
],
[
1.017277, 0.027029, -0.044306, -0.006113, 0.958479, 0.047634, 0.006379,
0.248708, 0.744913
],
[
1.104996, -0.046633, -0.058363, -0.032137, 0.971635, 0.060503, 0.001336,
0.317922, 0.680742
],
[
1.193214, -0.109812, -0.083402, -0.058496, 0.97941, 0.079086, -0.002346,
0.403492, 0.598854
],
[
1.257728, -0.139648, -0.118081, -0.078003, 0.975409, 0.102594,
-0.003316, 0.501214, 0.502102
],
[
1.278864, -0.125333, -0.153531, -0.084748, 0.957674, 0.127074,
-0.000989, 0.601151, 0.399838
],
[
1.255528, -0.076749, -0.178779, -0.078411, 0.930809, 0.147602, 0.004733,
0.691367, 0.3039
]
];
const deficiency = (lut, t) => {
let tt = Math.max(0, Math.min(1, t));
let i = Math.round(tt / 0.1);
let w = Math.round(tt % 0.1);
let arr = lut[i];
if (w > 0 && i < lut.length - 1) {
let arr_2 = lut[i + 1];
arr = arr.map((v, idx) => lerp(arr[idx], arr_2[idx], w));
}
return color => {
let c = prepare(color);
if (c === undefined) {
return undefined;
}
let { r, g, b } = rgb(c);
let ret = {
mode: 'rgb',
r: arr[0] * r + arr[1] * g + arr[2] * b,
g: arr[3] * r + arr[4] * g + arr[5] * b,
b: arr[6] * r + arr[7] * g + arr[8] * b
};
if (c.alpha !== undefined) {
ret.alpha = c.alpha;
}
return converter(c.mode)(ret);
};
};
export const filterDeficiencyProt = (severity = 1) =>
deficiency(PROT, severity);
export const filterDeficiencyDeuter = (severity = 1) =>
deficiency(DEUTER, severity);
export const filterDeficiencyTrit = (severity = 1) =>
deficiency(TRIT, severity);

306
node_modules/culori/src/difference.js generated vendored Normal file
View File

@ -0,0 +1,306 @@
import { getMode } from './modes.js';
import converter from './converter.js';
import normalizeHue from './util/normalizeHue.js';
const differenceHueSaturation = (std, smp) => {
if (std.h === undefined || smp.h === undefined || !std.s || !smp.s) {
return 0;
}
let std_h = normalizeHue(std.h);
let smp_h = normalizeHue(smp.h);
let dH = Math.sin((((smp_h - std_h + 360) / 2) * Math.PI) / 180);
return 2 * Math.sqrt(std.s * smp.s) * dH;
};
const differenceHueNaive = (std, smp) => {
if (std.h === undefined || smp.h === undefined) {
return 0;
}
let std_h = normalizeHue(std.h);
let smp_h = normalizeHue(smp.h);
if (Math.abs(smp_h - std_h) > 180) {
// todo should this be normalized once again?
return std_h - (smp_h - 360 * Math.sign(smp_h - std_h));
}
return smp_h - std_h;
};
const differenceHueChroma = (std, smp) => {
if (std.h === undefined || smp.h === undefined || !std.c || !smp.c) {
return 0;
}
let std_h = normalizeHue(std.h);
let smp_h = normalizeHue(smp.h);
let dH = Math.sin((((smp_h - std_h + 360) / 2) * Math.PI) / 180);
return 2 * Math.sqrt(std.c * smp.c) * dH;
};
const differenceEuclidean = (mode = 'rgb', weights = [1, 1, 1, 0]) => {
let def = getMode(mode);
let channels = def.channels;
let diffs = def.difference;
let conv = converter(mode);
return (std, smp) => {
let ConvStd = conv(std);
let ConvSmp = conv(smp);
return Math.sqrt(
channels.reduce((sum, k, idx) => {
let delta = diffs[k]
? diffs[k](ConvStd, ConvSmp)
: ConvStd[k] - ConvSmp[k];
return (
sum +
(weights[idx] || 0) * Math.pow(isNaN(delta) ? 0 : delta, 2)
);
}, 0)
);
};
};
const differenceCie76 = () => differenceEuclidean('lab65');
const differenceCie94 = (kL = 1, K1 = 0.045, K2 = 0.015) => {
let lab = converter('lab65');
return (std, smp) => {
let LabStd = lab(std);
let LabSmp = lab(smp);
// Extract Lab values, and compute Chroma
let lStd = LabStd.l;
let aStd = LabStd.a;
let bStd = LabStd.b;
let cStd = Math.sqrt(aStd * aStd + bStd * bStd);
let lSmp = LabSmp.l;
let aSmp = LabSmp.a;
let bSmp = LabSmp.b;
let cSmp = Math.sqrt(aSmp * aSmp + bSmp * bSmp);
let dL2 = Math.pow(lStd - lSmp, 2);
let dC2 = Math.pow(cStd - cSmp, 2);
let dH2 = Math.pow(aStd - aSmp, 2) + Math.pow(bStd - bSmp, 2) - dC2;
return Math.sqrt(
dL2 / Math.pow(kL, 2) +
dC2 / Math.pow(1 + K1 * cStd, 2) +
dH2 / Math.pow(1 + K2 * cStd, 2)
);
};
};
/*
CIEDE2000 color difference, original Matlab implementation by Gaurav Sharma
Based on "The CIEDE2000 Color-Difference Formula: Implementation Notes, Supplementary Test Data, and Mathematical Observations"
by Gaurav Sharma, Wencheng Wu, Edul N. Dalal in Color Research and Application, vol. 30. No. 1, pp. 21-30, February 2005.
http://www2.ece.rochester.edu/~gsharma/ciede2000/
*/
const differenceCiede2000 = (Kl = 1, Kc = 1, Kh = 1) => {
let lab = converter('lab65');
return (std, smp) => {
let LabStd = lab(std);
let LabSmp = lab(smp);
let lStd = LabStd.l;
let aStd = LabStd.a;
let bStd = LabStd.b;
let cStd = Math.sqrt(aStd * aStd + bStd * bStd);
let lSmp = LabSmp.l;
let aSmp = LabSmp.a;
let bSmp = LabSmp.b;
let cSmp = Math.sqrt(aSmp * aSmp + bSmp * bSmp);
let cAvg = (cStd + cSmp) / 2;
let G =
0.5 *
(1 -
Math.sqrt(
Math.pow(cAvg, 7) / (Math.pow(cAvg, 7) + Math.pow(25, 7))
));
let apStd = aStd * (1 + G);
let apSmp = aSmp * (1 + G);
let cpStd = Math.sqrt(apStd * apStd + bStd * bStd);
let cpSmp = Math.sqrt(apSmp * apSmp + bSmp * bSmp);
let hpStd =
Math.abs(apStd) + Math.abs(bStd) === 0
? 0
: Math.atan2(bStd, apStd);
hpStd += (hpStd < 0) * 2 * Math.PI;
let hpSmp =
Math.abs(apSmp) + Math.abs(bSmp) === 0
? 0
: Math.atan2(bSmp, apSmp);
hpSmp += (hpSmp < 0) * 2 * Math.PI;
let dL = lSmp - lStd;
let dC = cpSmp - cpStd;
let dhp = cpStd * cpSmp === 0 ? 0 : hpSmp - hpStd;
dhp -= (dhp > Math.PI) * 2 * Math.PI;
dhp += (dhp < -Math.PI) * 2 * Math.PI;
let dH = 2 * Math.sqrt(cpStd * cpSmp) * Math.sin(dhp / 2);
let Lp = (lStd + lSmp) / 2;
let Cp = (cpStd + cpSmp) / 2;
let hp;
if (cpStd * cpSmp === 0) {
hp = hpStd + hpSmp;
} else {
hp = (hpStd + hpSmp) / 2;
hp -= (Math.abs(hpStd - hpSmp) > Math.PI) * Math.PI;
hp += (hp < 0) * 2 * Math.PI;
}
let Lpm50 = Math.pow(Lp - 50, 2);
let T =
1 -
0.17 * Math.cos(hp - Math.PI / 6) +
0.24 * Math.cos(2 * hp) +
0.32 * Math.cos(3 * hp + Math.PI / 30) -
0.2 * Math.cos(4 * hp - (63 * Math.PI) / 180);
let Sl = 1 + (0.015 * Lpm50) / Math.sqrt(20 + Lpm50);
let Sc = 1 + 0.045 * Cp;
let Sh = 1 + 0.015 * Cp * T;
let deltaTheta =
((30 * Math.PI) / 180) *
Math.exp(-1 * Math.pow(((180 / Math.PI) * hp - 275) / 25, 2));
let Rc =
2 *
Math.sqrt(Math.pow(Cp, 7) / (Math.pow(Cp, 7) + Math.pow(25, 7)));
let Rt = -1 * Math.sin(2 * deltaTheta) * Rc;
return Math.sqrt(
Math.pow(dL / (Kl * Sl), 2) +
Math.pow(dC / (Kc * Sc), 2) +
Math.pow(dH / (Kh * Sh), 2) +
(((Rt * dC) / (Kc * Sc)) * dH) / (Kh * Sh)
);
};
};
/*
CMC (l:c) difference formula
References:
https://en.wikipedia.org/wiki/Color_difference#CMC_l:c_(1984)
http://www.brucelindbloom.com/index.html?Eqn_DeltaE_CMC.html
*/
const differenceCmc = (l = 1, c = 1) => {
let lab = converter('lab65');
/*
Comparte two colors:
std - standard (first) color
smp - sample (second) color
*/
return (std, smp) => {
// convert standard color to Lab
let LabStd = lab(std);
let lStd = LabStd.l;
let aStd = LabStd.a;
let bStd = LabStd.b;
// Obtain hue/chroma
let cStd = Math.sqrt(aStd * aStd + bStd * bStd);
let hStd = Math.atan2(bStd, aStd);
hStd = hStd + 2 * Math.PI * (hStd < 0);
// convert sample color to Lab, obtain LCh
let LabSmp = lab(smp);
let lSmp = LabSmp.l;
let aSmp = LabSmp.a;
let bSmp = LabSmp.b;
// Obtain chroma
let cSmp = Math.sqrt(aSmp * aSmp + bSmp * bSmp);
// lightness delta squared
let dL2 = Math.pow(lStd - lSmp, 2);
// chroma delta squared
let dC2 = Math.pow(cStd - cSmp, 2);
// hue delta squared
let dH2 = Math.pow(aStd - aSmp, 2) + Math.pow(bStd - bSmp, 2) - dC2;
let F = Math.sqrt(Math.pow(cStd, 4) / (Math.pow(cStd, 4) + 1900));
let T =
hStd >= (164 / 180) * Math.PI && hStd <= (345 / 180) * Math.PI
? 0.56 + Math.abs(0.2 * Math.cos(hStd + (168 / 180) * Math.PI))
: 0.36 + Math.abs(0.4 * Math.cos(hStd + (35 / 180) * Math.PI));
let Sl = lStd < 16 ? 0.511 : (0.040975 * lStd) / (1 + 0.01765 * lStd);
let Sc = (0.0638 * cStd) / (1 + 0.0131 * cStd) + 0.638;
let Sh = Sc * (F * T + 1 - F);
return Math.sqrt(
dL2 / Math.pow(l * Sl, 2) +
dC2 / Math.pow(c * Sc, 2) +
dH2 / Math.pow(Sh, 2)
);
};
};
/*
HyAB color difference formula, introduced in:
Abasi S, Amani Tehran M, Fairchild MD.
"Distance metrics for very large color differences."
Color Res Appl. 2019; 116.
https://doi.org/10.1002/col.22451
PDF available at:
http://markfairchild.org/PDFs/PAP40.pdf
*/
const differenceHyab = () => {
let lab = converter('lab65');
return (std, smp) => {
let LabStd = lab(std);
let LabSmp = lab(smp);
let dL = LabStd.l - LabSmp.l;
let dA = LabStd.a - LabSmp.a;
let dB = LabStd.b - LabSmp.b;
return Math.abs(dL) + Math.sqrt(dA * dA + dB * dB);
};
};
/*
"Measuring perceived color difference using YIQ NTSC
transmission color space in mobile applications"
by Yuriy Kotsarenko, Fernando Ramos in:
Programación Matemática y Software (2010)
Available at:
http://www.progmat.uaem.mx:8080/artVol2Num2/Articulo3Vol2Num2.pdf
*/
const differenceKotsarenkoRamos = () =>
differenceEuclidean('yiq', [0.5053, 0.299, 0.1957]);
export {
differenceHueChroma,
differenceHueSaturation,
differenceHueNaive,
differenceEuclidean,
differenceCie76,
differenceCie94,
differenceCiede2000,
differenceCmc,
differenceHyab,
differenceKotsarenkoRamos
};

48
node_modules/culori/src/dlab/definition.js generated vendored Normal file
View File

@ -0,0 +1,48 @@
import convertLabToLch from '../lch/convertLabToLch.js';
import convertLchToLab from '../lch/convertLchToLab.js';
import convertLab65ToRgb from '../lab65/convertLab65ToRgb.js';
import convertRgbToLab65 from '../lab65/convertRgbToLab65.js';
import convertDlchToLab65 from '../dlch/convertDlchToLab65.js';
import convertLab65ToDlch from '../dlch/convertLab65ToDlch.js';
import { interpolatorLinear } from '../interpolate/linear.js';
import { fixupAlpha } from '../fixup/alpha.js';
const convertDlabToLab65 = c => convertDlchToLab65(convertLabToLch(c, 'dlch'));
const convertLab65ToDlab = c => convertLchToLab(convertLab65ToDlch(c), 'dlab');
const definition = {
mode: 'dlab',
parse: ['--din99o-lab'],
serialize: '--din99o-lab',
toMode: {
lab65: convertDlabToLab65,
rgb: c => convertLab65ToRgb(convertDlabToLab65(c))
},
fromMode: {
lab65: convertLab65ToDlab,
rgb: c => convertLab65ToDlab(convertRgbToLab65(c))
},
channels: ['l', 'a', 'b', 'alpha'],
ranges: {
l: [0, 100],
a: [-40.09, 45.501],
b: [-40.469, 44.344]
},
interpolate: {
l: interpolatorLinear,
a: interpolatorLinear,
b: interpolatorLinear,
alpha: {
use: interpolatorLinear,
fixup: fixupAlpha
}
}
};
export default definition;

6
node_modules/culori/src/dlch/constants.js generated vendored Normal file
View File

@ -0,0 +1,6 @@
export const kE = 1;
export const kCH = 1;
export const θ = (26 / 180) * Math.PI;
export const cosθ = Math.cos(θ);
export const sinθ = Math.sin(θ);
export const factor = 100 / Math.log(139 / 100); // ~ 303.67

28
node_modules/culori/src/dlch/convertDlchToLab65.js generated vendored Normal file
View File

@ -0,0 +1,28 @@
import { kCH, kE, sinθ, cosθ, θ, factor } from './constants.js';
/*
Convert DIN99o LCh to CIELab D65
--------------------------------
*/
const convertDlchToLab65 = ({ l, c, h, alpha }) => {
let res = {
mode: 'lab65',
l: (Math.exp((l * kE) / factor) - 1) / 0.0039
};
if (h === undefined) {
res.a = res.b = 0;
} else {
let G = (Math.exp(0.0435 * c * kCH * kE) - 1) / 0.075;
let e = G * Math.cos((h / 180) * Math.PI - θ);
let f = G * Math.sin((h / 180) * Math.PI - θ);
res.a = e * cosθ - (f / 0.83) * sinθ;
res.b = e * sinθ + (f / 0.83) * cosθ;
}
if (alpha !== undefined) res.alpha = alpha;
return res;
};
export default convertDlchToLab65;

27
node_modules/culori/src/dlch/convertLab65ToDlch.js generated vendored Normal file
View File

@ -0,0 +1,27 @@
import { kCH, kE, sinθ, cosθ, θ, factor } from './constants.js';
import normalizeHue from '../util/normalizeHue.js';
/*
Convert CIELab D65 to DIN99o LCh
================================
*/
const convertLab65ToDlch = ({ l, a, b, alpha }) => {
let e = a * cosθ + b * sinθ;
let f = 0.83 * (b * cosθ - a * sinθ);
let G = Math.sqrt(e * e + f * f);
let res = {
mode: 'dlch',
l: (factor / kE) * Math.log(1 + 0.0039 * l),
c: Math.log(1 + 0.075 * G) / (0.0435 * kCH * kE)
};
if (res.c) {
res.h = normalizeHue(((Math.atan2(f, e) + θ) / Math.PI) * 180);
}
if (alpha !== undefined) res.alpha = alpha;
return res;
};
export default convertLab65ToDlch;

62
node_modules/culori/src/dlch/definition.js generated vendored Normal file
View File

@ -0,0 +1,62 @@
import convertLabToLch from '../lch/convertLabToLch.js';
import convertLchToLab from '../lch/convertLchToLab.js';
import convertDlchToLab65 from './convertDlchToLab65.js';
import convertLab65ToDlch from './convertLab65ToDlch.js';
import convertLab65ToRgb from '../lab65/convertLab65ToRgb.js';
import convertRgbToLab65 from '../lab65/convertRgbToLab65.js';
import { fixupHueShorter } from '../fixup/hue.js';
import { fixupAlpha } from '../fixup/alpha.js';
import { interpolatorLinear } from '../interpolate/linear.js';
import { differenceHueChroma } from '../difference.js';
import { averageAngle } from '../average.js';
const definition = {
mode: 'dlch',
parse: ['--din99o-lch'],
serialize: '--din99o-lch',
toMode: {
lab65: convertDlchToLab65,
dlab: c => convertLchToLab(c, 'dlab'),
rgb: c => convertLab65ToRgb(convertDlchToLab65(c))
},
fromMode: {
lab65: convertLab65ToDlch,
dlab: c => convertLabToLch(c, 'dlch'),
rgb: c => convertLab65ToDlch(convertRgbToLab65(c))
},
channels: ['l', 'c', 'h', 'alpha'],
ranges: {
l: [0, 100],
c: [0, 51.484],
h: [0, 360]
},
interpolate: {
l: interpolatorLinear,
c: interpolatorLinear,
h: {
use: interpolatorLinear,
fixup: fixupHueShorter
},
alpha: {
use: interpolatorLinear,
fixup: fixupAlpha
}
},
difference: {
h: differenceHueChroma
},
average: {
h: averageAngle
}
};
export default definition;

3
node_modules/culori/src/easing/gamma.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
const gamma = (γ = 1) => (γ === 1 ? t => t : t => Math.pow(t, γ));
export default gamma;

6
node_modules/culori/src/easing/inOutSine.js generated vendored Normal file
View File

@ -0,0 +1,6 @@
/*
Sinusoidal (cosine) in-out easing
*/
const inOutSine = t => (1 - Math.cos(t * Math.PI)) / 2;
export default inOutSine;

5
node_modules/culori/src/easing/midpoint.js generated vendored Normal file
View File

@ -0,0 +1,5 @@
// Color interpolation hint exponential function
const midpoint = (H = 0.5) => t =>
H <= 0 ? 1 : H >= 1 ? 0 : Math.pow(t, Math.log(0.5) / Math.log(H));
export default midpoint;

7
node_modules/culori/src/easing/smootherstep.js generated vendored Normal file
View File

@ -0,0 +1,7 @@
/*
Smootherstep easing function proposed by K. Perlin
Reference: https://en.wikipedia.org/wiki/Smoothstep
*/
const smootherstep = t => t * t * t * (t * (t * 6 - 15) + 10);
export default smootherstep;

8
node_modules/culori/src/easing/smoothstep.js generated vendored Normal file
View File

@ -0,0 +1,8 @@
/*
Smoothstep easing function and its inverse
Reference: https://en.wikipedia.org/wiki/Smoothstep
*/
const easingSmoothstep = t => t * t * (3 - 2 * t);
const easingSmoothstepInverse = t => 0.5 - Math.sin(Math.asin(1 - 2 * t) / 3);
export { easingSmoothstep, easingSmoothstepInverse };

162
node_modules/culori/src/filter.js generated vendored Normal file
View File

@ -0,0 +1,162 @@
import { mapper, mapTransferLinear } from './map.js';
import converter from './converter.js';
import prepare from './_prepare.js';
import { getMode } from './modes.js';
const minzero = v => Math.max(v, 0);
const clamp = v => Math.max(Math.min(v, 1), 0);
const lerp = (a, b, t) =>
a === undefined || b === undefined ? undefined : a + t * (b - a);
const matrixSepia = amount => {
let a = 1 - clamp(amount);
return [
0.393 + 0.607 * a,
0.769 - 0.769 * a,
0.189 - 0.189 * a,
0,
0.349 - 0.349 * a,
0.686 + 0.314 * a,
0.168 - 0.168 * a,
0,
0.272 - 0.272 * a,
0.534 - 0.534 * a,
0.131 + 0.869 * a,
0,
0,
0,
0,
1
];
};
const matrixSaturate = sat => {
let s = minzero(sat);
return [
0.213 + 0.787 * s,
0.715 - 0.715 * s,
0.072 - 0.072 * s,
0,
0.213 - 0.213 * s,
0.715 + 0.285 * s,
0.072 - 0.072 * s,
0,
0.213 - 0.213 * s,
0.715 - 0.715 * s,
0.072 + 0.928 * s,
0,
0,
0,
0,
1
];
};
const matrixGrayscale = amount => {
let a = 1 - clamp(amount);
return [
0.2126 + 0.7874 * a,
0.7152 - 0.7152 * a,
0.0722 - 0.0722 * a,
0,
0.2126 - 0.2126 * a,
0.7152 + 0.2848 * a,
0.0722 - 0.0722 * a,
0,
0.2126 - 0.2126 * a,
0.7152 - 0.7152 * a,
0.0722 + 0.9278 * a,
0,
0,
0,
0,
1
];
};
const matrixHueRotate = degrees => {
let rad = (Math.PI * degrees) / 180;
let c = Math.cos(rad);
let s = Math.sin(rad);
return [
0.213 + c * 0.787 - s * 0.213,
0.715 - c * 0.715 - s * 0.715,
0.072 - c * 0.072 + s * 0.928,
0,
0.213 - c * 0.213 + s * 0.143,
0.715 + c * 0.285 + s * 0.14,
0.072 - c * 0.072 - s * 0.283,
0,
0.213 - c * 0.213 - s * 0.787,
0.715 - c * 0.715 + s * 0.715,
0.072 + c * 0.928 + s * 0.072,
0,
0,
0,
0,
1
];
};
const matrix = (values, mode, preserve_mode = false) => {
let conv = converter(mode);
let channels = getMode(mode).channels;
return color => {
let c = conv(color);
if (!c) {
return undefined;
}
let res = { mode };
let ch;
let count = channels.length;
for (let i = 0; i < values.length; i++) {
ch = channels[Math.floor(i / count)];
if (c[ch] === undefined) {
continue;
}
res[ch] =
(res[ch] || 0) + values[i] * (c[channels[i % count]] || 0);
}
if (!preserve_mode) {
return res;
}
let prep = prepare(color);
return prep && res.mode !== prep.mode ? converter(prep.mode)(res) : res;
};
};
const filterBrightness = (amt = 1, mode = 'rgb') => {
let a = minzero(amt);
return mapper(mapTransferLinear(a), mode, true);
};
const filterContrast = (amt = 1, mode = 'rgb') => {
let a = minzero(amt);
return mapper(mapTransferLinear(a, (1 - a) / 2), mode, true);
};
const filterSepia = (amt = 1, mode = 'rgb') =>
matrix(matrixSepia(amt), mode, true);
const filterSaturate = (amt = 1, mode = 'rgb') =>
matrix(matrixSaturate(amt), mode, true);
const filterGrayscale = (amt = 1, mode = 'rgb') =>
matrix(matrixGrayscale(amt), mode, true);
const filterInvert = (amt = 1, mode = 'rgb') => {
let a = clamp(amt);
return mapper(
(v, ch) => (ch === 'alpha' ? v : lerp(a, 1 - a, v)),
mode,
true
);
};
const filterHueRotate = (deg = 0, mode = 'rgb') =>
matrix(matrixHueRotate(deg), mode, true);
export {
filterBrightness,
filterContrast,
filterSepia,
filterSaturate,
filterGrayscale,
filterInvert,
filterHueRotate
};

13
node_modules/culori/src/fixup/alpha.js generated vendored Normal file
View File

@ -0,0 +1,13 @@
const fixupAlpha = arr => {
let some_defined = false;
let res = arr.map(v => {
if (v !== undefined) {
some_defined = true;
return v;
}
return 1;
});
return some_defined ? res : arr;
};
export { fixupAlpha };

41
node_modules/culori/src/fixup/hue.js generated vendored Normal file
View File

@ -0,0 +1,41 @@
import normalizeHue from '../util/normalizeHue.js';
const hue = (hues, fn) => {
return hues
.map((hue, idx, arr) => {
if (hue === undefined) {
return hue;
}
let normalized = normalizeHue(hue);
if (idx === 0 || hues[idx - 1] === undefined) {
return normalized;
}
return fn(normalized - normalizeHue(arr[idx - 1]));
})
.reduce((acc, curr) => {
if (
!acc.length ||
curr === undefined ||
acc[acc.length - 1] === undefined
) {
acc.push(curr);
return acc;
}
acc.push(curr + acc[acc.length - 1]);
return acc;
}, []);
};
const fixupHueShorter = arr =>
hue(arr, d => (Math.abs(d) <= 180 ? d : d - 360 * Math.sign(d)));
const fixupHueLonger = arr =>
hue(arr, d => (Math.abs(d) >= 180 || d === 0 ? d : d - 360 * Math.sign(d)));
const fixupHueIncreasing = arr => hue(arr, d => (d >= 0 ? d : d + 360));
const fixupHueDecreasing = arr => hue(arr, d => (d <= 0 ? d : d - 360));
export {
fixupHueShorter,
fixupHueLonger,
fixupHueIncreasing,
fixupHueDecreasing
};

103
node_modules/culori/src/formatter.js generated vendored Normal file
View File

@ -0,0 +1,103 @@
import converter from './converter.js';
import round from './round.js';
import prepare from './_prepare.js';
import { getMode } from './modes.js';
let twoDecimals = round(2);
const clamp = value => Math.max(0, Math.min(1, value));
const fixup = value => Math.round(clamp(value) * 255);
export const serializeHex = color => {
if (color === undefined) {
return undefined;
}
let r = fixup(color.r);
let g = fixup(color.g);
let b = fixup(color.b);
return '#' + ((1 << 24) | (r << 16) | (g << 8) | b).toString(16).slice(1);
};
export const serializeHex8 = color => {
if (color === undefined) {
return undefined;
}
let a = fixup(color.alpha !== undefined ? color.alpha : 1);
return serializeHex(color) + ((1 << 8) | a).toString(16).slice(1);
};
export const serializeRgb = color => {
if (color === undefined) {
return undefined;
}
let r = color.r !== undefined ? fixup(color.r) : 'none';
let g = color.g !== undefined ? fixup(color.g) : 'none';
let b = color.b !== undefined ? fixup(color.b) : 'none';
if (color.alpha === undefined || color.alpha === 1) {
// opaque color
return `rgb(${r}, ${g}, ${b})`;
} else {
// transparent color
return `rgba(${r}, ${g}, ${b}, ${twoDecimals(clamp(color.alpha))})`;
}
};
export const serializeHsl = color => {
if (color === undefined) {
return undefined;
}
const h = twoDecimals(color.h || 0);
const s =
color.s !== undefined
? twoDecimals(clamp(color.s) * 100) + '%'
: 'none';
const l =
color.l !== undefined
? twoDecimals(clamp(color.l) * 100) + '%'
: 'none';
if (color.alpha === undefined || color.alpha === 1) {
// opaque color
return `hsl(${h}, ${s}, ${l})`;
} else {
// transparent color
return `hsla(${h}, ${s}, ${l}, ${twoDecimals(clamp(color.alpha))})`;
}
};
export const formatCss = c => {
const color = prepare(c);
if (!color) {
return undefined;
}
const def = getMode(color.mode);
if (!def.serialize || typeof def.serialize === 'string') {
let res = `color(${def.serialize || `--${color.mode}`} `;
def.channels.forEach((ch, i) => {
if (ch !== 'alpha') {
res +=
(i ? ' ' : '') +
(color[ch] !== undefined ? color[ch] : 'none');
}
});
if (color.alpha !== undefined && color.alpha < 1) {
res += ` / ${color.alpha}`;
}
return res + ')';
}
if (typeof def.serialize === 'function') {
return def.serialize(color);
}
return undefined;
};
export const formatHex = c => serializeHex(converter('rgb')(c));
export const formatHex8 = c => serializeHex8(converter('rgb')(c));
export const formatRgb = c => serializeRgb(converter('rgb')(c));
export const formatHsl = c => serializeHsl(converter('hsl')(c));

59
node_modules/culori/src/hsi/convertHsiToRgb.js generated vendored Normal file
View File

@ -0,0 +1,59 @@
import normalizeHue from '../util/normalizeHue.js';
// Based on: https://en.wikipedia.org/wiki/HSL_and_HSV#Converting_to_RGB
export default function convertHsiToRgb({ h, s, i, alpha }) {
h = normalizeHue(h);
let f = Math.abs(((h / 60) % 2) - 1);
let res;
switch (Math.floor(h / 60)) {
case 0:
res = {
r: i * (1 + s * (3 / (2 - f) - 1)),
g: i * (1 + s * ((3 * (1 - f)) / (2 - f) - 1)),
b: i * (1 - s)
};
break;
case 1:
res = {
r: i * (1 + s * ((3 * (1 - f)) / (2 - f) - 1)),
g: i * (1 + s * (3 / (2 - f) - 1)),
b: i * (1 - s)
};
break;
case 2:
res = {
r: i * (1 - s),
g: i * (1 + s * (3 / (2 - f) - 1)),
b: i * (1 + s * ((3 * (1 - f)) / (2 - f) - 1))
};
break;
case 3:
res = {
r: i * (1 - s),
g: i * (1 + s * ((3 * (1 - f)) / (2 - f) - 1)),
b: i * (1 + s * (3 / (2 - f) - 1))
};
break;
case 4:
res = {
r: i * (1 + s * ((3 * (1 - f)) / (2 - f) - 1)),
g: i * (1 - s),
b: i * (1 + s * (3 / (2 - f) - 1))
};
break;
case 5:
res = {
r: i * (1 + s * (3 / (2 - f) - 1)),
g: i * (1 - s),
b: i * (1 + s * ((3 * (1 - f)) / (2 - f) - 1))
};
break;
default:
res = { r: i * (1 - s), g: i * (1 - s), b: i * (1 - s) };
}
res.mode = 'rgb';
if (alpha !== undefined) res.alpha = alpha;
return res;
}

20
node_modules/culori/src/hsi/convertRgbToHsi.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
// Based on: https://en.wikipedia.org/wiki/HSL_and_HSV#Formal_derivation
export default function convertRgbToHsi({ r, g, b, alpha }) {
let M = Math.max(r, g, b),
m = Math.min(r, g, b);
let res = {
mode: 'hsi',
s: r + g + b === 0 ? 0 : 1 - (3 * m) / (r + g + b),
i: (r + g + b) / 3
};
if (M - m !== 0)
res.h =
(M === r
? (g - b) / (M - m) + (g < b) * 6
: M === g
? (b - r) / (M - m) + 2
: (r - g) / (M - m) + 4) * 60;
if (alpha !== undefined) res.alpha = alpha;
return res;
}

47
node_modules/culori/src/hsi/definition.js generated vendored Normal file
View File

@ -0,0 +1,47 @@
import convertHsiToRgb from './convertHsiToRgb.js';
import convertRgbToHsi from './convertRgbToHsi.js';
import { fixupHueShorter } from '../fixup/hue.js';
import { fixupAlpha } from '../fixup/alpha.js';
import { interpolatorLinear } from '../interpolate/linear.js';
import { differenceHueSaturation } from '../difference.js';
import { averageAngle } from '../average.js';
const definition = {
mode: 'hsi',
toMode: {
rgb: convertHsiToRgb
},
parse: ['--hsi'],
serialize: '--hsi',
fromMode: {
rgb: convertRgbToHsi
},
channels: ['h', 's', 'i', 'alpha'],
ranges: {
h: [0, 360]
},
gamut: 'rgb',
interpolate: {
h: { use: interpolatorLinear, fixup: fixupHueShorter },
s: interpolatorLinear,
i: interpolatorLinear,
alpha: { use: interpolatorLinear, fixup: fixupAlpha }
},
difference: {
h: differenceHueSaturation
},
average: {
h: averageAngle
}
};
export default definition;

34
node_modules/culori/src/hsl/convertHslToRgb.js generated vendored Normal file
View File

@ -0,0 +1,34 @@
import normalizeHue from '../util/normalizeHue.js';
// Based on: https://en.wikipedia.org/wiki/HSL_and_HSV#Converting_to_RGB
export default function convertHslToRgb({ h, s, l, alpha }) {
h = normalizeHue(h);
let m1 = l + s * (l < 0.5 ? l : 1 - l);
let m2 = m1 - (m1 - l) * 2 * Math.abs(((h / 60) % 2) - 1);
let res;
switch (Math.floor(h / 60)) {
case 0:
res = { r: m1, g: m2, b: 2 * l - m1 };
break;
case 1:
res = { r: m2, g: m1, b: 2 * l - m1 };
break;
case 2:
res = { r: 2 * l - m1, g: m1, b: m2 };
break;
case 3:
res = { r: 2 * l - m1, g: m2, b: m1 };
break;
case 4:
res = { r: m2, g: 2 * l - m1, b: m1 };
break;
case 5:
res = { r: m1, g: 2 * l - m1, b: m2 };
break;
default:
res = { r: 2 * l - m1, g: 2 * l - m1, b: 2 * l - m1 };
}
res.mode = 'rgb';
if (alpha !== undefined) res.alpha = alpha;
return res;
}

20
node_modules/culori/src/hsl/convertRgbToHsl.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
// Based on: https://en.wikipedia.org/wiki/HSL_and_HSV#Formal_derivation
export default function convertRgbToHsl({ r, g, b, alpha }) {
let M = Math.max(r, g, b),
m = Math.min(r, g, b);
let res = {
mode: 'hsl',
s: M === m ? 0 : (M - m) / (1 - Math.abs(M + m - 1)),
l: 0.5 * (M + m)
};
if (M - m !== 0)
res.h =
(M === r
? (g - b) / (M - m) + (g < b) * 6
: M === g
? (b - r) / (M - m) + 2
: (r - g) / (M - m) + 4) * 60;
if (alpha !== undefined) res.alpha = alpha;
return res;
}

52
node_modules/culori/src/hsl/definition.js generated vendored Normal file
View File

@ -0,0 +1,52 @@
import convertHslToRgb from './convertHslToRgb.js';
import convertRgbToHsl from './convertRgbToHsl.js';
import parseHslLegacy from './parseHslLegacy.js';
import parseHsl from './parseHsl.js';
import { fixupHueShorter } from '../fixup/hue.js';
import { fixupAlpha } from '../fixup/alpha.js';
import { interpolatorLinear } from '../interpolate/linear.js';
import { differenceHueSaturation } from '../difference.js';
import { averageAngle } from '../average.js';
const definition = {
mode: 'hsl',
toMode: {
rgb: convertHslToRgb
},
fromMode: {
rgb: convertRgbToHsl
},
channels: ['h', 's', 'l', 'alpha'],
ranges: {
h: [0, 360]
},
gamut: 'rgb',
parse: [parseHsl, parseHslLegacy],
serialize: c =>
`hsl(${c.h || 0} ${c.s !== undefined ? c.s * 100 + '%' : 'none'} ${
c.l !== undefined ? c.l * 100 + '%' : 'none'
}${c.alpha < 1 ? ` / ${c.alpha}` : ''})`,
interpolate: {
h: { use: interpolatorLinear, fixup: fixupHueShorter },
s: interpolatorLinear,
l: interpolatorLinear,
alpha: { use: interpolatorLinear, fixup: fixupAlpha }
},
difference: {
h: differenceHueSaturation
},
average: {
h: averageAngle
}
};
export default definition;

38
node_modules/culori/src/hsl/parseHsl.js generated vendored Normal file
View File

@ -0,0 +1,38 @@
import { Tok } from '../parse.js';
function parseHsl(color, parsed) {
if (!parsed || (parsed[0] !== 'hsl' && parsed[0] !== 'hsla')) {
return undefined;
}
const res = { mode: 'hsl' };
const [, h, s, l, alpha] = parsed;
if (h.type !== Tok.None) {
if (h.type === Tok.Percentage) {
return undefined;
}
res.h = h.value;
}
if (s.type !== Tok.None) {
if (s.type === Tok.Hue) {
return undefined;
}
res.s = s.type === Tok.Number ? s.value : s.value / 100;
}
if (l.type !== Tok.None) {
if (l.type === Tok.Hue) {
return undefined;
}
res.l = l.type === Tok.Number ? l.value : l.value / 100;
}
if (alpha.type !== Tok.None) {
res.alpha = alpha.type === Tok.Number ? alpha.value : alpha.value / 100;
}
return res;
}
export default parseHsl;

39
node_modules/culori/src/hsl/parseHslLegacy.js generated vendored Normal file
View File

@ -0,0 +1,39 @@
import hueToDeg from '../util/hue.js';
import { hue, per, num_per, c } from '../util/regex.js';
/*
hsl() regular expressions for legacy format
Reference: https://drafts.csswg.org/css-color/#the-hsl-notation
*/
const hsl_old = new RegExp(
`^hsla?\\(\\s*${hue}${c}${per}${c}${per}\\s*(?:,\\s*${num_per}\\s*)?\\)$`
);
const parseHslLegacy = color => {
let match = color.match(hsl_old);
if (!match) return;
let res = { mode: 'hsl' };
if (match[3] !== undefined) {
res.h = +match[3];
} else if (match[1] !== undefined && match[2] !== undefined) {
res.h = hueToDeg(match[1], match[2]);
}
if (match[4] !== undefined) {
res.s = Math.min(Math.max(0, match[4] / 100), 1);
}
if (match[5] !== undefined) {
res.l = Math.min(Math.max(0, match[5] / 100), 1);
}
if (match[6] !== undefined) {
res.alpha = match[6] / 100;
} else if (match[7] !== undefined) {
res.alpha = +match[7];
}
return res;
};
export default parseHslLegacy;

34
node_modules/culori/src/hsv/convertHsvToRgb.js generated vendored Normal file
View File

@ -0,0 +1,34 @@
import normalizeHue from '../util/normalizeHue.js';
// Based on: https://en.wikipedia.org/wiki/HSL_and_HSV#Converting_to_RGB
export default function convertHsvToRgb({ h, s, v, alpha }) {
h = normalizeHue(h);
let f = Math.abs(((h / 60) % 2) - 1);
let res;
switch (Math.floor(h / 60)) {
case 0:
res = { r: v, g: v * (1 - s * f), b: v * (1 - s) };
break;
case 1:
res = { r: v * (1 - s * f), g: v, b: v * (1 - s) };
break;
case 2:
res = { r: v * (1 - s), g: v, b: v * (1 - s * f) };
break;
case 3:
res = { r: v * (1 - s), g: v * (1 - s * f), b: v };
break;
case 4:
res = { r: v * (1 - s * f), g: v * (1 - s), b: v };
break;
case 5:
res = { r: v, g: v * (1 - s), b: v * (1 - s * f) };
break;
default:
res = { r: v * (1 - s), g: v * (1 - s), b: v * (1 - s) };
}
res.mode = 'rgb';
if (alpha !== undefined) res.alpha = alpha;
return res;
}

20
node_modules/culori/src/hsv/convertRgbToHsv.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
// Based on: https://en.wikipedia.org/wiki/HSL_and_HSV#Formal_derivation
export default function convertRgbToHsv({ r, g, b, alpha }) {
let M = Math.max(r, g, b),
m = Math.min(r, g, b);
let res = {
mode: 'hsv',
s: M === 0 ? 0 : 1 - m / M,
v: M
};
if (M - m !== 0)
res.h =
(M === r
? (g - b) / (M - m) + (g < b) * 6
: M === g
? (b - r) / (M - m) + 2
: (r - g) / (M - m) + 4) * 60;
if (alpha !== undefined) res.alpha = alpha;
return res;
}

47
node_modules/culori/src/hsv/definition.js generated vendored Normal file
View File

@ -0,0 +1,47 @@
import convertHsvToRgb from './convertHsvToRgb.js';
import convertRgbToHsv from './convertRgbToHsv.js';
import { fixupHueShorter } from '../fixup/hue.js';
import { fixupAlpha } from '../fixup/alpha.js';
import { interpolatorLinear } from '../interpolate/linear.js';
import { differenceHueSaturation } from '../difference.js';
import { averageAngle } from '../average.js';
const definition = {
mode: 'hsv',
toMode: {
rgb: convertHsvToRgb
},
parse: ['--hsv'],
serialize: '--hsv',
fromMode: {
rgb: convertRgbToHsv
},
channels: ['h', 's', 'v', 'alpha'],
ranges: {
h: [0, 360]
},
gamut: 'rgb',
interpolate: {
h: { use: interpolatorLinear, fixup: fixupHueShorter },
s: interpolatorLinear,
v: interpolatorLinear,
alpha: { use: interpolatorLinear, fixup: fixupAlpha }
},
difference: {
h: differenceHueSaturation
},
average: {
h: averageAngle
}
};
export default definition;

26
node_modules/culori/src/hwb/convertHwbToRgb.js generated vendored Normal file
View File

@ -0,0 +1,26 @@
/*
HWB to RGB converter
--------------------
References:
* https://drafts.csswg.org/css-color/#hwb-to-rgb
* https://en.wikipedia.org/wiki/HWB_color_model
* http://alvyray.com/Papers/CG/HWB_JGTv208.pdf
*/
import convertHsvToRgb from '../hsv/convertHsvToRgb.js';
export default function convertHwbToRgb({ h, w, b, alpha }) {
// normalize w + b to 1
if (w + b > 1) {
let s = w + b;
w /= s;
b /= s;
}
return convertHsvToRgb({
h: h,
s: b === 1 ? 1 : 1 - w / (1 - b),
v: 1 - b,
alpha: alpha
});
}

24
node_modules/culori/src/hwb/convertRgbToHwb.js generated vendored Normal file
View File

@ -0,0 +1,24 @@
/*
RGB to HWB converter
--------------------
References:
* https://drafts.csswg.org/css-color/#hwb-to-rgb
* https://en.wikipedia.org/wiki/HWB_color_model
* http://alvyray.com/Papers/CG/HWB_JGTv208.pdf
*/
import convertRgbToHsv from '../hsv/convertRgbToHsv.js';
export default function convertRgbToHwb(rgba) {
let hsv = convertRgbToHsv(rgba);
if (hsv === undefined) return undefined;
let res = {
mode: 'hwb',
w: (1 - hsv.s) * hsv.v,
b: 1 - hsv.v
};
if (hsv.h !== undefined) res.h = hsv.h;
if (hsv.alpha !== undefined) res.alpha = hsv.alpha;
return res;
}

51
node_modules/culori/src/hwb/definition.js generated vendored Normal file
View File

@ -0,0 +1,51 @@
import convertHwbToRgb from './convertHwbToRgb.js';
import convertRgbToHwb from './convertRgbToHwb.js';
import parseHwb from './parseHwb.js';
import { fixupHueShorter } from '../fixup/hue.js';
import { fixupAlpha } from '../fixup/alpha.js';
import { interpolatorLinear } from '../interpolate/linear.js';
import { differenceHueNaive } from '../difference.js';
import { averageAngle } from '../average.js';
const definition = {
mode: 'hwb',
toMode: {
rgb: convertHwbToRgb
},
fromMode: {
rgb: convertRgbToHwb
},
channels: ['h', 'w', 'b', 'alpha'],
ranges: {
h: [0, 360]
},
gamut: 'rgb',
parse: [parseHwb],
serialize: c =>
`hwb(${c.h || 0} ${c.w * 100}% ${c.b * 100}%${
c.alpha < 1 ? ` / ${c.alpha}` : ''
})`,
interpolate: {
h: { use: interpolatorLinear, fixup: fixupHueShorter },
w: interpolatorLinear,
b: interpolatorLinear,
alpha: { use: interpolatorLinear, fixup: fixupAlpha }
},
difference: {
h: differenceHueNaive
},
average: {
h: averageAngle
}
};
export default definition;

38
node_modules/culori/src/hwb/parseHwb.js generated vendored Normal file
View File

@ -0,0 +1,38 @@
import { Tok } from '../parse.js';
function ParseHwb(color, parsed) {
if (!parsed || parsed[0] !== 'hwb') {
return undefined;
}
const res = { mode: 'hwb' };
const [, h, w, b, alpha] = parsed;
if (h.type !== Tok.None) {
if (h.type === Tok.Percentage) {
return undefined;
}
res.h = h.value;
}
if (w.type !== Tok.None) {
if (w.type === Tok.Hue) {
return undefined;
}
res.w = w.type === Tok.Number ? w.value : w.value / 100;
}
if (b.type !== Tok.None) {
if (b.type === Tok.Hue) {
return undefined;
}
res.b = b.type === Tok.Number ? b.value : b.value / 100;
}
if (alpha.type !== Tok.None) {
res.alpha = alpha.type === Tok.Number ? alpha.value : alpha.value / 100;
}
return res;
}
export default ParseHwb;

226
node_modules/culori/src/index-fn.js generated vendored Normal file
View File

@ -0,0 +1,226 @@
// Color space definitions
export { default as modeA98 } from './a98/definition.js';
export { default as modeCubehelix } from './cubehelix/definition.js';
export { default as modeDlab } from './dlab/definition.js';
export { default as modeDlch } from './dlch/definition.js';
export { default as modeHsi } from './hsi/definition.js';
export { default as modeHsl } from './hsl/definition.js';
export { default as modeHsv } from './hsv/definition.js';
export { default as modeHwb } from './hwb/definition.js';
export { default as modeJab } from './jab/definition.js';
export { default as modeJch } from './jch/definition.js';
export { default as modeLab } from './lab/definition.js';
export { default as modeLab65 } from './lab65/definition.js';
export { default as modeLch } from './lch/definition.js';
export { default as modeLch65 } from './lch65/definition.js';
export { default as modeLchuv } from './lchuv/definition.js';
export { default as modeLrgb } from './lrgb/definition.js';
export { default as modeLuv } from './luv/definition.js';
export { default as modeOkhsl } from './okhsl/modeOkhsl.js';
export { default as modeOkhsv } from './okhsv/modeOkhsv.js';
export { default as modeOklab } from './oklab/definition.js';
export { default as modeOklch } from './oklch/definition.js';
export { default as modeP3 } from './p3/definition.js';
export { default as modeProphoto } from './prophoto/definition.js';
export { default as modeRec2020 } from './rec2020/definition.js';
export { default as modeRgb } from './rgb/definition.js';
export { default as modeXyb } from './xyb/definition.js';
export { default as modeXyz50 } from './xyz50/definition.js';
export { default as modeXyz65 } from './xyz65/definition.js';
export { default as modeYiq } from './yiq/definition.js';
export { default as converter } from './converter.js';
export {
serializeHex,
serializeHex8,
serializeRgb,
serializeHsl,
formatHex,
formatHex8,
formatRgb,
formatHsl,
formatCss
} from './formatter.js';
export { default as colorsNamed } from './colors/named.js';
export { default as blend } from './blend.js';
export { default as random } from './random.js';
export {
fixupHueShorter,
fixupHueLonger,
fixupHueIncreasing,
fixupHueDecreasing
} from './fixup/hue.js';
export { fixupAlpha } from './fixup/alpha.js';
export {
mapper,
mapAlphaMultiply,
mapAlphaDivide,
mapTransferLinear,
mapTransferGamma
} from './map.js';
export { average, averageAngle, averageNumber } from './average.js';
export { default as round } from './round.js';
export {
interpolate,
interpolateWith,
interpolateWithPremultipliedAlpha
} from './interpolate/interpolate.js';
export { interpolatorLinear } from './interpolate/linear.js';
export { interpolatorPiecewise } from './interpolate/piecewise.js';
export {
interpolatorSplineBasis,
interpolatorSplineBasisClosed
} from './interpolate/splineBasis.js';
export {
interpolatorSplineNatural,
interpolatorSplineNaturalClosed
} from './interpolate/splineNatural.js';
export {
interpolatorSplineMonotone,
interpolatorSplineMonotone2,
interpolatorSplineMonotoneClosed
} from './interpolate/splineMonotone.js';
export { lerp, unlerp, blerp, trilerp } from './interpolate/lerp.js';
export { default as samples } from './samples.js';
export {
displayable,
inGamut,
clampRgb,
clampChroma,
clampGamut,
toGamut
} from './clamp.js';
export { default as nearest } from './nearest.js';
export { useMode, getMode, useParser, removeParser } from './modes.js';
export { default as parse } from './parse.js';
export {
differenceEuclidean,
differenceCie76,
differenceCie94,
differenceCiede2000,
differenceCmc,
differenceHyab,
differenceHueSaturation,
differenceHueChroma,
differenceHueNaive,
differenceKotsarenkoRamos
} from './difference.js';
export {
filterBrightness,
filterContrast,
filterSepia,
filterInvert,
filterSaturate,
filterGrayscale,
filterHueRotate
} from './filter.js';
export {
filterDeficiencyProt,
filterDeficiencyDeuter,
filterDeficiencyTrit
} from './deficiency.js';
// Easings
export { default as easingMidpoint } from './easing/midpoint.js';
export {
easingSmoothstep,
easingSmoothstepInverse
} from './easing/smoothstep.js';
export { default as easingSmootherstep } from './easing/smootherstep.js';
export { default as easingInOutSine } from './easing/inOutSine.js';
export { default as easingGamma } from './easing/gamma.js';
export {
luminance as wcagLuminance,
contrast as wcagContrast
} from './wcag.js';
export { default as parseHsl } from './hsl/parseHsl.js';
export { default as parseHwb } from './hwb/parseHwb.js';
export { default as parseLab } from './lab/parseLab.js';
export { default as parseLch } from './lch/parseLch.js';
export { default as parseNamed } from './rgb/parseNamed.js';
export { default as parseTransparent } from './rgb/parseTransparent.js';
export { default as parseHex } from './rgb/parseHex.js';
export { default as parseRgb } from './rgb/parseRgb.js';
export { default as parseHslLegacy } from './hsl/parseHslLegacy.js';
export { default as parseRgbLegacy } from './rgb/parseRgbLegacy.js';
export { default as parseOklab } from './oklab/parseOklab.js';
export { default as parseOklch } from './oklch/parseOklch.js';
export { default as convertA98ToXyz65 } from './a98/convertA98ToXyz65.js';
export { default as convertCubehelixToRgb } from './cubehelix/convertCubehelixToRgb.js';
export { default as convertDlchToLab65 } from './dlch/convertDlchToLab65.js';
export { default as convertHsiToRgb } from './hsi/convertHsiToRgb.js';
export { default as convertHslToRgb } from './hsl/convertHslToRgb.js';
export { default as convertHsvToRgb } from './hsv/convertHsvToRgb.js';
export { default as convertHwbToRgb } from './hwb/convertHwbToRgb.js';
export { default as convertJabToJch } from './jch/convertJabToJch.js';
export { default as convertJabToRgb } from './jab/convertJabToRgb.js';
export { default as convertJabToXyz65 } from './jab/convertJabToXyz65.js';
export { default as convertJchToJab } from './jch/convertJchToJab.js';
export { default as convertLab65ToDlch } from './dlch/convertLab65ToDlch.js';
export { default as convertLab65ToRgb } from './lab65/convertLab65ToRgb.js';
export { default as convertLab65ToXyz65 } from './lab65/convertLab65ToXyz65.js';
export { default as convertLabToLch } from './lch/convertLabToLch.js';
export { default as convertLabToRgb } from './lab/convertLabToRgb.js';
export { default as convertLabToXyz50 } from './lab/convertLabToXyz50.js';
export { default as convertLchToLab } from './lch/convertLchToLab.js';
export { default as convertLchuvToLuv } from './lchuv/convertLchuvToLuv.js';
export { default as convertLrgbToOklab } from './oklab/convertLrgbToOklab.js';
export { default as convertLrgbToRgb } from './lrgb/convertLrgbToRgb.js';
export { default as convertLuvToLchuv } from './lchuv/convertLuvToLchuv.js';
export { default as convertLuvToXyz50 } from './luv/convertLuvToXyz50.js';
export { default as convertOkhslToOklab } from './okhsl/convertOkhslToOklab.js';
export { default as convertOkhsvToOklab } from './okhsv/convertOkhsvToOklab.js';
export { default as convertOklabToLrgb } from './oklab/convertOklabToLrgb.js';
export { default as convertOklabToOkhsl } from './okhsl/convertOklabToOkhsl.js';
export { default as convertOklabToOkhsv } from './okhsv/convertOklabToOkhsv.js';
export { default as convertOklabToRgb } from './oklab/convertOklabToRgb.js';
export { default as convertP3ToXyz65 } from './p3/convertP3ToXyz65.js';
export { default as convertProphotoToXyz50 } from './prophoto/convertProphotoToXyz50.js';
export { default as convertRec2020ToXyz65 } from './rec2020/convertRec2020ToXyz65.js';
export { default as convertRgbToCubehelix } from './cubehelix/convertRgbToCubehelix.js';
export { default as convertRgbToHsi } from './hsi/convertRgbToHsi.js';
export { default as convertRgbToHsl } from './hsl/convertRgbToHsl.js';
export { default as convertRgbToHsv } from './hsv/convertRgbToHsv.js';
export { default as convertRgbToHwb } from './hwb/convertRgbToHwb.js';
export { default as convertRgbToJab } from './jab/convertRgbToJab.js';
export { default as convertRgbToLab } from './lab/convertRgbToLab.js';
export { default as convertRgbToLab65 } from './lab65/convertRgbToLab65.js';
export { default as convertRgbToLrgb } from './lrgb/convertRgbToLrgb.js';
export { default as convertRgbToOklab } from './oklab/convertRgbToOklab.js';
export { default as convertRgbToXyz50 } from './xyz50/convertRgbToXyz50.js';
export { default as convertRgbToXyz65 } from './xyz65/convertRgbToXyz65.js';
export { default as convertRgbToYiq } from './yiq/convertRgbToYiq.js';
export { default as convertRgbToXyb } from './xyb/convertRgbToXyb.js';
export { default as convertXybToRgb } from './xyb/convertXybToRgb.js';
export { default as convertXyz65ToA98 } from './a98/convertXyz65ToA98.js';
export { default as convertXyz65ToJab } from './jab/convertXyz65ToJab.js';
export { default as convertXyz65ToLab65 } from './lab65/convertXyz65ToLab65.js';
export { default as convertXyz65ToP3 } from './p3/convertXyz65ToP3.js';
export { default as convertXyz65ToRec2020 } from './rec2020/convertXyz65ToRec2020.js';
export { default as convertXyz65ToRgb } from './xyz65/convertXyz65ToRgb.js';
export { default as convertXyz65ToXyz50 } from './xyz65/convertXyz65ToXyz50.js';
export { default as convertXyz50ToLab } from './lab/convertXyz50ToLab.js';
export { default as convertXyz50ToLuv } from './luv/convertXyz50ToLuv.js';
export { default as convertXyz50ToProphoto } from './prophoto/convertXyz50ToProphoto.js';
export { default as convertXyz50ToRgb } from './xyz50/convertXyz50ToRgb.js';
export { default as convertXyz50ToXyz65 } from './xyz65/convertXyz50ToXyz65.js';
export { default as convertYiqToRgb } from './yiq/convertYiqToRgb.js';

289
node_modules/culori/src/index.js generated vendored Normal file
View File

@ -0,0 +1,289 @@
// Color space definitions
import modeA98 from './a98/definition.js';
import modeCubehelix from './cubehelix/definition.js';
import modeDlab from './dlab/definition.js';
import modeDlch from './dlch/definition.js';
import modeHsi from './hsi/definition.js';
import modeHsl from './hsl/definition.js';
import modeHsv from './hsv/definition.js';
import modeHwb from './hwb/definition.js';
import modeJab from './jab/definition.js';
import modeJch from './jch/definition.js';
import modeLab from './lab/definition.js';
import modeLab65 from './lab65/definition.js';
import modeLch from './lch/definition.js';
import modeLch65 from './lch65/definition.js';
import modeLchuv from './lchuv/definition.js';
import modeLrgb from './lrgb/definition.js';
import modeLuv from './luv/definition.js';
import modeOkhsl from './okhsl/modeOkhsl.js';
import modeOkhsv from './okhsv/modeOkhsv.js';
import modeOklab from './oklab/definition.js';
import modeOklch from './oklch/definition.js';
import modeP3 from './p3/definition.js';
import modeProphoto from './prophoto/definition.js';
import modeRec2020 from './rec2020/definition.js';
import modeRgb from './rgb/definition.js';
import modeXyb from './xyb/definition.js';
import modeXyz50 from './xyz50/definition.js';
import modeXyz65 from './xyz65/definition.js';
import modeYiq from './yiq/definition.js';
import { useMode } from './modes.js';
export { default as converter } from './converter.js';
export {
serializeHex,
serializeHex8,
serializeRgb,
serializeHsl,
formatHex,
formatHex8,
formatRgb,
formatHsl,
formatCss
} from './formatter.js';
export { default as colorsNamed } from './colors/named.js';
export { default as blend } from './blend.js';
export { default as random } from './random.js';
export {
fixupHueShorter,
fixupHueLonger,
fixupHueIncreasing,
fixupHueDecreasing
} from './fixup/hue.js';
export { fixupAlpha } from './fixup/alpha.js';
export {
mapper,
mapAlphaMultiply,
mapAlphaDivide,
mapTransferLinear,
mapTransferGamma
} from './map.js';
export { average, averageAngle, averageNumber } from './average.js';
export { default as round } from './round.js';
export {
interpolate,
interpolateWith,
interpolateWithPremultipliedAlpha
} from './interpolate/interpolate.js';
export { interpolatorLinear } from './interpolate/linear.js';
export { interpolatorPiecewise } from './interpolate/piecewise.js';
export {
interpolatorSplineBasis,
interpolatorSplineBasisClosed
} from './interpolate/splineBasis.js';
export {
interpolatorSplineNatural,
interpolatorSplineNaturalClosed
} from './interpolate/splineNatural.js';
export {
interpolatorSplineMonotone,
interpolatorSplineMonotone2,
interpolatorSplineMonotoneClosed
} from './interpolate/splineMonotone.js';
export { lerp, unlerp, blerp, trilerp } from './interpolate/lerp.js';
export { default as samples } from './samples.js';
export {
displayable,
inGamut,
clampRgb,
clampChroma,
clampGamut,
toGamut
} from './clamp.js';
export { default as nearest } from './nearest.js';
export { useMode, getMode, useParser, removeParser } from './modes.js';
export { default as parse } from './parse.js';
export {
differenceEuclidean,
differenceCie76,
differenceCie94,
differenceCiede2000,
differenceCmc,
differenceHyab,
differenceHueSaturation,
differenceHueChroma,
differenceHueNaive,
differenceKotsarenkoRamos
} from './difference.js';
export {
filterBrightness,
filterContrast,
filterSepia,
filterInvert,
filterSaturate,
filterGrayscale,
filterHueRotate
} from './filter.js';
export {
filterDeficiencyProt,
filterDeficiencyDeuter,
filterDeficiencyTrit
} from './deficiency.js';
// Easings
export { default as easingMidpoint } from './easing/midpoint.js';
export {
easingSmoothstep,
easingSmoothstepInverse
} from './easing/smoothstep.js';
export { default as easingSmootherstep } from './easing/smootherstep.js';
export { default as easingInOutSine } from './easing/inOutSine.js';
export { default as easingGamma } from './easing/gamma.js';
export {
luminance as wcagLuminance,
contrast as wcagContrast
} from './wcag.js';
export { default as parseHsl } from './hsl/parseHsl.js';
export { default as parseHwb } from './hwb/parseHwb.js';
export { default as parseLab } from './lab/parseLab.js';
export { default as parseLch } from './lch/parseLch.js';
export { default as parseNamed } from './rgb/parseNamed.js';
export { default as parseTransparent } from './rgb/parseTransparent.js';
export { default as parseHex } from './rgb/parseHex.js';
export { default as parseRgb } from './rgb/parseRgb.js';
export { default as parseHslLegacy } from './hsl/parseHslLegacy.js';
export { default as parseRgbLegacy } from './rgb/parseRgbLegacy.js';
export { default as parseOklab } from './oklab/parseOklab.js';
export { default as parseOklch } from './oklch/parseOklch.js';
export { default as convertA98ToXyz65 } from './a98/convertA98ToXyz65.js';
export { default as convertCubehelixToRgb } from './cubehelix/convertCubehelixToRgb.js';
export { default as convertDlchToLab65 } from './dlch/convertDlchToLab65.js';
export { default as convertHsiToRgb } from './hsi/convertHsiToRgb.js';
export { default as convertHslToRgb } from './hsl/convertHslToRgb.js';
export { default as convertHsvToRgb } from './hsv/convertHsvToRgb.js';
export { default as convertHwbToRgb } from './hwb/convertHwbToRgb.js';
export { default as convertJabToJch } from './jch/convertJabToJch.js';
export { default as convertJabToRgb } from './jab/convertJabToRgb.js';
export { default as convertJabToXyz65 } from './jab/convertJabToXyz65.js';
export { default as convertJchToJab } from './jch/convertJchToJab.js';
export { default as convertLab65ToDlch } from './dlch/convertLab65ToDlch.js';
export { default as convertLab65ToRgb } from './lab65/convertLab65ToRgb.js';
export { default as convertLab65ToXyz65 } from './lab65/convertLab65ToXyz65.js';
export { default as convertLabToLch } from './lch/convertLabToLch.js';
export { default as convertLabToRgb } from './lab/convertLabToRgb.js';
export { default as convertLabToXyz50 } from './lab/convertLabToXyz50.js';
export { default as convertLchToLab } from './lch/convertLchToLab.js';
export { default as convertLchuvToLuv } from './lchuv/convertLchuvToLuv.js';
export { default as convertLrgbToOklab } from './oklab/convertLrgbToOklab.js';
export { default as convertLrgbToRgb } from './lrgb/convertLrgbToRgb.js';
export { default as convertLuvToLchuv } from './lchuv/convertLuvToLchuv.js';
export { default as convertLuvToXyz50 } from './luv/convertLuvToXyz50.js';
export { default as convertOkhslToOklab } from './okhsl/convertOkhslToOklab.js';
export { default as convertOkhsvToOklab } from './okhsv/convertOkhsvToOklab.js';
export { default as convertOklabToLrgb } from './oklab/convertOklabToLrgb.js';
export { default as convertOklabToOkhsl } from './okhsl/convertOklabToOkhsl.js';
export { default as convertOklabToOkhsv } from './okhsv/convertOklabToOkhsv.js';
export { default as convertOklabToRgb } from './oklab/convertOklabToRgb.js';
export { default as convertP3ToXyz65 } from './p3/convertP3ToXyz65.js';
export { default as convertProphotoToXyz50 } from './prophoto/convertProphotoToXyz50.js';
export { default as convertRec2020ToXyz65 } from './rec2020/convertRec2020ToXyz65.js';
export { default as convertRgbToCubehelix } from './cubehelix/convertRgbToCubehelix.js';
export { default as convertRgbToHsi } from './hsi/convertRgbToHsi.js';
export { default as convertRgbToHsl } from './hsl/convertRgbToHsl.js';
export { default as convertRgbToHsv } from './hsv/convertRgbToHsv.js';
export { default as convertRgbToHwb } from './hwb/convertRgbToHwb.js';
export { default as convertRgbToJab } from './jab/convertRgbToJab.js';
export { default as convertRgbToLab } from './lab/convertRgbToLab.js';
export { default as convertRgbToLab65 } from './lab65/convertRgbToLab65.js';
export { default as convertRgbToLrgb } from './lrgb/convertRgbToLrgb.js';
export { default as convertRgbToOklab } from './oklab/convertRgbToOklab.js';
export { default as convertRgbToXyb } from './xyb/convertRgbToXyb.js';
export { default as convertRgbToXyz50 } from './xyz50/convertRgbToXyz50.js';
export { default as convertRgbToXyz65 } from './xyz65/convertRgbToXyz65.js';
export { default as convertRgbToYiq } from './yiq/convertRgbToYiq.js';
export { default as convertXybToRgb } from './xyb/convertXybToRgb.js';
export { default as convertXyz50ToLab } from './lab/convertXyz50ToLab.js';
export { default as convertXyz50ToLuv } from './luv/convertXyz50ToLuv.js';
export { default as convertXyz50ToProphoto } from './prophoto/convertXyz50ToProphoto.js';
export { default as convertXyz50ToRgb } from './xyz50/convertXyz50ToRgb.js';
export { default as convertXyz50ToXyz65 } from './xyz65/convertXyz50ToXyz65.js';
export { default as convertXyz65ToA98 } from './a98/convertXyz65ToA98.js';
export { default as convertXyz65ToJab } from './jab/convertXyz65ToJab.js';
export { default as convertXyz65ToLab65 } from './lab65/convertXyz65ToLab65.js';
export { default as convertXyz65ToP3 } from './p3/convertXyz65ToP3.js';
export { default as convertXyz65ToRec2020 } from './rec2020/convertXyz65ToRec2020.js';
export { default as convertXyz65ToRgb } from './xyz65/convertXyz65ToRgb.js';
export { default as convertXyz65ToXyz50 } from './xyz65/convertXyz65ToXyz50.js';
export { default as convertYiqToRgb } from './yiq/convertYiqToRgb.js';
export {
modeA98,
modeCubehelix,
modeDlab,
modeDlch,
modeHsi,
modeHsl,
modeHsv,
modeHwb,
modeJab,
modeJch,
modeLab,
modeLab65,
modeLch,
modeLch65,
modeLchuv,
modeLrgb,
modeLuv,
modeOkhsl,
modeOkhsv,
modeOklab,
modeOklch,
modeP3,
modeProphoto,
modeRec2020,
modeRgb,
modeXyb,
modeXyz50,
modeXyz65,
modeYiq
};
export const a98 = useMode(modeA98);
export const cubehelix = useMode(modeCubehelix);
export const dlab = useMode(modeDlab);
export const dlch = useMode(modeDlch);
export const hsi = useMode(modeHsi);
export const hsl = useMode(modeHsl);
export const hsv = useMode(modeHsv);
export const hwb = useMode(modeHwb);
export const jab = useMode(modeJab);
export const jch = useMode(modeJch);
export const lab = useMode(modeLab);
export const lab65 = useMode(modeLab65);
export const lch = useMode(modeLch);
export const lch65 = useMode(modeLch65);
export const lchuv = useMode(modeLchuv);
export const lrgb = useMode(modeLrgb);
export const luv = useMode(modeLuv);
export const okhsl = useMode(modeOkhsl);
export const okhsv = useMode(modeOkhsv);
export const oklab = useMode(modeOklab);
export const oklch = useMode(modeOklch);
export const p3 = useMode(modeP3);
export const prophoto = useMode(modeProphoto);
export const rec2020 = useMode(modeRec2020);
export const rgb = useMode(modeRgb);
export const xyb = useMode(modeXyb);
export const xyz50 = useMode(modeXyz50);
export const xyz65 = useMode(modeXyz65);
export const yiq = useMode(modeYiq);

155
node_modules/culori/src/interpolate/interpolate.js generated vendored Normal file
View File

@ -0,0 +1,155 @@
import converter from '../converter.js';
import { getMode } from '../modes.js';
import normalizePositions from '../util/normalizePositions.js';
import easingMidpoint from '../easing/midpoint.js';
import { mapper, mapAlphaMultiply, mapAlphaDivide } from '../map.js';
const isfn = o => typeof o === 'function';
const isobj = o => o && typeof o === 'object';
const isnum = o => typeof o === 'number';
const interpolate_fn = (colors, mode = 'rgb', overrides, premap) => {
let def = getMode(mode);
let conv = converter(mode);
let conv_colors = [];
let positions = [];
let fns = {};
colors.forEach(val => {
if (Array.isArray(val)) {
conv_colors.push(conv(val[0]));
positions.push(val[1]);
} else if (isnum(val) || isfn(val)) {
// Color interpolation hint or easing function
fns[positions.length] = val;
} else {
conv_colors.push(conv(val));
positions.push(undefined);
}
});
normalizePositions(positions);
// override the default interpolators
// from the color space definition with any custom ones
let fixed = def.channels.reduce((res, ch) => {
let ffn;
if (isobj(overrides) && isobj(overrides[ch]) && overrides[ch].fixup) {
ffn = overrides[ch].fixup;
} else if (isobj(def.interpolate[ch]) && def.interpolate[ch].fixup) {
ffn = def.interpolate[ch].fixup;
} else {
ffn = v => v;
}
res[ch] = ffn(conv_colors.map(color => color[ch]));
return res;
}, {});
if (premap) {
let ccolors = conv_colors.map((color, idx) => {
return def.channels.reduce(
(c, ch) => {
c[ch] = fixed[ch][idx];
return c;
},
{ mode }
);
});
fixed = def.channels.reduce((res, ch) => {
res[ch] = ccolors.map(c => {
let v = premap(c[ch], ch, c, mode);
return isNaN(v) ? undefined : v;
});
return res;
}, {});
}
let interpolators = def.channels.reduce((res, ch) => {
let ifn;
if (isfn(overrides)) {
ifn = overrides;
} else if (isobj(overrides) && isfn(overrides[ch])) {
ifn = overrides[ch];
} else if (
isobj(overrides) &&
isobj(overrides[ch]) &&
overrides[ch].use
) {
ifn = overrides[ch].use;
} else if (isfn(def.interpolate[ch])) {
ifn = def.interpolate[ch];
} else if (isobj(def.interpolate[ch])) {
ifn = def.interpolate[ch].use;
}
res[ch] = ifn(fixed[ch]);
return res;
}, {});
let n = conv_colors.length - 1;
return t => {
// clamp t to the [0, 1] interval
t = Math.min(Math.max(0, t), 1);
if (t <= positions[0]) {
return conv_colors[0];
}
if (t > positions[n]) {
return conv_colors[n];
}
// Convert `t` from [0, 1] to `t0` between the appropriate two colors.
// First, look for the two colors between which `t` is located.
// Note: this can be optimized by searching for the index
// through bisection instead of start-to-end.
let idx = 0;
while (positions[idx] < t) idx++;
let start = positions[idx - 1];
let delta = positions[idx] - start;
let P = (t - start) / delta;
// use either the local easing, or the global easing, if any
let fn = fns[idx] || fns[0];
if (fn !== undefined) {
if (isnum(fn)) {
fn = easingMidpoint((fn - start) / delta);
}
P = fn(P);
}
let t0 = (idx - 1 + P) / n;
return def.channels.reduce(
(res, channel) => {
let val = interpolators[channel](t0);
if (val !== undefined) {
res[channel] = val;
}
return res;
},
{ mode }
);
};
};
const interpolate = (colors, mode = 'rgb', overrides) =>
interpolate_fn(colors, mode, overrides);
const interpolateWith =
(premap, postmap) =>
(colors, mode = 'rgb', overrides) => {
let post = postmap ? mapper(postmap, mode) : undefined;
let it = interpolate_fn(colors, mode, overrides, premap);
return post ? t => post(it(t)) : it;
};
const interpolateWithPremultipliedAlpha = interpolateWith(
mapAlphaMultiply,
mapAlphaDivide
);
export { interpolate, interpolateWith, interpolateWithPremultipliedAlpha };

28
node_modules/culori/src/interpolate/lerp.js generated vendored Normal file
View File

@ -0,0 +1,28 @@
const lerp = (a, b, t) => a + t * (b - a);
const unlerp = (a, b, v) => (v - a) / (b - a);
const blerp = (a00, a01, a10, a11, tx, ty) => {
return lerp(lerp(a00, a01, tx), lerp(a10, a11, tx), ty);
};
const trilerp = (
a000,
a010,
a100,
a110,
a001,
a011,
a101,
a111,
tx,
ty,
tz
) => {
return lerp(
blerp(a000, a010, a100, a110, tx, ty),
blerp(a001, a011, a101, a111, tx, ty),
tz
);
};
export { lerp, blerp, trilerp, unlerp };

4
node_modules/culori/src/interpolate/linear.js generated vendored Normal file
View File

@ -0,0 +1,4 @@
import { lerp } from './lerp.js';
import { interpolatorPiecewise } from './piecewise.js';
export const interpolatorLinear = interpolatorPiecewise(lerp);

Some files were not shown because too many files have changed in this diff Show More