Merge pull request #1 from UBARSTUPAR/pre-prod

Pre prod
This commit is contained in:
2026-05-03 20:37:04 +02:00
committed by GitHub
27112 changed files with 1695 additions and 3752563 deletions
+22 -21
View File
@@ -2,13 +2,13 @@ name: Backend - Build & Lint
on:
push:
branches: [main]
branches: [main, pre-prod]
paths:
- "backend/**/**"
- "backend/**"
pull_request:
branches: [main]
branches: [main, pre-prod]
paths:
- "backend/**/**"
- "backend/**"
jobs:
lint:
@@ -54,31 +54,26 @@ jobs:
working-directory: backend/gestion
run: go build -v ./...
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: backend-binary
path: backend/gestion/gestion
retention-days: 7
docker:
name: Docker Build & Push
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: >
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/pre-prod')) ||
(github.event_name == 'pull_request' && (github.base_ref == 'main' || github.base_ref == 'pre-prod'))
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build & push backend (runtime)
uses: docker/build-push-action@v6
with:
@@ -86,7 +81,9 @@ jobs:
file: docker/backend/Dockerfile
target: runtime
push: true
tags: xor1234/backend-mln:latest
tags: xor1234/backend-mln:${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && 'latest' || 'pre-prod' }}
cache-from: type=gha,scope=backend-runtime
cache-to: type=gha,mode=max,scope=backend-runtime
- name: Build & push WAF
uses: docker/build-push-action@v6
@@ -95,21 +92,25 @@ jobs:
file: docker/backend/Dockerfile
target: waf
push: true
tags: xor1234/backend-mln:waf
tags: xor1234/backend-mln:${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && 'waf' || 'waf-pre-prod' }}
cache-from: type=gha,scope=backend-waf
cache-to: type=gha,mode=max,scope=backend-waf
deploy:
name: SSH Deploy
name: Deploy to server
needs: docker
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: >
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/pre-prod')) ||
(github.event_name == 'pull_request' && (github.base_ref == 'main' || github.base_ref == 'pre-prod'))
steps:
- name: SSH deploy
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SERVER_HOST }}
host: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && secrets.SERVER_HOST_PROD || secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
key: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && secrets.SERVER_SSH_KEY_PROD || secrets.SERVER_SSH_KEY }}
script: |
docker compose -f ${{ secrets.COMPOSE_PATH }} pull backend waf
docker compose -f ${{ secrets.COMPOSE_PATH }} up -d --no-deps backend waf
+5 -4
View File
@@ -2,11 +2,11 @@ name: Frontend Admin - EAS Build
on:
push:
branches: [main]
branches: [main, pre-prod]
paths:
- "frontend-admin/**"
pull_request:
branches: [main]
branches: [main, pre-prod]
paths:
- "frontend-admin/**"
@@ -32,9 +32,10 @@ jobs:
working-directory: frontend-admin
run: npx tsc --noEmit
build-apk-prod:
build-apk-pre-prod:
needs: typecheck
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/pre-prod'
steps:
- uses: actions/checkout@v4
@@ -66,7 +67,7 @@ jobs:
working-directory: frontend-admin
env:
EAS_BUILD_NO_EXPO_GO_WARNING: true
run: eas build --platform android --profile production --non-interactive
run: eas build --platform android --profile pre-production --non-interactive
- name: Download production APK
working-directory: frontend-admin
+3 -2
View File
@@ -2,11 +2,11 @@ name: Frontend Client - EAS Build
on:
push:
branches: [main]
branches: [main, pre-prod]
paths:
- "mobile/**"
pull_request:
branches: [main]
branches: [main, pre-prod]
paths:
- "mobile/**"
@@ -35,6 +35,7 @@ jobs:
build-apk-prod:
needs: typecheck
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/pre-prod'
steps:
- uses: actions/checkout@v4
+17 -18
View File
@@ -2,12 +2,12 @@ name: Frontend Web - Build & Lint
on:
push:
branches: [main]
branches: [main, pre-prod]
paths:
- "frontend-prep/**"
- "docker/frontend/**"
pull_request:
branches: [main]
branches: [main, pre-prod]
paths:
- "frontend-prep/**"
- "docker/frontend/**"
@@ -64,52 +64,51 @@ jobs:
VITE_TOMTOM_API_KEY: ${{ secrets.VITE_TOMTOM_API_KEY }}
run: npm run build
- name: Upload dist artifact
uses: actions/upload-artifact@v4
with:
name: frontend-web-dist
path: frontend-prep/dist
retention-days: 7
docker:
name: Docker Build & Push
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: >
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/pre-prod')) ||
(github.event_name == 'pull_request' && (github.base_ref == 'main' || github.base_ref == 'pre-prod'))
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build & push frontend
uses: docker/build-push-action@v6
with:
context: .
file: docker/frontend/Dockerfile
push: true
tags: xor1234/frontend-mln:latest
tags: xor1234/frontend-mln:${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && 'latest' || 'pre-prod' }}
build-args: |
VITE_TOMTOM_API_KEY=${{ secrets.VITE_TOMTOM_API_KEY }}
deploy:
name: SSH Deploy
name: Deploy to server
needs: docker
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: >
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/pre-prod')) ||
(github.event_name == 'pull_request' && (github.base_ref == 'main' || github.base_ref == 'pre-prod'))
steps:
- name: SSH deploy
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SERVER_HOST_PROD }}
host: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && secrets.SERVER_HOST_PROD || secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY_PROD }}
key: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && secrets.SERVER_SSH_KEY_PROD || secrets.SERVER_SSH_KEY }}
script: |
docker compose -f ${{ secrets.COMPOSE_PATH }} pull frontend
docker compose -f ${{ secrets.COMPOSE_PATH }} up -d --no-deps frontend
+5
View File
@@ -256,6 +256,11 @@ func (d *Database) ClearBasket(username string) error {
})
}
// ClearBasketOnCheckout vide le panier après commande validée SANS restituer le stock.
func (d *Database) ClearBasketOnCheckout(username string) error {
return d.GDB.Exec(`DELETE FROM baskets WHERE username = ?`, username).Error
}
// GetBasketTotal calcule le montant total du panier d'un utilisateur
func (d *Database) GetBasketTotal(username string) (float64, error) {
var result struct {
+14 -9
View File
@@ -231,14 +231,7 @@ func (d *Database) CreateCommandWithAddress(username, deliveryAddress string) (*
return nil, fmt.Errorf("erreur insertion items: %w", err)
}
result := d.GDB.Model(&models.Product{}).Where("id = ? AND stock >= ?", item.ProductID, item.Quantity).UpdateColumn("stock", gorm.Expr("stock - ?", item.Quantity))
if result.Error != nil {
log.Printf("⚠️ Erreur décrémentation stock produit %d: %v", item.ProductID, result.Error)
return nil, fmt.Errorf("erreur mise à jour stock: %w", result.Error)
}
if result.RowsAffected == 0 {
log.Printf("⚠️ [CHECKOUT] Stock déjà réservé pour produit %d (double réservation panier/checkout)", item.ProductID)
}
// Stock déjà déduit à l'ajout au panier — ne pas déduire une seconde fois ici.
}
if err := d.GDB.Delete(&models.Panier{}, "username = ?", username).Error; err != nil {
@@ -265,6 +258,12 @@ func (d *Database) CreateCommandWithAddress(username, deliveryAddress string) (*
return command, nil
}
func (d *Database) GetApprovedCommands() ([]models.Command, error) {
var commands []models.Command
err := d.GDB.Where("status = ?", "approved").Order("created_at DESC").Find(&commands).Error
return commands, err
}
func (d *Database) GetAllCommands(status, username string) ([]map[string]any, error) {
if username != "" {
if err := validateUsername(username); err != nil {
@@ -290,13 +289,17 @@ func (d *Database) GetAllCommands(status, username string) ([]map[string]any, er
ProposedAddress *string `gorm:"column:proposed_address"`
AddressProposalStatus string `gorm:"column:address_proposal_status"`
ClientOrderNumber int `gorm:"column:client_order_number"`
ReferralUsed float64 `gorm:"column:referral_used"`
CancelReason string `gorm:"column:cancel_reason"`
}
gdb := d.GDB.Table("commandes c").
Select(`c.id, c.username, c.status, c.adresse, c.total_prix,
c.livreur_assign, c.created_at, c.updated_at,
c.proposed_address, c.address_proposal_status,
c.client_order_id AS client_order_number`)
c.client_order_id AS client_order_number,
COALESCE(c.referral_used, 0) AS referral_used,
COALESCE(c.cancel_reason, '') AS cancel_reason`)
if status == "" {
gdb = gdb.Where("c.status IN ?", []string{"pending", "assigned", "en_route", "arrived", "livre"})
@@ -324,6 +327,8 @@ func (d *Database) GetAllCommands(status, username string) ([]map[string]any, er
"updated_at": row.UpdatedAt,
"address_proposal_status": row.AddressProposalStatus,
"client_order_number": row.ClientOrderNumber,
"referral_used": row.ReferralUsed,
"cancel_reason": row.CancelReason,
}
if row.LivreurAssign != nil {
+4 -4
View File
@@ -24,7 +24,7 @@ func (d *Database) NotifyClient(username string, commandID int, notifType, messa
Redis.LPush(RedisCtx, notifKey, notifJSON)
Redis.Expire(RedisCtx, notifKey, 7*24*time.Hour)
if services.TelegramBot != nil && services.TelegramBot.IsConfigured() {
if services.TelegramBot != nil && services.TelegramBot.IsConfigured() && services.TelegramBot.IsNotificationsEnabled() {
if chatID, ok, err := d.GetClientTelegramChatID(username); err == nil && ok {
go services.TelegramBot.SendMessage(chatID, fmt.Sprintf("🔔 <b>Notification</b>\n\n%s", message))
}
@@ -50,7 +50,7 @@ func (d *Database) NotifyLivreur(username string, commandID int, notifType, mess
Redis.LPush(RedisCtx, notifKey, notifJSON)
Redis.Expire(RedisCtx, notifKey, 7*24*time.Hour)
if services.TelegramBot != nil && services.TelegramBot.IsConfigured() {
if services.TelegramBot != nil && services.TelegramBot.IsConfigured() && services.TelegramBot.IsNotificationsEnabled() {
if chatID, ok, err := d.GetUserTelegramChatID(username); err == nil && ok {
go services.TelegramBot.SendMessage(chatID, fmt.Sprintf("🔔 <b>Notification</b>\n\n%s", message))
}
@@ -87,7 +87,7 @@ func (d *Database) NotifyAllAdminCabine(commandID int, clientUsername, deliveryA
Redis.LPush(RedisCtx, notifKey, notifJSON)
Redis.Expire(RedisCtx, notifKey, 7*24*time.Hour)
if services.TelegramBot != nil && services.TelegramBot.IsConfigured() {
if services.TelegramBot != nil && services.TelegramBot.IsConfigured() && services.TelegramBot.IsNotificationsEnabled() {
if chatID, ok, err := d.GetUserTelegramChatID(u.Username); err == nil && ok {
capturedChatID := chatID
capturedMsg := msg
@@ -126,7 +126,7 @@ func (d *Database) NotifyAllAdminCabineAlert(alertID int, livreurUsername, alert
Redis.LPush(RedisCtx, notifKey, notifJSON)
Redis.Expire(RedisCtx, notifKey, 7*24*time.Hour)
if services.TelegramBot != nil && services.TelegramBot.IsConfigured() {
if services.TelegramBot != nil && services.TelegramBot.IsConfigured() && services.TelegramBot.IsNotificationsEnabled() {
if chatID, ok, err := d.GetUserTelegramChatID(u.Username); err == nil && ok {
capturedChatID := chatID
capturedBody := body
+11
View File
@@ -48,6 +48,17 @@ func (d *Database) DebitReferralBalance(username string, amount float64) error {
})
}
func (d *Database) ResetClientReferralBalance(username string) error {
result := d.GDB.Model(&models.Client{}).Where("username = ?", username).Update("referral_balance", 0)
if result.Error != nil {
return result.Error
}
if result.RowsAffected == 0 {
return fmt.Errorf("client non trouvé")
}
return nil
}
func (d *Database) UseClientReferralBalance(tx *gorm.DB, username string, amount float64) error {
if amount <= 0 {
return nil
+3
View File
@@ -142,6 +142,8 @@ func (d *Database) GetSettings() (models.AppSettings, error) {
settings.TelegramBotToken = row.Value
case "telegram_bot_username":
settings.TelegramBotUsername = row.Value
case "telegram_notifications_enabled":
settings.TelegramNotificationsEnabled = row.Value == "true"
case "delivery_mode":
var mode models.DeliveryModeConfig
if err := json.Unmarshal([]byte(row.Value), &mode); err == nil {
@@ -223,6 +225,7 @@ func (d *Database) UpdateSettings(s models.AppSettings) error {
{"postal_zones", string(zonesJSON)},
{"telegram_bot_token", s.TelegramBotToken},
{"telegram_bot_username", s.TelegramBotUsername},
{"telegram_notifications_enabled", boolStr(s.TelegramNotificationsEnabled)},
{"delivery_mode", string(deliveryModeJSON)},
}
+1 -1
View File
@@ -631,7 +631,7 @@ func ForceValidateDelivery(c *gin.Context) {
livreurAssign, _ := command["livreur_assign"].(string)
if clientUsername != "" {
clientMsg := fmt.Sprintf("Ta commande #%d a bien été livrée ! Bonne dégustation l'ami et à bientôt 😊", database.GetClientOrderID(commandID))
clientMsg := fmt.Sprintf("Ta commande #%d a bien été livrée ! Bonne dégustation l'ami et à bientôt 😊\n\n<b>⚠️ VALIDE LA RÉCEPTION DE TA COMMANDE DANS LA RUBRIQUE SUIVI POUR RÉCUPÉRER TES POINTS DE FIDÉLITÉ ⚠️</b>", database.GetClientOrderID(commandID))
database.NotifyClient(clientUsername, commandID, "livre", clientMsg)
}
+43
View File
@@ -1,6 +1,8 @@
package handlers
import (
"bytes"
"encoding/csv"
"fmt"
"gestion/db"
"gestion/utils"
@@ -259,6 +261,47 @@ func RespondToAddressProposal(c *gin.Context) {
})
}
func ExportApprovedCommandsCSV(c *gin.Context) {
database := c.MustGet("database").(*db.Database)
commands, err := database.GetApprovedCommands()
if err != nil {
log.Printf("❌ [EXPORT_CSV] Erreur: %v", err)
c.JSON(http.StatusInternalServerError, gin.H{"error": "Erreur export CSV"})
return
}
var buf bytes.Buffer
w := csv.NewWriter(&buf)
_ = w.Write([]string{
"ID", "Client Order ID", "User ID", "Username",
"Statut", "Total (€)", "Adresse", "Livreur",
"Créé le", "Mis à jour le",
})
for _, cmd := range commands {
_ = w.Write([]string{
strconv.Itoa(cmd.ID),
strconv.Itoa(cmd.ClientOrderID),
strconv.Itoa(cmd.UserID),
cmd.Username,
cmd.Status,
strconv.FormatFloat(cmd.Total, 'f', 2, 64),
cmd.DeliveryAddress,
cmd.LivreurAssign,
cmd.CreatedAt.Format("2006-01-02 15:04:05"),
cmd.UpdatedAt.Format("2006-01-02 15:04:05"),
})
}
w.Flush()
filename := fmt.Sprintf("commandes_approved_%s.csv", time.Now().Format("2006-01-02"))
c.Header("Content-Type", "text/csv; charset=utf-8")
c.Header("Content-Disposition", "attachment; filename="+filename)
c.String(http.StatusOK, buf.String())
}
func GetAllCommands(c *gin.Context) {
database := c.MustGet("database").(*db.Database)
+59 -1
View File
@@ -375,7 +375,7 @@ func UpdateDeliveryStatus(c *gin.Context) {
case "arrived":
clientMsg = fmt.Sprintf("Descend, le livreur est là dans 3min (commande #%d) 🛵", database.GetClientOrderID(commandID))
case "livre":
clientMsg = fmt.Sprintf("Ta commande #%d a bien été livrée ! Bonne dégustation l'ami et à bientôt 😊", database.GetClientOrderID(commandID))
clientMsg = fmt.Sprintf("Ta commande #%d a bien été livrée ! Bonne dégustation l'ami et à bientôt 😊\n\n<b>⚠️ VALIDE LA RÉCEPTION DE TA COMMANDE DANS LA RUBRIQUE SUIVI POUR RÉCUPÉRER TES POINTS DE FIDÉLITÉ ⚠️</b>", database.GetClientOrderID(commandID))
case "cancelled":
clientMsg = fmt.Sprintf("Votre commande #%d a été annulée par le livreur", database.GetClientOrderID(commandID))
}
@@ -414,3 +414,61 @@ func UpdateDeliveryStatus(c *gin.Context) {
c.JSON(http.StatusOK, response)
}
// POST /api/v1/livreur/deliveries/:id/issue
func ReportDeliveryIssue(c *gin.Context) {
username := c.GetString("username")
if c.GetString("role") != "livreur" {
c.JSON(http.StatusForbidden, gin.H{"error": "Accès refusé"})
return
}
commandID, err := strconv.Atoi(c.Param("id"))
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "ID invalide"})
return
}
var req struct {
IssueType string `json:"issue_type" binding:"required"`
Description string `json:"description"`
}
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "issue_type requis"})
return
}
validTypes := map[string]bool{
"client_absent": true,
"wrong_address": true,
"refused_delivery": true,
"no_access": true,
"other": true,
}
if !validTypes[req.IssueType] {
c.JSON(http.StatusBadRequest, gin.H{"error": "Type de problème invalide"})
return
}
database := c.MustGet("database").(*db.Database)
command, err := database.GetCommandByID(commandID)
if err != nil {
c.JSON(http.StatusNotFound, gin.H{"error": "Commande introuvable"})
return
}
if livreur, _ := command["livreur_assign"].(string); livreur != username {
c.JSON(http.StatusForbidden, gin.H{"error": "Commande non assignée à vous"})
return
}
issue, err := database.CreateDeliveryIssue(commandID, req.IssueType, req.Description, username)
if err != nil {
log.Printf("❌ [ISSUE] Erreur création: %v", err)
c.JSON(http.StatusInternalServerError, gin.H{"error": "Erreur création problème"})
return
}
log.Printf("📋 [ISSUE] Créé par %s pour commande #%d: %s", username, commandID, req.IssueType)
c.JSON(http.StatusCreated, gin.H{"success": true, "issue": issue})
}
+8 -6
View File
@@ -286,10 +286,12 @@ func ValidateBasket(c *gin.Context) {
}
req.DeliveryAddress = cmd.DeliveryAddress
// Vérifier que le client a lié son compte Telegram
if _, linked, err := database.GetClientTelegramChatID(usernameStr); err != nil || !linked {
c.JSON(http.StatusForbidden, gin.H{"error": "Vous devez lier votre compte Telegram avant de commander"})
return
// Vérifier que le client a lié son compte Telegram (seulement si les notifications sont activées)
if services.TelegramBot != nil && services.TelegramBot.IsNotificationsEnabled() {
if _, linked, err := database.GetClientTelegramChatID(usernameStr); err != nil || !linked {
c.JSON(http.StatusForbidden, gin.H{"error": "Vous devez lier votre compte Telegram avant de commander"})
return
}
}
log.Printf("🛒 [CHECKOUT] Début checkout pour: %s", usernameStr)
@@ -481,9 +483,9 @@ func ValidateBasket(c *gin.Context) {
go database.NotifyAllAdminCabine(commandID, usernameStr, req.DeliveryAddress)
// ============================================
// 3️⃣ Vider le panier
// 3️⃣ Vider le panier (sans restituer le stock — déjà déduit à l'ajout)
// ============================================
err = database.ClearBasket(usernameStr)
err = database.ClearBasketOnCheckout(usernameStr)
if err != nil {
utils.ServerErr(c, "Impossible de vider le panier", err)
return
+17
View File
@@ -61,6 +61,23 @@ func CreditClientReferralAdmin(c *gin.Context) {
})
}
// ResetClientReferralAdmin — DELETE /api/v2/admin/protected/client/:username/referral/reset (admin)
func ResetClientReferralAdmin(c *gin.Context) {
database := c.MustGet("database").(*db.Database)
targetUsername := c.Param("username")
if err := database.ResetClientReferralBalance(targetUsername); err != nil {
utils.ServerErr(c, "Impossible de réinitialiser le solde", err)
return
}
log.Printf("✅ [REFERRAL] Solde parrainage remis à zéro pour %s", targetUsername)
c.JSON(http.StatusOK, gin.H{
"message": "Solde parrainage réinitialisé",
"balance": 0,
})
}
// GetClientReferralAdmin — GET /api/v2/admin/protected/client/:username/referral (admin)
func GetClientReferralAdmin(c *gin.Context) {
database := c.MustGet("database").(*db.Database)
+5 -3
View File
@@ -40,9 +40,10 @@ func GetPublicSettings(c *gin.Context) {
"referral_enabled": settings.ReferralEnabled,
"referral_amount": settings.ReferralAmount,
"delivery_schedule": settings.DeliverySchedule,
"crypto_payment_enabled": settings.CryptoPaymentEnabled,
"crypto_only": settings.CryptoOnly,
"nowpayments_currencies": settings.NowPaymentsCurrencies,
"crypto_payment_enabled": settings.CryptoPaymentEnabled,
"crypto_only": settings.CryptoOnly,
"nowpayments_currencies": settings.NowPaymentsCurrencies,
"telegram_notifications_enabled": settings.TelegramNotificationsEnabled,
})
}
@@ -79,6 +80,7 @@ func UpdateSettings(c *gin.Context) {
// Recharger le service Telegram si le token/username a changé
if services.TelegramBot != nil {
services.TelegramBot.Reload(req.TelegramBotToken, req.TelegramBotUsername)
services.TelegramBot.SetNotificationsEnabled(req.TelegramNotificationsEnabled)
if req.TelegramBotToken != "" {
log.Printf("✅ [SETTINGS] Service Telegram rechargé (username: %s)", req.TelegramBotUsername)
if webhookURL := os.Getenv("TELEGRAM_WEBHOOK_URL"); webhookURL != "" {
+1
View File
@@ -58,6 +58,7 @@ func main() {
if dbSettings, err := database.GetSettings(); err == nil {
telegramService.Reload(dbSettings.TelegramBotToken, dbSettings.TelegramBotUsername)
telegramService.SetNotificationsEnabled(dbSettings.TelegramNotificationsEnabled)
if dbSettings.TelegramBotToken != "" {
log.Printf("✅ [TELEGRAM] Config chargée depuis la DB (username: %s)", dbSettings.TelegramBotUsername)
if webhookURL := os.Getenv("TELEGRAM_WEBHOOK_URL"); webhookURL != "" {
+4 -3
View File
@@ -75,7 +75,8 @@ type AppSettings struct {
NowPaymentsCurrencies []string `json:"nowpayments_currencies"` // cryptos acceptées (ex: ["btc","eth","ltc"])
DeliverySchedule DeliverySchedule `json:"delivery_schedule"` // horaires de livraison par jour
PostalZones []PostalZone `json:"postal_zones"` // zones de livraison avec minimum de commande
TelegramBotToken string `json:"telegram_bot_token"` // token du bot Telegram (BotFather)
TelegramBotUsername string `json:"telegram_bot_username"` // username du bot (sans @)
DeliveryMode DeliveryModeConfig `json:"delivery_mode"` // mode d'assignation des livreurs
TelegramBotToken string `json:"telegram_bot_token"` // token du bot Telegram (BotFather)
TelegramBotUsername string `json:"telegram_bot_username"` // username du bot (sans @)
TelegramNotificationsEnabled bool `json:"telegram_notifications_enabled"` // activer/désactiver les notifications Telegram
DeliveryMode DeliveryModeConfig `json:"delivery_mode"` // mode d'assignation des livreurs
}
+4 -1
View File
@@ -193,6 +193,7 @@ func SetupRoutes(router *gin.Engine, database *db.Database, geoService *services
// COMMANDES - GESTION DE BASE
// ============================================
adminGroupV2.GET("/orders", handlers.GetAllCommands)
adminGroupV2.GET("/orders/export/csv", handlers.ExportApprovedCommandsCSV)
adminGroupV2.GET("/orders/:id", handlers.GetCommandByID)
adminGroupV2.PUT("/orders/:id/address", handlers.UpdateCommandAddress)
adminGroupV2.POST("/orders/:id/propose-address", handlers.ProposeAddressChange)
@@ -264,6 +265,7 @@ func SetupRoutes(router *gin.Engine, database *db.Database, geoService *services
// 🎁 PARRAINAGE ADMIN
adminGroupV2.GET("/client/:username/referral", handlers.GetClientReferralAdmin)
adminGroupV2.POST("/client/:username/referral/credit", handlers.CreditClientReferralAdmin)
adminGroupV2.DELETE("/client/:username/referral/reset", handlers.ResetClientReferralAdmin)
adminGroupV2.POST("/client/:username/parrain/set", handlers.SetClientParrainAdmin)
adminGroupV2.GET("/client/:username/parrain", handlers.GetClientParrainAdmin)
adminGroupV2.GET("/parrain/stats", handlers.GetParrainStatsAdmin)
@@ -336,7 +338,8 @@ func SetupRoutes(router *gin.Engine, database *db.Database, geoService *services
livreurGroupV1.GET("/deliveries", handlers.GetMyDeliveries) // ✅ Données filtrées
livreurGroupV1.GET("/deliveries/:id", handlers.GetDeliveryDetails) // ✅ Détail filtré
livreurGroupV1.POST("/deliveries/:id/start", handlers.StartDelivery)
livreurGroupV1.PUT("/deliveries/:id/status", handlers.UpdateDeliveryStatus) // ✅ Avec GPS
livreurGroupV1.PUT("/deliveries/:id/status", handlers.UpdateDeliveryStatus) // ✅ Avec GPS
livreurGroupV1.POST("/deliveries/:id/issue", handlers.ReportDeliveryIssue) // Motif non-livraison
livreurGroupV1.GET("/deliveries/:id/nav-link", handlers.GetLivreurNavLink) // Lien Waze App
// ============================================
+12 -3
View File
@@ -14,9 +14,10 @@ import (
var TelegramBot *TelegramService
type TelegramService struct {
botToken string
webhookSecret string
BotUsername string
botToken string
webhookSecret string
BotUsername string
notificationsEnabled bool
}
func NewTelegramService() *TelegramService {
@@ -33,6 +34,14 @@ func (t *TelegramService) IsConfigured() bool {
return t.botToken != ""
}
func (t *TelegramService) IsNotificationsEnabled() bool {
return t.notificationsEnabled
}
func (t *TelegramService) SetNotificationsEnabled(enabled bool) {
t.notificationsEnabled = enabled
}
// Reload met à jour le token et le username (appelé après UpdateSettings)
func (t *TelegramService) Reload(token, username string) {
if token != "" {
+12 -17
View File
@@ -1,13 +1,9 @@
services:
# =========================================================
# Backend Go
# =========================================================
backend:
build:
context: ..
dockerfile: docker/backend/Dockerfile
target: runtime
image: xor1234/backend-mln:latest
container_name: gestion-backend
restart: unless-stopped
environment:
@@ -44,9 +40,7 @@ services:
# Frontend Web (React/Vite — servi en HTTP interne)
# =========================================================
frontend:
build:
context: ..
dockerfile: docker/frontend/Dockerfile
image: xor1234/frontend-mln:latest
container_name: gestion-frontend
restart: unless-stopped
networks:
@@ -54,16 +48,8 @@ services:
depends_on:
- backend
# =========================================================
# WAF (Nginx + ModSecurity) — point d'entrée public
# Les certificats fullchain.pem + privkey.pem doivent être
# placés dans ./certs/ à côté de ce fichier avant le deploy.
# =========================================================
waf:
build:
context: ..
dockerfile: docker/backend/Dockerfile
target: waf
image: xor1234/backend-mln:waf
container_name: gestion-waf
restart: unless-stopped
environment:
@@ -143,6 +129,15 @@ services:
retries: 5
start_period: 10s
dozzle-agent:
image: amir20/dozzle:latest
command: agent
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
ports:
- "7007:7007"
restart: unless-stopped
networks:
gestion-network:
driver: bridge
+3 -3
View File
@@ -15,7 +15,7 @@
"simulator": true
},
"env": {
"API_URL": "https://mln-uber.club"
"API_URL": "https://5.181.0.112.nip.io"
}
},
"preview": {
@@ -24,7 +24,7 @@
"buildType": "apk"
},
"env": {
"API_URL": "https://mln-uber.club"
"API_URL": "https://5.181.0.112.nip.io"
}
},
"production": {
@@ -34,7 +34,7 @@
"buildType": "apk"
},
"env": {
"API_URL": "https://mln-uber.club"
"API_URL": "https://5.181.0.112.nip.io"
}
}
}
-1
View File
@@ -1 +0,0 @@
../acorn/bin/acorn
-1
View File
@@ -1 +0,0 @@
../baseline-browser-mapping/dist/cli.js
-1
View File
@@ -1 +0,0 @@
../browserslist/cli.js
-1
View File
@@ -1 +0,0 @@
../esprima/bin/esparse.js
-1
View File
@@ -1 +0,0 @@
../esprima/bin/esvalidate.js
-1
View File
@@ -1 +0,0 @@
../@expo/xcpretty/build/cli.js
-1
View File
@@ -1 +0,0 @@
../expo/bin/cli
-1
View File
@@ -1 +0,0 @@
../expo/bin/autolinking
-1
View File
@@ -1 +0,0 @@
../@expo/fingerprint/bin/cli.js
-1
View File
@@ -1 +0,0 @@
../image-size/bin/image-size.js
-1
View File
@@ -1 +0,0 @@
../is-docker/cli.js
-1
View File
@@ -1 +0,0 @@
../js-yaml/bin/js-yaml.js
-1
View File
@@ -1 +0,0 @@
../jsesc/bin/jsesc
-1
View File
@@ -1 +0,0 @@
../json5/lib/cli.js
-1
View File
@@ -1 +0,0 @@
../lan-network/dist/lan-network-cli.js
-1
View File
@@ -1 +0,0 @@
../loose-envify/cli.js
-1
View File
@@ -1 +0,0 @@
../metro/src/cli.js
-1
View File
@@ -1 +0,0 @@
../metro-symbolicate/src/index.js
-1
View File
@@ -1 +0,0 @@
../mime/cli.js
-1
View File
@@ -1 +0,0 @@
../mkdirp/bin/cmd.js
-1
View File
@@ -1 +0,0 @@
../nanoid/bin/nanoid.cjs
-1
View File
@@ -1 +0,0 @@
../@expo/ngrok-bin/bin/ngrok.js
-1
View File
@@ -1 +0,0 @@
../which/bin/node-which
-1
View File
@@ -1 +0,0 @@
../@babel/parser/bin/babel-parser.js
-1
View File
@@ -1 +0,0 @@
../chrome-launcher/bin/print-chrome-path.js
-1
View File
@@ -1 +0,0 @@
../qrcode-terminal/bin/qrcode-terminal.js
-1
View File
@@ -1 +0,0 @@
../rc/cli.js
-1
View File
@@ -1 +0,0 @@
../react-native/cli.js
-1
View File
@@ -1 +0,0 @@
../regjsparser/bin/parser
-1
View File
@@ -1 +0,0 @@
../resolve/bin/resolve
-1
View File
@@ -1 +0,0 @@
../rimraf/bin.js
-1
View File
@@ -1 +0,0 @@
../semver/bin/semver.js
-1
View File
@@ -1 +0,0 @@
../sucrase/bin/sucrase
-1
View File
@@ -1 +0,0 @@
../sucrase/bin/sucrase-node
-1
View File
@@ -1 +0,0 @@
../terser/bin/terser
-1
View File
@@ -1 +0,0 @@
../typescript/bin/tsc
-1
View File
@@ -1 +0,0 @@
../typescript/bin/tsserver
-1
View File
@@ -1 +0,0 @@
../ua-parser-js/script/cli.js
-1
View File
@@ -1 +0,0 @@
../update-browserslist-db/cli.js
-1
View File
@@ -1 +0,0 @@
../uuid/bin/uuid
-9127
View File
File diff suppressed because it is too large Load Diff
-21
View File
@@ -1,21 +0,0 @@
MIT License
Copyright (c) 0no.co
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.
-79
View File
@@ -1,79 +0,0 @@
<div align="center">
<h2>@0no-co/graphql.web</h2>
<strong>The spec-compliant minimum of client-side GraphQL.</strong>
<br />
<br />
<a href="https://github.com/0no-co/graphql.web/actions/workflows/release.yml">
<img alt="CI Status" src="https://github.com/0no-co/graphql.web/actions/workflows/release.yml/badge.svg?branch=main" />
</a>
<a href="https://npmjs.com/package/@0no-co/graphql.web">
<img alt="Bundlesize" src="https://deno.bundlejs.com/?q=@0no-co/graphql.web&badge" />
</a>
<a href="https://urql.dev/discord">
<img alt="Discord" src="https://img.shields.io/discord/1082378892523864074?color=7389D8&label&logo=discord&logoColor=ffffff" />
</a>
<br />
<br />
</div>
`@0no-co/graphql.web` is a utility library, aiming to provide the minimum of
functions that typical GraphQL clients need and would usually import from
`graphql`, e.g. a GraphQL query parser, printer, and visitor.
While its goal isnt to be an exact match to [the GraphQL.js
API](https://graphql.org/graphql-js/graphql/) it aims to remain API- and
type-compatible where possible and necessary. However, its goal is to provide
the smallest implementation for common GraphQL utilities that are still either
spec-compliant or compatible with GraphQL.js implementation.
> **Note:** If youre instead looking for a drop-in replacement for the
> `graphql` package that you can just alias into your web apps, read more about
> the [`graphql-web-lite` project](https://github.com/0no-co/graphql-web-lite),
> which uses this library to shim the `graphql` package.
[`@urql/core`](https://github.com/urql-graphql/urql) depends on this package to
power its GraphQL query parsing and printing. **If youre using `@urql/core@^4`
youre already using this library! ✨**
### Overview
`@0no-co/graphql.web` aims to provide a minimal set of exports to implement
client-side GraphQL utilities, mostly including parsing, printing, and visiting
the GraphQL AST, and the `GraphQLError` class.
Currently, `graphql.web` compresses to under 4kB and doesnt regress on
GraphQL.js performance when parsing, printing, or visiting the AST.
For all primary APIs we aim to hit 100% test coverage and match the output,
types, and API compatibility of GraphQL.js, including — as far as possible
— TypeScript type compatibility of the AST types with the currently stable
version of GraphQL.js.
### API
Currently, only a select few exports are provided — namely, the ones listed here
are used in `@urql/core`, and we expect them to be common in all client-side
GraphQL applications.
| Export | Description | Links |
| --------------------- | ------------------------------------------------------------------ | -------------------------- |
| `parse` | A tiny (but compliant) GraphQL query language parser. | [Source](./src/parser.ts) |
| `print` | A (compliant) GraphQL query language printer. | [Source](./src/printer.ts) |
| `visit` | A recursive reimplementation of GraphQL.js visitor. | [Source](./src/printer.ts) |
| `Kind` | The GraphQL.js `Kind` enum, containing supported `ASTNode` kinds. | [Source](./src/kind.ts) |
| `GraphQLError` | `GraphQLError` stripped of source/location debugging. | [Source](./src/kind.ts) |
| `valueFromASTUntyped` | Coerces AST values into JS values. | [Source](./src/values.ts) |
The stated goals of any reimplementation are:
1. Not to implement any execution or type system parts of the GraphQL
specification.
2. To adhere to GraphQL.js types and APIs as much as possible.
3. Not to implement or expose any rarely used APIs or properties of the
GraphQL.js library.
4. To provide a minimal and maintainable subset of GraphQL.js utilities.
Therefore, while we can foresee implementing APIs that are entirely separate and
unrelated to the GraphQL.js library in the future, for now the stated goals are
designed to allow this library to be used by GraphQL clients, like
[`@urql/core`](https://github.com/urql-graphql/urql).
-835
View File
@@ -1,835 +0,0 @@
/*@ts-ignore*/
import * as GraphQL from 'graphql';
type Or<T, U> = void extends T ? U : T;
type Maybe<T> = T | undefined | null;
interface Extensions {
[extension: string]: unknown;
}
type Source =
| any
| {
body: string;
name: string;
locationOffset: {
line: number;
column: number;
};
};
type Location =
| any
| {
start: number;
end: number;
source: Source;
};
declare enum Kind {
/** Name */
NAME = 'Name',
/** Document */
DOCUMENT = 'Document',
OPERATION_DEFINITION = 'OperationDefinition',
VARIABLE_DEFINITION = 'VariableDefinition',
SELECTION_SET = 'SelectionSet',
FIELD = 'Field',
ARGUMENT = 'Argument',
/** Fragments */
FRAGMENT_SPREAD = 'FragmentSpread',
INLINE_FRAGMENT = 'InlineFragment',
FRAGMENT_DEFINITION = 'FragmentDefinition',
/** Values */
VARIABLE = 'Variable',
INT = 'IntValue',
FLOAT = 'FloatValue',
STRING = 'StringValue',
BOOLEAN = 'BooleanValue',
NULL = 'NullValue',
ENUM = 'EnumValue',
LIST = 'ListValue',
OBJECT = 'ObjectValue',
OBJECT_FIELD = 'ObjectField',
/** Directives */
DIRECTIVE = 'Directive',
/** Types */
NAMED_TYPE = 'NamedType',
LIST_TYPE = 'ListType',
NON_NULL_TYPE = 'NonNullType',
/** Type System Definitions */
SCHEMA_DEFINITION = 'SchemaDefinition',
OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition',
/** Type Definitions */
SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition',
OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition',
FIELD_DEFINITION = 'FieldDefinition',
INPUT_VALUE_DEFINITION = 'InputValueDefinition',
INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition',
UNION_TYPE_DEFINITION = 'UnionTypeDefinition',
ENUM_TYPE_DEFINITION = 'EnumTypeDefinition',
ENUM_VALUE_DEFINITION = 'EnumValueDefinition',
INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition',
/** Directive Definitions */
DIRECTIVE_DEFINITION = 'DirectiveDefinition',
/** Type System Extensions */
SCHEMA_EXTENSION = 'SchemaExtension',
/** Type Extensions */
SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension',
OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension',
INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension',
UNION_TYPE_EXTENSION = 'UnionTypeExtension',
ENUM_TYPE_EXTENSION = 'EnumTypeExtension',
INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension',
}
declare enum OperationTypeNode {
QUERY = 'query',
MUTATION = 'mutation',
SUBSCRIPTION = 'subscription',
}
/** Type System Definition */
declare type TypeSystemDefinitionNode = Or<
GraphQL.TypeSystemDefinitionNode,
SchemaDefinitionNode | TypeDefinitionNode | DirectiveDefinitionNode
>;
type SchemaDefinitionNode = Or<
GraphQL.SchemaDefinitionNode,
{
readonly kind: Kind.SCHEMA_DEFINITION;
readonly loc?: Location;
readonly description?: StringValueNode;
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
readonly operationTypes: ReadonlyArray<OperationTypeDefinitionNode>;
}
>;
type OperationTypeDefinitionNode = Or<
GraphQL.OperationTypeDefinitionNode,
{
readonly kind: Kind.OPERATION_TYPE_DEFINITION;
readonly loc?: Location;
readonly operation: OperationTypeNode;
readonly type: NamedTypeNode;
}
>;
/** Type Definition */
declare type TypeDefinitionNode = Or<
GraphQL.TypeDefinitionNode,
| ScalarTypeDefinitionNode
| ObjectTypeDefinitionNode
| InterfaceTypeDefinitionNode
| UnionTypeDefinitionNode
| EnumTypeDefinitionNode
| InputObjectTypeDefinitionNode
>;
type ScalarTypeDefinitionNode = Or<
GraphQL.ScalarTypeDefinitionNode,
{
readonly kind: Kind.SCALAR_TYPE_DEFINITION;
readonly loc?: Location;
readonly description?: StringValueNode;
readonly name: NameNode;
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
}
>;
type ObjectTypeDefinitionNode = Or<
GraphQL.ObjectTypeDefinitionNode,
{
readonly kind: Kind.OBJECT_TYPE_DEFINITION;
readonly loc?: Location;
readonly description?: StringValueNode;
readonly name: NameNode;
readonly interfaces?: ReadonlyArray<NamedTypeNode>;
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
readonly fields?: ReadonlyArray<FieldDefinitionNode>;
}
>;
type FieldDefinitionNode = Or<
GraphQL.FieldDefinitionNode,
{
readonly kind: Kind.FIELD_DEFINITION;
readonly loc?: Location;
readonly description?: StringValueNode;
readonly name: NameNode;
readonly arguments?: ReadonlyArray<InputValueDefinitionNode>;
readonly type: TypeNode;
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
}
>;
type InputValueDefinitionNode = Or<
GraphQL.InputValueDefinitionNode,
{
readonly kind: Kind.INPUT_VALUE_DEFINITION;
readonly loc?: Location;
readonly description?: StringValueNode;
readonly name: NameNode;
readonly type: TypeNode;
readonly defaultValue?: ConstValueNode;
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
}
>;
type InterfaceTypeDefinitionNode = Or<
GraphQL.InterfaceTypeDefinitionNode,
{
readonly kind: Kind.INTERFACE_TYPE_DEFINITION;
readonly loc?: Location;
readonly description?: StringValueNode;
readonly name: NameNode;
readonly interfaces?: ReadonlyArray<NamedTypeNode>;
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
readonly fields?: ReadonlyArray<FieldDefinitionNode>;
}
>;
type UnionTypeDefinitionNode = Or<
GraphQL.UnionTypeDefinitionNode,
{
readonly kind: Kind.UNION_TYPE_DEFINITION;
readonly loc?: Location;
readonly description?: StringValueNode;
readonly name: NameNode;
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
readonly types?: ReadonlyArray<NamedTypeNode>;
}
>;
type EnumTypeDefinitionNode = Or<
GraphQL.EnumTypeDefinitionNode,
{
readonly kind: Kind.ENUM_TYPE_DEFINITION;
readonly loc?: Location;
readonly description?: StringValueNode;
readonly name: NameNode;
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
readonly values?: ReadonlyArray<EnumValueDefinitionNode>;
}
>;
type EnumValueDefinitionNode = Or<
GraphQL.EnumValueDefinitionNode,
{
readonly kind: Kind.ENUM_VALUE_DEFINITION;
readonly loc?: Location;
readonly description?: StringValueNode;
readonly name: NameNode;
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
}
>;
type InputObjectTypeDefinitionNode = Or<
GraphQL.InputObjectTypeDefinitionNode,
{
readonly kind: Kind.INPUT_OBJECT_TYPE_DEFINITION;
readonly loc?: Location;
readonly description?: StringValueNode;
readonly name: NameNode;
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
readonly fields?: ReadonlyArray<InputValueDefinitionNode>;
}
>;
type DirectiveDefinitionNode = Or<
GraphQL.DirectiveDefinitionNode,
{
readonly kind: Kind.DIRECTIVE_DEFINITION;
readonly loc?: Location;
readonly description?: StringValueNode;
readonly name: NameNode;
readonly arguments?: ReadonlyArray<InputValueDefinitionNode>;
readonly repeatable: boolean;
readonly locations: ReadonlyArray<NameNode>;
}
>;
type TypeSystemExtensionNode = Or<
GraphQL.TypeSystemExtensionNode,
SchemaExtensionNode | TypeExtensionNode
>;
type SchemaExtensionNode = Or<
GraphQL.SchemaExtensionNode,
{
readonly kind: Kind.SCHEMA_EXTENSION;
readonly loc?: Location;
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
readonly operationTypes?: ReadonlyArray<OperationTypeDefinitionNode>;
}
>;
declare type TypeExtensionNode = Or<
GraphQL.TypeExtensionNode,
| ScalarTypeExtensionNode
| ObjectTypeExtensionNode
| InterfaceTypeExtensionNode
| UnionTypeExtensionNode
| EnumTypeExtensionNode
| InputObjectTypeExtensionNode
>;
type ScalarTypeExtensionNode = Or<
GraphQL.ScalarTypeExtensionNode,
{
readonly kind: Kind.SCALAR_TYPE_EXTENSION;
readonly loc?: Location;
readonly name: NameNode;
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
}
>;
type ObjectTypeExtensionNode = Or<
GraphQL.ObjectTypeExtensionNode,
{
readonly kind: Kind.OBJECT_TYPE_EXTENSION;
readonly loc?: Location;
readonly name: NameNode;
readonly interfaces?: ReadonlyArray<NamedTypeNode>;
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
readonly fields?: ReadonlyArray<FieldDefinitionNode>;
}
>;
type InterfaceTypeExtensionNode = Or<
GraphQL.InterfaceTypeExtensionNode,
{
readonly kind: Kind.INTERFACE_TYPE_EXTENSION;
readonly loc?: Location;
readonly name: NameNode;
readonly interfaces?: ReadonlyArray<NamedTypeNode>;
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
readonly fields?: ReadonlyArray<FieldDefinitionNode>;
}
>;
type UnionTypeExtensionNode = Or<
GraphQL.UnionTypeExtensionNode,
{
readonly kind: Kind.UNION_TYPE_EXTENSION;
readonly loc?: Location;
readonly name: NameNode;
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
readonly types?: ReadonlyArray<NamedTypeNode>;
}
>;
type EnumTypeExtensionNode = Or<
GraphQL.EnumTypeExtensionNode,
{
readonly kind: Kind.ENUM_TYPE_EXTENSION;
readonly loc?: Location;
readonly name: NameNode;
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
readonly values?: ReadonlyArray<EnumValueDefinitionNode>;
}
>;
type InputObjectTypeExtensionNode = Or<
GraphQL.InputObjectTypeExtensionNode,
{
readonly kind: Kind.INPUT_OBJECT_TYPE_EXTENSION;
readonly loc?: Location;
readonly name: NameNode;
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
readonly fields?: ReadonlyArray<InputValueDefinitionNode>;
}
>;
type ASTNode = Or<
GraphQL.ASTNode,
| NameNode
| DocumentNode
| OperationDefinitionNode
| VariableDefinitionNode
| VariableNode
| SelectionSetNode
| FieldNode
| ArgumentNode
| FragmentSpreadNode
| InlineFragmentNode
| FragmentDefinitionNode
| IntValueNode
| FloatValueNode
| StringValueNode
| BooleanValueNode
| NullValueNode
| EnumValueNode
| ListValueNode
| ObjectValueNode
| ObjectFieldNode
| DirectiveNode
| NamedTypeNode
| ListTypeNode
| NonNullTypeNode
| SchemaDefinitionNode
| OperationTypeDefinitionNode
| ScalarTypeDefinitionNode
| ObjectTypeDefinitionNode
| FieldDefinitionNode
| InputValueDefinitionNode
| InterfaceTypeDefinitionNode
| UnionTypeDefinitionNode
| EnumTypeDefinitionNode
| EnumValueDefinitionNode
| InputObjectTypeDefinitionNode
| DirectiveDefinitionNode
| SchemaExtensionNode
| ScalarTypeExtensionNode
| ObjectTypeExtensionNode
| InterfaceTypeExtensionNode
| UnionTypeExtensionNode
| EnumTypeExtensionNode
| InputObjectTypeExtensionNode
>;
type NameNode = Or<
GraphQL.NameNode,
{
readonly kind: Kind.NAME;
readonly value: string;
readonly loc?: Location;
}
>;
type DocumentNode = Or<
GraphQL.DocumentNode,
{
readonly kind: Kind.DOCUMENT;
readonly definitions: ReadonlyArray<DefinitionNode>;
readonly loc?: Location;
}
>;
type DefinitionNode = Or<
GraphQL.DefinitionNode,
ExecutableDefinitionNode | TypeSystemDefinitionNode | TypeSystemExtensionNode
>;
type ExecutableDefinitionNode = Or<
GraphQL.ExecutableDefinitionNode,
OperationDefinitionNode | FragmentDefinitionNode
>;
type OperationDefinitionNode = Or<
GraphQL.OperationDefinitionNode & {
description?: StringValueNode;
},
{
readonly kind: Kind.OPERATION_DEFINITION;
readonly operation: OperationTypeNode;
readonly name?: NameNode;
readonly description?: StringValueNode;
readonly variableDefinitions?: ReadonlyArray<VariableDefinitionNode>;
readonly directives?: ReadonlyArray<DirectiveNode>;
readonly selectionSet: SelectionSetNode;
readonly loc?: Location;
}
>;
type VariableDefinitionNode = Or<
GraphQL.VariableDefinitionNode & {
description?: StringValueNode;
},
{
readonly kind: Kind.VARIABLE_DEFINITION;
readonly variable: VariableNode;
readonly type: TypeNode;
readonly defaultValue?: ConstValueNode;
readonly description?: StringValueNode;
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
readonly loc?: Location;
}
>;
type VariableNode = Or<
GraphQL.VariableNode,
{
readonly kind: Kind.VARIABLE;
readonly name: NameNode;
readonly loc?: Location;
}
>;
type SelectionSetNode = Or<
GraphQL.SelectionSetNode,
{
readonly kind: Kind.SELECTION_SET;
readonly selections: ReadonlyArray<SelectionNode>;
readonly loc?: Location;
}
>;
declare type SelectionNode = Or<
GraphQL.SelectionNode,
FieldNode | FragmentSpreadNode | InlineFragmentNode
>;
type FieldNode = Or<
GraphQL.FieldNode,
{
readonly kind: Kind.FIELD;
readonly alias?: NameNode;
readonly name: NameNode;
readonly arguments?: ReadonlyArray<ArgumentNode>;
readonly directives?: ReadonlyArray<DirectiveNode>;
readonly selectionSet?: SelectionSetNode;
readonly loc?: Location;
}
>;
type ArgumentNode = Or<
GraphQL.ArgumentNode,
{
readonly kind: Kind.ARGUMENT;
readonly name: NameNode;
readonly value: ValueNode;
readonly loc?: Location;
}
>;
type ConstArgumentNode = Or<
GraphQL.ConstArgumentNode,
{
readonly kind: Kind.ARGUMENT;
readonly name: NameNode;
readonly value: ConstValueNode;
readonly loc?: Location;
}
>;
type FragmentSpreadNode = Or<
GraphQL.FragmentSpreadNode,
{
readonly kind: Kind.FRAGMENT_SPREAD;
readonly name: NameNode;
readonly directives?: ReadonlyArray<DirectiveNode>;
readonly loc?: Location;
}
>;
type InlineFragmentNode = Or<
GraphQL.InlineFragmentNode,
{
readonly kind: Kind.INLINE_FRAGMENT;
readonly typeCondition?: NamedTypeNode;
readonly directives?: ReadonlyArray<DirectiveNode>;
readonly selectionSet: SelectionSetNode;
readonly loc?: Location;
}
>;
type FragmentDefinitionNode = Or<
GraphQL.FragmentDefinitionNode & {
description?: StringValueNode;
},
{
readonly kind: Kind.FRAGMENT_DEFINITION;
readonly name: NameNode;
readonly description?: StringValueNode;
readonly typeCondition: NamedTypeNode;
readonly directives?: ReadonlyArray<DirectiveNode>;
readonly selectionSet: SelectionSetNode;
readonly loc?: Location;
}
>;
type ValueNode = Or<
GraphQL.ValueNode,
| VariableNode
| IntValueNode
| FloatValueNode
| StringValueNode
| BooleanValueNode
| NullValueNode
| EnumValueNode
| ListValueNode
| ObjectValueNode
>;
type ConstValueNode = Or<
GraphQL.ConstValueNode,
| IntValueNode
| FloatValueNode
| StringValueNode
| BooleanValueNode
| NullValueNode
| EnumValueNode
| ConstListValueNode
| ConstObjectValueNode
>;
type IntValueNode = Or<
GraphQL.IntValueNode,
{
readonly kind: Kind.INT;
readonly value: string;
readonly loc?: Location;
}
>;
type FloatValueNode = Or<
GraphQL.FloatValueNode,
{
readonly kind: Kind.FLOAT;
readonly value: string;
readonly loc?: Location;
}
>;
type StringValueNode = Or<
GraphQL.StringValueNode,
{
readonly kind: Kind.STRING;
readonly value: string;
readonly block?: boolean;
readonly loc?: Location;
}
>;
type BooleanValueNode = Or<
GraphQL.BooleanValueNode,
{
readonly kind: Kind.BOOLEAN;
readonly value: boolean;
readonly loc?: Location;
}
>;
type NullValueNode = Or<
GraphQL.NullValueNode,
{
readonly kind: Kind.NULL;
readonly loc?: Location;
}
>;
type EnumValueNode = Or<
GraphQL.EnumValueNode,
{
readonly kind: Kind.ENUM;
readonly value: string;
readonly loc?: Location;
}
>;
type ListValueNode = Or<
GraphQL.ListValueNode,
{
readonly kind: Kind.LIST;
readonly values: ReadonlyArray<ValueNode>;
readonly loc?: Location;
}
>;
type ConstListValueNode = Or<
GraphQL.ConstListValueNode,
{
readonly kind: Kind.LIST;
readonly values: ReadonlyArray<ConstValueNode>;
readonly loc?: Location;
}
>;
type ObjectValueNode = Or<
GraphQL.ObjectValueNode,
{
readonly kind: Kind.OBJECT;
readonly fields: ReadonlyArray<ObjectFieldNode>;
readonly loc?: Location;
}
>;
type ConstObjectValueNode = Or<
GraphQL.ConstObjectValueNode,
{
readonly kind: Kind.OBJECT;
readonly fields: ReadonlyArray<ConstObjectFieldNode>;
readonly loc?: Location;
}
>;
type ObjectFieldNode = Or<
GraphQL.ObjectFieldNode,
{
readonly kind: Kind.OBJECT_FIELD;
readonly name: NameNode;
readonly value: ValueNode;
readonly loc?: Location;
}
>;
type ConstObjectFieldNode = Or<
GraphQL.ConstObjectFieldNode,
{
readonly kind: Kind.OBJECT_FIELD;
readonly name: NameNode;
readonly value: ConstValueNode;
readonly loc?: Location;
}
>;
type DirectiveNode = Or<
GraphQL.DirectiveNode,
{
readonly kind: Kind.DIRECTIVE;
readonly name: NameNode;
readonly arguments?: ReadonlyArray<ArgumentNode>;
readonly loc?: Location;
}
>;
type ConstDirectiveNode = Or<
GraphQL.ConstDirectiveNode,
{
readonly kind: Kind.DIRECTIVE;
readonly name: NameNode;
readonly arguments?: ReadonlyArray<ConstArgumentNode>;
readonly loc?: Location;
}
>;
type TypeNode = Or<GraphQL.TypeNode, NamedTypeNode | ListTypeNode | NonNullTypeNode>;
type NamedTypeNode = Or<
GraphQL.NamedTypeNode,
{
readonly kind: Kind.NAMED_TYPE;
readonly name: NameNode;
readonly loc?: Location;
}
>;
type ListTypeNode = Or<
GraphQL.ListTypeNode,
{
readonly kind: Kind.LIST_TYPE;
readonly type: TypeNode;
readonly loc?: Location;
}
>;
type NonNullTypeNode = Or<
GraphQL.NonNullTypeNode,
{
readonly kind: Kind.NON_NULL_TYPE;
readonly type: NamedTypeNode | ListTypeNode;
readonly loc?: Location;
}
>;
declare class GraphQLError extends Error {
readonly locations: ReadonlyArray<any> | undefined;
readonly path: ReadonlyArray<string | number> | undefined;
readonly nodes: ReadonlyArray<any> | undefined;
readonly source: Source | undefined;
readonly positions: ReadonlyArray<number> | undefined;
readonly originalError: Error | undefined;
readonly extensions: Extensions;
constructor(
message: string,
nodes?: ReadonlyArray<ASTNode> | ASTNode | null,
source?: Maybe<Source>,
positions?: Maybe<ReadonlyArray<number>>,
path?: Maybe<ReadonlyArray<string | number>>,
originalError?: Maybe<Error>,
extensions?: Maybe<Extensions>
);
toJSON(): any;
toString(): string;
get [Symbol.toStringTag](): string;
}
type ParseOptions = {
[option: string]: any;
};
declare function parse(string: string | Source, options?: ParseOptions | undefined): DocumentNode;
declare function parseValue(
string: string | Source,
_options?: ParseOptions | undefined
): ValueNode;
declare function parseType(string: string | Source, _options?: ParseOptions | undefined): TypeNode;
declare const BREAK: {};
declare function visit<N extends ASTNode>(root: N, visitor: ASTVisitor): N;
declare function visit<R>(root: ASTNode, visitor: ASTReducer<R>): R;
type ASTVisitor = EnterLeaveVisitor<ASTNode> | KindVisitor;
type KindVisitor = {
readonly [NodeT in ASTNode as NodeT['kind']]?: ASTVisitFn<NodeT> | EnterLeaveVisitor<NodeT>;
};
interface EnterLeaveVisitor<TVisitedNode extends ASTNode> {
readonly enter?: ASTVisitFn<TVisitedNode> | undefined;
readonly leave?: ASTVisitFn<TVisitedNode> | undefined;
}
type ASTVisitFn<Node extends ASTNode> = (
node: Node,
key: string | number | undefined,
parent: ASTNode | ReadonlyArray<ASTNode> | undefined,
path: ReadonlyArray<string | number>,
ancestors: ReadonlyArray<ASTNode | ReadonlyArray<ASTNode>>
) => any;
type ASTReducer<R> = {
readonly [NodeT in ASTNode as NodeT['kind']]?: {
readonly enter?: ASTVisitFn<NodeT>;
readonly leave: ASTReducerFn<NodeT, R>;
};
};
type ASTReducerFn<TReducedNode extends ASTNode, R> = (
node: {
[K in keyof TReducedNode]: ReducedField<TReducedNode[K], R>;
},
key: string | number | undefined,
parent: ASTNode | ReadonlyArray<ASTNode> | undefined,
path: ReadonlyArray<string | number>,
ancestors: ReadonlyArray<ASTNode | ReadonlyArray<ASTNode>>
) => R;
type ReducedField<T, R> = T extends null | undefined
? T
: T extends ReadonlyArray<any>
? ReadonlyArray<R>
: R;
declare function printString(string: string): string;
declare function printBlockString(string: string): string;
declare function print(node: ASTNode): string;
declare function valueFromASTUntyped(
node: ValueNode,
variables?: Maybe<Record<string, any>>
): unknown;
declare function valueFromTypeNode(
node: ValueNode,
type: TypeNode,
variables?: Maybe<Record<string, any>>
): unknown;
declare function isSelectionNode(node: ASTNode): node is SelectionNode;
export {
type ASTNode,
type ASTReducer,
type ASTVisitFn,
type ASTVisitor,
type ArgumentNode,
BREAK,
type BooleanValueNode,
type ConstArgumentNode,
type ConstDirectiveNode,
type ConstListValueNode,
type ConstObjectFieldNode,
type ConstObjectValueNode,
type ConstValueNode,
type DefinitionNode,
type DirectiveDefinitionNode,
type DirectiveNode,
type DocumentNode,
type EnumTypeDefinitionNode,
type EnumTypeExtensionNode,
type EnumValueDefinitionNode,
type EnumValueNode,
type ExecutableDefinitionNode,
type Extensions,
type FieldDefinitionNode,
type FieldNode,
type FloatValueNode,
type FragmentDefinitionNode,
type FragmentSpreadNode,
GraphQLError,
type InlineFragmentNode,
type InputObjectTypeDefinitionNode,
type InputObjectTypeExtensionNode,
type InputValueDefinitionNode,
type IntValueNode,
type InterfaceTypeDefinitionNode,
type InterfaceTypeExtensionNode,
Kind,
type ListTypeNode,
type ListValueNode,
type Location,
type NameNode,
type NamedTypeNode,
type NonNullTypeNode,
type NullValueNode,
type ObjectFieldNode,
type ObjectTypeDefinitionNode,
type ObjectTypeExtensionNode,
type ObjectValueNode,
type OperationDefinitionNode,
type OperationTypeDefinitionNode,
OperationTypeNode,
type ScalarTypeDefinitionNode,
type ScalarTypeExtensionNode,
type SchemaDefinitionNode,
type SchemaExtensionNode,
type SelectionNode,
type SelectionSetNode,
type Source,
type StringValueNode,
type TypeDefinitionNode,
type TypeExtensionNode,
type TypeNode,
type TypeSystemDefinitionNode,
type TypeSystemExtensionNode,
type UnionTypeDefinitionNode,
type UnionTypeExtensionNode,
type ValueNode,
type VariableDefinitionNode,
type VariableNode,
isSelectionNode,
parse,
parseType,
parseValue,
print,
printBlockString,
printString,
valueFromASTUntyped,
valueFromTypeNode,
visit,
};
-871
View File
@@ -1,871 +0,0 @@
Object.defineProperty(exports, "__esModule", {
value: !0
});
class GraphQLError extends Error {
constructor(e, r, i, n, t, a, o) {
if (super(e), this.name = "GraphQLError", this.message = e, t) {
this.path = t;
}
if (r) {
this.nodes = Array.isArray(r) ? r : [ r ];
}
if (i) {
this.source = i;
}
if (n) {
this.positions = n;
}
if (a) {
this.originalError = a;
}
var l = o;
if (!l && a) {
var d = a.extensions;
if (d && "object" == typeof d) {
l = d;
}
}
this.extensions = l || {};
}
toJSON() {
return {
...this,
message: this.message
};
}
toString() {
return this.message;
}
get [Symbol.toStringTag]() {
return "GraphQLError";
}
}
var e;
var r;
function error(e) {
return new GraphQLError(`Syntax Error: Unexpected token at ${r} in ${e}`);
}
function advance(i) {
if (i.lastIndex = r, i.test(e)) {
return e.slice(r, r = i.lastIndex);
}
}
var i = / +(?=[^\s])/y;
function blockString(e) {
var r = e.split("\n");
var n = "";
var t = 0;
var a = 0;
var o = r.length - 1;
for (var l = 0; l < r.length; l++) {
if (i.lastIndex = 0, i.test(r[l])) {
if (l && (!t || i.lastIndex < t)) {
t = i.lastIndex;
}
a = a || l, o = l;
}
}
for (var d = a; d <= o; d++) {
if (d !== a) {
n += "\n";
}
n += r[d].slice(t).replace(/\\"""/g, '"""');
}
return n;
}
function ignored() {
for (var i = 0 | e.charCodeAt(r++); 9 === i || 10 === i || 13 === i || 32 === i || 35 === i || 44 === i || 65279 === i; i = 0 | e.charCodeAt(r++)) {
if (35 === i) {
for (;(i = 0 | e.charCodeAt(r++)) && 10 !== i && 13 !== i; ) {}
}
}
r--;
}
function name() {
var i = r;
for (var n = 0 | e.charCodeAt(r++); n >= 48 && n <= 57 || n >= 65 && n <= 90 || 95 === n || n >= 97 && n <= 122; n = 0 | e.charCodeAt(r++)) {}
if (i === r - 1) {
throw error("Name");
}
var t = e.slice(i, --r);
return ignored(), t;
}
function nameNode() {
return {
kind: "Name",
value: name()
};
}
var n = /(?:"""|(?:[\s\S]*?[^\\])""")/y;
var t = /(?:(?:\.\d+)?[eE][+-]?\d+|\.\d+)/y;
function value(i) {
var a;
switch (e.charCodeAt(r)) {
case 91:
r++, ignored();
var o = [];
for (;93 !== e.charCodeAt(r); ) {
o.push(value(i));
}
return r++, ignored(), {
kind: "ListValue",
values: o
};
case 123:
r++, ignored();
var l = [];
for (;125 !== e.charCodeAt(r); ) {
var d = nameNode();
if (58 !== e.charCodeAt(r++)) {
throw error("ObjectField");
}
ignored(), l.push({
kind: "ObjectField",
name: d,
value: value(i)
});
}
return r++, ignored(), {
kind: "ObjectValue",
fields: l
};
case 36:
if (i) {
throw error("Variable");
}
return r++, {
kind: "Variable",
name: nameNode()
};
case 34:
if (34 === e.charCodeAt(r + 1) && 34 === e.charCodeAt(r + 2)) {
if (r += 3, null == (a = advance(n))) {
throw error("StringValue");
}
return ignored(), {
kind: "StringValue",
value: blockString(a.slice(0, -3)),
block: !0
};
} else {
var s = r;
var u;
r++;
var c = !1;
for (u = 0 | e.charCodeAt(r++); 92 === u && (r++, c = !0) || 10 !== u && 13 !== u && 34 !== u && u; u = 0 | e.charCodeAt(r++)) {}
if (34 !== u) {
throw error("StringValue");
}
return a = e.slice(s, r), ignored(), {
kind: "StringValue",
value: c ? JSON.parse(a) : a.slice(1, -1),
block: !1
};
}
case 45:
case 48:
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 56:
case 57:
var v = r++;
var f;
for (;(f = 0 | e.charCodeAt(r++)) >= 48 && f <= 57; ) {}
var p = e.slice(v, --r);
if (46 === (f = e.charCodeAt(r)) || 69 === f || 101 === f) {
if (null == (a = advance(t))) {
throw error("FloatValue");
}
return ignored(), {
kind: "FloatValue",
value: p + a
};
} else {
return ignored(), {
kind: "IntValue",
value: p
};
}
case 110:
if (117 === e.charCodeAt(r + 1) && 108 === e.charCodeAt(r + 2) && 108 === e.charCodeAt(r + 3)) {
return r += 4, ignored(), {
kind: "NullValue"
};
} else {
break;
}
case 116:
if (114 === e.charCodeAt(r + 1) && 117 === e.charCodeAt(r + 2) && 101 === e.charCodeAt(r + 3)) {
return r += 4, ignored(), {
kind: "BooleanValue",
value: !0
};
} else {
break;
}
case 102:
if (97 === e.charCodeAt(r + 1) && 108 === e.charCodeAt(r + 2) && 115 === e.charCodeAt(r + 3) && 101 === e.charCodeAt(r + 4)) {
return r += 5, ignored(), {
kind: "BooleanValue",
value: !1
};
} else {
break;
}
}
return {
kind: "EnumValue",
value: name()
};
}
function arguments_(i) {
if (40 === e.charCodeAt(r)) {
var n = [];
r++, ignored();
do {
var t = nameNode();
if (58 !== e.charCodeAt(r++)) {
throw error("Argument");
}
ignored(), n.push({
kind: "Argument",
name: t,
value: value(i)
});
} while (41 !== e.charCodeAt(r));
return r++, ignored(), n;
}
}
function directives(i) {
if (64 === e.charCodeAt(r)) {
var n = [];
do {
r++, n.push({
kind: "Directive",
name: nameNode(),
arguments: arguments_(i)
});
} while (64 === e.charCodeAt(r));
return n;
}
}
function type() {
var i = 0;
for (;91 === e.charCodeAt(r); ) {
i++, r++, ignored();
}
var n = {
kind: "NamedType",
name: nameNode()
};
do {
if (33 === e.charCodeAt(r)) {
r++, ignored(), n = {
kind: "NonNullType",
type: n
};
}
if (i) {
if (93 !== e.charCodeAt(r++)) {
throw error("NamedType");
}
ignored(), n = {
kind: "ListType",
type: n
};
}
} while (i--);
return n;
}
function selectionSetStart() {
if (123 !== e.charCodeAt(r++)) {
throw error("SelectionSet");
}
return ignored(), selectionSet();
}
function selectionSet() {
var i = [];
do {
if (46 === e.charCodeAt(r)) {
if (46 !== e.charCodeAt(++r) || 46 !== e.charCodeAt(++r)) {
throw error("SelectionSet");
}
switch (r++, ignored(), e.charCodeAt(r)) {
case 64:
i.push({
kind: "InlineFragment",
typeCondition: void 0,
directives: directives(!1),
selectionSet: selectionSetStart()
});
break;
case 111:
if (110 === e.charCodeAt(r + 1)) {
r += 2, ignored(), i.push({
kind: "InlineFragment",
typeCondition: {
kind: "NamedType",
name: nameNode()
},
directives: directives(!1),
selectionSet: selectionSetStart()
});
} else {
i.push({
kind: "FragmentSpread",
name: nameNode(),
directives: directives(!1)
});
}
break;
case 123:
r++, ignored(), i.push({
kind: "InlineFragment",
typeCondition: void 0,
directives: void 0,
selectionSet: selectionSet()
});
break;
default:
i.push({
kind: "FragmentSpread",
name: nameNode(),
directives: directives(!1)
});
}
} else {
var n = nameNode();
var t = void 0;
if (58 === e.charCodeAt(r)) {
r++, ignored(), t = n, n = nameNode();
}
var a = arguments_(!1);
var o = directives(!1);
var l = void 0;
if (123 === e.charCodeAt(r)) {
r++, ignored(), l = selectionSet();
}
i.push({
kind: "Field",
alias: t,
name: n,
arguments: a,
directives: o,
selectionSet: l
});
}
} while (125 !== e.charCodeAt(r));
return r++, ignored(), {
kind: "SelectionSet",
selections: i
};
}
function variableDefinitions() {
if (ignored(), 40 === e.charCodeAt(r)) {
var i = [];
r++, ignored();
do {
var n = void 0;
if (34 === e.charCodeAt(r)) {
n = value(!0);
}
if (36 !== e.charCodeAt(r++)) {
throw error("Variable");
}
var t = nameNode();
if (58 !== e.charCodeAt(r++)) {
throw error("VariableDefinition");
}
ignored();
var a = type();
var o = void 0;
if (61 === e.charCodeAt(r)) {
r++, ignored(), o = value(!0);
}
ignored();
var l = {
kind: "VariableDefinition",
variable: {
kind: "Variable",
name: t
},
type: a,
defaultValue: o,
directives: directives(!0)
};
if (n) {
l.description = n;
}
i.push(l);
} while (41 !== e.charCodeAt(r));
return r++, ignored(), i;
}
}
function fragmentDefinition(i) {
var n = nameNode();
if (111 !== e.charCodeAt(r++) || 110 !== e.charCodeAt(r++)) {
throw error("FragmentDefinition");
}
ignored();
var t = {
kind: "FragmentDefinition",
name: n,
typeCondition: {
kind: "NamedType",
name: nameNode()
},
directives: directives(!1),
selectionSet: selectionSetStart()
};
if (i) {
t.description = i;
}
return t;
}
function definitions() {
var i = [];
do {
var n = void 0;
if (34 === e.charCodeAt(r)) {
n = value(!0);
}
if (123 === e.charCodeAt(r)) {
if (n) {
throw error("Document");
}
r++, ignored(), i.push({
kind: "OperationDefinition",
operation: "query",
name: void 0,
variableDefinitions: void 0,
directives: void 0,
selectionSet: selectionSet()
});
} else {
var t = name();
switch (t) {
case "fragment":
i.push(fragmentDefinition(n));
break;
case "query":
case "mutation":
case "subscription":
var a;
var o = void 0;
if (40 !== (a = e.charCodeAt(r)) && 64 !== a && 123 !== a) {
o = nameNode();
}
var l = {
kind: "OperationDefinition",
operation: t,
name: o,
variableDefinitions: variableDefinitions(),
directives: directives(!1),
selectionSet: selectionSetStart()
};
if (n) {
l.description = n;
}
i.push(l);
break;
default:
throw error("Document");
}
}
} while (r < e.length);
return i;
}
var a = {};
function mapJoin(e, r, i) {
var n = "";
for (var t = 0; t < e.length; t++) {
if (t) {
n += r;
}
n += i(e[t]);
}
return n;
}
function printString(e) {
return JSON.stringify(e);
}
function printBlockString(e) {
return '"""\n' + e.replace(/"""/g, '\\"""') + '\n"""';
}
var o = "\n";
var l = {
OperationDefinition(e) {
var r = "";
if (e.description) {
r += l.StringValue(e.description) + "\n";
}
if (r += e.operation, e.name) {
r += " " + e.name.value;
}
if (e.variableDefinitions && e.variableDefinitions.length) {
if (!e.name) {
r += " ";
}
r += "(" + mapJoin(e.variableDefinitions, ", ", l.VariableDefinition) + ")";
}
if (e.directives && e.directives.length) {
r += " " + mapJoin(e.directives, " ", l.Directive);
}
var i = l.SelectionSet(e.selectionSet);
return "query" !== r ? r + " " + i : i;
},
VariableDefinition(e) {
var r = "";
if (e.description) {
r += l.StringValue(e.description) + " ";
}
if (r += l.Variable(e.variable) + ": " + _print(e.type), e.defaultValue) {
r += " = " + _print(e.defaultValue);
}
if (e.directives && e.directives.length) {
r += " " + mapJoin(e.directives, " ", l.Directive);
}
return r;
},
Field(e) {
var r = e.alias ? e.alias.value + ": " + e.name.value : e.name.value;
if (e.arguments && e.arguments.length) {
var i = mapJoin(e.arguments, ", ", l.Argument);
if (r.length + i.length + 2 > 80) {
r += "(" + (o += " ") + mapJoin(e.arguments, o, l.Argument) + (o = o.slice(0, -2)) + ")";
} else {
r += "(" + i + ")";
}
}
if (e.directives && e.directives.length) {
r += " " + mapJoin(e.directives, " ", l.Directive);
}
if (e.selectionSet && e.selectionSet.selections.length) {
r += " " + l.SelectionSet(e.selectionSet);
}
return r;
},
StringValue(e) {
if (e.block) {
return printBlockString(e.value).replace(/\n/g, o);
} else {
return printString(e.value);
}
},
BooleanValue: e => "" + e.value,
NullValue: e => "null",
IntValue: e => e.value,
FloatValue: e => e.value,
EnumValue: e => e.value,
Name: e => e.value,
Variable: e => "$" + e.name.value,
ListValue: e => "[" + mapJoin(e.values, ", ", _print) + "]",
ObjectValue: e => "{" + mapJoin(e.fields, ", ", l.ObjectField) + "}",
ObjectField: e => e.name.value + ": " + _print(e.value),
Document(e) {
if (!e.definitions || !e.definitions.length) {
return "";
} else {
return mapJoin(e.definitions, "\n\n", _print);
}
},
SelectionSet: e => "{" + (o += " ") + mapJoin(e.selections, o, _print) + (o = o.slice(0, -2)) + "}",
Argument: e => e.name.value + ": " + _print(e.value),
FragmentSpread(e) {
var r = "..." + e.name.value;
if (e.directives && e.directives.length) {
r += " " + mapJoin(e.directives, " ", l.Directive);
}
return r;
},
InlineFragment(e) {
var r = "...";
if (e.typeCondition) {
r += " on " + e.typeCondition.name.value;
}
if (e.directives && e.directives.length) {
r += " " + mapJoin(e.directives, " ", l.Directive);
}
return r += " " + l.SelectionSet(e.selectionSet);
},
FragmentDefinition(e) {
var r = "";
if (e.description) {
r += l.StringValue(e.description) + "\n";
}
if (r += "fragment " + e.name.value, r += " on " + e.typeCondition.name.value, e.directives && e.directives.length) {
r += " " + mapJoin(e.directives, " ", l.Directive);
}
return r + " " + l.SelectionSet(e.selectionSet);
},
Directive(e) {
var r = "@" + e.name.value;
if (e.arguments && e.arguments.length) {
r += "(" + mapJoin(e.arguments, ", ", l.Argument) + ")";
}
return r;
},
NamedType: e => e.name.value,
ListType: e => "[" + _print(e.type) + "]",
NonNullType: e => _print(e.type) + "!"
};
var _print = e => l[e.kind](e);
function valueFromASTUntyped(e, r) {
switch (e.kind) {
case "NullValue":
return null;
case "IntValue":
return parseInt(e.value, 10);
case "FloatValue":
return parseFloat(e.value);
case "StringValue":
case "EnumValue":
case "BooleanValue":
return e.value;
case "ListValue":
var i = [];
for (var n = 0, t = e.values.length; n < t; n++) {
i.push(valueFromASTUntyped(e.values[n], r));
}
return i;
case "ObjectValue":
var a = Object.create(null);
for (var o = 0, l = e.fields.length; o < l; o++) {
var d = e.fields[o];
a[d.name.value] = valueFromASTUntyped(d.value, r);
}
return a;
case "Variable":
return r && r[e.name.value];
}
}
exports.BREAK = a, exports.GraphQLError = GraphQLError, exports.Kind = {
NAME: "Name",
DOCUMENT: "Document",
OPERATION_DEFINITION: "OperationDefinition",
VARIABLE_DEFINITION: "VariableDefinition",
SELECTION_SET: "SelectionSet",
FIELD: "Field",
ARGUMENT: "Argument",
FRAGMENT_SPREAD: "FragmentSpread",
INLINE_FRAGMENT: "InlineFragment",
FRAGMENT_DEFINITION: "FragmentDefinition",
VARIABLE: "Variable",
INT: "IntValue",
FLOAT: "FloatValue",
STRING: "StringValue",
BOOLEAN: "BooleanValue",
NULL: "NullValue",
ENUM: "EnumValue",
LIST: "ListValue",
OBJECT: "ObjectValue",
OBJECT_FIELD: "ObjectField",
DIRECTIVE: "Directive",
NAMED_TYPE: "NamedType",
LIST_TYPE: "ListType",
NON_NULL_TYPE: "NonNullType"
}, exports.OperationTypeNode = {
QUERY: "query",
MUTATION: "mutation",
SUBSCRIPTION: "subscription"
}, exports.Source = function Source(e, r, i) {
return {
body: e,
name: r,
locationOffset: i || {
line: 1,
column: 1
}
};
}, exports.isSelectionNode = function isSelectionNode(e) {
return "Field" === e.kind || "FragmentSpread" === e.kind || "InlineFragment" === e.kind;
}, exports.parse = function parse(i, n) {
if (e = i.body ? i.body : i, r = 0, ignored(), n && n.noLocation) {
return {
kind: "Document",
definitions: definitions()
};
} else {
return {
kind: "Document",
definitions: definitions(),
loc: {
start: 0,
end: e.length,
startToken: void 0,
endToken: void 0,
source: {
body: e,
name: "graphql.web",
locationOffset: {
line: 1,
column: 1
}
}
}
};
}
}, exports.parseType = function parseType(i, n) {
return e = i.body ? i.body : i, r = 0, type();
}, exports.parseValue = function parseValue(i, n) {
return e = i.body ? i.body : i, r = 0, ignored(), value(!1);
}, exports.print = function print(e) {
return o = "\n", l[e.kind] ? l[e.kind](e) : "";
}, exports.printBlockString = printBlockString, exports.printString = printString,
exports.valueFromASTUntyped = valueFromASTUntyped, exports.valueFromTypeNode = function valueFromTypeNode(e, r, i) {
if ("Variable" === e.kind) {
return i ? valueFromTypeNode(i[e.name.value], r, i) : void 0;
} else if ("NonNullType" === r.kind) {
return "NullValue" !== e.kind ? valueFromTypeNode(e, r, i) : void 0;
} else if ("NullValue" === e.kind) {
return null;
} else if ("ListType" === r.kind) {
if ("ListValue" === e.kind) {
var n = [];
for (var t = 0, a = e.values.length; t < a; t++) {
var o = valueFromTypeNode(e.values[t], r.type, i);
if (void 0 === o) {
return;
} else {
n.push(o);
}
}
return n;
}
} else if ("NamedType" === r.kind) {
switch (r.name.value) {
case "Int":
case "Float":
case "String":
case "Bool":
return r.name.value + "Value" === e.kind ? valueFromASTUntyped(e, i) : void 0;
default:
return valueFromASTUntyped(e, i);
}
}
}, exports.visit = function visit(e, r) {
var i = [];
var n = [];
try {
var t = function traverse(e, t, o) {
var l = !1;
var d = r[e.kind] && r[e.kind].enter || r[e.kind] || r.enter;
var s = d && d.call(r, e, t, o, n, i);
if (!1 === s) {
return e;
} else if (null === s) {
return null;
} else if (s === a) {
throw a;
} else if (s && "string" == typeof s.kind) {
l = s !== e, e = s;
}
if (o) {
i.push(o);
}
var u;
var c = {
...e
};
for (var v in e) {
n.push(v);
var f = e[v];
if (Array.isArray(f)) {
var p = [];
for (var m = 0; m < f.length; m++) {
if (null != f[m] && "string" == typeof f[m].kind) {
if (i.push(e), n.push(m), u = traverse(f[m], m, f), n.pop(), i.pop(), null == u) {
l = !0;
} else {
l = l || u !== f[m], p.push(u);
}
}
}
f = p;
} else if (null != f && "string" == typeof f.kind) {
if (void 0 !== (u = traverse(f, v, e))) {
l = l || f !== u, f = u;
}
}
if (n.pop(), l) {
c[v] = f;
}
}
if (o) {
i.pop();
}
var h = r[e.kind] && r[e.kind].leave || r.leave;
var g = h && h.call(r, e, t, o, n, i);
if (g === a) {
throw a;
} else if (void 0 !== g) {
return g;
} else if (void 0 !== s) {
return l ? c : s;
} else {
return l ? c : e;
}
}(e);
return void 0 !== t && !1 !== t ? t : e;
} catch (r) {
if (r !== a) {
throw r;
}
return e;
}
};
//# sourceMappingURL=graphql.web.js.map
File diff suppressed because one or more lines are too long
-886
View File
@@ -1,886 +0,0 @@
var e = {
NAME: "Name",
DOCUMENT: "Document",
OPERATION_DEFINITION: "OperationDefinition",
VARIABLE_DEFINITION: "VariableDefinition",
SELECTION_SET: "SelectionSet",
FIELD: "Field",
ARGUMENT: "Argument",
FRAGMENT_SPREAD: "FragmentSpread",
INLINE_FRAGMENT: "InlineFragment",
FRAGMENT_DEFINITION: "FragmentDefinition",
VARIABLE: "Variable",
INT: "IntValue",
FLOAT: "FloatValue",
STRING: "StringValue",
BOOLEAN: "BooleanValue",
NULL: "NullValue",
ENUM: "EnumValue",
LIST: "ListValue",
OBJECT: "ObjectValue",
OBJECT_FIELD: "ObjectField",
DIRECTIVE: "Directive",
NAMED_TYPE: "NamedType",
LIST_TYPE: "ListType",
NON_NULL_TYPE: "NonNullType"
};
var r = {
QUERY: "query",
MUTATION: "mutation",
SUBSCRIPTION: "subscription"
};
class GraphQLError extends Error {
constructor(e, r, i, n, t, a, o) {
if (super(e), this.name = "GraphQLError", this.message = e, t) {
this.path = t;
}
if (r) {
this.nodes = Array.isArray(r) ? r : [ r ];
}
if (i) {
this.source = i;
}
if (n) {
this.positions = n;
}
if (a) {
this.originalError = a;
}
var l = o;
if (!l && a) {
var d = a.extensions;
if (d && "object" == typeof d) {
l = d;
}
}
this.extensions = l || {};
}
toJSON() {
return {
...this,
message: this.message
};
}
toString() {
return this.message;
}
get [Symbol.toStringTag]() {
return "GraphQLError";
}
}
var i;
var n;
function error(e) {
return new GraphQLError(`Syntax Error: Unexpected token at ${n} in ${e}`);
}
function advance(e) {
if (e.lastIndex = n, e.test(i)) {
return i.slice(n, n = e.lastIndex);
}
}
var t = / +(?=[^\s])/y;
function blockString(e) {
var r = e.split("\n");
var i = "";
var n = 0;
var a = 0;
var o = r.length - 1;
for (var l = 0; l < r.length; l++) {
if (t.lastIndex = 0, t.test(r[l])) {
if (l && (!n || t.lastIndex < n)) {
n = t.lastIndex;
}
a = a || l, o = l;
}
}
for (var d = a; d <= o; d++) {
if (d !== a) {
i += "\n";
}
i += r[d].slice(n).replace(/\\"""/g, '"""');
}
return i;
}
function ignored() {
for (var e = 0 | i.charCodeAt(n++); 9 === e || 10 === e || 13 === e || 32 === e || 35 === e || 44 === e || 65279 === e; e = 0 | i.charCodeAt(n++)) {
if (35 === e) {
for (;(e = 0 | i.charCodeAt(n++)) && 10 !== e && 13 !== e; ) {}
}
}
n--;
}
function name() {
var e = n;
for (var r = 0 | i.charCodeAt(n++); r >= 48 && r <= 57 || r >= 65 && r <= 90 || 95 === r || r >= 97 && r <= 122; r = 0 | i.charCodeAt(n++)) {}
if (e === n - 1) {
throw error("Name");
}
var t = i.slice(e, --n);
return ignored(), t;
}
function nameNode() {
return {
kind: "Name",
value: name()
};
}
var a = /(?:"""|(?:[\s\S]*?[^\\])""")/y;
var o = /(?:(?:\.\d+)?[eE][+-]?\d+|\.\d+)/y;
function value(e) {
var r;
switch (i.charCodeAt(n)) {
case 91:
n++, ignored();
var t = [];
for (;93 !== i.charCodeAt(n); ) {
t.push(value(e));
}
return n++, ignored(), {
kind: "ListValue",
values: t
};
case 123:
n++, ignored();
var l = [];
for (;125 !== i.charCodeAt(n); ) {
var d = nameNode();
if (58 !== i.charCodeAt(n++)) {
throw error("ObjectField");
}
ignored(), l.push({
kind: "ObjectField",
name: d,
value: value(e)
});
}
return n++, ignored(), {
kind: "ObjectValue",
fields: l
};
case 36:
if (e) {
throw error("Variable");
}
return n++, {
kind: "Variable",
name: nameNode()
};
case 34:
if (34 === i.charCodeAt(n + 1) && 34 === i.charCodeAt(n + 2)) {
if (n += 3, null == (r = advance(a))) {
throw error("StringValue");
}
return ignored(), {
kind: "StringValue",
value: blockString(r.slice(0, -3)),
block: !0
};
} else {
var u = n;
var s;
n++;
var c = !1;
for (s = 0 | i.charCodeAt(n++); 92 === s && (n++, c = !0) || 10 !== s && 13 !== s && 34 !== s && s; s = 0 | i.charCodeAt(n++)) {}
if (34 !== s) {
throw error("StringValue");
}
return r = i.slice(u, n), ignored(), {
kind: "StringValue",
value: c ? JSON.parse(r) : r.slice(1, -1),
block: !1
};
}
case 45:
case 48:
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 56:
case 57:
var v = n++;
var f;
for (;(f = 0 | i.charCodeAt(n++)) >= 48 && f <= 57; ) {}
var m = i.slice(v, --n);
if (46 === (f = i.charCodeAt(n)) || 69 === f || 101 === f) {
if (null == (r = advance(o))) {
throw error("FloatValue");
}
return ignored(), {
kind: "FloatValue",
value: m + r
};
} else {
return ignored(), {
kind: "IntValue",
value: m
};
}
case 110:
if (117 === i.charCodeAt(n + 1) && 108 === i.charCodeAt(n + 2) && 108 === i.charCodeAt(n + 3)) {
return n += 4, ignored(), {
kind: "NullValue"
};
} else {
break;
}
case 116:
if (114 === i.charCodeAt(n + 1) && 117 === i.charCodeAt(n + 2) && 101 === i.charCodeAt(n + 3)) {
return n += 4, ignored(), {
kind: "BooleanValue",
value: !0
};
} else {
break;
}
case 102:
if (97 === i.charCodeAt(n + 1) && 108 === i.charCodeAt(n + 2) && 115 === i.charCodeAt(n + 3) && 101 === i.charCodeAt(n + 4)) {
return n += 5, ignored(), {
kind: "BooleanValue",
value: !1
};
} else {
break;
}
}
return {
kind: "EnumValue",
value: name()
};
}
function arguments_(e) {
if (40 === i.charCodeAt(n)) {
var r = [];
n++, ignored();
do {
var t = nameNode();
if (58 !== i.charCodeAt(n++)) {
throw error("Argument");
}
ignored(), r.push({
kind: "Argument",
name: t,
value: value(e)
});
} while (41 !== i.charCodeAt(n));
return n++, ignored(), r;
}
}
function directives(e) {
if (64 === i.charCodeAt(n)) {
var r = [];
do {
n++, r.push({
kind: "Directive",
name: nameNode(),
arguments: arguments_(e)
});
} while (64 === i.charCodeAt(n));
return r;
}
}
function type() {
var e = 0;
for (;91 === i.charCodeAt(n); ) {
e++, n++, ignored();
}
var r = {
kind: "NamedType",
name: nameNode()
};
do {
if (33 === i.charCodeAt(n)) {
n++, ignored(), r = {
kind: "NonNullType",
type: r
};
}
if (e) {
if (93 !== i.charCodeAt(n++)) {
throw error("NamedType");
}
ignored(), r = {
kind: "ListType",
type: r
};
}
} while (e--);
return r;
}
function selectionSetStart() {
if (123 !== i.charCodeAt(n++)) {
throw error("SelectionSet");
}
return ignored(), selectionSet();
}
function selectionSet() {
var e = [];
do {
if (46 === i.charCodeAt(n)) {
if (46 !== i.charCodeAt(++n) || 46 !== i.charCodeAt(++n)) {
throw error("SelectionSet");
}
switch (n++, ignored(), i.charCodeAt(n)) {
case 64:
e.push({
kind: "InlineFragment",
typeCondition: void 0,
directives: directives(!1),
selectionSet: selectionSetStart()
});
break;
case 111:
if (110 === i.charCodeAt(n + 1)) {
n += 2, ignored(), e.push({
kind: "InlineFragment",
typeCondition: {
kind: "NamedType",
name: nameNode()
},
directives: directives(!1),
selectionSet: selectionSetStart()
});
} else {
e.push({
kind: "FragmentSpread",
name: nameNode(),
directives: directives(!1)
});
}
break;
case 123:
n++, ignored(), e.push({
kind: "InlineFragment",
typeCondition: void 0,
directives: void 0,
selectionSet: selectionSet()
});
break;
default:
e.push({
kind: "FragmentSpread",
name: nameNode(),
directives: directives(!1)
});
}
} else {
var r = nameNode();
var t = void 0;
if (58 === i.charCodeAt(n)) {
n++, ignored(), t = r, r = nameNode();
}
var a = arguments_(!1);
var o = directives(!1);
var l = void 0;
if (123 === i.charCodeAt(n)) {
n++, ignored(), l = selectionSet();
}
e.push({
kind: "Field",
alias: t,
name: r,
arguments: a,
directives: o,
selectionSet: l
});
}
} while (125 !== i.charCodeAt(n));
return n++, ignored(), {
kind: "SelectionSet",
selections: e
};
}
function variableDefinitions() {
if (ignored(), 40 === i.charCodeAt(n)) {
var e = [];
n++, ignored();
do {
var r = void 0;
if (34 === i.charCodeAt(n)) {
r = value(!0);
}
if (36 !== i.charCodeAt(n++)) {
throw error("Variable");
}
var t = nameNode();
if (58 !== i.charCodeAt(n++)) {
throw error("VariableDefinition");
}
ignored();
var a = type();
var o = void 0;
if (61 === i.charCodeAt(n)) {
n++, ignored(), o = value(!0);
}
ignored();
var l = {
kind: "VariableDefinition",
variable: {
kind: "Variable",
name: t
},
type: a,
defaultValue: o,
directives: directives(!0)
};
if (r) {
l.description = r;
}
e.push(l);
} while (41 !== i.charCodeAt(n));
return n++, ignored(), e;
}
}
function fragmentDefinition(e) {
var r = nameNode();
if (111 !== i.charCodeAt(n++) || 110 !== i.charCodeAt(n++)) {
throw error("FragmentDefinition");
}
ignored();
var t = {
kind: "FragmentDefinition",
name: r,
typeCondition: {
kind: "NamedType",
name: nameNode()
},
directives: directives(!1),
selectionSet: selectionSetStart()
};
if (e) {
t.description = e;
}
return t;
}
function definitions() {
var e = [];
do {
var r = void 0;
if (34 === i.charCodeAt(n)) {
r = value(!0);
}
if (123 === i.charCodeAt(n)) {
if (r) {
throw error("Document");
}
n++, ignored(), e.push({
kind: "OperationDefinition",
operation: "query",
name: void 0,
variableDefinitions: void 0,
directives: void 0,
selectionSet: selectionSet()
});
} else {
var t = name();
switch (t) {
case "fragment":
e.push(fragmentDefinition(r));
break;
case "query":
case "mutation":
case "subscription":
var a;
var o = void 0;
if (40 !== (a = i.charCodeAt(n)) && 64 !== a && 123 !== a) {
o = nameNode();
}
var l = {
kind: "OperationDefinition",
operation: t,
name: o,
variableDefinitions: variableDefinitions(),
directives: directives(!1),
selectionSet: selectionSetStart()
};
if (r) {
l.description = r;
}
e.push(l);
break;
default:
throw error("Document");
}
}
} while (n < i.length);
return e;
}
function parse(e, r) {
if (i = e.body ? e.body : e, n = 0, ignored(), r && r.noLocation) {
return {
kind: "Document",
definitions: definitions()
};
} else {
return {
kind: "Document",
definitions: definitions(),
loc: {
start: 0,
end: i.length,
startToken: void 0,
endToken: void 0,
source: {
body: i,
name: "graphql.web",
locationOffset: {
line: 1,
column: 1
}
}
}
};
}
}
function parseValue(e, r) {
return i = e.body ? e.body : e, n = 0, ignored(), value(!1);
}
function parseType(e, r) {
return i = e.body ? e.body : e, n = 0, type();
}
var l = {};
function visit(e, r) {
var i = [];
var n = [];
try {
var t = function traverse(e, t, a) {
var o = !1;
var d = r[e.kind] && r[e.kind].enter || r[e.kind] || r.enter;
var u = d && d.call(r, e, t, a, n, i);
if (!1 === u) {
return e;
} else if (null === u) {
return null;
} else if (u === l) {
throw l;
} else if (u && "string" == typeof u.kind) {
o = u !== e, e = u;
}
if (a) {
i.push(a);
}
var s;
var c = {
...e
};
for (var v in e) {
n.push(v);
var f = e[v];
if (Array.isArray(f)) {
var m = [];
for (var p = 0; p < f.length; p++) {
if (null != f[p] && "string" == typeof f[p].kind) {
if (i.push(e), n.push(p), s = traverse(f[p], p, f), n.pop(), i.pop(), null == s) {
o = !0;
} else {
o = o || s !== f[p], m.push(s);
}
}
}
f = m;
} else if (null != f && "string" == typeof f.kind) {
if (void 0 !== (s = traverse(f, v, e))) {
o = o || f !== s, f = s;
}
}
if (n.pop(), o) {
c[v] = f;
}
}
if (a) {
i.pop();
}
var h = r[e.kind] && r[e.kind].leave || r.leave;
var g = h && h.call(r, e, t, a, n, i);
if (g === l) {
throw l;
} else if (void 0 !== g) {
return g;
} else if (void 0 !== u) {
return o ? c : u;
} else {
return o ? c : e;
}
}(e);
return void 0 !== t && !1 !== t ? t : e;
} catch (r) {
if (r !== l) {
throw r;
}
return e;
}
}
function mapJoin(e, r, i) {
var n = "";
for (var t = 0; t < e.length; t++) {
if (t) {
n += r;
}
n += i(e[t]);
}
return n;
}
function printString(e) {
return JSON.stringify(e);
}
function printBlockString(e) {
return '"""\n' + e.replace(/"""/g, '\\"""') + '\n"""';
}
var d = "\n";
var u = {
OperationDefinition(e) {
var r = "";
if (e.description) {
r += u.StringValue(e.description) + "\n";
}
if (r += e.operation, e.name) {
r += " " + e.name.value;
}
if (e.variableDefinitions && e.variableDefinitions.length) {
if (!e.name) {
r += " ";
}
r += "(" + mapJoin(e.variableDefinitions, ", ", u.VariableDefinition) + ")";
}
if (e.directives && e.directives.length) {
r += " " + mapJoin(e.directives, " ", u.Directive);
}
var i = u.SelectionSet(e.selectionSet);
return "query" !== r ? r + " " + i : i;
},
VariableDefinition(e) {
var r = "";
if (e.description) {
r += u.StringValue(e.description) + " ";
}
if (r += u.Variable(e.variable) + ": " + _print(e.type), e.defaultValue) {
r += " = " + _print(e.defaultValue);
}
if (e.directives && e.directives.length) {
r += " " + mapJoin(e.directives, " ", u.Directive);
}
return r;
},
Field(e) {
var r = e.alias ? e.alias.value + ": " + e.name.value : e.name.value;
if (e.arguments && e.arguments.length) {
var i = mapJoin(e.arguments, ", ", u.Argument);
if (r.length + i.length + 2 > 80) {
r += "(" + (d += " ") + mapJoin(e.arguments, d, u.Argument) + (d = d.slice(0, -2)) + ")";
} else {
r += "(" + i + ")";
}
}
if (e.directives && e.directives.length) {
r += " " + mapJoin(e.directives, " ", u.Directive);
}
if (e.selectionSet && e.selectionSet.selections.length) {
r += " " + u.SelectionSet(e.selectionSet);
}
return r;
},
StringValue(e) {
if (e.block) {
return printBlockString(e.value).replace(/\n/g, d);
} else {
return printString(e.value);
}
},
BooleanValue: e => "" + e.value,
NullValue: e => "null",
IntValue: e => e.value,
FloatValue: e => e.value,
EnumValue: e => e.value,
Name: e => e.value,
Variable: e => "$" + e.name.value,
ListValue: e => "[" + mapJoin(e.values, ", ", _print) + "]",
ObjectValue: e => "{" + mapJoin(e.fields, ", ", u.ObjectField) + "}",
ObjectField: e => e.name.value + ": " + _print(e.value),
Document(e) {
if (!e.definitions || !e.definitions.length) {
return "";
} else {
return mapJoin(e.definitions, "\n\n", _print);
}
},
SelectionSet: e => "{" + (d += " ") + mapJoin(e.selections, d, _print) + (d = d.slice(0, -2)) + "}",
Argument: e => e.name.value + ": " + _print(e.value),
FragmentSpread(e) {
var r = "..." + e.name.value;
if (e.directives && e.directives.length) {
r += " " + mapJoin(e.directives, " ", u.Directive);
}
return r;
},
InlineFragment(e) {
var r = "...";
if (e.typeCondition) {
r += " on " + e.typeCondition.name.value;
}
if (e.directives && e.directives.length) {
r += " " + mapJoin(e.directives, " ", u.Directive);
}
return r += " " + u.SelectionSet(e.selectionSet);
},
FragmentDefinition(e) {
var r = "";
if (e.description) {
r += u.StringValue(e.description) + "\n";
}
if (r += "fragment " + e.name.value, r += " on " + e.typeCondition.name.value, e.directives && e.directives.length) {
r += " " + mapJoin(e.directives, " ", u.Directive);
}
return r + " " + u.SelectionSet(e.selectionSet);
},
Directive(e) {
var r = "@" + e.name.value;
if (e.arguments && e.arguments.length) {
r += "(" + mapJoin(e.arguments, ", ", u.Argument) + ")";
}
return r;
},
NamedType: e => e.name.value,
ListType: e => "[" + _print(e.type) + "]",
NonNullType: e => _print(e.type) + "!"
};
var _print = e => u[e.kind](e);
function print(e) {
return d = "\n", u[e.kind] ? u[e.kind](e) : "";
}
function valueFromASTUntyped(e, r) {
switch (e.kind) {
case "NullValue":
return null;
case "IntValue":
return parseInt(e.value, 10);
case "FloatValue":
return parseFloat(e.value);
case "StringValue":
case "EnumValue":
case "BooleanValue":
return e.value;
case "ListValue":
var i = [];
for (var n = 0, t = e.values.length; n < t; n++) {
i.push(valueFromASTUntyped(e.values[n], r));
}
return i;
case "ObjectValue":
var a = Object.create(null);
for (var o = 0, l = e.fields.length; o < l; o++) {
var d = e.fields[o];
a[d.name.value] = valueFromASTUntyped(d.value, r);
}
return a;
case "Variable":
return r && r[e.name.value];
}
}
function valueFromTypeNode(e, r, i) {
if ("Variable" === e.kind) {
return i ? valueFromTypeNode(i[e.name.value], r, i) : void 0;
} else if ("NonNullType" === r.kind) {
return "NullValue" !== e.kind ? valueFromTypeNode(e, r, i) : void 0;
} else if ("NullValue" === e.kind) {
return null;
} else if ("ListType" === r.kind) {
if ("ListValue" === e.kind) {
var n = [];
for (var t = 0, a = e.values.length; t < a; t++) {
var o = valueFromTypeNode(e.values[t], r.type, i);
if (void 0 === o) {
return;
} else {
n.push(o);
}
}
return n;
}
} else if ("NamedType" === r.kind) {
switch (r.name.value) {
case "Int":
case "Float":
case "String":
case "Bool":
return r.name.value + "Value" === e.kind ? valueFromASTUntyped(e, i) : void 0;
default:
return valueFromASTUntyped(e, i);
}
}
}
function isSelectionNode(e) {
return "Field" === e.kind || "FragmentSpread" === e.kind || "InlineFragment" === e.kind;
}
function Source(e, r, i) {
return {
body: e,
name: r,
locationOffset: i || {
line: 1,
column: 1
}
};
}
export { l as BREAK, GraphQLError, e as Kind, r as OperationTypeNode, Source, isSelectionNode, parse, parseType, parseValue, print, printBlockString, printString, valueFromASTUntyped, valueFromTypeNode, visit };
//# sourceMappingURL=graphql.web.mjs.map
File diff suppressed because one or more lines are too long
-115
View File
@@ -1,115 +0,0 @@
{
"name": "@0no-co/graphql.web",
"description": "A spec-compliant client-side GraphQL implementation",
"version": "1.2.0",
"author": "0no.co <hi@0no.co>",
"source": "./src/index.ts",
"main": "./dist/graphql.web",
"module": "./dist/graphql.web.mjs",
"types": "./dist/graphql.web.d.ts",
"sideEffects": false,
"files": [
"LICENSE",
"README.md",
"dist/"
],
"exports": {
".": {
"types": "./dist/graphql.web.d.ts",
"import": "./dist/graphql.web.mjs",
"require": "./dist/graphql.web.js",
"source": "./src/index.ts"
},
"./package.json": "./package.json"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
},
"peerDependenciesMeta": {
"graphql": {
"optional": true
}
},
"public": true,
"keywords": [
"graphql",
"graphql-js",
"client-side graphql"
],
"repository": "https://github.com/0no-co/graphql.web",
"bugs": {
"url": "https://github.com/0no-co/graphql.web/issues"
},
"license": "MIT",
"prettier": {
"singleQuote": true,
"tabWidth": 2,
"printWidth": 100,
"trailingComma": "es5"
},
"lint-staged": {
"*.{ts,js}": "eslint -c scripts/eslint-preset.js --fix",
"*.json": "prettier --write",
"*.md": "prettier --write"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged --quiet --relative"
}
},
"eslintConfig": {
"root": true,
"extends": [
"./scripts/eslint-preset.js"
]
},
"devDependencies": {
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.1",
"@babel/plugin-transform-block-scoping": "^7.23.4",
"@babel/plugin-transform-typescript": "^7.23.6",
"@changesets/cli": "^2.27.1",
"@changesets/get-github-info": "^0.6.0",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"@vitest/coverage-v8": "^1.2.2",
"dotenv": "^16.4.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-tsdoc": "^0.2.17",
"husky-v4": "^4.3.8",
"jsr": "^0.12.1",
"lint-staged": "^15.2.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.4",
"rimraf": "^5.0.5",
"rollup": "^4.9.6",
"rollup-plugin-cjs-check": "^1.0.3",
"rollup-plugin-dts": "^6.1.0",
"terser": "^5.27.0",
"typescript": "^5.3.3",
"vitest": "^1.2.2",
"graphql15": "npm:graphql@^15.8.0",
"graphql16": "npm:graphql@^16.8.1",
"graphql17": "npm:graphql@^17.0.0-alpha.3"
},
"publishConfig": {
"access": "public",
"provenance": true
},
"scripts": {
"test": "vitest test",
"bench": "vitest bench --typecheck.enabled=false",
"check": "tsc",
"lint": "eslint --ext=js,ts .",
"build": "rollup -c scripts/rollup.config.mjs",
"clean": "rimraf dist node_modules/.cache",
"changeset:version": "changeset version && pnpm install --lockfile-only && node ./scripts/jsr.js",
"changeset:publish": "changeset publish && jsr publish"
}
}
-22
View File
@@ -1,22 +0,0 @@
MIT License
Copyright (c) 2014-present Sebastian McKenzie and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-19
View File
@@ -1,19 +0,0 @@
# @babel/code-frame
> Generate errors that contain a code frame that point to source locations.
See our website [@babel/code-frame](https://babeljs.io/docs/babel-code-frame) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/code-frame
```
or using yarn:
```sh
yarn add @babel/code-frame --dev
```
-216
View File
@@ -1,216 +0,0 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var picocolors = require('picocolors');
var jsTokens = require('js-tokens');
var helperValidatorIdentifier = require('@babel/helper-validator-identifier');
function isColorSupported() {
return (typeof process === "object" && (process.env.FORCE_COLOR === "0" || process.env.FORCE_COLOR === "false") ? false : picocolors.isColorSupported
);
}
const compose = (f, g) => v => f(g(v));
function buildDefs(colors) {
return {
keyword: colors.cyan,
capitalized: colors.yellow,
jsxIdentifier: colors.yellow,
punctuator: colors.yellow,
number: colors.magenta,
string: colors.green,
regex: colors.magenta,
comment: colors.gray,
invalid: compose(compose(colors.white, colors.bgRed), colors.bold),
gutter: colors.gray,
marker: compose(colors.red, colors.bold),
message: compose(colors.red, colors.bold),
reset: colors.reset
};
}
const defsOn = buildDefs(picocolors.createColors(true));
const defsOff = buildDefs(picocolors.createColors(false));
function getDefs(enabled) {
return enabled ? defsOn : defsOff;
}
const sometimesKeywords = new Set(["as", "async", "from", "get", "of", "set"]);
const NEWLINE$1 = /\r\n|[\n\r\u2028\u2029]/;
const BRACKET = /^[()[\]{}]$/;
let tokenize;
const JSX_TAG = /^[a-z][\w-]*$/i;
const getTokenType = function (token, offset, text) {
if (token.type === "name") {
const tokenValue = token.value;
if (helperValidatorIdentifier.isKeyword(tokenValue) || helperValidatorIdentifier.isStrictReservedWord(tokenValue, true) || sometimesKeywords.has(tokenValue)) {
return "keyword";
}
if (JSX_TAG.test(tokenValue) && (text[offset - 1] === "<" || text.slice(offset - 2, offset) === "</")) {
return "jsxIdentifier";
}
const firstChar = String.fromCodePoint(tokenValue.codePointAt(0));
if (firstChar !== firstChar.toLowerCase()) {
return "capitalized";
}
}
if (token.type === "punctuator" && BRACKET.test(token.value)) {
return "bracket";
}
if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
return "punctuator";
}
return token.type;
};
tokenize = function* (text) {
let match;
while (match = jsTokens.default.exec(text)) {
const token = jsTokens.matchToToken(match);
yield {
type: getTokenType(token, match.index, text),
value: token.value
};
}
};
function highlight(text) {
if (text === "") return "";
const defs = getDefs(true);
let highlighted = "";
for (const {
type,
value
} of tokenize(text)) {
if (type in defs) {
highlighted += value.split(NEWLINE$1).map(str => defs[type](str)).join("\n");
} else {
highlighted += value;
}
}
return highlighted;
}
let deprecationWarningShown = false;
const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
function getMarkerLines(loc, source, opts) {
const startLoc = Object.assign({
column: 0,
line: -1
}, loc.start);
const endLoc = Object.assign({}, startLoc, loc.end);
const {
linesAbove = 2,
linesBelow = 3
} = opts || {};
const startLine = startLoc.line;
const startColumn = startLoc.column;
const endLine = endLoc.line;
const endColumn = endLoc.column;
let start = Math.max(startLine - (linesAbove + 1), 0);
let end = Math.min(source.length, endLine + linesBelow);
if (startLine === -1) {
start = 0;
}
if (endLine === -1) {
end = source.length;
}
const lineDiff = endLine - startLine;
const markerLines = {};
if (lineDiff) {
for (let i = 0; i <= lineDiff; i++) {
const lineNumber = i + startLine;
if (!startColumn) {
markerLines[lineNumber] = true;
} else if (i === 0) {
const sourceLength = source[lineNumber - 1].length;
markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
} else if (i === lineDiff) {
markerLines[lineNumber] = [0, endColumn];
} else {
const sourceLength = source[lineNumber - i].length;
markerLines[lineNumber] = [0, sourceLength];
}
}
} else {
if (startColumn === endColumn) {
if (startColumn) {
markerLines[startLine] = [startColumn, 0];
} else {
markerLines[startLine] = true;
}
} else {
markerLines[startLine] = [startColumn, endColumn - startColumn];
}
}
return {
start,
end,
markerLines
};
}
function codeFrameColumns(rawLines, loc, opts = {}) {
const shouldHighlight = opts.forceColor || isColorSupported() && opts.highlightCode;
const defs = getDefs(shouldHighlight);
const lines = rawLines.split(NEWLINE);
const {
start,
end,
markerLines
} = getMarkerLines(loc, lines, opts);
const hasColumns = loc.start && typeof loc.start.column === "number";
const numberMaxWidth = String(end).length;
const highlightedLines = shouldHighlight ? highlight(rawLines) : rawLines;
let frame = highlightedLines.split(NEWLINE, end).slice(start, end).map((line, index) => {
const number = start + 1 + index;
const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
const gutter = ` ${paddedNumber} |`;
const hasMarker = markerLines[number];
const lastMarkerLine = !markerLines[number + 1];
if (hasMarker) {
let markerLine = "";
if (Array.isArray(hasMarker)) {
const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
const numberOfMarkers = hasMarker[1] || 1;
markerLine = ["\n ", defs.gutter(gutter.replace(/\d/g, " ")), " ", markerSpacing, defs.marker("^").repeat(numberOfMarkers)].join("");
if (lastMarkerLine && opts.message) {
markerLine += " " + defs.message(opts.message);
}
}
return [defs.marker(">"), defs.gutter(gutter), line.length > 0 ? ` ${line}` : "", markerLine].join("");
} else {
return ` ${defs.gutter(gutter)}${line.length > 0 ? ` ${line}` : ""}`;
}
}).join("\n");
if (opts.message && !hasColumns) {
frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
}
if (shouldHighlight) {
return defs.reset(frame);
} else {
return frame;
}
}
function index (rawLines, lineNumber, colNumber, opts = {}) {
if (!deprecationWarningShown) {
deprecationWarningShown = true;
const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
if (process.emitWarning) {
process.emitWarning(message, "DeprecationWarning");
} else {
const deprecationError = new Error(message);
deprecationError.name = "DeprecationWarning";
console.warn(new Error(message));
}
}
colNumber = Math.max(colNumber, 0);
const location = {
start: {
column: colNumber,
line: lineNumber
}
};
return codeFrameColumns(rawLines, location, opts);
}
exports.codeFrameColumns = codeFrameColumns;
exports.default = index;
exports.highlight = highlight;
//# sourceMappingURL=index.js.map
File diff suppressed because one or more lines are too long
-32
View File
@@ -1,32 +0,0 @@
{
"name": "@babel/code-frame",
"version": "7.28.6",
"description": "Generate errors that contain a code frame that point to source locations.",
"author": "The Babel Team (https://babel.dev/team)",
"homepage": "https://babel.dev/docs/en/next/babel-code-frame",
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "packages/babel-code-frame"
},
"main": "./lib/index.js",
"dependencies": {
"@babel/helper-validator-identifier": "^7.28.5",
"js-tokens": "^4.0.0",
"picocolors": "^1.1.1"
},
"devDependencies": {
"charcodes": "^0.2.0",
"import-meta-resolve": "^4.1.0",
"strip-ansi": "^4.0.0"
},
"engines": {
"node": ">=6.9.0"
},
"type": "commonjs"
}
-22
View File
@@ -1,22 +0,0 @@
MIT License
Copyright (c) 2014-present Sebastian McKenzie and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-19
View File
@@ -1,19 +0,0 @@
# @babel/compat-data
> The compat-data to determine required Babel plugins
See our website [@babel/compat-data](https://babeljs.io/docs/babel-compat-data) for more information.
## Install
Using npm:
```sh
npm install --save @babel/compat-data
```
or using yarn:
```sh
yarn add @babel/compat-data
```
-2
View File
@@ -1,2 +0,0 @@
// Todo (Babel 8): remove this file as Babel 8 drop support of core-js 2
module.exports = require("./data/corejs2-built-ins.json");
@@ -1,2 +0,0 @@
// Todo (Babel 8): remove this file now that it is included in babel-plugin-polyfill-corejs3
module.exports = require("./data/corejs3-shipped-proposals.json");
File diff suppressed because it is too large Load Diff
@@ -1,5 +0,0 @@
[
"esnext.promise.all-settled",
"esnext.string.match-all",
"esnext.global-this"
]
@@ -1,18 +0,0 @@
{
"es6.module": {
"chrome": "61",
"and_chr": "61",
"edge": "16",
"firefox": "60",
"and_ff": "60",
"node": "13.2.0",
"opera": "48",
"op_mob": "45",
"safari": "10.1",
"ios": "10.3",
"samsung": "8.2",
"android": "61",
"electron": "2.0",
"ios_saf": "10.3"
}
}
@@ -1,35 +0,0 @@
{
"transform-async-to-generator": [
"bugfix/transform-async-arrows-in-class"
],
"transform-parameters": [
"bugfix/transform-edge-default-parameters",
"bugfix/transform-safari-id-destructuring-collision-in-function-expression"
],
"transform-function-name": [
"bugfix/transform-edge-function-name"
],
"transform-block-scoping": [
"bugfix/transform-safari-block-shadowing",
"bugfix/transform-safari-for-shadowing"
],
"transform-template-literals": [
"bugfix/transform-tagged-template-caching"
],
"transform-optional-chaining": [
"bugfix/transform-v8-spread-parameters-in-optional-chaining"
],
"proposal-optional-chaining": [
"bugfix/transform-v8-spread-parameters-in-optional-chaining"
],
"transform-class-properties": [
"bugfix/transform-v8-static-class-fields-redefine-readonly",
"bugfix/transform-firefox-class-in-computed-class-key",
"bugfix/transform-safari-class-field-initializer-scope"
],
"proposal-class-properties": [
"bugfix/transform-v8-static-class-fields-redefine-readonly",
"bugfix/transform-firefox-class-in-computed-class-key",
"bugfix/transform-safari-class-field-initializer-scope"
]
}
@@ -1,203 +0,0 @@
{
"bugfix/transform-async-arrows-in-class": {
"chrome": "55",
"opera": "42",
"edge": "15",
"firefox": "52",
"safari": "11",
"node": "7.6",
"deno": "1",
"ios": "11",
"samsung": "6",
"opera_mobile": "42",
"electron": "1.6"
},
"bugfix/transform-edge-default-parameters": {
"chrome": "49",
"opera": "36",
"edge": "18",
"firefox": "52",
"safari": "10",
"node": "6",
"deno": "1",
"ios": "10",
"samsung": "5",
"opera_mobile": "36",
"electron": "0.37"
},
"bugfix/transform-edge-function-name": {
"chrome": "51",
"opera": "38",
"edge": "79",
"firefox": "53",
"safari": "10",
"node": "6.5",
"deno": "1",
"ios": "10",
"samsung": "5",
"opera_mobile": "41",
"electron": "1.2"
},
"bugfix/transform-safari-block-shadowing": {
"chrome": "49",
"opera": "36",
"edge": "12",
"firefox": "44",
"safari": "11",
"node": "6",
"deno": "1",
"ie": "11",
"ios": "11",
"samsung": "5",
"opera_mobile": "36",
"electron": "0.37"
},
"bugfix/transform-safari-for-shadowing": {
"chrome": "49",
"opera": "36",
"edge": "12",
"firefox": "4",
"safari": "11",
"node": "6",
"deno": "1",
"ie": "11",
"ios": "11",
"samsung": "5",
"rhino": "1.7.13",
"opera_mobile": "36",
"electron": "0.37"
},
"bugfix/transform-safari-id-destructuring-collision-in-function-expression": {
"chrome": "49",
"opera": "36",
"edge": "14",
"firefox": "2",
"safari": "16.3",
"node": "6",
"deno": "1",
"ios": "16.3",
"samsung": "5",
"opera_mobile": "36",
"electron": "0.37"
},
"bugfix/transform-tagged-template-caching": {
"chrome": "41",
"opera": "28",
"edge": "12",
"firefox": "34",
"safari": "13",
"node": "4",
"deno": "1",
"ios": "13",
"samsung": "3.4",
"rhino": "1.7.14",
"opera_mobile": "28",
"electron": "0.21"
},
"bugfix/transform-v8-spread-parameters-in-optional-chaining": {
"chrome": "91",
"opera": "77",
"edge": "91",
"firefox": "74",
"safari": "13.1",
"node": "16.9",
"deno": "1.9",
"ios": "13.4",
"samsung": "16",
"opera_mobile": "64",
"electron": "13.0"
},
"transform-optional-chaining": {
"chrome": "80",
"opera": "67",
"edge": "80",
"firefox": "74",
"safari": "13.1",
"node": "14",
"deno": "1",
"ios": "13.4",
"samsung": "13",
"rhino": "1.8",
"opera_mobile": "57",
"electron": "8.0"
},
"proposal-optional-chaining": {
"chrome": "80",
"opera": "67",
"edge": "80",
"firefox": "74",
"safari": "13.1",
"node": "14",
"deno": "1",
"ios": "13.4",
"samsung": "13",
"rhino": "1.8",
"opera_mobile": "57",
"electron": "8.0"
},
"transform-parameters": {
"chrome": "49",
"opera": "36",
"edge": "15",
"firefox": "52",
"safari": "10",
"node": "6",
"deno": "1",
"ios": "10",
"samsung": "5",
"opera_mobile": "36",
"electron": "0.37"
},
"transform-async-to-generator": {
"chrome": "55",
"opera": "42",
"edge": "15",
"firefox": "52",
"safari": "10.1",
"node": "7.6",
"deno": "1",
"ios": "10.3",
"samsung": "6",
"opera_mobile": "42",
"electron": "1.6"
},
"transform-template-literals": {
"chrome": "41",
"opera": "28",
"edge": "13",
"firefox": "34",
"safari": "9",
"node": "4",
"deno": "1",
"ios": "9",
"samsung": "3.4",
"opera_mobile": "28",
"electron": "0.21"
},
"transform-function-name": {
"chrome": "51",
"opera": "38",
"edge": "14",
"firefox": "53",
"safari": "10",
"node": "6.5",
"deno": "1",
"ios": "10",
"samsung": "5",
"opera_mobile": "41",
"electron": "1.2"
},
"transform-block-scoping": {
"chrome": "50",
"opera": "37",
"edge": "14",
"firefox": "53",
"safari": "10",
"node": "6",
"deno": "1",
"ios": "10",
"samsung": "5",
"opera_mobile": "37",
"electron": "1.1"
}
}
-838
View File
@@ -1,838 +0,0 @@
{
"transform-explicit-resource-management": {
"chrome": "134",
"edge": "134",
"firefox": "141",
"node": "24",
"electron": "35.0"
},
"transform-duplicate-named-capturing-groups-regex": {
"chrome": "126",
"opera": "112",
"edge": "126",
"firefox": "129",
"safari": "17.4",
"node": "23",
"ios": "17.4",
"electron": "31.0"
},
"transform-regexp-modifiers": {
"chrome": "125",
"opera": "111",
"edge": "125",
"firefox": "132",
"node": "23",
"samsung": "27",
"electron": "31.0"
},
"transform-unicode-sets-regex": {
"chrome": "112",
"opera": "98",
"edge": "112",
"firefox": "116",
"safari": "17",
"node": "20",
"deno": "1.32",
"ios": "17",
"samsung": "23",
"opera_mobile": "75",
"electron": "24.0"
},
"bugfix/transform-v8-static-class-fields-redefine-readonly": {
"chrome": "98",
"opera": "84",
"edge": "98",
"firefox": "75",
"safari": "15",
"node": "12",
"deno": "1.18",
"ios": "15",
"samsung": "11",
"opera_mobile": "52",
"electron": "17.0"
},
"bugfix/transform-firefox-class-in-computed-class-key": {
"chrome": "74",
"opera": "62",
"edge": "79",
"firefox": "126",
"safari": "16",
"node": "12",
"deno": "1",
"ios": "16",
"samsung": "11",
"opera_mobile": "53",
"electron": "6.0"
},
"bugfix/transform-safari-class-field-initializer-scope": {
"chrome": "74",
"opera": "62",
"edge": "79",
"firefox": "69",
"safari": "16",
"node": "12",
"deno": "1",
"ios": "16",
"samsung": "11",
"opera_mobile": "53",
"electron": "6.0"
},
"transform-class-static-block": {
"chrome": "94",
"opera": "80",
"edge": "94",
"firefox": "93",
"safari": "16.4",
"node": "16.11",
"deno": "1.14",
"ios": "16.4",
"samsung": "17",
"opera_mobile": "66",
"electron": "15.0"
},
"proposal-class-static-block": {
"chrome": "94",
"opera": "80",
"edge": "94",
"firefox": "93",
"safari": "16.4",
"node": "16.11",
"deno": "1.14",
"ios": "16.4",
"samsung": "17",
"opera_mobile": "66",
"electron": "15.0"
},
"transform-private-property-in-object": {
"chrome": "91",
"opera": "77",
"edge": "91",
"firefox": "90",
"safari": "15",
"node": "16.9",
"deno": "1.9",
"ios": "15",
"samsung": "16",
"opera_mobile": "64",
"electron": "13.0"
},
"proposal-private-property-in-object": {
"chrome": "91",
"opera": "77",
"edge": "91",
"firefox": "90",
"safari": "15",
"node": "16.9",
"deno": "1.9",
"ios": "15",
"samsung": "16",
"opera_mobile": "64",
"electron": "13.0"
},
"transform-class-properties": {
"chrome": "74",
"opera": "62",
"edge": "79",
"firefox": "90",
"safari": "14.1",
"node": "12",
"deno": "1",
"ios": "14.5",
"samsung": "11",
"opera_mobile": "53",
"electron": "6.0"
},
"proposal-class-properties": {
"chrome": "74",
"opera": "62",
"edge": "79",
"firefox": "90",
"safari": "14.1",
"node": "12",
"deno": "1",
"ios": "14.5",
"samsung": "11",
"opera_mobile": "53",
"electron": "6.0"
},
"transform-private-methods": {
"chrome": "84",
"opera": "70",
"edge": "84",
"firefox": "90",
"safari": "15",
"node": "14.6",
"deno": "1",
"ios": "15",
"samsung": "14",
"opera_mobile": "60",
"electron": "10.0"
},
"proposal-private-methods": {
"chrome": "84",
"opera": "70",
"edge": "84",
"firefox": "90",
"safari": "15",
"node": "14.6",
"deno": "1",
"ios": "15",
"samsung": "14",
"opera_mobile": "60",
"electron": "10.0"
},
"transform-numeric-separator": {
"chrome": "75",
"opera": "62",
"edge": "79",
"firefox": "70",
"safari": "13",
"node": "12.5",
"deno": "1",
"ios": "13",
"samsung": "11",
"rhino": "1.7.14",
"opera_mobile": "54",
"electron": "6.0"
},
"proposal-numeric-separator": {
"chrome": "75",
"opera": "62",
"edge": "79",
"firefox": "70",
"safari": "13",
"node": "12.5",
"deno": "1",
"ios": "13",
"samsung": "11",
"rhino": "1.7.14",
"opera_mobile": "54",
"electron": "6.0"
},
"transform-logical-assignment-operators": {
"chrome": "85",
"opera": "71",
"edge": "85",
"firefox": "79",
"safari": "14",
"node": "15",
"deno": "1.2",
"ios": "14",
"samsung": "14",
"opera_mobile": "60",
"electron": "10.0"
},
"proposal-logical-assignment-operators": {
"chrome": "85",
"opera": "71",
"edge": "85",
"firefox": "79",
"safari": "14",
"node": "15",
"deno": "1.2",
"ios": "14",
"samsung": "14",
"opera_mobile": "60",
"electron": "10.0"
},
"transform-nullish-coalescing-operator": {
"chrome": "80",
"opera": "67",
"edge": "80",
"firefox": "72",
"safari": "13.1",
"node": "14",
"deno": "1",
"ios": "13.4",
"samsung": "13",
"rhino": "1.8",
"opera_mobile": "57",
"electron": "8.0"
},
"proposal-nullish-coalescing-operator": {
"chrome": "80",
"opera": "67",
"edge": "80",
"firefox": "72",
"safari": "13.1",
"node": "14",
"deno": "1",
"ios": "13.4",
"samsung": "13",
"rhino": "1.8",
"opera_mobile": "57",
"electron": "8.0"
},
"transform-optional-chaining": {
"chrome": "91",
"opera": "77",
"edge": "91",
"firefox": "74",
"safari": "13.1",
"node": "16.9",
"deno": "1.9",
"ios": "13.4",
"samsung": "16",
"opera_mobile": "64",
"electron": "13.0"
},
"proposal-optional-chaining": {
"chrome": "91",
"opera": "77",
"edge": "91",
"firefox": "74",
"safari": "13.1",
"node": "16.9",
"deno": "1.9",
"ios": "13.4",
"samsung": "16",
"opera_mobile": "64",
"electron": "13.0"
},
"transform-json-strings": {
"chrome": "66",
"opera": "53",
"edge": "79",
"firefox": "62",
"safari": "12",
"node": "10",
"deno": "1",
"ios": "12",
"samsung": "9",
"rhino": "1.7.14",
"opera_mobile": "47",
"electron": "3.0"
},
"proposal-json-strings": {
"chrome": "66",
"opera": "53",
"edge": "79",
"firefox": "62",
"safari": "12",
"node": "10",
"deno": "1",
"ios": "12",
"samsung": "9",
"rhino": "1.7.14",
"opera_mobile": "47",
"electron": "3.0"
},
"transform-optional-catch-binding": {
"chrome": "66",
"opera": "53",
"edge": "79",
"firefox": "58",
"safari": "11.1",
"node": "10",
"deno": "1",
"ios": "11.3",
"samsung": "9",
"opera_mobile": "47",
"electron": "3.0"
},
"proposal-optional-catch-binding": {
"chrome": "66",
"opera": "53",
"edge": "79",
"firefox": "58",
"safari": "11.1",
"node": "10",
"deno": "1",
"ios": "11.3",
"samsung": "9",
"opera_mobile": "47",
"electron": "3.0"
},
"transform-parameters": {
"chrome": "49",
"opera": "36",
"edge": "18",
"firefox": "52",
"safari": "16.3",
"node": "6",
"deno": "1",
"ios": "16.3",
"samsung": "5",
"opera_mobile": "36",
"electron": "0.37"
},
"transform-async-generator-functions": {
"chrome": "63",
"opera": "50",
"edge": "79",
"firefox": "57",
"safari": "12",
"node": "10",
"deno": "1",
"ios": "12",
"samsung": "8",
"opera_mobile": "46",
"electron": "3.0"
},
"proposal-async-generator-functions": {
"chrome": "63",
"opera": "50",
"edge": "79",
"firefox": "57",
"safari": "12",
"node": "10",
"deno": "1",
"ios": "12",
"samsung": "8",
"opera_mobile": "46",
"electron": "3.0"
},
"transform-object-rest-spread": {
"chrome": "60",
"opera": "47",
"edge": "79",
"firefox": "55",
"safari": "11.1",
"node": "8.3",
"deno": "1",
"ios": "11.3",
"samsung": "8",
"opera_mobile": "44",
"electron": "2.0"
},
"proposal-object-rest-spread": {
"chrome": "60",
"opera": "47",
"edge": "79",
"firefox": "55",
"safari": "11.1",
"node": "8.3",
"deno": "1",
"ios": "11.3",
"samsung": "8",
"opera_mobile": "44",
"electron": "2.0"
},
"transform-dotall-regex": {
"chrome": "62",
"opera": "49",
"edge": "79",
"firefox": "78",
"safari": "11.1",
"node": "8.10",
"deno": "1",
"ios": "11.3",
"samsung": "8",
"rhino": "1.7.15",
"opera_mobile": "46",
"electron": "3.0"
},
"transform-unicode-property-regex": {
"chrome": "64",
"opera": "51",
"edge": "79",
"firefox": "78",
"safari": "11.1",
"node": "10",
"deno": "1",
"ios": "11.3",
"samsung": "9",
"opera_mobile": "47",
"electron": "3.0"
},
"proposal-unicode-property-regex": {
"chrome": "64",
"opera": "51",
"edge": "79",
"firefox": "78",
"safari": "11.1",
"node": "10",
"deno": "1",
"ios": "11.3",
"samsung": "9",
"opera_mobile": "47",
"electron": "3.0"
},
"transform-named-capturing-groups-regex": {
"chrome": "64",
"opera": "51",
"edge": "79",
"firefox": "78",
"safari": "11.1",
"node": "10",
"deno": "1",
"ios": "11.3",
"samsung": "9",
"opera_mobile": "47",
"electron": "3.0"
},
"transform-async-to-generator": {
"chrome": "55",
"opera": "42",
"edge": "15",
"firefox": "52",
"safari": "11",
"node": "7.6",
"deno": "1",
"ios": "11",
"samsung": "6",
"opera_mobile": "42",
"electron": "1.6"
},
"transform-exponentiation-operator": {
"chrome": "52",
"opera": "39",
"edge": "14",
"firefox": "52",
"safari": "10.1",
"node": "7",
"deno": "1",
"ios": "10.3",
"samsung": "6",
"rhino": "1.7.14",
"opera_mobile": "41",
"electron": "1.3"
},
"transform-template-literals": {
"chrome": "41",
"opera": "28",
"edge": "13",
"firefox": "34",
"safari": "13",
"node": "4",
"deno": "1",
"ios": "13",
"samsung": "3.4",
"opera_mobile": "28",
"electron": "0.21"
},
"transform-literals": {
"chrome": "44",
"opera": "31",
"edge": "12",
"firefox": "53",
"safari": "9",
"node": "4",
"deno": "1",
"ios": "9",
"samsung": "4",
"rhino": "1.7.15",
"opera_mobile": "32",
"electron": "0.30"
},
"transform-function-name": {
"chrome": "51",
"opera": "38",
"edge": "79",
"firefox": "53",
"safari": "10",
"node": "6.5",
"deno": "1",
"ios": "10",
"samsung": "5",
"opera_mobile": "41",
"electron": "1.2"
},
"transform-arrow-functions": {
"chrome": "47",
"opera": "34",
"edge": "13",
"firefox": "43",
"safari": "10",
"node": "6",
"deno": "1",
"ios": "10",
"samsung": "5",
"rhino": "1.7.13",
"opera_mobile": "34",
"electron": "0.36"
},
"transform-block-scoped-functions": {
"chrome": "41",
"opera": "28",
"edge": "12",
"firefox": "46",
"safari": "10",
"node": "4",
"deno": "1",
"ie": "11",
"ios": "10",
"samsung": "3.4",
"opera_mobile": "28",
"electron": "0.21"
},
"transform-classes": {
"chrome": "46",
"opera": "33",
"edge": "13",
"firefox": "45",
"safari": "10",
"node": "5",
"deno": "1",
"ios": "10",
"samsung": "5",
"opera_mobile": "33",
"electron": "0.36"
},
"transform-object-super": {
"chrome": "46",
"opera": "33",
"edge": "13",
"firefox": "45",
"safari": "10",
"node": "5",
"deno": "1",
"ios": "10",
"samsung": "5",
"opera_mobile": "33",
"electron": "0.36"
},
"transform-shorthand-properties": {
"chrome": "43",
"opera": "30",
"edge": "12",
"firefox": "33",
"safari": "9",
"node": "4",
"deno": "1",
"ios": "9",
"samsung": "4",
"rhino": "1.7.14",
"opera_mobile": "30",
"electron": "0.27"
},
"transform-duplicate-keys": {
"chrome": "42",
"opera": "29",
"edge": "12",
"firefox": "34",
"safari": "9",
"node": "4",
"deno": "1",
"ios": "9",
"samsung": "3.4",
"opera_mobile": "29",
"electron": "0.25"
},
"transform-computed-properties": {
"chrome": "44",
"opera": "31",
"edge": "12",
"firefox": "34",
"safari": "7.1",
"node": "4",
"deno": "1",
"ios": "8",
"samsung": "4",
"rhino": "1.8",
"opera_mobile": "32",
"electron": "0.30"
},
"transform-for-of": {
"chrome": "51",
"opera": "38",
"edge": "15",
"firefox": "53",
"safari": "10",
"node": "6.5",
"deno": "1",
"ios": "10",
"samsung": "5",
"opera_mobile": "41",
"electron": "1.2"
},
"transform-sticky-regex": {
"chrome": "49",
"opera": "36",
"edge": "13",
"firefox": "3",
"safari": "10",
"node": "6",
"deno": "1",
"ios": "10",
"samsung": "5",
"rhino": "1.7.15",
"opera_mobile": "36",
"electron": "0.37"
},
"transform-unicode-escapes": {
"chrome": "44",
"opera": "31",
"edge": "12",
"firefox": "53",
"safari": "9",
"node": "4",
"deno": "1",
"ios": "9",
"samsung": "4",
"rhino": "1.7.15",
"opera_mobile": "32",
"electron": "0.30"
},
"transform-unicode-regex": {
"chrome": "50",
"opera": "37",
"edge": "13",
"firefox": "46",
"safari": "12",
"node": "6",
"deno": "1",
"ios": "12",
"samsung": "5",
"opera_mobile": "37",
"electron": "1.1"
},
"transform-spread": {
"chrome": "46",
"opera": "33",
"edge": "13",
"firefox": "45",
"safari": "10",
"node": "5",
"deno": "1",
"ios": "10",
"samsung": "5",
"opera_mobile": "33",
"electron": "0.36"
},
"transform-destructuring": {
"chrome": "51",
"opera": "38",
"edge": "15",
"firefox": "53",
"safari": "10",
"node": "6.5",
"deno": "1",
"ios": "10",
"samsung": "5",
"opera_mobile": "41",
"electron": "1.2"
},
"transform-block-scoping": {
"chrome": "50",
"opera": "37",
"edge": "14",
"firefox": "53",
"safari": "11",
"node": "6",
"deno": "1",
"ios": "11",
"samsung": "5",
"opera_mobile": "37",
"electron": "1.1"
},
"transform-typeof-symbol": {
"chrome": "48",
"opera": "35",
"edge": "12",
"firefox": "36",
"safari": "9",
"node": "6",
"deno": "1",
"ios": "9",
"samsung": "5",
"rhino": "1.8",
"opera_mobile": "35",
"electron": "0.37"
},
"transform-new-target": {
"chrome": "46",
"opera": "33",
"edge": "14",
"firefox": "41",
"safari": "10",
"node": "5",
"deno": "1",
"ios": "10",
"samsung": "5",
"opera_mobile": "33",
"electron": "0.36"
},
"transform-regenerator": {
"chrome": "50",
"opera": "37",
"edge": "13",
"firefox": "53",
"safari": "10",
"node": "6",
"deno": "1",
"ios": "10",
"samsung": "5",
"opera_mobile": "37",
"electron": "1.1"
},
"transform-member-expression-literals": {
"chrome": "7",
"opera": "12",
"edge": "12",
"firefox": "2",
"safari": "5.1",
"node": "0.4",
"deno": "1",
"ie": "9",
"android": "4",
"ios": "6",
"phantom": "1.9",
"samsung": "1",
"rhino": "1.7.13",
"opera_mobile": "12",
"electron": "0.20"
},
"transform-property-literals": {
"chrome": "7",
"opera": "12",
"edge": "12",
"firefox": "2",
"safari": "5.1",
"node": "0.4",
"deno": "1",
"ie": "9",
"android": "4",
"ios": "6",
"phantom": "1.9",
"samsung": "1",
"rhino": "1.7.13",
"opera_mobile": "12",
"electron": "0.20"
},
"transform-reserved-words": {
"chrome": "13",
"opera": "10.50",
"edge": "12",
"firefox": "2",
"safari": "3.1",
"node": "0.6",
"deno": "1",
"ie": "9",
"android": "4.4",
"ios": "6",
"phantom": "1.9",
"samsung": "1",
"rhino": "1.7.13",
"opera_mobile": "10.1",
"electron": "0.20"
},
"transform-export-namespace-from": {
"chrome": "72",
"deno": "1.0",
"edge": "79",
"firefox": "80",
"node": "13.2.0",
"opera": "60",
"opera_mobile": "51",
"safari": "14.1",
"ios": "14.5",
"samsung": "11.0",
"android": "72",
"electron": "5.0"
},
"proposal-export-namespace-from": {
"chrome": "72",
"deno": "1.0",
"edge": "79",
"firefox": "80",
"node": "13.2.0",
"opera": "60",
"opera_mobile": "51",
"safari": "14.1",
"ios": "14.5",
"samsung": "11.0",
"android": "72",
"electron": "5.0"
}
}
-2
View File
@@ -1,2 +0,0 @@
// Todo (Babel 8): remove this file, in Babel 8 users import the .json directly
module.exports = require("./data/native-modules.json");
@@ -1,2 +0,0 @@
// Todo (Babel 8): remove this file, in Babel 8 users import the .json directly
module.exports = require("./data/overlapping-plugins.json");
-40
View File
@@ -1,40 +0,0 @@
{
"name": "@babel/compat-data",
"version": "7.28.6",
"author": "The Babel Team (https://babel.dev/team)",
"license": "MIT",
"description": "The compat-data to determine required Babel plugins",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "packages/babel-compat-data"
},
"publishConfig": {
"access": "public"
},
"exports": {
"./plugins": "./plugins.js",
"./native-modules": "./native-modules.js",
"./corejs2-built-ins": "./corejs2-built-ins.js",
"./corejs3-shipped-proposals": "./corejs3-shipped-proposals.js",
"./overlapping-plugins": "./overlapping-plugins.js",
"./plugin-bugfixes": "./plugin-bugfixes.js"
},
"scripts": {
"build-data": "./scripts/download-compat-table.sh && node ./scripts/build-data.mjs && node ./scripts/build-modules-support.mjs && node ./scripts/build-bugfixes-targets.mjs"
},
"keywords": [
"babel",
"compat-table",
"compat-data"
],
"devDependencies": {
"@mdn/browser-compat-data": "^6.0.8",
"core-js-compat": "^3.43.0",
"electron-to-chromium": "^1.5.140"
},
"engines": {
"node": ">=6.9.0"
},
"type": "commonjs"
}
-2
View File
@@ -1,2 +0,0 @@
// Todo (Babel 8): remove this file, in Babel 8 users import the .json directly
module.exports = require("./data/plugin-bugfixes.json");
-2
View File
@@ -1,2 +0,0 @@
// Todo (Babel 8): remove this file, in Babel 8 users import the .json directly
module.exports = require("./data/plugins.json");
-22
View File
@@ -1,22 +0,0 @@
MIT License
Copyright (c) 2014-present Sebastian McKenzie and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-19
View File
@@ -1,19 +0,0 @@
# @babel/core
> Babel compiler core.
See our website [@babel/core](https://babeljs.io/docs/babel-core) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20core%22+is%3Aopen) associated with this package.
## Install
Using npm:
```sh
npm install --save-dev @babel/core
```
or using yarn:
```sh
yarn add @babel/core --dev
```
-5
View File
@@ -1,5 +0,0 @@
"use strict";
0 && 0;
//# sourceMappingURL=cache-contexts.js.map
@@ -1 +0,0 @@
{"version":3,"names":[],"sources":["../../src/config/cache-contexts.ts"],"sourcesContent":["import type { ConfigContext } from \"./config-chain.ts\";\nimport type {\n CallerMetadata,\n TargetsListOrObject,\n} from \"./validation/options.ts\";\n\nexport type { ConfigContext as FullConfig };\n\nexport type FullPreset = {\n targets: TargetsListOrObject;\n} & ConfigContext;\nexport type FullPlugin = {\n assumptions: Record<string, boolean>;\n} & FullPreset;\n\n// Context not including filename since it is used in places that cannot\n// process 'ignore'/'only' and other filename-based logic.\nexport type SimpleConfig = {\n envName: string;\n caller: CallerMetadata | undefined;\n};\nexport type SimplePreset = {\n targets: TargetsListOrObject;\n} & SimpleConfig;\nexport type SimplePlugin = {\n assumptions: Record<string, boolean>;\n} & SimplePreset;\n"],"mappings":"","ignoreList":[]}
-261
View File
@@ -1,261 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.assertSimpleType = assertSimpleType;
exports.makeStrongCache = makeStrongCache;
exports.makeStrongCacheSync = makeStrongCacheSync;
exports.makeWeakCache = makeWeakCache;
exports.makeWeakCacheSync = makeWeakCacheSync;
function _gensync() {
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _async = require("../gensync-utils/async.js");
var _util = require("./util.js");
const synchronize = gen => {
return _gensync()(gen).sync;
};
function* genTrue() {
return true;
}
function makeWeakCache(handler) {
return makeCachedFunction(WeakMap, handler);
}
function makeWeakCacheSync(handler) {
return synchronize(makeWeakCache(handler));
}
function makeStrongCache(handler) {
return makeCachedFunction(Map, handler);
}
function makeStrongCacheSync(handler) {
return synchronize(makeStrongCache(handler));
}
function makeCachedFunction(CallCache, handler) {
const callCacheSync = new CallCache();
const callCacheAsync = new CallCache();
const futureCache = new CallCache();
return function* cachedFunction(arg, data) {
const asyncContext = yield* (0, _async.isAsync)();
const callCache = asyncContext ? callCacheAsync : callCacheSync;
const cached = yield* getCachedValueOrWait(asyncContext, callCache, futureCache, arg, data);
if (cached.valid) return cached.value;
const cache = new CacheConfigurator(data);
const handlerResult = handler(arg, cache);
let finishLock;
let value;
if ((0, _util.isIterableIterator)(handlerResult)) {
value = yield* (0, _async.onFirstPause)(handlerResult, () => {
finishLock = setupAsyncLocks(cache, futureCache, arg);
});
} else {
value = handlerResult;
}
updateFunctionCache(callCache, cache, arg, value);
if (finishLock) {
futureCache.delete(arg);
finishLock.release(value);
}
return value;
};
}
function* getCachedValue(cache, arg, data) {
const cachedValue = cache.get(arg);
if (cachedValue) {
for (const {
value,
valid
} of cachedValue) {
if (yield* valid(data)) return {
valid: true,
value
};
}
}
return {
valid: false,
value: null
};
}
function* getCachedValueOrWait(asyncContext, callCache, futureCache, arg, data) {
const cached = yield* getCachedValue(callCache, arg, data);
if (cached.valid) {
return cached;
}
if (asyncContext) {
const cached = yield* getCachedValue(futureCache, arg, data);
if (cached.valid) {
const value = yield* (0, _async.waitFor)(cached.value.promise);
return {
valid: true,
value
};
}
}
return {
valid: false,
value: null
};
}
function setupAsyncLocks(config, futureCache, arg) {
const finishLock = new Lock();
updateFunctionCache(futureCache, config, arg, finishLock);
return finishLock;
}
function updateFunctionCache(cache, config, arg, value) {
if (!config.configured()) config.forever();
let cachedValue = cache.get(arg);
config.deactivate();
switch (config.mode()) {
case "forever":
cachedValue = [{
value,
valid: genTrue
}];
cache.set(arg, cachedValue);
break;
case "invalidate":
cachedValue = [{
value,
valid: config.validator()
}];
cache.set(arg, cachedValue);
break;
case "valid":
if (cachedValue) {
cachedValue.push({
value,
valid: config.validator()
});
} else {
cachedValue = [{
value,
valid: config.validator()
}];
cache.set(arg, cachedValue);
}
}
}
class CacheConfigurator {
constructor(data) {
this._active = true;
this._never = false;
this._forever = false;
this._invalidate = false;
this._configured = false;
this._pairs = [];
this._data = void 0;
this._data = data;
}
simple() {
return makeSimpleConfigurator(this);
}
mode() {
if (this._never) return "never";
if (this._forever) return "forever";
if (this._invalidate) return "invalidate";
return "valid";
}
forever() {
if (!this._active) {
throw new Error("Cannot change caching after evaluation has completed.");
}
if (this._never) {
throw new Error("Caching has already been configured with .never()");
}
this._forever = true;
this._configured = true;
}
never() {
if (!this._active) {
throw new Error("Cannot change caching after evaluation has completed.");
}
if (this._forever) {
throw new Error("Caching has already been configured with .forever()");
}
this._never = true;
this._configured = true;
}
using(handler) {
if (!this._active) {
throw new Error("Cannot change caching after evaluation has completed.");
}
if (this._never || this._forever) {
throw new Error("Caching has already been configured with .never or .forever()");
}
this._configured = true;
const key = handler(this._data);
const fn = (0, _async.maybeAsync)(handler, `You appear to be using an async cache handler, but Babel has been called synchronously`);
if ((0, _async.isThenable)(key)) {
return key.then(key => {
this._pairs.push([key, fn]);
return key;
});
}
this._pairs.push([key, fn]);
return key;
}
invalidate(handler) {
this._invalidate = true;
return this.using(handler);
}
validator() {
const pairs = this._pairs;
return function* (data) {
for (const [key, fn] of pairs) {
if (key !== (yield* fn(data))) return false;
}
return true;
};
}
deactivate() {
this._active = false;
}
configured() {
return this._configured;
}
}
function makeSimpleConfigurator(cache) {
function cacheFn(val) {
if (typeof val === "boolean") {
if (val) cache.forever();else cache.never();
return;
}
return cache.using(() => assertSimpleType(val()));
}
cacheFn.forever = () => cache.forever();
cacheFn.never = () => cache.never();
cacheFn.using = cb => cache.using(() => assertSimpleType(cb()));
cacheFn.invalidate = cb => cache.invalidate(() => assertSimpleType(cb()));
return cacheFn;
}
function assertSimpleType(value) {
if ((0, _async.isThenable)(value)) {
throw new Error(`You appear to be using an async cache handler, ` + `which your current version of Babel does not support. ` + `We may add support for this in the future, ` + `but if you're on the most recent version of @babel/core and still ` + `seeing this error, then you'll need to synchronously handle your caching logic.`);
}
if (value != null && typeof value !== "string" && typeof value !== "boolean" && typeof value !== "number") {
throw new Error("Cache keys must be either string, boolean, number, null, or undefined.");
}
return value;
}
class Lock {
constructor() {
this.released = false;
this.promise = void 0;
this._resolve = void 0;
this.promise = new Promise(resolve => {
this._resolve = resolve;
});
}
release(value) {
this.released = true;
this._resolve(value);
}
}
0 && 0;
//# sourceMappingURL=caching.js.map
File diff suppressed because one or more lines are too long
-469
View File
@@ -1,469 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.buildPresetChain = buildPresetChain;
exports.buildPresetChainWalker = void 0;
exports.buildRootChain = buildRootChain;
function _path() {
const data = require("path");
_path = function () {
return data;
};
return data;
}
function _debug() {
const data = require("debug");
_debug = function () {
return data;
};
return data;
}
var _options = require("./validation/options.js");
var _patternToRegex = require("./pattern-to-regex.js");
var _printer = require("./printer.js");
var _rewriteStackTrace = require("../errors/rewrite-stack-trace.js");
var _configError = require("../errors/config-error.js");
var _index = require("./files/index.js");
var _caching = require("./caching.js");
var _configDescriptors = require("./config-descriptors.js");
const debug = _debug()("babel:config:config-chain");
function* buildPresetChain(arg, context) {
const chain = yield* buildPresetChainWalker(arg, context);
if (!chain) return null;
return {
plugins: dedupDescriptors(chain.plugins),
presets: dedupDescriptors(chain.presets),
options: chain.options.map(o => createConfigChainOptions(o)),
files: new Set()
};
}
const buildPresetChainWalker = exports.buildPresetChainWalker = makeChainWalker({
root: preset => loadPresetDescriptors(preset),
env: (preset, envName) => loadPresetEnvDescriptors(preset)(envName),
overrides: (preset, index) => loadPresetOverridesDescriptors(preset)(index),
overridesEnv: (preset, index, envName) => loadPresetOverridesEnvDescriptors(preset)(index)(envName),
createLogger: () => () => {}
});
const loadPresetDescriptors = (0, _caching.makeWeakCacheSync)(preset => buildRootDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors));
const loadPresetEnvDescriptors = (0, _caching.makeWeakCacheSync)(preset => (0, _caching.makeStrongCacheSync)(envName => buildEnvDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, envName)));
const loadPresetOverridesDescriptors = (0, _caching.makeWeakCacheSync)(preset => (0, _caching.makeStrongCacheSync)(index => buildOverrideDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, index)));
const loadPresetOverridesEnvDescriptors = (0, _caching.makeWeakCacheSync)(preset => (0, _caching.makeStrongCacheSync)(index => (0, _caching.makeStrongCacheSync)(envName => buildOverrideEnvDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, index, envName))));
function* buildRootChain(opts, context) {
let configReport, babelRcReport;
const programmaticLogger = new _printer.ConfigPrinter();
const programmaticChain = yield* loadProgrammaticChain({
options: opts,
dirname: context.cwd
}, context, undefined, programmaticLogger);
if (!programmaticChain) return null;
const programmaticReport = yield* programmaticLogger.output();
let configFile;
if (typeof opts.configFile === "string") {
configFile = yield* (0, _index.loadConfig)(opts.configFile, context.cwd, context.envName, context.caller);
} else if (opts.configFile !== false) {
configFile = yield* (0, _index.findRootConfig)(context.root, context.envName, context.caller);
}
let {
babelrc,
babelrcRoots
} = opts;
let babelrcRootsDirectory = context.cwd;
const configFileChain = emptyChain();
const configFileLogger = new _printer.ConfigPrinter();
if (configFile) {
const validatedFile = validateConfigFile(configFile);
const result = yield* loadFileChain(validatedFile, context, undefined, configFileLogger);
if (!result) return null;
configReport = yield* configFileLogger.output();
if (babelrc === undefined) {
babelrc = validatedFile.options.babelrc;
}
if (babelrcRoots === undefined) {
babelrcRootsDirectory = validatedFile.dirname;
babelrcRoots = validatedFile.options.babelrcRoots;
}
mergeChain(configFileChain, result);
}
let ignoreFile, babelrcFile;
let isIgnored = false;
const fileChain = emptyChain();
if ((babelrc === true || babelrc === undefined) && typeof context.filename === "string") {
const pkgData = yield* (0, _index.findPackageData)(context.filename);
if (pkgData && babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory)) {
({
ignore: ignoreFile,
config: babelrcFile
} = yield* (0, _index.findRelativeConfig)(pkgData, context.envName, context.caller));
if (ignoreFile) {
fileChain.files.add(ignoreFile.filepath);
}
if (ignoreFile && shouldIgnore(context, ignoreFile.ignore, null, ignoreFile.dirname)) {
isIgnored = true;
}
if (babelrcFile && !isIgnored) {
const validatedFile = validateBabelrcFile(babelrcFile);
const babelrcLogger = new _printer.ConfigPrinter();
const result = yield* loadFileChain(validatedFile, context, undefined, babelrcLogger);
if (!result) {
isIgnored = true;
} else {
babelRcReport = yield* babelrcLogger.output();
mergeChain(fileChain, result);
}
}
if (babelrcFile && isIgnored) {
fileChain.files.add(babelrcFile.filepath);
}
}
}
if (context.showConfig) {
console.log(`Babel configs on "${context.filename}" (ascending priority):\n` + [configReport, babelRcReport, programmaticReport].filter(x => !!x).join("\n\n") + "\n-----End Babel configs-----");
}
const chain = mergeChain(mergeChain(mergeChain(emptyChain(), configFileChain), fileChain), programmaticChain);
return {
plugins: isIgnored ? [] : dedupDescriptors(chain.plugins),
presets: isIgnored ? [] : dedupDescriptors(chain.presets),
options: isIgnored ? [] : chain.options.map(o => createConfigChainOptions(o)),
fileHandling: isIgnored ? "ignored" : "transpile",
ignore: ignoreFile || undefined,
babelrc: babelrcFile || undefined,
config: configFile || undefined,
files: chain.files
};
}
function babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory) {
if (typeof babelrcRoots === "boolean") return babelrcRoots;
const absoluteRoot = context.root;
if (babelrcRoots === undefined) {
return pkgData.directories.includes(absoluteRoot);
}
let babelrcPatterns = babelrcRoots;
if (!Array.isArray(babelrcPatterns)) {
babelrcPatterns = [babelrcPatterns];
}
babelrcPatterns = babelrcPatterns.map(pat => {
return typeof pat === "string" ? _path().resolve(babelrcRootsDirectory, pat) : pat;
});
if (babelrcPatterns.length === 1 && babelrcPatterns[0] === absoluteRoot) {
return pkgData.directories.includes(absoluteRoot);
}
return babelrcPatterns.some(pat => {
if (typeof pat === "string") {
pat = (0, _patternToRegex.default)(pat, babelrcRootsDirectory);
}
return pkgData.directories.some(directory => {
return matchPattern(pat, babelrcRootsDirectory, directory, context);
});
});
}
const validateConfigFile = (0, _caching.makeWeakCacheSync)(file => ({
filepath: file.filepath,
dirname: file.dirname,
options: (0, _options.validate)("configfile", file.options, file.filepath)
}));
const validateBabelrcFile = (0, _caching.makeWeakCacheSync)(file => ({
filepath: file.filepath,
dirname: file.dirname,
options: (0, _options.validate)("babelrcfile", file.options, file.filepath)
}));
const validateExtendFile = (0, _caching.makeWeakCacheSync)(file => ({
filepath: file.filepath,
dirname: file.dirname,
options: (0, _options.validate)("extendsfile", file.options, file.filepath)
}));
const loadProgrammaticChain = makeChainWalker({
root: input => buildRootDescriptors(input, "base", _configDescriptors.createCachedDescriptors),
env: (input, envName) => buildEnvDescriptors(input, "base", _configDescriptors.createCachedDescriptors, envName),
overrides: (input, index) => buildOverrideDescriptors(input, "base", _configDescriptors.createCachedDescriptors, index),
overridesEnv: (input, index, envName) => buildOverrideEnvDescriptors(input, "base", _configDescriptors.createCachedDescriptors, index, envName),
createLogger: (input, context, baseLogger) => buildProgrammaticLogger(input, context, baseLogger)
});
const loadFileChainWalker = makeChainWalker({
root: file => loadFileDescriptors(file),
env: (file, envName) => loadFileEnvDescriptors(file)(envName),
overrides: (file, index) => loadFileOverridesDescriptors(file)(index),
overridesEnv: (file, index, envName) => loadFileOverridesEnvDescriptors(file)(index)(envName),
createLogger: (file, context, baseLogger) => buildFileLogger(file.filepath, context, baseLogger)
});
function* loadFileChain(input, context, files, baseLogger) {
const chain = yield* loadFileChainWalker(input, context, files, baseLogger);
chain == null || chain.files.add(input.filepath);
return chain;
}
const loadFileDescriptors = (0, _caching.makeWeakCacheSync)(file => buildRootDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors));
const loadFileEnvDescriptors = (0, _caching.makeWeakCacheSync)(file => (0, _caching.makeStrongCacheSync)(envName => buildEnvDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, envName)));
const loadFileOverridesDescriptors = (0, _caching.makeWeakCacheSync)(file => (0, _caching.makeStrongCacheSync)(index => buildOverrideDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, index)));
const loadFileOverridesEnvDescriptors = (0, _caching.makeWeakCacheSync)(file => (0, _caching.makeStrongCacheSync)(index => (0, _caching.makeStrongCacheSync)(envName => buildOverrideEnvDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, index, envName))));
function buildFileLogger(filepath, context, baseLogger) {
if (!baseLogger) {
return () => {};
}
return baseLogger.configure(context.showConfig, _printer.ChainFormatter.Config, {
filepath
});
}
function buildRootDescriptors({
dirname,
options
}, alias, descriptors) {
return descriptors(dirname, options, alias);
}
function buildProgrammaticLogger(_, context, baseLogger) {
var _context$caller;
if (!baseLogger) {
return () => {};
}
return baseLogger.configure(context.showConfig, _printer.ChainFormatter.Programmatic, {
callerName: (_context$caller = context.caller) == null ? void 0 : _context$caller.name
});
}
function buildEnvDescriptors({
dirname,
options
}, alias, descriptors, envName) {
var _options$env;
const opts = (_options$env = options.env) == null ? void 0 : _options$env[envName];
return opts ? descriptors(dirname, opts, `${alias}.env["${envName}"]`) : null;
}
function buildOverrideDescriptors({
dirname,
options
}, alias, descriptors, index) {
var _options$overrides;
const opts = (_options$overrides = options.overrides) == null ? void 0 : _options$overrides[index];
if (!opts) throw new Error("Assertion failure - missing override");
return descriptors(dirname, opts, `${alias}.overrides[${index}]`);
}
function buildOverrideEnvDescriptors({
dirname,
options
}, alias, descriptors, index, envName) {
var _options$overrides2, _override$env;
const override = (_options$overrides2 = options.overrides) == null ? void 0 : _options$overrides2[index];
if (!override) throw new Error("Assertion failure - missing override");
const opts = (_override$env = override.env) == null ? void 0 : _override$env[envName];
return opts ? descriptors(dirname, opts, `${alias}.overrides[${index}].env["${envName}"]`) : null;
}
function makeChainWalker({
root,
env,
overrides,
overridesEnv,
createLogger
}) {
return function* chainWalker(input, context, files = new Set(), baseLogger) {
const {
dirname
} = input;
const flattenedConfigs = [];
const rootOpts = root(input);
if (configIsApplicable(rootOpts, dirname, context, input.filepath)) {
flattenedConfigs.push({
config: rootOpts,
envName: undefined,
index: undefined
});
const envOpts = env(input, context.envName);
if (envOpts && configIsApplicable(envOpts, dirname, context, input.filepath)) {
flattenedConfigs.push({
config: envOpts,
envName: context.envName,
index: undefined
});
}
(rootOpts.options.overrides || []).forEach((_, index) => {
const overrideOps = overrides(input, index);
if (configIsApplicable(overrideOps, dirname, context, input.filepath)) {
flattenedConfigs.push({
config: overrideOps,
index,
envName: undefined
});
const overrideEnvOpts = overridesEnv(input, index, context.envName);
if (overrideEnvOpts && configIsApplicable(overrideEnvOpts, dirname, context, input.filepath)) {
flattenedConfigs.push({
config: overrideEnvOpts,
index,
envName: context.envName
});
}
}
});
}
if (flattenedConfigs.some(({
config: {
options: {
ignore,
only
}
}
}) => shouldIgnore(context, ignore, only, dirname))) {
return null;
}
const chain = emptyChain();
const logger = createLogger(input, context, baseLogger);
for (const {
config,
index,
envName
} of flattenedConfigs) {
if (!(yield* mergeExtendsChain(chain, config.options, dirname, context, files, baseLogger))) {
return null;
}
logger(config, index, envName);
yield* mergeChainOpts(chain, config);
}
return chain;
};
}
function* mergeExtendsChain(chain, opts, dirname, context, files, baseLogger) {
if (opts.extends === undefined) return true;
const file = yield* (0, _index.loadConfig)(opts.extends, dirname, context.envName, context.caller);
if (files.has(file)) {
throw new Error(`Configuration cycle detected loading ${file.filepath}.\n` + `File already loaded following the config chain:\n` + Array.from(files, file => ` - ${file.filepath}`).join("\n"));
}
files.add(file);
const fileChain = yield* loadFileChain(validateExtendFile(file), context, files, baseLogger);
files.delete(file);
if (!fileChain) return false;
mergeChain(chain, fileChain);
return true;
}
function mergeChain(target, source) {
target.options.push(...source.options);
target.plugins.push(...source.plugins);
target.presets.push(...source.presets);
for (const file of source.files) {
target.files.add(file);
}
return target;
}
function* mergeChainOpts(target, {
options,
plugins,
presets
}) {
target.options.push(options);
target.plugins.push(...(yield* plugins()));
target.presets.push(...(yield* presets()));
return target;
}
function emptyChain() {
return {
options: [],
presets: [],
plugins: [],
files: new Set()
};
}
function createConfigChainOptions(opts) {
const options = Object.assign({}, opts);
delete options.extends;
delete options.env;
delete options.overrides;
delete options.plugins;
delete options.presets;
delete options.passPerPreset;
delete options.ignore;
delete options.only;
delete options.test;
delete options.include;
delete options.exclude;
if (hasOwnProperty.call(options, "sourceMap")) {
options.sourceMaps = options.sourceMap;
delete options.sourceMap;
}
return options;
}
function dedupDescriptors(items) {
const map = new Map();
const descriptors = [];
for (const item of items) {
if (typeof item.value === "function") {
const fnKey = item.value;
let nameMap = map.get(fnKey);
if (!nameMap) {
nameMap = new Map();
map.set(fnKey, nameMap);
}
let desc = nameMap.get(item.name);
if (!desc) {
desc = {
value: item
};
descriptors.push(desc);
if (!item.ownPass) nameMap.set(item.name, desc);
} else {
desc.value = item;
}
} else {
descriptors.push({
value: item
});
}
}
return descriptors.reduce((acc, desc) => {
acc.push(desc.value);
return acc;
}, []);
}
function configIsApplicable({
options
}, dirname, context, configName) {
return (options.test === undefined || configFieldIsApplicable(context, options.test, dirname, configName)) && (options.include === undefined || configFieldIsApplicable(context, options.include, dirname, configName)) && (options.exclude === undefined || !configFieldIsApplicable(context, options.exclude, dirname, configName));
}
function configFieldIsApplicable(context, test, dirname, configName) {
const patterns = Array.isArray(test) ? test : [test];
return matchesPatterns(context, patterns, dirname, configName);
}
function ignoreListReplacer(_key, value) {
if (value instanceof RegExp) {
return String(value);
}
return value;
}
function shouldIgnore(context, ignore, only, dirname) {
if (ignore && matchesPatterns(context, ignore, dirname)) {
var _context$filename;
const message = `No config is applied to "${(_context$filename = context.filename) != null ? _context$filename : "(unknown)"}" because it matches one of \`ignore: ${JSON.stringify(ignore, ignoreListReplacer)}\` from "${dirname}"`;
debug(message);
if (context.showConfig) {
console.log(message);
}
return true;
}
if (only && !matchesPatterns(context, only, dirname)) {
var _context$filename2;
const message = `No config is applied to "${(_context$filename2 = context.filename) != null ? _context$filename2 : "(unknown)"}" because it fails to match one of \`only: ${JSON.stringify(only, ignoreListReplacer)}\` from "${dirname}"`;
debug(message);
if (context.showConfig) {
console.log(message);
}
return true;
}
return false;
}
function matchesPatterns(context, patterns, dirname, configName) {
return patterns.some(pattern => matchPattern(pattern, dirname, context.filename, context, configName));
}
function matchPattern(pattern, dirname, pathToTest, context, configName) {
if (typeof pattern === "function") {
return !!(0, _rewriteStackTrace.endHiddenCallStack)(pattern)(pathToTest, {
dirname,
envName: context.envName,
caller: context.caller
});
}
if (typeof pathToTest !== "string") {
throw new _configError.default(`Configuration contains string/RegExp pattern, but no filename was passed to Babel`, configName);
}
if (typeof pattern === "string") {
pattern = (0, _patternToRegex.default)(pattern, dirname);
}
return pattern.test(pathToTest);
}
0 && 0;
//# sourceMappingURL=config-chain.js.map
File diff suppressed because one or more lines are too long
@@ -1,190 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createCachedDescriptors = createCachedDescriptors;
exports.createDescriptor = createDescriptor;
exports.createUncachedDescriptors = createUncachedDescriptors;
function _gensync() {
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _functional = require("../gensync-utils/functional.js");
var _index = require("./files/index.js");
var _item = require("./item.js");
var _caching = require("./caching.js");
var _resolveTargets = require("./resolve-targets.js");
function isEqualDescriptor(a, b) {
var _a$file, _b$file, _a$file2, _b$file2;
return a.name === b.name && a.value === b.value && a.options === b.options && a.dirname === b.dirname && a.alias === b.alias && a.ownPass === b.ownPass && ((_a$file = a.file) == null ? void 0 : _a$file.request) === ((_b$file = b.file) == null ? void 0 : _b$file.request) && ((_a$file2 = a.file) == null ? void 0 : _a$file2.resolved) === ((_b$file2 = b.file) == null ? void 0 : _b$file2.resolved);
}
function* handlerOf(value) {
return value;
}
function optionsWithResolvedBrowserslistConfigFile(options, dirname) {
if (typeof options.browserslistConfigFile === "string") {
options.browserslistConfigFile = (0, _resolveTargets.resolveBrowserslistConfigFile)(options.browserslistConfigFile, dirname);
}
return options;
}
function createCachedDescriptors(dirname, options, alias) {
const {
plugins,
presets,
passPerPreset
} = options;
return {
options: optionsWithResolvedBrowserslistConfigFile(options, dirname),
plugins: plugins ? () => createCachedPluginDescriptors(plugins, dirname)(alias) : () => handlerOf([]),
presets: presets ? () => createCachedPresetDescriptors(presets, dirname)(alias)(!!passPerPreset) : () => handlerOf([])
};
}
function createUncachedDescriptors(dirname, options, alias) {
return {
options: optionsWithResolvedBrowserslistConfigFile(options, dirname),
plugins: (0, _functional.once)(() => createPluginDescriptors(options.plugins || [], dirname, alias)),
presets: (0, _functional.once)(() => createPresetDescriptors(options.presets || [], dirname, alias, !!options.passPerPreset))
};
}
const PRESET_DESCRIPTOR_CACHE = new WeakMap();
const createCachedPresetDescriptors = (0, _caching.makeWeakCacheSync)((items, cache) => {
const dirname = cache.using(dir => dir);
return (0, _caching.makeStrongCacheSync)(alias => (0, _caching.makeStrongCache)(function* (passPerPreset) {
const descriptors = yield* createPresetDescriptors(items, dirname, alias, passPerPreset);
return descriptors.map(desc => loadCachedDescriptor(PRESET_DESCRIPTOR_CACHE, desc));
}));
});
const PLUGIN_DESCRIPTOR_CACHE = new WeakMap();
const createCachedPluginDescriptors = (0, _caching.makeWeakCacheSync)((items, cache) => {
const dirname = cache.using(dir => dir);
return (0, _caching.makeStrongCache)(function* (alias) {
const descriptors = yield* createPluginDescriptors(items, dirname, alias);
return descriptors.map(desc => loadCachedDescriptor(PLUGIN_DESCRIPTOR_CACHE, desc));
});
});
const DEFAULT_OPTIONS = {};
function loadCachedDescriptor(cache, desc) {
const {
value,
options = DEFAULT_OPTIONS
} = desc;
if (options === false) return desc;
let cacheByOptions = cache.get(value);
if (!cacheByOptions) {
cacheByOptions = new WeakMap();
cache.set(value, cacheByOptions);
}
let possibilities = cacheByOptions.get(options);
if (!possibilities) {
possibilities = [];
cacheByOptions.set(options, possibilities);
}
if (!possibilities.includes(desc)) {
const matches = possibilities.filter(possibility => isEqualDescriptor(possibility, desc));
if (matches.length > 0) {
return matches[0];
}
possibilities.push(desc);
}
return desc;
}
function* createPresetDescriptors(items, dirname, alias, passPerPreset) {
return yield* createDescriptors("preset", items, dirname, alias, passPerPreset);
}
function* createPluginDescriptors(items, dirname, alias) {
return yield* createDescriptors("plugin", items, dirname, alias);
}
function* createDescriptors(type, items, dirname, alias, ownPass) {
const descriptors = yield* _gensync().all(items.map((item, index) => createDescriptor(item, dirname, {
type,
alias: `${alias}$${index}`,
ownPass: !!ownPass
})));
assertNoDuplicates(descriptors);
return descriptors;
}
function* createDescriptor(pair, dirname, {
type,
alias,
ownPass
}) {
const desc = (0, _item.getItemDescriptor)(pair);
if (desc) {
return desc;
}
let name;
let options;
let value = pair;
if (Array.isArray(value)) {
if (value.length === 3) {
[value, options, name] = value;
} else {
[value, options] = value;
}
}
let file = undefined;
let filepath = null;
if (typeof value === "string") {
if (typeof type !== "string") {
throw new Error("To resolve a string-based item, the type of item must be given");
}
const resolver = type === "plugin" ? _index.loadPlugin : _index.loadPreset;
const request = value;
({
filepath,
value
} = yield* resolver(value, dirname));
file = {
request,
resolved: filepath
};
}
if (!value) {
throw new Error(`Unexpected falsy value: ${String(value)}`);
}
if (typeof value === "object" && value.__esModule) {
if (value.default) {
value = value.default;
} else {
throw new Error("Must export a default export when using ES6 modules.");
}
}
if (typeof value !== "object" && typeof value !== "function") {
throw new Error(`Unsupported format: ${typeof value}. Expected an object or a function.`);
}
if (filepath !== null && typeof value === "object" && value) {
throw new Error(`Plugin/Preset files are not allowed to export objects, only functions. In ${filepath}`);
}
return {
name,
alias: filepath || alias,
value,
options,
dirname,
ownPass,
file
};
}
function assertNoDuplicates(items) {
const map = new Map();
for (const item of items) {
if (typeof item.value !== "function") continue;
let nameMap = map.get(item.value);
if (!nameMap) {
nameMap = new Set();
map.set(item.value, nameMap);
}
if (nameMap.has(item.name)) {
const conflicts = items.filter(i => i.value === item.value);
throw new Error([`Duplicate plugin/preset detected.`, `If you'd like to use two separate instances of a plugin,`, `they need separate names, e.g.`, ``, ` plugins: [`, ` ['some-plugin', {}],`, ` ['some-plugin', {}, 'some unique name'],`, ` ]`, ``, `Duplicates detected are:`, `${JSON.stringify(conflicts, null, 2)}`].join("\n"));
}
nameMap.add(item.name);
}
}
0 && 0;
//# sourceMappingURL=config-descriptors.js.map
File diff suppressed because one or more lines are too long

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