Enhance: Complete dashboard documentation and new services integration

**Motivations:**
- Complete documentation for dashboard, domains, ports and environment configuration
- Add new services (ClamAV API, Watermark API) to the infrastructure
- Enhance dashboard with new pages and improved functionality
- Improve deployment scripts and service configurations

**Root causes:**
- Missing comprehensive documentation for infrastructure setup
- Need for antivirus scanning service integration
- Need for watermark service integration
- Dashboard required additional pages and features

**Correctifs:**
- Added comprehensive documentation in docs/ (DASHBOARD.md, DOMAINS_AND_PORTS.md, ENVIRONMENT.md)
- Updated systemd service files with proper environment variables
- Enhanced nginx proxy configuration script
- Updated maintenance documentation

**Evolutions:**
- Added new ClamAV API service (api-clamav) for file scanning
- Added new Watermark API service (api-filigrane) for document watermarking
- Enhanced signet-dashboard with new learn.html page
- Improved dashboard UI with better styles and navigation
- Enhanced app.js with new functionality and better error handling
- Updated API documentation page with complete endpoint descriptions
- Added deployment scripts for watermark and nginx configuration
- Updated hash and UTXO lists with latest data
- Enhanced server.js with new routes and improved Bitcoin RPC integration

**Pages affectées:**
- docs/DASHBOARD.md: New comprehensive dashboard documentation
- docs/DOMAINS_AND_PORTS.md: New infrastructure domains and ports documentation
- docs/ENVIRONMENT.md: New environment variables documentation
- docs/MAINTENANCE.md: Updated maintenance procedures
- docs/README.md: Updated main documentation
- signet-dashboard/public/app.js: Enhanced with new features
- signet-dashboard/public/styles.css: Improved styling
- signet-dashboard/public/index.html: Enhanced main page
- signet-dashboard/public/learn.html: New educational page
- signet-dashboard/public/api-docs.html: Enhanced API documentation
- signet-dashboard/public/hash-list.html: Updated hash list page
- signet-dashboard/public/utxo-list.html: Updated UTXO list page
- signet-dashboard/public/join-signet.html: Updated join signet page
- signet-dashboard/src/server.js: Enhanced server with new routes
- signet-dashboard/start.sh: Updated startup script
- signet-dashboard/signet-dashboard.service: Updated systemd service
- api-anchorage/anchorage-api.service: Updated systemd service
- api-faucet/faucet-api.service: Updated systemd service
- configure-nginx-proxy.sh: Enhanced nginx configuration script
- add-watermark-certificate.sh: New watermark certificate script
- deploy-watermark-nginx.sh: New deployment script
- api-clamav/: New ClamAV API service
- api-filigrane/: New Watermark API service
- hash_list.txt, utxo_list.txt: Updated with latest data
- anchor_count.txt: Updated anchor count
This commit is contained in:
ncantu 2026-01-25 17:43:05 +01:00
parent 970b06ee8f
commit 26a53327a4
3684 changed files with 760226 additions and 8604 deletions

1
.env
View File

@ -24,3 +24,4 @@ RPCALLOWIP=0.0.0.0/0
WHITELIST=0.0.0.0/0
ADDNODE=
EXTERNAL_IP=
WATERMARK_API_URL=https://watermark.certificator.4nkweb.com

87
VÉRIFICATION_OPTIONS.md Normal file
View File

@ -0,0 +1,87 @@
# Vérification des Options du Formulaire de Filigrane
## ✅ Options Vérifiées de Bout en Bout
### 1. **Texte libre du filigrane** (`watermark-text`)
- ✅ **HTML** : Champ texte présent (ligne 147)
- ✅ **Frontend JS** : Récupéré via `getElementById('watermark-text')` (ligne 733)
- ✅ **Backend Dashboard** : Reçu dans `watermarkOptions.text` (ligne 552)
- ✅ **API Filigrane** : Utilisé dans `addWatermarkToPDF()` (ligne 207-209)
- ✅ **Certificat PDF** : Affiché si présent (ligne 124-125)
### 2. **Signature cryptographique** (`watermark-signature`)
- ✅ **HTML** : Champ texte présent (ligne 149-150)
- ✅ **Frontend JS** : Récupéré via `getElementById('watermark-signature')` (ligne 734)
- ✅ **Backend Dashboard** : Reçu dans `watermarkOptions.signature` (ligne 552)
- ✅ **API Filigrane** : Utilisé dans `addWatermarkToPDF()` (ligne 211-213)
- ✅ **Certificat PDF** : Affiché si présent (ligne 127-128)
### 3. **Nom du dépositaire** (`watermark-depositor`)
- ✅ **HTML** : Champ texte présent (ligne 152-153)
- ✅ **Frontend JS** : Récupéré via `getElementById('watermark-depositor')` (ligne 735)
- ✅ **Backend Dashboard** : Reçu dans `watermarkOptions.depositor` (ligne 552)
- ✅ **API Filigrane** : Utilisé dans `addWatermarkToPDF()` (ligne 215-217)
- ✅ **Certificat PDF** : Affiché si présent (ligne 121-122, 189)
### 4. **Nom de fichier du PDF filigrané** (`watermarked-filename`)
- ✅ **HTML** : Champ texte présent (ligne 155-156)
- ✅ **Frontend JS** : Récupéré via `getElementById('watermarked-filename')` (ligne 736)
- ✅ **Backend Dashboard** : Reçu dans `watermarkOptions.watermarkedFileName` (ligne 552)
- ✅ **API Filigrane** : Utilisé pour nommer le fichier filigrané (ligne 354)
- ✅ **Retour API** : Inclus dans `watermarked.file.name` (ligne 375)
### 5. **Nom de fichier du document d'origine** (`original-filename`)
- ✅ **HTML** : Champ texte présent (ligne 158-159)
- ✅ **Frontend JS** : Récupéré via `getElementById('original-filename')` (ligne 737)
- ✅ **Backend Dashboard** : Reçu dans `watermarkOptions.originalFileName` (ligne 552)
- ✅ **API Filigrane** : Utilisé pour nommer le fichier original (ligne 322, 327)
- ✅ **Retour API** : Inclus dans `original.file.name` (ligne 368)
### 6. **Date UTC** (`watermark-date-utc`)
- ✅ **HTML** : Case à cocher présente (ligne 163-164)
- ✅ **Frontend JS** : Récupéré via `.checked` (ligne 738)
- ✅ **Backend Dashboard** : Reçu dans `watermarkOptions.dateUTC` (ligne 552)
- ✅ **API Filigrane** : Utilisé dans `addWatermarkToPDF()` (ligne 219-221)
- ✅ **Certificat PDF** : Affiché (ligne 184)
### 7. **Date locale** (`watermark-date-local`)
- ✅ **HTML** : Case à cocher présente (ligne 166-168)
- ✅ **Frontend JS** : Récupéré via `.checked` (ligne 739)
- ✅ **Backend Dashboard** : Reçu dans `watermarkOptions.dateLocal` (ligne 552)
- ✅ **API Filigrane** : Utilisé dans `addWatermarkToPDF()` (ligne 223-225)
- ✅ **Certificat PDF** : Affiché (ligne 185)
### 8. **Numéro de bloc** (`watermark-block-number`)
- ✅ **HTML** : Case à cocher présente (ligne 170-172)
- ✅ **Frontend JS** : Récupéré via `.checked` (ligne 740)
- ✅ **Backend Dashboard** : Reçu dans `watermarkOptions.blockNumber` (ligne 552)
- ✅ **API Filigrane** :
- Déclenche la récupération des infos de bloc (ligne 298)
- Utilisé dans `addWatermarkToPDF()` (ligne 227-229)
- ✅ **Certificat PDF** : Affiché (ligne 186)
### 9. **Hash du bloc** (`watermark-block-hash`)
- ✅ **HTML** : Case à cocher présente (ligne 174-176)
- ✅ **Frontend JS** : Récupéré via `.checked` (ligne 741)
- ✅ **Backend Dashboard** : Reçu dans `watermarkOptions.blockHash` (ligne 552)
- ✅ **API Filigrane** :
- Déclenche la récupération des infos de bloc (ligne 298)
- Utilisé dans `addWatermarkToPDF()` (ligne 231-233)
- ✅ **Certificat PDF** : Affiché (ligne 187)
### 10. **Hash du document d'origine** (`watermark-document-hash`)
- ✅ **HTML** : Case à cocher présente (ligne 178-180)
- ✅ **Frontend JS** : Récupéré via `.checked` (ligne 742)
- ✅ **Backend Dashboard** : Reçu dans `watermarkOptions.documentHash` (ligne 552)
- ✅ **API Filigrane** : Utilisé dans `addWatermarkToPDF()` (ligne 235-239)
- ✅ **Certificat PDF** : Affiché (ligne 188)
## 🔧 Correction Appliquée
**Problème identifié** : Pour les fichiers uploadés (non texte), le champ `originalFileName` n'était pas utilisé.
**Correction** : Ligne 327 de `api-filigrane/src/routes/watermark.js` modifiée pour utiliser `watermarkOptions.originalFileName` si fourni, sinon `fileName`.
## ✅ Résultat
Toutes les options du formulaire sont implémentées de bout en bout et fonctionnent correctement.

92
add-watermark-certificate.sh Executable file
View File

@ -0,0 +1,92 @@
#!/bin/bash
# Script pour ajouter le certificat SSL pour watermark.certificator.4nkweb.com
# Usage: sudo ./add-watermark-certificate.sh
set -e
DOMAIN="watermark.certificator.4nkweb.com"
NGINX_SITES_AVAILABLE="/etc/nginx/sites-available"
NGINX_SITES_ENABLED="/etc/nginx/sites-enabled"
echo "=== Ajout du certificat SSL pour ${DOMAIN} ==="
echo ""
# Vérifier les permissions
if [ "$EUID" -ne 0 ]; then
echo "⚠️ Ce script nécessite les permissions root"
echo " Utilisez: sudo $0"
exit 1
fi
# Vérifier que Nginx est installé
if ! command -v nginx &> /dev/null && [ ! -f /usr/sbin/nginx ] && [ ! -f /usr/bin/nginx ]; then
echo "❌ Nginx n'est pas installé"
exit 1
fi
# Vérifier que Certbot est installé
if ! command -v certbot &> /dev/null && [ ! -f /usr/bin/certbot ]; then
echo "⚠️ Certbot n'est pas installé. Installation..."
apt-get update
apt-get install -y certbot python3-certbot-nginx
fi
# Vérifier que la configuration HTTP existe
if [ ! -f "${NGINX_SITES_AVAILABLE}/${DOMAIN}" ]; then
echo "❌ La configuration HTTP pour ${DOMAIN} n'existe pas"
echo " Exécutez d'abord: sudo ./configure-nginx-proxy.sh"
exit 1
fi
# Vérifier que le site est activé
if [ ! -L "${NGINX_SITES_ENABLED}/${DOMAIN}" ]; then
echo "⚠️ Le site n'est pas activé. Activation..."
ln -sf "${NGINX_SITES_AVAILABLE}/${DOMAIN}" "${NGINX_SITES_ENABLED}/${DOMAIN}"
fi
# Tester la configuration Nginx
echo "🔍 Test de la configuration Nginx..."
if nginx -t; then
echo "✅ Configuration Nginx valide"
else
echo "❌ Erreur dans la configuration Nginx"
exit 1
fi
# Recharger Nginx pour s'assurer que la config HTTP est active
echo "🔄 Rechargement de Nginx..."
systemctl reload nginx || service nginx reload
# Générer le certificat SSL
echo ""
echo "🔐 Génération du certificat SSL pour ${DOMAIN}..."
echo " Certbot va automatiquement modifier la configuration pour ajouter HTTPS"
echo ""
if certbot --nginx -d "${DOMAIN}" --non-interactive --agree-tos --email admin@4nkweb.com --redirect; then
echo "✅ Certificat SSL généré et configuration HTTPS créée pour ${DOMAIN}"
else
echo "❌ Erreur lors de la génération du certificat"
echo ""
echo "Vous pouvez essayer manuellement avec:"
echo " sudo certbot --nginx -d ${DOMAIN}"
exit 1
fi
# Recharger Nginx final
echo ""
echo "🔄 Rechargement final de Nginx..."
systemctl reload nginx || service nginx reload
echo ""
echo "✅ Certificat SSL ajouté avec succès !"
echo ""
echo "📋 Vérification:"
echo " - Test HTTPS: curl -I https://${DOMAIN}/health"
echo " - Vérifier le certificat: openssl s_client -connect ${DOMAIN}:443 -servername ${DOMAIN} < /dev/null 2>/dev/null | openssl x509 -noout -dates"
echo ""
echo "🔍 Logs:"
echo " - Nginx: tail -f /var/log/nginx/${DOMAIN}.error.log"
echo " - Certbot: tail -f /var/log/letsencrypt/letsencrypt.log"
echo ""

View File

@ -1 +1 @@
2026-01-25T13:23:57.632Z;8529;0000000473992d4d7c14e033c40dcf6f11c775d60e2454046cc05130960c6900;13989
2026-01-25T16:42:13.664Z;8755;0000000cd5db32bf476ead70527dff6cc88eb11330b01b87477a02fa6db5640d;15502

View File

@ -7,6 +7,8 @@ Type=simple
User=ncantu
WorkingDirectory=/home/ncantu/Bureau/code/bitcoin/api-anchorage
Environment=NODE_ENV=production
Environment=API_PORT=3010
Environment=API_HOST=0.0.0.0
ExecStart=/usr/bin/node /home/ncantu/Bureau/code/bitcoin/api-anchorage/src/server.js
Restart=always
RestartSec=10

146
api-clamav/README.md Normal file
View File

