remove trash
@ -1,20 +0,0 @@
|
||||
# pull the Node.js Docker image
|
||||
FROM node:alpine
|
||||
|
||||
# create the directory inside the container
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# copy the package.json files from local machine to the workdir in container
|
||||
COPY package*.json ./
|
||||
|
||||
# run npm install in our local machine
|
||||
RUN npm install
|
||||
|
||||
# copy the generated modules and all other files to the container
|
||||
COPY . .
|
||||
|
||||
# our app is running on port 5000 within the container, so need to expose it
|
||||
EXPOSE 5000
|
||||
|
||||
# the command that starts our app
|
||||
CMD ["node", "index.js"]
|
Before Width: | Height: | Size: 133 KiB |
Before Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 21 KiB |
@ -1,94 +0,0 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
||||
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
||||
width="933.000000pt" height="178.000000pt" viewBox="0 0 933.000000 178.000000"
|
||||
preserveAspectRatio="xMidYMid meet">
|
||||
|
||||
<g transform="translate(0.000000,178.000000) scale(0.100000,-0.100000)"
|
||||
fill="#000000" stroke="none">
|
||||
<path d="M7523 1475 c-40 -17 -53 -42 -53 -103 0 -71 21 -93 96 -102 141 -17
|
||||
214 18 214 101 0 59 -23 96 -68 108 -52 15 -151 13 -189 -4z"/>
|
||||
<path d="M380 1420 c0 -5 1 -11 2 -12 1 -2 -4 -13 -10 -25 -9 -16 -9 -24 -1
|
||||
-29 8 -5 6 -10 -5 -16 -23 -13 -21 -48 3 -48 10 0 21 -7 25 -15 6 -18 36 -9
|
||||
36 11 0 9 11 14 29 14 25 0 28 3 23 25 -2 15 0 25 7 25 6 0 11 7 11 15 0 19
|
||||
-14 19 -30 0 -7 -9 -21 -13 -31 -10 -11 4 -22 -1 -28 -12 -9 -16 -12 -16 -21
|
||||
-3 -10 14 -8 38 6 74 3 9 1 16 -5 16 -6 0 -11 -4 -11 -10z"/>
|
||||
<path d="M1095 1420 c-3 -5 -7 -26 -9 -45 -2 -20 -8 -41 -15 -48 -17 -17 -14
|
||||
-48 4 -40 9 3 22 -2 31 -13 14 -18 15 -18 30 4 10 12 27 22 41 22 20 0 23 4
|
||||
18 21 -5 14 -1 25 11 33 13 10 14 15 4 21 -8 5 -18 1 -26 -9 -8 -12 -20 -16
|
||||
-32 -12 -13 4 -22 1 -26 -9 -3 -8 -9 -15 -15 -15 -16 0 -19 36 -5 69 12 28 4
|
||||
45 -11 21z"/>
|
||||
<path d="M2010 981 l0 -441 140 0 140 0 0 131 0 130 32 -3 c31 -3 34 -8 88
|
||||
-128 l56 -125 152 -3 c84 -1 152 0 152 4 0 4 -33 69 -72 145 l-73 138 38 34
|
||||
c64 59 82 113 82 247 0 96 -3 122 -21 160 -27 57 -67 97 -124 124 -42 19 -65
|
||||
21 -317 24 l-273 3 0 -440z m428 197 c14 -14 16 -116 2 -138 -6 -10 -32 -16
|
||||
-79 -18 l-71 -4 0 86 0 86 68 0 c40 0 73 -5 80 -12z"/>
|
||||
<path d="M620 1400 c0 -5 5 -10 11 -10 5 0 7 5 4 10 -3 6 -8 10 -11 10 -2 0
|
||||
-4 -4 -4 -10z"/>
|
||||
<path d="M1340 1400 c0 -5 5 -10 11 -10 5 0 7 5 4 10 -3 6 -8 10 -11 10 -2 0
|
||||
-4 -4 -4 -10z"/>
|
||||
<path d="M3085 1260 c-87 -8 -193 -29 -200 -40 -3 -6 24 -190 29 -197 0 -1 26
|
||||
5 56 13 30 8 108 17 173 21 l117 6 0 -25 c0 -25 -2 -25 -93 -32 -217 -16 -308
|
||||
-71 -338 -204 -9 -38 -9 -64 -1 -108 24 -117 97 -168 242 -168 72 -1 94 4 145
|
||||
27 33 16 70 38 83 49 l22 22 43 -42 c42 -41 45 -42 110 -42 l67 0 0 273 c0
|
||||
307 -4 326 -75 384 -66 55 -214 79 -380 63z m175 -459 c0 -56 -19 -71 -91 -71
|
||||
l-59 0 0 45 c0 54 14 64 93 65 l57 0 0 -39z"/>
|
||||
<path d="M4012 1259 c-59 -10 -103 -30 -134 -61 l-21 -21 -24 32 c-23 29 -28
|
||||
31 -94 31 l-69 0 0 -466 0 -466 43 5 c23 4 86 9 140 13 l97 6 0 104 0 104 90
|
||||
0 c168 0 248 36 303 137 79 146 51 407 -54 512 -62 63 -166 89 -277 70z m78
|
||||
-342 c0 -176 -5 -187 -86 -187 l-54 0 0 149 c0 176 2 181 86 181 l54 0 0 -143z"/>
|
||||
<path d="M4849 1260 c-56 -10 -111 -34 -135 -61 -23 -25 -27 -24 -47 11 -18
|
||||
29 -20 30 -93 30 l-74 0 0 -466 0 -466 43 5 c23 4 86 9 140 13 l97 6 0 103 0
|
||||
102 123 5 c97 4 130 9 162 25 99 51 145 137 153 281 11 209 -49 343 -179 395
|
||||
-46 19 -133 27 -190 17z m71 -355 c0 -177 1 -175 -89 -175 l-51 0 0 149 c0
|
||||
144 1 151 22 165 13 9 43 16 70 16 l48 0 0 -155z"/>
|
||||
<path d="M5550 1260 c-71 -7 -188 -28 -201 -36 -5 -3 16 -159 26 -191 3 -9 17
|
||||
-8 57 3 29 8 106 17 171 21 l117 6 0 -24 c0 -24 -3 -25 -113 -36 -230 -23
|
||||
-317 -93 -317 -255 1 -145 60 -209 208 -224 75 -8 171 16 238 61 l51 33 39
|
||||
-39 c37 -38 40 -39 106 -39 l68 0 0 277 c0 262 -1 279 -21 321 -48 99 -210
|
||||
145 -429 122z m170 -465 c0 -54 -16 -65 -94 -65 l-56 0 0 45 c0 54 14 64 93
|
||||
65 l57 0 0 -45z"/>
|
||||
<path d="M8160 1260 c-130 -21 -195 -62 -240 -154 -77 -156 -50 -415 53 -502
|
||||
77 -66 221 -96 356 -76 187 27 272 124 287 325 11 153 -34 287 -119 348 -71
|
||||
51 -218 77 -337 59z m160 -343 c0 -176 -5 -187 -86 -187 l-54 0 0 155 c0 177
|
||||
-1 174 88 175 l52 0 0 -143z"/>
|
||||
<path d="M7296 1240 c-27 -10 -66 -31 -87 -45 l-38 -27 -31 36 c-31 35 -34 36
|
||||
-106 36 l-74 0 0 -350 0 -351 138 3 137 3 3 199 c1 120 7 204 13 212 6 7 41
|
||||
21 79 30 l69 18 -5 86 c-8 144 -13 170 -32 170 -9 -1 -39 -10 -66 -20z"/>
|
||||
<path d="M6120 952 c0 -281 1 -290 23 -333 34 -66 96 -94 207 -94 98 0 143 13
|
||||
204 60 l44 33 38 -39 c39 -40 39 -40 109 -37 l70 3 3 348 2 347 -140 0 -140 0
|
||||
0 -233 c0 -277 0 -277 -86 -277 l-54 0 0 255 0 255 -140 0 -140 0 0 -288z"/>
|
||||
<path d="M7605 1225 c-49 -7 -98 -14 -107 -14 -17 -1 -18 -24 -18 -336 l0
|
||||
-335 140 0 140 0 0 350 0 350 -32 -1 c-18 -1 -73 -7 -123 -14z"/>
|
||||
<path d="M611 1194 c0 -11 3 -14 6 -6 3 7 2 16 -1 19 -3 4 -6 -2 -5 -13z"/>
|
||||
<path d="M581 1184 c0 -11 3 -14 6 -6 3 7 2 16 -1 19 -3 4 -6 -2 -5 -13z"/>
|
||||
<path d="M1155 1131 c-3 -5 -1 -12 5 -16 5 -3 10 1 10 9 0 18 -6 21 -15 7z"/>
|
||||
<path d="M792 1118 c-18 -18 -15 -113 3 -128 12 -10 15 -37 15 -121 l0 -109
|
||||
-110 0 -110 0 0 35 0 35 50 0 c41 0 56 5 75 25 32 31 35 89 6 105 -21 11 -348
|
||||
14 -375 4 -11 -4 -16 -19 -16 -48 0 -63 16 -79 89 -84 l61 -4 0 -34 0 -34 -58
|
||||
0 c-66 0 -92 -18 -92 -62 0 -54 16 -58 258 -58 l222 0 0 -45 c0 -43 -1 -45
|
||||
-30 -45 -38 0 -70 -32 -70 -70 l0 -30 -75 0 c-41 0 -85 -5 -99 -11 -31 -15
|
||||
-48 -55 -44 -105 l3 -39 173 -3 c149 -2 172 0 172 13 0 13 -23 15 -160 15
|
||||
l-160 0 0 34 c0 65 6 66 352 66 341 0 338 1 338 -66 l0 -34 -160 0 c-137 0
|
||||
-160 -2 -160 -15 0 -13 23 -15 173 -13 l172 3 3 52 c3 45 -1 56 -22 78 -23 23
|
||||
-33 25 -106 25 -77 0 -80 1 -80 24 0 39 -36 76 -76 76 -34 0 -34 0 -34 45 l0
|
||||
45 125 0 c104 0 125 2 125 15 0 13 -21 15 -125 15 l-125 0 0 30 0 30 218 0
|
||||
c229 0 251 -4 231 -42 -8 -15 -22 -18 -79 -18 -56 0 -70 -3 -70 -15 0 -12 15
|
||||
-15 74 -15 84 0 106 13 106 60 0 44 -23 60 -86 60 l-54 0 0 35 0 35 48 0 c69
|
||||
0 92 19 92 79 0 35 -4 51 -16 55 -20 8 -348 8 -368 0 -11 -4 -16 -19 -16 -48
|
||||
0 -62 17 -78 84 -84 l56 -4 0 -34 0 -34 -110 0 -110 0 0 106 c0 85 3 109 16
|
||||
118 24 18 30 90 10 121 -15 22 -23 25 -79 25 -36 0 -68 -5 -75 -12z m133 -63
|
||||
l0 -40 -57 -3 -58 -3 0 46 0 46 58 -3 57 -3 0 -40z m-35 -295 l0 -210 -25 0
|
||||
-25 0 0 210 0 210 25 0 25 0 0 -210z m-180 153 c-1 -42 -10 -44 -181 -41
|
||||
l-164 3 -3 28 -3 27 175 0 c161 0 176 -1 176 -17z m670 0 c-1 -42 -10 -44
|
||||
-181 -41 l-164 3 -3 28 -3 27 175 0 c161 0 176 -1 176 -17z m-820 -118 c0 -31
|
||||
-3 -35 -25 -35 -22 0 -25 4 -25 35 0 31 3 35 25 35 22 0 25 -4 25 -35z m670
|
||||
-1 c0 -33 -2 -35 -27 -32 -23 2 -29 8 -31 36 -3 30 -1 32 27 32 29 0 31 -3 31
|
||||
-36z m-420 -94 l0 -30 -220 0 c-187 0 -222 2 -226 15 -4 8 -4 22 0 30 4 13 39
|
||||
15 226 15 l220 0 0 -30z m180 -199 c25 -48 19 -51 -120 -51 l-130 0 0 29 c0
|
||||
16 6 32 13 34 6 3 60 6 119 6 96 1 108 -1 118 -18z"/>
|
||||
<path d="M605 1100 c3 -5 8 -10 11 -10 2 0 4 5 4 10 0 6 -5 10 -11 10 -5 0 -7
|
||||
-4 -4 -10z"/>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 265 KiB |
Before Width: | Height: | Size: 265 KiB |
Before Width: | Height: | Size: 1.0 MiB |
Before Width: | Height: | Size: 67 KiB |
406
app/index.js
@ -1,406 +0,0 @@
|
||||
const express = require('express');
|
||||
const exphbs = require('express-handlebars');
|
||||
const session = require('express-session');
|
||||
const MySQLStore = require('connect-mysql')(session);
|
||||
const path = require('path');
|
||||
const cookieParser = require('cookie-parser');
|
||||
const axios = require('axios');
|
||||
const bodyParser = require('body-parser');
|
||||
const Wikiapi = require('wikiapi');
|
||||
const wiki = new Wikiapi('fr');
|
||||
const app = express();
|
||||
const morgan = require('morgan');
|
||||
app.use(morgan('dev'));
|
||||
const mysql = require('mysql2');
|
||||
const dotenv = require('dotenv');
|
||||
const jwt = require('jsonwebtoken');
|
||||
// get config vars
|
||||
dotenv.config();
|
||||
|
||||
|
||||
|
||||
// Configuration du moteur de modèle Handlebars
|
||||
app.engine('.hbs', exphbs.engine({ extname: '.hbs' }));
|
||||
app.set('view engine', '.hbs');
|
||||
app.set('views', path.join(__dirname, 'views'));
|
||||
|
||||
// Middleware pour servir les fichiers statiques
|
||||
app.use(express.static(path.join(__dirname, '/')));
|
||||
|
||||
// Utilisation de cookie-parser comme middleware
|
||||
app.use(cookieParser());
|
||||
|
||||
// Middleware body-parser pour traiter les données POST du formulaire
|
||||
app.use(bodyParser.urlencoded({ extended: false }));
|
||||
|
||||
// ============================= FONCTIONS ========================================================
|
||||
|
||||
// Génère un token
|
||||
function generateAccessToken(username) {
|
||||
return jwt.sign(username, process.env.TOKEN_SECRET, { expiresIn: '1800s' });
|
||||
}
|
||||
|
||||
// Fonction de nettoyage personnalisée (pour infobox)
|
||||
function cleanInfoboxText(text) {
|
||||
// Supprimer les balises HTML
|
||||
const cleanedText = text.replace(/<\/?[^>]+(>|$)/g, "");
|
||||
|
||||
// Supprimer les caractères '{' et '}'
|
||||
const cleanedTextWithoutBraces = cleanedText.replace(/[{}]/g, "");
|
||||
|
||||
// Supprimer le caractère '|'
|
||||
const cleanedTextWithoutPipe = cleanedTextWithoutBraces.replace(/\|/g, "");
|
||||
|
||||
// Supprimer les caractères '[' et ']'
|
||||
const finalText = cleanedTextWithoutPipe.replace(/[\[\]]/g, "");
|
||||
|
||||
return finalText.trim();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Fonction pour récupérer les informations d'un article depuis l'API MediaWiki
|
||||
async function fetchArticleInfoFromAPI(articleTitle) {
|
||||
try {
|
||||
// Définir les paramètres de la requête pour obtenir les suggestions de titre
|
||||
const suggestionParams = new URLSearchParams({
|
||||
action: 'opensearch',
|
||||
search: articleTitle,
|
||||
format: 'json',
|
||||
});
|
||||
|
||||
// Effectuer la requête GET pour obtenir les suggestions de titre
|
||||
const suggestionResponse = await axios.get(`https://fr.wikipedia.org/w/api.php?${suggestionParams.toString()}`);
|
||||
const suggestionData = suggestionResponse.data;
|
||||
|
||||
// Vérifier s'il y a des suggestions de titre
|
||||
if (Array.isArray(suggestionData[1]) && suggestionData[1].length > 0) {
|
||||
// Utiliser le premier titre suggéré comme titre de l'article
|
||||
articleTitle = suggestionData[1][0];
|
||||
}
|
||||
|
||||
// Répéter la requête pour obtenir les informations de l'article avec le titre corrigé ou suggéré
|
||||
const params = new URLSearchParams({
|
||||
action: 'query',
|
||||
titles: articleTitle,
|
||||
format: 'json',
|
||||
prop: 'extracts|info|revisions|pageimages', // Ajoutez 'pageimages' pour obtenir les informations sur l'image
|
||||
inprop: 'url',
|
||||
explaintext: true,
|
||||
rvprop: 'timestamp|user|size|ids',
|
||||
rvlimit: 1,
|
||||
piprop: 'original', // Spécifiez 'original' pour obtenir l'URL de l'image originale
|
||||
});
|
||||
|
||||
// Effectuer la requête GET à l'API MediaWiki
|
||||
const response = await axios.get(`https://fr.wikipedia.org/w/api.php?${params.toString()}`);
|
||||
const data = response.data;
|
||||
|
||||
// ==== RECHERCHE INFOBOX ====
|
||||
|
||||
let infobox = {};
|
||||
|
||||
// Vérifiez si articleTitle est défini et non vide
|
||||
if (articleTitle) {
|
||||
const page_data = await wiki.page(articleTitle);
|
||||
const parsed = page_data.parse();
|
||||
|
||||
// Filtre des données compliquée à représentée
|
||||
const variablesExclues = ['image', 'blason', 'drapeau', 'logo', 'légende', 'carte', 'légende-carte', '_', 'statut', 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
|
||||
// Lire les modèles Infobox, les convertir en JSON.
|
||||
parsed.each('template', (template_token) => {
|
||||
if (template_token.name.startsWith('Infobox')) {
|
||||
const parameters = template_token.parameters;
|
||||
for (const key of Object.keys(parameters)) {
|
||||
const value = parameters[key];
|
||||
if (value !== '' && !variablesExclues.some(excluded => key.includes(excluded))) {
|
||||
infobox[key] = cleanInfoboxText(value.toString()); // Appliquer la fonction de nettoyage ici
|
||||
}
|
||||
}
|
||||
return parsed.each.exit;
|
||||
}
|
||||
});
|
||||
|
||||
// Vérifiez si l'infobox est vide
|
||||
if (Object.keys(infobox).length === 0) {
|
||||
console.log("Warning : Pas d'infobox");
|
||||
infobox = {
|
||||
Erreur: "Pas d'infobox sur wikipédia"
|
||||
};
|
||||
}
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
|
||||
// Vérifier si 'query' existe dans les données
|
||||
if (data.query) {
|
||||
// Obtenir la première page (il peut y avoir plusieurs résultats, nous prenons le premier)
|
||||
const page = Object.values(data.query.pages)[0];
|
||||
|
||||
if (page.missing !== undefined) {
|
||||
console.log(`Warning : l'article "${articleTitle}" n'a pas été trouvé.`);
|
||||
return null;
|
||||
} else {
|
||||
|
||||
// Fonction pour limiter le texte à 300 caractères et s'arrêter au dernier point
|
||||
function limitTextTo300Chars(text) {
|
||||
if (text.length <= 300) {
|
||||
// Si le texte est déjà inférieur ou égal à 300 caractères, retournez-le tel quel
|
||||
return text;
|
||||
} else {
|
||||
// Trouvez le dernier point dans les 300 premiers caractères
|
||||
const truncatedText = text.substring(0, 300);
|
||||
const lastPeriodIndex = truncatedText.lastIndexOf('.');
|
||||
|
||||
if (lastPeriodIndex !== -1) {
|
||||
// S'il y a un point dans les 300 premiers caractères, coupez le texte jusqu'à ce point
|
||||
return truncatedText.substring(0, lastPeriodIndex + 1);
|
||||
} else {
|
||||
// S'il n'y a pas de point, retournez simplement les 200 premiers caractères
|
||||
return truncatedText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Extraire les informations
|
||||
const articleInfo = {
|
||||
url: page.fullurl,
|
||||
title: page.title,
|
||||
extract: page.extract ? limitTextTo300Chars(page.extract) : 'Non disponible',
|
||||
lastEdit: page.revisions ? new Date(page.revisions[0].timestamp).toLocaleString() : 'Non disponible',
|
||||
numRevisions: page.revisions ? page.revisions[0].revid : 'Non disponible',
|
||||
pageSize: page.revisions ? page.revisions[0].size : 'Non disponible',
|
||||
firstRevisionUser: page.revisions ? page.revisions[0].user : 'Non disponible',
|
||||
latestRevisionId: page.revisions ? page.revisions[0].revid : 'Non disponible',
|
||||
pageId: page.pageid ? page.pageid : 'Non disponible',
|
||||
latestVersion: page.revisions ? page.revisions[0].parentid : 'Non disponible',
|
||||
wordCount: page.extract ? page.extract.split(/\s+/).length : 'Non disponible',
|
||||
charCount: page.extract ? page.extract.length : 'Non disponible',
|
||||
lastContributor: page.revisions ? page.revisions[0].user : 'Non disponible',
|
||||
image: page.original ? page.original.source : 'Non disponible',
|
||||
infobox,
|
||||
};
|
||||
|
||||
return articleInfo;
|
||||
}
|
||||
} else {
|
||||
console.log(`Warning : l'article "${articleTitle}" n'a pas été trouvé.`);
|
||||
return null;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Erreur : lors de la récupération des informations depuis l\'API :', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// ============================= ROUTES ===========================================================
|
||||
|
||||
// Index
|
||||
app.get('/', async (req, res) => {
|
||||
// Renvoyez la page index avec les informations de l'article et de l'infobox
|
||||
res.render('contains/index', { pageTitle: 'Accueil' });
|
||||
});
|
||||
|
||||
// Comparaison d'articles
|
||||
app.post('/search', async (req, res) => {
|
||||
try {
|
||||
// Récupérez les données du formulaire depuis req.body
|
||||
const articleTitle1 = req.body.articleTitle1;
|
||||
const articleTitle2 = req.body.articleTitle2;
|
||||
|
||||
// Utilisez la fonction pour récupérer les informations des articles
|
||||
const articleInfo1 = await fetchArticleInfoFromAPI(articleTitle1);
|
||||
const articleInfo2 = await fetchArticleInfoFromAPI(articleTitle2);
|
||||
|
||||
// Renvoyez la réponse au format JSON
|
||||
res.json({ articleInfo1, articleInfo2 });
|
||||
} catch (error) {
|
||||
console.error('Erreur lors de la recherche d\'informations sur les articles :', error);
|
||||
res.status(500).json({ error: 'Une erreur s\'est produite lors de la recherche d\'informations sur les articles.' });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Connexion
|
||||
app.get('/connexion', (req, res) => {
|
||||
res.render('contains/signin', { pageTitle: 'Connexion' });
|
||||
});
|
||||
|
||||
app.post('/connexion', async (req, res) => {
|
||||
try {
|
||||
// Récupérez les données du formulaire depuis req.body
|
||||
const ClientEmail = req.body.email;
|
||||
const ClientPassword = req.body.password;
|
||||
//console.log("Succès : " + ClientEmail + " " + ClientPassword);
|
||||
|
||||
// config de la connexion à la BDD
|
||||
var connection = mysql.createConnection({
|
||||
host: 'localhost',
|
||||
user: process.env.MYSQL_USER,
|
||||
password: process.env.MYSQL_PASSWORD,
|
||||
database: process.env.MYSQL_DB
|
||||
});
|
||||
|
||||
// Connexion à la BDD
|
||||
connection.connect(function (err) {
|
||||
if (err) {
|
||||
console.error('Erreur de connexion à la base de données :', err);
|
||||
throw err;
|
||||
} else {
|
||||
console.log('Connecté à la base de données MariaDB !');
|
||||
|
||||
// Requète BDD qui recupère les données
|
||||
connection.query("SELECT * FROM User", (err, results, fields) => {
|
||||
if (err) {
|
||||
console.error('Erreur lors de l\'exécution de la requête :', err);
|
||||
throw err;
|
||||
}
|
||||
|
||||
// Vérification si l'utilisateur est correct
|
||||
let ValidationConnection = '';
|
||||
|
||||
for (const row of results) {
|
||||
const BddEmail = row.email;
|
||||
const BddPassword = row.password;
|
||||
|
||||
if (BddEmail === ClientEmail && BddPassword === ClientPassword) {
|
||||
ValidationConnection = 'OK';
|
||||
break; // Sort de la boucle dès qu'il y a une correspondance
|
||||
}
|
||||
}
|
||||
|
||||
if (ValidationConnection !== 'OK') {
|
||||
ValidationConnection = 'WrongID';
|
||||
}
|
||||
else {
|
||||
const token = generateAccessToken({ username: ClientEmail });
|
||||
//console.log(token);
|
||||
|
||||
res.json({token});
|
||||
|
||||
connection.query("INSERT INTO sessions (session_id, email) VALUES (?, ?)", [token, ClientEmail], (err, results, fields) => {
|
||||
if (err) {
|
||||
console.error('Erreur lors de l\'exécution de la requête :', err);
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Fermeture de la BDD
|
||||
connection.end(function (err) {
|
||||
if (err) {
|
||||
console.error('Erreur lors de la fermeture de la connexion :', err);
|
||||
} else {
|
||||
console.log('Connexion à la base de données fermée.');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Erreur lors de la tentative de connexion :', error);
|
||||
}
|
||||
});
|
||||
|
||||
// Inscription
|
||||
app.get('/inscription', (req, res) => {
|
||||
res.render('contains/signup', { pageTitle: 'Inscription' });
|
||||
});
|
||||
|
||||
app.post('/inscription', async (req, res) => {
|
||||
try {
|
||||
// Récupérez les données du formulaire depuis req.body
|
||||
const name = req.body.name;
|
||||
const ClientEmail = req.body.email;
|
||||
const ClientPassword = req.body.password;
|
||||
|
||||
// config de la connexion à la BDD
|
||||
var connection = mysql.createConnection({
|
||||
host: 'localhost',
|
||||
user: process.env.MYSQL_USER,
|
||||
password: process.env.MYSQL_PASSWORD,
|
||||
database: process.env.MYSQL_DB
|
||||
});
|
||||
|
||||
// Connexion à la BDD
|
||||
connection.connect(function (err) {
|
||||
if (err) {
|
||||
console.error('Erreur de connexion à la base de données :', err);
|
||||
} else {
|
||||
console.log('Connecté à la base de données MariaDB !');
|
||||
|
||||
// Requette BDD qui vérifie les adresses mails
|
||||
connection.query("SELECT email FROM User", (err, results, fields) => {
|
||||
if (err) {
|
||||
console.error('Erreur lors de l\'exécution de la requête :', err);
|
||||
throw err;
|
||||
}
|
||||
|
||||
let ValidationInscription = '';
|
||||
|
||||
for (const row of results) {
|
||||
const BddEmail = row.email;
|
||||
|
||||
if (BddEmail === ClientEmail) {
|
||||
ValidationInscription = 'Doublon';
|
||||
break; // Sort de la boucle dès qu'il y a une correspondance
|
||||
}
|
||||
}
|
||||
|
||||
if (ValidationInscription !== 'Doublon') {
|
||||
// Requète BDD qui insère les données
|
||||
connection.query("INSERT INTO User (name, email, password) VALUES (?, ?, ?)", [name, ClientEmail, ClientPassword], (err, results, fields) => {
|
||||
if (err) {
|
||||
console.error('Erreur lors de l\'exécution de la requête :', err);
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
ValidationInscription = 'OK';
|
||||
}
|
||||
console.log(ValidationInscription);
|
||||
|
||||
// Fermeture de la BDD
|
||||
connection.end(function (err) {
|
||||
if (err) {
|
||||
console.error('Erreur lors de la fermeture de la connexion :', err);
|
||||
} else {
|
||||
console.log('Connexion à la base de données fermée.');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la tentative d'inscription :", error);
|
||||
}
|
||||
});
|
||||
|
||||
// Historique
|
||||
app.get('/historique', (req, res) => {
|
||||
res.render('contains/historique', { pageTitle: 'Historique' });
|
||||
});
|
||||
|
||||
// 404
|
||||
app.use((req, res, next) => {
|
||||
res.status(404).render('contains/404', { title: 'Erreur 404' });
|
||||
});
|
||||
|
||||
|
||||
// ============================= PORT ============================================================
|
||||
|
||||
|
||||
// Port
|
||||
const PORT = process.env.PORT || 5000;
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Info : le serveur est en écoute sur le port ${PORT}`);
|
||||
});
|
14
app/node_modules/@isaacs/cliui/LICENSE.txt
generated
vendored
@ -1,14 +0,0 @@
|
||||
Copyright (c) 2015, Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
that the above copyright notice and this permission notice
|
||||
appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
|
||||
LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
143
app/node_modules/@isaacs/cliui/README.md
generated
vendored
@ -1,143 +0,0 @@
|
||||
# @isaacs/cliui
|
||||
|
||||
Temporary fork of [cliui](http://npm.im/cliui).
|
||||
|
||||

|
||||
[](https://www.npmjs.com/package/cliui)
|
||||
[](https://conventionalcommits.org)
|
||||

|
||||
|
||||
easily create complex multi-column command-line-interfaces.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
const ui = require('cliui')()
|
||||
|
||||
ui.div('Usage: $0 [command] [options]')
|
||||
|
||||
ui.div({
|
||||
text: 'Options:',
|
||||
padding: [2, 0, 1, 0]
|
||||
})
|
||||
|
||||
ui.div(
|
||||
{
|
||||
text: "-f, --file",
|
||||
width: 20,
|
||||
padding: [0, 4, 0, 4]
|
||||
},
|
||||
{
|
||||
text: "the file to load." +
|
||||
chalk.green("(if this description is long it wraps).")
|
||||
,
|
||||
width: 20
|
||||
},
|
||||
{
|
||||
text: chalk.red("[required]"),
|
||||
align: 'right'
|
||||
}
|
||||
)
|
||||
|
||||
console.log(ui.toString())
|
||||
```
|
||||
|
||||
## Deno/ESM Support
|
||||
|
||||
As of `v7` `cliui` supports [Deno](https://github.com/denoland/deno) and
|
||||
[ESM](https://nodejs.org/api/esm.html#esm_ecmascript_modules):
|
||||
|
||||
```typescript
|
||||
import cliui from "https://deno.land/x/cliui/deno.ts";
|
||||
|
||||
const ui = cliui({})
|
||||
|
||||
ui.div('Usage: $0 [command] [options]')
|
||||
|
||||
ui.div({
|
||||
text: 'Options:',
|
||||
padding: [2, 0, 1, 0]
|
||||
})
|
||||
|
||||
ui.div({
|
||||
text: "-f, --file",
|
||||
width: 20,
|
||||
padding: [0, 4, 0, 4]
|
||||
})
|
||||
|
||||
console.log(ui.toString())
|
||||
```
|
||||
|
||||
<img width="500" src="screenshot.png">
|
||||
|
||||
## Layout DSL
|
||||
|
||||
cliui exposes a simple layout DSL:
|
||||
|
||||
If you create a single `ui.div`, passing a string rather than an
|
||||
object:
|
||||
|
||||
* `\n`: characters will be interpreted as new rows.
|
||||
* `\t`: characters will be interpreted as new columns.
|
||||
* `\s`: characters will be interpreted as padding.
|
||||
|
||||
**as an example...**
|
||||
|
||||
```js
|
||||
var ui = require('./')({
|
||||
width: 60
|
||||
})
|
||||
|
||||
ui.div(
|
||||
'Usage: node ./bin/foo.js\n' +
|
||||
' <regex>\t provide a regex\n' +
|
||||
' <glob>\t provide a glob\t [required]'
|
||||
)
|
||||
|
||||
console.log(ui.toString())
|
||||
```
|
||||
|
||||
**will output:**
|
||||
|
||||
```shell
|
||||
Usage: node ./bin/foo.js
|
||||
<regex> provide a regex
|
||||
<glob> provide a glob [required]
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
```js
|
||||
cliui = require('cliui')
|
||||
```
|
||||
|
||||
### cliui({width: integer})
|
||||
|
||||
Specify the maximum width of the UI being generated.
|
||||
If no width is provided, cliui will try to get the current window's width and use it, and if that doesn't work, width will be set to `80`.
|
||||
|
||||
### cliui({wrap: boolean})
|
||||
|
||||
Enable or disable the wrapping of text in a column.
|
||||
|
||||
### cliui.div(column, column, column)
|
||||
|
||||
Create a row with any number of columns, a column
|
||||
can either be a string, or an object with the following
|
||||
options:
|
||||
|
||||
* **text:** some text to place in the column.
|
||||
* **width:** the width of a column.
|
||||
* **align:** alignment, `right` or `center`.
|
||||
* **padding:** `[top, right, bottom, left]`.
|
||||
* **border:** should a border be placed around the div?
|
||||
|
||||
### cliui.span(column, column, column)
|
||||
|
||||
Similar to `div`, except the next row will be appended without
|
||||
a new line being created.
|
||||
|
||||
### cliui.resetOutput()
|
||||
|
||||
Resets the UI elements of the current cliui instance, maintaining the values
|
||||
set for `width` and `wrap`.
|
317
app/node_modules/@isaacs/cliui/build/index.cjs
generated
vendored
@ -1,317 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const align = {
|
||||
right: alignRight,
|
||||
center: alignCenter
|
||||
};
|
||||
const top = 0;
|
||||
const right = 1;
|
||||
const bottom = 2;
|
||||
const left = 3;
|
||||
class UI {
|
||||
constructor(opts) {
|
||||
var _a;
|
||||
this.width = opts.width;
|
||||
/* c8 ignore start */
|
||||
this.wrap = (_a = opts.wrap) !== null && _a !== void 0 ? _a : true;
|
||||
/* c8 ignore stop */
|
||||
this.rows = [];
|
||||
}
|
||||
span(...args) {
|
||||
const cols = this.div(...args);
|
||||
cols.span = true;
|
||||
}
|
||||
resetOutput() {
|
||||
this.rows = [];
|
||||
}
|
||||
div(...args) {
|
||||
if (args.length === 0) {
|
||||
this.div('');
|
||||
}
|
||||
if (this.wrap && this.shouldApplyLayoutDSL(...args) && typeof args[0] === 'string') {
|
||||
return this.applyLayoutDSL(args[0]);
|
||||
}
|
||||
const cols = args.map(arg => {
|
||||
if (typeof arg === 'string') {
|
||||
return this.colFromString(arg);
|
||||
}
|
||||
return arg;
|
||||
});
|
||||
this.rows.push(cols);
|
||||
return cols;
|
||||
}
|
||||
shouldApplyLayoutDSL(...args) {
|
||||
return args.length === 1 && typeof args[0] === 'string' &&
|
||||
/[\t\n]/.test(args[0]);
|
||||
}
|
||||
applyLayoutDSL(str) {
|
||||
const rows = str.split('\n').map(row => row.split('\t'));
|
||||
let leftColumnWidth = 0;
|
||||
// simple heuristic for layout, make sure the
|
||||
// second column lines up along the left-hand.
|
||||
// don't allow the first column to take up more
|
||||
// than 50% of the screen.
|
||||
rows.forEach(columns => {
|
||||
if (columns.length > 1 && mixin.stringWidth(columns[0]) > leftColumnWidth) {
|
||||
leftColumnWidth = Math.min(Math.floor(this.width * 0.5), mixin.stringWidth(columns[0]));
|
||||
}
|
||||
});
|
||||
// generate a table:
|
||||
// replacing ' ' with padding calculations.
|
||||
// using the algorithmically generated width.
|
||||
rows.forEach(columns => {
|
||||
this.div(...columns.map((r, i) => {
|
||||
return {
|
||||
text: r.trim(),
|
||||
padding: this.measurePadding(r),
|
||||
width: (i === 0 && columns.length > 1) ? leftColumnWidth : undefined
|
||||
};
|
||||
}));
|
||||
});
|
||||
return this.rows[this.rows.length - 1];
|
||||
}
|
||||
colFromString(text) {
|
||||
return {
|
||||
text,
|
||||
padding: this.measurePadding(text)
|
||||
};
|
||||
}
|
||||
measurePadding(str) {
|
||||
// measure padding without ansi escape codes
|
||||
const noAnsi = mixin.stripAnsi(str);
|
||||
return [0, noAnsi.match(/\s*$/)[0].length, 0, noAnsi.match(/^\s*/)[0].length];
|
||||
}
|
||||
toString() {
|
||||
const lines = [];
|
||||
this.rows.forEach(row => {
|
||||
this.rowToString(row, lines);
|
||||
});
|
||||
// don't display any lines with the
|
||||
// hidden flag set.
|
||||
return lines
|
||||
.filter(line => !line.hidden)
|
||||
.map(line => line.text)
|
||||
.join('\n');
|
||||
}
|
||||
rowToString(row, lines) {
|
||||
this.rasterize(row).forEach((rrow, r) => {
|
||||
let str = '';
|
||||
rrow.forEach((col, c) => {
|
||||
const { width } = row[c]; // the width with padding.
|
||||
const wrapWidth = this.negatePadding(row[c]); // the width without padding.
|
||||
let ts = col; // temporary string used during alignment/padding.
|
||||
if (wrapWidth > mixin.stringWidth(col)) {
|
||||
ts += ' '.repeat(wrapWidth - mixin.stringWidth(col));
|
||||
}
|
||||
// align the string within its column.
|
||||
if (row[c].align && row[c].align !== 'left' && this.wrap) {
|
||||
const fn = align[row[c].align];
|
||||
ts = fn(ts, wrapWidth);
|
||||
if (mixin.stringWidth(ts) < wrapWidth) {
|
||||
/* c8 ignore start */
|
||||
const w = width || 0;
|
||||
/* c8 ignore stop */
|
||||
ts += ' '.repeat(w - mixin.stringWidth(ts) - 1);
|
||||
}
|
||||
}
|
||||
// apply border and padding to string.
|
||||
const padding = row[c].padding || [0, 0, 0, 0];
|
||||
if (padding[left]) {
|
||||
str += ' '.repeat(padding[left]);
|
||||
}
|
||||
str += addBorder(row[c], ts, '| ');
|
||||
str += ts;
|
||||
str += addBorder(row[c], ts, ' |');
|
||||
if (padding[right]) {
|
||||
str += ' '.repeat(padding[right]);
|
||||
}
|
||||
// if prior row is span, try to render the
|
||||
// current row on the prior line.
|
||||
if (r === 0 && lines.length > 0) {
|
||||
str = this.renderInline(str, lines[lines.length - 1]);
|
||||
}
|
||||
});
|
||||
// remove trailing whitespace.
|
||||
lines.push({
|
||||
text: str.replace(/ +$/, ''),
|
||||
span: row.span
|
||||
});
|
||||
});
|
||||
return lines;
|
||||
}
|
||||
// if the full 'source' can render in
|
||||
// the target line, do so.
|
||||
renderInline(source, previousLine) {
|
||||
const match = source.match(/^ */);
|
||||
/* c8 ignore start */
|
||||
const leadingWhitespace = match ? match[0].length : 0;
|
||||
/* c8 ignore stop */
|
||||
const target = previousLine.text;
|
||||
const targetTextWidth = mixin.stringWidth(target.trimEnd());
|
||||
if (!previousLine.span) {
|
||||
return source;
|
||||
}
|
||||
// if we're not applying wrapping logic,
|
||||
// just always append to the span.
|
||||
if (!this.wrap) {
|
||||
previousLine.hidden = true;
|
||||
return target + source;
|
||||
}
|
||||
if (leadingWhitespace < targetTextWidth) {
|
||||
return source;
|
||||
}
|
||||
previousLine.hidden = true;
|
||||
return target.trimEnd() + ' '.repeat(leadingWhitespace - targetTextWidth) + source.trimStart();
|
||||
}
|
||||
rasterize(row) {
|
||||
const rrows = [];
|
||||
const widths = this.columnWidths(row);
|
||||
let wrapped;
|
||||
// word wrap all columns, and create
|
||||
// a data-structure that is easy to rasterize.
|
||||
row.forEach((col, c) => {
|
||||
// leave room for left and right padding.
|
||||
col.width = widths[c];
|
||||
if (this.wrap) {
|
||||
wrapped = mixin.wrap(col.text, this.negatePadding(col), { hard: true }).split('\n');
|
||||
}
|
||||
else {
|
||||
wrapped = col.text.split('\n');
|
||||
}
|
||||
if (col.border) {
|
||||
wrapped.unshift('.' + '-'.repeat(this.negatePadding(col) + 2) + '.');
|
||||
wrapped.push("'" + '-'.repeat(this.negatePadding(col) + 2) + "'");
|
||||
}
|
||||
// add top and bottom padding.
|
||||
if (col.padding) {
|
||||
wrapped.unshift(...new Array(col.padding[top] || 0).fill(''));
|
||||
wrapped.push(...new Array(col.padding[bottom] || 0).fill(''));
|
||||
}
|
||||
wrapped.forEach((str, r) => {
|
||||
if (!rrows[r]) {
|
||||
rrows.push([]);
|
||||
}
|
||||
const rrow = rrows[r];
|
||||
for (let i = 0; i < c; i++) {
|
||||
if (rrow[i] === undefined) {
|
||||
rrow.push('');
|
||||
}
|
||||
}
|
||||
rrow.push(str);
|
||||
});
|
||||
});
|
||||
return rrows;
|
||||
}
|
||||
negatePadding(col) {
|
||||
/* c8 ignore start */
|
||||
let wrapWidth = col.width || 0;
|
||||
/* c8 ignore stop */
|
||||
if (col.padding) {
|
||||
wrapWidth -= (col.padding[left] || 0) + (col.padding[right] || 0);
|
||||
}
|
||||
if (col.border) {
|
||||
wrapWidth -= 4;
|
||||
}
|
||||
return wrapWidth;
|
||||
}
|
||||
columnWidths(row) {
|
||||
if (!this.wrap) {
|
||||
return row.map(col => {
|
||||
return col.width || mixin.stringWidth(col.text);
|
||||
});
|
||||
}
|
||||
let unset = row.length;
|
||||
let remainingWidth = this.width;
|
||||
// column widths can be set in config.
|
||||
const widths = row.map(col => {
|
||||
if (col.width) {
|
||||
unset--;
|
||||
remainingWidth -= col.width;
|
||||
return col.width;
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
// any unset widths should be calculated.
|
||||
/* c8 ignore start */
|
||||
const unsetWidth = unset ? Math.floor(remainingWidth / unset) : 0;
|
||||
/* c8 ignore stop */
|
||||
return widths.map((w, i) => {
|
||||
if (w === undefined) {
|
||||
return Math.max(unsetWidth, _minWidth(row[i]));
|
||||
}
|
||||
return w;
|
||||
});
|
||||
}
|
||||
}
|
||||
function addBorder(col, ts, style) {
|
||||
if (col.border) {
|
||||
if (/[.']-+[.']/.test(ts)) {
|
||||
return '';
|
||||
}
|
||||
if (ts.trim().length !== 0) {
|
||||
return style;
|
||||
}
|
||||
return ' ';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
// calculates the minimum width of
|
||||
// a column, based on padding preferences.
|
||||
function _minWidth(col) {
|
||||
const padding = col.padding || [];
|
||||
const minWidth = 1 + (padding[left] || 0) + (padding[right] || 0);
|
||||
if (col.border) {
|
||||
return minWidth + 4;
|
||||
}
|
||||
return minWidth;
|
||||
}
|
||||
function getWindowWidth() {
|
||||
/* c8 ignore start */
|
||||
if (typeof process === 'object' && process.stdout && process.stdout.columns) {
|
||||
return process.stdout.columns;
|
||||
}
|
||||
return 80;
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
function alignRight(str, width) {
|
||||
str = str.trim();
|
||||
const strWidth = mixin.stringWidth(str);
|
||||
if (strWidth < width) {
|
||||
return ' '.repeat(width - strWidth) + str;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
function alignCenter(str, width) {
|
||||
str = str.trim();
|
||||
const strWidth = mixin.stringWidth(str);
|
||||
/* c8 ignore start */
|
||||
if (strWidth >= width) {
|
||||
return str;
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
return ' '.repeat((width - strWidth) >> 1) + str;
|
||||
}
|
||||
let mixin;
|
||||
function cliui(opts, _mixin) {
|
||||
mixin = _mixin;
|
||||
return new UI({
|
||||
/* c8 ignore start */
|
||||
width: (opts === null || opts === void 0 ? void 0 : opts.width) || getWindowWidth(),
|
||||
wrap: opts === null || opts === void 0 ? void 0 : opts.wrap
|
||||
/* c8 ignore stop */
|
||||
});
|
||||
}
|
||||
|
||||
// Bootstrap cliui with CommonJS dependencies:
|
||||
const stringWidth = require('string-width-cjs');
|
||||
const stripAnsi = require('strip-ansi-cjs');
|
||||
const wrap = require('wrap-ansi-cjs');
|
||||
function ui(opts) {
|
||||
return cliui(opts, {
|
||||
stringWidth,
|
||||
stripAnsi,
|
||||
wrap
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = ui;
|
43
app/node_modules/@isaacs/cliui/build/index.d.cts
generated
vendored
@ -1,43 +0,0 @@
|
||||
interface UIOptions {
|
||||
width: number;
|
||||
wrap?: boolean;
|
||||
rows?: string[];
|
||||
}
|
||||
interface Column {
|
||||
text: string;
|
||||
width?: number;
|
||||
align?: "right" | "left" | "center";
|
||||
padding: number[];
|
||||
border?: boolean;
|
||||
}
|
||||
interface ColumnArray extends Array<Column> {
|
||||
span: boolean;
|
||||
}
|
||||
interface Line {
|
||||
hidden?: boolean;
|
||||
text: string;
|
||||
span?: boolean;
|
||||
}
|
||||
declare class UI {
|
||||
width: number;
|
||||
wrap: boolean;
|
||||
rows: ColumnArray[];
|
||||
constructor(opts: UIOptions);
|
||||
span(...args: ColumnArray): void;
|
||||
resetOutput(): void;
|
||||
div(...args: (Column | string)[]): ColumnArray;
|
||||
private shouldApplyLayoutDSL;
|
||||
private applyLayoutDSL;
|
||||
private colFromString;
|
||||
private measurePadding;
|
||||
toString(): string;
|
||||
rowToString(row: ColumnArray, lines: Line[]): Line[];
|
||||
// if the full 'source' can render in
|
||||
// the target line, do so.
|
||||
private renderInline;
|
||||
private rasterize;
|
||||
private negatePadding;
|
||||
private columnWidths;
|
||||
}
|
||||
declare function ui(opts: UIOptions): UI;
|
||||
export { ui as default };
|
302
app/node_modules/@isaacs/cliui/build/lib/index.js
generated
vendored
@ -1,302 +0,0 @@
|
||||
'use strict';
|
||||
const align = {
|
||||
right: alignRight,
|
||||
center: alignCenter
|
||||
};
|
||||
const top = 0;
|
||||
const right = 1;
|
||||
const bottom = 2;
|
||||
const left = 3;
|
||||
export class UI {
|
||||
constructor(opts) {
|
||||
var _a;
|
||||
this.width = opts.width;
|
||||
/* c8 ignore start */
|
||||
this.wrap = (_a = opts.wrap) !== null && _a !== void 0 ? _a : true;
|
||||
/* c8 ignore stop */
|
||||
this.rows = [];
|
||||
}
|
||||
span(...args) {
|
||||
const cols = this.div(...args);
|
||||
cols.span = true;
|
||||
}
|
||||
resetOutput() {
|
||||
this.rows = [];
|
||||
}
|
||||
div(...args) {
|
||||
if (args.length === 0) {
|
||||
this.div('');
|
||||
}
|
||||
if (this.wrap && this.shouldApplyLayoutDSL(...args) && typeof args[0] === 'string') {
|
||||
return this.applyLayoutDSL(args[0]);
|
||||
}
|
||||
const cols = args.map(arg => {
|
||||
if (typeof arg === 'string') {
|
||||
return this.colFromString(arg);
|
||||
}
|
||||
return arg;
|
||||
});
|
||||
this.rows.push(cols);
|
||||
return cols;
|
||||
}
|
||||
shouldApplyLayoutDSL(...args) {
|
||||
return args.length === 1 && typeof args[0] === 'string' &&
|
||||
/[\t\n]/.test(args[0]);
|
||||
}
|
||||
applyLayoutDSL(str) {
|
||||
const rows = str.split('\n').map(row => row.split('\t'));
|
||||
let leftColumnWidth = 0;
|
||||
// simple heuristic for layout, make sure the
|
||||
// second column lines up along the left-hand.
|
||||
// don't allow the first column to take up more
|
||||
// than 50% of the screen.
|
||||
rows.forEach(columns => {
|
||||
if (columns.length > 1 && mixin.stringWidth(columns[0]) > leftColumnWidth) {
|
||||
leftColumnWidth = Math.min(Math.floor(this.width * 0.5), mixin.stringWidth(columns[0]));
|
||||
}
|
||||
});
|
||||
// generate a table:
|
||||
// replacing ' ' with padding calculations.
|
||||
// using the algorithmically generated width.
|
||||
rows.forEach(columns => {
|
||||
this.div(...columns.map((r, i) => {
|
||||
return {
|
||||
text: r.trim(),
|
||||
padding: this.measurePadding(r),
|
||||
width: (i === 0 && columns.length > 1) ? leftColumnWidth : undefined
|
||||
};
|
||||
}));
|
||||
});
|
||||
return this.rows[this.rows.length - 1];
|
||||
}
|
||||
colFromString(text) {
|
||||
return {
|
||||
text,
|
||||
padding: this.measurePadding(text)
|
||||
};
|
||||
}
|
||||
measurePadding(str) {
|
||||
// measure padding without ansi escape codes
|
||||
const noAnsi = mixin.stripAnsi(str);
|
||||
return [0, noAnsi.match(/\s*$/)[0].length, 0, noAnsi.match(/^\s*/)[0].length];
|
||||
}
|
||||
toString() {
|
||||
const lines = [];
|
||||
this.rows.forEach(row => {
|
||||
this.rowToString(row, lines);
|
||||
});
|
||||
// don't display any lines with the
|
||||
// hidden flag set.
|
||||
return lines
|
||||
.filter(line => !line.hidden)
|
||||
.map(line => line.text)
|
||||
.join('\n');
|
||||
}
|
||||
rowToString(row, lines) {
|
||||
this.rasterize(row).forEach((rrow, r) => {
|
||||
let str = '';
|
||||
rrow.forEach((col, c) => {
|
||||
const { width } = row[c]; // the width with padding.
|
||||
const wrapWidth = this.negatePadding(row[c]); // the width without padding.
|
||||
let ts = col; // temporary string used during alignment/padding.
|
||||
if (wrapWidth > mixin.stringWidth(col)) {
|
||||
ts += ' '.repeat(wrapWidth - mixin.stringWidth(col));
|
||||
}
|
||||
// align the string within its column.
|
||||
if (row[c].align && row[c].align !== 'left' && this.wrap) {
|
||||
const fn = align[row[c].align];
|
||||
ts = fn(ts, wrapWidth);
|
||||
if (mixin.stringWidth(ts) < wrapWidth) {
|
||||
/* c8 ignore start */
|
||||
const w = width || 0;
|
||||
/* c8 ignore stop */
|
||||
ts += ' '.repeat(w - mixin.stringWidth(ts) - 1);
|
||||
}
|
||||
}
|
||||
// apply border and padding to string.
|
||||
const padding = row[c].padding || [0, 0, 0, 0];
|
||||
if (padding[left]) {
|
||||
str += ' '.repeat(padding[left]);
|
||||
}
|
||||
str += addBorder(row[c], ts, '| ');
|
||||
str += ts;
|
||||
str += addBorder(row[c], ts, ' |');
|
||||
if (padding[right]) {
|
||||
str += ' '.repeat(padding[right]);
|
||||
}
|
||||
// if prior row is span, try to render the
|
||||
// current row on the prior line.
|
||||
if (r === 0 && lines.length > 0) {
|
||||
str = this.renderInline(str, lines[lines.length - 1]);
|
||||
}
|
||||
});
|
||||
// remove trailing whitespace.
|
||||
lines.push({
|
||||
text: str.replace(/ +$/, ''),
|
||||
span: row.span
|
||||
});
|
||||
});
|
||||
return lines;
|
||||
}
|
||||
// if the full 'source' can render in
|
||||
// the target line, do so.
|
||||
renderInline(source, previousLine) {
|
||||
const match = source.match(/^ */);
|
||||
/* c8 ignore start */
|
||||
const leadingWhitespace = match ? match[0].length : 0;
|
||||
/* c8 ignore stop */
|
||||
const target = previousLine.text;
|
||||
const targetTextWidth = mixin.stringWidth(target.trimEnd());
|
||||
if (!previousLine.span) {
|
||||
return source;
|
||||
}
|
||||
// if we're not applying wrapping logic,
|
||||
// just always append to the span.
|
||||
if (!this.wrap) {
|
||||
previousLine.hidden = true;
|
||||
return target + source;
|
||||
}
|
||||
if (leadingWhitespace < targetTextWidth) {
|
||||
return source;
|
||||
}
|
||||
previousLine.hidden = true;
|
||||
return target.trimEnd() + ' '.repeat(leadingWhitespace - targetTextWidth) + source.trimStart();
|
||||
}
|
||||
rasterize(row) {
|
||||
const rrows = [];
|
||||
const widths = this.columnWidths(row);
|
||||
let wrapped;
|
||||
// word wrap all columns, and create
|
||||
// a data-structure that is easy to rasterize.
|
||||
row.forEach((col, c) => {
|
||||
// leave room for left and right padding.
|
||||
col.width = widths[c];
|
||||
if (this.wrap) {
|
||||
wrapped = mixin.wrap(col.text, this.negatePadding(col), { hard: true }).split('\n');
|
||||
}
|
||||
else {
|
||||
wrapped = col.text.split('\n');
|
||||
}
|
||||
if (col.border) {
|
||||
wrapped.unshift('.' + '-'.repeat(this.negatePadding(col) + 2) + '.');
|
||||
wrapped.push("'" + '-'.repeat(this.negatePadding(col) + 2) + "'");
|
||||
}
|
||||
// add top and bottom padding.
|
||||
if (col.padding) {
|
||||
wrapped.unshift(...new Array(col.padding[top] || 0).fill(''));
|
||||
wrapped.push(...new Array(col.padding[bottom] || 0).fill(''));
|
||||
}
|
||||
wrapped.forEach((str, r) => {
|
||||
if (!rrows[r]) {
|
||||
rrows.push([]);
|
||||
}
|
||||
const rrow = rrows[r];
|
||||
for (let i = 0; i < c; i++) {
|
||||
if (rrow[i] === undefined) {
|
||||
rrow.push('');
|
||||
}
|
||||
}
|
||||
rrow.push(str);
|
||||
});
|
||||
});
|
||||
return rrows;
|
||||
}
|
||||
negatePadding(col) {
|
||||
/* c8 ignore start */
|
||||
let wrapWidth = col.width || 0;
|
||||
/* c8 ignore stop */
|
||||
if (col.padding) {
|
||||
wrapWidth -= (col.padding[left] || 0) + (col.padding[right] || 0);
|
||||
}
|
||||
if (col.border) {
|
||||
wrapWidth -= 4;
|
||||
}
|
||||
return wrapWidth;
|
||||
}
|
||||
columnWidths(row) {
|
||||
if (!this.wrap) {
|
||||
return row.map(col => {
|
||||
return col.width || mixin.stringWidth(col.text);
|
||||
});
|
||||
}
|
||||
let unset = row.length;
|
||||
let remainingWidth = this.width;
|
||||
// column widths can be set in config.
|
||||
const widths = row.map(col => {
|
||||
if (col.width) {
|
||||
unset--;
|
||||
remainingWidth -= col.width;
|
||||
return col.width;
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
// any unset widths should be calculated.
|
||||
/* c8 ignore start */
|
||||
const unsetWidth = unset ? Math.floor(remainingWidth / unset) : 0;
|
||||
/* c8 ignore stop */
|
||||
return widths.map((w, i) => {
|
||||
if (w === undefined) {
|
||||
return Math.max(unsetWidth, _minWidth(row[i]));
|
||||
}
|
||||
return w;
|
||||
});
|
||||
}
|
||||
}
|
||||
function addBorder(col, ts, style) {
|
||||
if (col.border) {
|
||||
if (/[.']-+[.']/.test(ts)) {
|
||||
return '';
|
||||
}
|
||||
if (ts.trim().length !== 0) {
|
||||
return style;
|
||||
}
|
||||
return ' ';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
// calculates the minimum width of
|
||||
// a column, based on padding preferences.
|
||||
function _minWidth(col) {
|
||||
const padding = col.padding || [];
|
||||
const minWidth = 1 + (padding[left] || 0) + (padding[right] || 0);
|
||||
if (col.border) {
|
||||
return minWidth + 4;
|
||||
}
|
||||
return minWidth;
|
||||
}
|
||||
function getWindowWidth() {
|
||||
/* c8 ignore start */
|
||||
if (typeof process === 'object' && process.stdout && process.stdout.columns) {
|
||||
return process.stdout.columns;
|
||||
}
|
||||
return 80;
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
function alignRight(str, width) {
|
||||
str = str.trim();
|
||||
const strWidth = mixin.stringWidth(str);
|
||||
if (strWidth < width) {
|
||||
return ' '.repeat(width - strWidth) + str;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
function alignCenter(str, width) {
|
||||
str = str.trim();
|
||||
const strWidth = mixin.stringWidth(str);
|
||||
/* c8 ignore start */
|
||||
if (strWidth >= width) {
|
||||
return str;
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
return ' '.repeat((width - strWidth) >> 1) + str;
|
||||
}
|
||||
let mixin;
|
||||
export function cliui(opts, _mixin) {
|
||||
mixin = _mixin;
|
||||
return new UI({
|
||||
/* c8 ignore start */
|
||||
width: (opts === null || opts === void 0 ? void 0 : opts.width) || getWindowWidth(),
|
||||
wrap: opts === null || opts === void 0 ? void 0 : opts.wrap
|
||||
/* c8 ignore stop */
|
||||
});
|
||||
}
|
14
app/node_modules/@isaacs/cliui/index.mjs
generated
vendored
@ -1,14 +0,0 @@
|
||||
// Bootstrap cliui with ESM dependencies:
|
||||
import { cliui } from './build/lib/index.js'
|
||||
|
||||
import stringWidth from 'string-width'
|
||||
import stripAnsi from 'strip-ansi'
|
||||
import wrap from 'wrap-ansi'
|
||||
|
||||
export default function ui (opts) {
|
||||
return cliui(opts, {
|
||||
stringWidth,
|
||||
stripAnsi,
|
||||
wrap
|
||||
})
|
||||
}
|
122
app/node_modules/@isaacs/cliui/package.json
generated
vendored
@ -1,122 +0,0 @@
|
||||
{
|
||||
"_from": "@isaacs/cliui@^8.0.2",
|
||||
"_id": "@isaacs/cliui@8.0.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==",
|
||||
"_location": "/@isaacs/cliui",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@isaacs/cliui@^8.0.2",
|
||||
"name": "@isaacs/cliui",
|
||||
"escapedName": "@isaacs%2fcliui",
|
||||
"scope": "@isaacs",
|
||||
"rawSpec": "^8.0.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^8.0.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/jackspeak"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz",
|
||||
"_shasum": "b37667b7bc181c168782259bab42474fbf52b550",
|
||||
"_spec": "@isaacs/cliui@^8.0.2",
|
||||
"_where": "/mnt/c/Users/docto/Downloads/Rappaurio/node_modules/jackspeak",
|
||||
"author": {
|
||||
"name": "Ben Coe",
|
||||
"email": "ben@npmjs.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/yargs/cliui/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"string-width": "^5.1.2",
|
||||
"string-width-cjs": "npm:string-width@^4.2.0",
|
||||
"strip-ansi": "^7.0.1",
|
||||
"strip-ansi-cjs": "npm:strip-ansi@^6.0.1",
|
||||
"wrap-ansi": "^8.1.0",
|
||||
"wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "easily create complex multi-column command-line-interfaces",
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.0.27",
|
||||
"@typescript-eslint/eslint-plugin": "^4.0.0",
|
||||
"@typescript-eslint/parser": "^4.0.0",
|
||||
"c8": "^7.3.0",
|
||||
"chai": "^4.2.0",
|
||||
"chalk": "^4.1.0",
|
||||
"cross-env": "^7.0.2",
|
||||
"eslint": "^7.6.0",
|
||||
"eslint-plugin-import": "^2.22.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"gts": "^3.0.0",
|
||||
"mocha": "^10.0.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^2.23.1",
|
||||
"rollup-plugin-ts": "^3.0.2",
|
||||
"standardx": "^7.0.0",
|
||||
"typescript": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"exports": {
|
||||
".": [
|
||||
{
|
||||
"import": "./index.mjs",
|
||||
"require": "./build/index.cjs"
|
||||
},
|
||||
"./build/index.cjs"
|
||||
]
|
||||
},
|
||||
"files": [
|
||||
"build",
|
||||
"index.mjs",
|
||||
"!*.d.ts"
|
||||
],
|
||||
"homepage": "https://github.com/yargs/cliui#readme",
|
||||
"keywords": [
|
||||
"cli",
|
||||
"command-line",
|
||||
"layout",
|
||||
"design",
|
||||
"console",
|
||||
"wrap",
|
||||
"table"
|
||||
],
|
||||
"license": "ISC",
|
||||
"main": "build/index.cjs",
|
||||
"module": "./index.mjs",
|
||||
"name": "@isaacs/cliui",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/yargs/cliui.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build:cjs": "rollup -c",
|
||||
"check": "standardx '**/*.ts' && standardx '**/*.js' && standardx '**/*.cjs'",
|
||||
"compile": "tsc",
|
||||
"coverage": "c8 report --check-coverage",
|
||||
"fix": "standardx --fix '**/*.ts' && standardx --fix '**/*.js' && standardx --fix '**/*.cjs'",
|
||||
"postcompile": "npm run build:cjs",
|
||||
"postest": "check",
|
||||
"precompile": "rimraf build",
|
||||
"prepare": "npm run compile",
|
||||
"pretest": "rimraf build && tsc -p tsconfig.test.json && cross-env NODE_ENV=test npm run build:cjs",
|
||||
"test": "c8 mocha ./test/*.cjs",
|
||||
"test:esm": "c8 mocha ./test/**/*.mjs"
|
||||
},
|
||||
"standard": {
|
||||
"ignore": [
|
||||
"**/example/**"
|
||||
],
|
||||
"globals": [
|
||||
"it"
|
||||
]
|
||||
},
|
||||
"type": "module",
|
||||
"version": "8.0.2"
|
||||
}
|
14
app/node_modules/@pkgjs/parseargs/.editorconfig
generated
vendored
@ -1,14 +0,0 @@
|
||||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Copied from Node.js to ease compatibility in PR.
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
quote_type = single
|
147
app/node_modules/@pkgjs/parseargs/CHANGELOG.md
generated
vendored
@ -1,147 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
## [0.11.0](https://github.com/pkgjs/parseargs/compare/v0.10.0...v0.11.0) (2022-10-08)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add `default` option parameter ([#142](https://github.com/pkgjs/parseargs/issues/142)) ([cd20847](https://github.com/pkgjs/parseargs/commit/cd20847a00b2f556aa9c085ac83b942c60868ec1))
|
||||
|
||||
## [0.10.0](https://github.com/pkgjs/parseargs/compare/v0.9.1...v0.10.0) (2022-07-21)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add parsed meta-data to returned properties ([#129](https://github.com/pkgjs/parseargs/issues/129)) ([91bfb4d](https://github.com/pkgjs/parseargs/commit/91bfb4d3f7b6937efab1b27c91c45d1205f1497e))
|
||||
|
||||
## [0.9.1](https://github.com/pkgjs/parseargs/compare/v0.9.0...v0.9.1) (2022-06-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **runtime:** support node 14+ ([#135](https://github.com/pkgjs/parseargs/issues/135)) ([6a1c5a6](https://github.com/pkgjs/parseargs/commit/6a1c5a6f7cadf2f035e004027e2742e3c4ce554b))
|
||||
|
||||
## [0.9.0](https://github.com/pkgjs/parseargs/compare/v0.8.0...v0.9.0) (2022-05-23)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* drop handling of electron arguments (#121)
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* drop handling of electron arguments ([#121](https://github.com/pkgjs/parseargs/issues/121)) ([a2ffd53](https://github.com/pkgjs/parseargs/commit/a2ffd537c244a062371522b955acb45a404fc9f2))
|
||||
|
||||
## [0.8.0](https://github.com/pkgjs/parseargs/compare/v0.7.1...v0.8.0) (2022-05-16)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* switch type:string option arguments to greedy, but with error for suspect cases in strict mode (#88)
|
||||
* positionals now opt-in when strict:true (#116)
|
||||
* create result.values with null prototype (#111)
|
||||
|
||||
### Features
|
||||
|
||||
* create result.values with null prototype ([#111](https://github.com/pkgjs/parseargs/issues/111)) ([9d539c3](https://github.com/pkgjs/parseargs/commit/9d539c3d57f269c160e74e0656ad4fa84ff92ec2))
|
||||
* positionals now opt-in when strict:true ([#116](https://github.com/pkgjs/parseargs/issues/116)) ([3643338](https://github.com/pkgjs/parseargs/commit/364333826b746e8a7dc5505b4b22fd19ac51df3b))
|
||||
* switch type:string option arguments to greedy, but with error for suspect cases in strict mode ([#88](https://github.com/pkgjs/parseargs/issues/88)) ([c2b5e72](https://github.com/pkgjs/parseargs/commit/c2b5e72161991dfdc535909f1327cc9b970fe7e8))
|
||||
|
||||
### [0.7.1](https://github.com/pkgjs/parseargs/compare/v0.7.0...v0.7.1) (2022-04-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* resist pollution ([#106](https://github.com/pkgjs/parseargs/issues/106)) ([ecf2dec](https://github.com/pkgjs/parseargs/commit/ecf2dece0a9f2a76d789384d5d71c68ffe64022a))
|
||||
|
||||
## [0.7.0](https://github.com/pkgjs/parseargs/compare/v0.6.0...v0.7.0) (2022-04-13)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Add strict mode to parser ([#74](https://github.com/pkgjs/parseargs/issues/74)) ([8267d02](https://github.com/pkgjs/parseargs/commit/8267d02083a87b8b8a71fcce08348d1e031ea91c))
|
||||
|
||||
## [0.6.0](https://github.com/pkgjs/parseargs/compare/v0.5.0...v0.6.0) (2022-04-11)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* rework results to remove redundant `flags` property and store value true for boolean options (#83)
|
||||
* switch to existing ERR_INVALID_ARG_VALUE (#97)
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* rework results to remove redundant `flags` property and store value true for boolean options ([#83](https://github.com/pkgjs/parseargs/issues/83)) ([be153db](https://github.com/pkgjs/parseargs/commit/be153dbed1d488cb7b6e27df92f601ba7337713d))
|
||||
* switch to existing ERR_INVALID_ARG_VALUE ([#97](https://github.com/pkgjs/parseargs/issues/97)) ([084a23f](https://github.com/pkgjs/parseargs/commit/084a23f9fde2da030b159edb1c2385f24579ce40))
|
||||
|
||||
## [0.5.0](https://github.com/pkgjs/parseargs/compare/v0.4.0...v0.5.0) (2022-04-10)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* Require type to be specified for each supplied option (#95)
|
||||
|
||||
### Features
|
||||
|
||||
* Require type to be specified for each supplied option ([#95](https://github.com/pkgjs/parseargs/issues/95)) ([02cd018](https://github.com/pkgjs/parseargs/commit/02cd01885b8aaa59f2db8308f2d4479e64340068))
|
||||
|
||||
## [0.4.0](https://github.com/pkgjs/parseargs/compare/v0.3.0...v0.4.0) (2022-03-12)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* parsing, revisit short option groups, add support for combined short and value (#75)
|
||||
* restructure configuration to take options bag (#63)
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* parsing, revisit short option groups, add support for combined short and value ([#75](https://github.com/pkgjs/parseargs/issues/75)) ([a92600f](https://github.com/pkgjs/parseargs/commit/a92600fa6c214508ab1e016fa55879a314f541af))
|
||||
* restructure configuration to take options bag ([#63](https://github.com/pkgjs/parseargs/issues/63)) ([b412095](https://github.com/pkgjs/parseargs/commit/b4120957d90e809ee8b607b06e747d3e6a6b213e))
|
||||
|
||||
## [0.3.0](https://github.com/pkgjs/parseargs/compare/v0.2.0...v0.3.0) (2022-02-06)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **parser:** support short-option groups ([#59](https://github.com/pkgjs/parseargs/issues/59)) ([882067b](https://github.com/pkgjs/parseargs/commit/882067bc2d7cbc6b796f8e5a079a99bc99d4e6ba))
|
||||
|
||||
## [0.2.0](https://github.com/pkgjs/parseargs/compare/v0.1.1...v0.2.0) (2022-02-05)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* basic support for shorts ([#50](https://github.com/pkgjs/parseargs/issues/50)) ([a2f36d7](https://github.com/pkgjs/parseargs/commit/a2f36d7da4145af1c92f76806b7fe2baf6beeceb))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* always store value for a=b ([#43](https://github.com/pkgjs/parseargs/issues/43)) ([a85e8dc](https://github.com/pkgjs/parseargs/commit/a85e8dc06379fd2696ee195cc625de8fac6aee42))
|
||||
* support single dash as positional ([#49](https://github.com/pkgjs/parseargs/issues/49)) ([d795bf8](https://github.com/pkgjs/parseargs/commit/d795bf877d068fd67aec381f30b30b63f97109ad))
|
||||
|
||||
### [0.1.1](https://github.com/pkgjs/parseargs/compare/v0.1.0...v0.1.1) (2022-01-25)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* only use arrays in results for multiples ([#42](https://github.com/pkgjs/parseargs/issues/42)) ([c357584](https://github.com/pkgjs/parseargs/commit/c357584847912506319ed34a0840080116f4fd65))
|
||||
|
||||
## 0.1.0 (2022-01-22)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* expand scenarios covered by default arguments for environments ([#20](https://github.com/pkgjs/parseargs/issues/20)) ([582ada7](https://github.com/pkgjs/parseargs/commit/582ada7be0eca3a73d6e0bd016e7ace43449fa4c))
|
||||
* update readme and include contributing guidelines ([8edd6fc](https://github.com/pkgjs/parseargs/commit/8edd6fc863cd705f6fac732724159ebe8065a2b0))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* do not strip excess leading dashes on long option names ([#21](https://github.com/pkgjs/parseargs/issues/21)) ([f848590](https://github.com/pkgjs/parseargs/commit/f848590ebf3249ed5979ff47e003fa6e1a8ec5c0))
|
||||
* name & readme ([3f057c1](https://github.com/pkgjs/parseargs/commit/3f057c1b158a1bdbe878c64b57460c58e56e465f))
|
||||
* package.json values ([9bac300](https://github.com/pkgjs/parseargs/commit/9bac300e00cd76c77076bf9e75e44f8929512da9))
|
||||
* update readme name ([957d8d9](https://github.com/pkgjs/parseargs/commit/957d8d96e1dcb48297c0a14345d44c0123b2883e))
|
||||
|
||||
|
||||
### Build System
|
||||
|
||||
* first release as minor ([421c6e2](https://github.com/pkgjs/parseargs/commit/421c6e2569a8668ad14fac5a5af5be60479a7571))
|
201
app/node_modules/@pkgjs/parseargs/LICENSE
generated
vendored
@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
413
app/node_modules/@pkgjs/parseargs/README.md
generated
vendored
@ -1,413 +0,0 @@
|
||||
<!-- omit in toc -->
|
||||
# parseArgs
|
||||
|
||||
[![Coverage][coverage-image]][coverage-url]
|
||||
|
||||
Polyfill of `util.parseArgs()`
|
||||
|
||||
## `util.parseArgs([config])`
|
||||
|
||||
<!-- YAML
|
||||
added: v18.3.0
|
||||
changes:
|
||||
- version: REPLACEME
|
||||
pr-url: https://github.com/nodejs/node/pull/43459
|
||||
description: add support for returning detailed parse information
|
||||
using `tokens` in input `config` and returned properties.
|
||||
-->
|
||||
|
||||
> Stability: 1 - Experimental
|
||||
|
||||
* `config` {Object} Used to provide arguments for parsing and to configure
|
||||
the parser. `config` supports the following properties:
|
||||
* `args` {string\[]} array of argument strings. **Default:** `process.argv`
|
||||
with `execPath` and `filename` removed.
|
||||
* `options` {Object} Used to describe arguments known to the parser.
|
||||
Keys of `options` are the long names of options and values are an
|
||||
{Object} accepting the following properties:
|
||||
* `type` {string} Type of argument, which must be either `boolean` or `string`.
|
||||
* `multiple` {boolean} Whether this option can be provided multiple
|
||||
times. If `true`, all values will be collected in an array. If
|
||||
`false`, values for the option are last-wins. **Default:** `false`.
|
||||
* `short` {string} A single character alias for the option.
|
||||
* `default` {string | boolean | string\[] | boolean\[]} The default option
|
||||
value when it is not set by args. It must be of the same type as the
|
||||
the `type` property. When `multiple` is `true`, it must be an array.
|
||||
* `strict` {boolean} Should an error be thrown when unknown arguments
|
||||
are encountered, or when arguments are passed that do not match the
|
||||
`type` configured in `options`.
|
||||
**Default:** `true`.
|
||||
* `allowPositionals` {boolean} Whether this command accepts positional
|
||||
arguments.
|
||||
**Default:** `false` if `strict` is `true`, otherwise `true`.
|
||||
* `tokens` {boolean} Return the parsed tokens. This is useful for extending
|
||||
the built-in behavior, from adding additional checks through to reprocessing
|
||||
the tokens in different ways.
|
||||
**Default:** `false`.
|
||||
|
||||
* Returns: {Object} The parsed command line arguments:
|
||||
* `values` {Object} A mapping of parsed option names with their {string}
|
||||
or {boolean} values.
|
||||
* `positionals` {string\[]} Positional arguments.
|
||||
* `tokens` {Object\[] | undefined} See [parseArgs tokens](#parseargs-tokens)
|
||||
section. Only returned if `config` includes `tokens: true`.
|
||||
|
||||
Provides a higher level API for command-line argument parsing than interacting
|
||||
with `process.argv` directly. Takes a specification for the expected arguments
|
||||
and returns a structured object with the parsed options and positionals.
|
||||
|
||||
```mjs
|
||||
import { parseArgs } from 'node:util';
|
||||
const args = ['-f', '--bar', 'b'];
|
||||
const options = {
|
||||
foo: {
|
||||
type: 'boolean',
|
||||
short: 'f'
|
||||
},
|
||||
bar: {
|
||||
type: 'string'
|
||||
}
|
||||
};
|
||||
const {
|
||||
values,
|
||||
positionals
|
||||
} = parseArgs({ args, options });
|
||||
console.log(values, positionals);
|
||||
// Prints: [Object: null prototype] { foo: true, bar: 'b' } []
|
||||
```
|
||||
|
||||
```cjs
|
||||
const { parseArgs } = require('node:util');
|
||||
const args = ['-f', '--bar', 'b'];
|
||||
const options = {
|
||||
foo: {
|
||||
type: 'boolean',
|
||||
short: 'f'
|
||||
},
|
||||
bar: {
|
||||
type: 'string'
|
||||
}
|
||||
};
|
||||
const {
|
||||
values,
|
||||
positionals
|
||||
} = parseArgs({ args, options });
|
||||
console.log(values, positionals);
|
||||
// Prints: [Object: null prototype] { foo: true, bar: 'b' } []
|
||||
```
|
||||
|
||||
`util.parseArgs` is experimental and behavior may change. Join the
|
||||
conversation in [pkgjs/parseargs][] to contribute to the design.
|
||||
|
||||
### `parseArgs` `tokens`
|
||||
|
||||
Detailed parse information is available for adding custom behaviours by
|
||||
specifying `tokens: true` in the configuration.
|
||||
The returned tokens have properties describing:
|
||||
|
||||
* all tokens
|
||||
* `kind` {string} One of 'option', 'positional', or 'option-terminator'.
|
||||
* `index` {number} Index of element in `args` containing token. So the
|
||||
source argument for a token is `args[token.index]`.
|
||||
* option tokens
|
||||
* `name` {string} Long name of option.
|
||||
* `rawName` {string} How option used in args, like `-f` of `--foo`.
|
||||
* `value` {string | undefined} Option value specified in args.
|
||||
Undefined for boolean options.
|
||||
* `inlineValue` {boolean | undefined} Whether option value specified inline,
|
||||
like `--foo=bar`.
|
||||
* positional tokens
|
||||
* `value` {string} The value of the positional argument in args (i.e. `args[index]`).
|
||||
* option-terminator token
|
||||
|
||||
The returned tokens are in the order encountered in the input args. Options
|
||||
that appear more than once in args produce a token for each use. Short option
|
||||
groups like `-xy` expand to a token for each option. So `-xxx` produces
|
||||
three tokens.
|
||||
|
||||
For example to use the returned tokens to add support for a negated option
|
||||
like `--no-color`, the tokens can be reprocessed to change the value stored
|
||||
for the negated option.
|
||||
|
||||
```mjs
|
||||
import { parseArgs } from 'node:util';
|
||||
|
||||
const options = {
|
||||
'color': { type: 'boolean' },
|
||||
'no-color': { type: 'boolean' },
|
||||
'logfile': { type: 'string' },
|
||||
'no-logfile': { type: 'boolean' },
|
||||
};
|
||||
const { values, tokens } = parseArgs({ options, tokens: true });
|
||||
|
||||
// Reprocess the option tokens and overwrite the returned values.
|
||||
tokens
|
||||
.filter((token) => token.kind === 'option')
|
||||
.forEach((token) => {
|
||||
if (token.name.startsWith('no-')) {
|
||||
// Store foo:false for --no-foo
|
||||
const positiveName = token.name.slice(3);
|
||||
values[positiveName] = false;
|
||||
delete values[token.name];
|
||||
} else {
|
||||
// Resave value so last one wins if both --foo and --no-foo.
|
||||
values[token.name] = token.value ?? true;
|
||||
}
|
||||
});
|
||||
|
||||
const color = values.color;
|
||||
const logfile = values.logfile ?? 'default.log';
|
||||
|
||||
console.log({ logfile, color });
|
||||
```
|
||||
|
||||
```cjs
|
||||
const { parseArgs } = require('node:util');
|
||||
|
||||
const options = {
|
||||
'color': { type: 'boolean' },
|
||||
'no-color': { type: 'boolean' },
|
||||
'logfile': { type: 'string' },
|
||||
'no-logfile': { type: 'boolean' },
|
||||
};
|
||||
const { values, tokens } = parseArgs({ options, tokens: true });
|
||||
|
||||
// Reprocess the option tokens and overwrite the returned values.
|
||||
tokens
|
||||
.filter((token) => token.kind === 'option')
|
||||
.forEach((token) => {
|
||||
if (token.name.startsWith('no-')) {
|
||||
// Store foo:false for --no-foo
|
||||
const positiveName = token.name.slice(3);
|
||||
values[positiveName] = false;
|
||||
delete values[token.name];
|
||||
} else {
|
||||
// Resave value so last one wins if both --foo and --no-foo.
|
||||
values[token.name] = token.value ?? true;
|
||||
}
|
||||
});
|
||||
|
||||
const color = values.color;
|
||||
const logfile = values.logfile ?? 'default.log';
|
||||
|
||||
console.log({ logfile, color });
|
||||
```
|
||||
|
||||
Example usage showing negated options, and when an option is used
|
||||
multiple ways then last one wins.
|
||||
|
||||
```console
|
||||
$ node negate.js
|
||||
{ logfile: 'default.log', color: undefined }
|
||||
$ node negate.js --no-logfile --no-color
|
||||
{ logfile: false, color: false }
|
||||
$ node negate.js --logfile=test.log --color
|
||||
{ logfile: 'test.log', color: true }
|
||||
$ node negate.js --no-logfile --logfile=test.log --color --no-color
|
||||
{ logfile: 'test.log', color: false }
|
||||
```
|
||||
|
||||
-----
|
||||
|
||||
<!-- omit in toc -->
|
||||
## Table of Contents
|
||||
- [`util.parseArgs([config])`](#utilparseargsconfig)
|
||||
- [Scope](#scope)
|
||||
- [Version Matchups](#version-matchups)
|
||||
- [🚀 Getting Started](#-getting-started)
|
||||
- [🙌 Contributing](#-contributing)
|
||||
- [💡 `process.mainArgs` Proposal](#-processmainargs-proposal)
|
||||
- [Implementation:](#implementation)
|
||||
- [📃 Examples](#-examples)
|
||||
- [F.A.Qs](#faqs)
|
||||
- [Links & Resources](#links--resources)
|
||||
|
||||
-----
|
||||
|
||||
## Scope
|
||||
|
||||
It is already possible to build great arg parsing modules on top of what Node.js provides; the prickly API is abstracted away by these modules. Thus, process.parseArgs() is not necessarily intended for library authors; it is intended for developers of simple CLI tools, ad-hoc scripts, deployed Node.js applications, and learning materials.
|
||||
|
||||
It is exceedingly difficult to provide an API which would both be friendly to these Node.js users while being extensible enough for libraries to build upon. We chose to prioritize these use cases because these are currently not well-served by Node.js' API.
|
||||
|
||||
----
|
||||
|
||||
## Version Matchups
|
||||
|
||||
| Node.js | @pkgjs/parseArgs |
|
||||
| -- | -- |
|
||||
| [v18.3.0](https://nodejs.org/docs/latest-v18.x/api/util.html#utilparseargsconfig) | [v0.9.1](https://github.com/pkgjs/parseargs/tree/v0.9.1#utilparseargsconfig) |
|
||||
| [v16.17.0](https://nodejs.org/dist/latest-v16.x/docs/api/util.html#utilparseargsconfig), [v18.7.0](https://nodejs.org/docs/latest-v18.x/api/util.html#utilparseargsconfig) | [0.10.0](https://github.com/pkgjs/parseargs/tree/v0.10.0#utilparseargsconfig) |
|
||||
|
||||
----
|
||||
|
||||
## 🚀 Getting Started
|
||||
|
||||
1. **Install dependencies.**
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
2. **Open the index.js file and start editing!**
|
||||
|
||||
3. **Test your code by calling parseArgs through our test file**
|
||||
|
||||
```bash
|
||||
npm test
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
## 🙌 Contributing
|
||||
|
||||
Any person who wants to contribute to the initiative is welcome! Please first read the [Contributing Guide](CONTRIBUTING.md)
|
||||
|
||||
Additionally, reading the [`Examples w/ Output`](#-examples-w-output) section of this document will be the best way to familiarize yourself with the target expected behavior for parseArgs() once it is fully implemented.
|
||||
|
||||
This package was implemented using [tape](https://www.npmjs.com/package/tape) as its test harness.
|
||||
|
||||
----
|
||||
|
||||
## 💡 `process.mainArgs` Proposal
|
||||
|
||||
> Note: This can be moved forward independently of the `util.parseArgs()` proposal/work.
|
||||
|
||||
### Implementation:
|
||||
|
||||
```javascript
|
||||
process.mainArgs = process.argv.slice(process._exec ? 1 : 2)
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
## 📃 Examples
|
||||
|
||||
```js
|
||||
const { parseArgs } = require('@pkgjs/parseargs');
|
||||
```
|
||||
|
||||
```js
|
||||
const { parseArgs } = require('@pkgjs/parseargs');
|
||||
// specify the options that may be used
|
||||
const options = {
|
||||
foo: { type: 'string'},
|
||||
bar: { type: 'boolean' },
|
||||
};
|
||||
const args = ['--foo=a', '--bar'];
|
||||
const { values, positionals } = parseArgs({ args, options });
|
||||
// values = { foo: 'a', bar: true }
|
||||
// positionals = []
|
||||
```
|
||||
|
||||
```js
|
||||
const { parseArgs } = require('@pkgjs/parseargs');
|
||||
// type:string & multiple
|
||||
const options = {
|
||||
foo: {
|
||||
type: 'string',
|
||||
multiple: true,
|
||||
},
|
||||
};
|
||||
const args = ['--foo=a', '--foo', 'b'];
|
||||
const { values, positionals } = parseArgs({ args, options });
|
||||
// values = { foo: [ 'a', 'b' ] }
|
||||
// positionals = []
|
||||
```
|
||||
|
||||
```js
|
||||
const { parseArgs } = require('@pkgjs/parseargs');
|
||||
// shorts
|
||||
const options = {
|
||||
foo: {
|
||||
short: 'f',
|
||||
type: 'boolean'
|
||||
},
|
||||
};
|
||||
const args = ['-f', 'b'];
|
||||
const { values, positionals } = parseArgs({ args, options, allowPositionals: true });
|
||||
// values = { foo: true }
|
||||
// positionals = ['b']
|
||||
```
|
||||
|
||||
```js
|
||||
const { parseArgs } = require('@pkgjs/parseargs');
|
||||
// unconfigured
|
||||
const options = {};
|
||||
const args = ['-f', '--foo=a', '--bar', 'b'];
|
||||
const { values, positionals } = parseArgs({ strict: false, args, options, allowPositionals: true });
|
||||
// values = { f: true, foo: 'a', bar: true }
|
||||
// positionals = ['b']
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
## F.A.Qs
|
||||
|
||||
- Is `cmd --foo=bar baz` the same as `cmd baz --foo=bar`?
|
||||
- yes
|
||||
- Does the parser execute a function?
|
||||
- no
|
||||
- Does the parser execute one of several functions, depending on input?
|
||||
- no
|
||||
- Can subcommands take options that are distinct from the main command?
|
||||
- no
|
||||
- Does it output generated help when no options match?
|
||||
- no
|
||||
- Does it generated short usage? Like: `usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]`
|
||||
- no (no usage/help at all)
|
||||
- Does the user provide the long usage text? For each option? For the whole command?
|
||||
- no
|
||||
- Do subcommands (if implemented) have their own usage output?
|
||||
- no
|
||||
- Does usage print if the user runs `cmd --help`?
|
||||
- no
|
||||
- Does it set `process.exitCode`?
|
||||
- no
|
||||
- Does usage print to stderr or stdout?
|
||||
- N/A
|
||||
- Does it check types? (Say, specify that an option is a boolean, number, etc.)
|
||||
- no
|
||||
- Can an option have more than one type? (string or false, for example)
|
||||
- no
|
||||
- Can the user define a type? (Say, `type: path` to call `path.resolve()` on the argument.)
|
||||
- no
|
||||
- Does a `--foo=0o22` mean 0, 22, 18, or "0o22"?
|
||||
- `"0o22"`
|
||||
- Does it coerce types?
|
||||
- no
|
||||
- Does `--no-foo` coerce to `--foo=false`? For all options? Only boolean options?
|
||||
- no, it sets `{values:{'no-foo': true}}`
|
||||
- Is `--foo` the same as `--foo=true`? Only for known booleans? Only at the end?
|
||||
- no, they are not the same. There is no special handling of `true` as a value so it is just another string.
|
||||
- Does it read environment variables? Ie, is `FOO=1 cmd` the same as `cmd --foo=1`?
|
||||
- no
|
||||
- Do unknown arguments raise an error? Are they parsed? Are they treated as positional arguments?
|
||||
- no, they are parsed, not treated as positionals
|
||||
- Does `--` signal the end of options?
|
||||
- yes
|
||||
- Is `--` included as a positional?
|
||||
- no
|
||||
- Is `program -- foo` the same as `program foo`?
|
||||
- yes, both store `{positionals:['foo']}`
|
||||
- Does the API specify whether a `--` was present/relevant?
|
||||
- no
|
||||
- Is `-bar` the same as `--bar`?
|
||||
- no, `-bar` is a short option or options, with expansion logic that follows the
|
||||
[Utility Syntax Guidelines in POSIX.1-2017](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html). `-bar` expands to `-b`, `-a`, `-r`.
|
||||
- Is `---foo` the same as `--foo`?
|
||||
- no
|
||||
- the first is a long option named `'-foo'`
|
||||
- the second is a long option named `'foo'`
|
||||
- Is `-` a positional? ie, `bash some-test.sh | tap -`
|
||||
- yes
|
||||
|
||||
## Links & Resources
|
||||
|
||||
* [Initial Tooling Issue](https://github.com/nodejs/tooling/issues/19)
|
||||
* [Initial Proposal](https://github.com/nodejs/node/pull/35015)
|
||||
* [parseArgs Proposal](https://github.com/nodejs/node/pull/42675)
|
||||
|
||||
[coverage-image]: https://img.shields.io/nycrc/pkgjs/parseargs
|
||||
[coverage-url]: https://github.com/pkgjs/parseargs/blob/main/.nycrc
|
||||
[pkgjs/parseargs]: https://github.com/pkgjs/parseargs
|
25
app/node_modules/@pkgjs/parseargs/examples/is-default-value.js
generated
vendored
@ -1,25 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
// This example shows how to understand if a default value is used or not.
|
||||
|
||||
// 1. const { parseArgs } = require('node:util'); // from node
|
||||
// 2. const { parseArgs } = require('@pkgjs/parseargs'); // from package
|
||||
const { parseArgs } = require('..'); // in repo
|
||||
|
||||
const options = {
|
||||
file: { short: 'f', type: 'string', default: 'FOO' },
|
||||
};
|
||||
|
||||
const { values, tokens } = parseArgs({ options, tokens: true });
|
||||
|
||||
const isFileDefault = !tokens.some((token) => token.kind === 'option' &&
|
||||
token.name === 'file'
|
||||
);
|
||||
|
||||
console.log(values);
|
||||
console.log(`Is the file option [${values.file}] the default value? ${isFileDefault}`);
|
||||
|
||||
// Try the following:
|
||||
// node is-default-value.js
|
||||
// node is-default-value.js -f FILE
|
||||
// node is-default-value.js --file FILE
|
35
app/node_modules/@pkgjs/parseargs/examples/limit-long-syntax.js
generated
vendored
@ -1,35 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
// This is an example of using tokens to add a custom behaviour.
|
||||
//
|
||||
// Require the use of `=` for long options and values by blocking
|
||||
// the use of space separated values.
|
||||
// So allow `--foo=bar`, and not allow `--foo bar`.
|
||||
//
|
||||
// Note: this is not a common behaviour, most CLIs allow both forms.
|
||||
|
||||
// 1. const { parseArgs } = require('node:util'); // from node
|
||||
// 2. const { parseArgs } = require('@pkgjs/parseargs'); // from package
|
||||
const { parseArgs } = require('..'); // in repo
|
||||
|
||||
const options = {
|
||||
file: { short: 'f', type: 'string' },
|
||||
log: { type: 'string' },
|
||||
};
|
||||
|
||||
const { values, tokens } = parseArgs({ options, tokens: true });
|
||||
|
||||
const badToken = tokens.find((token) => token.kind === 'option' &&
|
||||
token.value != null &&
|
||||
token.rawName.startsWith('--') &&
|
||||
!token.inlineValue
|
||||
);
|
||||
if (badToken) {
|
||||
throw new Error(`Option value for '${badToken.rawName}' must be inline, like '${badToken.rawName}=VALUE'`);
|
||||
}
|
||||
|
||||
console.log(values);
|
||||
|
||||
// Try the following:
|
||||
// node limit-long-syntax.js -f FILE --log=LOG
|
||||
// node limit-long-syntax.js --file FILE
|
43
app/node_modules/@pkgjs/parseargs/examples/negate.js
generated
vendored
@ -1,43 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
// This example is used in the documentation.
|
||||
|
||||
// How might I add my own support for --no-foo?
|
||||
|
||||
// 1. const { parseArgs } = require('node:util'); // from node
|
||||
// 2. const { parseArgs } = require('@pkgjs/parseargs'); // from package
|
||||
const { parseArgs } = require('..'); // in repo
|
||||
|
||||
const options = {
|
||||
'color': { type: 'boolean' },
|
||||
'no-color': { type: 'boolean' },
|
||||
'logfile': { type: 'string' },
|
||||
'no-logfile': { type: 'boolean' },
|
||||
};
|
||||
const { values, tokens } = parseArgs({ options, tokens: true });
|
||||
|
||||
// Reprocess the option tokens and overwrite the returned values.
|
||||
tokens
|
||||
.filter((token) => token.kind === 'option')
|
||||
.forEach((token) => {
|
||||
if (token.name.startsWith('no-')) {
|
||||
// Store foo:false for --no-foo
|
||||
const positiveName = token.name.slice(3);
|
||||
values[positiveName] = false;
|
||||
delete values[token.name];
|
||||
} else {
|
||||
// Resave value so last one wins if both --foo and --no-foo.
|
||||
values[token.name] = token.value ?? true;
|
||||
}
|
||||
});
|
||||
|
||||
const color = values.color;
|
||||
const logfile = values.logfile ?? 'default.log';
|
||||
|
||||
console.log({ logfile, color });
|
||||
|
||||
// Try the following:
|
||||
// node negate.js
|
||||
// node negate.js --no-logfile --no-color
|
||||
// negate.js --logfile=test.log --color
|
||||
// node negate.js --no-logfile --logfile=test.log --color --no-color
|
31
app/node_modules/@pkgjs/parseargs/examples/no-repeated-options.js
generated
vendored
@ -1,31 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
// This is an example of using tokens to add a custom behaviour.
|
||||
//
|
||||
// Throw an error if an option is used more than once.
|
||||
|
||||
// 1. const { parseArgs } = require('node:util'); // from node
|
||||
// 2. const { parseArgs } = require('@pkgjs/parseargs'); // from package
|
||||
const { parseArgs } = require('..'); // in repo
|
||||
|
||||
const options = {
|
||||
ding: { type: 'boolean', short: 'd' },
|
||||
beep: { type: 'boolean', short: 'b' }
|
||||
};
|
||||
const { values, tokens } = parseArgs({ options, tokens: true });
|
||||
|
||||
const seenBefore = new Set();
|
||||
tokens.forEach((token) => {
|
||||
if (token.kind !== 'option') return;
|
||||
if (seenBefore.has(token.name)) {
|
||||
throw new Error(`option '${token.name}' used multiple times`);
|
||||
}
|
||||
seenBefore.add(token.name);
|
||||
});
|
||||
|
||||
console.log(values);
|
||||
|
||||
// Try the following:
|
||||
// node no-repeated-options --ding --beep
|
||||
// node no-repeated-options --beep -b
|
||||
// node no-repeated-options -ddd
|
41
app/node_modules/@pkgjs/parseargs/examples/ordered-options.mjs
generated
vendored
@ -1,41 +0,0 @@
|
||||
// This is an example of using tokens to add a custom behaviour.
|
||||
//
|
||||
// This adds a option order check so that --some-unstable-option
|
||||
// may only be used after --enable-experimental-options
|
||||
//
|
||||
// Note: this is not a common behaviour, the order of different options
|
||||
// does not usually matter.
|
||||
|
||||
import { parseArgs } from '../index.js';
|
||||
|
||||
function findTokenIndex(tokens, target) {
|
||||
return tokens.findIndex((token) => token.kind === 'option' &&
|
||||
token.name === target
|
||||
);
|
||||
}
|
||||
|
||||
const experimentalName = 'enable-experimental-options';
|
||||
const unstableName = 'some-unstable-option';
|
||||
|
||||
const options = {
|
||||
[experimentalName]: { type: 'boolean' },
|
||||
[unstableName]: { type: 'boolean' },
|
||||
};
|
||||
|
||||
const { values, tokens } = parseArgs({ options, tokens: true });
|
||||
|
||||
const experimentalIndex = findTokenIndex(tokens, experimentalName);
|
||||
const unstableIndex = findTokenIndex(tokens, unstableName);
|
||||
if (unstableIndex !== -1 &&
|
||||
((experimentalIndex === -1) || (unstableIndex < experimentalIndex))) {
|
||||
throw new Error(`'--${experimentalName}' must be specified before '--${unstableName}'`);
|
||||
}
|
||||
|
||||
console.log(values);
|
||||
|
||||
/* eslint-disable max-len */
|
||||
// Try the following:
|
||||
// node ordered-options.mjs
|
||||
// node ordered-options.mjs --some-unstable-option
|
||||
// node ordered-options.mjs --some-unstable-option --enable-experimental-options
|
||||
// node ordered-options.mjs --enable-experimental-options --some-unstable-option
|
26
app/node_modules/@pkgjs/parseargs/examples/simple-hard-coded.js
generated
vendored
@ -1,26 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
// This example is used in the documentation.
|
||||
|
||||
// 1. const { parseArgs } = require('node:util'); // from node
|
||||
// 2. const { parseArgs } = require('@pkgjs/parseargs'); // from package
|
||||
const { parseArgs } = require('..'); // in repo
|
||||
|
||||
const args = ['-f', '--bar', 'b'];
|
||||
const options = {
|
||||
foo: {
|
||||
type: 'boolean',
|
||||
short: 'f'
|
||||
},
|
||||
bar: {
|
||||
type: 'string'
|
||||
}
|
||||
};
|
||||
const {
|
||||
values,
|
||||
positionals
|
||||
} = parseArgs({ args, options });
|
||||
console.log(values, positionals);
|
||||
|
||||
// Try the following:
|
||||
// node simple-hard-coded.js
|
396
app/node_modules/@pkgjs/parseargs/index.js
generated
vendored
@ -1,396 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
ArrayPrototypeForEach,
|
||||
ArrayPrototypeIncludes,
|
||||
ArrayPrototypeMap,
|
||||
ArrayPrototypePush,
|
||||
ArrayPrototypePushApply,
|
||||
ArrayPrototypeShift,
|
||||
ArrayPrototypeSlice,
|
||||
ArrayPrototypeUnshiftApply,
|
||||
ObjectEntries,
|
||||
ObjectPrototypeHasOwnProperty: ObjectHasOwn,
|
||||
StringPrototypeCharAt,
|
||||
StringPrototypeIndexOf,
|
||||
StringPrototypeSlice,
|
||||
StringPrototypeStartsWith,
|
||||
} = require('./internal/primordials');
|
||||
|
||||
const {
|
||||
validateArray,
|
||||
validateBoolean,
|
||||
validateBooleanArray,
|
||||
validateObject,
|
||||
validateString,
|
||||
validateStringArray,
|
||||
validateUnion,
|
||||
} = require('./internal/validators');
|
||||
|
||||
const {
|
||||
kEmptyObject,
|
||||
} = require('./internal/util');
|
||||
|
||||
const {
|
||||
findLongOptionForShort,
|
||||
isLoneLongOption,
|
||||
isLoneShortOption,
|
||||
isLongOptionAndValue,
|
||||
isOptionValue,
|
||||
isOptionLikeValue,
|
||||
isShortOptionAndValue,
|
||||
isShortOptionGroup,
|
||||
useDefaultValueOption,
|
||||
objectGetOwn,
|
||||
optionsGetOwn,
|
||||
} = require('./utils');
|
||||
|
||||
const {
|
||||
codes: {
|
||||
ERR_INVALID_ARG_VALUE,
|
||||
ERR_PARSE_ARGS_INVALID_OPTION_VALUE,
|
||||
ERR_PARSE_ARGS_UNKNOWN_OPTION,
|
||||
ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL,
|
||||
},
|
||||
} = require('./internal/errors');
|
||||
|
||||
function getMainArgs() {
|
||||
// Work out where to slice process.argv for user supplied arguments.
|
||||
|
||||
// Check node options for scenarios where user CLI args follow executable.
|
||||
const execArgv = process.execArgv;
|
||||
if (ArrayPrototypeIncludes(execArgv, '-e') ||
|
||||
ArrayPrototypeIncludes(execArgv, '--eval') ||
|
||||
ArrayPrototypeIncludes(execArgv, '-p') ||
|
||||
ArrayPrototypeIncludes(execArgv, '--print')) {
|
||||
return ArrayPrototypeSlice(process.argv, 1);
|
||||
}
|
||||
|
||||
// Normally first two arguments are executable and script, then CLI arguments
|
||||
return ArrayPrototypeSlice(process.argv, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* In strict mode, throw for possible usage errors like --foo --bar
|
||||
*
|
||||
* @param {object} token - from tokens as available from parseArgs
|
||||
*/
|
||||
function checkOptionLikeValue(token) {
|
||||
if (!token.inlineValue && isOptionLikeValue(token.value)) {
|
||||
// Only show short example if user used short option.
|
||||
const example = StringPrototypeStartsWith(token.rawName, '--') ?
|
||||
`'${token.rawName}=-XYZ'` :
|
||||
`'--${token.name}=-XYZ' or '${token.rawName}-XYZ'`;
|
||||
const errorMessage = `Option '${token.rawName}' argument is ambiguous.
|
||||
Did you forget to specify the option argument for '${token.rawName}'?
|
||||
To specify an option argument starting with a dash use ${example}.`;
|
||||
throw new ERR_PARSE_ARGS_INVALID_OPTION_VALUE(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* In strict mode, throw for usage errors.
|
||||
*
|
||||
* @param {object} config - from config passed to parseArgs
|
||||
* @param {object} token - from tokens as available from parseArgs
|
||||
*/
|
||||
function checkOptionUsage(config, token) {
|
||||
if (!ObjectHasOwn(config.options, token.name)) {
|
||||
throw new ERR_PARSE_ARGS_UNKNOWN_OPTION(
|
||||
token.rawName, config.allowPositionals);
|
||||
}
|
||||
|
||||
const short = optionsGetOwn(config.options, token.name, 'short');
|
||||
const shortAndLong = `${short ? `-${short}, ` : ''}--${token.name}`;
|
||||
const type = optionsGetOwn(config.options, token.name, 'type');
|
||||
if (type === 'string' && typeof token.value !== 'string') {
|
||||
throw new ERR_PARSE_ARGS_INVALID_OPTION_VALUE(`Option '${shortAndLong} <value>' argument missing`);
|
||||
}
|
||||
// (Idiomatic test for undefined||null, expecting undefined.)
|
||||
if (type === 'boolean' && token.value != null) {
|
||||
throw new ERR_PARSE_ARGS_INVALID_OPTION_VALUE(`Option '${shortAndLong}' does not take an argument`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Store the option value in `values`.
|
||||
*
|
||||
* @param {string} longOption - long option name e.g. 'foo'
|
||||
* @param {string|undefined} optionValue - value from user args
|
||||
* @param {object} options - option configs, from parseArgs({ options })
|
||||
* @param {object} values - option values returned in `values` by parseArgs
|
||||
*/
|
||||
function storeOption(longOption, optionValue, options, values) {
|
||||
if (longOption === '__proto__') {
|
||||
return; // No. Just no.
|
||||
}
|
||||
|
||||
// We store based on the option value rather than option type,
|
||||
// preserving the users intent for author to deal with.
|
||||
const newValue = optionValue ?? true;
|
||||
if (optionsGetOwn(options, longOption, 'multiple')) {
|
||||
// Always store value in array, including for boolean.
|
||||
// values[longOption] starts out not present,
|
||||
// first value is added as new array [newValue],
|
||||
// subsequent values are pushed to existing array.
|
||||
// (note: values has null prototype, so simpler usage)
|
||||
if (values[longOption]) {
|
||||
ArrayPrototypePush(values[longOption], newValue);
|
||||
} else {
|
||||
values[longOption] = [newValue];
|
||||
}
|
||||
} else {
|
||||
values[longOption] = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the default option value in `values`.
|
||||
*
|
||||
* @param {string} longOption - long option name e.g. 'foo'
|
||||
* @param {string
|
||||
* | boolean
|
||||
* | string[]
|
||||
* | boolean[]} optionValue - default value from option config
|
||||
* @param {object} values - option values returned in `values` by parseArgs
|
||||
*/
|
||||
function storeDefaultOption(longOption, optionValue, values) {
|
||||
if (longOption === '__proto__') {
|
||||
return; // No. Just no.
|
||||
}
|
||||
|
||||
values[longOption] = optionValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process args and turn into identified tokens:
|
||||
* - option (along with value, if any)
|
||||
* - positional
|
||||
* - option-terminator
|
||||
*
|
||||
* @param {string[]} args - from parseArgs({ args }) or mainArgs
|
||||
* @param {object} options - option configs, from parseArgs({ options })
|
||||
*/
|
||||
function argsToTokens(args, options) {
|
||||
const tokens = [];
|
||||
let index = -1;
|
||||
let groupCount = 0;
|
||||
|
||||
const remainingArgs = ArrayPrototypeSlice(args);
|
||||
while (remainingArgs.length > 0) {
|
||||
const arg = ArrayPrototypeShift(remainingArgs);
|
||||
const nextArg = remainingArgs[0];
|
||||
if (groupCount > 0)
|
||||
groupCount--;
|
||||
else
|
||||
index++;
|
||||
|
||||
// Check if `arg` is an options terminator.
|
||||
// Guideline 10 in https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html
|
||||
if (arg === '--') {
|
||||
// Everything after a bare '--' is considered a positional argument.
|
||||
ArrayPrototypePush(tokens, { kind: 'option-terminator', index });
|
||||
ArrayPrototypePushApply(
|
||||
tokens, ArrayPrototypeMap(remainingArgs, (arg) => {
|
||||
return { kind: 'positional', index: ++index, value: arg };
|
||||
})
|
||||
);
|
||||
break; // Finished processing args, leave while loop.
|
||||
}
|
||||
|
||||
if (isLoneShortOption(arg)) {
|
||||
// e.g. '-f'
|
||||
const shortOption = StringPrototypeCharAt(arg, 1);
|
||||
const longOption = findLongOptionForShort(shortOption, options);
|
||||
let value;
|
||||
let inlineValue;
|
||||
if (optionsGetOwn(options, longOption, 'type') === 'string' &&
|
||||
isOptionValue(nextArg)) {
|
||||
// e.g. '-f', 'bar'
|
||||
value = ArrayPrototypeShift(remainingArgs);
|
||||
inlineValue = false;
|
||||
}
|
||||
ArrayPrototypePush(
|
||||
tokens,
|
||||
{ kind: 'option', name: longOption, rawName: arg,
|
||||
index, value, inlineValue });
|
||||
if (value != null) ++index;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isShortOptionGroup(arg, options)) {
|
||||
// Expand -fXzy to -f -X -z -y
|
||||
const expanded = [];
|
||||
for (let index = 1; index < arg.length; index++) {
|
||||
const shortOption = StringPrototypeCharAt(arg, index);
|
||||
const longOption = findLongOptionForShort(shortOption, options);
|
||||
if (optionsGetOwn(options, longOption, 'type') !== 'string' ||
|
||||
index === arg.length - 1) {
|
||||
// Boolean option, or last short in group. Well formed.
|
||||
ArrayPrototypePush(expanded, `-${shortOption}`);
|
||||
} else {
|
||||
// String option in middle. Yuck.
|
||||
// Expand -abfFILE to -a -b -fFILE
|
||||
ArrayPrototypePush(expanded, `-${StringPrototypeSlice(arg, index)}`);
|
||||
break; // finished short group
|
||||
}
|
||||
}
|
||||
ArrayPrototypeUnshiftApply(remainingArgs, expanded);
|
||||
groupCount = expanded.length;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isShortOptionAndValue(arg, options)) {
|
||||
// e.g. -fFILE
|
||||
const shortOption = StringPrototypeCharAt(arg, 1);
|
||||
const longOption = findLongOptionForShort(shortOption, options);
|
||||
const value = StringPrototypeSlice(arg, 2);
|
||||
ArrayPrototypePush(
|
||||
tokens,
|
||||
{ kind: 'option', name: longOption, rawName: `-${shortOption}`,
|
||||
index, value, inlineValue: true });
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isLoneLongOption(arg)) {
|
||||
// e.g. '--foo'
|
||||
const longOption = StringPrototypeSlice(arg, 2);
|
||||
let value;
|
||||
let inlineValue;
|
||||
if (optionsGetOwn(options, longOption, 'type') === 'string' &&
|
||||
isOptionValue(nextArg)) {
|
||||
// e.g. '--foo', 'bar'
|
||||
value = ArrayPrototypeShift(remainingArgs);
|
||||
inlineValue = false;
|
||||
}
|
||||
ArrayPrototypePush(
|
||||
tokens,
|
||||
{ kind: 'option', name: longOption, rawName: arg,
|
||||
index, value, inlineValue });
|
||||
if (value != null) ++index;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isLongOptionAndValue(arg)) {
|
||||
// e.g. --foo=bar
|
||||
const equalIndex = StringPrototypeIndexOf(arg, '=');
|
||||
const longOption = StringPrototypeSlice(arg, 2, equalIndex);
|
||||
const value = StringPrototypeSlice(arg, equalIndex + 1);
|
||||
ArrayPrototypePush(
|
||||
tokens,
|
||||
{ kind: 'option', name: longOption, rawName: `--${longOption}`,
|
||||
index, value, inlineValue: true });
|
||||
continue;
|
||||
}
|
||||
|
||||
ArrayPrototypePush(tokens, { kind: 'positional', index, value: arg });
|
||||
}
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
const parseArgs = (config = kEmptyObject) => {
|
||||
const args = objectGetOwn(config, 'args') ?? getMainArgs();
|
||||
const strict = objectGetOwn(config, 'strict') ?? true;
|
||||
const allowPositionals = objectGetOwn(config, 'allowPositionals') ?? !strict;
|
||||
const returnTokens = objectGetOwn(config, 'tokens') ?? false;
|
||||
const options = objectGetOwn(config, 'options') ?? { __proto__: null };
|
||||
// Bundle these up for passing to strict-mode checks.
|
||||
const parseConfig = { args, strict, options, allowPositionals };
|
||||
|
||||
// Validate input configuration.
|
||||
validateArray(args, 'args');
|
||||
validateBoolean(strict, 'strict');
|
||||
validateBoolean(allowPositionals, 'allowPositionals');
|
||||
validateBoolean(returnTokens, 'tokens');
|
||||
validateObject(options, 'options');
|
||||
ArrayPrototypeForEach(
|
||||
ObjectEntries(options),
|
||||
({ 0: longOption, 1: optionConfig }) => {
|
||||
validateObject(optionConfig, `options.${longOption}`);
|
||||
|
||||
// type is required
|
||||
const optionType = objectGetOwn(optionConfig, 'type');
|
||||
validateUnion(optionType, `options.${longOption}.type`, ['string', 'boolean']);
|
||||
|
||||
if (ObjectHasOwn(optionConfig, 'short')) {
|
||||
const shortOption = optionConfig.short;
|
||||
validateString(shortOption, `options.${longOption}.short`);
|
||||
if (shortOption.length !== 1) {
|
||||
throw new ERR_INVALID_ARG_VALUE(
|
||||
`options.${longOption}.short`,
|
||||
shortOption,
|
||||
'must be a single character'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const multipleOption = objectGetOwn(optionConfig, 'multiple');
|
||||
if (ObjectHasOwn(optionConfig, 'multiple')) {
|
||||
validateBoolean(multipleOption, `options.${longOption}.multiple`);
|
||||
}
|
||||
|
||||
const defaultValue = objectGetOwn(optionConfig, 'default');
|
||||
if (defaultValue !== undefined) {
|
||||
let validator;
|
||||
switch (optionType) {
|
||||
case 'string':
|
||||
validator = multipleOption ? validateStringArray : validateString;
|
||||
break;
|
||||
|
||||
case 'boolean':
|
||||
validator = multipleOption ? validateBooleanArray : validateBoolean;
|
||||
break;
|
||||
}
|
||||
validator(defaultValue, `options.${longOption}.default`);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Phase 1: identify tokens
|
||||
const tokens = argsToTokens(args, options);
|
||||
|
||||
// Phase 2: process tokens into parsed option values and positionals
|
||||
const result = {
|
||||
values: { __proto__: null },
|
||||
positionals: [],
|
||||
};
|
||||
if (returnTokens) {
|
||||
result.tokens = tokens;
|
||||
}
|
||||
ArrayPrototypeForEach(tokens, (token) => {
|
||||
if (token.kind === 'option') {
|
||||
if (strict) {
|
||||
checkOptionUsage(parseConfig, token);
|
||||
checkOptionLikeValue(token);
|
||||
}
|
||||
storeOption(token.name, token.value, options, result.values);
|
||||
} else if (token.kind === 'positional') {
|
||||
if (!allowPositionals) {
|
||||
throw new ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL(token.value);
|
||||
}
|
||||
ArrayPrototypePush(result.positionals, token.value);
|
||||
}
|
||||
});
|
||||
|
||||
// Phase 3: fill in default values for missing args
|
||||
ArrayPrototypeForEach(ObjectEntries(options), ({ 0: longOption,
|
||||
1: optionConfig }) => {
|
||||
const mustSetDefault = useDefaultValueOption(longOption,
|
||||
optionConfig,
|
||||
result.values);
|
||||
if (mustSetDefault) {
|
||||
storeDefaultOption(longOption,
|
||||
objectGetOwn(optionConfig, 'default'),
|
||||
result.values);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
parseArgs,
|
||||
};
|
47
app/node_modules/@pkgjs/parseargs/internal/errors.js
generated
vendored
@ -1,47 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
class ERR_INVALID_ARG_TYPE extends TypeError {
|
||||
constructor(name, expected, actual) {
|
||||
super(`${name} must be ${expected} got ${actual}`);
|
||||
this.code = 'ERR_INVALID_ARG_TYPE';
|
||||
}
|
||||
}
|
||||
|
||||
class ERR_INVALID_ARG_VALUE extends TypeError {
|
||||
constructor(arg1, arg2, expected) {
|
||||
super(`The property ${arg1} ${expected}. Received '${arg2}'`);
|
||||
this.code = 'ERR_INVALID_ARG_VALUE';
|
||||
}
|
||||
}
|
||||
|
||||
class ERR_PARSE_ARGS_INVALID_OPTION_VALUE extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
this.code = 'ERR_PARSE_ARGS_INVALID_OPTION_VALUE';
|
||||
}
|
||||
}
|
||||
|
||||
class ERR_PARSE_ARGS_UNKNOWN_OPTION extends Error {
|
||||
constructor(option, allowPositionals) {
|
||||
const suggestDashDash = allowPositionals ? `. To specify a positional argument starting with a '-', place it at the end of the command after '--', as in '-- ${JSON.stringify(option)}` : '';
|
||||
super(`Unknown option '${option}'${suggestDashDash}`);
|
||||
this.code = 'ERR_PARSE_ARGS_UNKNOWN_OPTION';
|
||||
}
|
||||
}
|
||||
|
||||
class ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL extends Error {
|
||||
constructor(positional) {
|
||||
super(`Unexpected argument '${positional}'. This command does not take positional arguments`);
|
||||
this.code = 'ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL';
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
codes: {
|
||||
ERR_INVALID_ARG_TYPE,
|
||||
ERR_INVALID_ARG_VALUE,
|
||||
ERR_PARSE_ARGS_INVALID_OPTION_VALUE,
|
||||
ERR_PARSE_ARGS_UNKNOWN_OPTION,
|
||||
ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL,
|
||||
}
|
||||
};
|
393
app/node_modules/@pkgjs/parseargs/internal/primordials.js
generated
vendored
@ -1,393 +0,0 @@
|
||||
/*
|
||||
This file is copied from https://github.com/nodejs/node/blob/v14.19.3/lib/internal/per_context/primordials.js
|
||||
under the following license:
|
||||
|
||||
Copyright Node.js contributors. All rights reserved.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/* eslint-disable node-core/prefer-primordials */
|
||||
|
||||
// This file subclasses and stores the JS builtins that come from the VM
|
||||
// so that Node.js's builtin modules do not need to later look these up from
|
||||
// the global proxy, which can be mutated by users.
|
||||
|
||||
// Use of primordials have sometimes a dramatic impact on performance, please
|
||||
// benchmark all changes made in performance-sensitive areas of the codebase.
|
||||
// See: https://github.com/nodejs/node/pull/38248
|
||||
|
||||
const primordials = {};
|
||||
|
||||
const {
|
||||
defineProperty: ReflectDefineProperty,
|
||||
getOwnPropertyDescriptor: ReflectGetOwnPropertyDescriptor,
|
||||
ownKeys: ReflectOwnKeys,
|
||||
} = Reflect;
|
||||
|
||||
// `uncurryThis` is equivalent to `func => Function.prototype.call.bind(func)`.
|
||||
// It is using `bind.bind(call)` to avoid using `Function.prototype.bind`
|
||||
// and `Function.prototype.call` after it may have been mutated by users.
|
||||
const { apply, bind, call } = Function.prototype;
|
||||
const uncurryThis = bind.bind(call);
|
||||
primordials.uncurryThis = uncurryThis;
|
||||
|
||||
// `applyBind` is equivalent to `func => Function.prototype.apply.bind(func)`.
|
||||
// It is using `bind.bind(apply)` to avoid using `Function.prototype.bind`
|
||||
// and `Function.prototype.apply` after it may have been mutated by users.
|
||||
const applyBind = bind.bind(apply);
|
||||
primordials.applyBind = applyBind;
|
||||
|
||||
// Methods that accept a variable number of arguments, and thus it's useful to
|
||||
// also create `${prefix}${key}Apply`, which uses `Function.prototype.apply`,
|
||||
// instead of `Function.prototype.call`, and thus doesn't require iterator
|
||||
// destructuring.
|
||||
const varargsMethods = [
|
||||
// 'ArrayPrototypeConcat' is omitted, because it performs the spread
|
||||
// on its own for arrays and array-likes with a truthy
|
||||
// @@isConcatSpreadable symbol property.
|
||||
'ArrayOf',
|
||||
'ArrayPrototypePush',
|
||||
'ArrayPrototypeUnshift',
|
||||
// 'FunctionPrototypeCall' is omitted, since there's 'ReflectApply'
|
||||
// and 'FunctionPrototypeApply'.
|
||||
'MathHypot',
|
||||
'MathMax',
|
||||
'MathMin',
|
||||
'StringPrototypeConcat',
|
||||
'TypedArrayOf',
|
||||
];
|
||||
|
||||
function getNewKey(key) {
|
||||
return typeof key === 'symbol' ?
|
||||
`Symbol${key.description[7].toUpperCase()}${key.description.slice(8)}` :
|
||||
`${key[0].toUpperCase()}${key.slice(1)}`;
|
||||
}
|
||||
|
||||
function copyAccessor(dest, prefix, key, { enumerable, get, set }) {
|
||||
ReflectDefineProperty(dest, `${prefix}Get${key}`, {
|
||||
value: uncurryThis(get),
|
||||
enumerable
|
||||
});
|
||||
if (set !== undefined) {
|
||||
ReflectDefineProperty(dest, `${prefix}Set${key}`, {
|
||||
value: uncurryThis(set),
|
||||
enumerable
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function copyPropsRenamed(src, dest, prefix) {
|
||||
for (const key of ReflectOwnKeys(src)) {
|
||||
const newKey = getNewKey(key);
|
||||
const desc = ReflectGetOwnPropertyDescriptor(src, key);
|
||||
if ('get' in desc) {
|
||||
copyAccessor(dest, prefix, newKey, desc);
|
||||
} else {
|
||||
const name = `${prefix}${newKey}`;
|
||||
ReflectDefineProperty(dest, name, desc);
|
||||
if (varargsMethods.includes(name)) {
|
||||
ReflectDefineProperty(dest, `${name}Apply`, {
|
||||
// `src` is bound as the `this` so that the static `this` points
|
||||
// to the object it was defined on,
|
||||
// e.g.: `ArrayOfApply` gets a `this` of `Array`:
|
||||
value: applyBind(desc.value, src),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function copyPropsRenamedBound(src, dest, prefix) {
|
||||
for (const key of ReflectOwnKeys(src)) {
|
||||
const newKey = getNewKey(key);
|
||||
const desc = ReflectGetOwnPropertyDescriptor(src, key);
|
||||
if ('get' in desc) {
|
||||
copyAccessor(dest, prefix, newKey, desc);
|
||||
} else {
|
||||
const { value } = desc;
|
||||
if (typeof value === 'function') {
|
||||
desc.value = value.bind(src);
|
||||
}
|
||||
|
||||
const name = `${prefix}${newKey}`;
|
||||
ReflectDefineProperty(dest, name, desc);
|
||||
if (varargsMethods.includes(name)) {
|
||||
ReflectDefineProperty(dest, `${name}Apply`, {
|
||||
value: applyBind(value, src),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function copyPrototype(src, dest, prefix) {
|
||||
for (const key of ReflectOwnKeys(src)) {
|
||||
const newKey = getNewKey(key);
|
||||
const desc = ReflectGetOwnPropertyDescriptor(src, key);
|
||||
if ('get' in desc) {
|
||||
copyAccessor(dest, prefix, newKey, desc);
|
||||
} else {
|
||||
const { value } = desc;
|
||||
if (typeof value === 'function') {
|
||||
desc.value = uncurryThis(value);
|
||||
}
|
||||
|
||||
const name = `${prefix}${newKey}`;
|
||||
ReflectDefineProperty(dest, name, desc);
|
||||
if (varargsMethods.includes(name)) {
|
||||
ReflectDefineProperty(dest, `${name}Apply`, {
|
||||
value: applyBind(value),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create copies of configurable value properties of the global object
|
||||
[
|
||||
'Proxy',
|
||||
'globalThis',
|
||||
].forEach((name) => {
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
primordials[name] = globalThis[name];
|
||||
});
|
||||
|
||||
// Create copies of URI handling functions
|
||||
[
|
||||
decodeURI,
|
||||
decodeURIComponent,
|
||||
encodeURI,
|
||||
encodeURIComponent,
|
||||
].forEach((fn) => {
|
||||
primordials[fn.name] = fn;
|
||||
});
|
||||
|
||||
// Create copies of the namespace objects
|
||||
[
|
||||
'JSON',
|
||||
'Math',
|
||||
'Proxy',
|
||||
'Reflect',
|
||||
].forEach((name) => {
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
copyPropsRenamed(global[name], primordials, name);
|
||||
});
|
||||
|
||||
// Create copies of intrinsic objects
|
||||
[
|
||||
'Array',
|
||||
'ArrayBuffer',
|
||||
'BigInt',
|
||||
'BigInt64Array',
|
||||
'BigUint64Array',
|
||||
'Boolean',
|
||||
'DataView',
|
||||
'Date',
|
||||
'Error',
|
||||
'EvalError',
|
||||
'Float32Array',
|
||||
'Float64Array',
|
||||
'Function',
|
||||
'Int16Array',
|
||||
'Int32Array',
|
||||
'Int8Array',
|
||||
'Map',
|
||||
'Number',
|
||||
'Object',
|
||||
'RangeError',
|
||||
'ReferenceError',
|
||||
'RegExp',
|
||||
'Set',
|
||||
'String',
|
||||
'Symbol',
|
||||
'SyntaxError',
|
||||
'TypeError',
|
||||
'URIError',
|
||||
'Uint16Array',
|
||||
'Uint32Array',
|
||||
'Uint8Array',
|
||||
'Uint8ClampedArray',
|
||||
'WeakMap',
|
||||
'WeakSet',
|
||||
].forEach((name) => {
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
const original = global[name];
|
||||
primordials[name] = original;
|
||||
copyPropsRenamed(original, primordials, name);
|
||||
copyPrototype(original.prototype, primordials, `${name}Prototype`);
|
||||
});
|
||||
|
||||
// Create copies of intrinsic objects that require a valid `this` to call
|
||||
// static methods.
|
||||
// Refs: https://www.ecma-international.org/ecma-262/#sec-promise.all
|
||||
[
|
||||
'Promise',
|
||||
].forEach((name) => {
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
const original = global[name];
|
||||
primordials[name] = original;
|
||||
copyPropsRenamedBound(original, primordials, name);
|
||||
copyPrototype(original.prototype, primordials, `${name}Prototype`);
|
||||
});
|
||||
|
||||
// Create copies of abstract intrinsic objects that are not directly exposed
|
||||
// on the global object.
|
||||
// Refs: https://tc39.es/ecma262/#sec-%typedarray%-intrinsic-object
|
||||
[
|
||||
{ name: 'TypedArray', original: Reflect.getPrototypeOf(Uint8Array) },
|
||||
{ name: 'ArrayIterator', original: {
|
||||
prototype: Reflect.getPrototypeOf(Array.prototype[Symbol.iterator]()),
|
||||
} },
|
||||
{ name: 'StringIterator', original: {
|
||||
prototype: Reflect.getPrototypeOf(String.prototype[Symbol.iterator]()),
|
||||
} },
|
||||
].forEach(({ name, original }) => {
|
||||
primordials[name] = original;
|
||||
// The static %TypedArray% methods require a valid `this`, but can't be bound,
|
||||
// as they need a subclass constructor as the receiver:
|
||||
copyPrototype(original, primordials, name);
|
||||
copyPrototype(original.prototype, primordials, `${name}Prototype`);
|
||||
});
|
||||
|
||||
/* eslint-enable node-core/prefer-primordials */
|
||||
|
||||
const {
|
||||
ArrayPrototypeForEach,
|
||||
FunctionPrototypeCall,
|
||||
Map,
|
||||
ObjectFreeze,
|
||||
ObjectSetPrototypeOf,
|
||||
Set,
|
||||
SymbolIterator,
|
||||
WeakMap,
|
||||
WeakSet,
|
||||
} = primordials;
|
||||
|
||||
// Because these functions are used by `makeSafe`, which is exposed
|
||||
// on the `primordials` object, it's important to use const references
|
||||
// to the primordials that they use:
|
||||
const createSafeIterator = (factory, next) => {
|
||||
class SafeIterator {
|
||||
constructor(iterable) {
|
||||
this._iterator = factory(iterable);
|
||||
}
|
||||
next() {
|
||||
return next(this._iterator);
|
||||
}
|
||||
[SymbolIterator]() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
ObjectSetPrototypeOf(SafeIterator.prototype, null);
|
||||
ObjectFreeze(SafeIterator.prototype);
|
||||
ObjectFreeze(SafeIterator);
|
||||
return SafeIterator;
|
||||
};
|
||||
|
||||
primordials.SafeArrayIterator = createSafeIterator(
|
||||
primordials.ArrayPrototypeSymbolIterator,
|
||||
primordials.ArrayIteratorPrototypeNext
|
||||
);
|
||||
primordials.SafeStringIterator = createSafeIterator(
|
||||
primordials.StringPrototypeSymbolIterator,
|
||||
primordials.StringIteratorPrototypeNext
|
||||
);
|
||||
|
||||
const copyProps = (src, dest) => {
|
||||
ArrayPrototypeForEach(ReflectOwnKeys(src), (key) => {
|
||||
if (!ReflectGetOwnPropertyDescriptor(dest, key)) {
|
||||
ReflectDefineProperty(
|
||||
dest,
|
||||
key,
|
||||
ReflectGetOwnPropertyDescriptor(src, key));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const makeSafe = (unsafe, safe) => {
|
||||
if (SymbolIterator in unsafe.prototype) {
|
||||
const dummy = new unsafe();
|
||||
let next; // We can reuse the same `next` method.
|
||||
|
||||
ArrayPrototypeForEach(ReflectOwnKeys(unsafe.prototype), (key) => {
|
||||
if (!ReflectGetOwnPropertyDescriptor(safe.prototype, key)) {
|
||||
const desc = ReflectGetOwnPropertyDescriptor(unsafe.prototype, key);
|
||||
if (
|
||||
typeof desc.value === 'function' &&
|
||||
desc.value.length === 0 &&
|
||||
SymbolIterator in (FunctionPrototypeCall(desc.value, dummy) ?? {})
|
||||
) {
|
||||
const createIterator = uncurryThis(desc.value);
|
||||
next = next ?? uncurryThis(createIterator(dummy).next);
|
||||
const SafeIterator = createSafeIterator(createIterator, next);
|
||||
desc.value = function() {
|
||||
return new SafeIterator(this);
|
||||
};
|
||||
}
|
||||
ReflectDefineProperty(safe.prototype, key, desc);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
copyProps(unsafe.prototype, safe.prototype);
|
||||
}
|
||||
copyProps(unsafe, safe);
|
||||
|
||||
ObjectSetPrototypeOf(safe.prototype, null);
|
||||
ObjectFreeze(safe.prototype);
|
||||
ObjectFreeze(safe);
|
||||
return safe;
|
||||
};
|
||||
primordials.makeSafe = makeSafe;
|
||||
|
||||
// Subclass the constructors because we need to use their prototype
|
||||
// methods later.
|
||||
// Defining the `constructor` is necessary here to avoid the default
|
||||
// constructor which uses the user-mutable `%ArrayIteratorPrototype%.next`.
|
||||
primordials.SafeMap = makeSafe(
|
||||
Map,
|
||||
class SafeMap extends Map {
|
||||
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
|
||||
}
|
||||
);
|
||||
primordials.SafeWeakMap = makeSafe(
|
||||
WeakMap,
|
||||
class SafeWeakMap extends WeakMap {
|
||||
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
|
||||
}
|
||||
);
|
||||
primordials.SafeSet = makeSafe(
|
||||
Set,
|
||||
class SafeSet extends Set {
|
||||
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
|
||||
}
|
||||
);
|
||||
primordials.SafeWeakSet = makeSafe(
|
||||
WeakSet,
|
||||
class SafeWeakSet extends WeakSet {
|
||||
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
|
||||
}
|
||||
);
|
||||
|
||||
ObjectSetPrototypeOf(primordials, null);
|
||||
ObjectFreeze(primordials);
|
||||
|
||||
module.exports = primordials;
|
14
app/node_modules/@pkgjs/parseargs/internal/util.js
generated
vendored
@ -1,14 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
// This is a placeholder for util.js in node.js land.
|
||||
|
||||
const {
|
||||
ObjectCreate,
|
||||
ObjectFreeze,
|
||||
} = require('./primordials');
|
||||
|
||||
const kEmptyObject = ObjectFreeze(ObjectCreate(null));
|
||||
|
||||
module.exports = {
|
||||
kEmptyObject,
|
||||
};
|
89
app/node_modules/@pkgjs/parseargs/internal/validators.js
generated
vendored
@ -1,89 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
// This file is a proxy of the original file located at:
|
||||
// https://github.com/nodejs/node/blob/main/lib/internal/validators.js
|
||||
// Every addition or modification to this file must be evaluated
|
||||
// during the PR review.
|
||||
|
||||
const {
|
||||
ArrayIsArray,
|
||||
ArrayPrototypeIncludes,
|
||||
ArrayPrototypeJoin,
|
||||
} = require('./primordials');
|
||||
|
||||
const {
|
||||
codes: {
|
||||
ERR_INVALID_ARG_TYPE
|
||||
}
|
||||
} = require('./errors');
|
||||
|
||||
function validateString(value, name) {
|
||||
if (typeof value !== 'string') {
|
||||
throw new ERR_INVALID_ARG_TYPE(name, 'String', value);
|
||||
}
|
||||
}
|
||||
|
||||
function validateUnion(value, name, union) {
|
||||
if (!ArrayPrototypeIncludes(union, value)) {
|
||||
throw new ERR_INVALID_ARG_TYPE(name, `('${ArrayPrototypeJoin(union, '|')}')`, value);
|
||||
}
|
||||
}
|
||||
|
||||
function validateBoolean(value, name) {
|
||||
if (typeof value !== 'boolean') {
|
||||
throw new ERR_INVALID_ARG_TYPE(name, 'Boolean', value);
|
||||
}
|
||||
}
|
||||
|
||||
function validateArray(value, name) {
|
||||
if (!ArrayIsArray(value)) {
|
||||
throw new ERR_INVALID_ARG_TYPE(name, 'Array', value);
|
||||
}
|
||||
}
|
||||
|
||||
function validateStringArray(value, name) {
|
||||
validateArray(value, name);
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
validateString(value[i], `${name}[${i}]`);
|
||||
}
|
||||
}
|
||||
|
||||
function validateBooleanArray(value, name) {
|
||||
validateArray(value, name);
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
validateBoolean(value[i], `${name}[${i}]`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {unknown} value
|
||||
* @param {string} name
|
||||
* @param {{
|
||||
* allowArray?: boolean,
|
||||
* allowFunction?: boolean,
|
||||
* nullable?: boolean
|
||||
* }} [options]
|
||||
*/
|
||||
function validateObject(value, name, options) {
|
||||
const useDefaultOptions = options == null;
|
||||
const allowArray = useDefaultOptions ? false : options.allowArray;
|
||||
const allowFunction = useDefaultOptions ? false : options.allowFunction;
|
||||
const nullable = useDefaultOptions ? false : options.nullable;
|
||||
if ((!nullable && value === null) ||
|
||||
(!allowArray && ArrayIsArray(value)) ||
|
||||
(typeof value !== 'object' && (
|
||||
!allowFunction || typeof value !== 'function'
|
||||
))) {
|
||||
throw new ERR_INVALID_ARG_TYPE(name, 'Object', value);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
validateArray,
|
||||
validateObject,
|
||||
validateString,
|
||||
validateStringArray,
|
||||
validateUnion,
|
||||
validateBoolean,
|
||||
validateBooleanArray,
|
||||
};
|
62
app/node_modules/@pkgjs/parseargs/package.json
generated
vendored
@ -1,62 +0,0 @@
|
||||
{
|
||||
"_from": "@pkgjs/parseargs@^0.11.0",
|
||||
"_id": "@pkgjs/parseargs@0.11.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==",
|
||||
"_location": "/@pkgjs/parseargs",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@pkgjs/parseargs@^0.11.0",
|
||||
"name": "@pkgjs/parseargs",
|
||||
"escapedName": "@pkgjs%2fparseargs",
|
||||
"scope": "@pkgjs",
|
||||
"rawSpec": "^0.11.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.11.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/jackspeak"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
|
||||
"_shasum": "a77ea742fab25775145434eb1d2328cf5013ac33",
|
||||
"_spec": "@pkgjs/parseargs@^0.11.0",
|
||||
"_where": "/mnt/c/Users/docto/Downloads/Rappaurio/node_modules/jackspeak",
|
||||
"author": "",
|
||||
"bugs": {
|
||||
"url": "https://github.com/pkgjs/parseargs/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Polyfill of future proposal for `util.parseArgs()`",
|
||||
"devDependencies": {
|
||||
"c8": "^7.10.0",
|
||||
"eslint": "^8.2.0",
|
||||
"eslint-plugin-node-core": "github:iansu/eslint-plugin-node-core",
|
||||
"tape": "^5.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"homepage": "https://github.com/pkgjs/parseargs#readme",
|
||||
"keywords": [],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "@pkgjs/parseargs",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/pkgjs/parseargs.git"
|
||||
},
|
||||
"scripts": {
|
||||
"coverage": "c8 --check-coverage tape 'test/*.js'",
|
||||
"fix": "npm run posttest -- --fix",
|
||||
"posttest": "eslint .",
|
||||
"test": "c8 tape 'test/*.js'"
|
||||
},
|
||||
"version": "0.11.0"
|
||||
}
|
198
app/node_modules/@pkgjs/parseargs/utils.js
generated
vendored
@ -1,198 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
ArrayPrototypeFind,
|
||||
ObjectEntries,
|
||||
ObjectPrototypeHasOwnProperty: ObjectHasOwn,
|
||||
StringPrototypeCharAt,
|
||||
StringPrototypeIncludes,
|
||||
StringPrototypeStartsWith,
|
||||
} = require('./internal/primordials');
|
||||
|
||||
const {
|
||||
validateObject,
|
||||
} = require('./internal/validators');
|
||||
|
||||
// These are internal utilities to make the parsing logic easier to read, and
|
||||
// add lots of detail for the curious. They are in a separate file to allow
|
||||
// unit testing, although that is not essential (this could be rolled into
|
||||
// main file and just tested implicitly via API).
|
||||
//
|
||||
// These routines are for internal use, not for export to client.
|
||||
|
||||
/**
|
||||
* Return the named property, but only if it is an own property.
|
||||
*/
|
||||
function objectGetOwn(obj, prop) {
|
||||
if (ObjectHasOwn(obj, prop))
|
||||
return obj[prop];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the named options property, but only if it is an own property.
|
||||
*/
|
||||
function optionsGetOwn(options, longOption, prop) {
|
||||
if (ObjectHasOwn(options, longOption))
|
||||
return objectGetOwn(options[longOption], prop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the argument may be used as an option value.
|
||||
* @example
|
||||
* isOptionValue('V') // returns true
|
||||
* isOptionValue('-v') // returns true (greedy)
|
||||
* isOptionValue('--foo') // returns true (greedy)
|
||||
* isOptionValue(undefined) // returns false
|
||||
*/
|
||||
function isOptionValue(value) {
|
||||
if (value == null) return false;
|
||||
|
||||
// Open Group Utility Conventions are that an option-argument
|
||||
// is the argument after the option, and may start with a dash.
|
||||
return true; // greedy!
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect whether there is possible confusion and user may have omitted
|
||||
* the option argument, like `--port --verbose` when `port` of type:string.
|
||||
* In strict mode we throw errors if value is option-like.
|
||||
*/
|
||||
function isOptionLikeValue(value) {
|
||||
if (value == null) return false;
|
||||
|
||||
return value.length > 1 && StringPrototypeCharAt(value, 0) === '-';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if `arg` is just a short option.
|
||||
* @example '-f'
|
||||
*/
|
||||
function isLoneShortOption(arg) {
|
||||
return arg.length === 2 &&
|
||||
StringPrototypeCharAt(arg, 0) === '-' &&
|
||||
StringPrototypeCharAt(arg, 1) !== '-';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if `arg` is a lone long option.
|
||||
* @example
|
||||
* isLoneLongOption('a') // returns false
|
||||
* isLoneLongOption('-a') // returns false
|
||||
* isLoneLongOption('--foo') // returns true
|
||||
* isLoneLongOption('--foo=bar') // returns false
|
||||
*/
|
||||
function isLoneLongOption(arg) {
|
||||
return arg.length > 2 &&
|
||||
StringPrototypeStartsWith(arg, '--') &&
|
||||
!StringPrototypeIncludes(arg, '=', 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if `arg` is a long option and value in the same argument.
|
||||
* @example
|
||||
* isLongOptionAndValue('--foo') // returns false
|
||||
* isLongOptionAndValue('--foo=bar') // returns true
|
||||
*/
|
||||
function isLongOptionAndValue(arg) {
|
||||
return arg.length > 2 &&
|
||||
StringPrototypeStartsWith(arg, '--') &&
|
||||
StringPrototypeIncludes(arg, '=', 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if `arg` is a short option group.
|
||||
*
|
||||
* See Guideline 5 of the [Open Group Utility Conventions](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html).
|
||||
* One or more options without option-arguments, followed by at most one
|
||||
* option that takes an option-argument, should be accepted when grouped
|
||||
* behind one '-' delimiter.
|
||||
* @example
|
||||
* isShortOptionGroup('-a', {}) // returns false
|
||||
* isShortOptionGroup('-ab', {}) // returns true
|
||||
* // -fb is an option and a value, not a short option group
|
||||
* isShortOptionGroup('-fb', {
|
||||
* options: { f: { type: 'string' } }
|
||||
* }) // returns false
|
||||
* isShortOptionGroup('-bf', {
|
||||
* options: { f: { type: 'string' } }
|
||||
* }) // returns true
|
||||
* // -bfb is an edge case, return true and caller sorts it out
|
||||
* isShortOptionGroup('-bfb', {
|
||||
* options: { f: { type: 'string' } }
|
||||
* }) // returns true
|
||||
*/
|
||||
function isShortOptionGroup(arg, options) {
|
||||
if (arg.length <= 2) return false;
|
||||
if (StringPrototypeCharAt(arg, 0) !== '-') return false;
|
||||
if (StringPrototypeCharAt(arg, 1) === '-') return false;
|
||||
|
||||
const firstShort = StringPrototypeCharAt(arg, 1);
|
||||
const longOption = findLongOptionForShort(firstShort, options);
|
||||
return optionsGetOwn(options, longOption, 'type') !== 'string';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if arg is a short string option followed by its value.
|
||||
* @example
|
||||
* isShortOptionAndValue('-a', {}); // returns false
|
||||
* isShortOptionAndValue('-ab', {}); // returns false
|
||||
* isShortOptionAndValue('-fFILE', {
|
||||
* options: { foo: { short: 'f', type: 'string' }}
|
||||
* }) // returns true
|
||||
*/
|
||||
function isShortOptionAndValue(arg, options) {
|
||||
validateObject(options, 'options');
|
||||
|
||||
if (arg.length <= 2) return false;
|
||||
if (StringPrototypeCharAt(arg, 0) !== '-') return false;
|
||||
if (StringPrototypeCharAt(arg, 1) === '-') return false;
|
||||
|
||||
const shortOption = StringPrototypeCharAt(arg, 1);
|
||||
const longOption = findLongOptionForShort(shortOption, options);
|
||||
return optionsGetOwn(options, longOption, 'type') === 'string';
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the long option associated with a short option. Looks for a configured
|
||||
* `short` and returns the short option itself if a long option is not found.
|
||||
* @example
|
||||
* findLongOptionForShort('a', {}) // returns 'a'
|
||||
* findLongOptionForShort('b', {
|
||||
* options: { bar: { short: 'b' } }
|
||||
* }) // returns 'bar'
|
||||
*/
|
||||
function findLongOptionForShort(shortOption, options) {
|
||||
validateObject(options, 'options');
|
||||
const longOptionEntry = ArrayPrototypeFind(
|
||||
ObjectEntries(options),
|
||||
({ 1: optionConfig }) => objectGetOwn(optionConfig, 'short') === shortOption
|
||||
);
|
||||
return longOptionEntry?.[0] ?? shortOption;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given option includes a default value
|
||||
* and that option has not been set by the input args.
|
||||
*
|
||||
* @param {string} longOption - long option name e.g. 'foo'
|
||||
* @param {object} optionConfig - the option configuration properties
|
||||
* @param {object} values - option values returned in `values` by parseArgs
|
||||
*/
|
||||
function useDefaultValueOption(longOption, optionConfig, values) {
|
||||
return objectGetOwn(optionConfig, 'default') !== undefined &&
|
||||
values[longOption] === undefined;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
findLongOptionForShort,
|
||||
isLoneLongOption,
|
||||
isLoneShortOption,
|
||||
isLongOptionAndValue,
|
||||
isOptionValue,
|
||||
isOptionLikeValue,
|
||||
isShortOptionAndValue,
|
||||
isShortOptionGroup,
|
||||
useDefaultValueOption,
|
||||
objectGetOwn,
|
||||
optionsGetOwn,
|
||||
};
|
243
app/node_modules/accepts/HISTORY.md
generated
vendored
@ -1,243 +0,0 @@
|
||||
1.3.8 / 2022-02-02
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.34
|
||||
- deps: mime-db@~1.51.0
|
||||
* deps: negotiator@0.6.3
|
||||
|
||||
1.3.7 / 2019-04-29
|
||||
==================
|
||||
|
||||
* deps: negotiator@0.6.2
|
||||
- Fix sorting charset, encoding, and language with extra parameters
|
||||
|
||||
1.3.6 / 2019-04-28
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.24
|
||||
- deps: mime-db@~1.40.0
|
||||
|
||||
1.3.5 / 2018-02-28
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.18
|
||||
- deps: mime-db@~1.33.0
|
||||
|
||||
1.3.4 / 2017-08-22
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.16
|
||||
- deps: mime-db@~1.29.0
|
||||
|
||||
1.3.3 / 2016-05-02
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.11
|
||||
- deps: mime-db@~1.23.0
|
||||
* deps: negotiator@0.6.1
|
||||
- perf: improve `Accept` parsing speed
|
||||
- perf: improve `Accept-Charset` parsing speed
|
||||
- perf: improve `Accept-Encoding` parsing speed
|
||||
- perf: improve `Accept-Language` parsing speed
|
||||
|
||||
1.3.2 / 2016-03-08
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.10
|
||||
- Fix extension of `application/dash+xml`
|
||||
- Update primary extension for `audio/mp4`
|
||||
- deps: mime-db@~1.22.0
|
||||
|
||||
1.3.1 / 2016-01-19
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.9
|
||||
- deps: mime-db@~1.21.0
|
||||
|
||||
1.3.0 / 2015-09-29
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.7
|
||||
- deps: mime-db@~1.19.0
|
||||
* deps: negotiator@0.6.0
|
||||
- Fix including type extensions in parameters in `Accept` parsing
|
||||
- Fix parsing `Accept` parameters with quoted equals
|
||||
- Fix parsing `Accept` parameters with quoted semicolons
|
||||
- Lazy-load modules from main entry point
|
||||
- perf: delay type concatenation until needed
|
||||
- perf: enable strict mode
|
||||
- perf: hoist regular expressions
|
||||
- perf: remove closures getting spec properties
|
||||
- perf: remove a closure from media type parsing
|
||||
- perf: remove property delete from media type parsing
|
||||
|
||||
1.2.13 / 2015-09-06
|
||||
===================
|
||||
|
||||
* deps: mime-types@~2.1.6
|
||||
- deps: mime-db@~1.18.0
|
||||
|
||||
1.2.12 / 2015-07-30
|
||||
===================
|
||||
|
||||
* deps: mime-types@~2.1.4
|
||||
- deps: mime-db@~1.16.0
|
||||
|
||||
1.2.11 / 2015-07-16
|
||||
===================
|
||||
|
||||
* deps: mime-types@~2.1.3
|
||||
- deps: mime-db@~1.15.0
|
||||
|
||||
1.2.10 / 2015-07-01
|
||||
===================
|
||||
|
||||
* deps: mime-types@~2.1.2
|
||||
- deps: mime-db@~1.14.0
|
||||
|
||||
1.2.9 / 2015-06-08
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.1
|
||||
- perf: fix deopt during mapping
|
||||
|
||||
1.2.8 / 2015-06-07
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.0
|
||||
- deps: mime-db@~1.13.0
|
||||
* perf: avoid argument reassignment & argument slice
|
||||
* perf: avoid negotiator recursive construction
|
||||
* perf: enable strict mode
|
||||
* perf: remove unnecessary bitwise operator
|
||||
|
||||
1.2.7 / 2015-05-10
|
||||
==================
|
||||
|
||||
* deps: negotiator@0.5.3
|
||||
- Fix media type parameter matching to be case-insensitive
|
||||
|
||||
1.2.6 / 2015-05-07
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.11
|
||||
- deps: mime-db@~1.9.1
|
||||
* deps: negotiator@0.5.2
|
||||
- Fix comparing media types with quoted values
|
||||
- Fix splitting media types with quoted commas
|
||||
|
||||
1.2.5 / 2015-03-13
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.10
|
||||
- deps: mime-db@~1.8.0
|
||||
|
||||
1.2.4 / 2015-02-14
|
||||
==================
|
||||
|
||||
* Support Node.js 0.6
|
||||
* deps: mime-types@~2.0.9
|
||||
- deps: mime-db@~1.7.0
|
||||
* deps: negotiator@0.5.1
|
||||
- Fix preference sorting to be stable for long acceptable lists
|
||||
|
||||
1.2.3 / 2015-01-31
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.8
|
||||
- deps: mime-db@~1.6.0
|
||||
|
||||
1.2.2 / 2014-12-30
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.7
|
||||
- deps: mime-db@~1.5.0
|
||||
|
||||
1.2.1 / 2014-12-30
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.5
|
||||
- deps: mime-db@~1.3.1
|
||||
|
||||
1.2.0 / 2014-12-19
|
||||
==================
|
||||
|
||||
* deps: negotiator@0.5.0
|
||||
- Fix list return order when large accepted list
|
||||
- Fix missing identity encoding when q=0 exists
|
||||
- Remove dynamic building of Negotiator class
|
||||
|
||||
1.1.4 / 2014-12-10
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.4
|
||||
- deps: mime-db@~1.3.0
|
||||
|
||||
1.1.3 / 2014-11-09
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.3
|
||||
- deps: mime-db@~1.2.0
|
||||
|
||||
1.1.2 / 2014-10-14
|
||||
==================
|
||||
|
||||
* deps: negotiator@0.4.9
|
||||
- Fix error when media type has invalid parameter
|
||||
|
||||
1.1.1 / 2014-09-28
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.2
|
||||
- deps: mime-db@~1.1.0
|
||||
* deps: negotiator@0.4.8
|
||||
- Fix all negotiations to be case-insensitive
|
||||
- Stable sort preferences of same quality according to client order
|
||||
|
||||
1.1.0 / 2014-09-02
|
||||
==================
|
||||
|
||||
* update `mime-types`
|
||||
|
||||
1.0.7 / 2014-07-04
|
||||
==================
|
||||
|
||||
* Fix wrong type returned from `type` when match after unknown extension
|
||||
|
||||
1.0.6 / 2014-06-24
|
||||
==================
|
||||
|
||||
* deps: negotiator@0.4.7
|
||||
|
||||
1.0.5 / 2014-06-20
|
||||
==================
|
||||
|
||||
* fix crash when unknown extension given
|
||||
|
||||
1.0.4 / 2014-06-19
|
||||
==================
|
||||
|
||||
* use `mime-types`
|
||||
|
||||
1.0.3 / 2014-06-11
|
||||
==================
|
||||
|
||||
* deps: negotiator@0.4.6
|
||||
- Order by specificity when quality is the same
|
||||
|
||||
1.0.2 / 2014-05-29
|
||||
==================
|
||||
|
||||
* Fix interpretation when header not in request
|
||||
* deps: pin negotiator@0.4.5
|
||||
|
||||
1.0.1 / 2014-01-18
|
||||
==================
|
||||
|
||||
* Identity encoding isn't always acceptable
|
||||
* deps: negotiator@~0.4.0
|
||||
|
||||
1.0.0 / 2013-12-27
|
||||
==================
|
||||
|
||||
* Genesis
|
23
app/node_modules/accepts/LICENSE
generated
vendored
@ -1,23 +0,0 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
|
||||
Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.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.
|
140
app/node_modules/accepts/README.md
generated
vendored
@ -1,140 +0,0 @@
|
||||
# accepts
|
||||
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][github-actions-ci-image]][github-actions-ci-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator).
|
||||
Extracted from [koa](https://www.npmjs.com/package/koa) for general use.
|
||||
|
||||
In addition to negotiator, it allows:
|
||||
|
||||
- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])`
|
||||
as well as `('text/html', 'application/json')`.
|
||||
- Allows type shorthands such as `json`.
|
||||
- Returns `false` when no types match
|
||||
- Treats non-existent headers as `*`
|
||||
|
||||
## Installation
|
||||
|
||||
This is a [Node.js](https://nodejs.org/en/) module available through the
|
||||
[npm registry](https://www.npmjs.com/). Installation is done using the
|
||||
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
||||
|
||||
```sh
|
||||
$ npm install accepts
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var accepts = require('accepts')
|
||||
```
|
||||
|
||||
### accepts(req)
|
||||
|
||||
Create a new `Accepts` object for the given `req`.
|
||||
|
||||
#### .charset(charsets)
|
||||
|
||||
Return the first accepted charset. If nothing in `charsets` is accepted,
|
||||
then `false` is returned.
|
||||
|
||||
#### .charsets()
|
||||
|
||||
Return the charsets that the request accepts, in the order of the client's
|
||||
preference (most preferred first).
|
||||
|
||||
#### .encoding(encodings)
|
||||
|
||||
Return the first accepted encoding. If nothing in `encodings` is accepted,
|
||||
then `false` is returned.
|
||||
|
||||
#### .encodings()
|
||||
|
||||
Return the encodings that the request accepts, in the order of the client's
|
||||
preference (most preferred first).
|
||||
|
||||
#### .language(languages)
|
||||
|
||||
Return the first accepted language. If nothing in `languages` is accepted,
|
||||
then `false` is returned.
|
||||
|
||||
#### .languages()
|
||||
|
||||
Return the languages that the request accepts, in the order of the client's
|
||||
preference (most preferred first).
|
||||
|
||||
#### .type(types)
|
||||
|
||||
Return the first accepted type (and it is returned as the same text as what
|
||||
appears in the `types` array). If nothing in `types` is accepted, then `false`
|
||||
is returned.
|
||||
|
||||
The `types` array can contain full MIME types or file extensions. Any value
|
||||
that is not a full MIME types is passed to `require('mime-types').lookup`.
|
||||
|
||||
#### .types()
|
||||
|
||||
Return the types that the request accepts, in the order of the client's
|
||||
preference (most preferred first).
|
||||
|
||||
## Examples
|
||||
|
||||
### Simple type negotiation
|
||||
|
||||
This simple example shows how to use `accepts` to return a different typed
|
||||
respond body based on what the client wants to accept. The server lists it's
|
||||
preferences in order and will get back the best match between the client and
|
||||
server.
|
||||
|
||||
```js
|
||||
var accepts = require('accepts')
|
||||
var http = require('http')
|
||||
|
||||
function app (req, res) {
|
||||
var accept = accepts(req)
|
||||
|
||||
// the order of this list is significant; should be server preferred order
|
||||
switch (accept.type(['json', 'html'])) {
|
||||
case 'json':
|
||||
res.setHeader('Content-Type', 'application/json')
|
||||
res.write('{"hello":"world!"}')
|
||||
break
|
||||
case 'html':
|
||||
res.setHeader('Content-Type', 'text/html')
|
||||
res.write('<b>hello, world!</b>')
|
||||
break
|
||||
default:
|
||||
// the fallback is text/plain, so no need to specify it above
|
||||
res.setHeader('Content-Type', 'text/plain')
|
||||
res.write('hello, world!')
|
||||
break
|
||||
}
|
||||
|
||||
res.end()
|
||||
}
|
||||
|
||||
http.createServer(app).listen(3000)
|
||||
```
|
||||
|
||||
You can test this out with the cURL program:
|
||||
```sh
|
||||
curl -I -H'Accept: text/html' http://localhost:3000/
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/accepts/master
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master
|
||||
[github-actions-ci-image]: https://badgen.net/github/checks/jshttp/accepts/master?label=ci
|
||||
[github-actions-ci-url]: https://github.com/jshttp/accepts/actions/workflows/ci.yml
|
||||
[node-version-image]: https://badgen.net/npm/node/accepts
|
||||
[node-version-url]: https://nodejs.org/en/download
|
||||
[npm-downloads-image]: https://badgen.net/npm/dm/accepts
|
||||
[npm-url]: https://npmjs.org/package/accepts
|
||||
[npm-version-image]: https://badgen.net/npm/v/accepts
|
238
app/node_modules/accepts/index.js
generated
vendored
@ -1,238 +0,0 @@
|
||||
/*!
|
||||
* accepts
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var Negotiator = require('negotiator')
|
||||
var mime = require('mime-types')
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = Accepts
|
||||
|
||||
/**
|
||||
* Create a new Accepts object for the given req.
|
||||
*
|
||||
* @param {object} req
|
||||
* @public
|
||||
*/
|
||||
|
||||
function Accepts (req) {
|
||||
if (!(this instanceof Accepts)) {
|
||||
return new Accepts(req)
|
||||
}
|
||||
|
||||
this.headers = req.headers
|
||||
this.negotiator = new Negotiator(req)
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given `type(s)` is acceptable, returning
|
||||
* the best match when true, otherwise `undefined`, in which
|
||||
* case you should respond with 406 "Not Acceptable".
|
||||
*
|
||||
* The `type` value may be a single mime type string
|
||||
* such as "application/json", the extension name
|
||||
* such as "json" or an array `["json", "html", "text/plain"]`. When a list
|
||||
* or array is given the _best_ match, if any is returned.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* // Accept: text/html
|
||||
* this.types('html');
|
||||
* // => "html"
|
||||
*
|
||||
* // Accept: text/*, application/json
|
||||
* this.types('html');
|
||||
* // => "html"
|
||||
* this.types('text/html');
|
||||
* // => "text/html"
|
||||
* this.types('json', 'text');
|
||||
* // => "json"
|
||||
* this.types('application/json');
|
||||
* // => "application/json"
|
||||
*
|
||||
* // Accept: text/*, application/json
|
||||
* this.types('image/png');
|
||||
* this.types('png');
|
||||
* // => undefined
|
||||
*
|
||||
* // Accept: text/*;q=.5, application/json
|
||||
* this.types(['html', 'json']);
|
||||
* this.types('html', 'json');
|
||||
* // => "json"
|
||||
*
|
||||
* @param {String|Array} types...
|
||||
* @return {String|Array|Boolean}
|
||||
* @public
|
||||
*/
|
||||
|
||||
Accepts.prototype.type =
|
||||
Accepts.prototype.types = function (types_) {
|
||||
var types = types_
|
||||
|
||||
// support flattened arguments
|
||||
if (types && !Array.isArray(types)) {
|
||||
types = new Array(arguments.length)
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
types[i] = arguments[i]
|
||||
}
|
||||
}
|
||||
|
||||
// no types, return all requested types
|
||||
if (!types || types.length === 0) {
|
||||
return this.negotiator.mediaTypes()
|
||||
}
|
||||
|
||||
// no accept header, return first given type
|
||||
if (!this.headers.accept) {
|
||||
return types[0]
|
||||
}
|
||||
|
||||
var mimes = types.map(extToMime)
|
||||
var accepts = this.negotiator.mediaTypes(mimes.filter(validMime))
|
||||
var first = accepts[0]
|
||||
|
||||
return first
|
||||
? types[mimes.indexOf(first)]
|
||||
: false
|
||||
}
|
||||
|
||||
/**
|
||||
* Return accepted encodings or best fit based on `encodings`.
|
||||
*
|
||||
* Given `Accept-Encoding: gzip, deflate`
|
||||
* an array sorted by quality is returned:
|
||||
*
|
||||
* ['gzip', 'deflate']
|
||||
*
|
||||
* @param {String|Array} encodings...
|
||||
* @return {String|Array}
|
||||
* @public
|
||||
*/
|
||||
|
||||
Accepts.prototype.encoding =
|
||||
Accepts.prototype.encodings = function (encodings_) {
|
||||
var encodings = encodings_
|
||||
|
||||
// support flattened arguments
|
||||
if (encodings && !Array.isArray(encodings)) {
|
||||
encodings = new Array(arguments.length)
|
||||
for (var i = 0; i < encodings.length; i++) {
|
||||
encodings[i] = arguments[i]
|
||||
}
|
||||
}
|
||||
|
||||
// no encodings, return all requested encodings
|
||||
if (!encodings || encodings.length === 0) {
|
||||
return this.negotiator.encodings()
|
||||
}
|
||||
|
||||
return this.negotiator.encodings(encodings)[0] || false
|
||||
}
|
||||
|
||||
/**
|
||||
* Return accepted charsets or best fit based on `charsets`.
|
||||
*
|
||||
* Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
|
||||
* an array sorted by quality is returned:
|
||||
*
|
||||
* ['utf-8', 'utf-7', 'iso-8859-1']
|
||||
*
|
||||
* @param {String|Array} charsets...
|
||||
* @return {String|Array}
|
||||
* @public
|
||||
*/
|
||||
|
||||
Accepts.prototype.charset =
|
||||
Accepts.prototype.charsets = function (charsets_) {
|
||||
var charsets = charsets_
|
||||
|
||||
// support flattened arguments
|
||||
if (charsets && !Array.isArray(charsets)) {
|
||||
charsets = new Array(arguments.length)
|
||||
for (var i = 0; i < charsets.length; i++) {
|
||||
charsets[i] = arguments[i]
|
||||
}
|
||||
}
|
||||
|
||||
// no charsets, return all requested charsets
|
||||
if (!charsets || charsets.length === 0) {
|
||||
return this.negotiator.charsets()
|
||||
}
|
||||
|
||||
return this.negotiator.charsets(charsets)[0] || false
|
||||
}
|
||||
|
||||
/**
|
||||
* Return accepted languages or best fit based on `langs`.
|
||||
*
|
||||
* Given `Accept-Language: en;q=0.8, es, pt`
|
||||
* an array sorted by quality is returned:
|
||||
*
|
||||
* ['es', 'pt', 'en']
|
||||
*
|
||||
* @param {String|Array} langs...
|
||||
* @return {Array|String}
|
||||
* @public
|
||||
*/
|
||||
|
||||
Accepts.prototype.lang =
|
||||
Accepts.prototype.langs =
|
||||
Accepts.prototype.language =
|
||||
Accepts.prototype.languages = function (languages_) {
|
||||
var languages = languages_
|
||||
|
||||
// support flattened arguments
|
||||
if (languages && !Array.isArray(languages)) {
|
||||
languages = new Array(arguments.length)
|
||||
for (var i = 0; i < languages.length; i++) {
|
||||
languages[i] = arguments[i]
|
||||
}
|
||||
}
|
||||
|
||||
// no languages, return all requested languages
|
||||
if (!languages || languages.length === 0) {
|
||||
return this.negotiator.languages()
|
||||
}
|
||||
|
||||
return this.negotiator.languages(languages)[0] || false
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert extnames to mime.
|
||||
*
|
||||
* @param {String} type
|
||||
* @return {String}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function extToMime (type) {
|
||||
return type.indexOf('/') === -1
|
||||
? mime.lookup(type)
|
||||
: type
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if mime is valid.
|
||||
*
|
||||
* @param {String} type
|
||||
* @return {String}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function validMime (type) {
|
||||
return typeof type === 'string'
|
||||
}
|
86
app/node_modules/accepts/package.json
generated
vendored
@ -1,86 +0,0 @@
|
||||
{
|
||||
"_from": "accepts@~1.3.8",
|
||||
"_id": "accepts@1.3.8",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
|
||||
"_location": "/accepts",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "accepts@~1.3.8",
|
||||
"name": "accepts",
|
||||
"escapedName": "accepts",
|
||||
"rawSpec": "~1.3.8",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~1.3.8"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/express"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
|
||||
"_shasum": "0bf0be125b67014adcb0b0921e62db7bffe16b2e",
|
||||
"_spec": "accepts@~1.3.8",
|
||||
"_where": "/mnt/c/Users/docto/Downloads/Rappaurio/node_modules/express",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jshttp/accepts/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
{
|
||||
"name": "Jonathan Ong",
|
||||
"email": "me@jongleberry.com",
|
||||
"url": "http://jongleberry.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"mime-types": "~2.1.34",
|
||||
"negotiator": "0.6.3"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Higher-level content negotiation",
|
||||
"devDependencies": {
|
||||
"deep-equal": "1.0.1",
|
||||
"eslint": "7.32.0",
|
||||
"eslint-config-standard": "14.1.1",
|
||||
"eslint-plugin-import": "2.25.4",
|
||||
"eslint-plugin-markdown": "2.2.1",
|
||||
"eslint-plugin-node": "11.1.0",
|
||||
"eslint-plugin-promise": "4.3.1",
|
||||
"eslint-plugin-standard": "4.1.0",
|
||||
"mocha": "9.2.0",
|
||||
"nyc": "15.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"HISTORY.md",
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/jshttp/accepts#readme",
|
||||
"keywords": [
|
||||
"content",
|
||||
"negotiation",
|
||||
"accept",
|
||||
"accepts"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "accepts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jshttp/accepts.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"test": "mocha --reporter spec --check-leaks --bail test/",
|
||||
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
||||
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
||||
},
|
||||
"version": "1.3.8"
|
||||
}
|
33
app/node_modules/ansi-regex/index.d.ts
generated
vendored
@ -1,33 +0,0 @@
|
||||
export interface Options {
|
||||
/**
|
||||
Match only the first ANSI escape.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly onlyFirst: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
Regular expression for matching ANSI escape codes.
|
||||
|
||||
@example
|
||||
```
|
||||
import ansiRegex from 'ansi-regex';
|
||||
|
||||
ansiRegex().test('\u001B[4mcake\u001B[0m');
|
||||
//=> true
|
||||
|
||||
ansiRegex().test('cake');
|
||||
//=> false
|
||||
|
||||
'\u001B[4mcake\u001B[0m'.match(ansiRegex());
|
||||
//=> ['\u001B[4m', '\u001B[0m']
|
||||
|
||||
'\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true}));
|
||||
//=> ['\u001B[4m']
|
||||
|
||||
'\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex());
|
||||
//=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007']
|
||||
```
|
||||
*/
|
||||
export default function ansiRegex(options?: Options): RegExp;
|
8
app/node_modules/ansi-regex/index.js
generated
vendored
@ -1,8 +0,0 @@
|
||||
export default function ansiRegex({onlyFirst = false} = {}) {
|
||||
const pattern = [
|
||||
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
|
||||
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
|
||||
].join('|');
|
||||
|
||||
return new RegExp(pattern, onlyFirst ? undefined : 'g');
|
||||
}
|
9
app/node_modules/ansi-regex/license
generated
vendored
@ -1,9 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.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.
|
90
app/node_modules/ansi-regex/package.json
generated
vendored
@ -1,90 +0,0 @@
|
||||
{
|
||||
"_from": "ansi-regex@^6.0.1",
|
||||
"_id": "ansi-regex@6.0.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==",
|
||||
"_location": "/ansi-regex",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "ansi-regex@^6.0.1",
|
||||
"name": "ansi-regex",
|
||||
"escapedName": "ansi-regex",
|
||||
"rawSpec": "^6.0.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^6.0.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/strip-ansi"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz",
|
||||
"_shasum": "3183e38fae9a65d7cb5e53945cd5897d0260a06a",
|
||||
"_spec": "ansi-regex@^6.0.1",
|
||||
"_where": "/mnt/c/Users/docto/Downloads/Rappaurio/node_modules/strip-ansi",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/chalk/ansi-regex/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Regular expression for matching ANSI escape codes",
|
||||
"devDependencies": {
|
||||
"ava": "^3.15.0",
|
||||
"tsd": "^0.14.0",
|
||||
"xo": "^0.38.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"exports": "./index.js",
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"funding": "https://github.com/chalk/ansi-regex?sponsor=1",
|
||||
"homepage": "https://github.com/chalk/ansi-regex#readme",
|
||||
"keywords": [
|
||||
"ansi",
|
||||
"styles",
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"string",
|
||||
"tty",
|
||||
"escape",
|
||||
"formatting",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"command-line",
|
||||
"text",
|
||||
"regex",
|
||||
"regexp",
|
||||
"re",
|
||||
"match",
|
||||
"test",
|
||||
"find",
|
||||
"pattern"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "ansi-regex",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/chalk/ansi-regex.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd",
|
||||
"view-supported": "node fixtures/view-codes.js"
|
||||
},
|
||||
"type": "module",
|
||||
"version": "6.0.1"
|
||||
}
|
72
app/node_modules/ansi-regex/readme.md
generated
vendored
@ -1,72 +0,0 @@
|
||||
# ansi-regex
|
||||
|
||||
> Regular expression for matching [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code)
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install ansi-regex
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import ansiRegex from 'ansi-regex';
|
||||
|
||||
ansiRegex().test('\u001B[4mcake\u001B[0m');
|
||||
//=> true
|
||||
|
||||
ansiRegex().test('cake');
|
||||
//=> false
|
||||
|
||||
'\u001B[4mcake\u001B[0m'.match(ansiRegex());
|
||||
//=> ['\u001B[4m', '\u001B[0m']
|
||||
|
||||
'\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true}));
|
||||
//=> ['\u001B[4m']
|
||||
|
||||
'\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex());
|
||||
//=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007']
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### ansiRegex(options?)
|
||||
|
||||
Returns a regex for matching ANSI escape codes.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### onlyFirst
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false` *(Matches any ANSI escape codes in a string)*
|
||||
|
||||
Match only the first ANSI escape.
|
||||
|
||||
## FAQ
|
||||
|
||||
### Why do you test for codes not in the ECMA 48 standard?
|
||||
|
||||
Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. We test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them.
|
||||
|
||||
On the historical side, those ECMA standards were established in the early 90's whereas the VT100, for example, was designed in the mid/late 70's. At that point in time, control codes were still pretty ungoverned and engineers used them for a multitude of things, namely to activate hardware ports that may have been proprietary. Somewhere else you see a similar 'anarchy' of codes is in the x86 architecture for processors; there are a ton of "interrupts" that can mean different things on certain brands of processors, most of which have been phased out.
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-ansi-regex?utm_source=npm-ansi-regex&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
236
app/node_modules/ansi-styles/index.d.ts
generated
vendored
@ -1,236 +0,0 @@
|
||||
export interface CSPair { // eslint-disable-line @typescript-eslint/naming-convention
|
||||
/**
|
||||
The ANSI terminal control sequence for starting this style.
|
||||
*/
|
||||
readonly open: string;
|
||||
|
||||
/**
|
||||
The ANSI terminal control sequence for ending this style.
|
||||
*/
|
||||
readonly close: string;
|
||||
}
|
||||
|
||||
export interface ColorBase {
|
||||
/**
|
||||
The ANSI terminal control sequence for ending this color.
|
||||
*/
|
||||
readonly close: string;
|
||||
|
||||
ansi(code: number): string;
|
||||
|
||||
ansi256(code: number): string;
|
||||
|
||||
ansi16m(red: number, green: number, blue: number): string;
|
||||
}
|
||||
|
||||
export interface Modifier {
|
||||
/**
|
||||
Resets the current color chain.
|
||||
*/
|
||||
readonly reset: CSPair;
|
||||
|
||||
/**
|
||||
Make text bold.
|
||||
*/
|
||||
readonly bold: CSPair;
|
||||
|
||||
/**
|
||||
Emitting only a small amount of light.
|
||||
*/
|
||||
readonly dim: CSPair;
|
||||
|
||||
/**
|
||||
Make text italic. (Not widely supported)
|
||||
*/
|
||||
readonly italic: CSPair;
|
||||
|
||||
/**
|
||||
Make text underline. (Not widely supported)
|
||||
*/
|
||||
readonly underline: CSPair;
|
||||
|
||||
/**
|
||||
Make text overline.
|
||||
|
||||
Supported on VTE-based terminals, the GNOME terminal, mintty, and Git Bash.
|
||||
*/
|
||||
readonly overline: CSPair;
|
||||
|
||||
/**
|
||||
Inverse background and foreground colors.
|
||||
*/
|
||||
readonly inverse: CSPair;
|
||||
|
||||
/**
|
||||
Prints the text, but makes it invisible.
|
||||
*/
|
||||
readonly hidden: CSPair;
|
||||
|
||||
/**
|
||||
Puts a horizontal line through the center of the text. (Not widely supported)
|
||||
*/
|
||||
readonly strikethrough: CSPair;
|
||||
}
|
||||
|
||||
export interface ForegroundColor {
|
||||
readonly black: CSPair;
|
||||
readonly red: CSPair;
|
||||
readonly green: CSPair;
|
||||
readonly yellow: CSPair;
|
||||
readonly blue: CSPair;
|
||||
readonly cyan: CSPair;
|
||||
readonly magenta: CSPair;
|
||||
readonly white: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `blackBright`.
|
||||
*/
|
||||
readonly gray: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `blackBright`.
|
||||
*/
|
||||
readonly grey: CSPair;
|
||||
|
||||
readonly blackBright: CSPair;
|
||||
readonly redBright: CSPair;
|
||||
readonly greenBright: CSPair;
|
||||
readonly yellowBright: CSPair;
|
||||
readonly blueBright: CSPair;
|
||||
readonly cyanBright: CSPair;
|
||||
readonly magentaBright: CSPair;
|
||||
readonly whiteBright: CSPair;
|
||||
}
|
||||
|
||||
export interface BackgroundColor {
|
||||
readonly bgBlack: CSPair;
|
||||
readonly bgRed: CSPair;
|
||||
readonly bgGreen: CSPair;
|
||||
readonly bgYellow: CSPair;
|
||||
readonly bgBlue: CSPair;
|
||||
readonly bgCyan: CSPair;
|
||||
readonly bgMagenta: CSPair;
|
||||
readonly bgWhite: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `bgBlackBright`.
|
||||
*/
|
||||
readonly bgGray: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `bgBlackBright`.
|
||||
*/
|
||||
readonly bgGrey: CSPair;
|
||||
|
||||
readonly bgBlackBright: CSPair;
|
||||
readonly bgRedBright: CSPair;
|
||||
readonly bgGreenBright: CSPair;
|
||||
readonly bgYellowBright: CSPair;
|
||||
readonly bgBlueBright: CSPair;
|
||||
readonly bgCyanBright: CSPair;
|
||||
readonly bgMagentaBright: CSPair;
|
||||
readonly bgWhiteBright: CSPair;
|
||||
}
|
||||
|
||||
export interface ConvertColor {
|
||||
/**
|
||||
Convert from the RGB color space to the ANSI 256 color space.
|
||||
|
||||
@param red - (`0...255`)
|
||||
@param green - (`0...255`)
|
||||
@param blue - (`0...255`)
|
||||
*/
|
||||
rgbToAnsi256(red: number, green: number, blue: number): number;
|
||||
|
||||
/**
|
||||
Convert from the RGB HEX color space to the RGB color space.
|
||||
|
||||
@param hex - A hexadecimal string containing RGB data.
|
||||
*/
|
||||
hexToRgb(hex: string): [red: number, green: number, blue: number];
|
||||
|
||||
/**
|
||||
Convert from the RGB HEX color space to the ANSI 256 color space.
|
||||
|
||||
@param hex - A hexadecimal string containing RGB data.
|
||||
*/
|
||||
hexToAnsi256(hex: string): number;
|
||||
|
||||
/**
|
||||
Convert from the ANSI 256 color space to the ANSI 16 color space.
|
||||
|
||||
@param code - A number representing the ANSI 256 color.
|
||||
*/
|
||||
ansi256ToAnsi(code: number): number;
|
||||
|
||||
/**
|
||||
Convert from the RGB color space to the ANSI 16 color space.
|
||||
|
||||
@param red - (`0...255`)
|
||||
@param green - (`0...255`)
|
||||
@param blue - (`0...255`)
|
||||
*/
|
||||
rgbToAnsi(red: number, green: number, blue: number): number;
|
||||
|
||||
/**
|
||||
Convert from the RGB HEX color space to the ANSI 16 color space.
|
||||
|
||||
@param hex - A hexadecimal string containing RGB data.
|
||||
*/
|
||||
hexToAnsi(hex: string): number;
|
||||
}
|
||||
|
||||
/**
|
||||
Basic modifier names.
|
||||
*/
|
||||
export type ModifierName = keyof Modifier;
|
||||
|
||||
/**
|
||||
Basic foreground color names.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
export type ForegroundColorName = keyof ForegroundColor;
|
||||
|
||||
/**
|
||||
Basic background color names.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
export type BackgroundColorName = keyof BackgroundColor;
|
||||
|
||||
/**
|
||||
Basic color names. The combination of foreground and background color names.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
export type ColorName = ForegroundColorName | BackgroundColorName;
|
||||
|
||||
/**
|
||||
Basic modifier names.
|
||||
*/
|
||||
export const modifierNames: readonly ModifierName[];
|
||||
|
||||
/**
|
||||
Basic foreground color names.
|
||||
*/
|
||||
export const foregroundColorNames: readonly ForegroundColorName[];
|
||||
|
||||
/**
|
||||
Basic background color names.
|
||||
*/
|
||||
export const backgroundColorNames: readonly BackgroundColorName[];
|
||||
|
||||
/*
|
||||
Basic color names. The combination of foreground and background color names.
|
||||
*/
|
||||
export const colorNames: readonly ColorName[];
|
||||
|
||||
declare const ansiStyles: {
|
||||
readonly modifier: Modifier;
|
||||
readonly color: ColorBase & ForegroundColor;
|
||||
readonly bgColor: ColorBase & BackgroundColor;
|
||||
readonly codes: ReadonlyMap<number, number>;
|
||||
} & ForegroundColor & BackgroundColor & Modifier & ConvertColor;
|
||||
|
||||
export default ansiStyles;
|
223
app/node_modules/ansi-styles/index.js
generated
vendored
@ -1,223 +0,0 @@
|
||||
const ANSI_BACKGROUND_OFFSET = 10;
|
||||
|
||||
const wrapAnsi16 = (offset = 0) => code => `\u001B[${code + offset}m`;
|
||||
|
||||
const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
|
||||
|
||||
const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
|
||||
|
||||
const styles = {
|
||||
modifier: {
|
||||
reset: [0, 0],
|
||||
// 21 isn't widely supported and 22 does the same thing
|
||||
bold: [1, 22],
|
||||
dim: [2, 22],
|
||||
italic: [3, 23],
|
||||
underline: [4, 24],
|
||||
overline: [53, 55],
|
||||
inverse: [7, 27],
|
||||
hidden: [8, 28],
|
||||
strikethrough: [9, 29],
|
||||
},
|
||||
color: {
|
||||
black: [30, 39],
|
||||
red: [31, 39],
|
||||
green: [32, 39],
|
||||
yellow: [33, 39],
|
||||
blue: [34, 39],
|
||||
magenta: [35, 39],
|
||||
cyan: [36, 39],
|
||||
white: [37, 39],
|
||||
|
||||
// Bright color
|
||||
blackBright: [90, 39],
|
||||
gray: [90, 39], // Alias of `blackBright`
|
||||
grey: [90, 39], // Alias of `blackBright`
|
||||
redBright: [91, 39],
|
||||
greenBright: [92, 39],
|
||||
yellowBright: [93, 39],
|
||||
blueBright: [94, 39],
|
||||
magentaBright: [95, 39],
|
||||
cyanBright: [96, 39],
|
||||
whiteBright: [97, 39],
|
||||
},
|
||||
bgColor: {
|
||||
bgBlack: [40, 49],
|
||||
bgRed: [41, 49],
|
||||
bgGreen: [42, 49],
|
||||
bgYellow: [43, 49],
|
||||
bgBlue: [44, 49],
|
||||
bgMagenta: [45, 49],
|
||||
bgCyan: [46, 49],
|
||||
bgWhite: [47, 49],
|
||||
|
||||
// Bright color
|
||||
bgBlackBright: [100, 49],
|
||||
bgGray: [100, 49], // Alias of `bgBlackBright`
|
||||
bgGrey: [100, 49], // Alias of `bgBlackBright`
|
||||
bgRedBright: [101, 49],
|
||||
bgGreenBright: [102, 49],
|
||||
bgYellowBright: [103, 49],
|
||||
bgBlueBright: [104, 49],
|
||||
bgMagentaBright: [105, 49],
|
||||
bgCyanBright: [106, 49],
|
||||
bgWhiteBright: [107, 49],
|
||||
},
|
||||
};
|
||||
|
||||
export const modifierNames = Object.keys(styles.modifier);
|
||||
export const foregroundColorNames = Object.keys(styles.color);
|
||||
export const backgroundColorNames = Object.keys(styles.bgColor);
|
||||
export const colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
||||
|
||||
function assembleStyles() {
|
||||
const codes = new Map();
|
||||
|
||||
for (const [groupName, group] of Object.entries(styles)) {
|
||||
for (const [styleName, style] of Object.entries(group)) {
|
||||
styles[styleName] = {
|
||||
open: `\u001B[${style[0]}m`,
|
||||
close: `\u001B[${style[1]}m`,
|
||||
};
|
||||
|
||||
group[styleName] = styles[styleName];
|
||||
|
||||
codes.set(style[0], style[1]);
|
||||
}
|
||||
|
||||
Object.defineProperty(styles, groupName, {
|
||||
value: group,
|
||||
enumerable: false,
|
||||
});
|
||||
}
|
||||
|
||||
Object.defineProperty(styles, 'codes', {
|
||||
value: codes,
|
||||
enumerable: false,
|
||||
});
|
||||
|
||||
styles.color.close = '\u001B[39m';
|
||||
styles.bgColor.close = '\u001B[49m';
|
||||
|
||||
styles.color.ansi = wrapAnsi16();
|
||||
styles.color.ansi256 = wrapAnsi256();
|
||||
styles.color.ansi16m = wrapAnsi16m();
|
||||
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
||||
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
||||
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
||||
|
||||
// From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js
|
||||
Object.defineProperties(styles, {
|
||||
rgbToAnsi256: {
|
||||
value: (red, green, blue) => {
|
||||
// We use the extended greyscale palette here, with the exception of
|
||||
// black and white. normal palette only has 4 greyscale shades.
|
||||
if (red === green && green === blue) {
|
||||
if (red < 8) {
|
||||
return 16;
|
||||
}
|
||||
|
||||
if (red > 248) {
|
||||
return 231;
|
||||
}
|
||||
|
||||
return Math.round(((red - 8) / 247) * 24) + 232;
|
||||
}
|
||||
|
||||
return 16
|
||||
+ (36 * Math.round(red / 255 * 5))
|
||||
+ (6 * Math.round(green / 255 * 5))
|
||||
+ Math.round(blue / 255 * 5);
|
||||
},
|
||||
enumerable: false,
|
||||
},
|
||||
hexToRgb: {
|
||||
value: hex => {
|
||||
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
||||
if (!matches) {
|
||||
return [0, 0, 0];
|
||||
}
|
||||
|
||||
let [colorString] = matches;
|
||||
|
||||
if (colorString.length === 3) {
|
||||
colorString = [...colorString].map(character => character + character).join('');
|
||||
}
|
||||
|
||||
const integer = Number.parseInt(colorString, 16);
|
||||
|
||||
return [
|
||||
/* eslint-disable no-bitwise */
|
||||
(integer >> 16) & 0xFF,
|
||||
(integer >> 8) & 0xFF,
|
||||
integer & 0xFF,
|
||||
/* eslint-enable no-bitwise */
|
||||
];
|
||||
},
|
||||
enumerable: false,
|
||||
},
|
||||
hexToAnsi256: {
|
||||
value: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
||||
enumerable: false,
|
||||
},
|
||||
ansi256ToAnsi: {
|
||||
value: code => {
|
||||
if (code < 8) {
|
||||
return 30 + code;
|
||||
}
|
||||
|
||||
if (code < 16) {
|
||||
return 90 + (code - 8);
|
||||
}
|
||||
|
||||
let red;
|
||||
let green;
|
||||
let blue;
|
||||
|
||||
if (code >= 232) {
|
||||
red = (((code - 232) * 10) + 8) / 255;
|
||||
green = red;
|
||||
blue = red;
|
||||
} else {
|
||||
code -= 16;
|
||||
|
||||
const remainder = code % 36;
|
||||
|
||||
red = Math.floor(code / 36) / 5;
|
||||
green = Math.floor(remainder / 6) / 5;
|
||||
blue = (remainder % 6) / 5;
|
||||
}
|
||||
|
||||
const value = Math.max(red, green, blue) * 2;
|
||||
|
||||
if (value === 0) {
|
||||
return 30;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-bitwise
|
||||
let result = 30 + ((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));
|
||||
|
||||
if (value === 2) {
|
||||
result += 60;
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
enumerable: false,
|
||||
},
|
||||
rgbToAnsi: {
|
||||
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
||||
enumerable: false,
|
||||
},
|
||||
hexToAnsi: {
|
||||
value: hex => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
||||
enumerable: false,
|
||||
},
|
||||
});
|
||||
|
||||
return styles;
|
||||
}
|
||||
|
||||
const ansiStyles = assembleStyles();
|
||||
|
||||
export default ansiStyles;
|
9
app/node_modules/ansi-styles/license
generated
vendored
@ -1,9 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.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.
|
86
app/node_modules/ansi-styles/package.json
generated
vendored
@ -1,86 +0,0 @@
|
||||
{
|
||||
"_from": "ansi-styles@^6.1.0",
|
||||
"_id": "ansi-styles@6.2.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==",
|
||||
"_location": "/ansi-styles",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "ansi-styles@^6.1.0",
|
||||
"name": "ansi-styles",
|
||||
"escapedName": "ansi-styles",
|
||||
"rawSpec": "^6.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^6.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/wrap-ansi"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz",
|
||||
"_shasum": "0e62320cf99c21afff3b3012192546aacbfb05c5",
|
||||
"_spec": "ansi-styles@^6.1.0",
|
||||
"_where": "/mnt/c/Users/docto/Downloads/Rappaurio/node_modules/wrap-ansi",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/chalk/ansi-styles/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "ANSI escape codes for styling strings in the terminal",
|
||||
"devDependencies": {
|
||||
"ava": "^3.15.0",
|
||||
"svg-term-cli": "^2.1.1",
|
||||
"tsd": "^0.19.0",
|
||||
"xo": "^0.47.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"exports": "./index.js",
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"funding": "https://github.com/chalk/ansi-styles?sponsor=1",
|
||||
"homepage": "https://github.com/chalk/ansi-styles#readme",
|
||||
"keywords": [
|
||||
"ansi",
|
||||
"styles",
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"string",
|
||||
"tty",
|
||||
"escape",
|
||||
"formatting",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"log",
|
||||
"logging",
|
||||
"command-line",
|
||||
"text"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "ansi-styles",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/chalk/ansi-styles.git"
|
||||
},
|
||||
"scripts": {
|
||||
"screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor",
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"type": "module",
|
||||
"version": "6.2.1"
|
||||
}
|
173
app/node_modules/ansi-styles/readme.md
generated
vendored
@ -1,173 +0,0 @@
|
||||
# ansi-styles
|
||||
|
||||
> [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
|
||||
|
||||
You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
|
||||
|
||||

|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install ansi-styles
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import styles from 'ansi-styles';
|
||||
|
||||
console.log(`${styles.green.open}Hello world!${styles.green.close}`);
|
||||
|
||||
|
||||
// Color conversion between 256/truecolor
|
||||
// NOTE: When converting from truecolor to 256 colors, the original color
|
||||
// may be degraded to fit the new color palette. This means terminals
|
||||
// that do not support 16 million colors will best-match the
|
||||
// original color.
|
||||
console.log(`${styles.color.ansi(styles.rgbToAnsi(199, 20, 250))}Hello World${styles.color.close}`)
|
||||
console.log(`${styles.color.ansi256(styles.rgbToAnsi256(199, 20, 250))}Hello World${styles.color.close}`)
|
||||
console.log(`${styles.color.ansi16m(...styles.hexToRgb('#abcdef'))}Hello World${styles.color.close}`)
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `open` and `close`
|
||||
|
||||
Each style has an `open` and `close` property.
|
||||
|
||||
### `modifierNames`, `foregroundColorNames`, `backgroundColorNames`, and `colorNames`
|
||||
|
||||
All supported style strings are exposed as an array of strings for convenience. `colorNames` is the combination of `foregroundColorNames` and `backgroundColorNames`.
|
||||
|
||||
This can be useful if you need to validate input:
|
||||
|
||||
```js
|
||||
import {modifierNames, foregroundColorNames} from 'ansi-styles';
|
||||
|
||||
console.log(modifierNames.includes('bold'));
|
||||
//=> true
|
||||
|
||||
console.log(foregroundColorNames.includes('pink'));
|
||||
//=> false
|
||||
```
|
||||
|
||||
## Styles
|
||||
|
||||
### Modifiers
|
||||
|
||||
- `reset`
|
||||
- `bold`
|
||||
- `dim`
|
||||
- `italic` *(Not widely supported)*
|
||||
- `underline`
|
||||
- `overline` *Supported on VTE-based terminals, the GNOME terminal, mintty, and Git Bash.*
|
||||
- `inverse`
|
||||
- `hidden`
|
||||
- `strikethrough` *(Not widely supported)*
|
||||
|
||||
### Colors
|
||||
|
||||
- `black`
|
||||
- `red`
|
||||
- `green`
|
||||
- `yellow`
|
||||
- `blue`
|
||||
- `magenta`
|
||||
- `cyan`
|
||||
- `white`
|
||||
- `blackBright` (alias: `gray`, `grey`)
|
||||
- `redBright`
|
||||
- `greenBright`
|
||||
- `yellowBright`
|
||||
- `blueBright`
|
||||
- `magentaBright`
|
||||
- `cyanBright`
|
||||
- `whiteBright`
|
||||
|
||||
### Background colors
|
||||
|
||||
- `bgBlack`
|
||||
- `bgRed`
|
||||
- `bgGreen`
|
||||
- `bgYellow`
|
||||
- `bgBlue`
|
||||
- `bgMagenta`
|
||||
- `bgCyan`
|
||||
- `bgWhite`
|
||||
- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
|
||||
- `bgRedBright`
|
||||
- `bgGreenBright`
|
||||
- `bgYellowBright`
|
||||
- `bgBlueBright`
|
||||
- `bgMagentaBright`
|
||||
- `bgCyanBright`
|
||||
- `bgWhiteBright`
|
||||
|
||||
## Advanced usage
|
||||
|
||||
By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
|
||||
|
||||
- `styles.modifier`
|
||||
- `styles.color`
|
||||
- `styles.bgColor`
|
||||
|
||||
###### Example
|
||||
|
||||
```js
|
||||
import styles from 'ansi-styles';
|
||||
|
||||
console.log(styles.color.green.open);
|
||||
```
|
||||
|
||||
Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `styles.codes`, which returns a `Map` with the open codes as keys and close codes as values.
|
||||
|
||||
###### Example
|
||||
|
||||
```js
|
||||
import styles from 'ansi-styles';
|
||||
|
||||
console.log(styles.codes.get(36));
|
||||
//=> 39
|
||||
```
|
||||
|
||||
## 16 / 256 / 16 million (TrueColor) support
|
||||
|
||||
`ansi-styles` allows converting between various color formats and ANSI escapes, with support for 16, 256 and [16 million colors](https://gist.github.com/XVilka/8346728).
|
||||
|
||||
The following color spaces are supported:
|
||||
|
||||
- `rgb`
|
||||
- `hex`
|
||||
- `ansi256`
|
||||
- `ansi`
|
||||
|
||||
To use these, call the associated conversion function with the intended output, for example:
|
||||
|
||||
```js
|
||||
import styles from 'ansi-styles';
|
||||
|
||||
styles.color.ansi(styles.rgbToAnsi(100, 200, 15)); // RGB to 16 color ansi foreground code
|
||||
styles.bgColor.ansi(styles.hexToAnsi('#C0FFEE')); // HEX to 16 color ansi foreground code
|
||||
|
||||
styles.color.ansi256(styles.rgbToAnsi256(100, 200, 15)); // RGB to 256 color ansi foreground code
|
||||
styles.bgColor.ansi256(styles.hexToAnsi256('#C0FFEE')); // HEX to 256 color ansi foreground code
|
||||
|
||||
styles.color.ansi16m(100, 200, 15); // RGB to 16 million color foreground code
|
||||
styles.bgColor.ansi16m(...styles.hexToRgb('#C0FFEE')); // Hex (RGB) to 16 million color foreground code
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
|
||||
## For enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription.
|
||||
|
||||
The maintainers of `ansi-styles` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-ansi-styles?utm_source=npm-ansi-styles&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
21
app/node_modules/array-flatten/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Blake Embrey (hello@blakeembrey.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.
|
43
app/node_modules/array-flatten/README.md
generated
vendored
@ -1,43 +0,0 @@
|
||||
# Array Flatten
|
||||
|
||||
[![NPM version][npm-image]][npm-url]
|
||||
[![NPM downloads][downloads-image]][downloads-url]
|
||||
[![Build status][travis-image]][travis-url]
|
||||
[![Test coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
> Flatten an array of nested arrays into a single flat array. Accepts an optional depth.
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm install array-flatten --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var flatten = require('array-flatten')
|
||||
|
||||
flatten([1, [2, [3, [4, [5], 6], 7], 8], 9])
|
||||
//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||
|
||||
flatten([1, [2, [3, [4, [5], 6], 7], 8], 9], 2)
|
||||
//=> [1, 2, 3, [4, [5], 6], 7, 8, 9]
|
||||
|
||||
(function () {
|
||||
flatten(arguments) //=> [1, 2, 3]
|
||||
})(1, [2, 3])
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/array-flatten.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/array-flatten
|
||||
[downloads-image]: https://img.shields.io/npm/dm/array-flatten.svg?style=flat
|
||||
[downloads-url]: https://npmjs.org/package/array-flatten
|
||||
[travis-image]: https://img.shields.io/travis/blakeembrey/array-flatten.svg?style=flat
|
||||
[travis-url]: https://travis-ci.org/blakeembrey/array-flatten
|
||||
[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/array-flatten.svg?style=flat
|
||||
[coveralls-url]: https://coveralls.io/r/blakeembrey/array-flatten?branch=master
|
64
app/node_modules/array-flatten/array-flatten.js
generated
vendored
@ -1,64 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Expose `arrayFlatten`.
|
||||
*/
|
||||
module.exports = arrayFlatten
|
||||
|
||||
/**
|
||||
* Recursive flatten function with depth.
|
||||
*
|
||||
* @param {Array} array
|
||||
* @param {Array} result
|
||||
* @param {Number} depth
|
||||
* @return {Array}
|
||||
*/
|
||||
function flattenWithDepth (array, result, depth) {
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
var value = array[i]
|
||||
|
||||
if (depth > 0 && Array.isArray(value)) {
|
||||
flattenWithDepth(value, result, depth - 1)
|
||||
} else {
|
||||
result.push(value)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive flatten function. Omitting depth is slightly faster.
|
||||
*
|
||||
* @param {Array} array
|
||||
* @param {Array} result
|
||||
* @return {Array}
|
||||
*/
|
||||
function flattenForever (array, result) {
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
var value = array[i]
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
flattenForever(value, result)
|
||||
} else {
|
||||
result.push(value)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten an array, with the ability to define a depth.
|
||||
*
|
||||
* @param {Array} array
|
||||
* @param {Number} depth
|
||||
* @return {Array}
|
||||
*/
|
||||
function arrayFlatten (array, depth) {
|
||||
if (depth == null) {
|
||||
return flattenForever(array, [])
|
||||
}
|
||||
|
||||
return flattenWithDepth(array, [], depth)
|
||||
}
|
64
app/node_modules/array-flatten/package.json
generated
vendored
@ -1,64 +0,0 @@
|
||||
{
|
||||
"_from": "array-flatten@1.1.1",
|
||||
"_id": "array-flatten@1.1.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
|
||||
"_location": "/array-flatten",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "array-flatten@1.1.1",
|
||||
"name": "array-flatten",
|
||||
"escapedName": "array-flatten",
|
||||
"rawSpec": "1.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/express"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
||||
"_shasum": "9a5f699051b1e7073328f2a008968b64ea2955d2",
|
||||
"_spec": "array-flatten@1.1.1",
|
||||
"_where": "/mnt/c/Users/docto/Downloads/Rappaurio/node_modules/express",
|
||||
"author": {
|
||||
"name": "Blake Embrey",
|
||||
"email": "hello@blakeembrey.com",
|
||||
"url": "http://blakeembrey.me"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/blakeembrey/array-flatten/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Flatten an array of nested arrays into a single flat array",
|
||||
"devDependencies": {
|
||||
"istanbul": "^0.3.13",
|
||||
"mocha": "^2.2.4",
|
||||
"pre-commit": "^1.0.7",
|
||||
"standard": "^3.7.3"
|
||||
},
|
||||
"files": [
|
||||
"array-flatten.js",
|
||||
"LICENSE"
|
||||
],
|
||||
"homepage": "https://github.com/blakeembrey/array-flatten",
|
||||
"keywords": [
|
||||
"array",
|
||||
"flatten",
|
||||
"arguments",
|
||||
"depth"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "array-flatten.js",
|
||||
"name": "array-flatten",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/blakeembrey/array-flatten.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "istanbul cover _mocha -- -R spec"
|
||||
},
|
||||
"version": "1.1.1"
|
||||
}
|
21
app/node_modules/asynckit/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Alex Indigo
|
||||
|
||||
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.
|
233
app/node_modules/asynckit/README.md
generated
vendored
@ -1,233 +0,0 @@
|
||||
# asynckit [](https://www.npmjs.com/package/asynckit)
|
||||
|
||||
Minimal async jobs utility library, with streams support.
|
||||
|
||||
[](https://travis-ci.org/alexindigo/asynckit)
|
||||
[](https://travis-ci.org/alexindigo/asynckit)
|
||||
[](https://ci.appveyor.com/project/alexindigo/asynckit)
|
||||
|
||||
[](https://coveralls.io/github/alexindigo/asynckit?branch=master)
|
||||
[](https://david-dm.org/alexindigo/asynckit)
|
||||
[](https://www.bithound.io/github/alexindigo/asynckit)
|
||||
|
||||
<!-- [](https://www.npmjs.com/package/reamde) -->
|
||||
|
||||
AsyncKit provides harness for `parallel` and `serial` iterators over list of items represented by arrays or objects.
|
||||
Optionally it accepts abort function (should be synchronously return by iterator for each item), and terminates left over jobs upon an error event. For specific iteration order built-in (`ascending` and `descending`) and custom sort helpers also supported, via `asynckit.serialOrdered` method.
|
||||
|
||||
It ensures async operations to keep behavior more stable and prevent `Maximum call stack size exceeded` errors, from sync iterators.
|
||||
|
||||
| compression | size |
|
||||
| :----------------- | -------: |
|
||||
| asynckit.js | 12.34 kB |
|
||||
| asynckit.min.js | 4.11 kB |
|
||||
| asynckit.min.js.gz | 1.47 kB |
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ npm install --save asynckit
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Parallel Jobs
|
||||
|
||||
Runs iterator over provided array in parallel. Stores output in the `result` array,
|
||||
on the matching positions. In unlikely event of an error from one of the jobs,
|
||||
will terminate rest of the active jobs (if abort function is provided)
|
||||
and return error along with salvaged data to the main callback function.
|
||||
|
||||
#### Input Array
|
||||
|
||||
```javascript
|
||||
var parallel = require('asynckit').parallel
|
||||
, assert = require('assert')
|
||||
;
|
||||
|
||||
var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
|
||||
, expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ]
|
||||
, expectedTarget = [ 1, 1, 2, 4, 8, 16, 32, 64 ]
|
||||
, target = []
|
||||
;
|
||||
|
||||
parallel(source, asyncJob, function(err, result)
|
||||
{
|
||||
assert.deepEqual(result, expectedResult);
|
||||
assert.deepEqual(target, expectedTarget);
|
||||
});
|
||||
|
||||
// async job accepts one element from the array
|
||||
// and a callback function
|
||||
function asyncJob(item, cb)
|
||||
{
|
||||
// different delays (in ms) per item
|
||||
var delay = item * 25;
|
||||
|
||||
// pretend different jobs take different time to finish
|
||||
// and not in consequential order
|
||||
var timeoutId = setTimeout(function() {
|
||||
target.push(item);
|
||||
cb(null, item * 2);
|
||||
}, delay);
|
||||
|
||||
// allow to cancel "leftover" jobs upon error
|
||||
// return function, invoking of which will abort this job
|
||||
return clearTimeout.bind(null, timeoutId);
|
||||
}
|
||||
```
|
||||
|
||||
More examples could be found in [test/test-parallel-array.js](test/test-parallel-array.js).
|
||||
|
||||
#### Input Object
|
||||
|
||||
Also it supports named jobs, listed via object.
|
||||
|
||||
```javascript
|
||||
var parallel = require('asynckit/parallel')
|
||||
, assert = require('assert')
|
||||
;
|
||||
|
||||
var source = { first: 1, one: 1, four: 4, sixteen: 16, sixtyFour: 64, thirtyTwo: 32, eight: 8, two: 2 }
|
||||
, expectedResult = { first: 2, one: 2, four: 8, sixteen: 32, sixtyFour: 128, thirtyTwo: 64, eight: 16, two: 4 }
|
||||
, expectedTarget = [ 1, 1, 2, 4, 8, 16, 32, 64 ]
|
||||
, expectedKeys = [ 'first', 'one', 'two', 'four', 'eight', 'sixteen', 'thirtyTwo', 'sixtyFour' ]
|
||||
, target = []
|
||||
, keys = []
|
||||
;
|
||||
|
||||
parallel(source, asyncJob, function(err, result)
|
||||
{
|
||||
assert.deepEqual(result, expectedResult);
|
||||
assert.deepEqual(target, expectedTarget);
|
||||
assert.deepEqual(keys, expectedKeys);
|
||||
});
|
||||
|
||||
// supports full value, key, callback (shortcut) interface
|
||||
function asyncJob(item, key, cb)
|
||||
{
|
||||
// different delays (in ms) per item
|
||||
var delay = item * 25;
|
||||
|
||||
// pretend different jobs take different time to finish
|
||||
// and not in consequential order
|
||||
var timeoutId = setTimeout(function() {
|
||||
keys.push(key);
|
||||
target.push(item);
|
||||
cb(null, item * 2);
|
||||
}, delay);
|
||||
|
||||
// allow to cancel "leftover" jobs upon error
|
||||
// return function, invoking of which will abort this job
|
||||
return clearTimeout.bind(null, timeoutId);
|
||||
}
|
||||
```
|
||||
|
||||
More examples could be found in [test/test-parallel-object.js](test/test-parallel-object.js).
|
||||
|
||||
### Serial Jobs
|
||||
|
||||
Runs iterator over provided array sequentially. Stores output in the `result` array,
|
||||
on the matching positions. In unlikely event of an error from one of the jobs,
|
||||
will not proceed to the rest of the items in the list
|
||||
and return error along with salvaged data to the main callback function.
|
||||
|
||||
#### Input Array
|
||||
|
||||
```javascript
|
||||
var serial = require('asynckit/serial')
|
||||
, assert = require('assert')
|
||||
;
|
||||
|
||||
var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
|
||||
, expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ]
|
||||
, expectedTarget = [ 0, 1, 2, 3, 4, 5, 6, 7 ]
|
||||
, target = []
|
||||
;
|
||||
|
||||
serial(source, asyncJob, function(err, result)
|
||||
{
|
||||
assert.deepEqual(result, expectedResult);
|
||||
assert.deepEqual(target, expectedTarget);
|
||||
});
|
||||
|
||||
// extended interface (item, key, callback)
|
||||
// also supported for arrays
|
||||
function asyncJob(item, key, cb)
|
||||
{
|
||||
target.push(key);
|
||||
|
||||
// it will be automatically made async
|
||||
// even it iterator "returns" in the same event loop
|
||||
cb(null, item * 2);
|
||||
}
|
||||
```
|
||||
|
||||
More examples could be found in [test/test-serial-array.js](test/test-serial-array.js).
|
||||
|
||||
#### Input Object
|
||||
|
||||
Also it supports named jobs, listed via object.
|
||||
|
||||
```javascript
|
||||
var serial = require('asynckit').serial
|
||||
, assert = require('assert')
|
||||
;
|
||||
|
||||
var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
|
||||
, expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ]
|
||||
, expectedTarget = [ 0, 1, 2, 3, 4, 5, 6, 7 ]
|
||||
, target = []
|
||||
;
|
||||
|
||||
var source = { first: 1, one: 1, four: 4, sixteen: 16, sixtyFour: 64, thirtyTwo: 32, eight: 8, two: 2 }
|
||||
, expectedResult = { first: 2, one: 2, four: 8, sixteen: 32, sixtyFour: 128, thirtyTwo: 64, eight: 16, two: 4 }
|
||||
, expectedTarget = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
|
||||
, target = []
|
||||
;
|
||||
|
||||
|
||||
serial(source, asyncJob, function(err, result)
|
||||
{
|
||||
assert.deepEqual(result, expectedResult);
|
||||
assert.deepEqual(target, expectedTarget);
|
||||
});
|
||||
|
||||
// shortcut interface (item, callback)
|
||||
// works for object as well as for the arrays
|
||||
function asyncJob(item, cb)
|
||||
{
|
||||
target.push(item);
|
||||
|
||||
// it will be automatically made async
|
||||
// even it iterator "returns" in the same event loop
|
||||
cb(null, item * 2);
|
||||
}
|
||||
```
|
||||
|
||||
More examples could be found in [test/test-serial-object.js](test/test-serial-object.js).
|
||||
|
||||
_Note: Since _object_ is an _unordered_ collection of properties,
|
||||
it may produce unexpected results with sequential iterations.
|
||||
Whenever order of the jobs' execution is important please use `serialOrdered` method._
|
||||
|
||||
### Ordered Serial Iterations
|
||||
|
||||
TBD
|
||||
|
||||
For example [compare-property](compare-property) package.
|
||||
|
||||
### Streaming interface
|
||||
|
||||
TBD
|
||||
|
||||
## Want to Know More?
|
||||
|
||||
More examples can be found in [test folder](test/).
|
||||
|
||||
Or open an [issue](https://github.com/alexindigo/asynckit/issues) with questions and/or suggestions.
|
||||
|
||||
## License
|
||||
|
||||
AsyncKit is licensed under the MIT license.
|
76
app/node_modules/asynckit/bench.js
generated
vendored
@ -1,76 +0,0 @@
|
||||
/* eslint no-console: "off" */
|
||||
|
||||
var asynckit = require('./')
|
||||
, async = require('async')
|
||||
, assert = require('assert')
|
||||
, expected = 0
|
||||
;
|
||||
|
||||
var Benchmark = require('benchmark');
|
||||
var suite = new Benchmark.Suite;
|
||||
|
||||
var source = [];
|
||||
for (var z = 1; z < 100; z++)
|
||||
{
|
||||
source.push(z);
|
||||
expected += z;
|
||||
}
|
||||
|
||||
suite
|
||||
// add tests
|
||||
|
||||
.add('async.map', function(deferred)
|
||||
{
|
||||
var total = 0;
|
||||
|
||||
async.map(source,
|
||||
function(i, cb)
|
||||
{
|
||||
setImmediate(function()
|
||||
{
|
||||
total += i;
|
||||
cb(null, total);
|
||||
});
|
||||
},
|
||||
function(err, result)
|
||||
{
|
||||
assert.ifError(err);
|
||||
assert.equal(result[result.length - 1], expected);
|
||||
deferred.resolve();
|
||||
});
|
||||
}, {'defer': true})
|
||||
|
||||
|
||||
.add('asynckit.parallel', function(deferred)
|
||||
{
|
||||
var total = 0;
|
||||
|
||||
asynckit.parallel(source,
|
||||
function(i, cb)
|
||||
{
|
||||
setImmediate(function()
|
||||
{
|
||||
total += i;
|
||||
cb(null, total);
|
||||
});
|
||||
},
|
||||
function(err, result)
|
||||
{
|
||||
assert.ifError(err);
|
||||
assert.equal(result[result.length - 1], expected);
|
||||
deferred.resolve();
|
||||
});
|
||||
}, {'defer': true})
|
||||
|
||||
|
||||
// add listeners
|
||||
.on('cycle', function(ev)
|
||||
{
|
||||
console.log(String(ev.target));
|
||||
})
|
||||
.on('complete', function()
|
||||
{
|
||||
console.log('Fastest is ' + this.filter('fastest').map('name'));
|
||||
})
|
||||
// run async
|
||||
.run({ 'async': true });
|
6
app/node_modules/asynckit/index.js
generated
vendored
@ -1,6 +0,0 @@
|
||||
module.exports =
|
||||
{
|
||||
parallel : require('./parallel.js'),
|
||||
serial : require('./serial.js'),
|
||||
serialOrdered : require('./serialOrdered.js')
|
||||
};
|
29
app/node_modules/asynckit/lib/abort.js
generated
vendored
@ -1,29 +0,0 @@
|
||||
// API
|
||||
module.exports = abort;
|
||||
|
||||
/**
|
||||
* Aborts leftover active jobs
|
||||
*
|
||||
* @param {object} state - current state object
|
||||
*/
|
||||
function abort(state)
|
||||
{
|
||||
Object.keys(state.jobs).forEach(clean.bind(state));
|
||||
|
||||
// reset leftover jobs
|
||||
state.jobs = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up leftover job by invoking abort function for the provided job id
|
||||
*
|
||||
* @this state
|
||||
* @param {string|number} key - job id to abort
|
||||
*/
|
||||
function clean(key)
|
||||
{
|
||||
if (typeof this.jobs[key] == 'function')
|
||||
{
|
||||
this.jobs[key]();
|
||||
}
|
||||
}
|
34
app/node_modules/asynckit/lib/async.js
generated
vendored
@ -1,34 +0,0 @@
|
||||
var defer = require('./defer.js');
|
||||
|
||||
// API
|
||||
module.exports = async;
|
||||
|
||||
/**
|
||||
* Runs provided callback asynchronously
|
||||
* even if callback itself is not
|
||||
*
|
||||
* @param {function} callback - callback to invoke
|
||||
* @returns {function} - augmented callback
|
||||
*/
|
||||
function async(callback)
|
||||
{
|
||||
var isAsync = false;
|
||||
|
||||
// check if async happened
|
||||
defer(function() { isAsync = true; });
|
||||
|
||||
return function async_callback(err, result)
|
||||
{
|
||||
if (isAsync)
|
||||
{
|
||||
callback(err, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
defer(function nextTick_callback()
|
||||
{
|
||||
callback(err, result);
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
26
app/node_modules/asynckit/lib/defer.js
generated
vendored
@ -1,26 +0,0 @@
|
||||
module.exports = defer;
|
||||
|
||||
/**
|
||||
* Runs provided function on next iteration of the event loop
|
||||
*
|
||||
* @param {function} fn - function to run
|
||||
*/
|
||||
function defer(fn)
|
||||
{
|
||||
var nextTick = typeof setImmediate == 'function'
|
||||
? setImmediate
|
||||
: (
|
||||
typeof process == 'object' && typeof process.nextTick == 'function'
|
||||
? process.nextTick
|
||||
: null
|
||||
);
|
||||
|
||||
if (nextTick)
|
||||
{
|
||||
nextTick(fn);
|
||||
}
|
||||
else
|
||||
{
|
||||
setTimeout(fn, 0);
|
||||
}
|
||||
}
|
75
app/node_modules/asynckit/lib/iterate.js
generated
vendored
@ -1,75 +0,0 @@
|
||||
var async = require('./async.js')
|
||||
, abort = require('./abort.js')
|
||||
;
|
||||
|
||||
// API
|
||||
module.exports = iterate;
|
||||
|
||||
/**
|
||||
* Iterates over each job object
|
||||
*
|
||||
* @param {array|object} list - array or object (named list) to iterate over
|
||||
* @param {function} iterator - iterator to run
|
||||
* @param {object} state - current job status
|
||||
* @param {function} callback - invoked when all elements processed
|
||||
*/
|
||||
function iterate(list, iterator, state, callback)
|
||||
{
|
||||
// store current index
|
||||
var key = state['keyedList'] ? state['keyedList'][state.index] : state.index;
|
||||
|
||||
state.jobs[key] = runJob(iterator, key, list[key], function(error, output)
|
||||
{
|
||||
// don't repeat yourself
|
||||
// skip secondary callbacks
|
||||
if (!(key in state.jobs))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// clean up jobs
|
||||
delete state.jobs[key];
|
||||
|
||||
if (error)
|
||||
{
|
||||
// don't process rest of the results
|
||||
// stop still active jobs
|
||||
// and reset the list
|
||||
abort(state);
|
||||
}
|
||||
else
|
||||
{
|
||||
state.results[key] = output;
|
||||
}
|
||||
|
||||
// return salvaged results
|
||||
callback(error, state.results);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs iterator over provided job element
|
||||
*
|
||||
* @param {function} iterator - iterator to invoke
|
||||
* @param {string|number} key - key/index of the element in the list of jobs
|
||||
* @param {mixed} item - job description
|
||||
* @param {function} callback - invoked after iterator is done with the job
|
||||
* @returns {function|mixed} - job abort function or something else
|
||||
*/
|
||||
function runJob(iterator, key, item, callback)
|
||||
{
|
||||
var aborter;
|
||||
|
||||
// allow shortcut if iterator expects only two arguments
|
||||
if (iterator.length == 2)
|
||||
{
|
||||
aborter = iterator(item, async(callback));
|
||||
}
|
||||
// otherwise go with full three arguments
|
||||
else
|
||||
{
|
||||
aborter = iterator(item, key, async(callback));
|
||||
}
|
||||
|
||||
return aborter;
|
||||
}
|
91
app/node_modules/asynckit/lib/readable_asynckit.js
generated
vendored
@ -1,91 +0,0 @@
|
||||
var streamify = require('./streamify.js')
|
||||
, defer = require('./defer.js')
|
||||
;
|
||||
|
||||
// API
|
||||
module.exports = ReadableAsyncKit;
|
||||
|
||||
/**
|
||||
* Base constructor for all streams
|
||||
* used to hold properties/methods
|
||||
*/
|
||||
function ReadableAsyncKit()
|
||||
{
|
||||
ReadableAsyncKit.super_.apply(this, arguments);
|
||||
|
||||
// list of active jobs
|
||||
this.jobs = {};
|
||||
|
||||
// add stream methods
|
||||
this.destroy = destroy;
|
||||
this._start = _start;
|
||||
this._read = _read;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys readable stream,
|
||||
* by aborting outstanding jobs
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
function destroy()
|
||||
{
|
||||
if (this.destroyed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.destroyed = true;
|
||||
|
||||
if (typeof this.terminator == 'function')
|
||||
{
|
||||
this.terminator();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts provided jobs in async manner
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function _start()
|
||||
{
|
||||
// first argument – runner function
|
||||
var runner = arguments[0]
|
||||
// take away first argument
|
||||
, args = Array.prototype.slice.call(arguments, 1)
|
||||
// second argument - input data
|
||||
, input = args[0]
|
||||
// last argument - result callback
|
||||
, endCb = streamify.callback.call(this, args[args.length - 1])
|
||||
;
|
||||
|
||||
args[args.length - 1] = endCb;
|
||||
// third argument - iterator
|
||||
args[1] = streamify.iterator.call(this, args[1]);
|
||||
|
||||
// allow time for proper setup
|
||||
defer(function()
|
||||
{
|
||||
if (!this.destroyed)
|
||||
{
|
||||
this.terminator = runner.apply(null, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
endCb(null, Array.isArray(input) ? [] : {});
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implement _read to comply with Readable streams
|
||||
* Doesn't really make sense for flowing object mode
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function _read()
|
||||
{
|
||||
|
||||
}
|
25
app/node_modules/asynckit/lib/readable_parallel.js
generated
vendored
@ -1,25 +0,0 @@
|
||||
var parallel = require('../parallel.js');
|
||||
|
||||
// API
|
||||
module.exports = ReadableParallel;
|
||||
|
||||
/**
|
||||
* Streaming wrapper to `asynckit.parallel`
|
||||
*
|
||||
* @param {array|object} list - array or object (named list) to iterate over
|
||||
* @param {function} iterator - iterator to run
|
||||
* @param {function} callback - invoked when all elements processed
|
||||
* @returns {stream.Readable#}
|
||||
*/
|
||||
function ReadableParallel(list, iterator, callback)
|
||||
{
|
||||
if (!(this instanceof ReadableParallel))
|
||||
{
|
||||
return new ReadableParallel(list, iterator, callback);
|
||||
}
|
||||
|
||||
// turn on object mode
|
||||
ReadableParallel.super_.call(this, {objectMode: true});
|
||||
|
||||
this._start(parallel, list, iterator, callback);
|
||||
}
|
25
app/node_modules/asynckit/lib/readable_serial.js
generated
vendored
@ -1,25 +0,0 @@
|
||||
var serial = require('../serial.js');
|
||||
|
||||
// API
|
||||
module.exports = ReadableSerial;
|
||||
|
||||
/**
|
||||
* Streaming wrapper to `asynckit.serial`
|
||||
*
|
||||
* @param {array|object} list - array or object (named list) to iterate over
|
||||
* @param {function} iterator - iterator to run
|
||||
* @param {function} callback - invoked when all elements processed
|
||||
* @returns {stream.Readable#}
|
||||
*/
|
||||
function ReadableSerial(list, iterator, callback)
|
||||
{
|
||||
if (!(this instanceof ReadableSerial))
|
||||
{
|
||||
return new ReadableSerial(list, iterator, callback);
|
||||
}
|
||||
|
||||
// turn on object mode
|
||||
ReadableSerial.super_.call(this, {objectMode: true});
|
||||
|
||||
this._start(serial, list, iterator, callback);
|
||||
}
|
29
app/node_modules/asynckit/lib/readable_serial_ordered.js
generated
vendored
@ -1,29 +0,0 @@
|
||||
var serialOrdered = require('../serialOrdered.js');
|
||||
|
||||
// API
|
||||
module.exports = ReadableSerialOrdered;
|
||||
// expose sort helpers
|
||||
module.exports.ascending = serialOrdered.ascending;
|
||||
module.exports.descending = serialOrdered.descending;
|
||||
|
||||
/**
|
||||
* Streaming wrapper to `asynckit.serialOrdered`
|
||||
*
|
||||
* @param {array|object} list - array or object (named list) to iterate over
|
||||
* @param {function} iterator - iterator to run
|
||||
* @param {function} sortMethod - custom sort function
|
||||
* @param {function} callback - invoked when all elements processed
|
||||
* @returns {stream.Readable#}
|
||||
*/
|
||||
function ReadableSerialOrdered(list, iterator, sortMethod, callback)
|
||||
{
|
||||
if (!(this instanceof ReadableSerialOrdered))
|
||||
{
|
||||
return new ReadableSerialOrdered(list, iterator, sortMethod, callback);
|
||||
}
|
||||
|
||||
// turn on object mode
|
||||
ReadableSerialOrdered.super_.call(this, {objectMode: true});
|
||||
|
||||
this._start(serialOrdered, list, iterator, sortMethod, callback);
|
||||
}
|
37
app/node_modules/asynckit/lib/state.js
generated
vendored
@ -1,37 +0,0 @@
|
||||
// API
|
||||
module.exports = state;
|
||||
|
||||
/**
|
||||
* Creates initial state object
|
||||
* for iteration over list
|
||||
*
|
||||
* @param {array|object} list - list to iterate over
|
||||
* @param {function|null} sortMethod - function to use for keys sort,
|
||||
* or `null` to keep them as is
|
||||
* @returns {object} - initial state object
|
||||
*/
|
||||
function state(list, sortMethod)
|
||||
{
|
||||
var isNamedList = !Array.isArray(list)
|
||||
, initState =
|
||||
{
|
||||
index : 0,
|
||||
keyedList: isNamedList || sortMethod ? Object.keys(list) : null,
|
||||
jobs : {},
|
||||
results : isNamedList ? {} : [],
|
||||
size : isNamedList ? Object.keys(list).length : list.length
|
||||
}
|
||||
;
|
||||
|
||||
if (sortMethod)
|
||||
{
|
||||
// sort array keys based on it's values
|
||||
// sort object's keys just on own merit
|
||||
initState.keyedList.sort(isNamedList ? sortMethod : function(a, b)
|
||||
{
|
||||
return sortMethod(list[a], list[b]);
|
||||
});
|
||||
}
|
||||
|
||||
return initState;
|
||||
}
|
141
app/node_modules/asynckit/lib/streamify.js
generated
vendored
@ -1,141 +0,0 @@
|
||||
var async = require('./async.js');
|
||||
|
||||
// API
|
||||
module.exports = {
|
||||
iterator: wrapIterator,
|
||||
callback: wrapCallback
|
||||
};
|
||||
|
||||
/**
|
||||
* Wraps iterators with long signature
|
||||
*
|
||||
* @this ReadableAsyncKit#
|
||||
* @param {function} iterator - function to wrap
|
||||
* @returns {function} - wrapped function
|
||||
*/
|
||||
function wrapIterator(iterator)
|
||||
{
|
||||
var stream = this;
|
||||
|
||||
return function(item, key, cb)
|
||||
{
|
||||
var aborter
|
||||
, wrappedCb = async(wrapIteratorCallback.call(stream, cb, key))
|
||||
;
|
||||
|
||||
stream.jobs[key] = wrappedCb;
|
||||
|
||||
// it's either shortcut (item, cb)
|
||||
if (iterator.length == 2)
|
||||
{
|
||||
aborter = iterator(item, wrappedCb);
|
||||
}
|
||||
// or long format (item, key, cb)
|
||||
else
|
||||
{
|
||||
aborter = iterator(item, key, wrappedCb);
|
||||
}
|
||||
|
||||
return aborter;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps provided callback function
|
||||
* allowing to execute snitch function before
|
||||
* real callback
|
||||
*
|
||||
* @this ReadableAsyncKit#
|
||||
* @param {function} callback - function to wrap
|
||||
* @returns {function} - wrapped function
|
||||
*/
|
||||
function wrapCallback(callback)
|
||||
{
|
||||
var stream = this;
|
||||
|
||||
var wrapped = function(error, result)
|
||||
{
|
||||
return finisher.call(stream, error, result, callback);
|
||||
};
|
||||
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps provided iterator callback function
|
||||
* makes sure snitch only called once,
|
||||
* but passes secondary calls to the original callback
|
||||
*
|
||||
* @this ReadableAsyncKit#
|
||||
* @param {function} callback - callback to wrap
|
||||
* @param {number|string} key - iteration key
|
||||
* @returns {function} wrapped callback
|
||||
*/
|
||||
function wrapIteratorCallback(callback, key)
|
||||
{
|
||||
var stream = this;
|
||||
|
||||
return function(error, output)
|
||||
{
|
||||
// don't repeat yourself
|
||||
if (!(key in stream.jobs))
|
||||
{
|
||||
callback(error, output);
|
||||
return;
|
||||
}
|
||||
|
||||
// clean up jobs
|
||||
delete stream.jobs[key];
|
||||
|
||||
return streamer.call(stream, error, {key: key, value: output}, callback);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream wrapper for iterator callback
|
||||
*
|
||||
* @this ReadableAsyncKit#
|
||||
* @param {mixed} error - error response
|
||||
* @param {mixed} output - iterator output
|
||||
* @param {function} callback - callback that expects iterator results
|
||||
*/
|
||||
function streamer(error, output, callback)
|
||||
{
|
||||
if (error && !this.error)
|
||||
{
|
||||
this.error = error;
|
||||
this.pause();
|
||||
this.emit('error', error);
|
||||
// send back value only, as expected
|
||||
callback(error, output && output.value);
|
||||
return;
|
||||
}
|
||||
|
||||
// stream stuff
|
||||
this.push(output);
|
||||
|
||||
// back to original track
|
||||
// send back value only, as expected
|
||||
callback(error, output && output.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream wrapper for finishing callback
|
||||
*
|
||||
* @this ReadableAsyncKit#
|
||||
* @param {mixed} error - error response
|
||||
* @param {mixed} output - iterator output
|
||||
* @param {function} callback - callback that expects final results
|
||||
*/
|
||||
function finisher(error, output, callback)
|
||||
{
|
||||
// signal end of the stream
|
||||
// only for successfully finished streams
|
||||
if (!error)
|
||||
{
|
||||
this.push(null);
|
||||
}
|
||||
|
||||
// back to original track
|
||||
callback(error, output);
|
||||
}
|
29
app/node_modules/asynckit/lib/terminator.js
generated
vendored
@ -1,29 +0,0 @@
|
||||
var abort = require('./abort.js')
|
||||
, async = require('./async.js')
|
||||
;
|
||||
|
||||
// API
|
||||
module.exports = terminator;
|
||||
|
||||
/**
|
||||
* Terminates jobs in the attached state context
|
||||
*
|
||||
* @this AsyncKitState#
|
||||
* @param {function} callback - final callback to invoke after termination
|
||||
*/
|
||||
function terminator(callback)
|
||||
{
|
||||
if (!Object.keys(this.jobs).length)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// fast forward iteration index
|
||||
this.index = this.size;
|
||||
|
||||
// abort jobs
|
||||
abort(this);
|
||||
|
||||
// send back results we have so far
|
||||
async(callback)(null, this.results);
|
||||
}
|
91
app/node_modules/asynckit/package.json
generated
vendored
@ -1,91 +0,0 @@
|
||||
{
|
||||
"_from": "asynckit@^0.4.0",
|
||||
"_id": "asynckit@0.4.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
|
||||
"_location": "/asynckit",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "asynckit@^0.4.0",
|
||||
"name": "asynckit",
|
||||
"escapedName": "asynckit",
|
||||
"rawSpec": "^0.4.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.4.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/form-data"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"_shasum": "c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79",
|
||||
"_spec": "asynckit@^0.4.0",
|
||||
"_where": "/mnt/c/Users/docto/Downloads/Rappaurio/node_modules/form-data",
|
||||
"author": {
|
||||
"name": "Alex Indigo",
|
||||
"email": "iam@alexindigo.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/alexindigo/asynckit/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "Minimal async jobs utility library, with streams support",
|
||||
"devDependencies": {
|
||||
"browserify": "^13.0.0",
|
||||
"browserify-istanbul": "^2.0.0",
|
||||
"coveralls": "^2.11.9",
|
||||
"eslint": "^2.9.0",
|
||||
"istanbul": "^0.4.3",
|
||||
"obake": "^0.1.2",
|
||||
"phantomjs-prebuilt": "^2.1.7",
|
||||
"pre-commit": "^1.1.3",
|
||||
"reamde": "^1.1.0",
|
||||
"rimraf": "^2.5.2",
|
||||
"size-table": "^0.2.0",
|
||||
"tap-spec": "^4.1.1",
|
||||
"tape": "^4.5.1"
|
||||
},
|
||||
"homepage": "https://github.com/alexindigo/asynckit#readme",
|
||||
"keywords": [
|
||||
"async",
|
||||
"jobs",
|
||||
"parallel",
|
||||
"serial",
|
||||
"iterator",
|
||||
"array",
|
||||
"object",
|
||||
"stream",
|
||||
"destroy",
|
||||
"terminate",
|
||||
"abort"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "asynckit",
|
||||
"pre-commit": [
|
||||
"clean",
|
||||
"lint",
|
||||
"test",
|
||||
"browser",
|
||||
"report",
|
||||
"size"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/alexindigo/asynckit.git"
|
||||
},
|
||||
"scripts": {
|
||||
"browser": "browserify -t browserify-istanbul test/lib/browserify_adjustment.js test/test-*.js | obake --coverage | tap-spec",
|
||||
"clean": "rimraf coverage",
|
||||
"debug": "tape test/test-*.js",
|
||||
"lint": "eslint *.js lib/*.js test/*.js",
|
||||
"report": "istanbul report",
|
||||
"size": "browserify index.js | size-table asynckit",
|
||||
"test": "istanbul cover --reporter=json tape -- 'test/test-*.js' | tap-spec",
|
||||
"win-test": "tape test/test-*.js"
|
||||
},
|
||||
"version": "0.4.0"
|
||||
}
|
43
app/node_modules/asynckit/parallel.js
generated
vendored
@ -1,43 +0,0 @@
|
||||
var iterate = require('./lib/iterate.js')
|
||||
, initState = require('./lib/state.js')
|
||||
, terminator = require('./lib/terminator.js')
|
||||
;
|
||||
|
||||
// Public API
|
||||
module.exports = parallel;
|
||||
|
||||
/**
|
||||
* Runs iterator over provided array elements in parallel
|
||||
*
|
||||
* @param {array|object} list - array or object (named list) to iterate over
|
||||
* @param {function} iterator - iterator to run
|
||||
* @param {function} callback - invoked when all elements processed
|
||||
* @returns {function} - jobs terminator
|
||||
*/
|
||||
function parallel(list, iterator, callback)
|
||||
{
|
||||
var state = initState(list);
|
||||
|
||||
while (state.index < (state['keyedList'] || list).length)
|
||||
{
|
||||
iterate(list, iterator, state, function(error, result)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
callback(error, result);
|
||||
return;
|
||||
}
|
||||
|
||||
// looks like it's the last one
|
||||
if (Object.keys(state.jobs).length === 0)
|
||||
{
|
||||
callback(null, state.results);
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
state.index++;
|
||||
}
|
||||
|
||||
return terminator.bind(state, callback);
|
||||
}
|
17
app/node_modules/asynckit/serial.js
generated
vendored
@ -1,17 +0,0 @@
|
||||
var serialOrdered = require('./serialOrdered.js');
|
||||
|
||||
// Public API
|
||||
module.exports = serial;
|
||||
|
||||
/**
|
||||
* Runs iterator over provided array elements in series
|
||||
*
|
||||
* @param {array|object} list - array or object (named list) to iterate over
|
||||
* @param {function} iterator - iterator to run
|
||||
* @param {function} callback - invoked when all elements processed
|
||||
* @returns {function} - jobs terminator
|
||||
*/
|
||||
function serial(list, iterator, callback)
|
||||
{
|
||||
return serialOrdered(list, iterator, null, callback);
|
||||
}
|
75
app/node_modules/asynckit/serialOrdered.js
generated
vendored
@ -1,75 +0,0 @@
|
||||
var iterate = require('./lib/iterate.js')
|
||||
, initState = require('./lib/state.js')
|
||||
, terminator = require('./lib/terminator.js')
|
||||
;
|
||||
|
||||
// Public API
|
||||
module.exports = serialOrdered;
|
||||
// sorting helpers
|
||||
module.exports.ascending = ascending;
|
||||
module.exports.descending = descending;
|
||||
|
||||
/**
|
||||
* Runs iterator over provided sorted array elements in series
|
||||
*
|
||||
* @param {array|object} list - array or object (named list) to iterate over
|
||||
* @param {function} iterator - iterator to run
|
||||
* @param {function} sortMethod - custom sort function
|
||||
* @param {function} callback - invoked when all elements processed
|
||||
* @returns {function} - jobs terminator
|
||||
*/
|
||||
function serialOrdered(list, iterator, sortMethod, callback)
|
||||
{
|
||||
var state = initState(list, sortMethod);
|
||||
|
||||
iterate(list, iterator, state, function iteratorHandler(error, result)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
callback(error, result);
|
||||
return;
|
||||
}
|
||||
|
||||
state.index++;
|
||||
|
||||
// are we there yet?
|
||||
if (state.index < (state['keyedList'] || list).length)
|
||||
{
|
||||
iterate(list, iterator, state, iteratorHandler);
|
||||
return;
|
||||
}
|
||||
|
||||
// done here
|
||||
callback(null, state.results);
|
||||
});
|
||||
|
||||
return terminator.bind(state, callback);
|
||||
}
|
||||
|
||||
/*
|
||||
* -- Sort methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* sort helper to sort array elements in ascending order
|
||||
*
|
||||
* @param {mixed} a - an item to compare
|
||||
* @param {mixed} b - an item to compare
|
||||
* @returns {number} - comparison result
|
||||
*/
|
||||
function ascending(a, b)
|
||||
{
|
||||
return a < b ? -1 : a > b ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* sort helper to sort array elements in descending order
|
||||
*
|
||||
* @param {mixed} a - an item to compare
|
||||
* @param {mixed} b - an item to compare
|
||||
* @returns {number} - comparison result
|
||||
*/
|
||||
function descending(a, b)
|
||||
{
|
||||
return -1 * ascending(a, b);
|
||||
}
|
21
app/node_modules/asynckit/stream.js
generated
vendored
@ -1,21 +0,0 @@
|
||||
var inherits = require('util').inherits
|
||||
, Readable = require('stream').Readable
|
||||
, ReadableAsyncKit = require('./lib/readable_asynckit.js')
|
||||
, ReadableParallel = require('./lib/readable_parallel.js')
|
||||
, ReadableSerial = require('./lib/readable_serial.js')
|
||||
, ReadableSerialOrdered = require('./lib/readable_serial_ordered.js')
|
||||
;
|
||||
|
||||
// API
|
||||
module.exports =
|
||||
{
|
||||
parallel : ReadableParallel,
|
||||
serial : ReadableSerial,
|
||||
serialOrdered : ReadableSerialOrdered,
|
||||
};
|
||||
|
||||
inherits(ReadableAsyncKit, Readable);
|
||||
|
||||
inherits(ReadableParallel, ReadableAsyncKit);
|
||||
inherits(ReadableSerial, ReadableAsyncKit);
|
||||
inherits(ReadableSerialOrdered, ReadableAsyncKit);
|
565
app/node_modules/axios/CHANGELOG.md
generated
vendored
@ -1,565 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
# [1.5.0](https://github.com/axios/axios/compare/v1.4.0...v1.5.0) (2023-08-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **adapter:** make adapter loading error more clear by using platform-specific adapters explicitly ([#5837](https://github.com/axios/axios/issues/5837)) ([9a414bb](https://github.com/axios/axios/commit/9a414bb6c81796a95c6c7fe668637825458e8b6d))
|
||||
* **dns:** fixed `cacheable-lookup` integration; ([#5836](https://github.com/axios/axios/issues/5836)) ([b3e327d](https://github.com/axios/axios/commit/b3e327dcc9277bdce34c7ef57beedf644b00d628))
|
||||
* **headers:** added support for setting header names that overlap with class methods; ([#5831](https://github.com/axios/axios/issues/5831)) ([d8b4ca0](https://github.com/axios/axios/commit/d8b4ca0ea5f2f05efa4edfe1e7684593f9f68273))
|
||||
* **headers:** fixed common Content-Type header merging; ([#5832](https://github.com/axios/axios/issues/5832)) ([8fda276](https://github.com/axios/axios/commit/8fda2766b1e6bcb72c3fabc146223083ef13ce17))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* export getAdapter function ([#5324](https://github.com/axios/axios/issues/5324)) ([ca73eb8](https://github.com/axios/axios/commit/ca73eb878df0ae2dace81fe3a7f1fb5986231bf1))
|
||||
* **export:** export adapters without `unsafe` prefix ([#5839](https://github.com/axios/axios/issues/5839)) ([1601f4a](https://github.com/axios/axios/commit/1601f4a27a81ab47fea228f1e244b2c4e3ce28bf))
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+66/-29 (#5839 #5837 #5836 #5832 #5831 )")
|
||||
- <img src="https://avatars.githubusercontent.com/u/102841186?v=4&s=18" alt="avatar" width="18"/> [夜葬](https://github.com/geekact "+42/-0 (#5324 )")
|
||||
- <img src="https://avatars.githubusercontent.com/u/65978976?v=4&s=18" alt="avatar" width="18"/> [Jonathan Budiman](https://github.com/JBudiman00 "+30/-0 (#5788 )")
|
||||
- <img src="https://avatars.githubusercontent.com/u/5492927?v=4&s=18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+3/-5 (#5791 )")
|
||||
|
||||
# [1.4.0](https://github.com/axios/axios/compare/v1.3.6...v1.4.0) (2023-04-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **formdata:** add `multipart/form-data` content type for FormData payload on custom client environments; ([#5678](https://github.com/axios/axios/issues/5678)) ([bbb61e7](https://github.com/axios/axios/commit/bbb61e70cb1185adfb1cbbb86eaf6652c48d89d1))
|
||||
* **package:** export package internals with unsafe path prefix; ([#5677](https://github.com/axios/axios/issues/5677)) ([df38c94](https://github.com/axios/axios/commit/df38c949f26414d88ba29ec1e353c4d4f97eaf09))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **dns:** added support for a custom lookup function; ([#5339](https://github.com/axios/axios/issues/5339)) ([2701911](https://github.com/axios/axios/commit/2701911260a1faa5cc5e1afe437121b330a3b7bb))
|
||||
* **types:** export `AxiosHeaderValue` type. ([#5525](https://github.com/axios/axios/issues/5525)) ([726f1c8](https://github.com/axios/axios/commit/726f1c8e00cffa0461a8813a9bdcb8f8b9d762cf))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **merge-config:** optimize mergeConfig performance by avoiding duplicate key visits; ([#5679](https://github.com/axios/axios/issues/5679)) ([e6f7053](https://github.com/axios/axios/commit/e6f7053bf1a3e87cf1f9da8677e12e3fe829d68e))
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+151/-16 (#5684 #5339 #5679 #5678 #5677 )")
|
||||
- <img src="https://avatars.githubusercontent.com/u/47537704?v=4&s=18" alt="avatar" width="18"/> [Arthur Fiorette](https://github.com/arthurfiorette "+19/-19 (#5525 )")
|
||||
- <img src="https://avatars.githubusercontent.com/u/43876655?v=4&s=18" alt="avatar" width="18"/> [PIYUSH NEGI](https://github.com/npiyush97 "+2/-18 (#5670 )")
|
||||
|
||||
## [1.3.6](https://github.com/axios/axios/compare/v1.3.5...v1.3.6) (2023-04-19)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **types:** added transport to RawAxiosRequestConfig ([#5445](https://github.com/axios/axios/issues/5445)) ([6f360a2](https://github.com/axios/axios/commit/6f360a2531d8d70363fd9becef6a45a323f170e2))
|
||||
* **utils:** make isFormData detection logic stricter to avoid unnecessary calling of the `toString` method on the target; ([#5661](https://github.com/axios/axios/issues/5661)) ([aa372f7](https://github.com/axios/axios/commit/aa372f7306295dfd1100c1c2c77ce95c95808e76))
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+48/-10 (#5665 #5661 #5663 )")
|
||||
- <img src="https://avatars.githubusercontent.com/u/5492927?v=4&s=18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+2/-0 (#5445 )")
|
||||
|
||||
## [1.3.5](https://github.com/axios/axios/compare/v1.3.4...v1.3.5) (2023-04-05)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **headers:** fixed isValidHeaderName to support full list of allowed characters; ([#5584](https://github.com/axios/axios/issues/5584)) ([e7decef](https://github.com/axios/axios/commit/e7decef6a99f4627e27ed9ea5b00ce8e201c3841))
|
||||
* **params:** re-added the ability to set the function as `paramsSerializer` config; ([#5633](https://github.com/axios/axios/issues/5633)) ([a56c866](https://github.com/axios/axios/commit/a56c8661209d5ce5a645a05f294a0e08a6c1f6b3))
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+28/-10 (#5633 #5584 )")
|
||||
|
||||
## [1.3.4](https://github.com/axios/axios/compare/v1.3.3...v1.3.4) (2023-02-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **blob:** added a check to make sure the Blob class is available in the browser's global scope; ([#5548](https://github.com/axios/axios/issues/5548)) ([3772c8f](https://github.com/axios/axios/commit/3772c8fe74112a56e3e9551f894d899bc3a9443a))
|
||||
* **http:** fixed regression bug when handling synchronous errors inside the adapter; ([#5564](https://github.com/axios/axios/issues/5564)) ([a3b246c](https://github.com/axios/axios/commit/a3b246c9de5c3bc4b5a742e15add55b375479451))
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+38/-26 (#5564 )")
|
||||
- <img src="https://avatars.githubusercontent.com/u/19550000?v=4&s=18" alt="avatar" width="18"/> [lcysgsg](https://github.com/lcysgsg "+4/-0 (#5548 )")
|
||||
- <img src="https://avatars.githubusercontent.com/u/5492927?v=4&s=18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+3/-0 (#5444 )")
|
||||
|
||||
## [1.3.3](https://github.com/axios/axios/compare/v1.3.2...v1.3.3) (2023-02-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **formdata:** added a check to make sure the FormData class is available in the browser's global scope; ([#5545](https://github.com/axios/axios/issues/5545)) ([a6dfa72](https://github.com/axios/axios/commit/a6dfa72010db5ad52db8bd13c0f98e537e8fd05d))
|
||||
* **formdata:** fixed setting NaN as Content-Length for form payload in some cases; ([#5535](https://github.com/axios/axios/issues/5535)) ([c19f7bf](https://github.com/axios/axios/commit/c19f7bf770f90ae8307f4ea3104f227056912da1))
|
||||
* **headers:** fixed the filtering logic of the clear method; ([#5542](https://github.com/axios/axios/issues/5542)) ([ea87ebf](https://github.com/axios/axios/commit/ea87ebfe6d1699af072b9e7cd40faf8f14b0ab93))
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+11/-7 (#5545 #5535 #5542 )")
|
||||
- <img src="https://avatars.githubusercontent.com/u/19842213?v=4&s=18" alt="avatar" width="18"/> [陈若枫](https://github.com/ruofee "+2/-2 (#5467 )")
|
||||
|
||||
## [1.3.2](https://github.com/axios/axios/compare/v1.3.1...v1.3.2) (2023-02-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **http:** treat http://localhost as base URL for relative paths to avoid `ERR_INVALID_URL` error; ([#5528](https://github.com/axios/axios/issues/5528)) ([128d56f](https://github.com/axios/axios/commit/128d56f4a0fb8f5f2ed6e0dd80bc9225fee9538c))
|
||||
* **http:** use explicit import instead of TextEncoder global; ([#5530](https://github.com/axios/axios/issues/5530)) ([6b3c305](https://github.com/axios/axios/commit/6b3c305fc40c56428e0afabedc6f4d29c2830f6f))
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+2/-1 (#5530 #5528 )")
|
||||
|
||||
## [1.3.1](https://github.com/axios/axios/compare/v1.3.0...v1.3.1) (2023-02-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **formdata:** add hotfix to use the asynchronous API to compute the content-length header value; ([#5521](https://github.com/axios/axios/issues/5521)) ([96d336f](https://github.com/axios/axios/commit/96d336f527619f21da012fe1f117eeb53e5a2120))
|
||||
* **serializer:** fixed serialization of array-like objects; ([#5518](https://github.com/axios/axios/issues/5518)) ([08104c0](https://github.com/axios/axios/commit/08104c028c0f9353897b1b6691d74c440fd0c32d))
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+27/-8 (#5521 #5518 )")
|
||||
|
||||
# [1.3.0](https://github.com/axios/axios/compare/v1.2.6...v1.3.0) (2023-01-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **headers:** fixed & optimized clear method; ([#5507](https://github.com/axios/axios/issues/5507)) ([9915635](https://github.com/axios/axios/commit/9915635c69d0ab70daca5738488421f67ca60959))
|
||||
* **http:** add zlib headers if missing ([#5497](https://github.com/axios/axios/issues/5497)) ([65e8d1e](https://github.com/axios/axios/commit/65e8d1e28ce829f47a837e45129730e541950d3c))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **fomdata:** added support for spec-compliant FormData & Blob types; ([#5316](https://github.com/axios/axios/issues/5316)) ([6ac574e](https://github.com/axios/axios/commit/6ac574e00a06731288347acea1e8246091196953))
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+352/-67 (#5514 #5512 #5510 #5509 #5508 #5316 #5507 )")
|
||||
- <img src="https://avatars.githubusercontent.com/u/35015993?v=4&s=18" alt="avatar" width="18"/> [ItsNotGoodName](https://github.com/ItsNotGoodName "+43/-2 (#5497 )")
|
||||
|
||||
## [1.2.6](https://github.com/axios/axios/compare/v1.2.5...v1.2.6) (2023-01-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **headers:** added missed Authorization accessor; ([#5502](https://github.com/axios/axios/issues/5502)) ([342c0ba](https://github.com/axios/axios/commit/342c0ba9a16ea50f5ed7d2366c5c1a2c877e3f26))
|
||||
* **types:** fixed `CommonRequestHeadersList` & `CommonResponseHeadersList` types to be private in commonJS; ([#5503](https://github.com/axios/axios/issues/5503)) ([5a3d0a3](https://github.com/axios/axios/commit/5a3d0a3234d77361a1bc7cedee2da1e11df08e2c))
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
-  [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+24/-9 (#5503 #5502 )")
|
||||
|
||||
## [1.2.5](https://github.com/axios/axios/compare/v1.2.4...v1.2.5) (2023-01-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **types:** fixed AxiosHeaders to handle spread syntax by making all methods non-enumerable; ([#5499](https://github.com/axios/axios/issues/5499)) ([580f1e8](https://github.com/axios/axios/commit/580f1e8033a61baa38149d59fd16019de3932c22))
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
-  [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+82/-54 (#5499 )")
|
||||
-  [Elliot Ford](https://github.com/EFord36 "+1/-1 (#5462 )")
|
||||
|
||||
## [1.2.4](https://github.com/axios/axios/compare/v1.2.3...v1.2.4) (2023-01-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **types:** renamed `RawAxiosRequestConfig` back to `AxiosRequestConfig`; ([#5486](https://github.com/axios/axios/issues/5486)) ([2a71f49](https://github.com/axios/axios/commit/2a71f49bc6c68495fa419003a3107ed8bd703ad0))
|
||||
* **types:** fix `AxiosRequestConfig` generic; ([#5478](https://github.com/axios/axios/issues/5478)) ([9bce81b](https://github.com/axios/axios/commit/186ea062da8b7d578ae78b1a5c220986b9bce81b))
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
-  [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+242/-108 (#5486 #5482 )")
|
||||
-  [Daniel Hillmann](https://github.com/hilleer "+1/-1 (#5478 )")
|
||||
|
||||
## [1.2.3](https://github.com/axios/axios/compare/1.2.2...1.2.3) (2023-01-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **types:** fixed AxiosRequestConfig header interface by refactoring it to RawAxiosRequestConfig; ([#5420](https://github.com/axios/axios/issues/5420)) ([0811963](https://github.com/axios/axios/commit/08119634a22f1d5b19f5c9ea0adccb6d3eebc3bc))
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
-  [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+938/-442 (#5456 #5455 #5453 #5451 #5449 #5447 #5446 #5443 #5442 #5439 #5420 )")
|
||||
|
||||
## [1.2.2] - 2022-12-29
|
||||
|
||||
### Fixed
|
||||
- fix(ci): fix release script inputs [#5392](https://github.com/axios/axios/pull/5392)
|
||||
- fix(ci): prerelease scipts [#5377](https://github.com/axios/axios/pull/5377)
|
||||
- fix(ci): release scripts [#5376](https://github.com/axios/axios/pull/5376)
|
||||
- fix(ci): typescript tests [#5375](https://github.com/axios/axios/pull/5375)
|
||||
- fix: Brotli decompression [#5353](https://github.com/axios/axios/pull/5353)
|
||||
- fix: add missing HttpStatusCode [#5345](https://github.com/axios/axios/pull/5345)
|
||||
|
||||
### Chores
|
||||
- chore(ci): set conventional-changelog header config [#5406](https://github.com/axios/axios/pull/5406)
|
||||
- chore(ci): fix automatic contributors resolving [#5403](https://github.com/axios/axios/pull/5403)
|
||||
- chore(ci): improved logging for the contributors list generator [#5398](https://github.com/axios/axios/pull/5398)
|
||||
- chore(ci): fix release action [#5397](https://github.com/axios/axios/pull/5397)
|
||||
- chore(ci): fix version bump script by adding bump argument for target version [#5393](https://github.com/axios/axios/pull/5393)
|
||||
- chore(deps): bump decode-uri-component from 0.2.0 to 0.2.2 [#5342](https://github.com/axios/axios/pull/5342)
|
||||
- chore(ci): GitHub Actions Release script [#5384](https://github.com/axios/axios/pull/5384)
|
||||
- chore(ci): release scripts [#5364](https://github.com/axios/axios/pull/5364)
|
||||
|
||||
### Contributors to this release
|
||||
-  [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS)
|
||||
-  [Winnie](https://github.com/winniehell)
|
||||
|
||||
## [1.2.1] - 2022-12-05
|
||||
|
||||
### Changed
|
||||
- feat(exports): export mergeConfig [#5151](https://github.com/axios/axios/pull/5151)
|
||||
|
||||
### Fixed
|
||||
- fix(CancelledError): include config [#4922](https://github.com/axios/axios/pull/4922)
|
||||
- fix(general): removing multiple/trailing/leading whitespace [#5022](https://github.com/axios/axios/pull/5022)
|
||||
- fix(headers): decompression for responses without Content-Length header [#5306](https://github.com/axios/axios/pull/5306)
|
||||
- fix(webWorker): exception to sending form data in web worker [#5139](https://github.com/axios/axios/pull/5139)
|
||||
|
||||
### Refactors
|
||||
- refactor(types): AxiosProgressEvent.event type to any [#5308](https://github.com/axios/axios/pull/5308)
|
||||
- refactor(types): add missing types for static AxiosError.from method [#4956](https://github.com/axios/axios/pull/4956)
|
||||
|
||||
### Chores
|
||||
- chore(docs): remove README link to non-existent upgrade guide [#5307](https://github.com/axios/axios/pull/5307)
|
||||
- chore(docs): typo in issue template name [#5159](https://github.com/axios/axios/pull/5159)
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS)
|
||||
- [Zachary Lysobey](https://github.com/zachlysobey)
|
||||
- [Kevin Ennis](https://github.com/kevincennis)
|
||||
- [Philipp Loose](https://github.com/phloose)
|
||||
- [secondl1ght](https://github.com/secondl1ght)
|
||||
- [wenzheng](https://github.com/0x30)
|
||||
- [Ivan Barsukov](https://github.com/ovarn)
|
||||
- [Arthur Fiorette](https://github.com/arthurfiorette)
|
||||
|
||||
## [1.2.0] - 2022-11-10
|
||||
|
||||
### Changed
|
||||
|
||||
- changed: refactored module exports [#5162](https://github.com/axios/axios/pull/5162)
|
||||
- change: re-added support for loading Axios with require('axios').default [#5225](https://github.com/axios/axios/pull/5225)
|
||||
|
||||
### Fixed
|
||||
|
||||
- fix: improve AxiosHeaders class [#5224](https://github.com/axios/axios/pull/5224)
|
||||
- fix: TypeScript type definitions for commonjs [#5196](https://github.com/axios/axios/pull/5196)
|
||||
- fix: type definition of use method on AxiosInterceptorManager to match the the README [#5071](https://github.com/axios/axios/pull/5071)
|
||||
- fix: __dirname is not defined in the sandbox [#5269](https://github.com/axios/axios/pull/5269)
|
||||
- fix: AxiosError.toJSON method to avoid circular references [#5247](https://github.com/axios/axios/pull/5247)
|
||||
- fix: Z_BUF_ERROR when content-encoding is set but the response body is empty [#5250](https://github.com/axios/axios/pull/5250)
|
||||
|
||||
### Refactors
|
||||
- refactor: allowing adapters to be loaded by name [#5277](https://github.com/axios/axios/pull/5277)
|
||||
|
||||
### Chores
|
||||
|
||||
- chore: force CI restart [#5243](https://github.com/axios/axios/pull/5243)
|
||||
- chore: update ECOSYSTEM.md [#5077](https://github.com/axios/axios/pull/5077)
|
||||
- chore: update get/index.html [#5116](https://github.com/axios/axios/pull/5116)
|
||||
- chore: update Sandbox UI/UX [#5205](https://github.com/axios/axios/pull/5205)
|
||||
- chore:(actions): remove git credentials after checkout [#5235](https://github.com/axios/axios/pull/5235)
|
||||
- chore(actions): bump actions/dependency-review-action from 2 to 3 [#5266](https://github.com/axios/axios/pull/5266)
|
||||
- chore(packages): bump loader-utils from 1.4.1 to 1.4.2 [#5295](https://github.com/axios/axios/pull/5295)
|
||||
- chore(packages): bump engine.io from 6.2.0 to 6.2.1 [#5294](https://github.com/axios/axios/pull/5294)
|
||||
- chore(packages): bump socket.io-parser from 4.0.4 to 4.0.5 [#5241](https://github.com/axios/axios/pull/5241)
|
||||
- chore(packages): bump loader-utils from 1.4.0 to 1.4.1 [#5245](https://github.com/axios/axios/pull/5245)
|
||||
- chore(docs): update Resources links in README [#5119](https://github.com/axios/axios/pull/5119)
|
||||
- chore(docs): update the link for JSON url [#5265](https://github.com/axios/axios/pull/5265)
|
||||
- chore(docs): fix broken links [#5218](https://github.com/axios/axios/pull/5218)
|
||||
- chore(docs): update and rename UPGRADE_GUIDE.md to MIGRATION_GUIDE.md [#5170](https://github.com/axios/axios/pull/5170)
|
||||
- chore(docs): typo fix line #856 and #920 [#5194](https://github.com/axios/axios/pull/5194)
|
||||
- chore(docs): typo fix #800 [#5193](https://github.com/axios/axios/pull/5193)
|
||||
- chore(docs): fix typos [#5184](https://github.com/axios/axios/pull/5184)
|
||||
- chore(docs): fix punctuation in README.md [#5197](https://github.com/axios/axios/pull/5197)
|
||||
- chore(docs): update readme in the Handling Errors section - issue reference #5260 [#5261](https://github.com/axios/axios/pull/5261)
|
||||
- chore: remove \b from filename [#5207](https://github.com/axios/axios/pull/5207)
|
||||
- chore(docs): update CHANGELOG.md [#5137](https://github.com/axios/axios/pull/5137)
|
||||
- chore: add sideEffects false to package.json [#5025](https://github.com/axios/axios/pull/5025)
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
- [Maddy Miller](https://github.com/me4502)
|
||||
- [Amit Saini](https://github.com/amitsainii)
|
||||
- [ecyrbe](https://github.com/ecyrbe)
|
||||
- [Ikko Ashimine](https://github.com/eltociear)
|
||||
- [Geeth Gunnampalli](https://github.com/thetechie7)
|
||||
- [Shreem Asati](https://github.com/shreem-123)
|
||||
- [Frieder Bluemle](https://github.com/friederbluemle)
|
||||
- [윤세영](https://github.com/yunseyeong)
|
||||
- [Claudio Busatto](https://github.com/cjcbusatto)
|
||||
- [Remco Haszing](https://github.com/remcohaszing)
|
||||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS)
|
||||
- [Csaba Maulis](https://github.com/om4csaba)
|
||||
- [MoPaMo](https://github.com/MoPaMo)
|
||||
- [Daniel Fjeldstad](https://github.com/w3bdesign)
|
||||
- [Adrien Brunet](https://github.com/adrien-may)
|
||||
- [Frazer Smith](https://github.com/Fdawgs)
|
||||
- [HaiTao](https://github.com/836334258)
|
||||
- [AZM](https://github.com/aziyatali)
|
||||
- [relbns](https://github.com/relbns)
|
||||
|
||||
## [1.1.3] - 2022-10-15
|
||||
|
||||
### Added
|
||||
|
||||
- Added custom params serializer support [#5113](https://github.com/axios/axios/pull/5113)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed top-level export to keep them in-line with static properties [#5109](https://github.com/axios/axios/pull/5109)
|
||||
- Stopped including null values to query string. [#5108](https://github.com/axios/axios/pull/5108)
|
||||
- Restored proxy config backwards compatibility with 0.x [#5097](https://github.com/axios/axios/pull/5097)
|
||||
- Added back AxiosHeaders in AxiosHeaderValue [#5103](https://github.com/axios/axios/pull/5103)
|
||||
- Pin CDN install instructions to a specific version [#5060](https://github.com/axios/axios/pull/5060)
|
||||
- Handling of array values fixed for AxiosHeaders [#5085](https://github.com/axios/axios/pull/5085)
|
||||
|
||||
### Chores
|
||||
|
||||
- docs: match badge style, add link to them [#5046](https://github.com/axios/axios/pull/5046)
|
||||
- chore: fixing comments typo [#5054](https://github.com/axios/axios/pull/5054)
|
||||
- chore: update issue template [#5061](https://github.com/axios/axios/pull/5061)
|
||||
- chore: added progress capturing section to the docs; [#5084](https://github.com/axios/axios/pull/5084)
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
- [Jason Saayman](https://github.com/jasonsaayman)
|
||||
- [scarf](https://github.com/scarf005)
|
||||
- [Lenz Weber-Tronic](https://github.com/phryneas)
|
||||
- [Arvindh](https://github.com/itsarvindh)
|
||||
- [Félix Legrelle](https://github.com/FelixLgr)
|
||||
- [Patrick Petrovic](https://github.com/ppati000)
|
||||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS)
|
||||
- [littledian](https://github.com/littledian)
|
||||
- [ChronosMasterOfAllTime](https://github.com/ChronosMasterOfAllTime)
|
||||
|
||||
## [1.1.2] - 2022-10-07
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed broken exports for UMD builds.
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
- [Jason Saayman](https://github.com/jasonsaayman)
|
||||
|
||||
## [1.1.1] - 2022-10-07
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed broken exports for common js. This fix breaks a prior fix, I will fix both issues ASAP but the commonJS use is more impactful.
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
- [Jason Saayman](https://github.com/jasonsaayman)
|
||||
|
||||
## [1.1.0] - 2022-10-06
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed missing exports in type definition index.d.ts [#5003](https://github.com/axios/axios/pull/5003)
|
||||
- Fixed query params composing [#5018](https://github.com/axios/axios/pull/5018)
|
||||
- Fixed GenericAbortSignal interface by making it more generic [#5021](https://github.com/axios/axios/pull/5021)
|
||||
- Fixed adding "clear" to AxiosInterceptorManager [#5010](https://github.com/axios/axios/pull/5010)
|
||||
- Fixed commonjs & umd exports [#5030](https://github.com/axios/axios/pull/5030)
|
||||
- Fixed inability to access response headers when using axios 1.x with Jest [#5036](https://github.com/axios/axios/pull/5036)
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
- [Trim21](https://github.com/trim21)
|
||||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS)
|
||||
- [shingo.sasaki](https://github.com/s-sasaki-0529)
|
||||
- [Ivan Pepelko](https://github.com/ivanpepelko)
|
||||
- [Richard Kořínek](https://github.com/risa)
|
||||
|
||||
## [1.0.0] - 2022-10-04
|
||||
|
||||
### Added
|
||||
|
||||
- Added stack trace to AxiosError [#4624](https://github.com/axios/axios/pull/4624)
|
||||
- Add AxiosError to AxiosStatic [#4654](https://github.com/axios/axios/pull/4654)
|
||||
- Replaced Rollup as our build runner [#4596](https://github.com/axios/axios/pull/4596)
|
||||
- Added generic TS types for the exposed toFormData helper [#4668](https://github.com/axios/axios/pull/4668)
|
||||
- Added listen callback function [#4096](https://github.com/axios/axios/pull/4096)
|
||||
- Added instructions for installing using PNPM [#4207](https://github.com/axios/axios/pull/4207)
|
||||
- Added generic AxiosAbortSignal TS interface to avoid importing AbortController polyfill [#4229](https://github.com/axios/axios/pull/4229)
|
||||
- Added axios-url-template in ECOSYSTEM.md [#4238](https://github.com/axios/axios/pull/4238)
|
||||
- Added a clear() function to the request and response interceptors object so a user can ensure that all interceptors have been removed from an axios instance [#4248](https://github.com/axios/axios/pull/4248)
|
||||
- Added react hook plugin [#4319](https://github.com/axios/axios/pull/4319)
|
||||
- Adding HTTP status code for transformResponse [#4580](https://github.com/axios/axios/pull/4580)
|
||||
- Added blob to the list of protocols supported by the browser [#4678](https://github.com/axios/axios/pull/4678)
|
||||
- Resolving proxy from env on redirect [#4436](https://github.com/axios/axios/pull/4436)
|
||||
- Added enhanced toFormData implementation with additional options [4704](https://github.com/axios/axios/pull/4704)
|
||||
- Adding Canceler parameters config and request [#4711](https://github.com/axios/axios/pull/4711)
|
||||
- Added automatic payload serialization to application/x-www-form-urlencoded [#4714](https://github.com/axios/axios/pull/4714)
|
||||
- Added the ability for webpack users to overwrite built-ins [#4715](https://github.com/axios/axios/pull/4715)
|
||||
- Added string[] to AxiosRequestHeaders type [#4322](https://github.com/axios/axios/pull/4322)
|
||||
- Added the ability for the url-encoded-form serializer to respect the formSerializer config [#4721](https://github.com/axios/axios/pull/4721)
|
||||
- Added isCancel type assert [#4293](https://github.com/axios/axios/pull/4293)
|
||||
- Added data URL support for node.js [#4725](https://github.com/axios/axios/pull/4725)
|
||||
- Adding types for progress event callbacks [#4675](https://github.com/axios/axios/pull/4675)
|
||||
- URL params serializer [#4734](https://github.com/axios/axios/pull/4734)
|
||||
- Added axios.formToJSON method [#4735](https://github.com/axios/axios/pull/4735)
|
||||
- Bower platform add data protocol [#4804](https://github.com/axios/axios/pull/4804)
|
||||
- Use WHATWG URL API instead of url.parse() [#4852](https://github.com/axios/axios/pull/4852)
|
||||
- Add ENUM containing Http Status Codes to typings [#4903](https://github.com/axios/axios/pull/4903)
|
||||
- Improve typing of timeout in index.d.ts [#4934](https://github.com/axios/axios/pull/4934)
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated AxiosError.config to be optional in the type definition [#4665](https://github.com/axios/axios/pull/4665)
|
||||
- Updated README emphasizing the URLSearchParam built-in interface over other solutions [#4590](https://github.com/axios/axios/pull/4590)
|
||||
- Include request and config when creating a CanceledError instance [#4659](https://github.com/axios/axios/pull/4659)
|
||||
- Changed func-names eslint rule to as-needed [#4492](https://github.com/axios/axios/pull/4492)
|
||||
- Replacing deprecated substr() with slice() as substr() is deprecated [#4468](https://github.com/axios/axios/pull/4468)
|
||||
- Updating HTTP links in README.md to use HTTPS [#4387](https://github.com/axios/axios/pull/4387)
|
||||
- Updated to a better trim() polyfill [#4072](https://github.com/axios/axios/pull/4072)
|
||||
- Updated types to allow specifying partial default headers on instance create [#4185](https://github.com/axios/axios/pull/4185)
|
||||
- Expanded isAxiosError types [#4344](https://github.com/axios/axios/pull/4344)
|
||||
- Updated type definition for axios instance methods [#4224](https://github.com/axios/axios/pull/4224)
|
||||
- Updated eslint config [#4722](https://github.com/axios/axios/pull/4722)
|
||||
- Updated Docs [#4742](https://github.com/axios/axios/pull/4742)
|
||||
- Refactored Axios to use ES2017 [#4787](https://github.com/axios/axios/pull/4787)
|
||||
|
||||
|
||||
### Deprecated
|
||||
- There are multiple deprecations, refactors and fixes provided in this release. Please read through the full release notes to see how this may impact your project and use case.
|
||||
|
||||
### Removed
|
||||
|
||||
- Removed incorrect argument for NetworkError constructor [#4656](https://github.com/axios/axios/pull/4656)
|
||||
- Removed Webpack [#4596](https://github.com/axios/axios/pull/4596)
|
||||
- Removed function that transform arguments to array [#4544](https://github.com/axios/axios/pull/4544)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed grammar in README [#4649](https://github.com/axios/axios/pull/4649)
|
||||
- Fixed code error in README [#4599](https://github.com/axios/axios/pull/4599)
|
||||
- Optimized the code that checks cancellation [#4587](https://github.com/axios/axios/pull/4587)
|
||||
- Fix url pointing to defaults.js in README [#4532](https://github.com/axios/axios/pull/4532)
|
||||
- Use type alias instead of interface for AxiosPromise [#4505](https://github.com/axios/axios/pull/4505)
|
||||
- Fix some word spelling and lint style in code comments [#4500](https://github.com/axios/axios/pull/4500)
|
||||
- Edited readme with 3 updated browser icons of Chrome, FireFox and Safari [#4414](https://github.com/axios/axios/pull/4414)
|
||||
- Bump follow-redirects from 1.14.9 to 1.15.0 [#4673](https://github.com/axios/axios/pull/4673)
|
||||
- Fixing http tests to avoid hanging when assertions fail [#4435](https://github.com/axios/axios/pull/4435)
|
||||
- Fix TS definition for AxiosRequestTransformer [#4201](https://github.com/axios/axios/pull/4201)
|
||||
- Fix grammatical issues in README [#4232](https://github.com/axios/axios/pull/4232)
|
||||
- Fixing instance.defaults.headers type [#4557](https://github.com/axios/axios/pull/4557)
|
||||
- Fixed race condition on immediate requests cancellation [#4261](https://github.com/axios/axios/pull/4261)
|
||||
- Fixing Z_BUF_ERROR when no content [#4701](https://github.com/axios/axios/pull/4701)
|
||||
- Fixing proxy beforeRedirect regression [#4708](https://github.com/axios/axios/pull/4708)
|
||||
- Fixed AxiosError status code type [#4717](https://github.com/axios/axios/pull/4717)
|
||||
- Fixed AxiosError stack capturing [#4718](https://github.com/axios/axios/pull/4718)
|
||||
- Fixing AxiosRequestHeaders typings [#4334](https://github.com/axios/axios/pull/4334)
|
||||
- Fixed max body length defaults [#4731](https://github.com/axios/axios/pull/4731)
|
||||
- Fixed toFormData Blob issue on node>v17 [#4728](https://github.com/axios/axios/pull/4728)
|
||||
- Bump grunt from 1.5.2 to 1.5.3 [#4743](https://github.com/axios/axios/pull/4743)
|
||||
- Fixing content-type header repeated [#4745](https://github.com/axios/axios/pull/4745)
|
||||
- Fixed timeout error message for http [4738](https://github.com/axios/axios/pull/4738)
|
||||
- Request ignores false, 0 and empty string as body values [#4785](https://github.com/axios/axios/pull/4785)
|
||||
- Added back missing minified builds [#4805](https://github.com/axios/axios/pull/4805)
|
||||
- Fixed a type error [#4815](https://github.com/axios/axios/pull/4815)
|
||||
- Fixed a regression bug with unsubscribing from cancel token; [#4819](https://github.com/axios/axios/pull/4819)
|
||||
- Remove repeated compression algorithm [#4820](https://github.com/axios/axios/pull/4820)
|
||||
- The error of calling extend to pass parameters [#4857](https://github.com/axios/axios/pull/4857)
|
||||
- SerializerOptions.indexes allows boolean | null | undefined [#4862](https://github.com/axios/axios/pull/4862)
|
||||
- Require interceptors to return values [#4874](https://github.com/axios/axios/pull/4874)
|
||||
- Removed unused imports [#4949](https://github.com/axios/axios/pull/4949)
|
||||
- Allow null indexes on formSerializer and paramsSerializer [#4960](https://github.com/axios/axios/pull/4960)
|
||||
|
||||
### Chores
|
||||
- Set permissions for GitHub actions [#4765](https://github.com/axios/axios/pull/4765)
|
||||
- Included githubactions in the dependabot config [#4770](https://github.com/axios/axios/pull/4770)
|
||||
- Included dependency review [#4771](https://github.com/axios/axios/pull/4771)
|
||||
- Update security.md [#4784](https://github.com/axios/axios/pull/4784)
|
||||
- Remove unnecessary spaces [#4854](https://github.com/axios/axios/pull/4854)
|
||||
- Simplify the import path of AxiosError [#4875](https://github.com/axios/axios/pull/4875)
|
||||
- Fix Gitpod dead link [#4941](https://github.com/axios/axios/pull/4941)
|
||||
- Enable syntax highlighting for a code block [#4970](https://github.com/axios/axios/pull/4970)
|
||||
- Using Logo Axios in Readme.md [#4993](https://github.com/axios/axios/pull/4993)
|
||||
- Fix markup for note in README [#4825](https://github.com/axios/axios/pull/4825)
|
||||
- Fix typo and formatting, add colons [#4853](https://github.com/axios/axios/pull/4853)
|
||||
- Fix typo in readme [#4942](https://github.com/axios/axios/pull/4942)
|
||||
|
||||
### Security
|
||||
|
||||
- Update SECURITY.md [#4687](https://github.com/axios/axios/pull/4687)
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
- [Bertrand Marron](https://github.com/tusbar)
|
||||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS)
|
||||
- [Dan Mooney](https://github.com/danmooney)
|
||||
- [Michael Li](https://github.com/xiaoyu-tamu)
|
||||
- [aong](https://github.com/yxwzaxns)
|
||||
- [Des Preston](https://github.com/despreston)
|
||||
- [Ted Robertson](https://github.com/tredondo)
|
||||
- [zhoulixiang](https://github.com/zh-lx)
|
||||
- [Arthur Fiorette](https://github.com/arthurfiorette)
|
||||
- [Kumar Shanu](https://github.com/Kr-Shanu)
|
||||
- [JALAL](https://github.com/JLL32)
|
||||
- [Jingyi Lin](https://github.com/MageeLin)
|
||||
- [Philipp Loose](https://github.com/phloose)
|
||||
- [Alexander Shchukin](https://github.com/sashsvamir)
|
||||
- [Dave Cardwell](https://github.com/davecardwell)
|
||||
- [Cat Scarlet](https://github.com/catscarlet)
|
||||
- [Luca Pizzini](https://github.com/lpizzinidev)
|
||||
- [Kai](https://github.com/Schweinepriester)
|
||||
- [Maxime Bargiel](https://github.com/mbargiel)
|
||||
- [Brian Helba](https://github.com/brianhelba)
|
||||
- [reslear](https://github.com/reslear)
|
||||
- [Jamie Slome](https://github.com/JamieSlome)
|
||||
- [Landro3](https://github.com/Landro3)
|
||||
- [rafw87](https://github.com/rafw87)
|
||||
- [Afzal Sayed](https://github.com/afzalsayed96)
|
||||
- [Koki Oyatsu](https://github.com/kaishuu0123)
|
||||
- [Dave](https://github.com/wangcch)
|
||||
- [暴走老七](https://github.com/baozouai)
|
||||
- [Spencer](https://github.com/spalger)
|
||||
- [Adrian Wieprzkowicz](https://github.com/Argeento)
|
||||
- [Jamie Telin](https://github.com/lejahmie)
|
||||
- [毛呆](https://github.com/aweikalee)
|
||||
- [Kirill Shakirov](https://github.com/turisap)
|
||||
- [Rraji Abdelbari](https://github.com/estarossa0)
|
||||
- [Jelle Schutter](https://github.com/jelleschutter)
|
||||
- [Tom Ceuppens](https://github.com/KyorCode)
|
||||
- [Johann Cooper](https://github.com/JohannCooper)
|
||||
- [Dimitris Halatsis](https://github.com/mitsos1os)
|
||||
- [chenjigeng](https://github.com/chenjigeng)
|
||||
- [João Gabriel Quaresma](https://github.com/joaoGabriel55)
|
||||
- [Victor Augusto](https://github.com/VictorAugDB)
|
||||
- [neilnaveen](https://github.com/neilnaveen)
|
||||
- [Pavlos](https://github.com/psmoros)
|
||||
- [Kiryl Valkovich](https://github.com/visortelle)
|
||||
- [Naveen](https://github.com/naveensrinivasan)
|
||||
- [wenzheng](https://github.com/0x30)
|
||||
- [hcwhan](https://github.com/hcwhan)
|
||||
- [Bassel Rachid](https://github.com/basselworkforce)
|
||||
- [Grégoire Pineau](https://github.com/lyrixx)
|
||||
- [felipedamin](https://github.com/felipedamin)
|
||||
- [Karl Horky](https://github.com/karlhorky)
|
||||
- [Yue JIN](https://github.com/kingyue737)
|
||||
- [Usman Ali Siddiqui](https://github.com/usman250994)
|
||||
- [WD](https://github.com/techbirds)
|
||||
- [Günther Foidl](https://github.com/gfoidl)
|
||||
- [Stephen Jennings](https://github.com/jennings)
|
||||
- [C.T.Lin](https://github.com/chentsulin)
|
||||
- [mia-z](https://github.com/mia-z)
|
||||
- [Parth Banathia](https://github.com/Parth0105)
|
||||
- [parth0105pluang](https://github.com/parth0105pluang)
|
||||
- [Marco Weber](https://github.com/mrcwbr)
|
||||
- [Luca Pizzini](https://github.com/lpizzinidev)
|
||||
- [Willian Agostini](https://github.com/WillianAgostini)
|
||||
- [Huyen Nguyen](https://github.com/huyenltnguyen)
|
7
app/node_modules/axios/LICENSE
generated
vendored
@ -1,7 +0,0 @@
|
||||
# Copyright (c) 2014-present Matt Zabriskie & Collaborators
|
||||
|
||||
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.
|
3
app/node_modules/axios/MIGRATION_GUIDE.md
generated
vendored
@ -1,3 +0,0 @@
|
||||
# Migration Guide
|
||||
|
||||
## 0.x.x -> 1.1.0
|
1341
app/node_modules/axios/README.md
generated
vendored
6
app/node_modules/axios/SECURITY.md
generated
vendored
@ -1,6 +0,0 @@
|
||||
# Reporting a Vulnerability
|
||||
|
||||
If you discover a security vulnerability in axios please disclose it via [our huntr page](https://huntr.dev/repos/axios/axios/). Bounty eligibility, CVE assignment, response times and past reports are all there.
|
||||
|
||||
|
||||
Thank you for improving the security of axios.
|
2990
app/node_modules/axios/dist/axios.js
generated
vendored
1
app/node_modules/axios/dist/axios.js.map
generated
vendored
2
app/node_modules/axios/dist/axios.min.js
generated
vendored
1
app/node_modules/axios/dist/axios.min.js.map
generated
vendored
3214
app/node_modules/axios/dist/browser/axios.cjs
generated
vendored
1
app/node_modules/axios/dist/browser/axios.cjs.map
generated
vendored
3237
app/node_modules/axios/dist/esm/axios.js
generated
vendored
1
app/node_modules/axios/dist/esm/axios.js.map
generated
vendored
2
app/node_modules/axios/dist/esm/axios.min.js
generated
vendored
1
app/node_modules/axios/dist/esm/axios.min.js.map
generated
vendored
4243
app/node_modules/axios/dist/node/axios.cjs
generated
vendored
1
app/node_modules/axios/dist/node/axios.cjs.map
generated
vendored
533
app/node_modules/axios/index.d.cts
generated
vendored
@ -1,533 +0,0 @@
|
||||
interface RawAxiosHeaders {
|
||||
[key: string]: axios.AxiosHeaderValue;
|
||||
}
|
||||
|
||||
type MethodsHeaders = Partial<{
|
||||
[Key in axios.Method as Lowercase<Key>]: AxiosHeaders;
|
||||
} & {common: AxiosHeaders}>;
|
||||
|
||||
type AxiosHeaderMatcher = (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean;
|
||||
|
||||
type CommonRequestHeadersList = 'Accept' | 'Content-Length' | 'User-Agent'| 'Content-Encoding' | 'Authorization';
|
||||
|
||||
type ContentType = axios.AxiosHeaderValue | 'text/html' | 'text/plain' | 'multipart/form-data' | 'application/json' | 'application/x-www-form-urlencoded' | 'application/octet-stream';
|
||||
|
||||
type CommonResponseHeadersList = 'Server' | 'Content-Type' | 'Content-Length' | 'Cache-Control'| 'Content-Encoding';
|
||||
|
||||
declare class AxiosHeaders {
|
||||
constructor(
|
||||
headers?: RawAxiosHeaders | AxiosHeaders
|
||||
);
|
||||
|
||||
[key: string]: any;
|
||||
|
||||
set(headerName?: string, value?: axios.AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||
set(headers?: RawAxiosHeaders | AxiosHeaders, rewrite?: boolean): AxiosHeaders;
|
||||
|
||||
get(headerName: string, parser: RegExp): RegExpExecArray | null;
|
||||
get(headerName: string, matcher?: true | AxiosHeaderMatcher): axios.AxiosHeaderValue;
|
||||
|
||||
has(header: string, matcher?: true | AxiosHeaderMatcher): boolean;
|
||||
|
||||
delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean;
|
||||
|
||||
clear(matcher?: AxiosHeaderMatcher): boolean;
|
||||
|
||||
normalize(format: boolean): AxiosHeaders;
|
||||
|
||||
concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;
|
||||
|
||||
toJSON(asStrings?: boolean): RawAxiosHeaders;
|
||||
|
||||
static from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders;
|
||||
|
||||
static accessor(header: string | string[]): AxiosHeaders;
|
||||
|
||||
static concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;
|
||||
|
||||
setContentType(value: ContentType, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||
getContentType(parser?: RegExp): RegExpExecArray | null;
|
||||
getContentType(matcher?: AxiosHeaderMatcher): axios.AxiosHeaderValue;
|
||||
hasContentType(matcher?: AxiosHeaderMatcher): boolean;
|
||||
|
||||
setContentLength(value: axios.AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||
getContentLength(parser?: RegExp): RegExpExecArray | null;
|
||||
getContentLength(matcher?: AxiosHeaderMatcher): axios.AxiosHeaderValue;
|
||||
hasContentLength(matcher?: AxiosHeaderMatcher): boolean;
|
||||
|
||||
setAccept(value: axios.AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||
getAccept(parser?: RegExp): RegExpExecArray | null;
|
||||
getAccept(matcher?: AxiosHeaderMatcher): axios.AxiosHeaderValue;
|
||||
hasAccept(matcher?: AxiosHeaderMatcher): boolean;
|
||||
|
||||
setUserAgent(value: axios.AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||
getUserAgent(parser?: RegExp): RegExpExecArray | null;
|
||||
getUserAgent(matcher?: AxiosHeaderMatcher): axios.AxiosHeaderValue;
|
||||
hasUserAgent(matcher?: AxiosHeaderMatcher): boolean;
|
||||
|
||||
setContentEncoding(value: axios.AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||
getContentEncoding(parser?: RegExp): RegExpExecArray | null;
|
||||
getContentEncoding(matcher?: AxiosHeaderMatcher): axios.AxiosHeaderValue;
|
||||
hasContentEncoding(matcher?: AxiosHeaderMatcher): boolean;
|
||||
|
||||
setAuthorization(value: axios.AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||
getAuthorization(parser?: RegExp): RegExpExecArray | null;
|
||||
getAuthorization(matcher?: AxiosHeaderMatcher): axios.AxiosHeaderValue;
|
||||
hasAuthorization(matcher?: AxiosHeaderMatcher): boolean;
|
||||
|
||||
[Symbol.iterator](): IterableIterator<[string, axios.AxiosHeaderValue]>;
|
||||
}
|
||||
|
||||
declare class AxiosError<T = unknown, D = any> extends Error {
|
||||
constructor(
|
||||
message?: string,
|
||||
code?: string,
|
||||
config?: axios.InternalAxiosRequestConfig<D>,
|
||||
request?: any,
|
||||
response?: axios.AxiosResponse<T, D>
|
||||
);
|
||||
|
||||
config?: axios.InternalAxiosRequestConfig<D>;
|
||||
code?: string;
|
||||
request?: any;
|
||||
response?: axios.AxiosResponse<T, D>;
|
||||
isAxiosError: boolean;
|
||||
status?: number;
|
||||
toJSON: () => object;
|
||||
cause?: Error;
|
||||
static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";
|
||||
static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";
|
||||
static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION";
|
||||
static readonly ERR_NETWORK = "ERR_NETWORK";
|
||||
static readonly ERR_DEPRECATED = "ERR_DEPRECATED";
|
||||
static readonly ERR_BAD_RESPONSE = "ERR_BAD_RESPONSE";
|
||||
static readonly ERR_BAD_REQUEST = "ERR_BAD_REQUEST";
|
||||
static readonly ERR_NOT_SUPPORT = "ERR_NOT_SUPPORT";
|
||||
static readonly ERR_INVALID_URL = "ERR_INVALID_URL";
|
||||
static readonly ERR_CANCELED = "ERR_CANCELED";
|
||||
static readonly ECONNABORTED = "ECONNABORTED";
|
||||
static readonly ETIMEDOUT = "ETIMEDOUT";
|
||||
}
|
||||
|
||||
declare class CanceledError<T> extends AxiosError<T> {
|
||||
}
|
||||
|
||||
declare class Axios {
|
||||
constructor(config?: axios.AxiosRequestConfig);
|
||||
defaults: axios.AxiosDefaults;
|
||||
interceptors: {
|
||||
request: axios.AxiosInterceptorManager<axios.InternalAxiosRequestConfig>;
|
||||
response: axios.AxiosInterceptorManager<axios.AxiosResponse>;
|
||||
};
|
||||
getUri(config?: axios.AxiosRequestConfig): string;
|
||||
request<T = any, R = axios.AxiosResponse<T>, D = any>(config: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
get<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
delete<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
head<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
options<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
post<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
put<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
patch<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
postForm<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
putForm<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
patchForm<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;
|
||||
}
|
||||
|
||||
declare enum HttpStatusCode {
|
||||
Continue = 100,
|
||||
SwitchingProtocols = 101,
|
||||
Processing = 102,
|
||||
EarlyHints = 103,
|
||||
Ok = 200,
|
||||
Created = 201,
|
||||
Accepted = 202,
|
||||
NonAuthoritativeInformation = 203,
|
||||
NoContent = 204,
|
||||
ResetContent = 205,
|
||||
PartialContent = 206,
|
||||
MultiStatus = 207,
|
||||
AlreadyReported = 208,
|
||||
ImUsed = 226,
|
||||
MultipleChoices = 300,
|
||||
MovedPermanently = 301,
|
||||
Found = 302,
|
||||
SeeOther = 303,
|
||||
NotModified = 304,
|
||||
UseProxy = 305,
|
||||
Unused = 306,
|
||||
TemporaryRedirect = 307,
|
||||
PermanentRedirect = 308,
|
||||
BadRequest = 400,
|
||||
Unauthorized = 401,
|
||||
PaymentRequired = 402,
|
||||
Forbidden = 403,
|
||||
NotFound = 404,
|
||||
MethodNotAllowed = 405,
|
||||
NotAcceptable = 406,
|
||||
ProxyAuthenticationRequired = 407,
|
||||
RequestTimeout = 408,
|
||||
Conflict = 409,
|
||||
Gone = 410,
|
||||
LengthRequired = 411,
|
||||
PreconditionFailed = 412,
|
||||
PayloadTooLarge = 413,
|
||||
UriTooLong = 414,
|
||||
UnsupportedMediaType = 415,
|
||||
RangeNotSatisfiable = 416,
|
||||
ExpectationFailed = 417,
|
||||
ImATeapot = 418,
|
||||
MisdirectedRequest = 421,
|
||||
UnprocessableEntity = 422,
|
||||
Locked = 423,
|
||||
FailedDependency = 424,
|
||||
TooEarly = 425,
|
||||
UpgradeRequired = 426,
|
||||
PreconditionRequired = 428,
|
||||
TooManyRequests = 429,
|
||||
RequestHeaderFieldsTooLarge = 431,
|
||||
UnavailableForLegalReasons = 451,
|
||||
InternalServerError = 500,
|
||||
NotImplemented = 501,
|
||||
BadGateway = 502,
|
||||
ServiceUnavailable = 503,
|
||||
GatewayTimeout = 504,
|
||||
HttpVersionNotSupported = 505,
|
||||
VariantAlsoNegotiates = 506,
|
||||
InsufficientStorage = 507,
|
||||
LoopDetected = 508,
|
||||
NotExtended = 510,
|
||||
NetworkAuthenticationRequired = 511,
|
||||
}
|
||||
|
||||
type InternalAxiosError<T = unknown, D = any> = AxiosError<T, D>;
|
||||
|
||||
declare namespace axios {
|
||||
type AxiosError<T = unknown, D = any> = InternalAxiosError<T, D>;
|
||||
|
||||
type RawAxiosRequestHeaders = Partial<RawAxiosHeaders & {
|
||||
[Key in CommonRequestHeadersList]: AxiosHeaderValue;
|
||||
} & {
|
||||
'Content-Type': ContentType
|
||||
}>;
|
||||
|
||||
type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders;
|
||||
|
||||
type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null;
|
||||
|
||||
type RawCommonResponseHeaders = {
|
||||
[Key in CommonResponseHeadersList]: AxiosHeaderValue;
|
||||
} & {
|
||||
"set-cookie": string[];
|
||||
};
|
||||
|
||||
type RawAxiosResponseHeaders = Partial<RawAxiosHeaders & RawCommonResponseHeaders>;
|
||||
|
||||
type AxiosResponseHeaders = RawAxiosResponseHeaders & AxiosHeaders;
|
||||
|
||||
interface AxiosRequestTransformer {
|
||||
(this: InternalAxiosRequestConfig, data: any, headers: AxiosRequestHeaders): any;
|
||||
}
|
||||
|
||||
interface AxiosResponseTransformer {
|
||||
(this: InternalAxiosRequestConfig, data: any, headers: AxiosResponseHeaders, status?: number): any;
|
||||
}
|
||||
|
||||
interface AxiosAdapter {
|
||||
(config: InternalAxiosRequestConfig): AxiosPromise;
|
||||
}
|
||||
|
||||
interface AxiosBasicCredentials {
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
interface AxiosProxyConfig {
|
||||
host: string;
|
||||
port: number;
|
||||
auth?: {
|
||||
username: string;
|
||||
password: string;
|
||||
};
|
||||
protocol?: string;
|
||||
}
|
||||
|
||||
type Method =
|
||||
| 'get' | 'GET'
|
||||
| 'delete' | 'DELETE'
|
||||
| 'head' | 'HEAD'
|
||||
| 'options' | 'OPTIONS'
|
||||
| 'post' | 'POST'
|
||||
| 'put' | 'PUT'
|
||||
| 'patch' | 'PATCH'
|
||||
| 'purge' | 'PURGE'
|
||||
| 'link' | 'LINK'
|
||||
| 'unlink' | 'UNLINK';
|
||||
|
||||
type ResponseType =
|
||||
| 'arraybuffer'
|
||||
| 'blob'
|
||||
| 'document'
|
||||
| 'json'
|
||||
| 'text'
|
||||
| 'stream';
|
||||
|
||||
type responseEncoding =
|
||||
| 'ascii' | 'ASCII'
|
||||
| 'ansi' | 'ANSI'
|
||||
| 'binary' | 'BINARY'
|
||||
| 'base64' | 'BASE64'
|
||||
| 'base64url' | 'BASE64URL'
|
||||
| 'hex' | 'HEX'
|
||||
| 'latin1' | 'LATIN1'
|
||||
| 'ucs-2' | 'UCS-2'
|
||||
| 'ucs2' | 'UCS2'
|
||||
| 'utf-8' | 'UTF-8'
|
||||
| 'utf8' | 'UTF8'
|
||||
| 'utf16le' | 'UTF16LE';
|
||||
|
||||
interface TransitionalOptions {
|
||||
silentJSONParsing?: boolean;
|
||||
forcedJSONParsing?: boolean;
|
||||
clarifyTimeoutError?: boolean;
|
||||
}
|
||||
|
||||
interface GenericAbortSignal {
|
||||
readonly aborted: boolean;
|
||||
onabort?: ((...args: any) => any) | null;
|
||||
addEventListener?: (...args: any) => any;
|
||||
removeEventListener?: (...args: any) => any;
|
||||
}
|
||||
|
||||
interface FormDataVisitorHelpers {
|
||||
defaultVisitor: SerializerVisitor;
|
||||
convertValue: (value: any) => any;
|
||||
isVisitable: (value: any) => boolean;
|
||||
}
|
||||
|
||||
interface SerializerVisitor {
|
||||
(
|
||||
this: GenericFormData,
|
||||
value: any,
|
||||
key: string | number,
|
||||
path: null | Array<string | number>,
|
||||
helpers: FormDataVisitorHelpers
|
||||
): boolean;
|
||||
}
|
||||
|
||||
interface SerializerOptions {
|
||||
visitor?: SerializerVisitor;
|
||||
dots?: boolean;
|
||||
metaTokens?: boolean;
|
||||
indexes?: boolean | null;
|
||||
}
|
||||
|
||||
// tslint:disable-next-line
|
||||
interface FormSerializerOptions extends SerializerOptions {
|
||||
}
|
||||
|
||||
interface ParamEncoder {
|
||||
(value: any, defaultEncoder: (value: any) => any): any;
|
||||
}
|
||||
|
||||
interface CustomParamsSerializer {
|
||||
(params: Record<string, any>, options?: ParamsSerializerOptions): string;
|
||||
}
|
||||
|
||||
interface ParamsSerializerOptions extends SerializerOptions {
|
||||
encode?: ParamEncoder;
|
||||
serialize?: CustomParamsSerializer;
|
||||
}
|
||||
|
||||
type MaxUploadRate = number;
|
||||
|
||||
type MaxDownloadRate = number;
|
||||
|
||||
type BrowserProgressEvent = any;
|
||||
|
||||
interface AxiosProgressEvent {
|
||||
loaded: number;
|
||||
total?: number;
|
||||
progress?: number;
|
||||
bytes: number;
|
||||
rate?: number;
|
||||
estimated?: number;
|
||||
upload?: boolean;
|
||||
download?: boolean;
|
||||
event?: BrowserProgressEvent;
|
||||
}
|
||||
|
||||
type Milliseconds = number;
|
||||
|
||||
type AxiosAdapterName = 'xhr' | 'http' | string;
|
||||
|
||||
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
|
||||
|
||||
interface AxiosRequestConfig<D = any> {
|
||||
url?: string;
|
||||
method?: Method | string;
|
||||
baseURL?: string;
|
||||
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
|
||||
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
|
||||
headers?: (RawAxiosRequestHeaders & MethodsHeaders) | AxiosHeaders;
|
||||
params?: any;
|
||||
paramsSerializer?: ParamsSerializerOptions | CustomParamsSerializer;
|
||||
data?: D;
|
||||
timeout?: Milliseconds;
|
||||
timeoutErrorMessage?: string;
|
||||
withCredentials?: boolean;
|
||||
adapter?: AxiosAdapterConfig | AxiosAdapterConfig[];
|
||||
auth?: AxiosBasicCredentials;
|
||||
responseType?: ResponseType;
|
||||
responseEncoding?: responseEncoding | string;
|
||||
xsrfCookieName?: string;
|
||||
xsrfHeaderName?: string;
|
||||
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
|
||||
onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void;
|
||||
maxContentLength?: number;
|
||||
validateStatus?: ((status: number) => boolean) | null;
|
||||
maxBodyLength?: number;
|
||||
maxRedirects?: number;
|
||||
maxRate?: number | [MaxUploadRate, MaxDownloadRate];
|
||||
beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>}) => void;
|
||||
socketPath?: string | null;
|
||||
transport?: any;
|
||||
httpAgent?: any;
|
||||
httpsAgent?: any;
|
||||
proxy?: AxiosProxyConfig | false;
|
||||
cancelToken?: CancelToken;
|
||||
decompress?: boolean;
|
||||
transitional?: TransitionalOptions;
|
||||
signal?: GenericAbortSignal;
|
||||
insecureHTTPParser?: boolean;
|
||||
env?: {
|
||||
FormData?: new (...args: any[]) => object;
|
||||
};
|
||||
formSerializer?: FormSerializerOptions;
|
||||
family?: 4 | 6 | undefined;
|
||||
lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: string, family: number) => void) => void) |
|
||||
((hostname: string, options: object) => Promise<[address: string, family: number] | string>);
|
||||
}
|
||||
|
||||
// Alias
|
||||
type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>;
|
||||
|
||||
interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig {
|
||||
headers: AxiosRequestHeaders;
|
||||
}
|
||||
|
||||
interface HeadersDefaults {
|
||||
common: RawAxiosRequestHeaders;
|
||||
delete: RawAxiosRequestHeaders;
|
||||
get: RawAxiosRequestHeaders;
|
||||
head: RawAxiosRequestHeaders;
|
||||
post: RawAxiosRequestHeaders;
|
||||
put: RawAxiosRequestHeaders;
|
||||
patch: RawAxiosRequestHeaders;
|
||||
options?: RawAxiosRequestHeaders;
|
||||
purge?: RawAxiosRequestHeaders;
|
||||
link?: RawAxiosRequestHeaders;
|
||||
unlink?: RawAxiosRequestHeaders;
|
||||
}
|
||||
|
||||
interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
||||
headers: HeadersDefaults;
|
||||
}
|
||||
|
||||
interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
||||
headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>;
|
||||
}
|
||||
|
||||
interface AxiosResponse<T = any, D = any> {
|
||||
data: T;
|
||||
status: number;
|
||||
statusText: string;
|
||||
headers: RawAxiosResponseHeaders | AxiosResponseHeaders;
|
||||
config: InternalAxiosRequestConfig<D>;
|
||||
request?: any;
|
||||
}
|
||||
|
||||
type AxiosPromise<T = any> = Promise<AxiosResponse<T>>;
|
||||
|
||||
interface CancelStatic {
|
||||
new (message?: string): Cancel;
|
||||
}
|
||||
|
||||
interface Cancel {
|
||||
message: string | undefined;
|
||||
}
|
||||
|
||||
interface Canceler {
|
||||
(message?: string, config?: AxiosRequestConfig, request?: any): void;
|
||||
}
|
||||
|
||||
interface CancelTokenStatic {
|
||||
new (executor: (cancel: Canceler) => void): CancelToken;
|
||||
source(): CancelTokenSource;
|
||||
}
|
||||
|
||||
interface CancelToken {
|
||||
promise: Promise<Cancel>;
|
||||
reason?: Cancel;
|
||||
throwIfRequested(): void;
|
||||
}
|
||||
|
||||
interface CancelTokenSource {
|
||||
token: CancelToken;
|
||||
cancel: Canceler;
|
||||
}
|
||||
|
||||
interface AxiosInterceptorOptions {
|
||||
synchronous?: boolean;
|
||||
runWhen?: (config: InternalAxiosRequestConfig) => boolean;
|
||||
}
|
||||
|
||||
interface AxiosInterceptorManager<V> {
|
||||
use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any, options?: AxiosInterceptorOptions): number;
|
||||
eject(id: number): void;
|
||||
clear(): void;
|
||||
}
|
||||
|
||||
interface AxiosInstance extends Axios {
|
||||
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
||||
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||
|
||||
defaults: Omit<AxiosDefaults, 'headers'> & {
|
||||
headers: HeadersDefaults & {
|
||||
[key: string]: AxiosHeaderValue
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
interface GenericFormData {
|
||||
append(name: string, value: any, options?: any): any;
|
||||
}
|
||||
|
||||
interface GenericHTMLFormElement {
|
||||
name: string;
|
||||
method: string;
|
||||
submit(): void;
|
||||
}
|
||||
|
||||
interface AxiosStatic extends AxiosInstance {
|
||||
create(config?: CreateAxiosDefaults): AxiosInstance;
|
||||
Cancel: CancelStatic;
|
||||
CancelToken: CancelTokenStatic;
|
||||
Axios: typeof Axios;
|
||||
AxiosError: typeof AxiosError;
|
||||
CanceledError: typeof CanceledError;
|
||||
HttpStatusCode: typeof HttpStatusCode;
|
||||
readonly VERSION: string;
|
||||
isCancel(value: any): value is Cancel;
|
||||
all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
|
||||
spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
|
||||
isAxiosError<T = any, D = any>(payload: any): payload is AxiosError<T, D>;
|
||||
toFormData(sourceObj: object, targetFormData?: GenericFormData, options?: FormSerializerOptions): GenericFormData;
|
||||
formToJSON(form: GenericFormData|GenericHTMLFormElement): object;
|
||||
getAdapter(adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined): AxiosAdapter;
|
||||
AxiosHeaders: typeof AxiosHeaders;
|
||||
}
|
||||
}
|
||||
|
||||
declare const axios: axios.AxiosStatic;
|
||||
|
||||
export = axios;
|
550
app/node_modules/axios/index.d.ts
generated
vendored
@ -1,550 +0,0 @@
|
||||
// TypeScript Version: 4.7
|
||||
export type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null;
|
||||
|
||||
interface RawAxiosHeaders {
|
||||
[key: string]: AxiosHeaderValue;
|
||||
}
|
||||
|
||||
type MethodsHeaders = Partial<{
|
||||
[Key in Method as Lowercase<Key>]: AxiosHeaders;
|
||||
} & {common: AxiosHeaders}>;
|
||||
|
||||
type AxiosHeaderMatcher = (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean;
|
||||
|
||||
export class AxiosHeaders {
|
||||
constructor(
|
||||
headers?: RawAxiosHeaders | AxiosHeaders
|
||||
);
|
||||
|
||||
[key: string]: any;
|
||||
|
||||
set(headerName?: string, value?: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||
set(headers?: RawAxiosHeaders | AxiosHeaders, rewrite?: boolean): AxiosHeaders;
|
||||
|
||||
get(headerName: string, parser: RegExp): RegExpExecArray | null;
|
||||
get(headerName: string, matcher?: true | AxiosHeaderMatcher): AxiosHeaderValue;
|
||||
|
||||
has(header: string, matcher?: true | AxiosHeaderMatcher): boolean;
|
||||
|
||||
delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean;
|
||||
|
||||
clear(matcher?: AxiosHeaderMatcher): boolean;
|
||||
|
||||
normalize(format: boolean): AxiosHeaders;
|
||||
|
||||
concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;
|
||||
|
||||
toJSON(asStrings?: boolean): RawAxiosHeaders;
|
||||
|
||||
static from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders;
|
||||
|
||||
static accessor(header: string | string[]): AxiosHeaders;
|
||||
|
||||
static concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;
|
||||
|
||||
setContentType(value: ContentType, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||
getContentType(parser?: RegExp): RegExpExecArray | null;
|
||||
getContentType(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
||||
hasContentType(matcher?: AxiosHeaderMatcher): boolean;
|
||||
|
||||
setContentLength(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||
getContentLength(parser?: RegExp): RegExpExecArray | null;
|
||||
getContentLength(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
||||
hasContentLength(matcher?: AxiosHeaderMatcher): boolean;
|
||||
|
||||
setAccept(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||
getAccept(parser?: RegExp): RegExpExecArray | null;
|
||||
getAccept(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
||||
hasAccept(matcher?: AxiosHeaderMatcher): boolean;
|
||||
|
||||
setUserAgent(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||
getUserAgent(parser?: RegExp): RegExpExecArray | null;
|
||||
getUserAgent(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
||||
hasUserAgent(matcher?: AxiosHeaderMatcher): boolean;
|
||||
|
||||
setContentEncoding(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||
getContentEncoding(parser?: RegExp): RegExpExecArray | null;
|
||||
getContentEncoding(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
||||
hasContentEncoding(matcher?: AxiosHeaderMatcher): boolean;
|
||||
|
||||
setAuthorization(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
||||
getAuthorization(parser?: RegExp): RegExpExecArray | null;
|
||||
getAuthorization(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
|
||||
hasAuthorization(matcher?: AxiosHeaderMatcher): boolean;
|
||||
|
||||
[Symbol.iterator](): IterableIterator<[string, AxiosHeaderValue]>;
|
||||
}
|
||||
|
||||
type CommonRequestHeadersList = 'Accept' | 'Content-Length' | 'User-Agent' | 'Content-Encoding' | 'Authorization';
|
||||
|
||||
type ContentType = AxiosHeaderValue | 'text/html' | 'text/plain' | 'multipart/form-data' | 'application/json' | 'application/x-www-form-urlencoded' | 'application/octet-stream';
|
||||
|
||||
export type RawAxiosRequestHeaders = Partial<RawAxiosHeaders & {
|
||||
[Key in CommonRequestHeadersList]: AxiosHeaderValue;
|
||||
} & {
|
||||
'Content-Type': ContentType
|
||||
}>;
|
||||
|
||||
export type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders;
|
||||
|
||||
type CommonResponseHeadersList = 'Server' | 'Content-Type' | 'Content-Length' | 'Cache-Control'| 'Content-Encoding';
|
||||
|
||||
type RawCommonResponseHeaders = {
|
||||
[Key in CommonResponseHeadersList]: AxiosHeaderValue;
|
||||
} & {
|
||||
"set-cookie": string[];
|
||||
};
|
||||
|
||||
export type RawAxiosResponseHeaders = Partial<RawAxiosHeaders & RawCommonResponseHeaders>;
|
||||
|
||||
export type AxiosResponseHeaders = RawAxiosResponseHeaders & AxiosHeaders;
|
||||
|
||||
export interface AxiosRequestTransformer {
|
||||
(this: InternalAxiosRequestConfig, data: any, headers: AxiosRequestHeaders): any;
|
||||
}
|
||||
|
||||
export interface AxiosResponseTransformer {
|
||||
(this: InternalAxiosRequestConfig, data: any, headers: AxiosResponseHeaders, status?: number): any;
|
||||
}
|
||||
|
||||
export interface AxiosAdapter {
|
||||
(config: InternalAxiosRequestConfig): AxiosPromise;
|
||||
}
|
||||
|
||||
export interface AxiosBasicCredentials {
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
export interface AxiosProxyConfig {
|
||||
host: string;
|
||||
port: number;
|
||||
auth?: {
|
||||
username: string;
|
||||
password: string;
|
||||
};
|
||||
protocol?: string;
|
||||
}
|
||||
|
||||
export enum HttpStatusCode {
|
||||
Continue = 100,
|
||||
SwitchingProtocols = 101,
|
||||
Processing = 102,
|
||||
EarlyHints = 103,
|
||||
Ok = 200,
|
||||
Created = 201,
|
||||
Accepted = 202,
|
||||
NonAuthoritativeInformation = 203,
|
||||
NoContent = 204,
|
||||
ResetContent = 205,
|
||||
PartialContent = 206,
|
||||
MultiStatus = 207,
|
||||
AlreadyReported = 208,
|
||||
ImUsed = 226,
|
||||
MultipleChoices = 300,
|
||||
MovedPermanently = 301,
|
||||
Found = 302,
|
||||
SeeOther = 303,
|
||||
NotModified = 304,
|
||||
UseProxy = 305,
|
||||
Unused = 306,
|
||||
TemporaryRedirect = 307,
|
||||
PermanentRedirect = 308,
|
||||
BadRequest = 400,
|
||||
Unauthorized = 401,
|
||||
PaymentRequired = 402,
|
||||
Forbidden = 403,
|
||||
NotFound = 404,
|
||||
MethodNotAllowed = 405,
|
||||
NotAcceptable = 406,
|
||||
ProxyAuthenticationRequired = 407,
|
||||
RequestTimeout = 408,
|
||||
Conflict = 409,
|
||||
Gone = 410,
|
||||
LengthRequired = 411,
|
||||
PreconditionFailed = 412,
|
||||
PayloadTooLarge = 413,
|
||||
UriTooLong = 414,
|
||||
UnsupportedMediaType = 415,
|
||||
RangeNotSatisfiable = 416,
|
||||
ExpectationFailed = 417,
|
||||
ImATeapot = 418,
|
||||
MisdirectedRequest = 421,
|
||||
UnprocessableEntity = 422,
|
||||
Locked = 423,
|
||||
FailedDependency = 424,
|
||||
TooEarly = 425,
|
||||
UpgradeRequired = 426,
|
||||
PreconditionRequired = 428,
|
||||
TooManyRequests = 429,
|
||||
RequestHeaderFieldsTooLarge = 431,
|
||||
UnavailableForLegalReasons = 451,
|
||||
InternalServerError = 500,
|
||||
NotImplemented = 501,
|
||||
BadGateway = 502,
|
||||
ServiceUnavailable = 503,
|
||||
GatewayTimeout = 504,
|
||||
HttpVersionNotSupported = 505,
|
||||
VariantAlsoNegotiates = 506,
|
||||
InsufficientStorage = 507,
|
||||
LoopDetected = 508,
|
||||
NotExtended = 510,
|
||||
NetworkAuthenticationRequired = 511,
|
||||
}
|
||||
|
||||
export type Method =
|
||||
| 'get' | 'GET'
|
||||
| 'delete' | 'DELETE'
|
||||
| 'head' | 'HEAD'
|
||||
| 'options' | 'OPTIONS'
|
||||
| 'post' | 'POST'
|
||||
| 'put' | 'PUT'
|
||||
| 'patch' | 'PATCH'
|
||||
| 'purge' | 'PURGE'
|
||||
| 'link' | 'LINK'
|
||||
| 'unlink' | 'UNLINK';
|
||||
|
||||
export type ResponseType =
|
||||
| 'arraybuffer'
|
||||
| 'blob'
|
||||
| 'document'
|
||||
| 'json'
|
||||
| 'text'
|
||||
| 'stream';
|
||||
|
||||
export type responseEncoding =
|
||||
| 'ascii' | 'ASCII'
|
||||
| 'ansi' | 'ANSI'
|
||||
| 'binary' | 'BINARY'
|
||||
| 'base64' | 'BASE64'
|
||||
| 'base64url' | 'BASE64URL'
|
||||
| 'hex' | 'HEX'
|
||||
| 'latin1' | 'LATIN1'
|
||||
| 'ucs-2' | 'UCS-2'
|
||||
| 'ucs2' | 'UCS2'
|
||||
| 'utf-8' | 'UTF-8'
|
||||
| 'utf8' | 'UTF8'
|
||||
| 'utf16le' | 'UTF16LE';
|
||||
|
||||
export interface TransitionalOptions {
|
||||
silentJSONParsing?: boolean;
|
||||
forcedJSONParsing?: boolean;
|
||||
clarifyTimeoutError?: boolean;
|
||||
}
|
||||
|
||||
export interface GenericAbortSignal {
|
||||
readonly aborted: boolean;
|
||||
onabort?: ((...args: any) => any) | null;
|
||||
addEventListener?: (...args: any) => any;
|
||||
removeEventListener?: (...args: any) => any;
|
||||
}
|
||||
|
||||
export interface FormDataVisitorHelpers {
|
||||
defaultVisitor: SerializerVisitor;
|
||||
convertValue: (value: any) => any;
|
||||
isVisitable: (value: any) => boolean;
|
||||
}
|
||||
|
||||
export interface SerializerVisitor {
|
||||
(
|
||||
this: GenericFormData,
|
||||
value: any,
|
||||
key: string | number,
|
||||
path: null | Array<string | number>,
|
||||
helpers: FormDataVisitorHelpers
|
||||
): boolean;
|
||||
}
|
||||
|
||||
export interface SerializerOptions {
|
||||
visitor?: SerializerVisitor;
|
||||
dots?: boolean;
|
||||
metaTokens?: boolean;
|
||||
indexes?: boolean | null;
|
||||
}
|
||||
|
||||
// tslint:disable-next-line
|
||||
export interface FormSerializerOptions extends SerializerOptions {
|
||||
}
|
||||
|
||||
export interface ParamEncoder {
|
||||
(value: any, defaultEncoder: (value: any) => any): any;
|
||||
}
|
||||
|
||||
export interface CustomParamsSerializer {
|
||||
(params: Record<string, any>, options?: ParamsSerializerOptions): string;
|
||||
}
|
||||
|
||||
export interface ParamsSerializerOptions extends SerializerOptions {
|
||||
encode?: ParamEncoder;
|
||||
serialize?: CustomParamsSerializer;
|
||||
}
|
||||
|
||||
type MaxUploadRate = number;
|
||||
|
||||
type MaxDownloadRate = number;
|
||||
|
||||
type BrowserProgressEvent = any;
|
||||
|
||||
export interface AxiosProgressEvent {
|
||||
loaded: number;
|
||||
total?: number;
|
||||
progress?: number;
|
||||
bytes: number;
|
||||
rate?: number;
|
||||
estimated?: number;
|
||||
upload?: boolean;
|
||||
download?: boolean;
|
||||
event?: BrowserProgressEvent;
|
||||
}
|
||||
|
||||
type Milliseconds = number;
|
||||
|
||||
type AxiosAdapterName = 'xhr' | 'http' | string;
|
||||
|
||||
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
|
||||
|
||||
export interface AxiosRequestConfig<D = any> {
|
||||
url?: string;
|
||||
method?: Method | string;
|
||||
baseURL?: string;
|
||||
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
|
||||
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
|
||||
headers?: (RawAxiosRequestHeaders & MethodsHeaders) | AxiosHeaders;
|
||||
params?: any;
|
||||
paramsSerializer?: ParamsSerializerOptions | CustomParamsSerializer;
|
||||
data?: D;
|
||||
timeout?: Milliseconds;
|
||||
timeoutErrorMessage?: string;
|
||||
withCredentials?: boolean;
|
||||
adapter?: AxiosAdapterConfig | AxiosAdapterConfig[];
|
||||
auth?: AxiosBasicCredentials;
|
||||
responseType?: ResponseType;
|
||||
responseEncoding?: responseEncoding | string;
|
||||
xsrfCookieName?: string;
|
||||
xsrfHeaderName?: string;
|
||||
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
|
||||
onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void;
|
||||
maxContentLength?: number;
|
||||
validateStatus?: ((status: number) => boolean) | null;
|
||||
maxBodyLength?: number;
|
||||
maxRedirects?: number;
|
||||
maxRate?: number | [MaxUploadRate, MaxDownloadRate];
|
||||
beforeRedirect?: (options: Record<string, any>, responseDetails: { headers: Record<string, string> }) => void;
|
||||
socketPath?: string | null;
|
||||
transport?: any;
|
||||
httpAgent?: any;
|
||||
httpsAgent?: any;
|
||||
proxy?: AxiosProxyConfig | false;
|
||||
cancelToken?: CancelToken;
|
||||
decompress?: boolean;
|
||||
transitional?: TransitionalOptions;
|
||||
signal?: GenericAbortSignal;
|
||||
insecureHTTPParser?: boolean;
|
||||
env?: {
|
||||
FormData?: new (...args: any[]) => object;
|
||||
};
|
||||
formSerializer?: FormSerializerOptions;
|
||||
family?: 4 | 6 | undefined;
|
||||
lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: string, family: number) => void) => void) |
|
||||
((hostname: string, options: object) => Promise<[address: string, family: number] | string>);
|
||||
}
|
||||
|
||||
// Alias
|
||||
export type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>;
|
||||
|
||||
export interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig<D> {
|
||||
headers: AxiosRequestHeaders;
|
||||
}
|
||||
|
||||
export interface HeadersDefaults {
|
||||
common: RawAxiosRequestHeaders;
|
||||
delete: RawAxiosRequestHeaders;
|
||||
get: RawAxiosRequestHeaders;
|
||||
head: RawAxiosRequestHeaders;
|
||||
post: RawAxiosRequestHeaders;
|
||||
put: RawAxiosRequestHeaders;
|
||||
patch: RawAxiosRequestHeaders;
|
||||
options?: RawAxiosRequestHeaders;
|
||||
purge?: RawAxiosRequestHeaders;
|
||||
link?: RawAxiosRequestHeaders;
|
||||
unlink?: RawAxiosRequestHeaders;
|
||||
}
|
||||
|
||||
export interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
||||
headers: HeadersDefaults;
|
||||
}
|
||||
|
||||
export interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
||||
headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>;
|
||||
}
|
||||
|
||||
export interface AxiosResponse<T = any, D = any> {
|
||||
data: T;
|
||||
status: number;
|
||||
statusText: string;
|
||||
headers: RawAxiosResponseHeaders | AxiosResponseHeaders;
|
||||
config: InternalAxiosRequestConfig<D>;
|
||||
request?: any;
|
||||
}
|
||||
|
||||
export class AxiosError<T = unknown, D = any> extends Error {
|
||||
constructor(
|
||||
message?: string,
|
||||
code?: string,
|
||||
config?: InternalAxiosRequestConfig<D>,
|
||||
request?: any,
|
||||
response?: AxiosResponse<T, D>
|
||||
);
|
||||
|
||||
config?: InternalAxiosRequestConfig<D>;
|
||||
code?: string;
|
||||
request?: any;
|
||||
response?: AxiosResponse<T, D>;
|
||||
isAxiosError: boolean;
|
||||
status?: number;
|
||||
toJSON: () => object;
|
||||
cause?: Error;
|
||||
static from<T = unknown, D = any>(
|
||||
error: Error | unknown,
|
||||
code?: string,
|
||||
config?: InternalAxiosRequestConfig<D>,
|
||||
request?: any,
|
||||
response?: AxiosResponse<T, D>,
|
||||
customProps?: object,
|
||||
): AxiosError<T, D>;
|
||||
static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";
|
||||
static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";
|
||||
static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION";
|
||||
static readonly ERR_NETWORK = "ERR_NETWORK";
|
||||
static readonly ERR_DEPRECATED = "ERR_DEPRECATED";
|
||||
static readonly ERR_BAD_RESPONSE = "ERR_BAD_RESPONSE";
|
||||
static readonly ERR_BAD_REQUEST = "ERR_BAD_REQUEST";
|
||||
static readonly ERR_NOT_SUPPORT = "ERR_NOT_SUPPORT";
|
||||
static readonly ERR_INVALID_URL = "ERR_INVALID_URL";
|
||||
static readonly ERR_CANCELED = "ERR_CANCELED";
|
||||
static readonly ECONNABORTED = "ECONNABORTED";
|
||||
static readonly ETIMEDOUT = "ETIMEDOUT";
|
||||
}
|
||||
|
||||
export class CanceledError<T> extends AxiosError<T> {
|
||||
}
|
||||
|
||||
export type AxiosPromise<T = any> = Promise<AxiosResponse<T>>;
|
||||
|
||||
export interface CancelStatic {
|
||||
new (message?: string): Cancel;
|
||||
}
|
||||
|
||||
export interface Cancel {
|
||||
message: string | undefined;
|
||||
}
|
||||
|
||||
export interface Canceler {
|
||||
(message?: string, config?: AxiosRequestConfig, request?: any): void;
|
||||
}
|
||||
|
||||
export interface CancelTokenStatic {
|
||||
new (executor: (cancel: Canceler) => void): CancelToken;
|
||||
source(): CancelTokenSource;
|
||||
}
|
||||
|
||||
export interface CancelToken {
|
||||
promise: Promise<Cancel>;
|
||||
reason?: Cancel;
|
||||
throwIfRequested(): void;
|
||||
}
|
||||
|
||||
export interface CancelTokenSource {
|
||||
token: CancelToken;
|
||||
cancel: Canceler;
|
||||
}
|
||||
|
||||
export interface AxiosInterceptorOptions {
|
||||
synchronous?: boolean;
|
||||
runWhen?: (config: InternalAxiosRequestConfig) => boolean;
|
||||
}
|
||||
|
||||
export interface AxiosInterceptorManager<V> {
|
||||
use(onFulfilled?: ((value: V) => V | Promise<V>) | null, onRejected?: ((error: any) => any) | null, options?: AxiosInterceptorOptions): number;
|
||||
eject(id: number): void;
|
||||
clear(): void;
|
||||
}
|
||||
|
||||
export class Axios {
|
||||
constructor(config?: AxiosRequestConfig);
|
||||
defaults: AxiosDefaults;
|
||||
interceptors: {
|
||||
request: AxiosInterceptorManager<InternalAxiosRequestConfig>;
|
||||
response: AxiosInterceptorManager<AxiosResponse>;
|
||||
};
|
||||
getUri(config?: AxiosRequestConfig): string;
|
||||
request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
||||
get<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||
delete<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||
head<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||
options<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||
post<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||
put<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||
patch<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||
postForm<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||
putForm<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||
patchForm<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||
}
|
||||
|
||||
export interface AxiosInstance extends Axios {
|
||||
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
||||
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||
|
||||
defaults: Omit<AxiosDefaults, 'headers'> & {
|
||||
headers: HeadersDefaults & {
|
||||
[key: string]: AxiosHeaderValue
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export interface GenericFormData {
|
||||
append(name: string, value: any, options?: any): any;
|
||||
}
|
||||
|
||||
export interface GenericHTMLFormElement {
|
||||
name: string;
|
||||
method: string;
|
||||
submit(): void;
|
||||
}
|
||||
|
||||
export function getAdapter(adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined): AxiosAdapter;
|
||||
|
||||
export function toFormData(sourceObj: object, targetFormData?: GenericFormData, options?: FormSerializerOptions): GenericFormData;
|
||||
|
||||
export function formToJSON(form: GenericFormData|GenericHTMLFormElement): object;
|
||||
|
||||
export function isAxiosError<T = any, D = any>(payload: any): payload is AxiosError<T, D>;
|
||||
|
||||
export function spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
|
||||
|
||||
export function isCancel(value: any): value is Cancel;
|
||||
|
||||
export function all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
|
||||
|
||||
export interface AxiosStatic extends AxiosInstance {
|
||||
create(config?: CreateAxiosDefaults): AxiosInstance;
|
||||
Cancel: CancelStatic;
|
||||
CancelToken: CancelTokenStatic;
|
||||
Axios: typeof Axios;
|
||||
AxiosError: typeof AxiosError;
|
||||
HttpStatusCode: typeof HttpStatusCode;
|
||||
readonly VERSION: string;
|
||||
isCancel: typeof isCancel;
|
||||
all: typeof all;
|
||||
spread: typeof spread;
|
||||
isAxiosError: typeof isAxiosError;
|
||||
toFormData: typeof toFormData;
|
||||
formToJSON: typeof formToJSON;
|
||||
getAdapter: typeof getAdapter;
|
||||
CanceledError: typeof CanceledError;
|
||||
AxiosHeaders: typeof AxiosHeaders;
|
||||
}
|
||||
|
||||
declare const axios: AxiosStatic;
|
||||
|
||||
export default axios;
|
43
app/node_modules/axios/index.js
generated
vendored
@ -1,43 +0,0 @@
|
||||
import axios from './lib/axios.js';
|
||||
|
||||
// This module is intended to unwrap Axios default export as named.
|
||||
// Keep top-level export same with static properties
|
||||
// so that it can keep same with es module or cjs
|
||||
const {
|
||||
Axios,
|
||||
AxiosError,
|
||||
CanceledError,
|
||||
isCancel,
|
||||
CancelToken,
|
||||
VERSION,
|
||||
all,
|
||||
Cancel,
|
||||
isAxiosError,
|
||||
spread,
|
||||
toFormData,
|
||||
AxiosHeaders,
|
||||
HttpStatusCode,
|
||||
formToJSON,
|
||||
getAdapter,
|
||||
mergeConfig
|
||||
} = axios;
|
||||
|
||||
export {
|
||||
axios as default,
|
||||
Axios,
|
||||
AxiosError,
|
||||
CanceledError,
|
||||
isCancel,
|
||||
CancelToken,
|
||||
VERSION,
|
||||
all,
|
||||
Cancel,
|
||||
isAxiosError,
|
||||
spread,
|
||||
toFormData,
|
||||
AxiosHeaders,
|
||||
HttpStatusCode,
|
||||
formToJSON,
|
||||
getAdapter,
|
||||
mergeConfig
|
||||
}
|
37
app/node_modules/axios/lib/adapters/README.md
generated
vendored
@ -1,37 +0,0 @@
|
||||
# axios // adapters
|
||||
|
||||
The modules under `adapters/` are modules that handle dispatching a request and settling a returned `Promise` once a response is received.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var settle = require('./../core/settle');
|
||||
|
||||
module.exports = function myAdapter(config) {
|
||||
// At this point:
|
||||
// - config has been merged with defaults
|
||||
// - request transformers have already run
|
||||
// - request interceptors have already run
|
||||
|
||||
// Make the request using config provided
|
||||
// Upon response settle the Promise
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
|
||||
var response = {
|
||||
data: responseData,
|
||||
status: request.status,
|
||||
statusText: request.statusText,
|
||||
headers: responseHeaders,
|
||||
config: config,
|
||||
request: request
|
||||
};
|
||||
|
||||
settle(resolve, reject, response);
|
||||
|
||||
// From here:
|
||||
// - response transformers will run
|
||||
// - response interceptors will run
|
||||
});
|
||||
}
|
||||
```
|
59
app/node_modules/axios/lib/adapters/adapters.js
generated
vendored
@ -1,59 +0,0 @@
|
||||
import utils from '../utils.js';
|
||||
import httpAdapter from './http.js';
|
||||
import xhrAdapter from './xhr.js';
|
||||
import AxiosError from "../core/AxiosError.js";
|
||||
|
||||
const knownAdapters = {
|
||||
http: httpAdapter,
|
||||
xhr: xhrAdapter
|
||||
}
|
||||
|
||||
utils.forEach(knownAdapters, (fn, value) => {
|
||||
if(fn) {
|
||||
try {
|
||||
Object.defineProperty(fn, 'name', {value});
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line no-empty
|
||||
}
|
||||
Object.defineProperty(fn, 'adapterName', {value});
|
||||
}
|
||||
});
|
||||
|
||||
export default {
|
||||
getAdapter: (adapters) => {
|
||||
adapters = utils.isArray(adapters) ? adapters : [adapters];
|
||||
|
||||
const {length} = adapters;
|
||||
let nameOrAdapter;
|
||||
let adapter;
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
nameOrAdapter = adapters[i];
|
||||
if((adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!adapter) {
|
||||
if (adapter === false) {
|
||||
throw new AxiosError(
|
||||
`Adapter ${nameOrAdapter} is not supported by the environment`,
|
||||
'ERR_NOT_SUPPORT'
|
||||
);
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
utils.hasOwnProp(knownAdapters, nameOrAdapter) ?
|
||||
`Adapter '${nameOrAdapter}' is not available in the build` :
|
||||
`Unknown adapter '${nameOrAdapter}'`
|
||||
);
|
||||
}
|
||||
|
||||
if (!utils.isFunction(adapter)) {
|
||||
throw new TypeError('adapter is not a function');
|
||||
}
|
||||
|
||||
return adapter;
|
||||
},
|
||||
adapters: knownAdapters
|
||||
}
|
668
app/node_modules/axios/lib/adapters/http.js
generated
vendored
@ -1,668 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
import utils from './../utils.js';
|
||||
import settle from './../core/settle.js';
|
||||
import buildFullPath from '../core/buildFullPath.js';
|
||||
import buildURL from './../helpers/buildURL.js';
|
||||
import {getProxyForUrl} from 'proxy-from-env';
|
||||
import http from 'http';
|
||||
import https from 'https';
|
||||
import util from 'util';
|
||||
import followRedirects from 'follow-redirects';
|
||||
import zlib from 'zlib';
|
||||
import {VERSION} from '../env/data.js';
|
||||
import transitionalDefaults from '../defaults/transitional.js';
|
||||
import AxiosError from '../core/AxiosError.js';
|
||||
import CanceledError from '../cancel/CanceledError.js';
|
||||
import platform from '../platform/index.js';
|
||||
import fromDataURI from '../helpers/fromDataURI.js';
|
||||
import stream from 'stream';
|
||||
import AxiosHeaders from '../core/AxiosHeaders.js';
|
||||
import AxiosTransformStream from '../helpers/AxiosTransformStream.js';
|
||||
import EventEmitter from 'events';
|
||||
import formDataToStream from "../helpers/formDataToStream.js";
|
||||
import readBlob from "../helpers/readBlob.js";
|
||||
import ZlibHeaderTransformStream from '../helpers/ZlibHeaderTransformStream.js';
|
||||
import callbackify from "../helpers/callbackify.js";
|
||||
|
||||
const zlibOptions = {
|
||||
flush: zlib.constants.Z_SYNC_FLUSH,
|
||||
finishFlush: zlib.constants.Z_SYNC_FLUSH
|
||||
};
|
||||
|
||||
const brotliOptions = {
|
||||
flush: zlib.constants.BROTLI_OPERATION_FLUSH,
|
||||
finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH
|
||||
}
|
||||
|
||||
const isBrotliSupported = utils.isFunction(zlib.createBrotliDecompress);
|
||||
|
||||
const {http: httpFollow, https: httpsFollow} = followRedirects;
|
||||
|
||||
const isHttps = /https:?/;
|
||||
|
||||
const supportedProtocols = platform.protocols.map(protocol => {
|
||||
return protocol + ':';
|
||||
});
|
||||
|
||||
/**
|
||||
* If the proxy or config beforeRedirects functions are defined, call them with the options
|
||||
* object.
|
||||
*
|
||||
* @param {Object<string, any>} options - The options object that was passed to the request.
|
||||
*
|
||||
* @returns {Object<string, any>}
|
||||
*/
|
||||
function dispatchBeforeRedirect(options) {
|
||||
if (options.beforeRedirects.proxy) {
|
||||
options.beforeRedirects.proxy(options);
|
||||
}
|
||||
if (options.beforeRedirects.config) {
|
||||
options.beforeRedirects.config(options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the proxy or config afterRedirects functions are defined, call them with the options
|
||||
*
|
||||
* @param {http.ClientRequestArgs} options
|
||||
* @param {AxiosProxyConfig} configProxy configuration from Axios options object
|
||||
* @param {string} location
|
||||
*
|
||||
* @returns {http.ClientRequestArgs}
|
||||
*/
|
||||
function setProxy(options, configProxy, location) {
|
||||
let proxy = configProxy;
|
||||
if (!proxy && proxy !== false) {
|
||||
const proxyUrl = getProxyForUrl(location);
|
||||
if (proxyUrl) {
|
||||
proxy = new URL(proxyUrl);
|
||||
}
|
||||
}
|
||||
if (proxy) {
|
||||
// Basic proxy authorization
|
||||
if (proxy.username) {
|
||||
proxy.auth = (proxy.username || '') + ':' + (proxy.password || '');
|
||||
}
|
||||
|
||||
if (proxy.auth) {
|
||||
// Support proxy auth object form
|
||||
if (proxy.auth.username || proxy.auth.password) {
|
||||
proxy.auth = (proxy.auth.username || '') + ':' + (proxy.auth.password || '');
|
||||
}
|
||||
const base64 = Buffer
|
||||
.from(proxy.auth, 'utf8')
|
||||
.toString('base64');
|
||||
options.headers['Proxy-Authorization'] = 'Basic ' + base64;
|
||||
}
|
||||
|
||||
options.headers.host = options.hostname + (options.port ? ':' + options.port : '');
|
||||
const proxyHost = proxy.hostname || proxy.host;
|
||||
options.hostname = proxyHost;
|
||||
// Replace 'host' since options is not a URL object
|
||||
options.host = proxyHost;
|
||||
options.port = proxy.port;
|
||||
options.path = location;
|
||||
if (proxy.protocol) {
|
||||
options.protocol = proxy.protocol.includes(':') ? proxy.protocol : `${proxy.protocol}:`;
|
||||
}
|
||||
}
|
||||
|
||||
options.beforeRedirects.proxy = function beforeRedirect(redirectOptions) {
|
||||
// Configure proxy for redirected request, passing the original config proxy to apply
|
||||
// the exact same logic as if the redirected request was performed by axios directly.
|
||||
setProxy(redirectOptions, configProxy, redirectOptions.href);
|
||||
};
|
||||
}
|
||||
|
||||
const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(process) === 'process';
|
||||
|
||||
// temporary hotfix
|
||||
|
||||
const wrapAsync = (asyncExecutor) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let onDone;
|
||||
let isDone;
|
||||
|
||||
const done = (value, isRejected) => {
|
||||
if (isDone) return;
|
||||
isDone = true;
|
||||
onDone && onDone(value, isRejected);
|
||||
}
|
||||
|
||||
const _resolve = (value) => {
|
||||
done(value);
|
||||
resolve(value);
|
||||
};
|
||||
|
||||
const _reject = (reason) => {
|
||||
done(reason, true);
|
||||
reject(reason);
|
||||
}
|
||||
|
||||
asyncExecutor(_resolve, _reject, (onDoneHandler) => (onDone = onDoneHandler)).catch(_reject);
|
||||
})
|
||||
};
|
||||
|
||||
/*eslint consistent-return:0*/
|
||||
export default isHttpAdapterSupported && function httpAdapter(config) {
|
||||
return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
|
||||
let {data, lookup, family} = config;
|
||||
const {responseType, responseEncoding} = config;
|
||||
const method = config.method.toUpperCase();
|
||||
let isDone;
|
||||
let rejected = false;
|
||||
let req;
|
||||
|
||||
if (lookup && utils.isAsyncFn(lookup)) {
|
||||
lookup = callbackify(lookup, (entry) => {
|
||||
if(utils.isString(entry)) {
|
||||
entry = [entry, entry.indexOf('.') < 0 ? 6 : 4]
|
||||
} else if (!utils.isArray(entry)) {
|
||||
throw new TypeError('lookup async function must return an array [ip: string, family: number]]')
|
||||
}
|
||||
return entry;
|
||||
})
|
||||
}
|
||||
|
||||
// temporary internal emitter until the AxiosRequest class will be implemented
|
||||
const emitter = new EventEmitter();
|
||||
|
||||
const onFinished = () => {
|
||||
if (config.cancelToken) {
|
||||
config.cancelToken.unsubscribe(abort);
|
||||
}
|
||||
|
||||
if (config.signal) {
|
||||
config.signal.removeEventListener('abort', abort);
|
||||
}
|
||||
|
||||
emitter.removeAllListeners();
|
||||
}
|
||||
|
||||
onDone((value, isRejected) => {
|
||||
isDone = true;
|
||||
if (isRejected) {
|
||||
rejected = true;
|
||||
onFinished();
|
||||
}
|
||||
});
|
||||
|
||||
function abort(reason) {
|
||||
emitter.emit('abort', !reason || reason.type ? new CanceledError(null, config, req) : reason);
|
||||
}
|
||||
|
||||
emitter.once('abort', reject);
|
||||
|
||||
if (config.cancelToken || config.signal) {
|
||||
config.cancelToken && config.cancelToken.subscribe(abort);
|
||||
if (config.signal) {
|
||||
config.signal.aborted ? abort() : config.signal.addEventListener('abort', abort);
|
||||
}
|
||||
}
|
||||
|
||||
// Parse url
|
||||
const fullPath = buildFullPath(config.baseURL, config.url);
|
||||
const parsed = new URL(fullPath, 'http://localhost');
|
||||
const protocol = parsed.protocol || supportedProtocols[0];
|
||||
|
||||
if (protocol === 'data:') {
|
||||
let convertedData;
|
||||
|
||||
if (method !== 'GET') {
|
||||
return settle(resolve, reject, {
|
||||
status: 405,
|
||||
statusText: 'method not allowed',
|
||||
headers: {},
|
||||
config
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
convertedData = fromDataURI(config.url, responseType === 'blob', {
|
||||
Blob: config.env && config.env.Blob
|
||||
});
|
||||
} catch (err) {
|
||||
throw AxiosError.from(err, AxiosError.ERR_BAD_REQUEST, config);
|
||||
}
|
||||
|
||||
if (responseType === 'text') {
|
||||
convertedData = convertedData.toString(responseEncoding);
|
||||
|
||||
if (!responseEncoding || responseEncoding === 'utf8') {
|
||||
convertedData = utils.stripBOM(convertedData);
|
||||
}
|
||||
} else if (responseType === 'stream') {
|
||||
convertedData = stream.Readable.from(convertedData);
|
||||
}
|
||||
|
||||
return settle(resolve, reject, {
|
||||
data: convertedData,
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: new AxiosHeaders(),
|
||||
config
|
||||
});
|
||||
}
|
||||
|
||||
if (supportedProtocols.indexOf(protocol) === -1) {
|
||||
return reject(new AxiosError(
|
||||
'Unsupported protocol ' + protocol,
|
||||
AxiosError.ERR_BAD_REQUEST,
|
||||
config
|
||||
));
|
||||
}
|
||||
|
||||
const headers = AxiosHeaders.from(config.headers).normalize();
|
||||
|
||||
// Set User-Agent (required by some servers)
|
||||
// See https://github.com/axios/axios/issues/69
|
||||
// User-Agent is specified; handle case where no UA header is desired
|
||||
// Only set header if it hasn't been set in config
|
||||
headers.set('User-Agent', 'axios/' + VERSION, false);
|
||||
|
||||
const onDownloadProgress = config.onDownloadProgress;
|
||||
const onUploadProgress = config.onUploadProgress;
|
||||
const maxRate = config.maxRate;
|
||||
let maxUploadRate = undefined;
|
||||
let maxDownloadRate = undefined;
|
||||
|
||||
// support for spec compliant FormData objects
|
||||
if (utils.isSpecCompliantForm(data)) {
|
||||
const userBoundary = headers.getContentType(/boundary=([-_\w\d]{10,70})/i);
|
||||
|
||||
data = formDataToStream(data, (formHeaders) => {
|
||||
headers.set(formHeaders);
|
||||
}, {
|
||||
tag: `axios-${VERSION}-boundary`,
|
||||
boundary: userBoundary && userBoundary[1] || undefined
|
||||
});
|
||||
// support for https://www.npmjs.com/package/form-data api
|
||||
} else if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) {
|
||||
headers.set(data.getHeaders());
|
||||
|
||||
if (!headers.hasContentLength()) {
|
||||
try {
|
||||
const knownLength = await util.promisify(data.getLength).call(data);
|
||||
Number.isFinite(knownLength) && knownLength >= 0 && headers.setContentLength(knownLength);
|
||||
/*eslint no-empty:0*/
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
} else if (utils.isBlob(data)) {
|
||||
data.size && headers.setContentType(data.type || 'application/octet-stream');
|
||||
headers.setContentLength(data.size || 0);
|
||||
data = stream.Readable.from(readBlob(data));
|
||||
} else if (data && !utils.isStream(data)) {
|
||||
if (Buffer.isBuffer(data)) {
|
||||
// Nothing to do...
|
||||
} else if (utils.isArrayBuffer(data)) {
|
||||
data = Buffer.from(new Uint8Array(data));
|
||||
} else if (utils.isString(data)) {
|
||||
data = Buffer.from(data, 'utf-8');
|
||||
} else {
|
||||
return reject(new AxiosError(
|
||||
'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
|
||||
AxiosError.ERR_BAD_REQUEST,
|
||||
config
|
||||
));
|
||||
}
|
||||
|
||||
// Add Content-Length header if data exists
|
||||
headers.setContentLength(data.length, false);
|
||||
|
||||
if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
|
||||
return reject(new AxiosError(
|
||||
'Request body larger than maxBodyLength limit',
|
||||
AxiosError.ERR_BAD_REQUEST,
|
||||
config
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
const contentLength = utils.toFiniteNumber(headers.getContentLength());
|
||||
|
||||
if (utils.isArray(maxRate)) {
|
||||
maxUploadRate = maxRate[0];
|
||||
maxDownloadRate = maxRate[1];
|
||||
} else {
|
||||
maxUploadRate = maxDownloadRate = maxRate;
|
||||
}
|
||||
|
||||
if (data && (onUploadProgress || maxUploadRate)) {
|
||||
if (!utils.isStream(data)) {
|
||||
data = stream.Readable.from(data, {objectMode: false});
|
||||
}
|
||||
|
||||
data = stream.pipeline([data, new AxiosTransformStream({
|
||||
length: contentLength,
|
||||
maxRate: utils.toFiniteNumber(maxUploadRate)
|
||||
})], utils.noop);
|
||||
|
||||
onUploadProgress && data.on('progress', progress => {
|
||||
onUploadProgress(Object.assign(progress, {
|
||||
upload: true
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
// HTTP basic authentication
|
||||
let auth = undefined;
|
||||
if (config.auth) {
|
||||
const username = config.auth.username || '';
|
||||
const password = config.auth.password || '';
|
||||
auth = username + ':' + password;
|
||||
}
|
||||
|
||||
if (!auth && parsed.username) {
|
||||
const urlUsername = parsed.username;
|
||||
const urlPassword = parsed.password;
|
||||
auth = urlUsername + ':' + urlPassword;
|
||||
}
|
||||
|
||||
auth && headers.delete('authorization');
|
||||
|
||||
let path;
|
||||
|
||||
try {
|
||||
path = buildURL(
|
||||
parsed.pathname + parsed.search,
|
||||
config.params,
|
||||
config.paramsSerializer
|
||||
).replace(/^\?/, '');
|
||||
} catch (err) {
|
||||
const customErr = new Error(err.message);
|
||||
customErr.config = config;
|
||||
customErr.url = config.url;
|
||||
customErr.exists = true;
|
||||
return reject(customErr);
|
||||
}
|
||||
|
||||
headers.set(
|
||||
'Accept-Encoding',
|
||||
'gzip, compress, deflate' + (isBrotliSupported ? ', br' : ''), false
|
||||
);
|
||||
|
||||
const options = {
|
||||
path,
|
||||
method: method,
|
||||
headers: headers.toJSON(),
|
||||
agents: { http: config.httpAgent, https: config.httpsAgent },
|
||||
auth,
|
||||
protocol,
|
||||
family,
|
||||
beforeRedirect: dispatchBeforeRedirect,
|
||||
beforeRedirects: {}
|
||||
};
|
||||
|
||||
// cacheable-lookup integration hotfix
|
||||
!utils.isUndefined(lookup) && (options.lookup = lookup);
|
||||
|
||||
if (config.socketPath) {
|
||||
options.socketPath = config.socketPath;
|
||||
} else {
|
||||
options.hostname = parsed.hostname;
|
||||
options.port = parsed.port;
|
||||
setProxy(options, config.proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
|
||||
}
|
||||
|
||||
let transport;
|
||||
const isHttpsRequest = isHttps.test(options.protocol);
|
||||
options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
|
||||
if (config.transport) {
|
||||
transport = config.transport;
|
||||
} else if (config.maxRedirects === 0) {
|
||||
transport = isHttpsRequest ? https : http;
|
||||
} else {
|
||||
if (config.maxRedirects) {
|
||||
options.maxRedirects = config.maxRedirects;
|
||||
}
|
||||
if (config.beforeRedirect) {
|
||||
options.beforeRedirects.config = config.beforeRedirect;
|
||||
}
|
||||
transport = isHttpsRequest ? httpsFollow : httpFollow;
|
||||
}
|
||||
|
||||
if (config.maxBodyLength > -1) {
|
||||
options.maxBodyLength = config.maxBodyLength;
|
||||
} else {
|
||||
// follow-redirects does not skip comparison, so it should always succeed for axios -1 unlimited
|
||||
options.maxBodyLength = Infinity;
|
||||
}
|
||||
|
||||
if (config.insecureHTTPParser) {
|
||||
options.insecureHTTPParser = config.insecureHTTPParser;
|
||||
}
|
||||
|
||||
// Create the request
|
||||
req = transport.request(options, function handleResponse(res) {
|
||||
if (req.destroyed) return;
|
||||
|
||||
const streams = [res];
|
||||
|
||||
const responseLength = +res.headers['content-length'];
|
||||
|
||||
if (onDownloadProgress) {
|
||||
const transformStream = new AxiosTransformStream({
|
||||
length: utils.toFiniteNumber(responseLength),
|
||||
maxRate: utils.toFiniteNumber(maxDownloadRate)
|
||||
});
|
||||
|
||||
onDownloadProgress && transformStream.on('progress', progress => {
|
||||
onDownloadProgress(Object.assign(progress, {
|
||||
download: true
|
||||
}));
|
||||
});
|
||||
|
||||
streams.push(transformStream);
|
||||
}
|
||||
|
||||
// decompress the response body transparently if required
|
||||
let responseStream = res;
|
||||
|
||||
// return the last request in case of redirects
|
||||
const lastRequest = res.req || req;
|
||||
|
||||
// if decompress disabled we should not decompress
|
||||
if (config.decompress !== false && res.headers['content-encoding']) {
|
||||
// if no content, but headers still say that it is encoded,
|
||||
// remove the header not confuse downstream operations
|
||||
if (method === 'HEAD' || res.statusCode === 204) {
|
||||
delete res.headers['content-encoding'];
|
||||
}
|
||||
|
||||
switch (res.headers['content-encoding']) {
|
||||
/*eslint default-case:0*/
|
||||
case 'gzip':
|
||||
case 'x-gzip':
|
||||
case 'compress':
|
||||
case 'x-compress':
|
||||
// add the unzipper to the body stream processing pipeline
|
||||
streams.push(zlib.createUnzip(zlibOptions));
|
||||
|
||||
// remove the content-encoding in order to not confuse downstream operations
|
||||
delete res.headers['content-encoding'];
|
||||
break;
|
||||
case 'deflate':
|
||||
streams.push(new ZlibHeaderTransformStream());
|
||||
|
||||
// add the unzipper to the body stream processing pipeline
|
||||
streams.push(zlib.createUnzip(zlibOptions));
|
||||
|
||||
// remove the content-encoding in order to not confuse downstream operations
|
||||
delete res.headers['content-encoding'];
|
||||
break;
|
||||
case 'br':
|
||||
if (isBrotliSupported) {
|
||||
streams.push(zlib.createBrotliDecompress(brotliOptions));
|
||||
delete res.headers['content-encoding'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
responseStream = streams.length > 1 ? stream.pipeline(streams, utils.noop) : streams[0];
|
||||
|
||||
const offListeners = stream.finished(responseStream, () => {
|
||||
offListeners();
|
||||
onFinished();
|
||||
});
|
||||
|
||||
const response = {
|
||||
status: res.statusCode,
|
||||
statusText: res.statusMessage,
|
||||
headers: new AxiosHeaders(res.headers),
|
||||
config,
|
||||
request: lastRequest
|
||||
};
|
||||
|
||||
if (responseType === 'stream') {
|
||||
response.data = responseStream;
|
||||
settle(resolve, reject, response);
|
||||
} else {
|
||||
const responseBuffer = [];
|
||||
let totalResponseBytes = 0;
|
||||
|
||||
responseStream.on('data', function handleStreamData(chunk) {
|
||||
responseBuffer.push(chunk);
|
||||
totalResponseBytes += chunk.length;
|
||||
|
||||
// make sure the content length is not over the maxContentLength if specified
|
||||
if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
|
||||
// stream.destroy() emit aborted event before calling reject() on Node.js v16
|
||||
rejected = true;
|
||||
responseStream.destroy();
|
||||
reject(new AxiosError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
|
||||
AxiosError.ERR_BAD_RESPONSE, config, lastRequest));
|
||||
}
|
||||
});
|
||||
|
||||
responseStream.on('aborted', function handlerStreamAborted() {
|
||||
if (rejected) {
|
||||
return;
|
||||
}
|
||||
|
||||
const err = new AxiosError(
|
||||
'maxContentLength size of ' + config.maxContentLength + ' exceeded',
|
||||
AxiosError.ERR_BAD_RESPONSE,
|
||||
config,
|
||||
lastRequest
|
||||
);
|
||||
responseStream.destroy(err);
|
||||
reject(err);
|
||||
});
|
||||
|
||||
responseStream.on('error', function handleStreamError(err) {
|
||||
if (req.destroyed) return;
|
||||
reject(AxiosError.from(err, null, config, lastRequest));
|
||||
});
|
||||
|
||||
responseStream.on('end', function handleStreamEnd() {
|
||||
try {
|
||||
let responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer);
|
||||
if (responseType !== 'arraybuffer') {
|
||||
responseData = responseData.toString(responseEncoding);
|
||||
if (!responseEncoding || responseEncoding === 'utf8') {
|
||||
responseData = utils.stripBOM(responseData);
|
||||
}
|
||||
}
|
||||
response.data = responseData;
|
||||
} catch (err) {
|
||||
reject(AxiosError.from(err, null, config, response.request, response));
|
||||
}
|
||||
settle(resolve, reject, response);
|
||||
});
|
||||
}
|
||||
|
||||
emitter.once('abort', err => {
|
||||
if (!responseStream.destroyed) {
|
||||
responseStream.emit('error', err);
|
||||
responseStream.destroy();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
emitter.once('abort', err => {
|
||||
reject(err);
|
||||
req.destroy(err);
|
||||
});
|
||||
|
||||
// Handle errors
|
||||
req.on('error', function handleRequestError(err) {
|
||||
// @todo remove
|
||||
// if (req.aborted && err.code !== AxiosError.ERR_FR_TOO_MANY_REDIRECTS) return;
|
||||
reject(AxiosError.from(err, null, config, req));
|
||||
});
|
||||
|
||||
// set tcp keep alive to prevent drop connection by peer
|
||||
req.on('socket', function handleRequestSocket(socket) {
|
||||
// default interval of sending ack packet is 1 minute
|
||||
socket.setKeepAlive(true, 1000 * 60);
|
||||
});
|
||||
|
||||
// Handle request timeout
|
||||
if (config.timeout) {
|
||||
// This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
|
||||
const timeout = parseInt(config.timeout, 10);
|
||||
|
||||
if (isNaN(timeout)) {
|
||||
reject(new AxiosError(
|
||||
'error trying to parse `config.timeout` to int',
|
||||
AxiosError.ERR_BAD_OPTION_VALUE,
|
||||
config,
|
||||
req
|
||||
));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
|
||||
// And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
|
||||
// At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
|
||||
// And then these socket which be hang up will devouring CPU little by little.
|
||||
// ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
|
||||
req.setTimeout(timeout, function handleRequestTimeout() {
|
||||
if (isDone) return;
|
||||
let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
|
||||
const transitional = config.transitional || transitionalDefaults;
|
||||
if (config.timeoutErrorMessage) {
|
||||
timeoutErrorMessage = config.timeoutErrorMessage;
|
||||
}
|
||||
reject(new AxiosError(
|
||||
timeoutErrorMessage,
|
||||
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
||||
config,
|
||||
req
|
||||
));
|
||||
abort();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Send the request
|
||||
if (utils.isStream(data)) {
|
||||
let ended = false;
|
||||
let errored = false;
|
||||
|
||||
data.on('end', () => {
|
||||
ended = true;
|
||||
});
|
||||
|
||||
data.once('error', err => {
|
||||
errored = true;
|
||||
req.destroy(err);
|
||||
});
|
||||
|
||||
data.on('close', () => {
|
||||
if (!ended && !errored) {
|
||||
abort(new CanceledError('Request stream has been aborted', config, req));
|
||||
}
|
||||
});
|
||||
|
||||
data.pipe(req);
|
||||
} else {
|
||||
req.end(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export const __setProxy = setProxy;
|
253
app/node_modules/axios/lib/adapters/xhr.js
generated
vendored
@ -1,253 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
import utils from './../utils.js';
|
||||
import settle from './../core/settle.js';
|
||||
import cookies from './../helpers/cookies.js';
|
||||
import buildURL from './../helpers/buildURL.js';
|
||||
import buildFullPath from '../core/buildFullPath.js';
|
||||
import isURLSameOrigin from './../helpers/isURLSameOrigin.js';
|
||||
import transitionalDefaults from '../defaults/transitional.js';
|
||||
import AxiosError from '../core/AxiosError.js';
|
||||
import CanceledError from '../cancel/CanceledError.js';
|
||||
import parseProtocol from '../helpers/parseProtocol.js';
|
||||
import platform from '../platform/index.js';
|
||||
import AxiosHeaders from '../core/AxiosHeaders.js';
|
||||
import speedometer from '../helpers/speedometer.js';
|
||||
|
||||
function progressEventReducer(listener, isDownloadStream) {
|
||||
let bytesNotified = 0;
|
||||
const _speedometer = speedometer(50, 250);
|
||||
|
||||
return e => {
|
||||
const loaded = e.loaded;
|
||||
const total = e.lengthComputable ? e.total : undefined;
|
||||
const progressBytes = loaded - bytesNotified;
|
||||
const rate = _speedometer(progressBytes);
|
||||
const inRange = loaded <= total;
|
||||
|
||||
bytesNotified = loaded;
|
||||
|
||||
const data = {
|
||||
loaded,
|
||||
total,
|
||||
progress: total ? (loaded / total) : undefined,
|
||||
bytes: progressBytes,
|
||||
rate: rate ? rate : undefined,
|
||||
estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
||||
event: e
|
||||
};
|
||||
|
||||
data[isDownloadStream ? 'download' : 'upload'] = true;
|
||||
|
||||
listener(data);
|
||||
};
|
||||
}
|
||||
|
||||
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
||||
|
||||
export default isXHRAdapterSupported && function (config) {
|
||||
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
||||
let requestData = config.data;
|
||||
const requestHeaders = AxiosHeaders.from(config.headers).normalize();
|
||||
const responseType = config.responseType;
|
||||
let onCanceled;
|
||||
function done() {
|
||||
if (config.cancelToken) {
|
||||
config.cancelToken.unsubscribe(onCanceled);
|
||||
}
|
||||
|
||||
if (config.signal) {
|
||||
config.signal.removeEventListener('abort', onCanceled);
|
||||
}
|
||||
}
|
||||
|
||||
if (utils.isFormData(requestData)) {
|
||||
if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) {
|
||||
requestHeaders.setContentType(false); // Let the browser set it
|
||||
} else {
|
||||
requestHeaders.setContentType('multipart/form-data;', false); // mobile/desktop app frameworks
|
||||
}
|
||||
}
|
||||
|
||||
let request = new XMLHttpRequest();
|
||||
|
||||
// HTTP basic authentication
|
||||
if (config.auth) {
|
||||
const username = config.auth.username || '';
|
||||
const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
|
||||
requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
|
||||
}
|
||||
|
||||
const fullPath = buildFullPath(config.baseURL, config.url);
|
||||
|
||||
request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
|
||||
|
||||
// Set the request timeout in MS
|
||||
request.timeout = config.timeout;
|
||||
|
||||
function onloadend() {
|
||||
if (!request) {
|
||||
return;
|
||||
}
|
||||
// Prepare the response
|
||||
const responseHeaders = AxiosHeaders.from(
|
||||
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
||||
);
|
||||
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
||||
request.responseText : request.response;
|
||||
const response = {
|
||||
data: responseData,
|
||||
status: request.status,
|
||||
statusText: request.statusText,
|
||||
headers: responseHeaders,
|
||||
config,
|
||||
request
|
||||
};
|
||||
|
||||
settle(function _resolve(value) {
|
||||
resolve(value);
|
||||
done();
|
||||
}, function _reject(err) {
|
||||
reject(err);
|
||||
done();
|
||||
}, response);
|
||||
|
||||
// Clean up request
|
||||
request = null;
|
||||
}
|
||||
|
||||
if ('onloadend' in request) {
|
||||
// Use onloadend if available
|
||||
request.onloadend = onloadend;
|
||||
} else {
|
||||
// Listen for ready state to emulate onloadend
|
||||
request.onreadystatechange = function handleLoad() {
|
||||
if (!request || request.readyState !== 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The request errored out and we didn't get a response, this will be
|
||||
// handled by onerror instead
|
||||
// With one exception: request that using file: protocol, most browsers
|
||||
// will return status as 0 even though it's a successful request
|
||||
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
||||
return;
|
||||
}
|
||||
// readystate handler is calling before onerror or ontimeout handlers,
|
||||
// so we should call onloadend on the next 'tick'
|
||||
setTimeout(onloadend);
|
||||
};
|
||||
}
|
||||
|
||||
// Handle browser request cancellation (as opposed to a manual cancellation)
|
||||
request.onabort = function handleAbort() {
|
||||
if (!request) {
|
||||
return;
|
||||
}
|
||||
|
||||
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
||||
|
||||
// Clean up request
|
||||
request = null;
|
||||
};
|
||||
|
||||
// Handle low level network errors
|
||||
request.onerror = function handleError() {
|
||||
// Real errors are hidden from us by the browser
|
||||
// onerror should only fire if it's a network error
|
||||
reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
|
||||
|
||||
// Clean up request
|
||||
request = null;
|
||||
};
|
||||
|
||||
// Handle timeout
|
||||
request.ontimeout = function handleTimeout() {
|
||||
let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
|
||||
const transitional = config.transitional || transitionalDefaults;
|
||||
if (config.timeoutErrorMessage) {
|
||||
timeoutErrorMessage = config.timeoutErrorMessage;
|
||||
}
|
||||
reject(new AxiosError(
|
||||
timeoutErrorMessage,
|
||||
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
||||
config,
|
||||
request));
|
||||
|
||||
// Clean up request
|
||||
request = null;
|
||||
};
|
||||
|
||||
// Add xsrf header
|
||||
// This is only done if running in a standard browser environment.
|
||||
// Specifically not if we're in a web worker, or react-native.
|
||||
if (platform.isStandardBrowserEnv) {
|
||||
// Add xsrf header
|
||||
const xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath))
|
||||
&& config.xsrfCookieName && cookies.read(config.xsrfCookieName);
|
||||
|
||||
if (xsrfValue) {
|
||||
requestHeaders.set(config.xsrfHeaderName, xsrfValue);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove Content-Type if data is undefined
|
||||
requestData === undefined && requestHeaders.setContentType(null);
|
||||
|
||||
// Add headers to the request
|
||||
if ('setRequestHeader' in request) {
|
||||
utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
||||
request.setRequestHeader(key, val);
|
||||
});
|
||||
}
|
||||
|
||||
// Add withCredentials to request if needed
|
||||
if (!utils.isUndefined(config.withCredentials)) {
|
||||
request.withCredentials = !!config.withCredentials;
|
||||
}
|
||||
|
||||
// Add responseType to request if needed
|
||||
if (responseType && responseType !== 'json') {
|
||||
request.responseType = config.responseType;
|
||||
}
|
||||
|
||||
// Handle progress if needed
|
||||
if (typeof config.onDownloadProgress === 'function') {
|
||||
request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));
|
||||
}
|
||||
|
||||
// Not all browsers support upload events
|
||||
if (typeof config.onUploadProgress === 'function' && request.upload) {
|
||||
request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));
|
||||
}
|
||||
|
||||
if (config.cancelToken || config.signal) {
|
||||
// Handle cancellation
|
||||
// eslint-disable-next-line func-names
|
||||
onCanceled = cancel => {
|
||||
if (!request) {
|
||||
return;
|
||||
}
|
||||
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
|
||||
request.abort();
|
||||
request = null;
|
||||
};
|
||||
|
||||
config.cancelToken && config.cancelToken.subscribe(onCanceled);
|
||||
if (config.signal) {
|
||||
config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
|
||||
}
|
||||
}
|
||||
|
||||
const protocol = parseProtocol(fullPath);
|
||||
|
||||
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
||||
reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Send the request
|
||||
request.send(requestData || null);
|
||||
});
|
||||
}
|