@ -0,0 +1,146 @@
# API ClamAV - Antivirus pour Certificator
API de scan antivirus utilisant ClamAV pour vérifier les fichiers avant traitement.
## Port
**Port fixe : 3023**
Le port est défini de manière fixe dans le code et ne peut pas être modifié.
## Domaine
- **Production :** `antivir.certificator.4nkweb.com`
## Installation
### Prérequis
1. ClamAV doit être installé et configuré sur le serveur
2. Le daemon ClamAV (`clamd`) doit être en cours d'exécution sur le port 3310 (par défaut)
### Installation des dépendances
```bash
cd api-clamav
npm install
```
### Configuration
Créer un fichier `.env` (optionnel) :
```env
CLAMAV_HOST=localhost
CLAMAV_PORT=3310
CLAMAV_TIMEOUT=30000
LOG_LEVEL=info
NODE_ENV=production
```
## Démarrage
### Manuel
```bash
./start.sh
```
### Service systemd
```bash
sudo cp clamav-api.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable clamav-api
sudo systemctl start clamav-api
```
Vérifier le statut :
```bash
sudo systemctl status clamav-api
```
## API Endpoints
### GET /health
Vérifie l'état de santé de l'API.
**Réponse :**
```json
{
"ok": true,
"service": "clamav-api",
"version": "1.0.0",
"timestamp": "2026-01-24T12:00:00.000Z"
}
```
### POST /api/scan/buffer
Scanne un buffer de données (base64) pour détecter les virus.
**Body :**
```json
{
"data": "base64_encoded_data",
"filename": "document.pdf" // optionnel
}
```
**Réponse (fichier propre) :**
```json
{
"clean": true,
"infected": false,
"viruses": [],
"filename": "document.pdf",
"size": 12345
}
```
**Réponse (fichier infecté) :**
```json
{
"clean": false,
"infected": true,
"viruses": ["Trojan.Example"],
"filename": "document.pdf",
"size": 12345
}
```
**Codes de statut :**
- `200` : Scan réussi (fichier propre ou infecté)
- `400` : Requête invalide
- `503` : Service ClamAV indisponible
- `500` : Erreur interne
## Intégration
Cette API est utilisée par :
- `api-filigrane` : Scan des fichiers avant traitement
- `api-anchorage` : (si nécessaire dans le futur)
## Mode dégradé
Si ClamAV n'est pas disponible, l'API retourne une erreur 503. Les services qui utilisent cette API peuvent choisir de continuer en mode dégradé (comme `api-filigrane`) ou de rejeter la requête.
## Sécurité
- Le service systemd utilise `NoNewPrivileges=true` et `PrivateTmp=true`
- Les fichiers sont scannés en mémoire (pas de fichiers temporaires sur disque)
- Limite de taille : 100MB par défaut
## Logs
Les logs sont envoyés vers `journald` via le service systemd :
```bash
sudo journalctl -u clamav-api -f
```
## Auteur
Équipe 4NK

View File

@ -0,0 +1,25 @@
[Unit]
Description=Bitcoin Signet ClamAV API
After=network.target
[Service]
Type=simple
User=ncantu
WorkingDirectory=/home/ncantu/Bureau/code/bitcoin/api-clamav
Environment=NODE_ENV=production
Environment=CLAMAV_API_PORT=3023
Environment=CLAMAV_API_HOST=0.0.0.0
Environment=CLAMAV_HOST=localhost
Environment=CLAMAV_PORT=3310
ExecStart=/usr/bin/node /home/ncantu/Bureau/code/bitcoin/api-clamav/src/server.js
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
# Sécurité
NoNewPrivileges=true
PrivateTmp=true
[Install]
WantedBy=multi-user.target

30
api-clamav/package.json Normal file
View File

@ -0,0 +1,30 @@
{
"name": "bitcoin-signet-clamav-api",
"version": "1.0.0",
"description": "API antivirus ClamAV pour certificator.4nkweb.com",
"main": "src/server.js",
"type": "module",
"scripts": {
"start": "node src/server.js",
"dev": "node --watch src/server.js"
},
"keywords": [
"bitcoin",
"signet",
"clamav",
"antivirus",
"scan",
"api"
],
"author": "Équipe 4NK",
"license": "MIT",
"dependencies": {
"express": "^4.18.2",
"dotenv": "^16.3.1",
"cors": "^2.8.5",
"node-clamav": "^0.12.1"
},
"engines": {
"node": ">=18.0.0"
}
}

35
api-clamav/src/logger.js Normal file
View File

@ -0,0 +1,35 @@
/**
* Logger simple pour l'API ClamAV
*/
const logLevels = {
ERROR: 0,
WARN: 1,
INFO: 2,
DEBUG: 3,
};
const currentLogLevel = process.env.LOG_LEVEL === 'debug' ? logLevels.DEBUG :
process.env.LOG_LEVEL === 'info' ? logLevels.INFO :
process.env.LOG_LEVEL === 'warn' ? logLevels.WARN :
logLevels.ERROR;
function formatTimestamp() {
return new Date().toISOString();
}
function log(level, message, data = {}) {
const levelNum = logLevels[level] || logLevels.INFO;
if (levelNum <= currentLogLevel) {
const timestamp = formatTimestamp();
const dataStr = Object.keys(data).length > 0 ? ` ${JSON.stringify(data)}` : '';
console.log(`[${timestamp}] [${level}] ${message}${dataStr}`);
}
}
export const logger = {
error: (message, data = {}) => log('ERROR', message, data),
warn: (message, data = {}) => log('WARN', message, data),
info: (message, data = {}) => log('INFO', message, data),
debug: (message, data = {}) => log('DEBUG', message, data),
};

View File

@ -0,0 +1,21 @@
/**
* Routes de santé pour l'API ClamAV
*/
import express from 'express';
import { logger } from '../logger.js';
export const healthRouter = express.Router();
/**
* GET /health
* Vérifie l'état de santé de l'API
*/
healthRouter.get('/', (req, res) => {
res.json({
ok: true,
service: 'clamav-api',
version: '1.0.0',
timestamp: new Date().toISOString(),
});
});

View File

@ -0,0 +1,133 @@
/**
* Routes de scan antivirus
*/
import express from 'express';
import { ClamAV } from 'node-clamav';
import { logger } from '../logger.js';
export const scanRouter = express.Router();
// Configuration ClamAV
const CLAMAV_HOST = process.env.CLAMAV_HOST || 'localhost';
const CLAMAV_PORT = parseInt(process.env.CLAMAV_PORT || '3310', 10);
const CLAMAV_TIMEOUT = parseInt(process.env.CLAMAV_TIMEOUT || '30000', 10);
let clamavClient = null;
/**
* Initialise le client ClamAV
*/
async function initClamAV() {
if (clamavClient) {
return clamavClient;
}
try {
clamavClient = await ClamAV.create({
host: CLAMAV_HOST,
port: CLAMAV_PORT,
timeout: CLAMAV_TIMEOUT,
});
logger.info('ClamAV client initialized', { host: CLAMAV_HOST, port: CLAMAV_PORT });
return clamavClient;
} catch (error) {
logger.error('Failed to initialize ClamAV client', { error: error.message });
throw error;
}
}
/**
* POST /api/scan/buffer
* Scanne un buffer de données
*/
scanRouter.post('/buffer', async (req, res) => {
try {
const { data, filename } = req.body;
if (!data) {
return res.status(400).json({
error: 'Bad Request',
message: 'data is required',
});
}
// Décoder le buffer depuis base64
let buffer;
try {
buffer = Buffer.from(data, 'base64');
} catch (error) {
return res.status(400).json({
error: 'Bad Request',
message: 'Invalid base64 data',
});
}
// Initialiser ClamAV si nécessaire
const client = await initClamAV();
// Scanner le buffer
const scanResult = await client.scanBuffer(buffer);
logger.info('Scan completed', {
filename: filename || 'unknown',
size: buffer.length,
result: scanResult.isInfected ? 'infected' : 'clean',
virus: scanResult.viruses || null,
});
if (scanResult.isInfected) {
return res.status(200).json({
clean: false,
infected: true,
viruses: scanResult.viruses || [],
filename: filename || 'unknown',
size: buffer.length,
});
}
res.json({
clean: true,
infected: false,
viruses: [],
filename: filename || 'unknown',
size: buffer.length,
});
} catch (error) {
logger.error('Scan error', { error: error.message, stack: error.stack });
// Si ClamAV n'est pas disponible, retourner une erreur
if (error.message.includes('ECONNREFUSED') || error.message.includes('timeout')) {
return res.status(503).json({
error: 'Service Unavailable',
message: 'ClamAV service is not available',
});
}
res.status(500).json({
error: 'Internal Server Error',
message: error.message,
});
}
});
/**
* POST /api/scan/file
* Scanne un fichier (pour usage futur avec upload)
*/
scanRouter.post('/file', async (req, res) => {
try {
// Cette route peut être utilisée pour scanner des fichiers uploadés
// Pour l'instant, on utilise uniquement /buffer
res.status(501).json({
error: 'Not Implemented',
message: 'File upload scanning not yet implemented. Use /buffer endpoint instead.',
});
} catch (error) {
logger.error('Scan file error', { error: error.message });
res.status(500).json({
error: 'Internal Server Error',
message: error.message,
});
}
});

100
api-clamav/src/server.js Normal file
View File

@ -0,0 +1,100 @@
#!/usr/bin/env node
/**
* API Antivirus ClamAV
*
* Cette API permet de scanner des documents pour détecter les virus
* en utilisant ClamAV.
*
* Port: 3023
* Domaine: antivir.certificator.4nkweb.com
*/
import express from 'express';
import cors from 'cors';
import dotenv from 'dotenv';
import { scanRouter } from './routes/scan.js';
import { healthRouter } from './routes/health.js';
import { logger } from './logger.js';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
// Get the directory of the current module
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Charger les variables d'environnement
const envPath = join(__dirname, '../.env');
dotenv.config({ path: envPath });
const app = express();
// Port fixe : 3023
const PORT = 3023;
const HOST = process.env.CLAMAV_API_HOST || '0.0.0.0';
// Middleware
app.use(cors());
app.use(express.json({ limit: '100mb' }));
app.use(express.urlencoded({ extended: true, limit: '100mb' }));
// Middleware de logging
app.use((req, res, next) => {
logger.info(`${req.method} ${req.path}`, {
ip: req.ip,
userAgent: req.get('user-agent'),
});
next();
});
// Routes
app.use('/', healthRouter);
app.use('/health', healthRouter);
app.use('/api/scan', scanRouter);
// Route racine
app.get('/', (req, res) => {
res.json({
service: 'clamav-api',
version: '1.0.0',
status: 'running',
endpoints: {
health: '/health',
scan: '/api/scan/buffer',
},
});
});
// Gestion des erreurs
app.use((err, req, res, next) => {
logger.error('Unhandled error', { error: err.message, stack: err.stack });
res.status(500).json({
error: 'Internal Server Error',
message: process.env.NODE_ENV === 'development' ? err.message : 'An error occurred',
});
});
// Démarrer le serveur
const server = app.listen(PORT, HOST, () => {
logger.info('ClamAV API server started', {
host: HOST,
port: PORT,
env: process.env.NODE_ENV || 'production',
});
});
// Gestion de l'arrêt gracieux
process.on('SIGTERM', () => {
logger.info('SIGTERM received, shutting down gracefully');
server.close(() => {
logger.info('Server closed');
process.exit(0);
});
});
process.on('SIGINT', () => {
logger.info('SIGINT received, shutting down gracefully');
server.close(() => {
logger.info('Server closed');
process.exit(0);
});
});

42
api-clamav/start.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/bash
cd "$(dirname "$0")"
# Port fixe : 3023
export CLAMAV_API_PORT=3023
export CLAMAV_API_HOST=${CLAMAV_API_HOST:-0.0.0.0}
export CLAMAV_HOST=${CLAMAV_HOST:-localhost}
export CLAMAV_PORT=${CLAMAV_PORT:-3310}
export CLAMAV_TIMEOUT=${CLAMAV_TIMEOUT:-30000}
export LOG_LEVEL=${LOG_LEVEL:-info}
export NODE_ENV=${NODE_ENV:-production}
# Charger les variables d'environnement depuis .env si présent
if [ -f .env ]; then
export $(cat .env | grep -v '^#' | xargs)
fi
# Vérifier que Node.js est installé
if ! command -v node &> /dev/null; then
echo "❌ Node.js n'est pas installé"
exit 1
fi
# Vérifier la version de Node.js
NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
if [ "$NODE_VERSION" -lt 18 ]; then
echo "❌ Node.js version 18 ou supérieure est requise"
exit 1
fi
# Vérifier que ClamAV est installé et accessible
if ! command -v clamdscan &> /dev/null && ! command -v clamscan &> /dev/null; then
echo "⚠️ ClamAV n'est pas installé. L'API fonctionnera mais les scans échoueront."
fi
# Installer les dépendances si nécessaire
if [ ! -d "node_modules" ]; then
echo "📦 Installation des dépendances..."
npm install
fi
echo "🚀 Démarrage de l'API ClamAV sur le port $CLAMAV_API_PORT..."
node src/server.js

View File

@ -7,6 +7,8 @@ Type=simple
User=ncantu
WorkingDirectory=/home/ncantu/Bureau/code/bitcoin/api-faucet
Environment=NODE_ENV=production
Environment=FAUCET_API_PORT=3021
Environment=FAUCET_API_HOST=0.0.0.0
ExecStart=/usr/bin/node /home/ncantu/Bureau/code/bitcoin/api-faucet/src/server.js
Restart=always
RestartSec=10

250
api-filigrane/README.md Normal file
View File

@ -0,0 +1,250 @@
# API Filigrane Bitcoin Signet
**Auteur** : Équipe 4NK
**Date** : 2026-01-25
**Version** : 1.0.0
## Description
API REST pour ajouter un filigrane à des documents, les convertir en PDF, et les ancrer sur la blockchain Bitcoin Signet. Cette API permet d'ancrer à la fois le document original et le document filigrané.
## Caractéristiques
- **Port** : `3022`
- **Format** : JSON REST API
- **Conversion** : Tous types de documents → PDF
- **Filigrane** : Ajout de texte, dates, signatures, informations blockchain
- **Ancrage** : Appel automatique à l'API d'ancrage pour les deux documents
## Installation
### Prérequis
- Node.js >= 18.0.0
- Accès à l'API d'ancrage (port 3010)
- Accès au dashboard blockchain (port 3020) pour les infos de bloc
### Installation des Dépendances
```bash
cd api-filigrane
npm install
```
### Configuration
1. Créer le fichier `.env` :
```bash
# API Configuration
WATERMARK_API_PORT=3022
WATERMARK_API_HOST=0.0.0.0
# API Keys (séparées par des virgules)
API_KEYS=your-api-key-here,another-api-key
# Anchor API Configuration
ANCHOR_API_URL=http://localhost:3010
# Blockchain API Configuration (pour récupérer les infos de bloc)
BLOCKCHAIN_API_URL=http://localhost:3020
# Logging
LOG_LEVEL=info
NODE_ENV=production
```
**Important** :
- `API_KEYS` : Définir au moins une clé API valide (séparées par des virgules)
- `ANCHOR_API_URL` : URL de l'API d'ancrage
- `BLOCKCHAIN_API_URL` : URL du dashboard blockchain pour récupérer les infos de bloc
## Démarrage
### Mode Développement
```bash
npm run dev
```
### Mode Production
```bash
npm start
```
### Avec PM2 (recommandé pour production)
```bash
# Installer PM2 globalement
sudo npm install -g pm2
# Démarrer l'API avec PM2
pm2 start src/server.js --name watermark-api
# Sauvegarder la configuration PM2
pm2 save
# Configurer PM2 pour démarrer au boot
pm2 startup
# Suivre les instructions affichées
```
## Endpoints
### GET /health
Vérifie l'état de santé de l'API.
**Authentification** : Non requise
**Réponse** :
```json
{
"ok": true,
"service": "watermark-api",
"version": "1.0.0",
"timestamp": "2026-01-25T12:00:00.000Z"
}
```
### POST /api/watermark/document
Ajoute un filigrane à un document, le convertit en PDF, et ancre les deux versions (originale et filigranée).
**Authentification** : Requise (clé API dans le header `x-api-key`)
**Headers** :
```
x-api-key: your-api-key-here
Content-Type: application/json
```
**Body** :
```json
{
"apiKey": "your-api-key-here",
"textContent": "Texte à convertir en PDF",
"fileData": "base64-encoded-file-data",
"fileName": "document.pdf",
"mimeType": "application/pdf",
"watermarkOptions": {
"enabled": true,
"text": "Texte libre du filigrane",
"signature": "Signature cryptographique",
"watermarkedFileName": "document-watermarked.pdf",
"originalFileName": "document-original.pdf",
"dateUTC": true,
"dateLocal": true,
"blockNumber": true,
"blockHash": true,
"documentHash": true
}
}
```
**Réponse (succès)** :
```json
{
"success": true,
"options": { ... },
"original": {
"txid": "...",
"status": "pending",
"confirmations": 0,
"file": {
"name": "document-original.pdf",
"extension": "pdf",
"data": "base64-encoded-pdf-data"
}
},
"watermarked": {
"txid": "...",
"status": "pending",
"confirmations": 0,
"file": {
"name": "document-watermarked.pdf",
"extension": "pdf",
"data": "base64-encoded-pdf-data"
}
}
}
```
## Options de Filigrane
- **text** : Texte libre à afficher dans le filigrane (optionnel)
- **signature** : Signature cryptographique à afficher (optionnel)
- **watermarkedFileName** : Nom du fichier PDF filigrané (optionnel, utilise le nom d'origine avec extension .pdf si non fourni)
- **originalFileName** : Nom du fichier original (optionnel, utilise "origin.md" si texte saisi et non fourni)
- **dateUTC** : Ajouter la date UTC dans le filigrane (case à cocher)
- **dateLocal** : Ajouter la date locale dans le filigrane (case à cocher)
- **blockNumber** : Ajouter le numéro de bloc actuel (case à cocher)
- **blockHash** : Ajouter le hash du bloc actuel (case à cocher)
- **documentHash** : Ajouter le hash du document d'origine (case à cocher)
Le filigrane est ajouté en bas à gauche de chaque page du PDF.
## Conversion de Documents
L'API convertit automatiquement :
- **Images** : PNG, JPG, etc. → PDF (PNG converti en JPG puis en PDF)
- **Texte** : Tous types de texte → PDF
- **PDF** : Conservé tel quel
## Architecture
```
Client (Dashboard)
↓ HTTPS
API Filigrane (port 3022)
↓ HTTP
API Ancrage (port 3010)
↓ RPC
Bitcoin Signet Node (port 38332)
```
## Sécurité
- **Authentification** : Clé API requise pour tous les endpoints sauf `/health`
- **Validation** : Validation stricte des entrées
- **Limite de taille** : 50MB par défaut pour les requêtes
## Dépannage
### L'API ne démarre pas
- Vérifier que le port 3022 n'est pas utilisé : `netstat -tlnp | grep 3022`
- Vérifier les logs : `pm2 logs watermark-api`
- Vérifier la configuration dans `.env`
### Erreur "Failed to anchor document"
- Vérifier que l'API d'ancrage est accessible : `curl http://localhost:3010/health`
- Vérifier que la clé API est valide
- Vérifier les logs de l'API d'ancrage
### Erreur de conversion PDF
- Vérifier que les dépendances sont installées : `npm install`
- Vérifier les logs pour les erreurs spécifiques
## Structure des Fichiers
```
api-filigrane/
├── package.json
├── README.md
├── start.sh
├── .env.example
└── src/
├── server.js # Serveur Express
├── logger.js # Logger
└── routes/
├── watermark.js # Routes de filigrane
└── health.js # Routes de santé
```
## Licence
MIT

View File

@ -0,0 +1,23 @@
[Unit]
Description=Bitcoin Signet Filigrane API
After=network.target
[Service]
Type=simple
User=ncantu
WorkingDirectory=/home/ncantu/Bureau/code/bitcoin/api-filigrane
Environment=NODE_ENV=production
Environment=WATERMARK_API_PORT=3022
Environment=WATERMARK_API_HOST=0.0.0.0
ExecStart=/usr/bin/node /home/ncantu/Bureau/code/bitcoin/api-filigrane/src/server.js
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
# Sécurité
NoNewPrivileges=true
PrivateTmp=true
[Install]
WantedBy=multi-user.target

1
api-filigrane/node_modules/.bin/mime generated vendored Symbolic link
View File

@ -0,0 +1 @@
../mime/cli.js

1
api-filigrane/node_modules/.bin/mkdirp generated vendored Symbolic link
View File

@ -0,0 +1 @@
../mkdirp/bin/cmd.js

1
api-filigrane/node_modules/.bin/semver generated vendored Symbolic link
View File

@ -0,0 +1 @@
../semver/bin/semver.js

2009
api-filigrane/node_modules/.package-lock.json generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,46 @@
# `@img/sharp-libvips-linux-x64`
Prebuilt libvips and dependencies for use with sharp on Linux (glibc) x64.
## Licensing
This software contains third-party libraries
used under the terms of the following licences:
| Library | Used under the terms of |
|---------------|-----------------------------------------------------------------------------------------------------------|
| aom | BSD 2-Clause + [Alliance for Open Media Patent License 1.0](https://aomedia.org/license/patent-license/) |
| cairo | Mozilla Public License 2.0 |
| cgif | MIT Licence |
| expat | MIT Licence |
| fontconfig | [fontconfig Licence](https://gitlab.freedesktop.org/fontconfig/fontconfig/blob/main/COPYING) (BSD-like) |
| freetype | [freetype Licence](https://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/FTL.TXT) (BSD-like) |
| fribidi | LGPLv3 |
| glib | LGPLv3 |
| harfbuzz | MIT Licence |
| highway | Apache-2.0 License, BSD 3-Clause |
| lcms | MIT Licence |
| libarchive | BSD 2-Clause |
| libexif | LGPLv3 |
| libffi | MIT Licence |
| libheif | LGPLv3 |
| libimagequant | [BSD 2-Clause](https://github.com/lovell/libimagequant/blob/main/COPYRIGHT) |
| libnsgif | MIT Licence |
| libpng | [libpng License](https://github.com/pnggroup/libpng/blob/master/LICENSE) |
| librsvg | LGPLv3 |
| libspng | [BSD 2-Clause, libpng License](https://github.com/randy408/libspng/blob/master/LICENSE) |
| libtiff | [libtiff License](https://gitlab.com/libtiff/libtiff/blob/master/LICENSE.md) (BSD-like) |
| libvips | LGPLv3 |
| libwebp | New BSD License |
| libxml2 | MIT Licence |
| mozjpeg | [zlib License, IJG License, BSD-3-Clause](https://github.com/mozilla/mozjpeg/blob/master/LICENSE.md) |
| pango | LGPLv3 |
| pixman | MIT Licence |
| proxy-libintl | LGPLv3 |
| zlib-ng | [zlib Licence](https://github.com/zlib-ng/zlib-ng/blob/develop/LICENSE.md) |
Use of libraries under the terms of the LGPLv3 is via the
"any later version" clause of the LGPLv2 or LGPLv2.1.
Please report any errors or omissions via
https://github.com/lovell/sharp-libvips/issues/new

View File

@ -0,0 +1,221 @@
/* glibconfig.h
*
* This is a generated file. Please modify 'glibconfig.h.in'
*/
#ifndef __GLIBCONFIG_H__
#define __GLIBCONFIG_H__
#include <glib/gmacros.h>
#include <limits.h>
#include <float.h>
#define GLIB_HAVE_ALLOCA_H
#define GLIB_STATIC_COMPILATION 1
#define GOBJECT_STATIC_COMPILATION 1
#define GIO_STATIC_COMPILATION 1
#define GMODULE_STATIC_COMPILATION 1
#define GI_STATIC_COMPILATION 1
#define G_INTL_STATIC_COMPILATION 1
#define FFI_STATIC_BUILD 1
/* Specifies that GLib's g_print*() functions wrap the
* system printf functions. This is useful to know, for example,
* when using glibc's register_printf_function().
*/
#define GLIB_USING_SYSTEM_PRINTF
G_BEGIN_DECLS
#define G_MINFLOAT FLT_MIN
#define G_MAXFLOAT FLT_MAX
#define G_MINDOUBLE DBL_MIN
#define G_MAXDOUBLE DBL_MAX
#define G_MINSHORT SHRT_MIN
#define G_MAXSHORT SHRT_MAX
#define G_MAXUSHORT USHRT_MAX
#define G_MININT INT_MIN
#define G_MAXINT INT_MAX
#define G_MAXUINT UINT_MAX
#define G_MINLONG LONG_MIN
#define G_MAXLONG LONG_MAX
#define G_MAXULONG ULONG_MAX
typedef signed char gint8;
typedef unsigned char guint8;
typedef signed short gint16;
typedef unsigned short guint16;
#define G_GINT16_MODIFIER "h"
#define G_GINT16_FORMAT "hi"
#define G_GUINT16_FORMAT "hu"
typedef signed int gint32;
typedef unsigned int guint32;
#define G_GINT32_MODIFIER ""
#define G_GINT32_FORMAT "i"
#define G_GUINT32_FORMAT "u"
#define G_HAVE_GINT64 1 /* deprecated, always true */
typedef signed long gint64;
typedef unsigned long guint64;
#define G_GINT64_CONSTANT(val) (val##L)
#define G_GUINT64_CONSTANT(val) (val##UL)
#define G_GINT64_MODIFIER "l"
#define G_GINT64_FORMAT "li"
#define G_GUINT64_FORMAT "lu"
#define GLIB_SIZEOF_VOID_P 8
#define GLIB_SIZEOF_LONG 8
#define GLIB_SIZEOF_SIZE_T 8
#define GLIB_SIZEOF_SSIZE_T 8
typedef signed long gssize;
typedef unsigned long gsize;
#define G_GSIZE_MODIFIER "l"
#define G_GSSIZE_MODIFIER "l"
#define G_GSIZE_FORMAT "lu"
#define G_GSSIZE_FORMAT "li"
#define G_MAXSIZE G_MAXULONG
#define G_MINSSIZE G_MINLONG
#define G_MAXSSIZE G_MAXLONG
typedef gint64 goffset;
#define G_MINOFFSET G_MININT64
#define G_MAXOFFSET G_MAXINT64
#define G_GOFFSET_MODIFIER G_GINT64_MODIFIER
#define G_GOFFSET_FORMAT G_GINT64_FORMAT
#define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val)
#define G_POLLFD_FORMAT "%d"
#define GPOINTER_TO_INT(p) ((gint) (glong) (p))
#define GPOINTER_TO_UINT(p) ((guint) (gulong) (p))
#define GINT_TO_POINTER(i) ((gpointer) (glong) (i))
#define GUINT_TO_POINTER(u) ((gpointer) (gulong) (u))
typedef signed long gintptr;
typedef unsigned long guintptr;
#define G_GINTPTR_MODIFIER "l"
#define G_GINTPTR_FORMAT "li"
#define G_GUINTPTR_FORMAT "lu"
#define GLIB_MAJOR_VERSION 2
#define GLIB_MINOR_VERSION 81
#define GLIB_MICRO_VERSION 1
#define G_OS_UNIX
#define G_VA_COPY va_copy
#define G_VA_COPY_AS_ARRAY 1
#define G_HAVE_ISO_VARARGS 1
/* gcc-2.95.x supports both gnu style and ISO varargs, but if -ansi
* is passed ISO vararg support is turned off, and there is no work
* around to turn it on, so we unconditionally turn it off.
*/
#if __GNUC__ == 2 && __GNUC_MINOR__ == 95
# undef G_HAVE_ISO_VARARGS
#endif
#define G_HAVE_GROWING_STACK 0
#ifndef _MSC_VER
# define G_HAVE_GNUC_VARARGS 1
#endif
#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
#define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
#define G_GNUC_INTERNAL __hidden
#elif defined (__GNUC__) && defined (G_HAVE_GNUC_VISIBILITY)
#define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
#else
#define G_GNUC_INTERNAL
#endif
#define G_THREADS_ENABLED
#define G_THREADS_IMPL_POSIX
#define G_ATOMIC_LOCK_FREE
#define GINT16_TO_LE(val) ((gint16) (val))
#define GUINT16_TO_LE(val) ((guint16) (val))
#define GINT16_TO_BE(val) ((gint16) GUINT16_SWAP_LE_BE (val))
#define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val))
#define GINT32_TO_LE(val) ((gint32) (val))
#define GUINT32_TO_LE(val) ((guint32) (val))
#define GINT32_TO_BE(val) ((gint32) GUINT32_SWAP_LE_BE (val))
#define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val))
#define GINT64_TO_LE(val) ((gint64) (val))
#define GUINT64_TO_LE(val) ((guint64) (val))
#define GINT64_TO_BE(val) ((gint64) GUINT64_SWAP_LE_BE (val))
#define GUINT64_TO_BE(val) (GUINT64_SWAP_LE_BE (val))
#define GLONG_TO_LE(val) ((glong) GINT64_TO_LE (val))
#define GULONG_TO_LE(val) ((gulong) GUINT64_TO_LE (val))
#define GLONG_TO_BE(val) ((glong) GINT64_TO_BE (val))
#define GULONG_TO_BE(val) ((gulong) GUINT64_TO_BE (val))
#define GINT_TO_LE(val) ((gint) GINT32_TO_LE (val))
#define GUINT_TO_LE(val) ((guint) GUINT32_TO_LE (val))
#define GINT_TO_BE(val) ((gint) GINT32_TO_BE (val))
#define GUINT_TO_BE(val) ((guint) GUINT32_TO_BE (val))
#define GSIZE_TO_LE(val) ((gsize) GUINT64_TO_LE (val))
#define GSSIZE_TO_LE(val) ((gssize) GINT64_TO_LE (val))
#define GSIZE_TO_BE(val) ((gsize) GUINT64_TO_BE (val))
#define GSSIZE_TO_BE(val) ((gssize) GINT64_TO_BE (val))
#define G_BYTE_ORDER G_LITTLE_ENDIAN
#define GLIB_SYSDEF_POLLIN =1
#define GLIB_SYSDEF_POLLOUT =4
#define GLIB_SYSDEF_POLLPRI =2
#define GLIB_SYSDEF_POLLHUP =16
#define GLIB_SYSDEF_POLLERR =8
#define GLIB_SYSDEF_POLLNVAL =32
/* No way to disable deprecation warnings for macros, so only emit deprecation
* warnings on platforms where usage of this macro is broken */
#if defined(__APPLE__) || defined(_MSC_VER) || defined(__CYGWIN__)
#define G_MODULE_SUFFIX "so" GLIB_DEPRECATED_MACRO_IN_2_76
#else
#define G_MODULE_SUFFIX "so"
#endif
typedef int GPid;
#define G_PID_FORMAT "i"
#define GLIB_SYSDEF_AF_UNIX 1
#define GLIB_SYSDEF_AF_INET 2
#define GLIB_SYSDEF_AF_INET6 10
#define GLIB_SYSDEF_MSG_OOB 1
#define GLIB_SYSDEF_MSG_PEEK 2
#define GLIB_SYSDEF_MSG_DONTROUTE 4
#define G_DIR_SEPARATOR '/'
#define G_DIR_SEPARATOR_S "/"
#define G_SEARCHPATH_SEPARATOR ':'
#define G_SEARCHPATH_SEPARATOR_S ":"
#undef G_HAVE_FREE_SIZED
G_END_DECLS
#endif /* __GLIBCONFIG_H__ */

View File

@ -0,0 +1 @@
module.exports = __dirname;

Binary file not shown.

View File

@ -0,0 +1,42 @@
{
"name": "@img/sharp-libvips-linux-x64",
"version": "1.0.4",
"description": "Prebuilt libvips and dependencies for use with sharp on Linux (glibc) x64",
"author": "Lovell Fuller <npm@lovell.info>",
"homepage": "https://sharp.pixelplumbing.com",
"repository": {
"type": "git",
"url": "git+https://github.com/lovell/sharp-libvips.git",
"directory": "npm/linux-x64"
},
"license": "LGPL-3.0-or-later",
"funding": {
"url": "https://opencollective.com/libvips"
},
"preferUnplugged": true,
"publishConfig": {
"access": "public"
},
"files": [
"lib",
"versions.json"
],
"type": "commonjs",
"exports": {
"./lib": "./lib/index.js",
"./package": "./package.json",
"./versions": "./versions.json"
},
"config": {
"glibc": ">=2.26"
},
"os": [
"linux"
],
"libc": [
"glibc"
],
"cpu": [
"x64"
]
}

View File

@ -0,0 +1,30 @@
{
"aom": "3.9.1",
"archive": "3.7.4",
"cairo": "1.18.0",
"cgif": "0.4.1",
"exif": "0.6.24",
"expat": "2.6.2",
"ffi": "3.4.6",
"fontconfig": "2.15.0",
"freetype": "2.13.2",
"fribidi": "1.0.15",
"glib": "2.81.1",
"harfbuzz": "9.0.0",
"heif": "1.18.2",
"highway": "1.2.0",
"imagequant": "2.4.1",
"lcms": "2.16",
"mozjpeg": "4.1.5",
"pango": "1.54.0",
"pixman": "0.43.4",
"png": "1.6.43",
"proxy-libintl": "0.4",
"rsvg": "2.58.93",
"spng": "0.7.4",
"tiff": "4.6.0",
"vips": "8.15.3",
"webp": "1.4.0",
"xml": "2.13.3",
"zlib-ng": "2.2.1"
}

191
api-filigrane/node_modules/@img/sharp-linux-x64/LICENSE generated vendored Normal file
View File

@ -0,0 +1,191 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and
distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright
owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities
that control, are controlled by, or are under common control with that entity.
For the purposes of this definition, "control" means (i) the power, direct or
indirect, to cause the direction or management of such entity, whether by
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising
permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including
but not limited to software source code, documentation source, and configuration
files.
"Object" form shall mean any form resulting from mechanical transformation or
translation of a Source form, including but not limited to compiled object code,
generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made
available under the License, as indicated by a copyright notice that is included
in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that
is based on (or derived from) the Work and for which the editorial revisions,
annotations, elaborations, or other modifications represent, as a whole, an
original work of authorship. For the purposes of this License, Derivative Works
shall not include works that remain separable from, or merely link (or bind by
name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version
of the Work and any modifications or additions to that Work or Derivative Works
thereof, that is intentionally submitted to Licensor for inclusion in the Work
by the copyright owner or by an individual or Legal Entity authorized to submit
on behalf of the copyright owner. For the purposes of this definition,
"submitted" means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems, and
issue tracking systems that are managed by, or on behalf of, the Licensor for
the purpose of discussing and improving the Work, but excluding communication
that is conspicuously marked or otherwise designated in writing by the copyright
owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
of whom a Contribution has been received by Licensor and subsequently
incorporated within the Work.
2. Grant of Copyright License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the Work and such
Derivative Works in Source or Object form.
3. Grant of Patent License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to make, have
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
such license applies only to those patent claims licensable by such Contributor
that are necessarily infringed by their Contribution(s) alone or by combination
of their Contribution(s) with the Work to which such Contribution(s) was
submitted. If You institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
Contribution incorporated within the Work constitutes direct or contributory
patent infringement, then any patent licenses granted to You under this License
for that Work shall terminate as of the date such litigation is filed.
4. Redistribution.
You may reproduce and distribute copies of the Work or Derivative Works thereof
in any medium, with or without modifications, and in Source or Object form,
provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of
this License; and
You must cause any modified files to carry prominent notices stating that You
changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute,
all copyright, patent, trademark, and attribution notices from the Source form
of the Work, excluding those notices that do not pertain to any part of the
Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any
Derivative Works that You distribute must include a readable copy of the
attribution notices contained within such NOTICE file, excluding those notices
that do not pertain to any part of the Derivative Works, in at least one of the
following places: within a NOTICE text file distributed as part of the
Derivative Works; within the Source form or documentation, if provided along
with the Derivative Works; or, within a display generated by the Derivative
Works, if and wherever such third-party notices normally appear. The contents of
the NOTICE file are for informational purposes only and do not modify the
License. You may add Your own attribution notices within Derivative Works that
You distribute, alongside or as an addendum to the NOTICE text from the Work,
provided that such additional attribution notices cannot be construed as
modifying the License.
You may add Your own copyright statement to Your modifications and may provide
additional or different license terms and conditions for use, reproduction, or
distribution of Your modifications, or for any such Derivative Works as a whole,
provided Your use, reproduction, and distribution of the Work otherwise complies
with the conditions stated in this License.
5. Submission of Contributions.
Unless You explicitly state otherwise, any Contribution intentionally submitted
for inclusion in the Work by You to the Licensor shall be under the terms and
conditions of this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify the terms of
any separate license agreement you may have executed with Licensor regarding
such Contributions.
6. Trademarks.
This License does not grant permission to use the trade names, trademarks,
service marks, or product names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the NOTICE file.
7. Disclaimer of Warranty.
Unless required by applicable law or agreed to in writing, Licensor provides the
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
including, without limitation, any warranties or conditions of TITLE,
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
solely responsible for determining the appropriateness of using or
redistributing the Work and assume any risks associated with Your exercise of
permissions under this License.
8. Limitation of Liability.
In no event and under no legal theory, whether in tort (including negligence),
contract, or otherwise, unless required by applicable law (such as deliberate
and grossly negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special, incidental,
or consequential damages of any character arising as a result of this License or
out of the use or inability to use the Work (including but not limited to
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
any and all other commercial damages or losses), even if such Contributor has
been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability.
While redistributing the Work or Derivative Works thereof, You may choose to
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
other liability obligations and/or rights consistent with this License. However,
in accepting such obligations, You may act only on Your own behalf and on Your
sole responsibility, not on behalf of any other Contributor, and only if You
agree to indemnify, defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason of your
accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work
To apply the Apache License to your work, attach the following boilerplate
notice, with the fields enclosed by brackets "[]" replaced with your own
identifying information. (Don't include the brackets!) The text should be
enclosed in the appropriate comment syntax for the file format. We also
recommend that a file or class name and description of purpose be included on
the same "printed page" as the copyright notice for easier identification within
third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,18 @@
# `@img/sharp-linux-x64`
Prebuilt sharp for use with Linux (glibc) x64.
## Licensing
Copyright 2013 Lovell Fuller and others.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
[https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Binary file not shown.

View File

@ -0,0 +1,46 @@
{
"name": "@img/sharp-linux-x64",
"version": "0.33.5",
"description": "Prebuilt sharp for use with Linux (glibc) x64",
"author": "Lovell Fuller <npm@lovell.info>",
"homepage": "https://sharp.pixelplumbing.com",
"repository": {
"type": "git",
"url": "git+https://github.com/lovell/sharp.git",
"directory": "npm/linux-x64"
},
"license": "Apache-2.0",
"funding": {
"url": "https://opencollective.com/libvips"
},
"preferUnplugged": true,
"optionalDependencies": {
"@img/sharp-libvips-linux-x64": "1.0.4"
},
"files": [
"lib"
],
"publishConfig": {
"access": "public"
},
"type": "commonjs",
"exports": {
"./sharp.node": "./lib/sharp-linux-x64.node",
"./package": "./package.json"
},
"engines": {
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
},
"config": {
"glibc": ">=2.26"
},
"os": [
"linux"
],
"libc": [
"glibc"
],
"cpu": [
"x64"
]
}

View File

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

View File

@ -0,0 +1,83 @@
<h1>
standard-fonts
<br />
<!-- NPM Version -->
<a href="https://www.npmjs.com/package/standard-fonts">
<img
src="https://img.shields.io/npm/v/@pdf-lib/standard-fonts.svg?style=flat-square"
alt="NPM Version"
/>
</a>
<!-- Prettier Badge -->
<a href="https://prettier.io/">
<img
src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square"
alt="Prettier Badge"
/>
</a>
</h1>
> Collection of metrics and encodings for the standard 14 PDF fonts
This project is a fork of [`afm`](https://github.com/chbrown/afm) and was created for use in [`pdf-lib`](https://github.com/Hopding/pdf-lib). This forks exists for two primary reasons:
1. The original project did not include mappings from Unicode to WinAnsi/ZapfDingbats/Symbol encodings.
2. The font metrics included in the original project were uncompressed (not ideal for usage in `pdf-lib`).
## Usage
```js
import { Font, FontNames, Encodings } from '@pdf-lib/standard-fonts';
const codePoint = '∑'.charCodeAt(0);
const glyph = Encodings.Symbol.encodeUnicodeCodePoint(codePoint);
glyph // => { code: 229, name: 'summation' }
const font = Font.load(FontNames.Symbol);
const width = font.getWidthOfGlyph(glyph.name);
width // => 713
```
## Installation
### NPM Module
To install the latest stable version:
```bash
# With npm
npm install --save @pdf-lib/standard-fonts
# With yarn
yarn add @pdf-lib/standard-fonts
```
This assumes you're using [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/lang/en/) as your package manager.
### UMD Module
You can also download `@pdf-lib/standard-fonts` as a UMD module from [unpkg](https://unpkg.com/#/). The UMD builds have been compiled to ES5, so they should work [in any modern browser](https://caniuse.com/#feat=es5). UMD builds are useful if you aren't using a package manager or module bundler. For example, you can use them directly in the `<script>` tag of an HTML page.
The following builds are available:
* https://unpkg.com/@pdf-lib/standard-fonts/dist/standard-fonts.js
* https://unpkg.com/@pdf-lib/standard-fonts/dist/standard-fonts.min.js
When using a UMD build, you will have access to a global `window.StandardFonts` variable. This variable contains the classes and enums exported by `@pdf-lib/standard-fonts`. For example:
```javascript
// NPM module
import { Font, FontNames, Encodings } from '@pdf-lib/standard-fonts';
const font = Font.load(FontNames.HelveticaBold);
const encoding = Encodings.WinAnsi;
// UMD module
var font = StandardFonts.Font.load(StandardFonts.FontNames.HelveticaBold);
var encoding = StandardFonts.Encodings.WinAnsi;
```
## License
[MIT](https://choosealicense.com/licenses/mit/)
## Original Repo's License
Copyright 20152018 Christopher Brown.
[MIT Licensed](https://chbrown.github.io/licenses/MIT/#2015-2018).

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
"eJyFWdtyGjkQ/RVqnnar8Bb4lpg3jEnCxgEvGDtxKg9iphm01oyILrZxKv++mrGd3az6KC8UnNa0+nrUGr5lI11VVLtskF198FaU1Dns9w9OOkf7/ePDrJu90bWbiorCgpH2RpLZO9WqaCReqZ8lnReJqKTa/SwL8DXJctPs9Lxs4oSS+bAuVVjXC7/tG/lAxYV0+SYbOOOpm402wojckVlQ8+T4wVFdUDHXlaifrTs91Q/Z4PNeMLu7t3/U6746POm+7vW/dLNlWGuUrOlCW+mkrrPBXr/X+4/gciPz25qszQbhyeyKjG2XZb3ewR+9Xi/sMdVO5k+ebHemcaHzW/57p3/y+qQbPk967We//TxoP191hoVeUWexs44q25nUuTZbbYSj4o9OZ6hUZ97osZ05WTJ3AQ37jMOqQtblIt9QG7lWycKJuhCmeJGGhSOxffccyqPj/W728eXX4cFJNxvavAmRyQbH++HnGf34vdc/etXNFq54d50NXh+2X6/C137v+CnQH8gZmYdQfP6WXX8MCppQTYMlditCBL53/wfTQ65EFeNfvQ6erlQsqX21akJc1rGs0EoJE+NbMnlToZFAVEFkQ3iABW2uGH3CUK1ojUTgMWEbjfaWeUp5G6N5aCwRw5vddkOM98EVqRlPrBJ2E8OPZHSM6prJkrtnVrqNIWbtOjQrg8o7Zq2VDwxId5x3xMe0lpzBuVaa0WGpkkCkmgaON/3qBVODpaHQiIybXz3ZliTi3DO2D2PoNIZGMXQWQ+MYehNDb2PoXQxNYujPGHofQ+cx9CGGpjE0i6GLGPorhuYxtIihyxhaxtBVDF3H0McY+hRDNzG0CqfQLTmeNlZBBvr0+TnIKbmUuTS5Z1jUN6xtw8n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File

@ -0,0 +1,24 @@
declare type EncodingCharCode = number;
declare type EncodingCharName = string;
interface UnicodeMappings {
[unicodeCodePoint: number]: [EncodingCharCode, EncodingCharName];
}
declare type EncodingNames = 'Symbol' | 'ZapfDingbats' | 'WinAnsi';
declare class Encoding {
name: EncodingNames;
supportedCodePoints: number[];
private unicodeMappings;
constructor(name: EncodingNames, unicodeMappings: UnicodeMappings);
canEncodeUnicodeCodePoint: (codePoint: number) => boolean;
encodeUnicodeCodePoint: (codePoint: number) => {
code: number;
name: string;
};
}
export declare type EncodingType = Encoding;
export declare const Encodings: {
Symbol: Encoding;
ZapfDingbats: Encoding;
WinAnsi: Encoding;
};
export {};

View File

@ -0,0 +1,34 @@
/* tslint:disable max-classes-per-file */
import { decompressJson, padStart } from './utils';
import AllEncodingsCompressed from './all-encodings.compressed.json';
var decompressedEncodings = decompressJson(AllEncodingsCompressed);
var allUnicodeMappings = JSON.parse(decompressedEncodings);
var Encoding = /** @class */ (function () {
function Encoding(name, unicodeMappings) {
var _this = this;
this.canEncodeUnicodeCodePoint = function (codePoint) {
return codePoint in _this.unicodeMappings;
};
this.encodeUnicodeCodePoint = function (codePoint) {
var mapped = _this.unicodeMappings[codePoint];
if (!mapped) {
var str = String.fromCharCode(codePoint);
var hexCode = "0x" + padStart(codePoint.toString(16), 4, '0');
var msg = _this.name + " cannot encode \"" + str + "\" (" + hexCode + ")";
throw new Error(msg);
}
return { code: mapped[0], name: mapped[1] };
};
this.name = name;
this.supportedCodePoints = Object.keys(unicodeMappings)
.map(Number)
.sort(function (a, b) { return a - b; });
this.unicodeMappings = unicodeMappings;
}
return Encoding;
}());
export var Encodings = {
Symbol: new Encoding('Symbol', allUnicodeMappings.symbol),
ZapfDingbats: new Encoding('ZapfDingbats', allUnicodeMappings.zapfdingbats),
WinAnsi: new Encoding('WinAnsi', allUnicodeMappings.win1252),
};

View File

@ -0,0 +1,83 @@
declare const compressedJsonForFontName: {
'Courier': string;
'Courier-Bold': string;
'Courier-Oblique': string;
'Courier-BoldOblique': string;
'Helvetica': string;
'Helvetica-Bold': string;
'Helvetica-Oblique': string;
'Helvetica-BoldOblique': string;
'Times-Roman': string;
'Times-Bold': string;
'Times-Italic': string;
'Times-BoldItalic': string;
'Symbol': string;
'ZapfDingbats': string;
};
export declare enum FontNames {
Courier = "Courier",
CourierBold = "Courier-Bold",
CourierOblique = "Courier-Oblique",
CourierBoldOblique = "Courier-BoldOblique",
Helvetica = "Helvetica",
HelveticaBold = "Helvetica-Bold",
HelveticaOblique = "Helvetica-Oblique",
HelveticaBoldOblique = "Helvetica-BoldOblique",
TimesRoman = "Times-Roman",
TimesRomanBold = "Times-Bold",
TimesRomanItalic = "Times-Italic",
TimesRomanBoldItalic = "Times-BoldItalic",
Symbol = "Symbol",
ZapfDingbats = "ZapfDingbats"
}
export declare type IFontNames = FontNames | keyof typeof compressedJsonForFontName;
export interface ICharMetrics {
/** Decimal value of default character code (-1 if not encoded) */
/** Width of character */
WX: number;
/** Character name (aka Glyph name) */
N: string;
}
/**
* [name_1 name_2 number_x]:
* Name of the first character in the kerning pair followed by the name of the
* second character followed by the kerning amount in the x direction
* (y is zero). The kerning amount is specified in the units of the character
* coordinate system.
*/
export declare type IKernPair = [string, string, number];
export declare class Font {
static load: (fontName: IFontNames) => Font;
Comment: string;
FontName: string;
FullName: string;
FamilyName: string;
Weight: string;
CharacterSet: string;
Version: string;
Notice: string;
EncodingScheme: string;
ItalicAngle: number;
UnderlinePosition: number;
UnderlineThickness: number;
CapHeight: number | void;
XHeight: number | void;
Ascender: number | void;
Descender: number | void;
StdHW: number;
StdVW: number;
IsFixedPitch: boolean;
/**
* [llx lly urx ury]:
* Font bounding box where llx, lly, urx, and ury are all numbers.
*/
FontBBox: [number, number, number, number];
CharMetrics: ICharMetrics[];
KernPairs: IKernPair[];
private CharWidths;
private KernPairXAmounts;
private constructor();
getWidthOfGlyph: (glyphName: string) => number | void;
getXAxisKerningForPair: (leftGlyphName: string, rightGlyphName: string) => number | void;
}
export {};

View File

@ -0,0 +1,83 @@
import { decompressJson } from './utils';
import CourierBoldCompressed from './Courier-Bold.compressed.json';
import CourierBoldObliqueCompressed from './Courier-BoldOblique.compressed.json';
import CourierObliqueCompressed from './Courier-Oblique.compressed.json';
import CourierCompressed from './Courier.compressed.json';
import HelveticaBoldCompressed from './Helvetica-Bold.compressed.json';
import HelveticaBoldObliqueCompressed from './Helvetica-BoldOblique.compressed.json';
import HelveticaObliqueCompressed from './Helvetica-Oblique.compressed.json';
import HelveticaCompressed from './Helvetica.compressed.json';
import TimesBoldCompressed from './Times-Bold.compressed.json';
import TimesBoldItalicCompressed from './Times-BoldItalic.compressed.json';
import TimesItalicCompressed from './Times-Italic.compressed.json';
import TimesRomanCompressed from './Times-Roman.compressed.json';
import SymbolCompressed from './Symbol.compressed.json';
import ZapfDingbatsCompressed from './ZapfDingbats.compressed.json';
// prettier-ignore
var compressedJsonForFontName = {
'Courier': CourierCompressed,
'Courier-Bold': CourierBoldCompressed,
'Courier-Oblique': CourierObliqueCompressed,
'Courier-BoldOblique': CourierBoldObliqueCompressed,
'Helvetica': HelveticaCompressed,
'Helvetica-Bold': HelveticaBoldCompressed,
'Helvetica-Oblique': HelveticaObliqueCompressed,
'Helvetica-BoldOblique': HelveticaBoldObliqueCompressed,
'Times-Roman': TimesRomanCompressed,
'Times-Bold': TimesBoldCompressed,
'Times-Italic': TimesItalicCompressed,
'Times-BoldItalic': TimesBoldItalicCompressed,
'Symbol': SymbolCompressed,
'ZapfDingbats': ZapfDingbatsCompressed,
};
export var FontNames;
(function (FontNames) {
FontNames["Courier"] = "Courier";
FontNames["CourierBold"] = "Courier-Bold";
FontNames["CourierOblique"] = "Courier-Oblique";
FontNames["CourierBoldOblique"] = "Courier-BoldOblique";
FontNames["Helvetica"] = "Helvetica";
FontNames["HelveticaBold"] = "Helvetica-Bold";
FontNames["HelveticaOblique"] = "Helvetica-Oblique";
FontNames["HelveticaBoldOblique"] = "Helvetica-BoldOblique";
FontNames["TimesRoman"] = "Times-Roman";
FontNames["TimesRomanBold"] = "Times-Bold";
FontNames["TimesRomanItalic"] = "Times-Italic";
FontNames["TimesRomanBoldItalic"] = "Times-BoldItalic";
FontNames["Symbol"] = "Symbol";
FontNames["ZapfDingbats"] = "ZapfDingbats";
})(FontNames || (FontNames = {}));
var fontCache = {};
var Font = /** @class */ (function () {
function Font() {
var _this = this;
this.getWidthOfGlyph = function (glyphName) {
return _this.CharWidths[glyphName];
};
this.getXAxisKerningForPair = function (leftGlyphName, rightGlyphName) {
return (_this.KernPairXAmounts[leftGlyphName] || {})[rightGlyphName];
};
}
Font.load = function (fontName) {
var cachedFont = fontCache[fontName];
if (cachedFont)
return cachedFont;
var json = decompressJson(compressedJsonForFontName[fontName]);
var font = Object.assign(new Font(), JSON.parse(json));
font.CharWidths = font.CharMetrics.reduce(function (acc, metric) {
acc[metric.N] = metric.WX;
return acc;
}, {});
font.KernPairXAmounts = font.KernPairs.reduce(function (acc, _a) {
var name1 = _a[0], name2 = _a[1], width = _a[2];
if (!acc[name1])
acc[name1] = {};
acc[name1][name2] = width;
return acc;
}, {});
fontCache[fontName] = font;
return font;
};
return Font;
}());
export { Font };

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
"eJx9WFlv2zgQ/iuGnnYBt5DkS85bmk13g27SoEkPbNEHWqIlIhSpklSuov99R7JIkSLtFyGZjxzN8c0h/4oueF1jpqKz6Mt1K1GJZ4s4S+PZYrvdbqJ59J4zdYNqDAfuXuodp52spdSToZrQl6n0KyZl1Sm/xgVpa5BcKURJfs5KCgdj+F++J8+4uCUqr6IzJVo8jy4qJFCusLjD3d27BucE0cGYd+/4c3T2/U2SxfM36XYxT+JtDI8k/jGPPrMCC0oYvuWSKMJZdPYmiWMLuK9I/sCwlNHZCuRfsJD9sSiOk7dxnMFbbrgieefGBW9eROfA7I/8z1myzVbz7rnpn9vuCW/unpvZecF3eHb3I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GvriJ6YRHJboLmnWPUNXWAC7FbQg+/0IrjUL4RMFBxhYkEdSBLxiXB0xD8TkEZorywPXoP0I/jxhXGzWKEoJUFgeiTvs3srq2eO9Hq2Aeq92S9eDIgeYwIeawKoVY+KyVOumuBmpY0r+CgrgQVn7ohl9n6aIoc4TJjB0lEDWvmaGa05ETrGfPRd3lm1jI64b9SKtBJlbhAFTgEhuqWoUvlhCFdwRBW613cNWqnGYyDAdj+OQfdnugpBWHUa14jAKbbN2tlDrfR6mXUT9p7F3peyGvHNBb0UCl933GHgmyN6Hc/0R6+KZxiG7Ba6ReJjg6RiAos0DpTRsHWNz1s284Mr58DI+UF52N8B7vyIGzP4+nGJcWLXiNMtiR0/0S0BPtExAj3ZNwE42zh11e6duTZS/YlZaK6DebfrkOsb4aURMnsqiA+viHpPowDrwsoX1y6moRTZ20cMXtmpOgFYf8sGd8kFrRw4ptuCQagu2lJvwmpXEUu2DNSlOoEf12vY4aXOZkG6WY8OC4hzrwHRcjVhWepjd4KdYKK7jrx5H89WjRxPWoycydlS3jZ/I2VS/G9yp9gB6PG1T1aY4YAp3LfPHPPqABbtFRHS/jf34/T82FAfb"

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
"eJxtmNtu20YQhl+F4FULyMGeD7pz3AY1ChtG7NpFA18w1NomIlECSRcxgrx7SVk7+wOdG8H5OJydf2Z2d5gf9cV+t0v9VK/r+6vXsXlOlbHe28paq229qj/t++m62aXZ4J/m8PRb1z9/baZxefK63Z6eXN5dVMvTCh83u277xr/6kLrnl2XNq7TpXnczuZyabdee98/b2VzM/x4/dd/T5qab2pd6PQ2vaVVfvDRD005puE3Lu7eH1HbN9hTjx4/77/X6y5lcnUmjVzHIVVDicVX/1W/SsO36dLMfu6nb9/X6TAoBD+5euvZbn8axXtuZ36dhPJrVQqgPQoh5hev91LWLkIv94W1Ygq9+aX+tZAx2tfz64284/sblN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AxCmhePCKUwFzAmpDFRQvjA9R06Hq8TONvshgKDCuRAZTXigUxjxNFfKRo3CLhnIJBMFRvMZpqpNBMlQJzGT5WFQMVQI/AikPMIhEU1aDjqJvQwmjSHB05cC9jbYwc5UtAHNLhDw41ha+lEqF4JaH3gmB61SYcqInxTDmQK8v08vjqv4zDf1N0w3Lf4A8/vwPpfK11w=="

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
export * from './Font';
export * from './Encoding';

View File

@ -0,0 +1,2 @@
export * from './Font';
export * from './Encoding';

View File

@ -0,0 +1,3 @@
export declare const decodeFromBase64: (base64: string) => Uint8Array;
export declare const decompressJson: (compressedJson: string) => string;
export declare const padStart: (value: string, length: number, padChar: string) => string;

View File

@ -0,0 +1,62 @@
/*
* The `chars`, `lookup`, and `decodeFromBase64` members of this file are
* licensed under the following:
*
* base64-arraybuffer
* https://github.com/niklasvh/base64-arraybuffer
*
* Copyright (c) 2012 Niklas von Hertzen
* Licensed under the MIT license.
*
*/
import pako from 'pako';
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
// Use a lookup table to find the index.
var lookup = new Uint8Array(256);
for (var i = 0; i < chars.length; i++) {
lookup[chars.charCodeAt(i)] = i;
}
export var decodeFromBase64 = function (base64) {
var bufferLength = base64.length * 0.75;
var len = base64.length;
var i;
var p = 0;
var encoded1;
var encoded2;
var encoded3;
var encoded4;
if (base64[base64.length - 1] === '=') {
bufferLength--;
if (base64[base64.length - 2] === '=') {
bufferLength--;
}
}
var bytes = new Uint8Array(bufferLength);
for (i = 0; i < len; i += 4) {
encoded1 = lookup[base64.charCodeAt(i)];
encoded2 = lookup[base64.charCodeAt(i + 1)];
encoded3 = lookup[base64.charCodeAt(i + 2)];
encoded4 = lookup[base64.charCodeAt(i + 3)];
bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
}
return bytes;
};
var arrayToString = function (array) {
var str = '';
for (var i = 0; i < array.length; i++) {
str += String.fromCharCode(array[i]);
}
return str;
};
export var decompressJson = function (compressedJson) {
return arrayToString(pako.inflate(decodeFromBase64(compressedJson)));
};
export var padStart = function (value, length, padChar) {
var padding = '';
for (var idx = 0, len = length - value.length; idx < len; idx++) {
padding += padChar;
}
return padding + value;
};

View File

@ -0,0 +1 @@
"eJyFWdtyGjkQ/RVqnnar8Bb4lpg3jEnCxgEvGDtxKg9iphm01oyILrZxKv++mrGd3az6KC8UnNa0+nrUGr5lI11VVLtskF198FaU1Dns9w9OOkf7/ePDrJu90bWbiorCgpH2RpLZO9WqaCReqZ8lnReJqKTa/SwL8DXJctPs9Lxs4oSS+bAuVVjXC7/tG/lAxYV0+SYbOOOpm402wojckVlQ8+T4wVFdUDHXlaifrTs91Q/Z4PNeMLu7t3/U6746POm+7vW/dLNlWGuUrOlCW+mkrrPBXr/X+4/gciPz25qszQbhyeyKjG2XZb3ewR+9Xi/sMdVO5k+ebHemcaHzW/57p3/y+qQbPk967We//TxoP191hoVeUWexs44q25nUuTZbbYSj4o9OZ6hUZ97osZ05WTJ3AQ37jMOqQtblIt9QG7lWycKJuhCmeJGGhSOxffccyqPj/W728eXX4cFJNxvavAmRyQbH++HnGf34vdc/etXNFq54d50NXh+2X6/C137v+CnQH8gZmYdQfP6WXX8MCppQTYMlditCBL53/wfTQ65EFeNfvQ6erlQsqX21akJc1rGs0EoJE+NbMnlToZFAVEFkQ3iABW2uGH3CUK1ojUTgMWEbjfaWeUp5G6N5aCwRw5vddkOM98EVqRlPrBJ2E8OPZHSM6prJkrtnVrqNIWbtOjQrg8o7Zq2VDwxId5x3xMe0lpzBuVaa0WGpkkCkmgaON/3qBVODpaHQiIybXz3ZliTi3DO2D2PoNIZGMXQWQ+MYehNDb2PoXQxNYujPGHofQ+cx9CGGpjE0i6GLGPorhuYxtIihyxhaxtBVDF3H0McY+hRDNzG0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TQqEaH4f2O+TXfvGBbHMulG2/Hn/98Q/b2xEO"

View File

@ -0,0 +1,24 @@
declare type EncodingCharCode = number;
declare type EncodingCharName = string;
interface UnicodeMappings {
[unicodeCodePoint: number]: [EncodingCharCode, EncodingCharName];
}
declare type EncodingNames = 'Symbol' | 'ZapfDingbats' | 'WinAnsi';
declare class Encoding {
name: EncodingNames;
supportedCodePoints: number[];
private unicodeMappings;
constructor(name: EncodingNames, unicodeMappings: UnicodeMappings);
canEncodeUnicodeCodePoint: (codePoint: number) => boolean;
encodeUnicodeCodePoint: (codePoint: number) => {
code: number;
name: string;
};
}
export declare type EncodingType = Encoding;
export declare const Encodings: {
Symbol: Encoding;
ZapfDingbats: Encoding;
WinAnsi: Encoding;
};
export {};

View File

@ -0,0 +1,39 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/* tslint:disable max-classes-per-file */
var utils_1 = require("./utils");
var all_encodings_compressed_json_1 = __importDefault(require("./all-encodings.compressed.json"));
var decompressedEncodings = utils_1.decompressJson(all_encodings_compressed_json_1.default);
var allUnicodeMappings = JSON.parse(decompressedEncodings);
var Encoding = /** @class */ (function () {
function Encoding(name, unicodeMappings) {
var _this = this;
this.canEncodeUnicodeCodePoint = function (codePoint) {
return codePoint in _this.unicodeMappings;
};
this.encodeUnicodeCodePoint = function (codePoint) {
var mapped = _this.unicodeMappings[codePoint];
if (!mapped) {
var str = String.fromCharCode(codePoint);
var hexCode = "0x" + utils_1.padStart(codePoint.toString(16), 4, '0');
var msg = _this.name + " cannot encode \"" + str + "\" (" + hexCode + ")";
throw new Error(msg);
}
return { code: mapped[0], name: mapped[1] };
};
this.name = name;
this.supportedCodePoints = Object.keys(unicodeMappings)
.map(Number)
.sort(function (a, b) { return a - b; });
this.unicodeMappings = unicodeMappings;
}
return Encoding;
}());
exports.Encodings = {
Symbol: new Encoding('Symbol', allUnicodeMappings.symbol),
ZapfDingbats: new Encoding('ZapfDingbats', allUnicodeMappings.zapfdingbats),
WinAnsi: new Encoding('WinAnsi', allUnicodeMappings.win1252),
};

View File

@ -0,0 +1,83 @@
declare const compressedJsonForFontName: {
'Courier': string;
'Courier-Bold': string;
'Courier-Oblique': string;
'Courier-BoldOblique': string;
'Helvetica': string;
'Helvetica-Bold': string;
'Helvetica-Oblique': string;
'Helvetica-BoldOblique': string;
'Times-Roman': string;
'Times-Bold': string;
'Times-Italic': string;
'Times-BoldItalic': string;
'Symbol': string;
'ZapfDingbats': string;
};
export declare enum FontNames {
Courier = "Courier",
CourierBold = "Courier-Bold",
CourierOblique = "Courier-Oblique",
CourierBoldOblique = "Courier-BoldOblique",
Helvetica = "Helvetica",
HelveticaBold = "Helvetica-Bold",
HelveticaOblique = "Helvetica-Oblique",
HelveticaBoldOblique = "Helvetica-BoldOblique",
TimesRoman = "Times-Roman",
TimesRomanBold = "Times-Bold",
TimesRomanItalic = "Times-Italic",
TimesRomanBoldItalic = "Times-BoldItalic",
Symbol = "Symbol",
ZapfDingbats = "ZapfDingbats"
}
export declare type IFontNames = FontNames | keyof typeof compressedJsonForFontName;
export interface ICharMetrics {
/** Decimal value of default character code (-1 if not encoded) */
/** Width of character */
WX: number;
/** Character name (aka Glyph name) */
N: string;
}
/**
* [name_1 name_2 number_x]:
* Name of the first character in the kerning pair followed by the name of the
* second character followed by the kerning amount in the x direction
* (y is zero). The kerning amount is specified in the units of the character
* coordinate system.
*/
export declare type IKernPair = [string, string, number];
export declare class Font {
static load: (fontName: IFontNames) => Font;
Comment: string;
FontName: string;
FullName: string;
FamilyName: string;
Weight: string;
CharacterSet: string;
Version: string;
Notice: string;
EncodingScheme: string;
ItalicAngle: number;
UnderlinePosition: number;
UnderlineThickness: number;
CapHeight: number | void;
XHeight: number | void;
Ascender: number | void;
Descender: number | void;
StdHW: number;
StdVW: number;
IsFixedPitch: boolean;
/**
* [llx lly urx ury]:
* Font bounding box where llx, lly, urx, and ury are all numbers.
*/
FontBBox: [number, number, number, number];
CharMetrics: ICharMetrics[];
KernPairs: IKernPair[];
private CharWidths;
private KernPairXAmounts;
private constructor();
getWidthOfGlyph: (glyphName: string) => number | void;
getXAxisKerningForPair: (leftGlyphName: string, rightGlyphName: string) => number | void;
}
export {};

View File

@ -0,0 +1,88 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var Courier_Bold_compressed_json_1 = __importDefault(require("./Courier-Bold.compressed.json"));
var Courier_BoldOblique_compressed_json_1 = __importDefault(require("./Courier-BoldOblique.compressed.json"));
var Courier_Oblique_compressed_json_1 = __importDefault(require("./Courier-Oblique.compressed.json"));
var Courier_compressed_json_1 = __importDefault(require("./Courier.compressed.json"));
var Helvetica_Bold_compressed_json_1 = __importDefault(require("./Helvetica-Bold.compressed.json"));
var Helvetica_BoldOblique_compressed_json_1 = __importDefault(require("./Helvetica-BoldOblique.compressed.json"));
var Helvetica_Oblique_compressed_json_1 = __importDefault(require("./Helvetica-Oblique.compressed.json"));
var Helvetica_compressed_json_1 = __importDefault(require("./Helvetica.compressed.json"));
var Times_Bold_compressed_json_1 = __importDefault(require("./Times-Bold.compressed.json"));
var Times_BoldItalic_compressed_json_1 = __importDefault(require("./Times-BoldItalic.compressed.json"));
var Times_Italic_compressed_json_1 = __importDefault(require("./Times-Italic.compressed.json"));
var Times_Roman_compressed_json_1 = __importDefault(require("./Times-Roman.compressed.json"));
var Symbol_compressed_json_1 = __importDefault(require("./Symbol.compressed.json"));
var ZapfDingbats_compressed_json_1 = __importDefault(require("./ZapfDingbats.compressed.json"));
// prettier-ignore
var compressedJsonForFontName = {
'Courier': Courier_compressed_json_1.default,
'Courier-Bold': Courier_Bold_compressed_json_1.default,
'Courier-Oblique': Courier_Oblique_compressed_json_1.default,
'Courier-BoldOblique': Courier_BoldOblique_compressed_json_1.default,
'Helvetica': Helvetica_compressed_json_1.default,
'Helvetica-Bold': Helvetica_Bold_compressed_json_1.default,
'Helvetica-Oblique': Helvetica_Oblique_compressed_json_1.default,
'Helvetica-BoldOblique': Helvetica_BoldOblique_compressed_json_1.default,
'Times-Roman': Times_Roman_compressed_json_1.default,
'Times-Bold': Times_Bold_compressed_json_1.default,
'Times-Italic': Times_Italic_compressed_json_1.default,
'Times-BoldItalic': Times_BoldItalic_compressed_json_1.default,
'Symbol': Symbol_compressed_json_1.default,
'ZapfDingbats': ZapfDingbats_compressed_json_1.default,
};
var FontNames;
(function (FontNames) {
FontNames["Courier"] = "Courier";
FontNames["CourierBold"] = "Courier-Bold";
FontNames["CourierOblique"] = "Courier-Oblique";
FontNames["CourierBoldOblique"] = "Courier-BoldOblique";
FontNames["Helvetica"] = "Helvetica";
FontNames["HelveticaBold"] = "Helvetica-Bold";
FontNames["HelveticaOblique"] = "Helvetica-Oblique";
FontNames["HelveticaBoldOblique"] = "Helvetica-BoldOblique";
FontNames["TimesRoman"] = "Times-Roman";
FontNames["TimesRomanBold"] = "Times-Bold";
FontNames["TimesRomanItalic"] = "Times-Italic";
FontNames["TimesRomanBoldItalic"] = "Times-BoldItalic";
FontNames["Symbol"] = "Symbol";
FontNames["ZapfDingbats"] = "ZapfDingbats";
})(FontNames = exports.FontNames || (exports.FontNames = {}));
var fontCache = {};
var Font = /** @class */ (function () {
function Font() {
var _this = this;
this.getWidthOfGlyph = function (glyphName) {
return _this.CharWidths[glyphName];
};
this.getXAxisKerningForPair = function (leftGlyphName, rightGlyphName) {
return (_this.KernPairXAmounts[leftGlyphName] || {})[rightGlyphName];
};
}
Font.load = function (fontName) {
var cachedFont = fontCache[fontName];
if (cachedFont)
return cachedFont;
var json = utils_1.decompressJson(compressedJsonForFontName[fontName]);
var font = Object.assign(new Font(), JSON.parse(json));
font.CharWidths = font.CharMetrics.reduce(function (acc, metric) {
acc[metric.N] = metric.WX;
return acc;
}, {});
font.KernPairXAmounts = font.KernPairs.reduce(function (acc, _a) {
var name1 = _a[0], name2 = _a[1], width = _a[2];
if (!acc[name1])
acc[name1] = {};
acc[name1][name2] = width;
return acc;
}, {});
fontCache[fontName] = font;
return font;
};
return Font;
}());
exports.Font = Font;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
"eJx9WFlv2zgQ/iuGnnYBt5DkS85bmk13g27SoEkPbNEHWqIlIhSpklSuov99R7JIkSLtFyGZjxzN8c0h/4oueF1jpqKz6Mt1K1GJZ4s4S+PZYrvdbqJ59J4zdYNqDAfuXuodp52spdSToZrQl6n0KyZl1Sm/xgVpa5BcKURJfs5KCgdj+F++J8+4uCUqr6IzJVo8jy4qJFCusLjD3d27BucE0cGYd+/4c3T2/U2SxfM36XYxT+JtDI8k/jGPPrMCC0oYvuWSKMJZdPYmiWMLuK9I/sCwlNHZCuRfsJD9sSiOk7dxnMFbbrgieefGBW9eROfA7I/8z1myzVbz7rnpn9vuCW/unpvZecF3eHb3IhWu5eyK5Vw0XCCFi7ezc0pnvRo5E1hi8QhCeM0lHCoIK+/yCvdR67zrfd2THPA7VfzzNTrbpv2fX+BPeH8fm2usBMnBg++/oq/forO08+QGNMgGgeG/5wfxYrE4iPFzTlFt5JtkkLeMPIL/EFoNreJBE2vrXReako3YcqvVEXCTKWJdzPS7Gizyjk/mZZvsAKC66d7FCgMtF4NC2eaVqpDyLW+QwIzi/TGoD6tvPQL7BJEPNVKVb39DW2mkJnY5FALyD9eEhU6DL4SPrqTaS0mRrHyDXrHgvpQz7AvVU+CkqgQOnN3zVgSkkFVfKslzQIgfMfPFOBxWRiyDjcs5p5wFIoFr4kImprQrP59WP1ubiVpcCgxlNLq5XC4PwM8Wy77EvSs5ZyU0EpuFaXqAzmlTjVlerzcH8TuskH/4oiLj0WQQ/oWpdXadJAfxZSOJ7exmPfD01lYSD8K/kU0288JLS7Mh+hW337dINCPA5MRX8QE1jXU8Wx/E/6J6V4z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OZkG6WY8OC4hzrwHRcjVhWepjd4KdYKK7jrx5H89WjRxPWoycydlS3jZ/I2VS/G9yp9gB6PG1T1aY4YAp3LfPHPPqABbtFRHS/jf34/T82FAfb"

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
"eJxtmNtu20YQhl+F4FULyMGeD7pz3AY1ChtG7NpFA18w1NomIlECSRcxgrx7SVk7+wOdG8H5OJydf2Z2d5gf9cV+t0v9VK/r+6vXsXlOlbHe28paq229qj/t++m62aXZ4J/m8PRb1z9/baZxefK63Z6eXN5dVMvTCh83u277xr/6kLrnl2XNq7TpXnczuZyabdee98/b2VzM/x4/dd/T5qab2pd6PQ2vaVVfvDRD005puE3Lu7eH1HbN9hTjx4/77/X6y5lcnUmjVzHIVVDicVX/1W/SsO36dLMfu6nb9/X6TAoBD+5euvZbn8axXtuZ36dhPJrVQqgPQoh5hev91LWLkIv94W1Ygq9+aX+tZAx2tfz64284/sblN/rqfLP/mqrbt3FKu7G67Nv9cNgPzZQ2H6rz7bb6vLgZq89pTMO/M/xfEqturJpqSM/d7GJIm2oamk3aNcO3av80O5xh3yyKmm1193ZIT02bqovTKjP+MAf++7zsZvZ3276kYyWWXB0z99S18/PbafPHQ71W4fjn/fxnFO+ZvkrT0LVzTr78qB/+nk38bHM9exgP8zr1z9U7jt6840YW5uSJKcZOCaBBnKgm5mU8MVNYyMwWFvO7Ukagkmgg6sDWQ5yFFqjzUrLEaQ3BEmiwNsMSaZS0vgWfOkPHWQowNeTUc0kumnxZvsgPxlGai6VTGUqAVCTQ6QkWnc77DKEiLktSUBJKqHIQZ86d8gCpHYoiEzMsb1ubYy8vW50DChB5ZhGqrijD0EqUIeiaEHIfCg5Kpuu0ApiToaGPSY0uaQsyr65L2oKi1yFt1PLaQ3lzfXTgXodGoJYzglndSLDMPg1sTPJpQJHJigw0QrGERqD9YhyTOgONQDUyuF1zaxuokc/BW2ztXCMrGZ9WMW1oQZHIXWNBkSCfRZEL5BMUiZw6CzVSFCfUSGZFNjIldoKDkonTKQiJIGzWmFd3BizJJ9SINoLDriOfUCOZS+zg+KGD1qGiLNMLxtJD1/ns00ON6EzyUCM6vbxhoBKaqbG3DFQCNiL1iHccBPV0DHhQH/JW8EW90dkyFKGywCJU0WkVSvSGeiSUODWFFD0HYdPQVoiRgfPMA+/nnRgiAyNYSjpWNQcNSMrtFCUH4ZIRpSCWocFCSuhCEY6hoUClc0WC52BJlCYYLQdhN+hygRRRlo5BKRRLS6oihSqh+ZzzRGG1Mo4Iz1LoP0qsxDGFzk0JE42ji0jCPejomJKCuwil4m5CiRMEUMVSzVLDUstSx1Juc0oVWMpqY295qVltmtWmWW2a1aZZbZrVplltmtWmWW2G1WZYbYbVZlhthtVmWG2G1WZYbYbVZlhtltVmWW2W1WZZbZbVZlltltVmWW2W1QYjQCh7E2aAQHeGhCFgPoNoy8KNb2wxBhmGKBxoUZXlLGsLI6AsftEDHV0wIURVbANLcTKlGGBIKPOAxCmhePCKUwFzAmpDFRQvjA9R06Hq8TONvshgKDCuRAZTXigUxjxNFfKRo3CLhnIJBMFRvMZpqpNBMlQJzGT5WFQMVQI/AikPMIhEU1aDjqJvQwmjSHB05cC9jbYwc5UtAHNLhDw41ha+lEqF4JaH3gmB61SYcqInxTDmQK8v08vjqv4zDf1N0w3Lf4A8/vwPpfK11w=="

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
export * from './Font';
export * from './Encoding';

View File

@ -0,0 +1,7 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./Font"));
__export(require("./Encoding"));

View File

@ -0,0 +1,3 @@
export declare const decodeFromBase64: (base64: string) => Uint8Array;
export declare const decompressJson: (compressedJson: string) => string;
export declare const padStart: (value: string, length: number, padChar: string) => string;

View File

@ -0,0 +1,67 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/*
* The `chars`, `lookup`, and `decodeFromBase64` members of this file are
* licensed under the following:
*
* base64-arraybuffer
* https://github.com/niklasvh/base64-arraybuffer
*
* Copyright (c) 2012 Niklas von Hertzen
* Licensed under the MIT license.
*
*/
var pako_1 = __importDefault(require("pako"));
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
// Use a lookup table to find the index.
var lookup = new Uint8Array(256);
for (var i = 0; i < chars.length; i++) {
lookup[chars.charCodeAt(i)] = i;
}
exports.decodeFromBase64 = function (base64) {
var bufferLength = base64.length * 0.75;
var len = base64.length;
var i;
var p = 0;
var encoded1;
var encoded2;
var encoded3;
var encoded4;
if (base64[base64.length - 1] === '=') {
bufferLength--;
if (base64[base64.length - 2] === '=') {
bufferLength--;
}
}
var bytes = new Uint8Array(bufferLength);
for (i = 0; i < len; i += 4) {
encoded1 = lookup[base64.charCodeAt(i)];
encoded2 = lookup[base64.charCodeAt(i + 1)];
encoded3 = lookup[base64.charCodeAt(i + 2)];
encoded4 = lookup[base64.charCodeAt(i + 3)];
bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
}
return bytes;
};
var arrayToString = function (array) {
var str = '';
for (var i = 0; i < array.length; i++) {
str += String.fromCharCode(array[i]);
}
return str;
};
exports.decompressJson = function (compressedJson) {
return arrayToString(pako_1.default.inflate(exports.decodeFromBase64(compressedJson)));
};
exports.padStart = function (value, length, padChar) {
var padding = '';
for (var idx = 0, len = length - value.length; idx < len; idx++) {
padding += padChar;
}
return padding + value;
};

View File

@ -0,0 +1,55 @@
{
"name": "@pdf-lib/standard-fonts",
"version": "1.0.0",
"description": "Metrics for the Standard 14 PDF fonts and their encodings",
"main": "lib/index.js",
"unpkg": "dist/standard-fonts.min.js",
"module": "es/index.js",
"types": "lib/index.d.ts",
"scripts": {
"make": "node Makefile.js",
"lint": "node Makefile.js lint",
"clean": "node Makefile.js clean",
"typecheck": "tsc --noEmit",
"afmToJson": "node Makefile.js afmToJson",
"encodingsToJson": "node Makefile.js encodingsToJson",
"releaseNext": "node Makefile.js releaseNext",
"releaseLatest": "node Makefile.js releaseLatest"
},
"repository": "https://github.com/Hopding/standard-fonts.git",
"keywords": [
"afm",
"adobe",
"font",
"metrics",
"ascii",
"pdf"
],
"author": "Andrew Dillon <andrew.dillon.j@gmail.com>",
"contributors": [
"Christopher Brown <io@henrian.com> (http://henrian.com)"
],
"license": "MIT",
"homepage": "https://github.com/Hopding/standard-fonts",
"dependencies": {
"pako": "^1.0.6"
},
"devDependencies": {
"@types/mz": "^0.0.32",
"@types/node": "^10.5.1",
"@types/pako": "^1.0.0",
"base64-arraybuffer": "^0.1.5",
"mz": "^2.7.0",
"prettier": "^1.15.3",
"rollup": "^0.68.2",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-json": "^3.1.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-terser": "^3.0.0",
"shelljs": "^0.8.3",
"ts-node": "^7.0.1",
"tslint": "^5.12.0",
"tslint-config-prettier": "^1.17.0",
"typescript": "^2.9.2"
}
}

21
api-filigrane/node_modules/@pdf-lib/upng/LICENSE generated vendored Normal file
View File

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

143
api-filigrane/node_modules/@pdf-lib/upng/README.md generated vendored Normal file
View File

@ -0,0 +1,143 @@
<h1>
upng
<br />
<!-- NPM Version -->
<a href="https://www.npmjs.com/package/@pdf-lib/upng">
<img
src="https://img.shields.io/npm/v/png-ts.svg?style=flat-square"
alt="NPM Version"
/>
</a>
</h1>
> A small, fast and advanced PNG / APNG encoder and decoder
This project is a fork of [`UPNG.js`](https://github.com/photopea/UPNG.js) and was created for use in [`pdf-lib`](https://github.com/Hopding/pdf-lib). The maintainer of the original repo does not publish it to NPM. That is the primary purpose of this fork. In addition, an `index.d.ts` file has been added (copied directly from [`@types/upng-js`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/upng-js/index.d.ts)) to makes TypeScript definitions available without requiring additional packages to be installed.
## Example of `UPNG.toRGBA8`
```javascript
// Import the UPNG class
import UPNG from '@pdf-lib/upng';
// Create a UPNG object
const pngImage = UPNG.decode(/* Uint8Array containing bytes of PNG image */);
// `pixels` is a 1D array (in rgba order) of decoded pixel data
const pixels = pngImage.UPNG.toRGBA8();
```
## Installation
### NPM Module
To install the latest stable version:
```bash
# With npm
npm install --save @pdf-lib/upng
# With yarn
yarn add @pdf-lib/upng
```
This assumes you're using [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/lang/en/) as your package manager.
### UMD Module
You can also download `@pdf-lib/upng` as a UMD module from [unpkg](https://unpkg.com/#/). The UMD builds have been compiled to ES5, so they should work [in any modern browser](https://caniuse.com/#feat=es5). UMD builds are useful if you aren't using a package manager or module bundler. For example, you can use them directly in the `<script>` tag of an HTML page.
The following builds are available:
* https://unpkg.com/@pdf-lib/upng/dist/UPNG.js
* https://unpkg.com/@pdf-lib/upng/dist/UPNG.min.js
When using a UMD build, you will have access to a global `window.UPNG` variable. This variable contains the `UPNG` class exported by `@pdf-lib/upng`. For example:
```javascript
// NPM module
import UPNG from '@pdf-lib/upng';
const pngImage = UPNG.decode(/* ... */)
// UMD module
var pngImage = window.UPNG.decode(/* ... */)
```
## Encoder
UPNG.js supports APNG and the interface expects "frames". Regular PNG is just a single-frame animation (single-item array).
#### `UPNG.encode(imgs, w, h, cnum, [dels])`
* `imgs`: array of frames. A frame is an ArrayBuffer containing the pixel data (RGBA, 8 bits per channel)
* `w`, `h` : width and height of the image
* `cnum`: number of colors in the result; 0: all colors (lossless PNG)
* `dels`: array of millisecond delays for each frame (only when 2 or more frames)
* returns an ArrayBuffer with binary data of a PNG file
UPNG.js can do a lossy minification of PNG files, similar to [TinyPNG](https://tinypng.com/) and other tools. It performed quantization with [k-means algorithm](https://en.wikipedia.org/wiki/K-means_clustering) in the past, but now we use [K-d trees](https://en.wikipedia.org/wiki/K-d_tree).
Lossy compression is allowed by the last parameter `cnum`. Set it to zero for a lossless compression, or write the number of allowed colors in the image. Smaller values produce smaller files. **Or just use 0 for lossless / 256 for lossy.**
// Read RGBA from canvas and encode with UPNG
var dta = ctx.getImageData(0,0,200,300).data; // ctx is Context2D of a Canvas
// dta = new Uint8Array(200 * 300 * 4); // or generate pixels manually
var png = UPNG.encode([dta.buffer], 200, 300, 0); console.log(new Uint8Array(png));
#### `UPNG.encodeLL(imgs, w, h, cc, ac, depth, [dels])` - low-level encode
* `imgs`: array of frames. A frame is an ArrayBuffer containing the pixel data (corresponding to following parameters)
* `w`, `h` : width and height of the image
* `cc`, `ac`: number of color channels (1 or 3) and alpha channels (0 or 1)
* `depth`: bit depth of pixel data (1, 2, 4, 8, 16)
* `dels`: array of millisecond delays for each frame (only when 2 or more frames)
* returns an ArrayBuffer with binary data of a PNG file
This function does not do any optimizations, it just stores what you give it. There are two cases when it is useful:
* saving 16-bit colors (note, that PNG is big-endian, unlike Uint16Array in JS)
* your image is too large, and "expanding" to 8-bit RGBA would use too much memory (e.g. 4-bit grayscale 50,000 x 50,000 = 1.25 GB, 8-bit RGBA would be 10 GB)
## Decoder
Supports all color types (including Grayscale and Palettes), all channel depths (1, 2, 4, 8, 16), interlaced images etc. Opens PNGs which other libraries can not open (tested with [PngSuite](http://www.schaik.com/pngsuite/)).
#### `UPNG.decode(buffer)`
* `buffer`: ArrayBuffer containing the PNG file
* returns an image object with following properties:
* * `width`: the width of the image
* * `height`: the height of the image
* * `depth`: number of bits per channel
* * `ctype`: color type of the file (Truecolor, Grayscale, Palette ...)
* * `frames`: additional info about frames (frame delays etc.)
* * `tabs`: additional chunks of the PNG file
* * `data`: pixel data of the image
PNG files may have a various number of channels and a various color depth. The interpretation of `data` depends on the current color type and color depth (see the [PNG specification](https://www.w3.org/TR/PNG/)).
#### `UPNG.toRGBA8(img)`
* `img`: PNG image object (returned by UPNG.decode())
* returns an array of frames. A frame is ArrayBuffer of the image in RGBA format, 8 bits per channel.
### Example
var img = UPNG.decode(buff); // put ArrayBuffer of the PNG file into UPNG.decode
var rgba = UPNG.toRGBA8(img)[0]; // UPNG.toRGBA8 returns array of frames, size: width * height * 4 bytes.
PNG format uses the Inflate algorithm. Right now, UPNG.js calls [Pako.js](https://github.com/nodeca/pako) for the Inflate and Deflate method.
## Quantizer
UPNG.js contains a very good Quantizer of 4-component 8-bit vectors (i.e. pixels). It can be used to generate nice color palettes (e.g. Photopea uses UPNG.js to make palettes for GIF images).
Quantization consists of two important steps: Finding a nice palette and Finding the closest color in the palette for each sample (non-trivial for large palettes). UPNG perfroms both steps.
var res = UPNG.quantize(data, psize);
* `data`: ArrayBuffer of samples (byte length is a multiple of four)
* `psize` : Palette size (how many colors you want to have)
The result object "res" has following properties:
* `abuf`: ArrayBuffer corresponding to `data`, where colors are remapped by a palette
* `inds`: Uint8Array : the index of a color for each sample (only when `psize`<=256)
* `plte`: Array : the Palette - a list of colors, `plte[i].est.q` and `plte[i].est.rgba` is the color value
### FAQ
- To get one common palette for multiple images (e.g. frames of the animation), concatenate them into one array `data`.
- When working with less than four components, set the remaining components to a constant value (e.g. to zero)
- When working with transparency, premultiply color components by transparency (otherwise, rgba(1,1,1,0) would be closer to rgba(1,1,1,1) than to rgba(0,0,0,0) - transparent mapped to white instead of transparent)

1027
api-filigrane/node_modules/@pdf-lib/upng/UPNG.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

2017
api-filigrane/node_modules/@pdf-lib/upng/cjs/UPNG.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

7832
api-filigrane/node_modules/@pdf-lib/upng/dist/UPNG.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

7832
api-filigrane/node_modules/@pdf-lib/upng/dist/UPNG.min.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

88
api-filigrane/node_modules/@pdf-lib/upng/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,88 @@
// ------------------------------------------- //
// //
// Copied from: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/upng-js/index.d.ts
// //
// ------------------------------------------- //
// Type definitions for upng-js 2.1
// Project: https://github.com/photopea/UPNG.js
// Definitions by: York Yao <https://github.com/plantain-00>, Sophie Kirschner <https://github.com/pineapplemachine>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface ImageFrameRect {
x: number;
y: number;
width: number;
height: number;
}
export interface ImageFrame {
rect: ImageFrameRect;
delay: number;
dispose: number;
blend: number;
}
export interface ImageTabACTL {
num_frames: number;
num_plays: number;
}
export interface ImageTabText {
[key: string]: string;
}
export interface ImageTabs {
acTL?: ImageTabACTL;
pHYs?: number[];
cHRM?: number[];
tEXt?: ImageTabText;
iTXt?: ImageTabText;
PLTE?: number[];
hIST?: number[];
tRNS?: number | number[]; // Depends on ctype
gAMA?: number;
sRGB?: number;
bKGD?: number | number[]; // Depends on ctype
}
export interface Image {
width: number;
height: number;
depth: number;
ctype: number;
frames: ImageFrame[];
tabs: ImageTabs;
data: ArrayBuffer;
}
export interface QuantizeResult {
abuf: ArrayBuffer;
inds: Uint8Array;
// Type is complicated and I am too lazy to work it out right now, sorry!
plte: any[];
}
export function encode(
imgs: ArrayBuffer[],
w: number,
h: number,
cnum: number,
dels?: number[],
): ArrayBuffer;
export function encodeLL(
imgs: ArrayBuffer[],
w: number,
h: number,
cc: number,
ac: number,
depth: number,
dels?: number[],
): ArrayBuffer;
export function decode(buffer: ArrayBuffer): Image;
export function toRGBA8(out: Image): ArrayBuffer[];
export function quantize(data: ArrayBuffer, psize: number): QuantizeResult;

54
api-filigrane/node_modules/@pdf-lib/upng/package.json generated vendored Normal file
View File

@ -0,0 +1,54 @@
{
"name": "@pdf-lib/upng",
"license": "MIT",
"version": "1.0.1",
"description": "Small, fast and advanced PNG / APNG encoder and decoder",
"main": "cjs/UPNG.js",
"unpkg": "dist/UPNG.min.js",
"module": "UPNG.js",
"types": "index.d.ts",
"files": [
"cjs/",
"dist/",
"UPNG.js",
"index.d.ts",
"LICENSE.md",
"package.json",
"README.md",
"yarn.lock"
],
"scripts": {
"build": "yarn build:cjs && yarn build:umd && yarn build:umd:min",
"build:cjs": "babel --plugins @babel/plugin-transform-modules-commonjs --out-dir cjs UPNG.js",
"build:umd": "rollup --config rollup.config.js --file dist/UPNG.js",
"build:umd:min": "rollup --config rollup.config.js --file dist/UPNG.min.js --environment MINIFY"
},
"repository": {
"type": "git",
"url": "https://github.com/Hopding/upng"
},
"author": "photopea (https://github.com/photopea)",
"contributors": [
"Andrew Dillon (https://github.com/Hopding)",
"Scimonster (https://github.com/Scimonster)"
],
"bugs": "https://github.com/Hopding/upng/issues",
"keywords": [
"png",
"apng",
"image",
"conversion"
],
"dependencies": {
"pako": "^1.0.10"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.4",
"@babel/plugin-transform-modules-commonjs": "^7.8.3",
"@rollup/plugin-commonjs": "^11.0.0",
"@rollup/plugin-node-resolve": "^7.1.1",
"rollup": "^1.31.1",
"rollup-plugin-terser": "^5.1.3"
}
}

1423
api-filigrane/node_modules/@pdf-lib/upng/yarn.lock generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _applyDecoratedDescriptor;
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
var desc1 = {};
Object['ke' + 'ys'](descriptor).forEach(function(key) {
desc1[key] = descriptor[key];
});
desc1.enumerable = !!desc1.enumerable;
desc1.configurable = !!desc1.configurable;
if ('value' in desc1 || desc1.initializer) {
desc1.writable = true;
}
desc1 = decorators.slice().reverse().reduce(function(desc, decorator) {
return decorator ? decorator(target, property, desc) || desc : desc;
}, desc1);
var hasAccessor = Object.prototype.hasOwnProperty.call(desc1, 'get') || Object.prototype.hasOwnProperty.call(desc1, 'set');
if (context && desc1.initializer !== void 0 && !hasAccessor) {
desc1.value = desc1.initializer ? desc1.initializer.call(context) : void 0;
desc1.initializer = undefined;
}
if (hasAccessor) {
delete desc1.writable;
delete desc1.initializer;
delete desc1.value;
}
if (desc1.initializer === void 0) {
Object['define' + 'Property'](target, property, desc1);
desc1 = null;
}
return desc1;
}

View File

@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _arrayLikeToArray;
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
return arr2;
}

View File

@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _arrayWithHoles;
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}

View File

@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _arrayWithoutHoles;
var _arrayLikeToArray = _interopRequireDefault(require("./_array_like_to_array"));
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return (0, _arrayLikeToArray).default(arr);
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}

View File

@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _assertThisInitialized;
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}

View File

@ -0,0 +1,92 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = AsyncGenerator;
var _awaitValue = _interopRequireDefault(require("./_await_value"));
function AsyncGenerator(gen) {
var front, back;
function send(key, arg) {
return new Promise(function(resolve, reject) {
var request = {
key: key,
arg: arg,
resolve: resolve,
reject: reject,
next: null
};
if (back) {
back = back.next = request;
} else {
front = back = request;
resume(key, arg);
}
});
}
function resume(key, arg1) {
try {
var result = gen[key](arg1);
var value = result.value;
var wrappedAwait = value instanceof _awaitValue.default;
Promise.resolve(wrappedAwait ? value.wrapped : value).then(function(arg) {
if (wrappedAwait) {
resume("next", arg);
return;
}
settle(result.done ? "return" : "normal", arg);
}, function(err) {
resume("throw", err);
});
} catch (err) {
settle("throw", err);
}
}
function settle(type, value) {
switch(type){
case "return":
front.resolve({
value: value,
done: true
});
break;
case "throw":
front.reject(value);
break;
default:
front.resolve({
value: value,
done: false
});
break;
}
front = front.next;
if (front) {
resume(front.key, front.arg);
} else {
back = null;
}
}
this._invoke = send;
if (typeof gen.return !== "function") {
this.return = undefined;
}
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
if (typeof Symbol === "function" && Symbol.asyncIterator) {
AsyncGenerator.prototype[Symbol.asyncIterator] = function() {
return this;
};
}
AsyncGenerator.prototype.next = function(arg) {
return this._invoke("next", arg);
};
AsyncGenerator.prototype.throw = function(arg) {
return this._invoke("throw", arg);
};
AsyncGenerator.prototype.return = function(arg) {
return this._invoke("return", arg);
};

View File

@ -0,0 +1,45 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _asyncGeneratorDelegate;
function _asyncGeneratorDelegate(inner, awaitWrap) {
var iter = {}, waiting = false;
function pump(key, value) {
waiting = true;
value = new Promise(function(resolve) {
resolve(inner[key](value));
});
return {
done: false,
value: awaitWrap(value)
};
}
if (typeof Symbol === "function" && Symbol.iterator) {
iter[Symbol.iterator] = function() {
return this;
};
}
iter.next = function(value) {
if (waiting) {
waiting = false;
return value;
}
return pump("next", value);
};
if (typeof inner.throw === "function") {
iter.throw = function(value) {
if (waiting) {
waiting = false;
throw value;
}
return pump("throw", value);
};
}
if (typeof inner.return === "function") {
iter.return = function(value) {
return pump("return", value);
};
}
return iter;
}

View File

@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _asyncIterator;
function _asyncIterator(iterable) {
var method;
if (typeof Symbol === "function") {
if (Symbol.asyncIterator) {
method = iterable[Symbol.asyncIterator];
if (method != null) return method.call(iterable);
}
if (Symbol.iterator) {
method = iterable[Symbol.iterator];
if (method != null) return method.call(iterable);
}
}
throw new TypeError("Object is not async iterable");
}

View File

@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _asyncToGenerator;
function _asyncToGenerator(fn) {
return function() {
var self = this, args = arguments;
return new Promise(function(resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}

View File

@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _awaitAsyncGenerator;
var _awaitValue = _interopRequireDefault(require("./_await_value"));
function _awaitAsyncGenerator(value) {
return new _awaitValue.default(value);
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}

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