Initial commit - Upload .NET MVC Project
commit
0190563c9a
|
@ -0,0 +1,8 @@
|
||||||
|
bin/
|
||||||
|
obj/
|
||||||
|
publish/
|
||||||
|
wwwroot/lib/
|
||||||
|
appsettings.Development.json
|
||||||
|
*.user
|
||||||
|
*.db
|
||||||
|
node_modules/
|
|
@ -0,0 +1,17 @@
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace eSPJ.Controllers
|
||||||
|
{
|
||||||
|
[Route("detail-penjemputan")]
|
||||||
|
public class DetailPenjemputanController : Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
[HttpGet("")]
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
using System.Diagnostics;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using eSPJ.Models;
|
||||||
|
|
||||||
|
namespace eSPJ.Controllers;
|
||||||
|
|
||||||
|
public class HomeController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger<HomeController> _logger;
|
||||||
|
|
||||||
|
public HomeController(ILogger<HomeController> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult Privacy()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
|
public IActionResult Error()
|
||||||
|
{
|
||||||
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace eSPJ.Controllers
|
||||||
|
{
|
||||||
|
[Route("profil")]
|
||||||
|
public class ProfilController : Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
[HttpGet("")]
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
namespace eSPJ.Models;
|
||||||
|
|
||||||
|
public class ErrorViewModel
|
||||||
|
{
|
||||||
|
public string? RequestId { get; set; }
|
||||||
|
|
||||||
|
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
// Add services to the container.
|
||||||
|
builder.Services.AddControllersWithViews();
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
// Configure the HTTP request pipeline.
|
||||||
|
if (!app.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.UseExceptionHandler("/Home/Error");
|
||||||
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||||
|
app.UseHsts();
|
||||||
|
}
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
app.UseRouting();
|
||||||
|
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.MapStaticAssets();
|
||||||
|
|
||||||
|
app.MapControllerRoute(
|
||||||
|
name: "default",
|
||||||
|
pattern: "{controller=Home}/{action=Index}/{id?}")
|
||||||
|
.WithStaticAssets();
|
||||||
|
|
||||||
|
|
||||||
|
app.Run();
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"profiles": {
|
||||||
|
"http": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"applicationUrl": "http://localhost:5002",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"https": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"applicationUrl": "https://localhost:7193;http://localhost:5002",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Detail Penjemputan";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="max-w-sm mx-auto bg-white min-h-screen">
|
||||||
|
<!-- Header -->
|
||||||
|
<div class="bg-orange-500 text-white px-4 py-6 rounded-b-3xl relative pb-12">
|
||||||
|
<div class="flex items-center justify-center relative">
|
||||||
|
<a href="@Url.Action("Index", "Home")" class="absolute left-0">
|
||||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||||
|
<polyline points="15,18 9,12 15,6"></polyline>
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
<h1 class="text-xl font-bold">Detail Lokasi</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- License Plate - Overlapping -->
|
||||||
|
<div class="flex justify-center -mt-10 mb-6 relative">
|
||||||
|
<div class="bg-orange-100 border border-orange-400 px-4 py-2 rounded-xl shadow flex flex-col items-center">
|
||||||
|
<span class="text-green-700 font-bold text-lg">B 9632 TOR</span>
|
||||||
|
<span class="text-orange-500 text-xs mt-1">(JRC 005)</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Content -->
|
||||||
|
<div class="px-6 space-y-3">
|
||||||
|
<!-- Status Badge -->
|
||||||
|
<div class="flex justify-center">
|
||||||
|
<span class="inline-flex items-center px-4 py-1 bg-gradient-to-r from-green-500 to-green-400 text-white rounded-full text-xs font-semibold shadow-md">
|
||||||
|
PENGANGKUTAN
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Company Info -->
|
||||||
|
<div class="text-center space-y-2">
|
||||||
|
<h2 class="text-xl font-extrabold text-gray-800 tracking-wide drop-shadow">CV Tri Berkah Sejahtera</h2>
|
||||||
|
<p class="text-gray-500 text-sm bg-gray-100 rounded px-2 py-1 inline-block shadow">SPJ/07-2025/PKM/000476</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Address -->
|
||||||
|
<div class="space-y-2">
|
||||||
|
<h3 class="font-semibold text-gray-800 text-center tracking-wider">Alamat</h3>
|
||||||
|
<p class="text-gray-600 text-sm text-center leading-relaxed px-4">
|
||||||
|
Kp. Pertanian II Rt.004 Rw.001 Kel. Klender Kec, Duren Sawit, Kota Adm. Jakarta Timur 13470
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Odometer Section -->
|
||||||
|
<div class="space-y-6">
|
||||||
|
<h3 class="font-bold text-gray-800 text-center text-lg tracking-wide">Masukkan Odometer</h3>
|
||||||
|
<div class="flex justify-center">
|
||||||
|
<div class="relative flex items-center justify-center">
|
||||||
|
<img src="@Url.Content("~/odo_simple.svg")" class="overflow-visible drop-shadow-lg scale-110" alt="">
|
||||||
|
<!-- Digital display -->
|
||||||
|
<div class="absolute bottom-8 left-1/2 transform -translate-x-1/2">
|
||||||
|
<input type="text" maxlength="6" class="bg-gray-900 text-green-400 px-4 py-2 rounded-lg text-lg font-mono tracking-widest text-center w-36 outline-none border-2 border-green-400 focus:ring-2 focus:ring-orange-400 transition" placeholder="000000" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Submit Button -->
|
||||||
|
<div class="pt-6">
|
||||||
|
<button class="w-full bg-gradient-to-r from-orange-500 to-orange-400 text-white py-3 rounded-xl font-bold text-lg shadow-xl hover:scale-105 hover:bg-orange-600 transition-all duration-200 flex items-center justify-center gap-2">
|
||||||
|
|
||||||
|
Submit
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<partial name="~/Views/Shared/Components/_Navigation.cshtml" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<register-block dynamic-section="scripts" key="jsDetailPenjemputan">
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
var odoInput = document.querySelector('input[maxlength="6"]');
|
||||||
|
if (odoInput) {
|
||||||
|
odoInput.addEventListener('focus', function() {
|
||||||
|
setTimeout(function() {
|
||||||
|
odoInput.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||||
|
}, 300); // delay agar keyboard muncul dulu
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</register-block>
|
|
@ -0,0 +1,167 @@
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Home Page";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="container max-w-sm mx-auto bg-white min-h-screen">
|
||||||
|
|
||||||
|
<!-- Header -->
|
||||||
|
<div class="absolute top-0 max-w-sm container mx-auto bg-orange-500 text-white rounded-br-[125px] h-[250px] flex flex-row justify-between items-start px-6 py-6 shadow-lg z-20">
|
||||||
|
<div class="flex flex-col gap-1">
|
||||||
|
@* <div class="flex items-center gap-2 text-base font-medium">
|
||||||
|
<span>Hallo</span>
|
||||||
|
<span>👋</span>
|
||||||
|
</div>
|
||||||
|
<h1 class="text-xl font-bold leading-tight">Bonny Agung Putra</h1>
|
||||||
|
<p class="text-base opacity-90">Driver UPST</p> *@
|
||||||
|
<!-- Your Location -->
|
||||||
|
<p class="text-sm mt-2 opacity-90">Your Location:</p>
|
||||||
|
<p id="userLocation" class="font-semibold text-sm tracking-wide cursor-pointer underline">
|
||||||
|
Mendeteksi lokasi...
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center justify-center">
|
||||||
|
<div class="w-14 h-14 rounded-full border-4 border-white overflow-hidden shadow-md">
|
||||||
|
<img src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=100&h=100&fit=crop&crop=face" alt="Profile" class="w-full h-full object-cover">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- SPJ Data Card -->
|
||||||
|
<div class="bg-green-500 text-white mx-4 px-6 py-6 mt-32 rounded-2xl relative overflow-hidden shadow-lg z-21">
|
||||||
|
<!-- Background pattern -->
|
||||||
|
<div class="absolute right-0 bottom-0 opacity-30 pointer-events-none select-none" style="width: 160px; height: 160px;">
|
||||||
|
<img src="@Url.Content("~/tree.svg")" alt="tree" class="w-full h-full object-contain">
|
||||||
|
</div>
|
||||||
|
<div class="relative z-10">
|
||||||
|
<div class="flex justify-between items-center mb-4">
|
||||||
|
<h2 class="text-xl font-bold">Data SPJ</h2>
|
||||||
|
<div class="flex flex-col items-end">
|
||||||
|
<div class="bg-white text-green-600 px-4 py-2 rounded-full text-base font-bold shadow-md flex items-center gap-2">
|
||||||
|
<span>B 9632 TOR</span>
|
||||||
|
</div>
|
||||||
|
<div class="text-xs text-white mt-1 font-semibold tracking-wide opacity-80">(JRC 005)</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="space-y-1 mt-2">
|
||||||
|
<p class="text-sm opacity-90">No. SPJ</p>
|
||||||
|
<p class="font-bold text-lg tracking-wide">SPJ/07-2025/PKM/000476</p>
|
||||||
|
<p class="text-sm opacity-90 mt-3">Tujuan Pembuangan</p>
|
||||||
|
<p class="font-bold text-lg tracking-wide">Taman Barito</p>
|
||||||
|
</div>
|
||||||
|
<!-- DLH logo -->
|
||||||
|
<div class="absolute bottom-2 right-4 opacity-80" style="width: 48px; height: 48px;">
|
||||||
|
<img src="@Url.Content("~/dlh_type.svg")" alt="DLH Logo" class="w-full h-full object-contain">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Pickup Locations -->
|
||||||
|
<div class="px-4 mt-8">
|
||||||
|
<div class="flex justify-between items-center mb-4">
|
||||||
|
<h3 class="text-lg font-semibold text-gray-800">Lokasi Pengangkutan</h3>
|
||||||
|
<button class="bg-gray-400 text-white px-4 py-1 rounded-full text-sm">
|
||||||
|
Selesai
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Location 1 - Completed -->
|
||||||
|
<a href="@Url.Action("Index", "DetailPenjemputan")" class="hover:cursor-pointer">
|
||||||
|
<div class="bg-green-100 border border-green-200 rounded-lg p-4 mb-3 relative">
|
||||||
|
<div class="flex justify-between items-start">
|
||||||
|
<div class="flex-1">
|
||||||
|
<span class="inline-block bg-green-500 text-white text-xs font-semibold px-3 py-1 rounded-full mb-1">Sudah Diangkut</span>
|
||||||
|
<h4 class="font-semibold text-gray-800 mb-2">CV Tri Berkah Sejahtera</h4>
|
||||||
|
<p class="text-sm text-gray-600 mb-1">Alamat</p>
|
||||||
|
<p class="text-sm text-gray-700">
|
||||||
|
Kp. Pertanian II Rt.004 Rw.001 Kel. Klender Kec, Duren Sawit, Kota Adm. Jakarta Timur 13470
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="ml-4">
|
||||||
|
<div class="w-8 h-8 bg-green-500 rounded-full flex items-center justify-center">
|
||||||
|
<i class="w-5 h-5 text-white" data-lucide="circle-check"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<!-- Location 2 - Pending -->
|
||||||
|
<div class="bg-white border border-gray-200 rounded-lg p-4 mb-6 relative">
|
||||||
|
<div class="flex justify-between items-start">
|
||||||
|
<div class="flex-1">
|
||||||
|
<span class="inline-block bg-yellow-400 text-white text-xs font-semibold px-3 py-1 rounded-full mb-1">Pengangkutan</span>
|
||||||
|
<h4 class="font-semibold text-gray-800 mb-2">CV Tri Mitra Utama</h4>
|
||||||
|
<p class="text-sm text-gray-600 mb-1">Shell Radio Dalam</p>
|
||||||
|
<p class="text-sm text-gray-600 mb-1">Alamat</p>
|
||||||
|
<p class="text-sm text-gray-700">
|
||||||
|
Jl. Radio Dalam Raya No.6C Gandaria Utara, Kecamatan Kebayoran Baru, Kota Jakarta Selatan 12140
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="ml-4">
|
||||||
|
<div class="w-8 h-8 border-2 border-gray-300 rounded-full flex items-center justify-center">
|
||||||
|
<i class="w-5 h-5 text-gray-400" data-lucide="circle-ellipsis"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Bottom Navigation -->
|
||||||
|
<partial name="~/Views/Shared/Components/_Navigation.cshtml" />
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<register-block dynamic-section="scripts" key="jsHomeIndex">
|
||||||
|
<script>
|
||||||
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
const userLocationEl = document.getElementById("userLocation");
|
||||||
|
|
||||||
|
function reverseGeocode(lat, lng) {
|
||||||
|
fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${lat}&lon=${lng}`)
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(data => {
|
||||||
|
const address = data.display_name || `${lat}, ${lng}`;
|
||||||
|
userLocationEl.textContent = address;
|
||||||
|
localStorage.setItem("user_latitude", lat);
|
||||||
|
localStorage.setItem("user_longitude", lng);
|
||||||
|
localStorage.setItem("user_address", address);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
userLocationEl.textContent = `${lat}, ${lng}`;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLocationUpdate() {
|
||||||
|
if ("geolocation" in navigator) {
|
||||||
|
userLocationEl.textContent = "Mendeteksi lokasi baru...";
|
||||||
|
navigator.geolocation.getCurrentPosition(
|
||||||
|
function (position) {
|
||||||
|
const lat = position.coords.latitude.toFixed(6);
|
||||||
|
const lng = position.coords.longitude.toFixed(6);
|
||||||
|
reverseGeocode(lat, lng);
|
||||||
|
},
|
||||||
|
function () {
|
||||||
|
userLocationEl.textContent = "Lokasi tidak diizinkan";
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
userLocationEl.textContent = "Browser tidak mendukung lokasi";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ambil dari localStorage jika ada
|
||||||
|
const savedAddress = localStorage.getItem("user_address");
|
||||||
|
if (savedAddress) {
|
||||||
|
userLocationEl.textContent = savedAddress;
|
||||||
|
} else {
|
||||||
|
getLocationUpdate(); // Pertama kali ambil lokasi
|
||||||
|
}
|
||||||
|
|
||||||
|
// ✅ Klik untuk update lokasi
|
||||||
|
userLocationEl.addEventListener("click", function () {
|
||||||
|
getLocationUpdate();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</register-block>
|
|
@ -0,0 +1,6 @@
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Privacy Policy";
|
||||||
|
}
|
||||||
|
<h1>@ViewData["Title"]</h1>
|
||||||
|
|
||||||
|
<p>Use this page to detail your site's privacy policy.</p>
|
|
@ -0,0 +1,103 @@
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Profil Page";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="max-w-sm mx-auto bg-white min-h-screen">
|
||||||
|
<!-- Header with Orange Background -->
|
||||||
|
<div class="bg-orange-500 text-white px-3 py-4 rounded-b-2xl relative pb-12">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<button class="p-1 hover:bg-white/10 rounded-full transition-colors">
|
||||||
|
<i class="w-5 h-5" data-lucide="chevron-left"></i>
|
||||||
|
</button>
|
||||||
|
<h1 class="text-lg font-bold">Profil</h1>
|
||||||
|
<div class="w-8"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Profile Picture Section - Overlapping -->
|
||||||
|
<div class="flex justify-center -mt-12 mb-6 relative z-10">
|
||||||
|
<div class="relative">
|
||||||
|
<!-- Profile Picture -->
|
||||||
|
<div class="w-20 h-20 rounded-full border-2 border-white shadow-xl overflow-hidden bg-gray-200">
|
||||||
|
<img src="https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=100&h=100&fit=crop&crop=face"
|
||||||
|
alt="Profile Picture"
|
||||||
|
class="w-full h-full object-cover">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Edit Icon -->
|
||||||
|
<button class="absolute bottom-1 right-1 w-7 h-7 bg-white rounded-full shadow-lg flex items-center justify-center border border-gray-100 hover:bg-gray-50 transition-colors">
|
||||||
|
<i class="w-4 h-4 text-gray-600" data-lucide="edit-2"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Profile Content -->
|
||||||
|
<div class="p-4 space-y-4 bg-white border border-gray-200 mx-4 rounded-2xl">
|
||||||
|
<!-- Info Akun Header -->
|
||||||
|
<div class="flex justify-between items-center">
|
||||||
|
<h2 class="text-lg font-bold text-gray-800">Info Akun</h2>
|
||||||
|
<button class="text-orange-500 font-medium hover:text-orange-600 transition-colors text-sm">
|
||||||
|
Ubah
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Profile Information -->
|
||||||
|
<div class="space-y-4">
|
||||||
|
<!-- Nama -->
|
||||||
|
<div class="flex items-start gap-3">
|
||||||
|
<div class="w-8 h-8 bg-gray-100 rounded-full flex items-center justify-center flex-shrink-0 mt-1">
|
||||||
|
<i class="w-4 h-4 text-gray-600" data-lucide="user"></i>
|
||||||
|
</div>
|
||||||
|
<div class="flex-1">
|
||||||
|
<p class="text-xs text-gray-500 mb-0.5">Nama</p>
|
||||||
|
<p class="text-base font-semibold text-gray-800">Bonny Agung Putra</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Email -->
|
||||||
|
<div class="flex items-start gap-3">
|
||||||
|
<div class="w-8 h-8 bg-gray-100 rounded-full flex items-center justify-center flex-shrink-0 mt-1">
|
||||||
|
<i class="w-4 h-4 text-gray-600" data-lucide="mail"></i>
|
||||||
|
</div>
|
||||||
|
<div class="flex-1">
|
||||||
|
<p class="text-xs text-gray-500 mb-0.5">E-mail</p>
|
||||||
|
<p class="text-base font-semibold text-gray-800">bonny@gmail.com</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Phone -->
|
||||||
|
<div class="flex items-start gap-3">
|
||||||
|
<div class="w-8 h-8 bg-gray-100 rounded-full flex items-center justify-center flex-shrink-0 mt-1">
|
||||||
|
<i class="w-4 h-4 text-gray-600" data-lucide="phone"></i>
|
||||||
|
</div>
|
||||||
|
<div class="flex-1">
|
||||||
|
<p class="text-xs text-gray-500 mb-0.5">No. HP</p>
|
||||||
|
<p class="text-base font-semibold text-gray-800">+6285777777777</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Address -->
|
||||||
|
<div class="flex items-start gap-3">
|
||||||
|
<div class="w-8 h-8 bg-gray-100 rounded-full flex items-center justify-center flex-shrink-0 mt-1">
|
||||||
|
<i class="w-4 h-4 text-gray-600" data-lucide="map-pin"></i>
|
||||||
|
</div>
|
||||||
|
<div class="flex-1">
|
||||||
|
<p class="text-xs text-gray-500 mb-0.5">Alamat</p>
|
||||||
|
<p class="text-base font-semibold text-gray-800 leading-relaxed">
|
||||||
|
Kp. Pertanian II Rt 004 Rw 001 Kel. Klender Kec, Duren Swakit, Kota Adm. Jakarta Timur 13470
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- Logout Button -->
|
||||||
|
<div class="mx-4 pt-4 pb-4">
|
||||||
|
<button class="w-full bg-orange-500 hover:bg-orange-600 text-white py-3 rounded-xl font-bold text-base shadow-lg transition-all duration-200 hover:scale-105">
|
||||||
|
Keluar
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<partial name="~/Views/Shared/Components/_Navigation.cshtml" />
|
||||||
|
</div>
|
|
@ -0,0 +1,129 @@
|
||||||
|
<div class="fixed bottom-0 left-1/2 transform -translate-x-1/2 w-full max-w-sm z-99">
|
||||||
|
<!-- Navigation Bar with Curved Inward Notch -->
|
||||||
|
<div class="relative backdrop-blur-lg border border-gray-200/50 rounded-t-3xl shadow-xl overflow-hidden">
|
||||||
|
<!-- Curved Notch using CSS -->
|
||||||
|
<div class="absolute -top-0 left-1/2 transform -translate-x-1/2 w-20 h-10">
|
||||||
|
<div class="w-full h-full bg-transparent relative">
|
||||||
|
<!-- Left curve -->
|
||||||
|
<div class="absolute left-0 top-0 w-10 h-10 backdrop-blur-lg rounded-br-full"></div>
|
||||||
|
<!-- Right curve -->
|
||||||
|
<div class="absolute right-0 top-0 w-10 h-10 backdrop-blur-lg rounded-bl-full"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Navigation Content -->
|
||||||
|
<div class="flex justify-between items-center px-8 relative pt-6">
|
||||||
|
<!-- Home Button -->
|
||||||
|
<a href="@Url.Action("Index", "Home")" class="flex flex-col items-center gap-1 px-4 py-2 transition-all duration-300 hover:scale-105 group">
|
||||||
|
<div class="relative">
|
||||||
|
<i class="w-6 h-6 text-gray-400 group-hover:text-orange-500 transition-colors duration-300" data-lucide="home"></i>
|
||||||
|
<div class="absolute -bottom-0.5 left-1/2 transform -translate-x-1/2 w-0 h-0.5 bg-orange-500 group-hover:w-full transition-all duration-300"></div>
|
||||||
|
</div>
|
||||||
|
<span class="text-xs text-gray-600 group-hover:text-orange-500 font-medium transition-colors duration-300">Home</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<!-- Spacer for center FAB -->
|
||||||
|
<div class="w-12"></div>
|
||||||
|
|
||||||
|
<!-- Profile Button -->
|
||||||
|
|
||||||
|
<a href="@Url.Action("Index", "Profil")" class="flex flex-col items-center gap-1 px-4 py-2 transition-all duration-300 hover:scale-105 group">
|
||||||
|
<div class="relative">
|
||||||
|
<i class="w-6 h-6 text-gray-400 group-hover:text-orange-500 transition-colors duration-300" data-lucide="user"></i>
|
||||||
|
<div class="absolute -bottom-0.5 left-1/2 transform -translate-x-1/2 w-0 h-0.5 bg-orange-500 group-hover:w-full transition-all duration-300"></div>
|
||||||
|
</div>
|
||||||
|
<span class="text-xs text-gray-600 group-hover:text-orange-500 font-medium transition-colors duration-300">Profile</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Center Floating Action Button in Curved Notch -->
|
||||||
|
<div class="absolute -top-4 left-1/2 transform -translate-x-1/2">
|
||||||
|
<button id="truckBtn" class="w-14 h-14 bg-gradient-to-br from-orange-500 via-orange-400 to-orange-600 rounded-full shadow-xl flex items-center justify-center transition-all duration-300 hover:scale-110 hover:rotate-6 border-4 border-white ring-2 ring-orange-200">
|
||||||
|
<i class="w-6 h-6 text-white" data-lucide="truck"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="h-40"></div>
|
||||||
|
<!-- Modal Overlay -->
|
||||||
|
<div id="modalOverlay" class="fixed inset-0 bg-black/50 backdrop-blur-sm z-50 opacity-0 invisible transition-all duration-300 flex items-center justify-center">
|
||||||
|
<!-- Modal Content -->
|
||||||
|
<div id="modalContent" class="transform scale-95 opacity-0 transition-all duration-300 ease-out max-w-sm w-full mx-4">
|
||||||
|
<div class="bg-green-500 text-white px-6 py-6 rounded-2xl relative overflow-hidden shadow-2xl">
|
||||||
|
<!-- Background pattern -->
|
||||||
|
<div class="absolute right-0 bottom-0 opacity-30 pointer-events-none select-none" style="width: 160px; height: 160px;">
|
||||||
|
<!-- Tree SVG placeholder -->
|
||||||
|
<div class="w-full h-full bg-green-400/20 rounded-full flex items-center justify-center">
|
||||||
|
<img src="@Url.Content("~/tree.svg")" alt="tree" class="w-full h-full object-contain">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="relative z-10">
|
||||||
|
<div class="flex justify-between items-center mb-4">
|
||||||
|
<h2 class="text-xl font-bold">Data SPJ</h2>
|
||||||
|
<div class="flex flex-col items-end mt-8">
|
||||||
|
<div class="bg-white text-green-600 px-4 py-2 rounded-full text-base font-bold shadow-md flex items-center gap-2">
|
||||||
|
<span>B 9632 TOR</span>
|
||||||
|
</div>
|
||||||
|
<div class="text-xs text-white mt-1 font-semibold tracking-wide opacity-80">(JRC 005)</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="space-y-1 mt-2">
|
||||||
|
<p class="text-sm opacity-90">No. SPJ</p>
|
||||||
|
<p class="font-bold text-lg tracking-wide">SPJ/07-2025/PKM/000476</p>
|
||||||
|
<p class="text-sm opacity-90 mt-3">Tujuan Pembuangan</p>
|
||||||
|
<p class="font-bold text-lg tracking-wide">Taman Barito</p>
|
||||||
|
</div>
|
||||||
|
<!-- DLH logo -->
|
||||||
|
<div class="absolute bottom-2 right-4 opacity-80" style="width: 48px; height: 48px;">
|
||||||
|
<!-- DLH Logo placeholder -->
|
||||||
|
<div class="w-full h-full flex items-center justify-center">
|
||||||
|
<img src="@Url.Content("~/dlh_type.svg")" alt="DLH Logo" class="w-full h-full object-contain">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Close button -->
|
||||||
|
<button id="closeModal" class="absolute top-4 right-4 w-8 h-8 bg-white/20 hover:bg-white/30 rounded-full flex items-center justify-center transition-colors duration-200 hover:cursor-pointer">
|
||||||
|
<i class="w-4 h-4 text-white" data-lucide="x"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<register-block dynamic-section="scripts" key="jsNav">
|
||||||
|
<script>
|
||||||
|
|
||||||
|
// Modal functionality
|
||||||
|
const truckBtn = document.getElementById('truckBtn');
|
||||||
|
const modalOverlay = document.getElementById('modalOverlay');
|
||||||
|
const modalContent = document.getElementById('modalContent');
|
||||||
|
const closeModal = document.getElementById('closeModal');
|
||||||
|
|
||||||
|
// Show modal
|
||||||
|
truckBtn.addEventListener('click', () => {
|
||||||
|
modalOverlay.classList.remove('opacity-0', 'invisible');
|
||||||
|
modalOverlay.classList.add('opacity-100', 'visible');
|
||||||
|
modalContent.classList.remove('scale-95', 'opacity-0');
|
||||||
|
modalContent.classList.add('scale-100', 'opacity-100');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Hide modal
|
||||||
|
function hideModal() {
|
||||||
|
modalOverlay.classList.remove('opacity-100', 'visible');
|
||||||
|
modalOverlay.classList.add('opacity-0', 'invisible');
|
||||||
|
modalContent.classList.remove('scale-100', 'opacity-100');
|
||||||
|
modalContent.classList.add('scale-95', 'opacity-0');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close modal events
|
||||||
|
closeModal.addEventListener('click', hideModal);
|
||||||
|
modalOverlay.addEventListener('click', (e) => {
|
||||||
|
if (e.target === modalOverlay) {
|
||||||
|
hideModal();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</register-block>
|
|
@ -0,0 +1,26 @@
|
||||||
|
<!-- Status Bar -->
|
||||||
|
<div class="flex justify-between items-center px-4 py-2 text-sm bg-slate-800/50 backdrop-blur-sm">
|
||||||
|
<div class="flex items-center space-x-2">
|
||||||
|
<span class="font-semibold">13:33</span>
|
||||||
|
<div class="flex space-x-1">
|
||||||
|
<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
|
||||||
|
<path d="M2 3a1 1 0 011-1h2.153a1 1 0 01.986.836l.74 4.435a1 1 0 01-.54 1.06l-1.548.773a11.037 11.037 0 006.105 6.105l.774-1.548a1 1 0 011.059-.54l4.435.74a1 1 0 01.836.986V17a1 1 0 01-1 1h-2C7.82 18 2 12.18 2 5V3z"/>
|
||||||
|
</svg>
|
||||||
|
<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
|
||||||
|
<path fill-rule="evenodd" d="M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z" clip-rule="evenodd"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center space-x-2 text-xs">
|
||||||
|
<span>4G</span>
|
||||||
|
<div class="flex space-x-1">
|
||||||
|
<div class="w-1 h-3 bg-white rounded-full"></div>
|
||||||
|
<div class="w-1 h-4 bg-white rounded-full"></div>
|
||||||
|
<div class="w-1 h-3 bg-white rounded-full"></div>
|
||||||
|
<div class="w-1 h-2 bg-white/50 rounded-full"></div>
|
||||||
|
</div>
|
||||||
|
<div class="w-6 h-3 border border-white rounded-sm">
|
||||||
|
<div class="w-4 h-full bg-green-400 rounded-sm"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -0,0 +1,25 @@
|
||||||
|
@model ErrorViewModel
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Error";
|
||||||
|
}
|
||||||
|
|
||||||
|
<h1 class="text-danger">Error.</h1>
|
||||||
|
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||||
|
|
||||||
|
@if (Model.ShowRequestId)
|
||||||
|
{
|
||||||
|
<p>
|
||||||
|
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
|
||||||
|
<h3>Development Mode</h3>
|
||||||
|
<p>
|
||||||
|
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
|
||||||
|
It can result in displaying sensitive information from exceptions to end users.
|
||||||
|
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
|
||||||
|
and restarting the app.
|
||||||
|
</p>
|
|
@ -0,0 +1,63 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>@ViewData["Title"] - eSPJ</title>
|
||||||
|
<script type="importmap"></script>
|
||||||
|
|
||||||
|
<!-- Theme Colors -->
|
||||||
|
<meta name="theme-color" content="#f97316">
|
||||||
|
<meta name="msapplication-navbutton-color" content="#f97316">
|
||||||
|
<meta name="apple-mobile-web-app-status-bar-style" content="default">
|
||||||
|
|
||||||
|
<!-- Mobile Optimization -->
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||||
|
<meta name="mobile-web-app-capable" content="yes">
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
|
<meta name="apple-mobile-web-app-title" content="SPJ Angkut">
|
||||||
|
|
||||||
|
<!-- iOS Icons -->
|
||||||
|
<link rel="apple-touch-icon" href="~/icons/icon-152x152.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="180x180" href="~/icons/icon-180x180.png">
|
||||||
|
|
||||||
|
<!-- Windows Tiles -->
|
||||||
|
<meta name="msapplication-TileImage" content="/icons/icon-144x144.png">
|
||||||
|
<meta name="msapplication-TileColor" content="#f97316">
|
||||||
|
|
||||||
|
<link rel="manifest" href="~/manifest.json" />
|
||||||
|
@* <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" /> *@
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Inter+Tight:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="~/css/watch.css" asp-append-version="true" />
|
||||||
|
<link rel="stylesheet" href="~/css/website.css" asp-append-version="true" />
|
||||||
|
<link rel="stylesheet" href="~/eSPJ.styles.css" asp-append-version="true" />
|
||||||
|
@await RenderSectionAsync("Styles", required: false)
|
||||||
|
</head>
|
||||||
|
<body class="bg-gray-100">
|
||||||
|
|
||||||
|
@RenderBody()
|
||||||
|
|
||||||
|
|
||||||
|
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||||
|
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||||
|
<script src="https://unpkg.com/lucide@latest"></script>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
lucide.createIcons();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@await RenderSectionAsync("Scripts", required: false)
|
||||||
|
<dynamic-section name="scripts" />
|
||||||
|
<script>
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
navigator.serviceWorker.register('/service-worker.js')
|
||||||
|
.then(() => console.log('Service Worker registered'));
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,48 @@
|
||||||
|
/* Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
||||||
|
for details on configuring this project to bundle and minify static web assets. */
|
||||||
|
|
||||||
|
a.navbar-brand {
|
||||||
|
white-space: normal;
|
||||||
|
text-align: center;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #0077cc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #1b6ec2;
|
||||||
|
border-color: #1861ac;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #1b6ec2;
|
||||||
|
border-color: #1861ac;
|
||||||
|
}
|
||||||
|
|
||||||
|
.border-top {
|
||||||
|
border-top: 1px solid #e5e5e5;
|
||||||
|
}
|
||||||
|
.border-bottom {
|
||||||
|
border-bottom: 1px solid #e5e5e5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box-shadow {
|
||||||
|
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
|
||||||
|
}
|
||||||
|
|
||||||
|
button.accept-policy {
|
||||||
|
font-size: 1rem;
|
||||||
|
line-height: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
width: 100%;
|
||||||
|
white-space: nowrap;
|
||||||
|
line-height: 60px;
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
|
||||||
|
<script src="~/lib/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.min.js"></script>
|
|
@ -0,0 +1,4 @@
|
||||||
|
@using eSPJ
|
||||||
|
@using eSPJ.Models
|
||||||
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
|
@addTagHelper *, DynamicSections
|
|
@ -0,0 +1,3 @@
|
||||||
|
@{
|
||||||
|
Layout = "_Layout";
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="DynamicSections" Version="2.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,24 @@
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.5.2.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eSPJ", "eSPJ.csproj", "{B8539925-B145-B609-A063-20B0D85C7150}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{B8539925-B145-B609-A063-20B0D85C7150}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B8539925-B145-B609-A063-20B0D85C7150}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B8539925-B145-B609-A063-20B0D85C7150}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B8539925-B145-B609-A063-20B0D85C7150}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {88CB0BDE-3A27-4073-9743-BF4F7AE7EB9C}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*)
|
||||||
|
if command -v cygpath > /dev/null 2>&1; then
|
||||||
|
basedir=`cygpath -w "$basedir"`
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../detect-libc/bin/detect-libc.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../detect-libc/bin/detect-libc.js" "$@"
|
||||||
|
fi
|
|
@ -0,0 +1,17 @@
|
||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\detect-libc\bin\detect-libc.js" %*
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../detect-libc/bin/detect-libc.js" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../detect-libc/bin/detect-libc.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../detect-libc/bin/detect-libc.js" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../detect-libc/bin/detect-libc.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*)
|
||||||
|
if command -v cygpath > /dev/null 2>&1; then
|
||||||
|
basedir=`cygpath -w "$basedir"`
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../jiti/lib/jiti-cli.mjs" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../jiti/lib/jiti-cli.mjs" "$@"
|
||||||
|
fi
|
|
@ -0,0 +1,17 @@
|
||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\jiti\lib\jiti-cli.mjs" %*
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../jiti/lib/jiti-cli.mjs" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../jiti/lib/jiti-cli.mjs" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../jiti/lib/jiti-cli.mjs" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../jiti/lib/jiti-cli.mjs" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*)
|
||||||
|
if command -v cygpath > /dev/null 2>&1; then
|
||||||
|
basedir=`cygpath -w "$basedir"`
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../mkdirp/dist/cjs/src/bin.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../mkdirp/dist/cjs/src/bin.js" "$@"
|
||||||
|
fi
|
|
@ -0,0 +1,17 @@
|
||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\mkdirp\dist\cjs\src\bin.js" %*
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../mkdirp/dist/cjs/src/bin.js" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../mkdirp/dist/cjs/src/bin.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../mkdirp/dist/cjs/src/bin.js" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../mkdirp/dist/cjs/src/bin.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*)
|
||||||
|
if command -v cygpath > /dev/null 2>&1; then
|
||||||
|
basedir=`cygpath -w "$basedir"`
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../@tailwindcss/cli/dist/index.mjs" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../@tailwindcss/cli/dist/index.mjs" "$@"
|
||||||
|
fi
|
|
@ -0,0 +1,17 @@
|
||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\@tailwindcss\cli\dist\index.mjs" %*
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../@tailwindcss/cli/dist/index.mjs" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../@tailwindcss/cli/dist/index.mjs" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../@tailwindcss/cli/dist/index.mjs" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../@tailwindcss/cli/dist/index.mjs" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
|
@ -0,0 +1,521 @@
|
||||||
|
{
|
||||||
|
"name": "eSPJ",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"node_modules/@ampproject/remapping": {
|
||||||
|
"version": "2.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz",
|
||||||
|
"integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@jridgewell/gen-mapping": "^0.3.5",
|
||||||
|
"@jridgewell/trace-mapping": "^0.3.24"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@isaacs/fs-minipass": {
|
||||||
|
"version": "4.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz",
|
||||||
|
"integrity": "sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"minipass": "^7.0.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@jridgewell/gen-mapping": {
|
||||||
|
"version": "0.3.12",
|
||||||
|
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.12.tgz",
|
||||||
|
"integrity": "sha512-OuLGC46TjB5BbN1dH8JULVVZY4WTdkF7tV9Ys6wLL1rubZnCMstOhNHueU5bLCrnRuDhKPDM4g6sw4Bel5Gzqg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@jridgewell/sourcemap-codec": "^1.5.0",
|
||||||
|
"@jridgewell/trace-mapping": "^0.3.24"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@jridgewell/resolve-uri": {
|
||||||
|
"version": "3.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
|
||||||
|
"integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@jridgewell/sourcemap-codec": {
|
||||||
|
"version": "1.5.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.4.tgz",
|
||||||
|
"integrity": "sha512-VT2+G1VQs/9oz078bLrYbecdZKs912zQlkelYpuf+SXF+QvZDYJlbx/LSx+meSAwdDFnF8FVXW92AVjjkVmgFw==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/@jridgewell/trace-mapping": {
|
||||||
|
"version": "0.3.29",
|
||||||
|
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.29.tgz",
|
||||||
|
"integrity": "sha512-uw6guiW/gcAGPDhLmd77/6lW8QLeiV5RUTsAX46Db6oLhGaVj4lhnPwb184s1bkc8kdVg/+h988dro8GRDpmYQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@jridgewell/resolve-uri": "^3.1.0",
|
||||||
|
"@jridgewell/sourcemap-codec": "^1.4.14"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@parcel/watcher": {
|
||||||
|
"version": "2.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.1.tgz",
|
||||||
|
"integrity": "sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg==",
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"detect-libc": "^1.0.3",
|
||||||
|
"is-glob": "^4.0.3",
|
||||||
|
"micromatch": "^4.0.5",
|
||||||
|
"node-addon-api": "^7.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/parcel"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"@parcel/watcher-android-arm64": "2.5.1",
|
||||||
|
"@parcel/watcher-darwin-arm64": "2.5.1",
|
||||||
|
"@parcel/watcher-darwin-x64": "2.5.1",
|
||||||
|
"@parcel/watcher-freebsd-x64": "2.5.1",
|
||||||
|
"@parcel/watcher-linux-arm-glibc": "2.5.1",
|
||||||
|
"@parcel/watcher-linux-arm-musl": "2.5.1",
|
||||||
|
"@parcel/watcher-linux-arm64-glibc": "2.5.1",
|
||||||
|
"@parcel/watcher-linux-arm64-musl": "2.5.1",
|
||||||
|
"@parcel/watcher-linux-x64-glibc": "2.5.1",
|
||||||
|
"@parcel/watcher-linux-x64-musl": "2.5.1",
|
||||||
|
"@parcel/watcher-win32-arm64": "2.5.1",
|
||||||
|
"@parcel/watcher-win32-ia32": "2.5.1",
|
||||||
|
"@parcel/watcher-win32-x64": "2.5.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@parcel/watcher-win32-x64": {
|
||||||
|
"version": "2.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.5.1.tgz",
|
||||||
|
"integrity": "sha512-9lHBdJITeNR++EvSQVUcaZoWupyHfXe1jZvGZ06O/5MflPcuPLtEphScIBL+AiCWBO46tDSHzWyD0uDmmZqsgA==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/parcel"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@tailwindcss/cli": {
|
||||||
|
"version": "4.1.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/@tailwindcss/cli/-/cli-4.1.11.tgz",
|
||||||
|
"integrity": "sha512-7RAFOrVaXCFz5ooEG36Kbh+sMJiI2j4+Ozp71smgjnLfBRu7DTfoq8DsTvzse2/6nDeo2M3vS/FGaxfDgr3rtQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@parcel/watcher": "^2.5.1",
|
||||||
|
"@tailwindcss/node": "4.1.11",
|
||||||
|
"@tailwindcss/oxide": "4.1.11",
|
||||||
|
"enhanced-resolve": "^5.18.1",
|
||||||
|
"mri": "^1.2.0",
|
||||||
|
"picocolors": "^1.1.1",
|
||||||
|
"tailwindcss": "4.1.11"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"tailwindcss": "dist/index.mjs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@tailwindcss/node": {
|
||||||
|
"version": "4.1.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.1.11.tgz",
|
||||||
|
"integrity": "sha512-yzhzuGRmv5QyU9qLNg4GTlYI6STedBWRE7NjxP45CsFYYq9taI0zJXZBMqIC/c8fViNLhmrbpSFS57EoxUmD6Q==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@ampproject/remapping": "^2.3.0",
|
||||||
|
"enhanced-resolve": "^5.18.1",
|
||||||
|
"jiti": "^2.4.2",
|
||||||
|
"lightningcss": "1.30.1",
|
||||||
|
"magic-string": "^0.30.17",
|
||||||
|
"source-map-js": "^1.2.1",
|
||||||
|
"tailwindcss": "4.1.11"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@tailwindcss/oxide": {
|
||||||
|
"version": "4.1.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.1.11.tgz",
|
||||||
|
"integrity": "sha512-Q69XzrtAhuyfHo+5/HMgr1lAiPP/G40OMFAnws7xcFEYqcypZmdW8eGXaOUIeOl1dzPJBPENXgbjsOyhg2nkrg==",
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"detect-libc": "^2.0.4",
|
||||||
|
"tar": "^7.4.3"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"@tailwindcss/oxide-android-arm64": "4.1.11",
|
||||||
|
"@tailwindcss/oxide-darwin-arm64": "4.1.11",
|
||||||
|
"@tailwindcss/oxide-darwin-x64": "4.1.11",
|
||||||
|
"@tailwindcss/oxide-freebsd-x64": "4.1.11",
|
||||||
|
"@tailwindcss/oxide-linux-arm-gnueabihf": "4.1.11",
|
||||||
|
"@tailwindcss/oxide-linux-arm64-gnu": "4.1.11",
|
||||||
|
"@tailwindcss/oxide-linux-arm64-musl": "4.1.11",
|
||||||
|
"@tailwindcss/oxide-linux-x64-gnu": "4.1.11",
|
||||||
|
"@tailwindcss/oxide-linux-x64-musl": "4.1.11",
|
||||||
|
"@tailwindcss/oxide-wasm32-wasi": "4.1.11",
|
||||||
|
"@tailwindcss/oxide-win32-arm64-msvc": "4.1.11",
|
||||||
|
"@tailwindcss/oxide-win32-x64-msvc": "4.1.11"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@tailwindcss/oxide-win32-x64-msvc": {
|
||||||
|
"version": "4.1.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-x64-msvc/-/oxide-win32-x64-msvc-4.1.11.tgz",
|
||||||
|
"integrity": "sha512-YfHoggn1j0LK7wR82TOucWc5LDCguHnoS879idHekmmiR7g9HUtMw9MI0NHatS28u/Xlkfi9w5RJWgz2Dl+5Qg==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@tailwindcss/oxide/node_modules/detect-libc": {
|
||||||
|
"version": "2.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.4.tgz",
|
||||||
|
"integrity": "sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/braces": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
|
||||||
|
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"fill-range": "^7.1.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/chownr": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==",
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/detect-libc": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz",
|
||||||
|
"integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"bin": {
|
||||||
|
"detect-libc": "bin/detect-libc.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/enhanced-resolve": {
|
||||||
|
"version": "5.18.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.18.2.tgz",
|
||||||
|
"integrity": "sha512-6Jw4sE1maoRJo3q8MsSIn2onJFbLTOjY9hlx4DZXmOKvLRd1Ok2kXmAGXaafL2+ijsJZ1ClYbl/pmqr9+k4iUQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"graceful-fs": "^4.2.4",
|
||||||
|
"tapable": "^2.2.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.13.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/fill-range": {
|
||||||
|
"version": "7.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
|
||||||
|
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"to-regex-range": "^5.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/graceful-fs": {
|
||||||
|
"version": "4.2.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
|
||||||
|
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
|
||||||
|
"license": "ISC"
|
||||||
|
},
|
||||||
|
"node_modules/is-extglob": {
|
||||||
|
"version": "2.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
|
||||||
|
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/is-glob": {
|
||||||
|
"version": "4.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
|
||||||
|
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"is-extglob": "^2.1.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/is-number": {
|
||||||
|
"version": "7.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
|
||||||
|
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/jiti": {
|
||||||
|
"version": "2.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/jiti/-/jiti-2.5.1.tgz",
|
||||||
|
"integrity": "sha512-twQoecYPiVA5K/h6SxtORw/Bs3ar+mLUtoPSc7iMXzQzK8d7eJ/R09wmTwAjiamETn1cXYPGfNnu7DMoHgu12w==",
|
||||||
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"jiti": "lib/jiti-cli.mjs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lightningcss": {
|
||||||
|
"version": "1.30.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.30.1.tgz",
|
||||||
|
"integrity": "sha512-xi6IyHML+c9+Q3W0S4fCQJOym42pyurFiJUHEcEyHS0CeKzia4yZDEsLlqOFykxOdHpNy0NmvVO31vcSqAxJCg==",
|
||||||
|
"license": "MPL-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"detect-libc": "^2.0.3"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/parcel"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"lightningcss-darwin-arm64": "1.30.1",
|
||||||
|
"lightningcss-darwin-x64": "1.30.1",
|
||||||
|
"lightningcss-freebsd-x64": "1.30.1",
|
||||||
|
"lightningcss-linux-arm-gnueabihf": "1.30.1",
|
||||||
|
"lightningcss-linux-arm64-gnu": "1.30.1",
|
||||||
|
"lightningcss-linux-arm64-musl": "1.30.1",
|
||||||
|
"lightningcss-linux-x64-gnu": "1.30.1",
|
||||||
|
"lightningcss-linux-x64-musl": "1.30.1",
|
||||||
|
"lightningcss-win32-arm64-msvc": "1.30.1",
|
||||||
|
"lightningcss-win32-x64-msvc": "1.30.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lightningcss-win32-x64-msvc": {
|
||||||
|
"version": "1.30.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.30.1.tgz",
|
||||||
|
"integrity": "sha512-PVqXh48wh4T53F/1CCu8PIPCxLzWyCnn/9T5W1Jpmdy5h9Cwd+0YQS6/LwhHXSafuc61/xg9Lv5OrCby6a++jg==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"license": "MPL-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/parcel"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lightningcss/node_modules/detect-libc": {
|
||||||
|
"version": "2.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.4.tgz",
|
||||||
|
"integrity": "sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/magic-string": {
|
||||||
|
"version": "0.30.17",
|
||||||
|
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz",
|
||||||
|
"integrity": "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@jridgewell/sourcemap-codec": "^1.5.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/micromatch": {
|
||||||
|
"version": "4.0.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
|
||||||
|
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"braces": "^3.0.3",
|
||||||
|
"picomatch": "^2.3.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/minipass": {
|
||||||
|
"version": "7.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz",
|
||||||
|
"integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==",
|
||||||
|
"license": "ISC",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16 || 14 >=14.17"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/minizlib": {
|
||||||
|
"version": "3.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.0.2.tgz",
|
||||||
|
"integrity": "sha512-oG62iEk+CYt5Xj2YqI5Xi9xWUeZhDI8jjQmC5oThVH5JGCTgIjr7ciJDzC7MBzYd//WvR1OTmP5Q38Q8ShQtVA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"minipass": "^7.1.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 18"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mkdirp": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"mkdirp": "dist/cjs/src/bin.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mri": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
|
||||||
|
"integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/node-addon-api": {
|
||||||
|
"version": "7.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz",
|
||||||
|
"integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/picocolors": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
|
||||||
|
"license": "ISC"
|
||||||
|
},
|
||||||
|
"node_modules/picomatch": {
|
||||||
|
"version": "2.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
|
||||||
|
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.6"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/jonschlinkert"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/source-map-js": {
|
||||||
|
"version": "1.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
|
||||||
|
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tailwindcss": {
|
||||||
|
"version": "4.1.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.11.tgz",
|
||||||
|
"integrity": "sha512-2E9TBm6MDD/xKYe+dvJZAmg3yxIEDNRc0jwlNyDg/4Fil2QcSLjFKGVff0lAf1jjeaArlG/M75Ey/EYr/OJtBA==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/tapable": {
|
||||||
|
"version": "2.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.2.tgz",
|
||||||
|
"integrity": "sha512-Re10+NauLTMCudc7T5WLFLAwDhQ0JWdrMK+9B2M8zR5hRExKmsRDCBA7/aV/pNJFltmBFO5BAMlQFi/vq3nKOg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tar": {
|
||||||
|
"version": "7.4.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/tar/-/tar-7.4.3.tgz",
|
||||||
|
"integrity": "sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"@isaacs/fs-minipass": "^4.0.0",
|
||||||
|
"chownr": "^3.0.0",
|
||||||
|
"minipass": "^7.1.2",
|
||||||
|
"minizlib": "^3.0.1",
|
||||||
|
"mkdirp": "^3.0.1",
|
||||||
|
"yallist": "^5.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/to-regex-range": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"is-number": "^7.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/yallist": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==",
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,202 @@
|
||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
|
@ -0,0 +1,218 @@
|
||||||
|
# @ampproject/remapping
|
||||||
|
|
||||||
|
> Remap sequential sourcemaps through transformations to point at the original source code
|
||||||
|
|
||||||
|
Remapping allows you to take the sourcemaps generated through transforming your code and "remap"
|
||||||
|
them to the original source locations. Think "my minified code, transformed with babel and bundled
|
||||||
|
with webpack", all pointing to the correct location in your original source code.
|
||||||
|
|
||||||
|
With remapping, none of your source code transformations need to be aware of the input's sourcemap,
|
||||||
|
they only need to generate an output sourcemap. This greatly simplifies building custom
|
||||||
|
transformations (think a find-and-replace).
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install @ampproject/remapping
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
function remapping(
|
||||||
|
map: SourceMap | SourceMap[],
|
||||||
|
loader: (file: string, ctx: LoaderContext) => (SourceMap | null | undefined),
|
||||||
|
options?: { excludeContent: boolean, decodedMappings: boolean }
|
||||||
|
): SourceMap;
|
||||||
|
|
||||||
|
// LoaderContext gives the loader the importing sourcemap, tree depth, the ability to override the
|
||||||
|
// "source" location (where child sources are resolved relative to, or the location of original
|
||||||
|
// source), and the ability to override the "content" of an original source for inclusion in the
|
||||||
|
// output sourcemap.
|
||||||
|
type LoaderContext = {
|
||||||
|
readonly importer: string;
|
||||||
|
readonly depth: number;
|
||||||
|
source: string;
|
||||||
|
content: string | null | undefined;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
`remapping` takes the final output sourcemap, and a `loader` function. For every source file pointer
|
||||||
|
in the sourcemap, the `loader` will be called with the resolved path. If the path itself represents
|
||||||
|
a transformed file (it has a sourcmap associated with it), then the `loader` should return that
|
||||||
|
sourcemap. If not, the path will be treated as an original, untransformed source code.
|
||||||
|
|
||||||
|
```js
|
||||||
|
// Babel transformed "helloworld.js" into "transformed.js"
|
||||||
|
const transformedMap = JSON.stringify({
|
||||||
|
file: 'transformed.js',
|
||||||
|
// 1st column of 2nd line of output file translates into the 1st source
|
||||||
|
// file, line 3, column 2
|
||||||
|
mappings: ';CAEE',
|
||||||
|
sources: ['helloworld.js'],
|
||||||
|
version: 3,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Uglify minified "transformed.js" into "transformed.min.js"
|
||||||
|
const minifiedTransformedMap = JSON.stringify({
|
||||||
|
file: 'transformed.min.js',
|
||||||
|
// 0th column of 1st line of output file translates into the 1st source
|
||||||
|
// file, line 2, column 1.
|
||||||
|
mappings: 'AACC',
|
||||||
|
names: [],
|
||||||
|
sources: ['transformed.js'],
|
||||||
|
version: 3,
|
||||||
|
});
|
||||||
|
|
||||||
|
const remapped = remapping(
|
||||||
|
minifiedTransformedMap,
|
||||||
|
(file, ctx) => {
|
||||||
|
|
||||||
|
// The "transformed.js" file is an transformed file.
|
||||||
|
if (file === 'transformed.js') {
|
||||||
|
// The root importer is empty.
|
||||||
|
console.assert(ctx.importer === '');
|
||||||
|
// The depth in the sourcemap tree we're currently loading.
|
||||||
|
// The root `minifiedTransformedMap` is depth 0, and its source children are depth 1, etc.
|
||||||
|
console.assert(ctx.depth === 1);
|
||||||
|
|
||||||
|
return transformedMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Loader will be called to load transformedMap's source file pointers as well.
|
||||||
|
console.assert(file === 'helloworld.js');
|
||||||
|
// `transformed.js`'s sourcemap points into `helloworld.js`.
|
||||||
|
console.assert(ctx.importer === 'transformed.js');
|
||||||
|
// This is a source child of `transformed`, which is a source child of `minifiedTransformedMap`.
|
||||||
|
console.assert(ctx.depth === 2);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(remapped);
|
||||||
|
// {
|
||||||
|
// file: 'transpiled.min.js',
|
||||||
|
// mappings: 'AAEE',
|
||||||
|
// sources: ['helloworld.js'],
|
||||||
|
// version: 3,
|
||||||
|
// };
|
||||||
|
```
|
||||||
|
|
||||||
|
In this example, `loader` will be called twice:
|
||||||
|
|
||||||
|
1. `"transformed.js"`, the first source file pointer in the `minifiedTransformedMap`. We return the
|
||||||
|
associated sourcemap for it (its a transformed file, after all) so that sourcemap locations can
|
||||||
|
be traced through it into the source files it represents.
|
||||||
|
2. `"helloworld.js"`, our original, unmodified source code. This file does not have a sourcemap, so
|
||||||
|
we return `null`.
|
||||||
|
|
||||||
|
The `remapped` sourcemap now points from `transformed.min.js` into locations in `helloworld.js`. If
|
||||||
|
you were to read the `mappings`, it says "0th column of the first line output line points to the 1st
|
||||||
|
column of the 2nd line of the file `helloworld.js`".
|
||||||
|
|
||||||
|
### Multiple transformations of a file
|
||||||
|
|
||||||
|
As a convenience, if you have multiple single-source transformations of a file, you may pass an
|
||||||
|
array of sourcemap files in the order of most-recent transformation sourcemap first. Note that this
|
||||||
|
changes the `importer` and `depth` of each call to our loader. So our above example could have been
|
||||||
|
written as:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const remapped = remapping(
|
||||||
|
[minifiedTransformedMap, transformedMap],
|
||||||
|
() => null
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(remapped);
|
||||||
|
// {
|
||||||
|
// file: 'transpiled.min.js',
|
||||||
|
// mappings: 'AAEE',
|
||||||
|
// sources: ['helloworld.js'],
|
||||||
|
// version: 3,
|
||||||
|
// };
|
||||||
|
```
|
||||||
|
|
||||||
|
### Advanced control of the loading graph
|
||||||
|
|
||||||
|
#### `source`
|
||||||
|
|
||||||
|
The `source` property can overridden to any value to change the location of the current load. Eg,
|
||||||
|
for an original source file, it allows us to change the location to the original source regardless
|
||||||
|
of what the sourcemap source entry says. And for transformed files, it allows us to change the
|
||||||
|
relative resolving location for child sources of the loaded sourcemap.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const remapped = remapping(
|
||||||
|
minifiedTransformedMap,
|
||||||
|
(file, ctx) => {
|
||||||
|
|
||||||
|
if (file === 'transformed.js') {
|
||||||
|
// We pretend the transformed.js file actually exists in the 'src/' directory. When the nested
|
||||||
|
// source files are loaded, they will now be relative to `src/`.
|
||||||
|
ctx.source = 'src/transformed.js';
|
||||||
|
return transformedMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.assert(file === 'src/helloworld.js');
|
||||||
|
// We could futher change the source of this original file, eg, to be inside a nested directory
|
||||||
|
// itself. This will be reflected in the remapped sourcemap.
|
||||||
|
ctx.source = 'src/nested/transformed.js';
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(remapped);
|
||||||
|
// {
|
||||||
|
// …,
|
||||||
|
// sources: ['src/nested/helloworld.js'],
|
||||||
|
// };
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
#### `content`
|
||||||
|
|
||||||
|
The `content` property can be overridden when we encounter an original source file. Eg, this allows
|
||||||
|
you to manually provide the source content of the original file regardless of whether the
|
||||||
|
`sourcesContent` field is present in the parent sourcemap. It can also be set to `null` to remove
|
||||||
|
the source content.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const remapped = remapping(
|
||||||
|
minifiedTransformedMap,
|
||||||
|
(file, ctx) => {
|
||||||
|
|
||||||
|
if (file === 'transformed.js') {
|
||||||
|
// transformedMap does not include a `sourcesContent` field, so usually the remapped sourcemap
|
||||||
|
// would not include any `sourcesContent` values.
|
||||||
|
return transformedMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.assert(file === 'helloworld.js');
|
||||||
|
// We can read the file to provide the source content.
|
||||||
|
ctx.content = fs.readFileSync(file, 'utf8');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(remapped);
|
||||||
|
// {
|
||||||
|
// …,
|
||||||
|
// sourcesContent: [
|
||||||
|
// 'console.log("Hello world!")',
|
||||||
|
// ],
|
||||||
|
// };
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
#### excludeContent
|
||||||
|
|
||||||
|
By default, `excludeContent` is `false`. Passing `{ excludeContent: true }` will exclude the
|
||||||
|
`sourcesContent` field from the returned sourcemap. This is mainly useful when you want to reduce
|
||||||
|
the size out the sourcemap.
|
||||||
|
|
||||||
|
#### decodedMappings
|
||||||
|
|
||||||
|
By default, `decodedMappings` is `false`. Passing `{ decodedMappings: true }` will leave the
|
||||||
|
`mappings` field in a [decoded state](https://github.com/rich-harris/sourcemap-codec) instead of
|
||||||
|
encoding into a VLQ string.
|
|
@ -0,0 +1,197 @@
|
||||||
|
import { decodedMappings, traceSegment, TraceMap } from '@jridgewell/trace-mapping';
|
||||||
|
import { GenMapping, maybeAddSegment, setSourceContent, setIgnore, toDecodedMap, toEncodedMap } from '@jridgewell/gen-mapping';
|
||||||
|
|
||||||
|
const SOURCELESS_MAPPING = /* #__PURE__ */ SegmentObject('', -1, -1, '', null, false);
|
||||||
|
const EMPTY_SOURCES = [];
|
||||||
|
function SegmentObject(source, line, column, name, content, ignore) {
|
||||||
|
return { source, line, column, name, content, ignore };
|
||||||
|
}
|
||||||
|
function Source(map, sources, source, content, ignore) {
|
||||||
|
return {
|
||||||
|
map,
|
||||||
|
sources,
|
||||||
|
source,
|
||||||
|
content,
|
||||||
|
ignore,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes
|
||||||
|
* (which may themselves be SourceMapTrees).
|
||||||
|
*/
|
||||||
|
function MapSource(map, sources) {
|
||||||
|
return Source(map, sources, '', null, false);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive
|
||||||
|
* segment tracing ends at the `OriginalSource`.
|
||||||
|
*/
|
||||||
|
function OriginalSource(source, content, ignore) {
|
||||||
|
return Source(null, EMPTY_SOURCES, source, content, ignore);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* traceMappings is only called on the root level SourceMapTree, and begins the process of
|
||||||
|
* resolving each mapping in terms of the original source files.
|
||||||
|
*/
|
||||||
|
function traceMappings(tree) {
|
||||||
|
// TODO: Eventually support sourceRoot, which has to be removed because the sources are already
|
||||||
|
// fully resolved. We'll need to make sources relative to the sourceRoot before adding them.
|
||||||
|
const gen = new GenMapping({ file: tree.map.file });
|
||||||
|
const { sources: rootSources, map } = tree;
|
||||||
|
const rootNames = map.names;
|
||||||
|
const rootMappings = decodedMappings(map);
|
||||||
|
for (let i = 0; i < rootMappings.length; i++) {
|
||||||
|
const segments = rootMappings[i];
|
||||||
|
for (let j = 0; j < segments.length; j++) {
|
||||||
|
const segment = segments[j];
|
||||||
|
const genCol = segment[0];
|
||||||
|
let traced = SOURCELESS_MAPPING;
|
||||||
|
// 1-length segments only move the current generated column, there's no source information
|
||||||
|
// to gather from it.
|
||||||
|
if (segment.length !== 1) {
|
||||||
|
const source = rootSources[segment[1]];
|
||||||
|
traced = originalPositionFor(source, segment[2], segment[3], segment.length === 5 ? rootNames[segment[4]] : '');
|
||||||
|
// If the trace is invalid, then the trace ran into a sourcemap that doesn't contain a
|
||||||
|
// respective segment into an original source.
|
||||||
|
if (traced == null)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const { column, line, name, content, source, ignore } = traced;
|
||||||
|
maybeAddSegment(gen, i, genCol, source, line, column, name);
|
||||||
|
if (source && content != null)
|
||||||
|
setSourceContent(gen, source, content);
|
||||||
|
if (ignore)
|
||||||
|
setIgnore(gen, source, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return gen;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* originalPositionFor is only called on children SourceMapTrees. It recurses down into its own
|
||||||
|
* child SourceMapTrees, until we find the original source map.
|
||||||
|
*/
|
||||||
|
function originalPositionFor(source, line, column, name) {
|
||||||
|
if (!source.map) {
|
||||||
|
return SegmentObject(source.source, line, column, name, source.content, source.ignore);
|
||||||
|
}
|
||||||
|
const segment = traceSegment(source.map, line, column);
|
||||||
|
// If we couldn't find a segment, then this doesn't exist in the sourcemap.
|
||||||
|
if (segment == null)
|
||||||
|
return null;
|
||||||
|
// 1-length segments only move the current generated column, there's no source information
|
||||||
|
// to gather from it.
|
||||||
|
if (segment.length === 1)
|
||||||
|
return SOURCELESS_MAPPING;
|
||||||
|
return originalPositionFor(source.sources[segment[1]], segment[2], segment[3], segment.length === 5 ? source.map.names[segment[4]] : name);
|
||||||
|
}
|
||||||
|
|
||||||
|
function asArray(value) {
|
||||||
|
if (Array.isArray(value))
|
||||||
|
return value;
|
||||||
|
return [value];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Recursively builds a tree structure out of sourcemap files, with each node
|
||||||
|
* being either an `OriginalSource` "leaf" or a `SourceMapTree` composed of
|
||||||
|
* `OriginalSource`s and `SourceMapTree`s.
|
||||||
|
*
|
||||||
|
* Every sourcemap is composed of a collection of source files and mappings
|
||||||
|
* into locations of those source files. When we generate a `SourceMapTree` for
|
||||||
|
* the sourcemap, we attempt to load each source file's own sourcemap. If it
|
||||||
|
* does not have an associated sourcemap, it is considered an original,
|
||||||
|
* unmodified source file.
|
||||||
|
*/
|
||||||
|
function buildSourceMapTree(input, loader) {
|
||||||
|
const maps = asArray(input).map((m) => new TraceMap(m, ''));
|
||||||
|
const map = maps.pop();
|
||||||
|
for (let i = 0; i < maps.length; i++) {
|
||||||
|
if (maps[i].sources.length > 1) {
|
||||||
|
throw new Error(`Transformation map ${i} must have exactly one source file.\n` +
|
||||||
|
'Did you specify these with the most recent transformation maps first?');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let tree = build(map, loader, '', 0);
|
||||||
|
for (let i = maps.length - 1; i >= 0; i--) {
|
||||||
|
tree = MapSource(maps[i], [tree]);
|
||||||
|
}
|
||||||
|
return tree;
|
||||||
|
}
|
||||||
|
function build(map, loader, importer, importerDepth) {
|
||||||
|
const { resolvedSources, sourcesContent, ignoreList } = map;
|
||||||
|
const depth = importerDepth + 1;
|
||||||
|
const children = resolvedSources.map((sourceFile, i) => {
|
||||||
|
// The loading context gives the loader more information about why this file is being loaded
|
||||||
|
// (eg, from which importer). It also allows the loader to override the location of the loaded
|
||||||
|
// sourcemap/original source, or to override the content in the sourcesContent field if it's
|
||||||
|
// an unmodified source file.
|
||||||
|
const ctx = {
|
||||||
|
importer,
|
||||||
|
depth,
|
||||||
|
source: sourceFile || '',
|
||||||
|
content: undefined,
|
||||||
|
ignore: undefined,
|
||||||
|
};
|
||||||
|
// Use the provided loader callback to retrieve the file's sourcemap.
|
||||||
|
// TODO: We should eventually support async loading of sourcemap files.
|
||||||
|
const sourceMap = loader(ctx.source, ctx);
|
||||||
|
const { source, content, ignore } = ctx;
|
||||||
|
// If there is a sourcemap, then we need to recurse into it to load its source files.
|
||||||
|
if (sourceMap)
|
||||||
|
return build(new TraceMap(sourceMap, source), loader, source, depth);
|
||||||
|
// Else, it's an unmodified source file.
|
||||||
|
// The contents of this unmodified source file can be overridden via the loader context,
|
||||||
|
// allowing it to be explicitly null or a string. If it remains undefined, we fall back to
|
||||||
|
// the importing sourcemap's `sourcesContent` field.
|
||||||
|
const sourceContent = content !== undefined ? content : sourcesContent ? sourcesContent[i] : null;
|
||||||
|
const ignored = ignore !== undefined ? ignore : ignoreList ? ignoreList.includes(i) : false;
|
||||||
|
return OriginalSource(source, sourceContent, ignored);
|
||||||
|
});
|
||||||
|
return MapSource(map, children);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A SourceMap v3 compatible sourcemap, which only includes fields that were
|
||||||
|
* provided to it.
|
||||||
|
*/
|
||||||
|
class SourceMap {
|
||||||
|
constructor(map, options) {
|
||||||
|
const out = options.decodedMappings ? toDecodedMap(map) : toEncodedMap(map);
|
||||||
|
this.version = out.version; // SourceMap spec says this should be first.
|
||||||
|
this.file = out.file;
|
||||||
|
this.mappings = out.mappings;
|
||||||
|
this.names = out.names;
|
||||||
|
this.ignoreList = out.ignoreList;
|
||||||
|
this.sourceRoot = out.sourceRoot;
|
||||||
|
this.sources = out.sources;
|
||||||
|
if (!options.excludeContent) {
|
||||||
|
this.sourcesContent = out.sourcesContent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
toString() {
|
||||||
|
return JSON.stringify(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Traces through all the mappings in the root sourcemap, through the sources
|
||||||
|
* (and their sourcemaps), all the way back to the original source location.
|
||||||
|
*
|
||||||
|
* `loader` will be called every time we encounter a source file. If it returns
|
||||||
|
* a sourcemap, we will recurse into that sourcemap to continue the trace. If
|
||||||
|
* it returns a falsey value, that source file is treated as an original,
|
||||||
|
* unmodified source file.
|
||||||
|
*
|
||||||
|
* Pass `excludeContent` to exclude any self-containing source file content
|
||||||
|
* from the output sourcemap.
|
||||||
|
*
|
||||||
|
* Pass `decodedMappings` to receive a SourceMap with decoded (instead of
|
||||||
|
* VLQ encoded) mappings.
|
||||||
|
*/
|
||||||
|
function remapping(input, loader, options) {
|
||||||
|
const opts = typeof options === 'object' ? options : { excludeContent: !!options, decodedMappings: false };
|
||||||
|
const tree = buildSourceMapTree(input, loader);
|
||||||
|
return new SourceMap(traceMappings(tree), opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { remapping as default };
|
||||||
|
//# sourceMappingURL=remapping.mjs.map
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,202 @@
|
||||||
|
(function (global, factory) {
|
||||||
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@jridgewell/trace-mapping'), require('@jridgewell/gen-mapping')) :
|
||||||
|
typeof define === 'function' && define.amd ? define(['@jridgewell/trace-mapping', '@jridgewell/gen-mapping'], factory) :
|
||||||
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.remapping = factory(global.traceMapping, global.genMapping));
|
||||||
|
})(this, (function (traceMapping, genMapping) { 'use strict';
|
||||||
|
|
||||||
|
const SOURCELESS_MAPPING = /* #__PURE__ */ SegmentObject('', -1, -1, '', null, false);
|
||||||
|
const EMPTY_SOURCES = [];
|
||||||
|
function SegmentObject(source, line, column, name, content, ignore) {
|
||||||
|
return { source, line, column, name, content, ignore };
|
||||||
|
}
|
||||||
|
function Source(map, sources, source, content, ignore) {
|
||||||
|
return {
|
||||||
|
map,
|
||||||
|
sources,
|
||||||
|
source,
|
||||||
|
content,
|
||||||
|
ignore,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes
|
||||||
|
* (which may themselves be SourceMapTrees).
|
||||||
|
*/
|
||||||
|
function MapSource(map, sources) {
|
||||||
|
return Source(map, sources, '', null, false);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive
|
||||||
|
* segment tracing ends at the `OriginalSource`.
|
||||||
|
*/
|
||||||
|
function OriginalSource(source, content, ignore) {
|
||||||
|
return Source(null, EMPTY_SOURCES, source, content, ignore);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* traceMappings is only called on the root level SourceMapTree, and begins the process of
|
||||||
|
* resolving each mapping in terms of the original source files.
|
||||||
|
*/
|
||||||
|
function traceMappings(tree) {
|
||||||
|
// TODO: Eventually support sourceRoot, which has to be removed because the sources are already
|
||||||
|
// fully resolved. We'll need to make sources relative to the sourceRoot before adding them.
|
||||||
|
const gen = new genMapping.GenMapping({ file: tree.map.file });
|
||||||
|
const { sources: rootSources, map } = tree;
|
||||||
|
const rootNames = map.names;
|
||||||
|
const rootMappings = traceMapping.decodedMappings(map);
|
||||||
|
for (let i = 0; i < rootMappings.length; i++) {
|
||||||
|
const segments = rootMappings[i];
|
||||||
|
for (let j = 0; j < segments.length; j++) {
|
||||||
|
const segment = segments[j];
|
||||||
|
const genCol = segment[0];
|
||||||
|
let traced = SOURCELESS_MAPPING;
|
||||||
|
// 1-length segments only move the current generated column, there's no source information
|
||||||
|
// to gather from it.
|
||||||
|
if (segment.length !== 1) {
|
||||||
|
const source = rootSources[segment[1]];
|
||||||
|
traced = originalPositionFor(source, segment[2], segment[3], segment.length === 5 ? rootNames[segment[4]] : '');
|
||||||
|
// If the trace is invalid, then the trace ran into a sourcemap that doesn't contain a
|
||||||
|
// respective segment into an original source.
|
||||||
|
if (traced == null)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const { column, line, name, content, source, ignore } = traced;
|
||||||
|
genMapping.maybeAddSegment(gen, i, genCol, source, line, column, name);
|
||||||
|
if (source && content != null)
|
||||||
|
genMapping.setSourceContent(gen, source, content);
|
||||||
|
if (ignore)
|
||||||
|
genMapping.setIgnore(gen, source, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return gen;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* originalPositionFor is only called on children SourceMapTrees. It recurses down into its own
|
||||||
|
* child SourceMapTrees, until we find the original source map.
|
||||||
|
*/
|
||||||
|
function originalPositionFor(source, line, column, name) {
|
||||||
|
if (!source.map) {
|
||||||
|
return SegmentObject(source.source, line, column, name, source.content, source.ignore);
|
||||||
|
}
|
||||||
|
const segment = traceMapping.traceSegment(source.map, line, column);
|
||||||
|
// If we couldn't find a segment, then this doesn't exist in the sourcemap.
|
||||||
|
if (segment == null)
|
||||||
|
return null;
|
||||||
|
// 1-length segments only move the current generated column, there's no source information
|
||||||
|
// to gather from it.
|
||||||
|
if (segment.length === 1)
|
||||||
|
return SOURCELESS_MAPPING;
|
||||||
|
return originalPositionFor(source.sources[segment[1]], segment[2], segment[3], segment.length === 5 ? source.map.names[segment[4]] : name);
|
||||||
|
}
|
||||||
|
|
||||||
|
function asArray(value) {
|
||||||
|
if (Array.isArray(value))
|
||||||
|
return value;
|
||||||
|
return [value];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Recursively builds a tree structure out of sourcemap files, with each node
|
||||||
|
* being either an `OriginalSource` "leaf" or a `SourceMapTree` composed of
|
||||||
|
* `OriginalSource`s and `SourceMapTree`s.
|
||||||
|
*
|
||||||
|
* Every sourcemap is composed of a collection of source files and mappings
|
||||||
|
* into locations of those source files. When we generate a `SourceMapTree` for
|
||||||
|
* the sourcemap, we attempt to load each source file's own sourcemap. If it
|
||||||
|
* does not have an associated sourcemap, it is considered an original,
|
||||||
|
* unmodified source file.
|
||||||
|
*/
|
||||||
|
function buildSourceMapTree(input, loader) {
|
||||||
|
const maps = asArray(input).map((m) => new traceMapping.TraceMap(m, ''));
|
||||||
|
const map = maps.pop();
|
||||||
|
for (let i = 0; i < maps.length; i++) {
|
||||||
|
if (maps[i].sources.length > 1) {
|
||||||
|
throw new Error(`Transformation map ${i} must have exactly one source file.\n` +
|
||||||
|
'Did you specify these with the most recent transformation maps first?');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let tree = build(map, loader, '', 0);
|
||||||
|
for (let i = maps.length - 1; i >= 0; i--) {
|
||||||
|
tree = MapSource(maps[i], [tree]);
|
||||||
|
}
|
||||||
|
return tree;
|
||||||
|
}
|
||||||
|
function build(map, loader, importer, importerDepth) {
|
||||||
|
const { resolvedSources, sourcesContent, ignoreList } = map;
|
||||||
|
const depth = importerDepth + 1;
|
||||||
|
const children = resolvedSources.map((sourceFile, i) => {
|
||||||
|
// The loading context gives the loader more information about why this file is being loaded
|
||||||
|
// (eg, from which importer). It also allows the loader to override the location of the loaded
|
||||||
|
// sourcemap/original source, or to override the content in the sourcesContent field if it's
|
||||||
|
// an unmodified source file.
|
||||||
|
const ctx = {
|
||||||
|
importer,
|
||||||
|
depth,
|
||||||
|
source: sourceFile || '',
|
||||||
|
content: undefined,
|
||||||
|
ignore: undefined,
|
||||||
|
};
|
||||||
|
// Use the provided loader callback to retrieve the file's sourcemap.
|
||||||
|
// TODO: We should eventually support async loading of sourcemap files.
|
||||||
|
const sourceMap = loader(ctx.source, ctx);
|
||||||
|
const { source, content, ignore } = ctx;
|
||||||
|
// If there is a sourcemap, then we need to recurse into it to load its source files.
|
||||||
|
if (sourceMap)
|
||||||
|
return build(new traceMapping.TraceMap(sourceMap, source), loader, source, depth);
|
||||||
|
// Else, it's an unmodified source file.
|
||||||
|
// The contents of this unmodified source file can be overridden via the loader context,
|
||||||
|
// allowing it to be explicitly null or a string. If it remains undefined, we fall back to
|
||||||
|
// the importing sourcemap's `sourcesContent` field.
|
||||||
|
const sourceContent = content !== undefined ? content : sourcesContent ? sourcesContent[i] : null;
|
||||||
|
const ignored = ignore !== undefined ? ignore : ignoreList ? ignoreList.includes(i) : false;
|
||||||
|
return OriginalSource(source, sourceContent, ignored);
|
||||||
|
});
|
||||||
|
return MapSource(map, children);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A SourceMap v3 compatible sourcemap, which only includes fields that were
|
||||||
|
* provided to it.
|
||||||
|
*/
|
||||||
|
class SourceMap {
|
||||||
|
constructor(map, options) {
|
||||||
|
const out = options.decodedMappings ? genMapping.toDecodedMap(map) : genMapping.toEncodedMap(map);
|
||||||
|
this.version = out.version; // SourceMap spec says this should be first.
|
||||||
|
this.file = out.file;
|
||||||
|
this.mappings = out.mappings;
|
||||||
|
this.names = out.names;
|
||||||
|
this.ignoreList = out.ignoreList;
|
||||||
|
this.sourceRoot = out.sourceRoot;
|
||||||
|
this.sources = out.sources;
|
||||||
|
if (!options.excludeContent) {
|
||||||
|
this.sourcesContent = out.sourcesContent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
toString() {
|
||||||
|
return JSON.stringify(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Traces through all the mappings in the root sourcemap, through the sources
|
||||||
|
* (and their sourcemaps), all the way back to the original source location.
|
||||||
|
*
|
||||||
|
* `loader` will be called every time we encounter a source file. If it returns
|
||||||
|
* a sourcemap, we will recurse into that sourcemap to continue the trace. If
|
||||||
|
* it returns a falsey value, that source file is treated as an original,
|
||||||
|
* unmodified source file.
|
||||||
|
*
|
||||||
|
* Pass `excludeContent` to exclude any self-containing source file content
|
||||||
|
* from the output sourcemap.
|
||||||
|
*
|
||||||
|
* Pass `decodedMappings` to receive a SourceMap with decoded (instead of
|
||||||
|
* VLQ encoded) mappings.
|
||||||
|
*/
|
||||||
|
function remapping(input, loader, options) {
|
||||||
|
const opts = typeof options === 'object' ? options : { excludeContent: !!options, decodedMappings: false };
|
||||||
|
const tree = buildSourceMapTree(input, loader);
|
||||||
|
return new SourceMap(traceMappings(tree), opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
return remapping;
|
||||||
|
|
||||||
|
}));
|
||||||
|
//# sourceMappingURL=remapping.umd.js.map
|
File diff suppressed because one or more lines are too long
14
node_modules/@ampproject/remapping/dist/types/build-source-map-tree.d.ts
generated
vendored
100644
14
node_modules/@ampproject/remapping/dist/types/build-source-map-tree.d.ts
generated
vendored
100644
|
@ -0,0 +1,14 @@
|
||||||
|
import type { MapSource as MapSourceType } from './source-map-tree';
|
||||||
|
import type { SourceMapInput, SourceMapLoader } from './types';
|
||||||
|
/**
|
||||||
|
* Recursively builds a tree structure out of sourcemap files, with each node
|
||||||
|
* being either an `OriginalSource` "leaf" or a `SourceMapTree` composed of
|
||||||
|
* `OriginalSource`s and `SourceMapTree`s.
|
||||||
|
*
|
||||||
|
* Every sourcemap is composed of a collection of source files and mappings
|
||||||
|
* into locations of those source files. When we generate a `SourceMapTree` for
|
||||||
|
* the sourcemap, we attempt to load each source file's own sourcemap. If it
|
||||||
|
* does not have an associated sourcemap, it is considered an original,
|
||||||
|
* unmodified source file.
|
||||||
|
*/
|
||||||
|
export default function buildSourceMapTree(input: SourceMapInput | SourceMapInput[], loader: SourceMapLoader): MapSourceType;
|
|
@ -0,0 +1,20 @@
|
||||||
|
import SourceMap from './source-map';
|
||||||
|
import type { SourceMapInput, SourceMapLoader, Options } from './types';
|
||||||
|
export type { SourceMapSegment, EncodedSourceMap, EncodedSourceMap as RawSourceMap, DecodedSourceMap, SourceMapInput, SourceMapLoader, LoaderContext, Options, } from './types';
|
||||||
|
export type { SourceMap };
|
||||||
|
/**
|
||||||
|
* Traces through all the mappings in the root sourcemap, through the sources
|
||||||
|
* (and their sourcemaps), all the way back to the original source location.
|
||||||
|
*
|
||||||
|
* `loader` will be called every time we encounter a source file. If it returns
|
||||||
|
* a sourcemap, we will recurse into that sourcemap to continue the trace. If
|
||||||
|
* it returns a falsey value, that source file is treated as an original,
|
||||||
|
* unmodified source file.
|
||||||
|
*
|
||||||
|
* Pass `excludeContent` to exclude any self-containing source file content
|
||||||
|
* from the output sourcemap.
|
||||||
|
*
|
||||||
|
* Pass `decodedMappings` to receive a SourceMap with decoded (instead of
|
||||||
|
* VLQ encoded) mappings.
|
||||||
|
*/
|
||||||
|
export default function remapping(input: SourceMapInput | SourceMapInput[], loader: SourceMapLoader, options?: boolean | Options): SourceMap;
|
|
@ -0,0 +1,45 @@
|
||||||
|
import { GenMapping } from '@jridgewell/gen-mapping';
|
||||||
|
import type { TraceMap } from '@jridgewell/trace-mapping';
|
||||||
|
export declare type SourceMapSegmentObject = {
|
||||||
|
column: number;
|
||||||
|
line: number;
|
||||||
|
name: string;
|
||||||
|
source: string;
|
||||||
|
content: string | null;
|
||||||
|
ignore: boolean;
|
||||||
|
};
|
||||||
|
export declare type OriginalSource = {
|
||||||
|
map: null;
|
||||||
|
sources: Sources[];
|
||||||
|
source: string;
|
||||||
|
content: string | null;
|
||||||
|
ignore: boolean;
|
||||||
|
};
|
||||||
|
export declare type MapSource = {
|
||||||
|
map: TraceMap;
|
||||||
|
sources: Sources[];
|
||||||
|
source: string;
|
||||||
|
content: null;
|
||||||
|
ignore: false;
|
||||||
|
};
|
||||||
|
export declare type Sources = OriginalSource | MapSource;
|
||||||
|
/**
|
||||||
|
* MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes
|
||||||
|
* (which may themselves be SourceMapTrees).
|
||||||
|
*/
|
||||||
|
export declare function MapSource(map: TraceMap, sources: Sources[]): MapSource;
|
||||||
|
/**
|
||||||
|
* A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive
|
||||||
|
* segment tracing ends at the `OriginalSource`.
|
||||||
|
*/
|
||||||
|
export declare function OriginalSource(source: string, content: string | null, ignore: boolean): OriginalSource;
|
||||||
|
/**
|
||||||
|
* traceMappings is only called on the root level SourceMapTree, and begins the process of
|
||||||
|
* resolving each mapping in terms of the original source files.
|
||||||
|
*/
|
||||||
|
export declare function traceMappings(tree: MapSource): GenMapping;
|
||||||
|
/**
|
||||||
|
* originalPositionFor is only called on children SourceMapTrees. It recurses down into its own
|
||||||
|
* child SourceMapTrees, until we find the original source map.
|
||||||
|
*/
|
||||||
|
export declare function originalPositionFor(source: Sources, line: number, column: number, name: string): SourceMapSegmentObject | null;
|
|
@ -0,0 +1,18 @@
|
||||||
|
import type { GenMapping } from '@jridgewell/gen-mapping';
|
||||||
|
import type { DecodedSourceMap, EncodedSourceMap, Options } from './types';
|
||||||
|
/**
|
||||||
|
* A SourceMap v3 compatible sourcemap, which only includes fields that were
|
||||||
|
* provided to it.
|
||||||
|
*/
|
||||||
|
export default class SourceMap {
|
||||||
|
file?: string | null;
|
||||||
|
mappings: EncodedSourceMap['mappings'] | DecodedSourceMap['mappings'];
|
||||||
|
sourceRoot?: string;
|
||||||
|
names: string[];
|
||||||
|
sources: (string | null)[];
|
||||||
|
sourcesContent?: (string | null)[];
|
||||||
|
version: 3;
|
||||||
|
ignoreList: number[] | undefined;
|
||||||
|
constructor(map: GenMapping, options: Options);
|
||||||
|
toString(): string;
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
import type { SourceMapInput } from '@jridgewell/trace-mapping';
|
||||||
|
export type { SourceMapSegment, DecodedSourceMap, EncodedSourceMap, } from '@jridgewell/trace-mapping';
|
||||||
|
export type { SourceMapInput };
|
||||||
|
export declare type LoaderContext = {
|
||||||
|
readonly importer: string;
|
||||||
|
readonly depth: number;
|
||||||
|
source: string;
|
||||||
|
content: string | null | undefined;
|
||||||
|
ignore: boolean | undefined;
|
||||||
|
};
|
||||||
|
export declare type SourceMapLoader = (file: string, ctx: LoaderContext) => SourceMapInput | null | undefined | void;
|
||||||
|
export declare type Options = {
|
||||||
|
excludeContent?: boolean;
|
||||||
|
decodedMappings?: boolean;
|
||||||
|
};
|
|
@ -0,0 +1,75 @@
|
||||||
|
{
|
||||||
|
"name": "@ampproject/remapping",
|
||||||
|
"version": "2.3.0",
|
||||||
|
"description": "Remap sequential sourcemaps through transformations to point at the original source code",
|
||||||
|
"keywords": [
|
||||||
|
"source",
|
||||||
|
"map",
|
||||||
|
"remap"
|
||||||
|
],
|
||||||
|
"main": "dist/remapping.umd.js",
|
||||||
|
"module": "dist/remapping.mjs",
|
||||||
|
"types": "dist/types/remapping.d.ts",
|
||||||
|
"exports": {
|
||||||
|
".": [
|
||||||
|
{
|
||||||
|
"types": "./dist/types/remapping.d.ts",
|
||||||
|
"browser": "./dist/remapping.umd.js",
|
||||||
|
"require": "./dist/remapping.umd.js",
|
||||||
|
"import": "./dist/remapping.mjs"
|
||||||
|
},
|
||||||
|
"./dist/remapping.umd.js"
|
||||||
|
],
|
||||||
|
"./package.json": "./package.json"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"author": "Justin Ridgewell <jridgewell@google.com>",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/ampproject/remapping.git"
|
||||||
|
},
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "run-s -n build:*",
|
||||||
|
"build:rollup": "rollup -c rollup.config.js",
|
||||||
|
"build:ts": "tsc --project tsconfig.build.json",
|
||||||
|
"lint": "run-s -n lint:*",
|
||||||
|
"lint:prettier": "npm run test:lint:prettier -- --write",
|
||||||
|
"lint:ts": "npm run test:lint:ts -- --fix",
|
||||||
|
"prebuild": "rm -rf dist",
|
||||||
|
"prepublishOnly": "npm run preversion",
|
||||||
|
"preversion": "run-s test build",
|
||||||
|
"test": "run-s -n test:lint test:only",
|
||||||
|
"test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand",
|
||||||
|
"test:lint": "run-s -n test:lint:*",
|
||||||
|
"test:lint:prettier": "prettier --check '{src,test}/**/*.ts'",
|
||||||
|
"test:lint:ts": "eslint '{src,test}/**/*.ts'",
|
||||||
|
"test:only": "jest --coverage",
|
||||||
|
"test:watch": "jest --coverage --watch"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@rollup/plugin-typescript": "8.3.2",
|
||||||
|
"@types/jest": "27.4.1",
|
||||||
|
"@typescript-eslint/eslint-plugin": "5.20.0",
|
||||||
|
"@typescript-eslint/parser": "5.20.0",
|
||||||
|
"eslint": "8.14.0",
|
||||||
|
"eslint-config-prettier": "8.5.0",
|
||||||
|
"jest": "27.5.1",
|
||||||
|
"jest-config": "27.5.1",
|
||||||
|
"npm-run-all": "4.1.5",
|
||||||
|
"prettier": "2.6.2",
|
||||||
|
"rollup": "2.70.2",
|
||||||
|
"ts-jest": "27.1.4",
|
||||||
|
"tslib": "2.4.0",
|
||||||
|
"typescript": "4.6.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@jridgewell/gen-mapping": "^0.3.5",
|
||||||
|
"@jridgewell/trace-mapping": "^0.3.24"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
The ISC License
|
||||||
|
|
||||||
|
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||||
|
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
@ -0,0 +1,71 @@
|
||||||
|
# fs-minipass
|
||||||
|
|
||||||
|
Filesystem streams based on [minipass](http://npm.im/minipass).
|
||||||
|
|
||||||
|
4 classes are exported:
|
||||||
|
|
||||||
|
- ReadStream
|
||||||
|
- ReadStreamSync
|
||||||
|
- WriteStream
|
||||||
|
- WriteStreamSync
|
||||||
|
|
||||||
|
When using `ReadStreamSync`, all of the data is made available
|
||||||
|
immediately upon consuming the stream. Nothing is buffered in memory
|
||||||
|
when the stream is constructed. If the stream is piped to a writer,
|
||||||
|
then it will synchronously `read()` and emit data into the writer as
|
||||||
|
fast as the writer can consume it. (That is, it will respect
|
||||||
|
backpressure.) If you call `stream.read()` then it will read the
|
||||||
|
entire file and return the contents.
|
||||||
|
|
||||||
|
When using `WriteStreamSync`, every write is flushed to the file
|
||||||
|
synchronously. If your writes all come in a single tick, then it'll
|
||||||
|
write it all out in a single tick. It's as synchronous as you are.
|
||||||
|
|
||||||
|
The async versions work much like their node builtin counterparts,
|
||||||
|
with the exception of introducing significantly less Stream machinery
|
||||||
|
overhead.
|
||||||
|
|
||||||
|
## USAGE
|
||||||
|
|
||||||
|
It's just streams, you pipe them or read() them or write() to them.
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { ReadStream, WriteStream } from 'fs-minipass'
|
||||||
|
// or: const { ReadStream, WriteStream } = require('fs-minipass')
|
||||||
|
const readStream = new ReadStream('file.txt')
|
||||||
|
const writeStream = new WriteStream('output.txt')
|
||||||
|
writeStream.write('some file header or whatever\n')
|
||||||
|
readStream.pipe(writeStream)
|
||||||
|
```
|
||||||
|
|
||||||
|
## ReadStream(path, options)
|
||||||
|
|
||||||
|
Path string is required, but somewhat irrelevant if an open file
|
||||||
|
descriptor is passed in as an option.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
- `fd` Pass in a numeric file descriptor, if the file is already open.
|
||||||
|
- `readSize` The size of reads to do, defaults to 16MB
|
||||||
|
- `size` The size of the file, if known. Prevents zero-byte read()
|
||||||
|
call at the end.
|
||||||
|
- `autoClose` Set to `false` to prevent the file descriptor from being
|
||||||
|
closed when the file is done being read.
|
||||||
|
|
||||||
|
## WriteStream(path, options)
|
||||||
|
|
||||||
|
Path string is required, but somewhat irrelevant if an open file
|
||||||
|
descriptor is passed in as an option.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
- `fd` Pass in a numeric file descriptor, if the file is already open.
|
||||||
|
- `mode` The mode to create the file with. Defaults to `0o666`.
|
||||||
|
- `start` The position in the file to start reading. If not
|
||||||
|
specified, then the file will start writing at position zero, and be
|
||||||
|
truncated by default.
|
||||||
|
- `autoClose` Set to `false` to prevent the file descriptor from being
|
||||||
|
closed when the stream is ended.
|
||||||
|
- `flags` Flags to use when opening the file. Irrelevant if `fd` is
|
||||||
|
passed in, since file won't be opened in that case. Defaults to
|
||||||
|
`'a'` if a `pos` is specified, or `'w'` otherwise.
|
|
@ -0,0 +1,118 @@
|
||||||
|
/// <reference types="node" />
|
||||||
|
/// <reference types="node" />
|
||||||
|
/// <reference types="node" />
|
||||||
|
import EE from 'events';
|
||||||
|
import { Minipass } from 'minipass';
|
||||||
|
declare const _autoClose: unique symbol;
|
||||||
|
declare const _close: unique symbol;
|
||||||
|
declare const _ended: unique symbol;
|
||||||
|
declare const _fd: unique symbol;
|
||||||
|
declare const _finished: unique symbol;
|
||||||
|
declare const _flags: unique symbol;
|
||||||
|
declare const _flush: unique symbol;
|
||||||
|
declare const _handleChunk: unique symbol;
|
||||||
|
declare const _makeBuf: unique symbol;
|
||||||
|
declare const _mode: unique symbol;
|
||||||
|
declare const _needDrain: unique symbol;
|
||||||
|
declare const _onerror: unique symbol;
|
||||||
|
declare const _onopen: unique symbol;
|
||||||
|
declare const _onread: unique symbol;
|
||||||
|
declare const _onwrite: unique symbol;
|
||||||
|
declare const _open: unique symbol;
|
||||||
|
declare const _path: unique symbol;
|
||||||
|
declare const _pos: unique symbol;
|
||||||
|
declare const _queue: unique symbol;
|
||||||
|
declare const _read: unique symbol;
|
||||||
|
declare const _readSize: unique symbol;
|
||||||
|
declare const _reading: unique symbol;
|
||||||
|
declare const _remain: unique symbol;
|
||||||
|
declare const _size: unique symbol;
|
||||||
|
declare const _write: unique symbol;
|
||||||
|
declare const _writing: unique symbol;
|
||||||
|
declare const _defaultFlag: unique symbol;
|
||||||
|
declare const _errored: unique symbol;
|
||||||
|
export type ReadStreamOptions = Minipass.Options<Minipass.ContiguousData> & {
|
||||||
|
fd?: number;
|
||||||
|
readSize?: number;
|
||||||
|
size?: number;
|
||||||
|
autoClose?: boolean;
|
||||||
|
};
|
||||||
|
export type ReadStreamEvents = Minipass.Events<Minipass.ContiguousData> & {
|
||||||
|
open: [fd: number];
|
||||||
|
};
|
||||||
|
export declare class ReadStream extends Minipass<Minipass.ContiguousData, Buffer, ReadStreamEvents> {
|
||||||
|
[_errored]: boolean;
|
||||||
|
[_fd]?: number;
|
||||||
|
[_path]: string;
|
||||||
|
[_readSize]: number;
|
||||||
|
[_reading]: boolean;
|
||||||
|
[_size]: number;
|
||||||
|
[_remain]: number;
|
||||||
|
[_autoClose]: boolean;
|
||||||
|
constructor(path: string, opt: ReadStreamOptions);
|
||||||
|
get fd(): number | undefined;
|
||||||
|
get path(): string;
|
||||||
|
write(): void;
|
||||||
|
end(): void;
|
||||||
|
[_open](): void;
|
||||||
|
[_onopen](er?: NodeJS.ErrnoException | null, fd?: number): void;
|
||||||
|
[_makeBuf](): Buffer;
|
||||||
|
[_read](): void;
|
||||||
|
[_onread](er?: NodeJS.ErrnoException | null, br?: number, buf?: Buffer): void;
|
||||||
|
[_close](): void;
|
||||||
|
[_onerror](er: NodeJS.ErrnoException): void;
|
||||||
|
[_handleChunk](br: number, buf: Buffer): boolean;
|
||||||
|
emit<Event extends keyof ReadStreamEvents>(ev: Event, ...args: ReadStreamEvents[Event]): boolean;
|
||||||
|
}
|
||||||
|
export declare class ReadStreamSync extends ReadStream {
|
||||||
|
[_open](): void;
|
||||||
|
[_read](): void;
|
||||||
|
[_close](): void;
|
||||||
|
}
|
||||||
|
export type WriteStreamOptions = {
|
||||||
|
fd?: number;
|
||||||
|
autoClose?: boolean;
|
||||||
|
mode?: number;
|
||||||
|
captureRejections?: boolean;
|
||||||
|
start?: number;
|
||||||
|
flags?: string;
|
||||||
|
};
|
||||||
|
export declare class WriteStream extends EE {
|
||||||
|
readable: false;
|
||||||
|
writable: boolean;
|
||||||
|
[_errored]: boolean;
|
||||||
|
[_writing]: boolean;
|
||||||
|
[_ended]: boolean;
|
||||||
|
[_queue]: Buffer[];
|
||||||
|
[_needDrain]: boolean;
|
||||||
|
[_path]: string;
|
||||||
|
[_mode]: number;
|
||||||
|
[_autoClose]: boolean;
|
||||||
|
[_fd]?: number;
|
||||||
|
[_defaultFlag]: boolean;
|
||||||
|
[_flags]: string;
|
||||||
|
[_finished]: boolean;
|
||||||
|
[_pos]?: number;
|
||||||
|
constructor(path: string, opt: WriteStreamOptions);
|
||||||
|
emit(ev: string, ...args: any[]): boolean;
|
||||||
|
get fd(): number | undefined;
|
||||||
|
get path(): string;
|
||||||
|
[_onerror](er: NodeJS.ErrnoException): void;
|
||||||
|
[_open](): void;
|
||||||
|
[_onopen](er?: null | NodeJS.ErrnoException, fd?: number): void;
|
||||||
|
end(buf: string, enc?: BufferEncoding): this;
|
||||||
|
end(buf?: Buffer, enc?: undefined): this;
|
||||||
|
write(buf: string, enc?: BufferEncoding): boolean;
|
||||||
|
write(buf: Buffer, enc?: undefined): boolean;
|
||||||
|
[_write](buf: Buffer): void;
|
||||||
|
[_onwrite](er?: null | NodeJS.ErrnoException, bw?: number): void;
|
||||||
|
[_flush](): void;
|
||||||
|
[_close](): void;
|
||||||
|
}
|
||||||
|
export declare class WriteStreamSync extends WriteStream {
|
||||||
|
[_open](): void;
|
||||||
|
[_close](): void;
|
||||||
|
[_write](buf: Buffer): void;
|
||||||
|
}
|
||||||
|
export {};
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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"}
|
|
@ -0,0 +1,430 @@
|
||||||
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.WriteStreamSync = exports.WriteStream = exports.ReadStreamSync = exports.ReadStream = void 0;
|
||||||
|
const events_1 = __importDefault(require("events"));
|
||||||
|
const fs_1 = __importDefault(require("fs"));
|
||||||
|
const minipass_1 = require("minipass");
|
||||||
|
const writev = fs_1.default.writev;
|
||||||
|
const _autoClose = Symbol('_autoClose');
|
||||||
|
const _close = Symbol('_close');
|
||||||
|
const _ended = Symbol('_ended');
|
||||||
|
const _fd = Symbol('_fd');
|
||||||
|
const _finished = Symbol('_finished');
|
||||||
|
const _flags = Symbol('_flags');
|
||||||
|
const _flush = Symbol('_flush');
|
||||||
|
const _handleChunk = Symbol('_handleChunk');
|
||||||
|
const _makeBuf = Symbol('_makeBuf');
|
||||||
|
const _mode = Symbol('_mode');
|
||||||
|
const _needDrain = Symbol('_needDrain');
|
||||||
|
const _onerror = Symbol('_onerror');
|
||||||
|
const _onopen = Symbol('_onopen');
|
||||||
|
const _onread = Symbol('_onread');
|
||||||
|
const _onwrite = Symbol('_onwrite');
|
||||||
|
const _open = Symbol('_open');
|
||||||
|
const _path = Symbol('_path');
|
||||||
|
const _pos = Symbol('_pos');
|
||||||
|
const _queue = Symbol('_queue');
|
||||||
|
const _read = Symbol('_read');
|
||||||
|
const _readSize = Symbol('_readSize');
|
||||||
|
const _reading = Symbol('_reading');
|
||||||
|
const _remain = Symbol('_remain');
|
||||||
|
const _size = Symbol('_size');
|
||||||
|
const _write = Symbol('_write');
|
||||||
|
const _writing = Symbol('_writing');
|
||||||
|
const _defaultFlag = Symbol('_defaultFlag');
|
||||||
|
const _errored = Symbol('_errored');
|
||||||
|
class ReadStream extends minipass_1.Minipass {
|
||||||
|
[_errored] = false;
|
||||||
|
[_fd];
|
||||||
|
[_path];
|
||||||
|
[_readSize];
|
||||||
|
[_reading] = false;
|
||||||
|
[_size];
|
||||||
|
[_remain];
|
||||||
|
[_autoClose];
|
||||||
|
constructor(path, opt) {
|
||||||
|
opt = opt || {};
|
||||||
|
super(opt);
|
||||||
|
this.readable = true;
|
||||||
|
this.writable = false;
|
||||||
|
if (typeof path !== 'string') {
|
||||||
|
throw new TypeError('path must be a string');
|
||||||
|
}
|
||||||
|
this[_errored] = false;
|
||||||
|
this[_fd] = typeof opt.fd === 'number' ? opt.fd : undefined;
|
||||||
|
this[_path] = path;
|
||||||
|
this[_readSize] = opt.readSize || 16 * 1024 * 1024;
|
||||||
|
this[_reading] = false;
|
||||||
|
this[_size] = typeof opt.size === 'number' ? opt.size : Infinity;
|
||||||
|
this[_remain] = this[_size];
|
||||||
|
this[_autoClose] =
|
||||||
|
typeof opt.autoClose === 'boolean' ? opt.autoClose : true;
|
||||||
|
if (typeof this[_fd] === 'number') {
|
||||||
|
this[_read]();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this[_open]();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
get fd() {
|
||||||
|
return this[_fd];
|
||||||
|
}
|
||||||
|
get path() {
|
||||||
|
return this[_path];
|
||||||
|
}
|
||||||
|
//@ts-ignore
|
||||||
|
write() {
|
||||||
|
throw new TypeError('this is a readable stream');
|
||||||
|
}
|
||||||
|
//@ts-ignore
|
||||||
|
end() {
|
||||||
|
throw new TypeError('this is a readable stream');
|
||||||
|
}
|
||||||
|
[_open]() {
|
||||||
|
fs_1.default.open(this[_path], 'r', (er, fd) => this[_onopen](er, fd));
|
||||||
|
}
|
||||||
|
[_onopen](er, fd) {
|
||||||
|
if (er) {
|
||||||
|
this[_onerror](er);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this[_fd] = fd;
|
||||||
|
this.emit('open', fd);
|
||||||
|
this[_read]();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[_makeBuf]() {
|
||||||
|
return Buffer.allocUnsafe(Math.min(this[_readSize], this[_remain]));
|
||||||
|
}
|
||||||
|
[_read]() {
|
||||||
|
if (!this[_reading]) {
|
||||||
|
this[_reading] = true;
|
||||||
|
const buf = this[_makeBuf]();
|
||||||
|
/* c8 ignore start */
|
||||||
|
if (buf.length === 0) {
|
||||||
|
return process.nextTick(() => this[_onread](null, 0, buf));
|
||||||
|
}
|
||||||
|
/* c8 ignore stop */
|
||||||
|
fs_1.default.read(this[_fd], buf, 0, buf.length, null, (er, br, b) => this[_onread](er, br, b));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[_onread](er, br, buf) {
|
||||||
|
this[_reading] = false;
|
||||||
|
if (er) {
|
||||||
|
this[_onerror](er);
|
||||||
|
}
|
||||||
|
else if (this[_handleChunk](br, buf)) {
|
||||||
|
this[_read]();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[_close]() {
|
||||||
|
if (this[_autoClose] && typeof this[_fd] === 'number') {
|
||||||
|
const fd = this[_fd];
|
||||||
|
this[_fd] = undefined;
|
||||||
|
fs_1.default.close(fd, er => er ? this.emit('error', er) : this.emit('close'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[_onerror](er) {
|
||||||
|
this[_reading] = true;
|
||||||
|
this[_close]();
|
||||||
|
this.emit('error', er);
|
||||||
|
}
|
||||||
|
[_handleChunk](br, buf) {
|
||||||
|
let ret = false;
|
||||||
|
// no effect if infinite
|
||||||
|
this[_remain] -= br;
|
||||||
|
if (br > 0) {
|
||||||
|
ret = super.write(br < buf.length ? buf.subarray(0, br) : buf);
|
||||||
|
}
|
||||||
|
if (br === 0 || this[_remain] <= 0) {
|
||||||
|
ret = false;
|
||||||
|
this[_close]();
|
||||||
|
super.end();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
emit(ev, ...args) {
|
||||||
|
switch (ev) {
|
||||||
|
case 'prefinish':
|
||||||
|
case 'finish':
|
||||||
|
return false;
|
||||||
|
case 'drain':
|
||||||
|
if (typeof this[_fd] === 'number') {
|
||||||
|
this[_read]();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case 'error':
|
||||||
|
if (this[_errored]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this[_errored] = true;
|
||||||
|
return super.emit(ev, ...args);
|
||||||
|
default:
|
||||||
|
return super.emit(ev, ...args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.ReadStream = ReadStream;
|
||||||
|
class ReadStreamSync extends ReadStream {
|
||||||
|
[_open]() {
|
||||||
|
let threw = true;
|
||||||
|
try {
|
||||||
|
this[_onopen](null, fs_1.default.openSync(this[_path], 'r'));
|
||||||
|
threw = false;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (threw) {
|
||||||
|
this[_close]();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[_read]() {
|
||||||
|
let threw = true;
|
||||||
|
try {
|
||||||
|
if (!this[_reading]) {
|
||||||
|
this[_reading] = true;
|
||||||
|
do {
|
||||||
|
const buf = this[_makeBuf]();
|
||||||
|
/* c8 ignore start */
|
||||||
|
const br = buf.length === 0
|
||||||
|
? 0
|
||||||
|
: fs_1.default.readSync(this[_fd], buf, 0, buf.length, null);
|
||||||
|
/* c8 ignore stop */
|
||||||
|
if (!this[_handleChunk](br, buf)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (true);
|
||||||
|
this[_reading] = false;
|
||||||
|
}
|
||||||
|
threw = false;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (threw) {
|
||||||
|
this[_close]();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[_close]() {
|
||||||
|
if (this[_autoClose] && typeof this[_fd] === 'number') {
|
||||||
|
const fd = this[_fd];
|
||||||
|
this[_fd] = undefined;
|
||||||
|
fs_1.default.closeSync(fd);
|
||||||
|
this.emit('close');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.ReadStreamSync = ReadStreamSync;
|
||||||
|
class WriteStream extends events_1.default {
|
||||||
|
readable = false;
|
||||||
|
writable = true;
|
||||||
|
[_errored] = false;
|
||||||
|
[_writing] = false;
|
||||||
|
[_ended] = false;
|
||||||
|
[_queue] = [];
|
||||||
|
[_needDrain] = false;
|
||||||
|
[_path];
|
||||||
|
[_mode];
|
||||||
|
[_autoClose];
|
||||||
|
[_fd];
|
||||||
|
[_defaultFlag];
|
||||||
|
[_flags];
|
||||||
|
[_finished] = false;
|
||||||
|
[_pos];
|
||||||
|
constructor(path, opt) {
|
||||||
|
opt = opt || {};
|
||||||
|
super(opt);
|
||||||
|
this[_path] = path;
|
||||||
|
this[_fd] = typeof opt.fd === 'number' ? opt.fd : undefined;
|
||||||
|
this[_mode] = opt.mode === undefined ? 0o666 : opt.mode;
|
||||||
|
this[_pos] = typeof opt.start === 'number' ? opt.start : undefined;
|
||||||
|
this[_autoClose] =
|
||||||
|
typeof opt.autoClose === 'boolean' ? opt.autoClose : true;
|
||||||
|
// truncating makes no sense when writing into the middle
|
||||||
|
const defaultFlag = this[_pos] !== undefined ? 'r+' : 'w';
|
||||||
|
this[_defaultFlag] = opt.flags === undefined;
|
||||||
|
this[_flags] = opt.flags === undefined ? defaultFlag : opt.flags;
|
||||||
|
if (this[_fd] === undefined) {
|
||||||
|
this[_open]();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
emit(ev, ...args) {
|
||||||
|
if (ev === 'error') {
|
||||||
|
if (this[_errored]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this[_errored] = true;
|
||||||
|
}
|
||||||
|
return super.emit(ev, ...args);
|
||||||
|
}
|
||||||
|
get fd() {
|
||||||
|
return this[_fd];
|
||||||
|
}
|
||||||
|
get path() {
|
||||||
|
return this[_path];
|
||||||
|
}
|
||||||
|
[_onerror](er) {
|
||||||
|
this[_close]();
|
||||||
|
this[_writing] = true;
|
||||||
|
this.emit('error', er);
|
||||||
|
}
|
||||||
|
[_open]() {
|
||||||
|
fs_1.default.open(this[_path], this[_flags], this[_mode], (er, fd) => this[_onopen](er, fd));
|
||||||
|
}
|
||||||
|
[_onopen](er, fd) {
|
||||||
|
if (this[_defaultFlag] &&
|
||||||
|
this[_flags] === 'r+' &&
|
||||||
|
er &&
|
||||||
|
er.code === 'ENOENT') {
|
||||||
|
this[_flags] = 'w';
|
||||||
|
this[_open]();
|
||||||
|
}
|
||||||
|
else if (er) {
|
||||||
|
this[_onerror](er);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this[_fd] = fd;
|
||||||
|
this.emit('open', fd);
|
||||||
|
if (!this[_writing]) {
|
||||||
|
this[_flush]();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end(buf, enc) {
|
||||||
|
if (buf) {
|
||||||
|
//@ts-ignore
|
||||||
|
this.write(buf, enc);
|
||||||
|
}
|
||||||
|
this[_ended] = true;
|
||||||
|
// synthetic after-write logic, where drain/finish live
|
||||||
|
if (!this[_writing] &&
|
||||||
|
!this[_queue].length &&
|
||||||
|
typeof this[_fd] === 'number') {
|
||||||
|
this[_onwrite](null, 0);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
write(buf, enc) {
|
||||||
|
if (typeof buf === 'string') {
|
||||||
|
buf = Buffer.from(buf, enc);
|
||||||
|
}
|
||||||
|
if (this[_ended]) {
|
||||||
|
this.emit('error', new Error('write() after end()'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this[_fd] === undefined || this[_writing] || this[_queue].length) {
|
||||||
|
this[_queue].push(buf);
|
||||||
|
this[_needDrain] = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this[_writing] = true;
|
||||||
|
this[_write](buf);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
[_write](buf) {
|
||||||
|
fs_1.default.write(this[_fd], buf, 0, buf.length, this[_pos], (er, bw) => this[_onwrite](er, bw));
|
||||||
|
}
|
||||||
|
[_onwrite](er, bw) {
|
||||||
|
if (er) {
|
||||||
|
this[_onerror](er);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (this[_pos] !== undefined && typeof bw === 'number') {
|
||||||
|
this[_pos] += bw;
|
||||||
|
}
|
||||||
|
if (this[_queue].length) {
|
||||||
|
this[_flush]();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this[_writing] = false;
|
||||||
|
if (this[_ended] && !this[_finished]) {
|
||||||
|
this[_finished] = true;
|
||||||
|
this[_close]();
|
||||||
|
this.emit('finish');
|
||||||
|
}
|
||||||
|
else if (this[_needDrain]) {
|
||||||
|
this[_needDrain] = false;
|
||||||
|
this.emit('drain');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[_flush]() {
|
||||||
|
if (this[_queue].length === 0) {
|
||||||
|
if (this[_ended]) {
|
||||||
|
this[_onwrite](null, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (this[_queue].length === 1) {
|
||||||
|
this[_write](this[_queue].pop());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const iovec = this[_queue];
|
||||||
|
this[_queue] = [];
|
||||||
|
writev(this[_fd], iovec, this[_pos], (er, bw) => this[_onwrite](er, bw));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[_close]() {
|
||||||
|
if (this[_autoClose] && typeof this[_fd] === 'number') {
|
||||||
|
const fd = this[_fd];
|
||||||
|
this[_fd] = undefined;
|
||||||
|
fs_1.default.close(fd, er => er ? this.emit('error', er) : this.emit('close'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.WriteStream = WriteStream;
|
||||||
|
class WriteStreamSync extends WriteStream {
|
||||||
|
[_open]() {
|
||||||
|
let fd;
|
||||||
|
// only wrap in a try{} block if we know we'll retry, to avoid
|
||||||
|
// the rethrow obscuring the error's source frame in most cases.
|
||||||
|
if (this[_defaultFlag] && this[_flags] === 'r+') {
|
||||||
|
try {
|
||||||
|
fd = fs_1.default.openSync(this[_path], this[_flags], this[_mode]);
|
||||||
|
}
|
||||||
|
catch (er) {
|
||||||
|
if (er?.code === 'ENOENT') {
|
||||||
|
this[_flags] = 'w';
|
||||||
|
return this[_open]();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw er;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fd = fs_1.default.openSync(this[_path], this[_flags], this[_mode]);
|
||||||
|
}
|
||||||
|
this[_onopen](null, fd);
|
||||||
|
}
|
||||||
|
[_close]() {
|
||||||
|
if (this[_autoClose] && typeof this[_fd] === 'number') {
|
||||||
|
const fd = this[_fd];
|
||||||
|
this[_fd] = undefined;
|
||||||
|
fs_1.default.closeSync(fd);
|
||||||
|
this.emit('close');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[_write](buf) {
|
||||||
|
// throw the original, but try to close if it fails
|
||||||
|
let threw = true;
|
||||||
|
try {
|
||||||
|
this[_onwrite](null, fs_1.default.writeSync(this[_fd], buf, 0, buf.length, this[_pos]));
|
||||||
|
threw = false;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (threw) {
|
||||||
|
try {
|
||||||
|
this[_close]();
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// ok error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.WriteStreamSync = WriteStreamSync;
|
||||||
|
//# sourceMappingURL=index.js.map
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"type": "commonjs"
|
||||||
|
}
|
|
@ -0,0 +1,118 @@
|
||||||
|
/// <reference types="node" resolution-mode="require"/>
|
||||||
|
/// <reference types="node" resolution-mode="require"/>
|
||||||
|
/// <reference types="node" resolution-mode="require"/>
|
||||||
|
import EE from 'events';
|
||||||
|
import { Minipass } from 'minipass';
|
||||||
|
declare const _autoClose: unique symbol;
|
||||||
|
declare const _close: unique symbol;
|
||||||
|
declare const _ended: unique symbol;
|
||||||
|
declare const _fd: unique symbol;
|
||||||
|
declare const _finished: unique symbol;
|
||||||
|
declare const _flags: unique symbol;
|
||||||
|
declare const _flush: unique symbol;
|
||||||
|
declare const _handleChunk: unique symbol;
|
||||||
|
declare const _makeBuf: unique symbol;
|
||||||
|
declare const _mode: unique symbol;
|
||||||
|
declare const _needDrain: unique symbol;
|
||||||
|
declare const _onerror: unique symbol;
|
||||||
|
declare const _onopen: unique symbol;
|
||||||
|
declare const _onread: unique symbol;
|
||||||
|
declare const _onwrite: unique symbol;
|
||||||
|
declare const _open: unique symbol;
|
||||||
|
declare const _path: unique symbol;
|
||||||
|
declare const _pos: unique symbol;
|
||||||
|
declare const _queue: unique symbol;
|
||||||
|
declare const _read: unique symbol;
|
||||||
|
declare const _readSize: unique symbol;
|
||||||
|
declare const _reading: unique symbol;
|
||||||
|
declare const _remain: unique symbol;
|
||||||
|
declare const _size: unique symbol;
|
||||||
|
declare const _write: unique symbol;
|
||||||
|
declare const _writing: unique symbol;
|
||||||
|
declare const _defaultFlag: unique symbol;
|
||||||
|
declare const _errored: unique symbol;
|
||||||
|
export type ReadStreamOptions = Minipass.Options<Minipass.ContiguousData> & {
|
||||||
|
fd?: number;
|
||||||
|
readSize?: number;
|
||||||
|
size?: number;
|
||||||
|
autoClose?: boolean;
|
||||||
|
};
|
||||||
|
export type ReadStreamEvents = Minipass.Events<Minipass.ContiguousData> & {
|
||||||
|
open: [fd: number];
|
||||||
|
};
|
||||||
|
export declare class ReadStream extends Minipass<Minipass.ContiguousData, Buffer, ReadStreamEvents> {
|
||||||
|
[_errored]: boolean;
|
||||||
|
[_fd]?: number;
|
||||||
|
[_path]: string;
|
||||||
|
[_readSize]: number;
|
||||||
|
[_reading]: boolean;
|
||||||
|
[_size]: number;
|
||||||
|
[_remain]: number;
|
||||||
|
[_autoClose]: boolean;
|
||||||
|
constructor(path: string, opt: ReadStreamOptions);
|
||||||
|
get fd(): number | undefined;
|
||||||
|
get path(): string;
|
||||||
|
write(): void;
|
||||||
|
end(): void;
|
||||||
|
[_open](): void;
|
||||||
|
[_onopen](er?: NodeJS.ErrnoException | null, fd?: number): void;
|
||||||
|
[_makeBuf](): Buffer;
|
||||||
|
[_read](): void;
|
||||||
|
[_onread](er?: NodeJS.ErrnoException | null, br?: number, buf?: Buffer): void;
|
||||||
|
[_close](): void;
|
||||||
|
[_onerror](er: NodeJS.ErrnoException): void;
|
||||||
|
[_handleChunk](br: number, buf: Buffer): boolean;
|
||||||
|
emit<Event extends keyof ReadStreamEvents>(ev: Event, ...args: ReadStreamEvents[Event]): boolean;
|
||||||
|
}
|
||||||
|
export declare class ReadStreamSync extends ReadStream {
|
||||||
|
[_open](): void;
|
||||||
|
[_read](): void;
|
||||||
|
[_close](): void;
|
||||||
|
}
|
||||||
|
export type WriteStreamOptions = {
|
||||||
|
fd?: number;
|
||||||
|
autoClose?: boolean;
|
||||||
|
mode?: number;
|
||||||
|
captureRejections?: boolean;
|
||||||
|
start?: number;
|
||||||
|
flags?: string;
|
||||||
|
};
|
||||||
|
export declare class WriteStream extends EE {
|
||||||
|
readable: false;
|
||||||
|
writable: boolean;
|
||||||
|
[_errored]: boolean;
|
||||||
|
[_writing]: boolean;
|
||||||
|
[_ended]: boolean;
|
||||||
|
[_queue]: Buffer[];
|
||||||
|
[_needDrain]: boolean;
|
||||||
|
[_path]: string;
|
||||||
|
[_mode]: number;
|
||||||
|
[_autoClose]: boolean;
|
||||||
|
[_fd]?: number;
|
||||||
|
[_defaultFlag]: boolean;
|
||||||
|
[_flags]: string;
|
||||||
|
[_finished]: boolean;
|
||||||
|
[_pos]?: number;
|
||||||
|
constructor(path: string, opt: WriteStreamOptions);
|
||||||
|
emit(ev: string, ...args: any[]): boolean;
|
||||||
|
get fd(): number | undefined;
|
||||||
|
get path(): string;
|
||||||
|
[_onerror](er: NodeJS.ErrnoException): void;
|
||||||
|
[_open](): void;
|
||||||
|
[_onopen](er?: null | NodeJS.ErrnoException, fd?: number): void;
|
||||||
|
end(buf: string, enc?: BufferEncoding): this;
|
||||||
|
end(buf?: Buffer, enc?: undefined): this;
|
||||||
|
write(buf: string, enc?: BufferEncoding): boolean;
|
||||||
|
write(buf: Buffer, enc?: undefined): boolean;
|
||||||
|
[_write](buf: Buffer): void;
|
||||||
|
[_onwrite](er?: null | NodeJS.ErrnoException, bw?: number): void;
|
||||||
|
[_flush](): void;
|
||||||
|
[_close](): void;
|
||||||
|
}
|
||||||
|
export declare class WriteStreamSync extends WriteStream {
|
||||||
|
[_open](): void;
|
||||||
|
[_close](): void;
|
||||||
|
[_write](buf: Buffer): void;
|
||||||
|
}
|
||||||
|
export {};
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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"}
|
|
@ -0,0 +1,420 @@
|
||||||
|
import EE from 'events';
|
||||||
|
import fs from 'fs';
|
||||||
|
import { Minipass } from 'minipass';
|
||||||
|
const writev = fs.writev;
|
||||||
|
const _autoClose = Symbol('_autoClose');
|
||||||
|
const _close = Symbol('_close');
|
||||||
|
const _ended = Symbol('_ended');
|
||||||
|
const _fd = Symbol('_fd');
|
||||||
|
const _finished = Symbol('_finished');
|
||||||
|
const _flags = Symbol('_flags');
|
||||||
|
const _flush = Symbol('_flush');
|
||||||
|
const _handleChunk = Symbol('_handleChunk');
|
||||||
|
const _makeBuf = Symbol('_makeBuf');
|
||||||
|
const _mode = Symbol('_mode');
|
||||||
|
const _needDrain = Symbol('_needDrain');
|
||||||
|
const _onerror = Symbol('_onerror');
|
||||||
|
const _onopen = Symbol('_onopen');
|
||||||
|
const _onread = Symbol('_onread');
|
||||||
|
const _onwrite = Symbol('_onwrite');
|
||||||
|
const _open = Symbol('_open');
|
||||||
|
const _path = Symbol('_path');
|
||||||
|
const _pos = Symbol('_pos');
|
||||||
|
const _queue = Symbol('_queue');
|
||||||
|
const _read = Symbol('_read');
|
||||||
|
const _readSize = Symbol('_readSize');
|
||||||
|
const _reading = Symbol('_reading');
|
||||||
|
const _remain = Symbol('_remain');
|
||||||
|
const _size = Symbol('_size');
|
||||||
|
const _write = Symbol('_write');
|
||||||
|
const _writing = Symbol('_writing');
|
||||||
|
const _defaultFlag = Symbol('_defaultFlag');
|
||||||
|
const _errored = Symbol('_errored');
|
||||||
|
export class ReadStream extends Minipass {
|
||||||
|
[_errored] = false;
|
||||||
|
[_fd];
|
||||||
|
[_path];
|
||||||
|
[_readSize];
|
||||||
|
[_reading] = false;
|
||||||
|
[_size];
|
||||||
|
[_remain];
|
||||||
|
[_autoClose];
|
||||||
|
constructor(path, opt) {
|
||||||
|
opt = opt || {};
|
||||||
|
super(opt);
|
||||||
|
this.readable = true;
|
||||||
|
this.writable = false;
|
||||||
|
if (typeof path !== 'string') {
|
||||||
|
throw new TypeError('path must be a string');
|
||||||
|
}
|
||||||
|
this[_errored] = false;
|
||||||
|
this[_fd] = typeof opt.fd === 'number' ? opt.fd : undefined;
|
||||||
|
this[_path] = path;
|
||||||
|
this[_readSize] = opt.readSize || 16 * 1024 * 1024;
|
||||||
|
this[_reading] = false;
|
||||||
|
this[_size] = typeof opt.size === 'number' ? opt.size : Infinity;
|
||||||
|
this[_remain] = this[_size];
|
||||||
|
this[_autoClose] =
|
||||||
|
typeof opt.autoClose === 'boolean' ? opt.autoClose : true;
|
||||||
|
if (typeof this[_fd] === 'number') {
|
||||||
|
this[_read]();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this[_open]();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
get fd() {
|
||||||
|
return this[_fd];
|
||||||
|
}
|
||||||
|
get path() {
|
||||||
|
return this[_path];
|
||||||
|
}
|
||||||
|
//@ts-ignore
|
||||||
|
write() {
|
||||||
|
throw new TypeError('this is a readable stream');
|
||||||
|
}
|
||||||
|
//@ts-ignore
|
||||||
|
end() {
|
||||||
|
throw new TypeError('this is a readable stream');
|
||||||
|
}
|
||||||
|
[_open]() {
|
||||||
|
fs.open(this[_path], 'r', (er, fd) => this[_onopen](er, fd));
|
||||||
|
}
|
||||||
|
[_onopen](er, fd) {
|
||||||
|
if (er) {
|
||||||
|
this[_onerror](er);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this[_fd] = fd;
|
||||||
|
this.emit('open', fd);
|
||||||
|
this[_read]();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[_makeBuf]() {
|
||||||
|
return Buffer.allocUnsafe(Math.min(this[_readSize], this[_remain]));
|
||||||
|
}
|
||||||
|
[_read]() {
|
||||||
|
if (!this[_reading]) {
|
||||||
|
this[_reading] = true;
|
||||||
|
const buf = this[_makeBuf]();
|
||||||
|
/* c8 ignore start */
|
||||||
|
if (buf.length === 0) {
|
||||||
|
return process.nextTick(() => this[_onread](null, 0, buf));
|
||||||
|
}
|
||||||
|
/* c8 ignore stop */
|
||||||
|
fs.read(this[_fd], buf, 0, buf.length, null, (er, br, b) => this[_onread](er, br, b));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[_onread](er, br, buf) {
|
||||||
|
this[_reading] = false;
|
||||||
|
if (er) {
|
||||||
|
this[_onerror](er);
|
||||||
|
}
|
||||||
|
else if (this[_handleChunk](br, buf)) {
|
||||||
|
this[_read]();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[_close]() {
|
||||||
|
if (this[_autoClose] && typeof this[_fd] === 'number') {
|
||||||
|
const fd = this[_fd];
|
||||||
|
this[_fd] = undefined;
|
||||||
|
fs.close(fd, er => er ? this.emit('error', er) : this.emit('close'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[_onerror](er) {
|
||||||
|
this[_reading] = true;
|
||||||
|
this[_close]();
|
||||||
|
this.emit('error', er);
|
||||||
|
}
|
||||||
|
[_handleChunk](br, buf) {
|
||||||
|
let ret = false;
|
||||||
|
// no effect if infinite
|
||||||
|
this[_remain] -= br;
|
||||||
|
if (br > 0) {
|
||||||
|
ret = super.write(br < buf.length ? buf.subarray(0, br) : buf);
|
||||||
|
}
|
||||||
|
if (br === 0 || this[_remain] <= 0) {
|
||||||
|
ret = false;
|
||||||
|
this[_close]();
|
||||||
|
super.end();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
emit(ev, ...args) {
|
||||||
|
switch (ev) {
|
||||||
|
case 'prefinish':
|
||||||
|
case 'finish':
|
||||||
|
return false;
|
||||||
|
case 'drain':
|
||||||
|
if (typeof this[_fd] === 'number') {
|
||||||
|
this[_read]();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case 'error':
|
||||||
|
if (this[_errored]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this[_errored] = true;
|
||||||
|
return super.emit(ev, ...args);
|
||||||
|
default:
|
||||||
|
return super.emit(ev, ...args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class ReadStreamSync extends ReadStream {
|
||||||
|
[_open]() {
|
||||||
|
let threw = true;
|
||||||
|
try {
|
||||||
|
this[_onopen](null, fs.openSync(this[_path], 'r'));
|
||||||
|
threw = false;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (threw) {
|
||||||
|
this[_close]();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[_read]() {
|
||||||
|
let threw = true;
|
||||||
|
try {
|
||||||
|
if (!this[_reading]) {
|
||||||
|
this[_reading] = true;
|
||||||
|
do {
|
||||||
|
const buf = this[_makeBuf]();
|
||||||
|
/* c8 ignore start */
|
||||||
|
const br = buf.length === 0
|
||||||
|
? 0
|
||||||
|
: fs.readSync(this[_fd], buf, 0, buf.length, null);
|
||||||
|
/* c8 ignore stop */
|
||||||
|
if (!this[_handleChunk](br, buf)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (true);
|
||||||
|
this[_reading] = false;
|
||||||
|
}
|
||||||
|
threw = false;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (threw) {
|
||||||
|
this[_close]();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[_close]() {
|
||||||
|
if (this[_autoClose] && typeof this[_fd] === 'number') {
|
||||||
|
const fd = this[_fd];
|
||||||
|
this[_fd] = undefined;
|
||||||
|
fs.closeSync(fd);
|
||||||
|
this.emit('close');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class WriteStream extends EE {
|
||||||
|
readable = false;
|
||||||
|
writable = true;
|
||||||
|
[_errored] = false;
|
||||||
|
[_writing] = false;
|
||||||
|
[_ended] = false;
|
||||||
|
[_queue] = [];
|
||||||
|
[_needDrain] = false;
|
||||||
|
[_path];
|
||||||
|
[_mode];
|
||||||
|
[_autoClose];
|
||||||
|
[_fd];
|
||||||
|
[_defaultFlag];
|
||||||
|
[_flags];
|
||||||
|
[_finished] = false;
|
||||||
|
[_pos];
|
||||||
|
constructor(path, opt) {
|
||||||
|
opt = opt || {};
|
||||||
|
super(opt);
|
||||||
|
this[_path] = path;
|
||||||
|
this[_fd] = typeof opt.fd === 'number' ? opt.fd : undefined;
|
||||||
|
this[_mode] = opt.mode === undefined ? 0o666 : opt.mode;
|
||||||
|
this[_pos] = typeof opt.start === 'number' ? opt.start : undefined;
|
||||||
|
this[_autoClose] =
|
||||||
|
typeof opt.autoClose === 'boolean' ? opt.autoClose : true;
|
||||||
|
// truncating makes no sense when writing into the middle
|
||||||
|
const defaultFlag = this[_pos] !== undefined ? 'r+' : 'w';
|
||||||
|
this[_defaultFlag] = opt.flags === undefined;
|
||||||
|
this[_flags] = opt.flags === undefined ? defaultFlag : opt.flags;
|
||||||
|
if (this[_fd] === undefined) {
|
||||||
|
this[_open]();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
emit(ev, ...args) {
|
||||||
|
if (ev === 'error') {
|
||||||
|
if (this[_errored]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this[_errored] = true;
|
||||||
|
}
|
||||||
|
return super.emit(ev, ...args);
|
||||||
|
}
|
||||||
|
get fd() {
|
||||||
|
return this[_fd];
|
||||||
|
}
|
||||||
|
get path() {
|
||||||
|
return this[_path];
|
||||||
|
}
|
||||||
|
[_onerror](er) {
|
||||||
|
this[_close]();
|
||||||
|
this[_writing] = true;
|
||||||
|
this.emit('error', er);
|
||||||
|
}
|
||||||
|
[_open]() {
|
||||||
|
fs.open(this[_path], this[_flags], this[_mode], (er, fd) => this[_onopen](er, fd));
|
||||||
|
}
|
||||||
|
[_onopen](er, fd) {
|
||||||
|
if (this[_defaultFlag] &&
|
||||||
|
this[_flags] === 'r+' &&
|
||||||
|
er &&
|
||||||
|
er.code === 'ENOENT') {
|
||||||
|
this[_flags] = 'w';
|
||||||
|
this[_open]();
|
||||||
|
}
|
||||||
|
else if (er) {
|
||||||
|
this[_onerror](er);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this[_fd] = fd;
|
||||||
|
this.emit('open', fd);
|
||||||
|
if (!this[_writing]) {
|
||||||
|
this[_flush]();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end(buf, enc) {
|
||||||
|
if (buf) {
|
||||||
|
//@ts-ignore
|
||||||
|
this.write(buf, enc);
|
||||||
|
}
|
||||||
|
this[_ended] = true;
|
||||||
|
// synthetic after-write logic, where drain/finish live
|
||||||
|
if (!this[_writing] &&
|
||||||
|
!this[_queue].length &&
|
||||||
|
typeof this[_fd] === 'number') {
|
||||||
|
this[_onwrite](null, 0);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
write(buf, enc) {
|
||||||
|
if (typeof buf === 'string') {
|
||||||
|
buf = Buffer.from(buf, enc);
|
||||||
|
}
|
||||||
|
if (this[_ended]) {
|
||||||
|
this.emit('error', new Error('write() after end()'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this[_fd] === undefined || this[_writing] || this[_queue].length) {
|
||||||
|
this[_queue].push(buf);
|
||||||
|
this[_needDrain] = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this[_writing] = true;
|
||||||
|
this[_write](buf);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
[_write](buf) {
|
||||||
|
fs.write(this[_fd], buf, 0, buf.length, this[_pos], (er, bw) => this[_onwrite](er, bw));
|
||||||
|
}
|
||||||
|
[_onwrite](er, bw) {
|
||||||
|
if (er) {
|
||||||
|
this[_onerror](er);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (this[_pos] !== undefined && typeof bw === 'number') {
|
||||||
|
this[_pos] += bw;
|
||||||
|
}
|
||||||
|
if (this[_queue].length) {
|
||||||
|
this[_flush]();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this[_writing] = false;
|
||||||
|
if (this[_ended] && !this[_finished]) {
|
||||||
|
this[_finished] = true;
|
||||||
|
this[_close]();
|
||||||
|
this.emit('finish');
|
||||||
|
}
|
||||||
|
else if (this[_needDrain]) {
|
||||||
|
this[_needDrain] = false;
|
||||||
|
this.emit('drain');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[_flush]() {
|
||||||
|
if (this[_queue].length === 0) {
|
||||||
|
if (this[_ended]) {
|
||||||
|
this[_onwrite](null, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (this[_queue].length === 1) {
|
||||||
|
this[_write](this[_queue].pop());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const iovec = this[_queue];
|
||||||
|
this[_queue] = [];
|
||||||
|
writev(this[_fd], iovec, this[_pos], (er, bw) => this[_onwrite](er, bw));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[_close]() {
|
||||||
|
if (this[_autoClose] && typeof this[_fd] === 'number') {
|
||||||
|
const fd = this[_fd];
|
||||||
|
this[_fd] = undefined;
|
||||||
|
fs.close(fd, er => er ? this.emit('error', er) : this.emit('close'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class WriteStreamSync extends WriteStream {
|
||||||
|
[_open]() {
|
||||||
|
let fd;
|
||||||
|
// only wrap in a try{} block if we know we'll retry, to avoid
|
||||||
|
// the rethrow obscuring the error's source frame in most cases.
|
||||||
|
if (this[_defaultFlag] && this[_flags] === 'r+') {
|
||||||
|
try {
|
||||||
|
fd = fs.openSync(this[_path], this[_flags], this[_mode]);
|
||||||
|
}
|
||||||
|
catch (er) {
|
||||||
|
if (er?.code === 'ENOENT') {
|
||||||
|
this[_flags] = 'w';
|
||||||
|
return this[_open]();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw er;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fd = fs.openSync(this[_path], this[_flags], this[_mode]);
|
||||||
|
}
|
||||||
|
this[_onopen](null, fd);
|
||||||
|
}
|
||||||
|
[_close]() {
|
||||||
|
if (this[_autoClose] && typeof this[_fd] === 'number') {
|
||||||
|
const fd = this[_fd];
|
||||||
|
this[_fd] = undefined;
|
||||||
|
fs.closeSync(fd);
|
||||||
|
this.emit('close');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[_write](buf) {
|
||||||
|
// throw the original, but try to close if it fails
|
||||||
|
let threw = true;
|
||||||
|
try {
|
||||||
|
this[_onwrite](null, fs.writeSync(this[_fd], buf, 0, buf.length, this[_pos]));
|
||||||
|
threw = false;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (threw) {
|
||||||
|
try {
|
||||||
|
this[_close]();
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// ok error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=index.js.map
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"type": "module"
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
{
|
||||||
|
"name": "@isaacs/fs-minipass",
|
||||||
|
"version": "4.0.1",
|
||||||
|
"main": "./dist/commonjs/index.js",
|
||||||
|
"scripts": {
|
||||||
|
"prepare": "tshy",
|
||||||
|
"pretest": "npm run prepare",
|
||||||
|
"test": "tap",
|
||||||
|
"preversion": "npm test",
|
||||||
|
"postversion": "npm publish",
|
||||||
|
"prepublishOnly": "git push origin --follow-tags",
|
||||||
|
"format": "prettier --write . --loglevel warn",
|
||||||
|
"typedoc": "typedoc --tsconfig .tshy/esm.json ./src/*.ts"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "Isaac Z. Schlueter",
|
||||||
|
"license": "ISC",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/npm/fs-minipass.git"
|
||||||
|
},
|
||||||
|
"description": "fs read and write streams based on minipass",
|
||||||
|
"dependencies": {
|
||||||
|
"minipass": "^7.0.4"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^20.11.30",
|
||||||
|
"mutate-fs": "^2.1.1",
|
||||||
|
"prettier": "^3.2.5",
|
||||||
|
"tap": "^18.7.1",
|
||||||
|
"tshy": "^1.12.0",
|
||||||
|
"typedoc": "^0.25.12"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
|
},
|
||||||
|
"tshy": {
|
||||||
|
"exports": {
|
||||||
|
"./package.json": "./package.json",
|
||||||
|
".": "./src/index.ts"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"exports": {
|
||||||
|
"./package.json": "./package.json",
|
||||||
|
".": {
|
||||||
|
"import": {
|
||||||
|
"types": "./dist/esm/index.d.ts",
|
||||||
|
"default": "./dist/esm/index.js"
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"types": "./dist/commonjs/index.d.ts",
|
||||||
|
"default": "./dist/commonjs/index.js"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"types": "./dist/commonjs/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
|
"prettier": {
|
||||||
|
"semi": false,
|
||||||
|
"printWidth": 75,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"useTabs": false,
|
||||||
|
"singleQuote": true,
|
||||||
|
"jsxSingleQuote": false,
|
||||||
|
"bracketSameLine": true,
|
||||||
|
"arrowParens": "avoid",
|
||||||
|
"endOfLine": "lf"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
Copyright 2024 Justin Ridgewell <justin@ridgewell.name>
|
||||||
|
|
||||||
|
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.
|
|
@ -0,0 +1,227 @@
|
||||||
|
# @jridgewell/gen-mapping
|
||||||
|
|
||||||
|
> Generate source maps
|
||||||
|
|
||||||
|
`gen-mapping` allows you to generate a source map during transpilation or minification.
|
||||||
|
With a source map, you're able to trace the original location in the source file, either in Chrome's
|
||||||
|
DevTools or using a library like [`@jridgewell/trace-mapping`][trace-mapping].
|
||||||
|
|
||||||
|
You may already be familiar with the [`source-map`][source-map] package's `SourceMapGenerator`. This
|
||||||
|
provides the same `addMapping` and `setSourceContent` API.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install @jridgewell/gen-mapping
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { GenMapping, addMapping, setSourceContent, toEncodedMap, toDecodedMap } from '@jridgewell/gen-mapping';
|
||||||
|
|
||||||
|
const map = new GenMapping({
|
||||||
|
file: 'output.js',
|
||||||
|
sourceRoot: 'https://example.com/',
|
||||||
|
});
|
||||||
|
|
||||||
|
setSourceContent(map, 'input.js', `function foo() {}`);
|
||||||
|
|
||||||
|
addMapping(map, {
|
||||||
|
// Lines start at line 1, columns at column 0.
|
||||||
|
generated: { line: 1, column: 0 },
|
||||||
|
source: 'input.js',
|
||||||
|
original: { line: 1, column: 0 },
|
||||||
|
});
|
||||||
|
|
||||||
|
addMapping(map, {
|
||||||
|
generated: { line: 1, column: 9 },
|
||||||
|
source: 'input.js',
|
||||||
|
original: { line: 1, column: 9 },
|
||||||
|
name: 'foo',
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(toDecodedMap(map), {
|
||||||
|
version: 3,
|
||||||
|
file: 'output.js',
|
||||||
|
names: ['foo'],
|
||||||
|
sourceRoot: 'https://example.com/',
|
||||||
|
sources: ['input.js'],
|
||||||
|
sourcesContent: ['function foo() {}'],
|
||||||
|
mappings: [
|
||||||
|
[ [0, 0, 0, 0], [9, 0, 0, 9, 0] ]
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(toEncodedMap(map), {
|
||||||
|
version: 3,
|
||||||
|
file: 'output.js',
|
||||||
|
names: ['foo'],
|
||||||
|
sourceRoot: 'https://example.com/',
|
||||||
|
sources: ['input.js'],
|
||||||
|
sourcesContent: ['function foo() {}'],
|
||||||
|
mappings: 'AAAA,SAASA',
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Smaller Sourcemaps
|
||||||
|
|
||||||
|
Not everything needs to be added to a sourcemap, and needless markings can cause signficantly
|
||||||
|
larger file sizes. `gen-mapping` exposes `maybeAddSegment`/`maybeAddMapping` APIs that will
|
||||||
|
intelligently determine if this marking adds useful information. If not, the marking will be
|
||||||
|
skipped.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { maybeAddMapping } from '@jridgewell/gen-mapping';
|
||||||
|
|
||||||
|
const map = new GenMapping();
|
||||||
|
|
||||||
|
// Adding a sourceless marking at the beginning of a line isn't useful.
|
||||||
|
maybeAddMapping(map, {
|
||||||
|
generated: { line: 1, column: 0 },
|
||||||
|
});
|
||||||
|
|
||||||
|
// Adding a new source marking is useful.
|
||||||
|
maybeAddMapping(map, {
|
||||||
|
generated: { line: 1, column: 0 },
|
||||||
|
source: 'input.js',
|
||||||
|
original: { line: 1, column: 0 },
|
||||||
|
});
|
||||||
|
|
||||||
|
// But adding another marking pointing to the exact same original location isn't, even if the
|
||||||
|
// generated column changed.
|
||||||
|
maybeAddMapping(map, {
|
||||||
|
generated: { line: 1, column: 9 },
|
||||||
|
source: 'input.js',
|
||||||
|
original: { line: 1, column: 0 },
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(toEncodedMap(map), {
|
||||||
|
version: 3,
|
||||||
|
names: [],
|
||||||
|
sources: ['input.js'],
|
||||||
|
sourcesContent: [null],
|
||||||
|
mappings: 'AAAA',
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## Benchmarks
|
||||||
|
|
||||||
|
```
|
||||||
|
node v18.0.0
|
||||||
|
|
||||||
|
amp.js.map
|
||||||
|
Memory Usage:
|
||||||
|
gen-mapping: addSegment 5852872 bytes
|
||||||
|
gen-mapping: addMapping 7716042 bytes
|
||||||
|
source-map-js 6143250 bytes
|
||||||
|
source-map-0.6.1 6124102 bytes
|
||||||
|
source-map-0.8.0 6121173 bytes
|
||||||
|
Smallest memory usage is gen-mapping: addSegment
|
||||||
|
|
||||||
|
Adding speed:
|
||||||
|
gen-mapping: addSegment x 441 ops/sec ±2.07% (90 runs sampled)
|
||||||
|
gen-mapping: addMapping x 350 ops/sec ±2.40% (86 runs sampled)
|
||||||
|
source-map-js: addMapping x 169 ops/sec ±2.42% (80 runs sampled)
|
||||||
|
source-map-0.6.1: addMapping x 167 ops/sec ±2.56% (80 runs sampled)
|
||||||
|
source-map-0.8.0: addMapping x 168 ops/sec ±2.52% (80 runs sampled)
|
||||||
|
Fastest is gen-mapping: addSegment
|
||||||
|
|
||||||
|
Generate speed:
|
||||||
|
gen-mapping: decoded output x 150,824,370 ops/sec ±0.07% (102 runs sampled)
|
||||||
|
gen-mapping: encoded output x 663 ops/sec ±0.22% (98 runs sampled)
|
||||||
|
source-map-js: encoded output x 197 ops/sec ±0.45% (84 runs sampled)
|
||||||
|
source-map-0.6.1: encoded output x 198 ops/sec ±0.33% (85 runs sampled)
|
||||||
|
source-map-0.8.0: encoded output x 197 ops/sec ±0.06% (93 runs sampled)
|
||||||
|
Fastest is gen-mapping: decoded output
|
||||||
|
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
|
||||||
|
babel.min.js.map
|
||||||
|
Memory Usage:
|
||||||
|
gen-mapping: addSegment 37578063 bytes
|
||||||
|
gen-mapping: addMapping 37212897 bytes
|
||||||
|
source-map-js 47638527 bytes
|
||||||
|
source-map-0.6.1 47690503 bytes
|
||||||
|
source-map-0.8.0 47470188 bytes
|
||||||
|
Smallest memory usage is gen-mapping: addMapping
|
||||||
|
|
||||||
|
Adding speed:
|
||||||
|
gen-mapping: addSegment x 31.05 ops/sec ±8.31% (43 runs sampled)
|
||||||
|
gen-mapping: addMapping x 29.83 ops/sec ±7.36% (51 runs sampled)
|
||||||
|
source-map-js: addMapping x 20.73 ops/sec ±6.22% (38 runs sampled)
|
||||||
|
source-map-0.6.1: addMapping x 20.03 ops/sec ±10.51% (38 runs sampled)
|
||||||
|
source-map-0.8.0: addMapping x 19.30 ops/sec ±8.27% (37 runs sampled)
|
||||||
|
Fastest is gen-mapping: addSegment
|
||||||
|
|
||||||
|
Generate speed:
|
||||||
|
gen-mapping: decoded output x 381,379,234 ops/sec ±0.29% (96 runs sampled)
|
||||||
|
gen-mapping: encoded output x 95.15 ops/sec ±2.98% (72 runs sampled)
|
||||||
|
source-map-js: encoded output x 15.20 ops/sec ±7.41% (33 runs sampled)
|
||||||
|
source-map-0.6.1: encoded output x 16.36 ops/sec ±10.46% (31 runs sampled)
|
||||||
|
source-map-0.8.0: encoded output x 16.06 ops/sec ±6.45% (31 runs sampled)
|
||||||
|
Fastest is gen-mapping: decoded output
|
||||||
|
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
|
||||||
|
preact.js.map
|
||||||
|
Memory Usage:
|
||||||
|
gen-mapping: addSegment 416247 bytes
|
||||||
|
gen-mapping: addMapping 419824 bytes
|
||||||
|
source-map-js 1024619 bytes
|
||||||
|
source-map-0.6.1 1146004 bytes
|
||||||
|
source-map-0.8.0 1113250 bytes
|
||||||
|
Smallest memory usage is gen-mapping: addSegment
|
||||||
|
|
||||||
|
Adding speed:
|
||||||
|
gen-mapping: addSegment x 13,755 ops/sec ±0.15% (98 runs sampled)
|
||||||
|
gen-mapping: addMapping x 13,013 ops/sec ±0.11% (101 runs sampled)
|
||||||
|
source-map-js: addMapping x 4,564 ops/sec ±0.21% (98 runs sampled)
|
||||||
|
source-map-0.6.1: addMapping x 4,562 ops/sec ±0.11% (99 runs sampled)
|
||||||
|
source-map-0.8.0: addMapping x 4,593 ops/sec ±0.11% (100 runs sampled)
|
||||||
|
Fastest is gen-mapping: addSegment
|
||||||
|
|
||||||
|
Generate speed:
|
||||||
|
gen-mapping: decoded output x 379,864,020 ops/sec ±0.23% (93 runs sampled)
|
||||||
|
gen-mapping: encoded output x 14,368 ops/sec ±4.07% (82 runs sampled)
|
||||||
|
source-map-js: encoded output x 5,261 ops/sec ±0.21% (99 runs sampled)
|
||||||
|
source-map-0.6.1: encoded output x 5,124 ops/sec ±0.58% (99 runs sampled)
|
||||||
|
source-map-0.8.0: encoded output x 5,434 ops/sec ±0.33% (96 runs sampled)
|
||||||
|
Fastest is gen-mapping: decoded output
|
||||||
|
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
|
||||||
|
react.js.map
|
||||||
|
Memory Usage:
|
||||||
|
gen-mapping: addSegment 975096 bytes
|
||||||
|
gen-mapping: addMapping 1102981 bytes
|
||||||
|
source-map-js 2918836 bytes
|
||||||
|
source-map-0.6.1 2885435 bytes
|
||||||
|
source-map-0.8.0 2874336 bytes
|
||||||
|
Smallest memory usage is gen-mapping: addSegment
|
||||||
|
|
||||||
|
Adding speed:
|
||||||
|
gen-mapping: addSegment x 4,772 ops/sec ±0.15% (100 runs sampled)
|
||||||
|
gen-mapping: addMapping x 4,456 ops/sec ±0.13% (97 runs sampled)
|
||||||
|
source-map-js: addMapping x 1,618 ops/sec ±0.24% (97 runs sampled)
|
||||||
|
source-map-0.6.1: addMapping x 1,622 ops/sec ±0.12% (99 runs sampled)
|
||||||
|
source-map-0.8.0: addMapping x 1,631 ops/sec ±0.12% (100 runs sampled)
|
||||||
|
Fastest is gen-mapping: addSegment
|
||||||
|
|
||||||
|
Generate speed:
|
||||||
|
gen-mapping: decoded output x 379,107,695 ops/sec ±0.07% (99 runs sampled)
|
||||||
|
gen-mapping: encoded output x 5,421 ops/sec ±1.60% (89 runs sampled)
|
||||||
|
source-map-js: encoded output x 2,113 ops/sec ±1.81% (98 runs sampled)
|
||||||
|
source-map-0.6.1: encoded output x 2,126 ops/sec ±0.10% (100 runs sampled)
|
||||||
|
source-map-0.8.0: encoded output x 2,176 ops/sec ±0.39% (98 runs sampled)
|
||||||
|
Fastest is gen-mapping: decoded output
|
||||||
|
```
|
||||||
|
|
||||||
|
[source-map]: https://www.npmjs.com/package/source-map
|
||||||
|
[trace-mapping]: https://github.com/jridgewell/trace-mapping
|
|
@ -0,0 +1,292 @@
|
||||||
|
// src/set-array.ts
|
||||||
|
var SetArray = class {
|
||||||
|
constructor() {
|
||||||
|
this._indexes = { __proto__: null };
|
||||||
|
this.array = [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
function cast(set) {
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
function get(setarr, key) {
|
||||||
|
return cast(setarr)._indexes[key];
|
||||||
|
}
|
||||||
|
function put(setarr, key) {
|
||||||
|
const index = get(setarr, key);
|
||||||
|
if (index !== void 0) return index;
|
||||||
|
const { array, _indexes: indexes } = cast(setarr);
|
||||||
|
const length = array.push(key);
|
||||||
|
return indexes[key] = length - 1;
|
||||||
|
}
|
||||||
|
function remove(setarr, key) {
|
||||||
|
const index = get(setarr, key);
|
||||||
|
if (index === void 0) return;
|
||||||
|
const { array, _indexes: indexes } = cast(setarr);
|
||||||
|
for (let i = index + 1; i < array.length; i++) {
|
||||||
|
const k = array[i];
|
||||||
|
array[i - 1] = k;
|
||||||
|
indexes[k]--;
|
||||||
|
}
|
||||||
|
indexes[key] = void 0;
|
||||||
|
array.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// src/gen-mapping.ts
|
||||||
|
import {
|
||||||
|
encode
|
||||||
|
} from "@jridgewell/sourcemap-codec";
|
||||||
|
import { TraceMap, decodedMappings } from "@jridgewell/trace-mapping";
|
||||||
|
|
||||||
|
// src/sourcemap-segment.ts
|
||||||
|
var COLUMN = 0;
|
||||||
|
var SOURCES_INDEX = 1;
|
||||||
|
var SOURCE_LINE = 2;
|
||||||
|
var SOURCE_COLUMN = 3;
|
||||||
|
var NAMES_INDEX = 4;
|
||||||
|
|
||||||
|
// src/gen-mapping.ts
|
||||||
|
var NO_NAME = -1;
|
||||||
|
var GenMapping = class {
|
||||||
|
constructor({ file, sourceRoot } = {}) {
|
||||||
|
this._names = new SetArray();
|
||||||
|
this._sources = new SetArray();
|
||||||
|
this._sourcesContent = [];
|
||||||
|
this._mappings = [];
|
||||||
|
this.file = file;
|
||||||
|
this.sourceRoot = sourceRoot;
|
||||||
|
this._ignoreList = new SetArray();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
function cast2(map) {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
function addSegment(map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) {
|
||||||
|
return addSegmentInternal(
|
||||||
|
false,
|
||||||
|
map,
|
||||||
|
genLine,
|
||||||
|
genColumn,
|
||||||
|
source,
|
||||||
|
sourceLine,
|
||||||
|
sourceColumn,
|
||||||
|
name,
|
||||||
|
content
|
||||||
|
);
|
||||||
|
}
|
||||||
|
function addMapping(map, mapping) {
|
||||||
|
return addMappingInternal(false, map, mapping);
|
||||||
|
}
|
||||||
|
var maybeAddSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => {
|
||||||
|
return addSegmentInternal(
|
||||||
|
true,
|
||||||
|
map,
|
||||||
|
genLine,
|
||||||
|
genColumn,
|
||||||
|
source,
|
||||||
|
sourceLine,
|
||||||
|
sourceColumn,
|
||||||
|
name,
|
||||||
|
content
|
||||||
|
);
|
||||||
|
};
|
||||||
|
var maybeAddMapping = (map, mapping) => {
|
||||||
|
return addMappingInternal(true, map, mapping);
|
||||||
|
};
|
||||||
|
function setSourceContent(map, source, content) {
|
||||||
|
const {
|
||||||
|
_sources: sources,
|
||||||
|
_sourcesContent: sourcesContent
|
||||||
|
// _originalScopes: originalScopes,
|
||||||
|
} = cast2(map);
|
||||||
|
const index = put(sources, source);
|
||||||
|
sourcesContent[index] = content;
|
||||||
|
}
|
||||||
|
function setIgnore(map, source, ignore = true) {
|
||||||
|
const {
|
||||||
|
_sources: sources,
|
||||||
|
_sourcesContent: sourcesContent,
|
||||||
|
_ignoreList: ignoreList
|
||||||
|
// _originalScopes: originalScopes,
|
||||||
|
} = cast2(map);
|
||||||
|
const index = put(sources, source);
|
||||||
|
if (index === sourcesContent.length) sourcesContent[index] = null;
|
||||||
|
if (ignore) put(ignoreList, index);
|
||||||
|
else remove(ignoreList, index);
|
||||||
|
}
|
||||||
|
function toDecodedMap(map) {
|
||||||
|
const {
|
||||||
|
_mappings: mappings,
|
||||||
|
_sources: sources,
|
||||||
|
_sourcesContent: sourcesContent,
|
||||||
|
_names: names,
|
||||||
|
_ignoreList: ignoreList
|
||||||
|
// _originalScopes: originalScopes,
|
||||||
|
// _generatedRanges: generatedRanges,
|
||||||
|
} = cast2(map);
|
||||||
|
removeEmptyFinalLines(mappings);
|
||||||
|
return {
|
||||||
|
version: 3,
|
||||||
|
file: map.file || void 0,
|
||||||
|
names: names.array,
|
||||||
|
sourceRoot: map.sourceRoot || void 0,
|
||||||
|
sources: sources.array,
|
||||||
|
sourcesContent,
|
||||||
|
mappings,
|
||||||
|
// originalScopes,
|
||||||
|
// generatedRanges,
|
||||||
|
ignoreList: ignoreList.array
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function toEncodedMap(map) {
|
||||||
|
const decoded = toDecodedMap(map);
|
||||||
|
return Object.assign({}, decoded, {
|
||||||
|
// originalScopes: decoded.originalScopes.map((os) => encodeOriginalScopes(os)),
|
||||||
|
// generatedRanges: encodeGeneratedRanges(decoded.generatedRanges as GeneratedRange[]),
|
||||||
|
mappings: encode(decoded.mappings)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function fromMap(input) {
|
||||||
|
const map = new TraceMap(input);
|
||||||
|
const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot });
|
||||||
|
putAll(cast2(gen)._names, map.names);
|
||||||
|
putAll(cast2(gen)._sources, map.sources);
|
||||||
|
cast2(gen)._sourcesContent = map.sourcesContent || map.sources.map(() => null);
|
||||||
|
cast2(gen)._mappings = decodedMappings(map);
|
||||||
|
if (map.ignoreList) putAll(cast2(gen)._ignoreList, map.ignoreList);
|
||||||
|
return gen;
|
||||||
|
}
|
||||||
|
function allMappings(map) {
|
||||||
|
const out = [];
|
||||||
|
const { _mappings: mappings, _sources: sources, _names: names } = cast2(map);
|
||||||
|
for (let i = 0; i < mappings.length; i++) {
|
||||||
|
const line = mappings[i];
|
||||||
|
for (let j = 0; j < line.length; j++) {
|
||||||
|
const seg = line[j];
|
||||||
|
const generated = { line: i + 1, column: seg[COLUMN] };
|
||||||
|
let source = void 0;
|
||||||
|
let original = void 0;
|
||||||
|
let name = void 0;
|
||||||
|
if (seg.length !== 1) {
|
||||||
|
source = sources.array[seg[SOURCES_INDEX]];
|
||||||
|
original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] };
|
||||||
|
if (seg.length === 5) name = names.array[seg[NAMES_INDEX]];
|
||||||
|
}
|
||||||
|
out.push({ generated, source, original, name });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
function addSegmentInternal(skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) {
|
||||||
|
const {
|
||||||
|
_mappings: mappings,
|
||||||
|
_sources: sources,
|
||||||
|
_sourcesContent: sourcesContent,
|
||||||
|
_names: names
|
||||||
|
// _originalScopes: originalScopes,
|
||||||
|
} = cast2(map);
|
||||||
|
const line = getIndex(mappings, genLine);
|
||||||
|
const index = getColumnIndex(line, genColumn);
|
||||||
|
if (!source) {
|
||||||
|
if (skipable && skipSourceless(line, index)) return;
|
||||||
|
return insert(line, index, [genColumn]);
|
||||||
|
}
|
||||||
|
assert(sourceLine);
|
||||||
|
assert(sourceColumn);
|
||||||
|
const sourcesIndex = put(sources, source);
|
||||||
|
const namesIndex = name ? put(names, name) : NO_NAME;
|
||||||
|
if (sourcesIndex === sourcesContent.length) sourcesContent[sourcesIndex] = content != null ? content : null;
|
||||||
|
if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return insert(
|
||||||
|
line,
|
||||||
|
index,
|
||||||
|
name ? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex] : [genColumn, sourcesIndex, sourceLine, sourceColumn]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
function assert(_val) {
|
||||||
|
}
|
||||||
|
function getIndex(arr, index) {
|
||||||
|
for (let i = arr.length; i <= index; i++) {
|
||||||
|
arr[i] = [];
|
||||||
|
}
|
||||||
|
return arr[index];
|
||||||
|
}
|
||||||
|
function getColumnIndex(line, genColumn) {
|
||||||
|
let index = line.length;
|
||||||
|
for (let i = index - 1; i >= 0; index = i--) {
|
||||||
|
const current = line[i];
|
||||||
|
if (genColumn >= current[COLUMN]) break;
|
||||||
|
}
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
function insert(array, index, value) {
|
||||||
|
for (let i = array.length; i > index; i--) {
|
||||||
|
array[i] = array[i - 1];
|
||||||
|
}
|
||||||
|
array[index] = value;
|
||||||
|
}
|
||||||
|
function removeEmptyFinalLines(mappings) {
|
||||||
|
const { length } = mappings;
|
||||||
|
let len = length;
|
||||||
|
for (let i = len - 1; i >= 0; len = i, i--) {
|
||||||
|
if (mappings[i].length > 0) break;
|
||||||
|
}
|
||||||
|
if (len < length) mappings.length = len;
|
||||||
|
}
|
||||||
|
function putAll(setarr, array) {
|
||||||
|
for (let i = 0; i < array.length; i++) put(setarr, array[i]);
|
||||||
|
}
|
||||||
|
function skipSourceless(line, index) {
|
||||||
|
if (index === 0) return true;
|
||||||
|
const prev = line[index - 1];
|
||||||
|
return prev.length === 1;
|
||||||
|
}
|
||||||
|
function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex) {
|
||||||
|
if (index === 0) return false;
|
||||||
|
const prev = line[index - 1];
|
||||||
|
if (prev.length === 1) return false;
|
||||||
|
return sourcesIndex === prev[SOURCES_INDEX] && sourceLine === prev[SOURCE_LINE] && sourceColumn === prev[SOURCE_COLUMN] && namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME);
|
||||||
|
}
|
||||||
|
function addMappingInternal(skipable, map, mapping) {
|
||||||
|
const { generated, source, original, name, content } = mapping;
|
||||||
|
if (!source) {
|
||||||
|
return addSegmentInternal(
|
||||||
|
skipable,
|
||||||
|
map,
|
||||||
|
generated.line - 1,
|
||||||
|
generated.column,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
assert(original);
|
||||||
|
return addSegmentInternal(
|
||||||
|
skipable,
|
||||||
|
map,
|
||||||
|
generated.line - 1,
|
||||||
|
generated.column,
|
||||||
|
source,
|
||||||
|
original.line - 1,
|
||||||
|
original.column,
|
||||||
|
name,
|
||||||
|
content
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export {
|
||||||
|
GenMapping,
|
||||||
|
addMapping,
|
||||||
|
addSegment,
|
||||||
|
allMappings,
|
||||||
|
fromMap,
|
||||||
|
maybeAddMapping,
|
||||||
|
maybeAddSegment,
|
||||||
|
setIgnore,
|
||||||
|
setSourceContent,
|
||||||
|
toDecodedMap,
|
||||||
|
toEncodedMap
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=gen-mapping.mjs.map
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,346 @@
|
||||||
|
(function (global, factory, m) {
|
||||||
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(module, require('@jridgewell/sourcemap-codec'), require('@jridgewell/trace-mapping')) :
|
||||||
|
typeof define === 'function' && define.amd ? define(['module', '@jridgewell/sourcemap-codec', '@jridgewell/trace-mapping'], factory) :
|
||||||
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(m = { exports: {} }, global.sourcemapCodec, global.traceMapping), global.genMapping = 'default' in m.exports ? m.exports.default : m.exports);
|
||||||
|
})(this, (function (module, require_sourcemapCodec, require_traceMapping) {
|
||||||
|
"use strict";
|
||||||
|
var __create = Object.create;
|
||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||||
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||||
|
var __getProtoOf = Object.getPrototypeOf;
|
||||||
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||||
|
var __commonJS = (cb, mod) => function __require() {
|
||||||
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||||
|
};
|
||||||
|
var __export = (target, all) => {
|
||||||
|
for (var name in all)
|
||||||
|
__defProp(target, name, { get: all[name], enumerable: true });
|
||||||
|
};
|
||||||
|
var __copyProps = (to, from, except, desc) => {
|
||||||
|
if (from && typeof from === "object" || typeof from === "function") {
|
||||||
|
for (let key of __getOwnPropNames(from))
|
||||||
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||||
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||||
|
}
|
||||||
|
return to;
|
||||||
|
};
|
||||||
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||||
|
// If the importer is in node compatibility mode or this is not an ESM
|
||||||
|
// file that has been converted to a CommonJS file using a Babel-
|
||||||
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||||
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||||
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||||
|
mod
|
||||||
|
));
|
||||||
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||||
|
|
||||||
|
// umd:@jridgewell/sourcemap-codec
|
||||||
|
var require_sourcemap_codec = __commonJS({
|
||||||
|
"umd:@jridgewell/sourcemap-codec"(exports, module2) {
|
||||||
|
module2.exports = require_sourcemapCodec;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// umd:@jridgewell/trace-mapping
|
||||||
|
var require_trace_mapping = __commonJS({
|
||||||
|
"umd:@jridgewell/trace-mapping"(exports, module2) {
|
||||||
|
module2.exports = require_traceMapping;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// src/gen-mapping.ts
|
||||||
|
var gen_mapping_exports = {};
|
||||||
|
__export(gen_mapping_exports, {
|
||||||
|
GenMapping: () => GenMapping,
|
||||||
|
addMapping: () => addMapping,
|
||||||
|
addSegment: () => addSegment,
|
||||||
|
allMappings: () => allMappings,
|
||||||
|
fromMap: () => fromMap,
|
||||||
|
maybeAddMapping: () => maybeAddMapping,
|
||||||
|
maybeAddSegment: () => maybeAddSegment,
|
||||||
|
setIgnore: () => setIgnore,
|
||||||
|
setSourceContent: () => setSourceContent,
|
||||||
|
toDecodedMap: () => toDecodedMap,
|
||||||
|
toEncodedMap: () => toEncodedMap
|
||||||
|
});
|
||||||
|
module.exports = __toCommonJS(gen_mapping_exports);
|
||||||
|
|
||||||
|
// src/set-array.ts
|
||||||
|
var SetArray = class {
|
||||||
|
constructor() {
|
||||||
|
this._indexes = { __proto__: null };
|
||||||
|
this.array = [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
function cast(set) {
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
function get(setarr, key) {
|
||||||
|
return cast(setarr)._indexes[key];
|
||||||
|
}
|
||||||
|
function put(setarr, key) {
|
||||||
|
const index = get(setarr, key);
|
||||||
|
if (index !== void 0) return index;
|
||||||
|
const { array, _indexes: indexes } = cast(setarr);
|
||||||
|
const length = array.push(key);
|
||||||
|
return indexes[key] = length - 1;
|
||||||
|
}
|
||||||
|
function remove(setarr, key) {
|
||||||
|
const index = get(setarr, key);
|
||||||
|
if (index === void 0) return;
|
||||||
|
const { array, _indexes: indexes } = cast(setarr);
|
||||||
|
for (let i = index + 1; i < array.length; i++) {
|
||||||
|
const k = array[i];
|
||||||
|
array[i - 1] = k;
|
||||||
|
indexes[k]--;
|
||||||
|
}
|
||||||
|
indexes[key] = void 0;
|
||||||
|
array.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// src/gen-mapping.ts
|
||||||
|
var import_sourcemap_codec = __toESM(require_sourcemap_codec());
|
||||||
|
var import_trace_mapping = __toESM(require_trace_mapping());
|
||||||
|
|
||||||
|
// src/sourcemap-segment.ts
|
||||||
|
var COLUMN = 0;
|
||||||
|
var SOURCES_INDEX = 1;
|
||||||
|
var SOURCE_LINE = 2;
|
||||||
|
var SOURCE_COLUMN = 3;
|
||||||
|
var NAMES_INDEX = 4;
|
||||||
|
|
||||||
|
// src/gen-mapping.ts
|
||||||
|
var NO_NAME = -1;
|
||||||
|
var GenMapping = class {
|
||||||
|
constructor({ file, sourceRoot } = {}) {
|
||||||
|
this._names = new SetArray();
|
||||||
|
this._sources = new SetArray();
|
||||||
|
this._sourcesContent = [];
|
||||||
|
this._mappings = [];
|
||||||
|
this.file = file;
|
||||||
|
this.sourceRoot = sourceRoot;
|
||||||
|
this._ignoreList = new SetArray();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
function cast2(map) {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
function addSegment(map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) {
|
||||||
|
return addSegmentInternal(
|
||||||
|
false,
|
||||||
|
map,
|
||||||
|
genLine,
|
||||||
|
genColumn,
|
||||||
|
source,
|
||||||
|
sourceLine,
|
||||||
|
sourceColumn,
|
||||||
|
name,
|
||||||
|
content
|
||||||
|
);
|
||||||
|
}
|
||||||
|
function addMapping(map, mapping) {
|
||||||
|
return addMappingInternal(false, map, mapping);
|
||||||
|
}
|
||||||
|
var maybeAddSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => {
|
||||||
|
return addSegmentInternal(
|
||||||
|
true,
|
||||||
|
map,
|
||||||
|
genLine,
|
||||||
|
genColumn,
|
||||||
|
source,
|
||||||
|
sourceLine,
|
||||||
|
sourceColumn,
|
||||||
|
name,
|
||||||
|
content
|
||||||
|
);
|
||||||
|
};
|
||||||
|
var maybeAddMapping = (map, mapping) => {
|
||||||
|
return addMappingInternal(true, map, mapping);
|
||||||
|
};
|
||||||
|
function setSourceContent(map, source, content) {
|
||||||
|
const {
|
||||||
|
_sources: sources,
|
||||||
|
_sourcesContent: sourcesContent
|
||||||
|
// _originalScopes: originalScopes,
|
||||||
|
} = cast2(map);
|
||||||
|
const index = put(sources, source);
|
||||||
|
sourcesContent[index] = content;
|
||||||
|
}
|
||||||
|
function setIgnore(map, source, ignore = true) {
|
||||||
|
const {
|
||||||
|
_sources: sources,
|
||||||
|
_sourcesContent: sourcesContent,
|
||||||
|
_ignoreList: ignoreList
|
||||||
|
// _originalScopes: originalScopes,
|
||||||
|
} = cast2(map);
|
||||||
|
const index = put(sources, source);
|
||||||
|
if (index === sourcesContent.length) sourcesContent[index] = null;
|
||||||
|
if (ignore) put(ignoreList, index);
|
||||||
|
else remove(ignoreList, index);
|
||||||
|
}
|
||||||
|
function toDecodedMap(map) {
|
||||||
|
const {
|
||||||
|
_mappings: mappings,
|
||||||
|
_sources: sources,
|
||||||
|
_sourcesContent: sourcesContent,
|
||||||
|
_names: names,
|
||||||
|
_ignoreList: ignoreList
|
||||||
|
// _originalScopes: originalScopes,
|
||||||
|
// _generatedRanges: generatedRanges,
|
||||||
|
} = cast2(map);
|
||||||
|
removeEmptyFinalLines(mappings);
|
||||||
|
return {
|
||||||
|
version: 3,
|
||||||
|
file: map.file || void 0,
|
||||||
|
names: names.array,
|
||||||
|
sourceRoot: map.sourceRoot || void 0,
|
||||||
|
sources: sources.array,
|
||||||
|
sourcesContent,
|
||||||
|
mappings,
|
||||||
|
// originalScopes,
|
||||||
|
// generatedRanges,
|
||||||
|
ignoreList: ignoreList.array
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function toEncodedMap(map) {
|
||||||
|
const decoded = toDecodedMap(map);
|
||||||
|
return Object.assign({}, decoded, {
|
||||||
|
// originalScopes: decoded.originalScopes.map((os) => encodeOriginalScopes(os)),
|
||||||
|
// generatedRanges: encodeGeneratedRanges(decoded.generatedRanges as GeneratedRange[]),
|
||||||
|
mappings: (0, import_sourcemap_codec.encode)(decoded.mappings)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function fromMap(input) {
|
||||||
|
const map = new import_trace_mapping.TraceMap(input);
|
||||||
|
const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot });
|
||||||
|
putAll(cast2(gen)._names, map.names);
|
||||||
|
putAll(cast2(gen)._sources, map.sources);
|
||||||
|
cast2(gen)._sourcesContent = map.sourcesContent || map.sources.map(() => null);
|
||||||
|
cast2(gen)._mappings = (0, import_trace_mapping.decodedMappings)(map);
|
||||||
|
if (map.ignoreList) putAll(cast2(gen)._ignoreList, map.ignoreList);
|
||||||
|
return gen;
|
||||||
|
}
|
||||||
|
function allMappings(map) {
|
||||||
|
const out = [];
|
||||||
|
const { _mappings: mappings, _sources: sources, _names: names } = cast2(map);
|
||||||
|
for (let i = 0; i < mappings.length; i++) {
|
||||||
|
const line = mappings[i];
|
||||||
|
for (let j = 0; j < line.length; j++) {
|
||||||
|
const seg = line[j];
|
||||||
|
const generated = { line: i + 1, column: seg[COLUMN] };
|
||||||
|
let source = void 0;
|
||||||
|
let original = void 0;
|
||||||
|
let name = void 0;
|
||||||
|
if (seg.length !== 1) {
|
||||||
|
source = sources.array[seg[SOURCES_INDEX]];
|
||||||
|
original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] };
|
||||||
|
if (seg.length === 5) name = names.array[seg[NAMES_INDEX]];
|
||||||
|
}
|
||||||
|
out.push({ generated, source, original, name });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
function addSegmentInternal(skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) {
|
||||||
|
const {
|
||||||
|
_mappings: mappings,
|
||||||
|
_sources: sources,
|
||||||
|
_sourcesContent: sourcesContent,
|
||||||
|
_names: names
|
||||||
|
// _originalScopes: originalScopes,
|
||||||
|
} = cast2(map);
|
||||||
|
const line = getIndex(mappings, genLine);
|
||||||
|
const index = getColumnIndex(line, genColumn);
|
||||||
|
if (!source) {
|
||||||
|
if (skipable && skipSourceless(line, index)) return;
|
||||||
|
return insert(line, index, [genColumn]);
|
||||||
|
}
|
||||||
|
assert(sourceLine);
|
||||||
|
assert(sourceColumn);
|
||||||
|
const sourcesIndex = put(sources, source);
|
||||||
|
const namesIndex = name ? put(names, name) : NO_NAME;
|
||||||
|
if (sourcesIndex === sourcesContent.length) sourcesContent[sourcesIndex] = content != null ? content : null;
|
||||||
|
if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return insert(
|
||||||
|
line,
|
||||||
|
index,
|
||||||
|
name ? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex] : [genColumn, sourcesIndex, sourceLine, sourceColumn]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
function assert(_val) {
|
||||||
|
}
|
||||||
|
function getIndex(arr, index) {
|
||||||
|
for (let i = arr.length; i <= index; i++) {
|
||||||
|
arr[i] = [];
|
||||||
|
}
|
||||||
|
return arr[index];
|
||||||
|
}
|
||||||
|
function getColumnIndex(line, genColumn) {
|
||||||
|
let index = line.length;
|
||||||
|
for (let i = index - 1; i >= 0; index = i--) {
|
||||||
|
const current = line[i];
|
||||||
|
if (genColumn >= current[COLUMN]) break;
|
||||||
|
}
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
function insert(array, index, value) {
|
||||||
|
for (let i = array.length; i > index; i--) {
|
||||||
|
array[i] = array[i - 1];
|
||||||
|
}
|
||||||
|
array[index] = value;
|
||||||
|
}
|
||||||
|
function removeEmptyFinalLines(mappings) {
|
||||||
|
const { length } = mappings;
|
||||||
|
let len = length;
|
||||||
|
for (let i = len - 1; i >= 0; len = i, i--) {
|
||||||
|
if (mappings[i].length > 0) break;
|
||||||
|
}
|
||||||
|
if (len < length) mappings.length = len;
|
||||||
|
}
|
||||||
|
function putAll(setarr, array) {
|
||||||
|
for (let i = 0; i < array.length; i++) put(setarr, array[i]);
|
||||||
|
}
|
||||||
|
function skipSourceless(line, index) {
|
||||||
|
if (index === 0) return true;
|
||||||
|
const prev = line[index - 1];
|
||||||
|
return prev.length === 1;
|
||||||
|
}
|
||||||
|
function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex) {
|
||||||
|
if (index === 0) return false;
|
||||||
|
const prev = line[index - 1];
|
||||||
|
if (prev.length === 1) return false;
|
||||||
|
return sourcesIndex === prev[SOURCES_INDEX] && sourceLine === prev[SOURCE_LINE] && sourceColumn === prev[SOURCE_COLUMN] && namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME);
|
||||||
|
}
|
||||||
|
function addMappingInternal(skipable, map, mapping) {
|
||||||
|
const { generated, source, original, name, content } = mapping;
|
||||||
|
if (!source) {
|
||||||
|
return addSegmentInternal(
|
||||||
|
skipable,
|
||||||
|
map,
|
||||||
|
generated.line - 1,
|
||||||
|
generated.column,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
assert(original);
|
||||||
|
return addSegmentInternal(
|
||||||
|
skipable,
|
||||||
|
map,
|
||||||
|
generated.line - 1,
|
||||||
|
generated.column,
|
||||||
|
source,
|
||||||
|
original.line - 1,
|
||||||
|
original.column,
|
||||||
|
name,
|
||||||
|
content
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
//# sourceMappingURL=gen-mapping.umd.js.map
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,71 @@
|
||||||
|
{
|
||||||
|
"name": "@jridgewell/gen-mapping",
|
||||||
|
"version": "0.3.12",
|
||||||
|
"description": "Generate source maps",
|
||||||
|
"keywords": [
|
||||||
|
"source",
|
||||||
|
"map"
|
||||||
|
],
|
||||||
|
"main": "dist/gen-mapping.umd.js",
|
||||||
|
"module": "dist/gen-mapping.mjs",
|
||||||
|
"types": "types/gen-mapping.d.cts",
|
||||||
|
"files": [
|
||||||
|
"dist",
|
||||||
|
"src",
|
||||||
|
"types"
|
||||||
|
],
|
||||||
|
"exports": {
|
||||||
|
".": [
|
||||||
|
{
|
||||||
|
"import": {
|
||||||
|
"types": "./types/gen-mapping.d.mts",
|
||||||
|
"default": "./dist/gen-mapping.mjs"
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"types": "./types/gen-mapping.d.cts",
|
||||||
|
"default": "./dist/gen-mapping.umd.js"
|
||||||
|
},
|
||||||
|
"browser": {
|
||||||
|
"types": "./types/gen-mapping.d.cts",
|
||||||
|
"default": "./dist/gen-mapping.umd.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"./dist/gen-mapping.umd.js"
|
||||||
|
],
|
||||||
|
"./package.json": "./package.json"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"benchmark": "run-s build:code benchmark:*",
|
||||||
|
"benchmark:install": "cd benchmark && npm install",
|
||||||
|
"benchmark:only": "node --expose-gc benchmark/index.js",
|
||||||
|
"build": "run-s -n build:code build:types",
|
||||||
|
"build:code": "node ../../esbuild.mjs gen-mapping.ts",
|
||||||
|
"build:types": "run-s build:types:force build:types:emit build:types:mts",
|
||||||
|
"build:types:force": "rimraf tsconfig.build.tsbuildinfo",
|
||||||
|
"build:types:emit": "tsc --project tsconfig.build.json",
|
||||||
|
"build:types:mts": "node ../../mts-types.mjs",
|
||||||
|
"clean": "run-s -n clean:code clean:types",
|
||||||
|
"clean:code": "tsc --build --clean tsconfig.build.json",
|
||||||
|
"clean:types": "rimraf dist types",
|
||||||
|
"test": "run-s -n test:types test:only test:format",
|
||||||
|
"test:format": "prettier --check '{src,test}/**/*.ts'",
|
||||||
|
"test:only": "mocha",
|
||||||
|
"test:types": "eslint '{src,test}/**/*.ts'",
|
||||||
|
"lint": "run-s -n lint:types lint:format",
|
||||||
|
"lint:format": "npm run test:format -- --write",
|
||||||
|
"lint:types": "npm run test:types -- --fix",
|
||||||
|
"prepublishOnly": "npm run-s -n build test"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/jridgewell/sourcemaps/tree/main/packages/gen-mapping",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/jridgewell/sourcemaps.git",
|
||||||
|
"directory": "packages/gen-mapping"
|
||||||
|
},
|
||||||
|
"author": "Justin Ridgewell <justin@ridgewell.name>",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@jridgewell/sourcemap-codec": "^1.5.0",
|
||||||
|
"@jridgewell/trace-mapping": "^0.3.24"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,614 @@
|
||||||
|
import { SetArray, put, remove } from './set-array';
|
||||||
|
import {
|
||||||
|
encode,
|
||||||
|
// encodeGeneratedRanges,
|
||||||
|
// encodeOriginalScopes
|
||||||
|
} from '@jridgewell/sourcemap-codec';
|
||||||
|
import { TraceMap, decodedMappings } from '@jridgewell/trace-mapping';
|
||||||
|
|
||||||
|
import {
|
||||||
|
COLUMN,
|
||||||
|
SOURCES_INDEX,
|
||||||
|
SOURCE_LINE,
|
||||||
|
SOURCE_COLUMN,
|
||||||
|
NAMES_INDEX,
|
||||||
|
} from './sourcemap-segment';
|
||||||
|
|
||||||
|
import type { SourceMapInput } from '@jridgewell/trace-mapping';
|
||||||
|
// import type { OriginalScope, GeneratedRange } from '@jridgewell/sourcemap-codec';
|
||||||
|
import type { SourceMapSegment } from './sourcemap-segment';
|
||||||
|
import type {
|
||||||
|
DecodedSourceMap,
|
||||||
|
EncodedSourceMap,
|
||||||
|
Pos,
|
||||||
|
Mapping,
|
||||||
|
// BindingExpressionRange,
|
||||||
|
// OriginalPos,
|
||||||
|
// OriginalScopeInfo,
|
||||||
|
// GeneratedRangeInfo,
|
||||||
|
} from './types';
|
||||||
|
|
||||||
|
export type { DecodedSourceMap, EncodedSourceMap, Mapping };
|
||||||
|
|
||||||
|
export type Options = {
|
||||||
|
file?: string | null;
|
||||||
|
sourceRoot?: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const NO_NAME = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the state to generate a sourcemap.
|
||||||
|
*/
|
||||||
|
export class GenMapping {
|
||||||
|
declare private _names: SetArray<string>;
|
||||||
|
declare private _sources: SetArray<string>;
|
||||||
|
declare private _sourcesContent: (string | null)[];
|
||||||
|
declare private _mappings: SourceMapSegment[][];
|
||||||
|
// private declare _originalScopes: OriginalScope[][];
|
||||||
|
// private declare _generatedRanges: GeneratedRange[];
|
||||||
|
declare private _ignoreList: SetArray<number>;
|
||||||
|
declare file: string | null | undefined;
|
||||||
|
declare sourceRoot: string | null | undefined;
|
||||||
|
|
||||||
|
constructor({ file, sourceRoot }: Options = {}) {
|
||||||
|
this._names = new SetArray();
|
||||||
|
this._sources = new SetArray();
|
||||||
|
this._sourcesContent = [];
|
||||||
|
this._mappings = [];
|
||||||
|
// this._originalScopes = [];
|
||||||
|
// this._generatedRanges = [];
|
||||||
|
this.file = file;
|
||||||
|
this.sourceRoot = sourceRoot;
|
||||||
|
this._ignoreList = new SetArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PublicMap {
|
||||||
|
_names: GenMapping['_names'];
|
||||||
|
_sources: GenMapping['_sources'];
|
||||||
|
_sourcesContent: GenMapping['_sourcesContent'];
|
||||||
|
_mappings: GenMapping['_mappings'];
|
||||||
|
// _originalScopes: GenMapping['_originalScopes'];
|
||||||
|
// _generatedRanges: GenMapping['_generatedRanges'];
|
||||||
|
_ignoreList: GenMapping['_ignoreList'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Typescript doesn't allow friend access to private fields, so this just casts the map into a type
|
||||||
|
* with public access modifiers.
|
||||||
|
*/
|
||||||
|
function cast(map: unknown): PublicMap {
|
||||||
|
return map as any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A low-level API to associate a generated position with an original source position. Line and
|
||||||
|
* column here are 0-based, unlike `addMapping`.
|
||||||
|
*/
|
||||||
|
export function addSegment(
|
||||||
|
map: GenMapping,
|
||||||
|
genLine: number,
|
||||||
|
genColumn: number,
|
||||||
|
source?: null,
|
||||||
|
sourceLine?: null,
|
||||||
|
sourceColumn?: null,
|
||||||
|
name?: null,
|
||||||
|
content?: null,
|
||||||
|
): void;
|
||||||
|
export function addSegment(
|
||||||
|
map: GenMapping,
|
||||||
|
genLine: number,
|
||||||
|
genColumn: number,
|
||||||
|
source: string,
|
||||||
|
sourceLine: number,
|
||||||
|
sourceColumn: number,
|
||||||
|
name?: null,
|
||||||
|
content?: string | null,
|
||||||
|
): void;
|
||||||
|
export function addSegment(
|
||||||
|
map: GenMapping,
|
||||||
|
genLine: number,
|
||||||
|
genColumn: number,
|
||||||
|
source: string,
|
||||||
|
sourceLine: number,
|
||||||
|
sourceColumn: number,
|
||||||
|
name: string,
|
||||||
|
content?: string | null,
|
||||||
|
): void;
|
||||||
|
export function addSegment(
|
||||||
|
map: GenMapping,
|
||||||
|
genLine: number,
|
||||||
|
genColumn: number,
|
||||||
|
source?: string | null,
|
||||||
|
sourceLine?: number | null,
|
||||||
|
sourceColumn?: number | null,
|
||||||
|
name?: string | null,
|
||||||
|
content?: string | null,
|
||||||
|
): void {
|
||||||
|
return addSegmentInternal(
|
||||||
|
false,
|
||||||
|
map,
|
||||||
|
genLine,
|
||||||
|
genColumn,
|
||||||
|
source,
|
||||||
|
sourceLine,
|
||||||
|
sourceColumn,
|
||||||
|
name,
|
||||||
|
content,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A high-level API to associate a generated position with an original source position. Line is
|
||||||
|
* 1-based, but column is 0-based, due to legacy behavior in `source-map` library.
|
||||||
|
*/
|
||||||
|
export function addMapping(
|
||||||
|
map: GenMapping,
|
||||||
|
mapping: {
|
||||||
|
generated: Pos;
|
||||||
|
source?: null;
|
||||||
|
original?: null;
|
||||||
|
name?: null;
|
||||||
|
content?: null;
|
||||||
|
},
|
||||||
|
): void;
|
||||||
|
export function addMapping(
|
||||||
|
map: GenMapping,
|
||||||
|
mapping: {
|
||||||
|
generated: Pos;
|
||||||
|
source: string;
|
||||||
|
original: Pos;
|
||||||
|
name?: null;
|
||||||
|
content?: string | null;
|
||||||
|
},
|
||||||
|
): void;
|
||||||
|
export function addMapping(
|
||||||
|
map: GenMapping,
|
||||||
|
mapping: {
|
||||||
|
generated: Pos;
|
||||||
|
source: string;
|
||||||
|
original: Pos;
|
||||||
|
name: string;
|
||||||
|
content?: string | null;
|
||||||
|
},
|
||||||
|
): void;
|
||||||
|
export function addMapping(
|
||||||
|
map: GenMapping,
|
||||||
|
mapping: {
|
||||||
|
generated: Pos;
|
||||||
|
source?: string | null;
|
||||||
|
original?: Pos | null;
|
||||||
|
name?: string | null;
|
||||||
|
content?: string | null;
|
||||||
|
},
|
||||||
|
): void {
|
||||||
|
return addMappingInternal(false, map, mapping as Parameters<typeof addMappingInternal>[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as `addSegment`, but will only add the segment if it generates useful information in the
|
||||||
|
* resulting map. This only works correctly if segments are added **in order**, meaning you should
|
||||||
|
* not add a segment with a lower generated line/column than one that came before.
|
||||||
|
*/
|
||||||
|
export const maybeAddSegment: typeof addSegment = (
|
||||||
|
map,
|
||||||
|
genLine,
|
||||||
|
genColumn,
|
||||||
|
source,
|
||||||
|
sourceLine,
|
||||||
|
sourceColumn,
|
||||||
|
name,
|
||||||
|
content,
|
||||||
|
) => {
|
||||||
|
return addSegmentInternal(
|
||||||
|
true,
|
||||||
|
map,
|
||||||
|
genLine,
|
||||||
|
genColumn,
|
||||||
|
source,
|
||||||
|
sourceLine,
|
||||||
|
sourceColumn,
|
||||||
|
name,
|
||||||
|
content,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as `addMapping`, but will only add the mapping if it generates useful information in the
|
||||||
|
* resulting map. This only works correctly if mappings are added **in order**, meaning you should
|
||||||
|
* not add a mapping with a lower generated line/column than one that came before.
|
||||||
|
*/
|
||||||
|
export const maybeAddMapping: typeof addMapping = (map, mapping) => {
|
||||||
|
return addMappingInternal(true, map, mapping as Parameters<typeof addMappingInternal>[2]);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds/removes the content of the source file to the source map.
|
||||||
|
*/
|
||||||
|
export function setSourceContent(map: GenMapping, source: string, content: string | null): void {
|
||||||
|
const {
|
||||||
|
_sources: sources,
|
||||||
|
_sourcesContent: sourcesContent,
|
||||||
|
// _originalScopes: originalScopes,
|
||||||
|
} = cast(map);
|
||||||
|
const index = put(sources, source);
|
||||||
|
sourcesContent[index] = content;
|
||||||
|
// if (index === originalScopes.length) originalScopes[index] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setIgnore(map: GenMapping, source: string, ignore = true) {
|
||||||
|
const {
|
||||||
|
_sources: sources,
|
||||||
|
_sourcesContent: sourcesContent,
|
||||||
|
_ignoreList: ignoreList,
|
||||||
|
// _originalScopes: originalScopes,
|
||||||
|
} = cast(map);
|
||||||
|
const index = put(sources, source);
|
||||||
|
if (index === sourcesContent.length) sourcesContent[index] = null;
|
||||||
|
// if (index === originalScopes.length) originalScopes[index] = [];
|
||||||
|
if (ignore) put(ignoreList, index);
|
||||||
|
else remove(ignoreList, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects
|
||||||
|
* a sourcemap, or to JSON.stringify.
|
||||||
|
*/
|
||||||
|
export function toDecodedMap(map: GenMapping): DecodedSourceMap {
|
||||||
|
const {
|
||||||
|
_mappings: mappings,
|
||||||
|
_sources: sources,
|
||||||
|
_sourcesContent: sourcesContent,
|
||||||
|
_names: names,
|
||||||
|
_ignoreList: ignoreList,
|
||||||
|
// _originalScopes: originalScopes,
|
||||||
|
// _generatedRanges: generatedRanges,
|
||||||
|
} = cast(map);
|
||||||
|
removeEmptyFinalLines(mappings);
|
||||||
|
|
||||||
|
return {
|
||||||
|
version: 3,
|
||||||
|
file: map.file || undefined,
|
||||||
|
names: names.array,
|
||||||
|
sourceRoot: map.sourceRoot || undefined,
|
||||||
|
sources: sources.array,
|
||||||
|
sourcesContent,
|
||||||
|
mappings,
|
||||||
|
// originalScopes,
|
||||||
|
// generatedRanges,
|
||||||
|
ignoreList: ignoreList.array,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects
|
||||||
|
* a sourcemap, or to JSON.stringify.
|
||||||
|
*/
|
||||||
|
export function toEncodedMap(map: GenMapping): EncodedSourceMap {
|
||||||
|
const decoded = toDecodedMap(map);
|
||||||
|
return Object.assign({}, decoded, {
|
||||||
|
// originalScopes: decoded.originalScopes.map((os) => encodeOriginalScopes(os)),
|
||||||
|
// generatedRanges: encodeGeneratedRanges(decoded.generatedRanges as GeneratedRange[]),
|
||||||
|
mappings: encode(decoded.mappings as SourceMapSegment[][]),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new GenMapping, using the already present mappings of the input.
|
||||||
|
*/
|
||||||
|
export function fromMap(input: SourceMapInput): GenMapping {
|
||||||
|
const map = new TraceMap(input);
|
||||||
|
const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot });
|
||||||
|
|
||||||
|
putAll(cast(gen)._names, map.names);
|
||||||
|
putAll(cast(gen)._sources, map.sources as string[]);
|
||||||
|
cast(gen)._sourcesContent = map.sourcesContent || map.sources.map(() => null);
|
||||||
|
cast(gen)._mappings = decodedMappings(map) as GenMapping['_mappings'];
|
||||||
|
// TODO: implement originalScopes/generatedRanges
|
||||||
|
if (map.ignoreList) putAll(cast(gen)._ignoreList, map.ignoreList);
|
||||||
|
|
||||||
|
return gen;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of high-level mapping objects for every recorded segment, which could then be
|
||||||
|
* passed to the `source-map` library.
|
||||||
|
*/
|
||||||
|
export function allMappings(map: GenMapping): Mapping[] {
|
||||||
|
const out: Mapping[] = [];
|
||||||
|
const { _mappings: mappings, _sources: sources, _names: names } = cast(map);
|
||||||
|
|
||||||
|
for (let i = 0; i < mappings.length; i++) {
|
||||||
|
const line = mappings[i];
|
||||||
|
for (let j = 0; j < line.length; j++) {
|
||||||
|
const seg = line[j];
|
||||||
|
|
||||||
|
const generated = { line: i + 1, column: seg[COLUMN] };
|
||||||
|
let source: string | undefined = undefined;
|
||||||
|
let original: Pos | undefined = undefined;
|
||||||
|
let name: string | undefined = undefined;
|
||||||
|
|
||||||
|
if (seg.length !== 1) {
|
||||||
|
source = sources.array[seg[SOURCES_INDEX]];
|
||||||
|
original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] };
|
||||||
|
|
||||||
|
if (seg.length === 5) name = names.array[seg[NAMES_INDEX]];
|
||||||
|
}
|
||||||
|
|
||||||
|
out.push({ generated, source, original, name } as Mapping);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This split declaration is only so that terser can elminiate the static initialization block.
|
||||||
|
function addSegmentInternal<S extends string | null | undefined>(
|
||||||
|
skipable: boolean,
|
||||||
|
map: GenMapping,
|
||||||
|
genLine: number,
|
||||||
|
genColumn: number,
|
||||||
|
source: S,
|
||||||
|
sourceLine: S extends string ? number : null | undefined,
|
||||||
|
sourceColumn: S extends string ? number : null | undefined,
|
||||||
|
name: S extends string ? string | null | undefined : null | undefined,
|
||||||
|
content: S extends string ? string | null | undefined : null | undefined,
|
||||||
|
): void {
|
||||||
|
const {
|
||||||
|
_mappings: mappings,
|
||||||
|
_sources: sources,
|
||||||
|
_sourcesContent: sourcesContent,
|
||||||
|
_names: names,
|
||||||
|
// _originalScopes: originalScopes,
|
||||||
|
} = cast(map);
|
||||||
|
const line = getIndex(mappings, genLine);
|
||||||
|
const index = getColumnIndex(line, genColumn);
|
||||||
|
|
||||||
|
if (!source) {
|
||||||
|
if (skipable && skipSourceless(line, index)) return;
|
||||||
|
return insert(line, index, [genColumn]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sigh, TypeScript can't figure out sourceLine and sourceColumn aren't nullish if source
|
||||||
|
// isn't nullish.
|
||||||
|
assert<number>(sourceLine);
|
||||||
|
assert<number>(sourceColumn);
|
||||||
|
|
||||||
|
const sourcesIndex = put(sources, source);
|
||||||
|
const namesIndex = name ? put(names, name) : NO_NAME;
|
||||||
|
if (sourcesIndex === sourcesContent.length) sourcesContent[sourcesIndex] = content ?? null;
|
||||||
|
// if (sourcesIndex === originalScopes.length) originalScopes[sourcesIndex] = [];
|
||||||
|
|
||||||
|
if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return insert(
|
||||||
|
line,
|
||||||
|
index,
|
||||||
|
name
|
||||||
|
? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]
|
||||||
|
: [genColumn, sourcesIndex, sourceLine, sourceColumn],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function assert<T>(_val: unknown): asserts _val is T {
|
||||||
|
// noop.
|
||||||
|
}
|
||||||
|
|
||||||
|
function getIndex<T>(arr: T[][], index: number): T[] {
|
||||||
|
for (let i = arr.length; i <= index; i++) {
|
||||||
|
arr[i] = [];
|
||||||
|
}
|
||||||
|
return arr[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getColumnIndex(line: SourceMapSegment[], genColumn: number): number {
|
||||||
|
let index = line.length;
|
||||||
|
for (let i = index - 1; i >= 0; index = i--) {
|
||||||
|
const current = line[i];
|
||||||
|
if (genColumn >= current[COLUMN]) break;
|
||||||
|
}
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
function insert<T>(array: T[], index: number, value: T) {
|
||||||
|
for (let i = array.length; i > index; i--) {
|
||||||
|
array[i] = array[i - 1];
|
||||||
|
}
|
||||||
|
array[index] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeEmptyFinalLines(mappings: SourceMapSegment[][]) {
|
||||||
|
const { length } = mappings;
|
||||||
|
let len = length;
|
||||||
|
for (let i = len - 1; i >= 0; len = i, i--) {
|
||||||
|
if (mappings[i].length > 0) break;
|
||||||
|
}
|
||||||
|
if (len < length) mappings.length = len;
|
||||||
|
}
|
||||||
|
|
||||||
|
function putAll<T extends string | number>(setarr: SetArray<T>, array: T[]) {
|
||||||
|
for (let i = 0; i < array.length; i++) put(setarr, array[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function skipSourceless(line: SourceMapSegment[], index: number): boolean {
|
||||||
|
// The start of a line is already sourceless, so adding a sourceless segment to the beginning
|
||||||
|
// doesn't generate any useful information.
|
||||||
|
if (index === 0) return true;
|
||||||
|
|
||||||
|
const prev = line[index - 1];
|
||||||
|
// If the previous segment is also sourceless, then adding another sourceless segment doesn't
|
||||||
|
// genrate any new information. Else, this segment will end the source/named segment and point to
|
||||||
|
// a sourceless position, which is useful.
|
||||||
|
return prev.length === 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function skipSource(
|
||||||
|
line: SourceMapSegment[],
|
||||||
|
index: number,
|
||||||
|
sourcesIndex: number,
|
||||||
|
sourceLine: number,
|
||||||
|
sourceColumn: number,
|
||||||
|
namesIndex: number,
|
||||||
|
): boolean {
|
||||||
|
// A source/named segment at the start of a line gives position at that genColumn
|
||||||
|
if (index === 0) return false;
|
||||||
|
|
||||||
|
const prev = line[index - 1];
|
||||||
|
|
||||||
|
// If the previous segment is sourceless, then we're transitioning to a source.
|
||||||
|
if (prev.length === 1) return false;
|
||||||
|
|
||||||
|
// If the previous segment maps to the exact same source position, then this segment doesn't
|
||||||
|
// provide any new position information.
|
||||||
|
return (
|
||||||
|
sourcesIndex === prev[SOURCES_INDEX] &&
|
||||||
|
sourceLine === prev[SOURCE_LINE] &&
|
||||||
|
sourceColumn === prev[SOURCE_COLUMN] &&
|
||||||
|
namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addMappingInternal<S extends string | null | undefined>(
|
||||||
|
skipable: boolean,
|
||||||
|
map: GenMapping,
|
||||||
|
mapping: {
|
||||||
|
generated: Pos;
|
||||||
|
source: S;
|
||||||
|
original: S extends string ? Pos : null | undefined;
|
||||||
|
name: S extends string ? string | null | undefined : null | undefined;
|
||||||
|
content: S extends string ? string | null | undefined : null | undefined;
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
const { generated, source, original, name, content } = mapping;
|
||||||
|
if (!source) {
|
||||||
|
return addSegmentInternal(
|
||||||
|
skipable,
|
||||||
|
map,
|
||||||
|
generated.line - 1,
|
||||||
|
generated.column,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
assert<Pos>(original);
|
||||||
|
return addSegmentInternal(
|
||||||
|
skipable,
|
||||||
|
map,
|
||||||
|
generated.line - 1,
|
||||||
|
generated.column,
|
||||||
|
source as string,
|
||||||
|
original.line - 1,
|
||||||
|
original.column,
|
||||||
|
name,
|
||||||
|
content,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
export function addOriginalScope(
|
||||||
|
map: GenMapping,
|
||||||
|
data: {
|
||||||
|
start: Pos;
|
||||||
|
end: Pos;
|
||||||
|
source: string;
|
||||||
|
kind: string;
|
||||||
|
name?: string;
|
||||||
|
variables?: string[];
|
||||||
|
},
|
||||||
|
): OriginalScopeInfo {
|
||||||
|
const { start, end, source, kind, name, variables } = data;
|
||||||
|
const {
|
||||||
|
_sources: sources,
|
||||||
|
_sourcesContent: sourcesContent,
|
||||||
|
_originalScopes: originalScopes,
|
||||||
|
_names: names,
|
||||||
|
} = cast(map);
|
||||||
|
const index = put(sources, source);
|
||||||
|
if (index === sourcesContent.length) sourcesContent[index] = null;
|
||||||
|
if (index === originalScopes.length) originalScopes[index] = [];
|
||||||
|
|
||||||
|
const kindIndex = put(names, kind);
|
||||||
|
const scope: OriginalScope = name
|
||||||
|
? [start.line - 1, start.column, end.line - 1, end.column, kindIndex, put(names, name)]
|
||||||
|
: [start.line - 1, start.column, end.line - 1, end.column, kindIndex];
|
||||||
|
if (variables) {
|
||||||
|
scope.vars = variables.map((v) => put(names, v));
|
||||||
|
}
|
||||||
|
const len = originalScopes[index].push(scope);
|
||||||
|
return [index, len - 1, variables];
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Generated Ranges
|
||||||
|
/*
|
||||||
|
export function addGeneratedRange(
|
||||||
|
map: GenMapping,
|
||||||
|
data: {
|
||||||
|
start: Pos;
|
||||||
|
isScope: boolean;
|
||||||
|
originalScope?: OriginalScopeInfo;
|
||||||
|
callsite?: OriginalPos;
|
||||||
|
},
|
||||||
|
): GeneratedRangeInfo {
|
||||||
|
const { start, isScope, originalScope, callsite } = data;
|
||||||
|
const {
|
||||||
|
_originalScopes: originalScopes,
|
||||||
|
_sources: sources,
|
||||||
|
_sourcesContent: sourcesContent,
|
||||||
|
_generatedRanges: generatedRanges,
|
||||||
|
} = cast(map);
|
||||||
|
|
||||||
|
const range: GeneratedRange = [
|
||||||
|
start.line - 1,
|
||||||
|
start.column,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
originalScope ? originalScope[0] : -1,
|
||||||
|
originalScope ? originalScope[1] : -1,
|
||||||
|
];
|
||||||
|
if (originalScope?.[2]) {
|
||||||
|
range.bindings = originalScope[2].map(() => [[-1]]);
|
||||||
|
}
|
||||||
|
if (callsite) {
|
||||||
|
const index = put(sources, callsite.source);
|
||||||
|
if (index === sourcesContent.length) sourcesContent[index] = null;
|
||||||
|
if (index === originalScopes.length) originalScopes[index] = [];
|
||||||
|
range.callsite = [index, callsite.line - 1, callsite.column];
|
||||||
|
}
|
||||||
|
if (isScope) range.isScope = true;
|
||||||
|
generatedRanges.push(range);
|
||||||
|
|
||||||
|
return [range, originalScope?.[2]];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setEndPosition(range: GeneratedRangeInfo, pos: Pos) {
|
||||||
|
range[0][2] = pos.line - 1;
|
||||||
|
range[0][3] = pos.column;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addBinding(
|
||||||
|
map: GenMapping,
|
||||||
|
range: GeneratedRangeInfo,
|
||||||
|
variable: string,
|
||||||
|
expression: string | BindingExpressionRange,
|
||||||
|
) {
|
||||||
|
const { _names: names } = cast(map);
|
||||||
|
const bindings = (range[0].bindings ||= []);
|
||||||
|
const vars = range[1];
|
||||||
|
|
||||||
|
const index = vars!.indexOf(variable);
|
||||||
|
const binding = getIndex(bindings, index);
|
||||||
|
|
||||||
|
if (typeof expression === 'string') binding[0] = [put(names, expression)];
|
||||||
|
else {
|
||||||
|
const { start } = expression;
|
||||||
|
binding.push([put(names, expression.expression), start.line - 1, start.column]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
|
@ -0,0 +1,82 @@
|
||||||
|
type Key = string | number | symbol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the
|
||||||
|
* index of the `key` in the backing array.
|
||||||
|
*
|
||||||
|
* This is designed to allow synchronizing a second array with the contents of the backing array,
|
||||||
|
* like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`,
|
||||||
|
* and there are never duplicates.
|
||||||
|
*/
|
||||||
|
export class SetArray<T extends Key = Key> {
|
||||||
|
declare private _indexes: Record<T, number | undefined>;
|
||||||
|
declare array: readonly T[];
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this._indexes = { __proto__: null } as any;
|
||||||
|
this.array = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PublicSet<T extends Key> {
|
||||||
|
array: T[];
|
||||||
|
_indexes: SetArray<T>['_indexes'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Typescript doesn't allow friend access to private fields, so this just casts the set into a type
|
||||||
|
* with public access modifiers.
|
||||||
|
*/
|
||||||
|
function cast<T extends Key>(set: SetArray<T>): PublicSet<T> {
|
||||||
|
return set as any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the index associated with `key` in the backing array, if it is already present.
|
||||||
|
*/
|
||||||
|
export function get<T extends Key>(setarr: SetArray<T>, key: T): number | undefined {
|
||||||
|
return cast(setarr)._indexes[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Puts `key` into the backing array, if it is not already present. Returns
|
||||||
|
* the index of the `key` in the backing array.
|
||||||
|
*/
|
||||||
|
export function put<T extends Key>(setarr: SetArray<T>, key: T): number {
|
||||||
|
// The key may or may not be present. If it is present, it's a number.
|
||||||
|
const index = get(setarr, key);
|
||||||
|
if (index !== undefined) return index;
|
||||||
|
|
||||||
|
const { array, _indexes: indexes } = cast(setarr);
|
||||||
|
|
||||||
|
const length = array.push(key);
|
||||||
|
return (indexes[key] = length - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pops the last added item out of the SetArray.
|
||||||
|
*/
|
||||||
|
export function pop<T extends Key>(setarr: SetArray<T>): void {
|
||||||
|
const { array, _indexes: indexes } = cast(setarr);
|
||||||
|
if (array.length === 0) return;
|
||||||
|
|
||||||
|
const last = array.pop()!;
|
||||||
|
indexes[last] = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the key, if it exists in the set.
|
||||||
|
*/
|
||||||
|
export function remove<T extends Key>(setarr: SetArray<T>, key: T): void {
|
||||||
|
const index = get(setarr, key);
|
||||||
|
if (index === undefined) return;
|
||||||
|
|
||||||
|
const { array, _indexes: indexes } = cast(setarr);
|
||||||
|
for (let i = index + 1; i < array.length; i++) {
|
||||||
|
const k = array[i];
|
||||||
|
array[i - 1] = k;
|
||||||
|
indexes[k]!--;
|
||||||
|
}
|
||||||
|
indexes[key] = undefined;
|
||||||
|
array.pop();
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
type GeneratedColumn = number;
|
||||||
|
type SourcesIndex = number;
|
||||||
|
type SourceLine = number;
|
||||||
|
type SourceColumn = number;
|
||||||
|
type NamesIndex = number;
|
||||||
|
|
||||||
|
export type SourceMapSegment =
|
||||||
|
| [GeneratedColumn]
|
||||||
|
| [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn]
|
||||||
|
| [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex];
|
||||||
|
|
||||||
|
export const COLUMN = 0;
|
||||||
|
export const SOURCES_INDEX = 1;
|
||||||
|
export const SOURCE_LINE = 2;
|
||||||
|
export const SOURCE_COLUMN = 3;
|
||||||
|
export const NAMES_INDEX = 4;
|
|
@ -0,0 +1,61 @@
|
||||||
|
// import type { GeneratedRange, OriginalScope } from '@jridgewell/sourcemap-codec';
|
||||||
|
import type { SourceMapSegment } from './sourcemap-segment';
|
||||||
|
|
||||||
|
export interface SourceMapV3 {
|
||||||
|
file?: string | null;
|
||||||
|
names: readonly string[];
|
||||||
|
sourceRoot?: string;
|
||||||
|
sources: readonly (string | null)[];
|
||||||
|
sourcesContent?: readonly (string | null)[];
|
||||||
|
version: 3;
|
||||||
|
ignoreList?: readonly number[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EncodedSourceMap extends SourceMapV3 {
|
||||||
|
mappings: string;
|
||||||
|
// originalScopes: string[];
|
||||||
|
// generatedRanges: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DecodedSourceMap extends SourceMapV3 {
|
||||||
|
mappings: readonly SourceMapSegment[][];
|
||||||
|
// originalScopes: readonly OriginalScope[][];
|
||||||
|
// generatedRanges: readonly GeneratedRange[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Pos {
|
||||||
|
line: number; // 1-based
|
||||||
|
column: number; // 0-based
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OriginalPos extends Pos {
|
||||||
|
source: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BindingExpressionRange {
|
||||||
|
start: Pos;
|
||||||
|
expression: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// export type OriginalScopeInfo = [number, number, string[] | undefined];
|
||||||
|
// export type GeneratedRangeInfo = [GeneratedRange, string[] | undefined];
|
||||||
|
|
||||||
|
export type Mapping =
|
||||||
|
| {
|
||||||
|
generated: Pos;
|
||||||
|
source: undefined;
|
||||||
|
original: undefined;
|
||||||
|
name: undefined;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
generated: Pos;
|
||||||
|
source: string;
|
||||||
|
original: Pos;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
generated: Pos;
|
||||||
|
source: string;
|
||||||
|
original: Pos;
|
||||||
|
name: undefined;
|
||||||
|
};
|
|
@ -0,0 +1,89 @@
|
||||||
|
import type { SourceMapInput } from '@jridgewell/trace-mapping';
|
||||||
|
import type { DecodedSourceMap, EncodedSourceMap, Pos, Mapping } from './types.cts';
|
||||||
|
export type { DecodedSourceMap, EncodedSourceMap, Mapping };
|
||||||
|
export type Options = {
|
||||||
|
file?: string | null;
|
||||||
|
sourceRoot?: string | null;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Provides the state to generate a sourcemap.
|
||||||
|
*/
|
||||||
|
export declare class GenMapping {
|
||||||
|
private _names;
|
||||||
|
private _sources;
|
||||||
|
private _sourcesContent;
|
||||||
|
private _mappings;
|
||||||
|
private _ignoreList;
|
||||||
|
file: string | null | undefined;
|
||||||
|
sourceRoot: string | null | undefined;
|
||||||
|
constructor({ file, sourceRoot }?: Options);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* A low-level API to associate a generated position with an original source position. Line and
|
||||||
|
* column here are 0-based, unlike `addMapping`.
|
||||||
|
*/
|
||||||
|
export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source?: null, sourceLine?: null, sourceColumn?: null, name?: null, content?: null): void;
|
||||||
|
export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name?: null, content?: string | null): void;
|
||||||
|
export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name: string, content?: string | null): void;
|
||||||
|
/**
|
||||||
|
* A high-level API to associate a generated position with an original source position. Line is
|
||||||
|
* 1-based, but column is 0-based, due to legacy behavior in `source-map` library.
|
||||||
|
*/
|
||||||
|
export declare function addMapping(map: GenMapping, mapping: {
|
||||||
|
generated: Pos;
|
||||||
|
source?: null;
|
||||||
|
original?: null;
|
||||||
|
name?: null;
|
||||||
|
content?: null;
|
||||||
|
}): void;
|
||||||
|
export declare function addMapping(map: GenMapping, mapping: {
|
||||||
|
generated: Pos;
|
||||||
|
source: string;
|
||||||
|
original: Pos;
|
||||||
|
name?: null;
|
||||||
|
content?: string | null;
|
||||||
|
}): void;
|
||||||
|
export declare function addMapping(map: GenMapping, mapping: {
|
||||||
|
generated: Pos;
|
||||||
|
source: string;
|
||||||
|
original: Pos;
|
||||||
|
name: string;
|
||||||
|
content?: string | null;
|
||||||
|
}): void;
|
||||||
|
/**
|
||||||
|
* Same as `addSegment`, but will only add the segment if it generates useful information in the
|
||||||
|
* resulting map. This only works correctly if segments are added **in order**, meaning you should
|
||||||
|
* not add a segment with a lower generated line/column than one that came before.
|
||||||
|
*/
|
||||||
|
export declare const maybeAddSegment: typeof addSegment;
|
||||||
|
/**
|
||||||
|
* Same as `addMapping`, but will only add the mapping if it generates useful information in the
|
||||||
|
* resulting map. This only works correctly if mappings are added **in order**, meaning you should
|
||||||
|
* not add a mapping with a lower generated line/column than one that came before.
|
||||||
|
*/
|
||||||
|
export declare const maybeAddMapping: typeof addMapping;
|
||||||
|
/**
|
||||||
|
* Adds/removes the content of the source file to the source map.
|
||||||
|
*/
|
||||||
|
export declare function setSourceContent(map: GenMapping, source: string, content: string | null): void;
|
||||||
|
export declare function setIgnore(map: GenMapping, source: string, ignore?: boolean): void;
|
||||||
|
/**
|
||||||
|
* Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects
|
||||||
|
* a sourcemap, or to JSON.stringify.
|
||||||
|
*/
|
||||||
|
export declare function toDecodedMap(map: GenMapping): DecodedSourceMap;
|
||||||
|
/**
|
||||||
|
* Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects
|
||||||
|
* a sourcemap, or to JSON.stringify.
|
||||||
|
*/
|
||||||
|
export declare function toEncodedMap(map: GenMapping): EncodedSourceMap;
|
||||||
|
/**
|
||||||
|
* Constructs a new GenMapping, using the already present mappings of the input.
|
||||||
|
*/
|
||||||
|
export declare function fromMap(input: SourceMapInput): GenMapping;
|
||||||
|
/**
|
||||||
|
* Returns an array of high-level mapping objects for every recorded segment, which could then be
|
||||||
|
* passed to the `source-map` library.
|
||||||
|
*/
|
||||||
|
export declare function allMappings(map: GenMapping): Mapping[];
|
||||||
|
//# sourceMappingURL=gen-mapping.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"gen-mapping.d.ts","sourceRoot":"","sources":["../src/gen-mapping.ts"],"names":[],"mappings":"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"}
|
|
@ -0,0 +1,89 @@
|
||||||
|
import type { SourceMapInput } from '@jridgewell/trace-mapping';
|
||||||
|
import type { DecodedSourceMap, EncodedSourceMap, Pos, Mapping } from './types.mts';
|
||||||
|
export type { DecodedSourceMap, EncodedSourceMap, Mapping };
|
||||||
|
export type Options = {
|
||||||
|
file?: string | null;
|
||||||
|
sourceRoot?: string | null;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Provides the state to generate a sourcemap.
|
||||||
|
*/
|
||||||
|
export declare class GenMapping {
|
||||||
|
private _names;
|
||||||
|
private _sources;
|
||||||
|
private _sourcesContent;
|
||||||
|
private _mappings;
|
||||||
|
private _ignoreList;
|
||||||
|
file: string | null | undefined;
|
||||||
|
sourceRoot: string | null | undefined;
|
||||||
|
constructor({ file, sourceRoot }?: Options);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* A low-level API to associate a generated position with an original source position. Line and
|
||||||
|
* column here are 0-based, unlike `addMapping`.
|
||||||
|
*/
|
||||||
|
export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source?: null, sourceLine?: null, sourceColumn?: null, name?: null, content?: null): void;
|
||||||
|
export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name?: null, content?: string | null): void;
|
||||||
|
export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name: string, content?: string | null): void;
|
||||||
|
/**
|
||||||
|
* A high-level API to associate a generated position with an original source position. Line is
|
||||||
|
* 1-based, but column is 0-based, due to legacy behavior in `source-map` library.
|
||||||
|
*/
|
||||||
|
export declare function addMapping(map: GenMapping, mapping: {
|
||||||
|
generated: Pos;
|
||||||
|
source?: null;
|
||||||
|
original?: null;
|
||||||
|
name?: null;
|
||||||
|
content?: null;
|
||||||
|
}): void;
|
||||||
|
export declare function addMapping(map: GenMapping, mapping: {
|
||||||
|
generated: Pos;
|
||||||
|
source: string;
|
||||||
|
original: Pos;
|
||||||
|
name?: null;
|
||||||
|
content?: string | null;
|
||||||
|
}): void;
|
||||||
|
export declare function addMapping(map: GenMapping, mapping: {
|
||||||
|
generated: Pos;
|
||||||
|
source: string;
|
||||||
|
original: Pos;
|
||||||
|
name: string;
|
||||||
|
content?: string | null;
|
||||||
|
}): void;
|
||||||
|
/**
|
||||||
|
* Same as `addSegment`, but will only add the segment if it generates useful information in the
|
||||||
|
* resulting map. This only works correctly if segments are added **in order**, meaning you should
|
||||||
|
* not add a segment with a lower generated line/column than one that came before.
|
||||||
|
*/
|
||||||
|
export declare const maybeAddSegment: typeof addSegment;
|
||||||
|
/**
|
||||||
|
* Same as `addMapping`, but will only add the mapping if it generates useful information in the
|
||||||
|
* resulting map. This only works correctly if mappings are added **in order**, meaning you should
|
||||||
|
* not add a mapping with a lower generated line/column than one that came before.
|
||||||
|
*/
|
||||||
|
export declare const maybeAddMapping: typeof addMapping;
|
||||||
|
/**
|
||||||
|
* Adds/removes the content of the source file to the source map.
|
||||||
|
*/
|
||||||
|
export declare function setSourceContent(map: GenMapping, source: string, content: string | null): void;
|
||||||
|
export declare function setIgnore(map: GenMapping, source: string, ignore?: boolean): void;
|
||||||
|
/**
|
||||||
|
* Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects
|
||||||
|
* a sourcemap, or to JSON.stringify.
|
||||||
|
*/
|
||||||
|
export declare function toDecodedMap(map: GenMapping): DecodedSourceMap;
|
||||||
|
/**
|
||||||
|
* Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects
|
||||||
|
* a sourcemap, or to JSON.stringify.
|
||||||
|
*/
|
||||||
|
export declare function toEncodedMap(map: GenMapping): EncodedSourceMap;
|
||||||
|
/**
|
||||||
|
* Constructs a new GenMapping, using the already present mappings of the input.
|
||||||
|
*/
|
||||||
|
export declare function fromMap(input: SourceMapInput): GenMapping;
|
||||||
|
/**
|
||||||
|
* Returns an array of high-level mapping objects for every recorded segment, which could then be
|
||||||
|
* passed to the `source-map` library.
|
||||||
|
*/
|
||||||
|
export declare function allMappings(map: GenMapping): Mapping[];
|
||||||
|
//# sourceMappingURL=gen-mapping.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"gen-mapping.d.ts","sourceRoot":"","sources":["../src/gen-mapping.ts"],"names":[],"mappings":"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"}
|
|
@ -0,0 +1,33 @@
|
||||||
|
type Key = string | number | symbol;
|
||||||
|
/**
|
||||||
|
* SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the
|
||||||
|
* index of the `key` in the backing array.
|
||||||
|
*
|
||||||
|
* This is designed to allow synchronizing a second array with the contents of the backing array,
|
||||||
|
* like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`,
|
||||||
|
* and there are never duplicates.
|
||||||
|
*/
|
||||||
|
export declare class SetArray<T extends Key = Key> {
|
||||||
|
private _indexes;
|
||||||
|
array: readonly T[];
|
||||||
|
constructor();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Gets the index associated with `key` in the backing array, if it is already present.
|
||||||
|
*/
|
||||||
|
export declare function get<T extends Key>(setarr: SetArray<T>, key: T): number | undefined;
|
||||||
|
/**
|
||||||
|
* Puts `key` into the backing array, if it is not already present. Returns
|
||||||
|
* the index of the `key` in the backing array.
|
||||||
|
*/
|
||||||
|
export declare function put<T extends Key>(setarr: SetArray<T>, key: T): number;
|
||||||
|
/**
|
||||||
|
* Pops the last added item out of the SetArray.
|
||||||
|
*/
|
||||||
|
export declare function pop<T extends Key>(setarr: SetArray<T>): void;
|
||||||
|
/**
|
||||||
|
* Removes the key, if it exists in the set.
|
||||||
|
*/
|
||||||
|
export declare function remove<T extends Key>(setarr: SetArray<T>, key: T): void;
|
||||||
|
export {};
|
||||||
|
//# sourceMappingURL=set-array.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"set-array.d.ts","sourceRoot":"","sources":["../src/set-array.ts"],"names":[],"mappings":"AAAA,KAAK,GAAG,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpC;;;;;;;GAOG;AACH,qBAAa,QAAQ,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG;IACvC,QAAgB,QAAQ,CAAgC;IAChD,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;;CAM7B;AAeD;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,GAAG,SAAS,CAElF;AAED;;;GAGG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,CAStE;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAM5D;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,CAYvE"}
|
|
@ -0,0 +1,33 @@
|
||||||
|
type Key = string | number | symbol;
|
||||||
|
/**
|
||||||
|
* SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the
|
||||||
|
* index of the `key` in the backing array.
|
||||||
|
*
|
||||||
|
* This is designed to allow synchronizing a second array with the contents of the backing array,
|
||||||
|
* like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`,
|
||||||
|
* and there are never duplicates.
|
||||||
|
*/
|
||||||
|
export declare class SetArray<T extends Key = Key> {
|
||||||
|
private _indexes;
|
||||||
|
array: readonly T[];
|
||||||
|
constructor();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Gets the index associated with `key` in the backing array, if it is already present.
|
||||||
|
*/
|
||||||
|
export declare function get<T extends Key>(setarr: SetArray<T>, key: T): number | undefined;
|
||||||
|
/**
|
||||||
|
* Puts `key` into the backing array, if it is not already present. Returns
|
||||||
|
* the index of the `key` in the backing array.
|
||||||
|
*/
|
||||||
|
export declare function put<T extends Key>(setarr: SetArray<T>, key: T): number;
|
||||||
|
/**
|
||||||
|
* Pops the last added item out of the SetArray.
|
||||||
|
*/
|
||||||
|
export declare function pop<T extends Key>(setarr: SetArray<T>): void;
|
||||||
|
/**
|
||||||
|
* Removes the key, if it exists in the set.
|
||||||
|
*/
|
||||||
|
export declare function remove<T extends Key>(setarr: SetArray<T>, key: T): void;
|
||||||
|
export {};
|
||||||
|
//# sourceMappingURL=set-array.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"set-array.d.ts","sourceRoot":"","sources":["../src/set-array.ts"],"names":[],"mappings":"AAAA,KAAK,GAAG,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpC;;;;;;;GAOG;AACH,qBAAa,QAAQ,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG;IACvC,QAAgB,QAAQ,CAAgC;IAChD,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;;CAM7B;AAeD;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,GAAG,SAAS,CAElF;AAED;;;GAGG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,CAStE;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAM5D;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,CAYvE"}
|
|
@ -0,0 +1,13 @@
|
||||||
|
type GeneratedColumn = number;
|
||||||
|
type SourcesIndex = number;
|
||||||
|
type SourceLine = number;
|
||||||
|
type SourceColumn = number;
|
||||||
|
type NamesIndex = number;
|
||||||
|
export type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex];
|
||||||
|
export declare const COLUMN = 0;
|
||||||
|
export declare const SOURCES_INDEX = 1;
|
||||||
|
export declare const SOURCE_LINE = 2;
|
||||||
|
export declare const SOURCE_COLUMN = 3;
|
||||||
|
export declare const NAMES_INDEX = 4;
|
||||||
|
export {};
|
||||||
|
//# sourceMappingURL=sourcemap-segment.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"sourcemap-segment.d.ts","sourceRoot":"","sources":["../src/sourcemap-segment.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG,MAAM,CAAC;AAC9B,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AACzB,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AAEzB,MAAM,MAAM,gBAAgB,GACxB,CAAC,eAAe,CAAC,GACjB,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,CAAC,GACzD,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AAE1E,eAAO,MAAM,MAAM,IAAI,CAAC;AACxB,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC"}
|
|
@ -0,0 +1,13 @@
|
||||||
|
type GeneratedColumn = number;
|
||||||
|
type SourcesIndex = number;
|
||||||
|
type SourceLine = number;
|
||||||
|
type SourceColumn = number;
|
||||||
|
type NamesIndex = number;
|
||||||
|
export type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex];
|
||||||
|
export declare const COLUMN = 0;
|
||||||
|
export declare const SOURCES_INDEX = 1;
|
||||||
|
export declare const SOURCE_LINE = 2;
|
||||||
|
export declare const SOURCE_COLUMN = 3;
|
||||||
|
export declare const NAMES_INDEX = 4;
|
||||||
|
export {};
|
||||||
|
//# sourceMappingURL=sourcemap-segment.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"sourcemap-segment.d.ts","sourceRoot":"","sources":["../src/sourcemap-segment.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG,MAAM,CAAC;AAC9B,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AACzB,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,UAAU,GAAG,MAAM,CAAC;AAEzB,MAAM,MAAM,gBAAgB,GACxB,CAAC,eAAe,CAAC,GACjB,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,CAAC,GACzD,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AAE1E,eAAO,MAAM,MAAM,IAAI,CAAC;AACxB,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC"}
|
|
@ -0,0 +1,44 @@
|
||||||
|
import type { SourceMapSegment } from './sourcemap-segment.cts';
|
||||||
|
export interface SourceMapV3 {
|
||||||
|
file?: string | null;
|
||||||
|
names: readonly string[];
|
||||||
|
sourceRoot?: string;
|
||||||
|
sources: readonly (string | null)[];
|
||||||
|
sourcesContent?: readonly (string | null)[];
|
||||||
|
version: 3;
|
||||||
|
ignoreList?: readonly number[];
|
||||||
|
}
|
||||||
|
export interface EncodedSourceMap extends SourceMapV3 {
|
||||||
|
mappings: string;
|
||||||
|
}
|
||||||
|
export interface DecodedSourceMap extends SourceMapV3 {
|
||||||
|
mappings: readonly SourceMapSegment[][];
|
||||||
|
}
|
||||||
|
export interface Pos {
|
||||||
|
line: number;
|
||||||
|
column: number;
|
||||||
|
}
|
||||||
|
export interface OriginalPos extends Pos {
|
||||||
|
source: string;
|
||||||
|
}
|
||||||
|
export interface BindingExpressionRange {
|
||||||
|
start: Pos;
|
||||||
|
expression: string;
|
||||||
|
}
|
||||||
|
export type Mapping = {
|
||||||
|
generated: Pos;
|
||||||
|
source: undefined;
|
||||||
|
original: undefined;
|
||||||
|
name: undefined;
|
||||||
|
} | {
|
||||||
|
generated: Pos;
|
||||||
|
source: string;
|
||||||
|
original: Pos;
|
||||||
|
name: string;
|
||||||
|
} | {
|
||||||
|
generated: Pos;
|
||||||
|
source: string;
|
||||||
|
original: Pos;
|
||||||
|
name: undefined;
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=types.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACpC,cAAc,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAC5C,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,MAAM,CAAC;CAGlB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,SAAS,gBAAgB,EAAE,EAAE,CAAC;CAGzC;AAED,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAY,SAAQ,GAAG;IACtC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;CACpB;AAKD,MAAM,MAAM,OAAO,GACf;IACE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC;CACjB,GACD;IACE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC"}
|
|
@ -0,0 +1,44 @@
|
||||||
|
import type { SourceMapSegment } from './sourcemap-segment.mts';
|
||||||
|
export interface SourceMapV3 {
|
||||||
|
file?: string | null;
|
||||||
|
names: readonly string[];
|
||||||
|
sourceRoot?: string;
|
||||||
|
sources: readonly (string | null)[];
|
||||||
|
sourcesContent?: readonly (string | null)[];
|
||||||
|
version: 3;
|
||||||
|
ignoreList?: readonly number[];
|
||||||
|
}
|
||||||
|
export interface EncodedSourceMap extends SourceMapV3 {
|
||||||
|
mappings: string;
|
||||||
|
}
|
||||||
|
export interface DecodedSourceMap extends SourceMapV3 {
|
||||||
|
mappings: readonly SourceMapSegment[][];
|
||||||
|
}
|
||||||
|
export interface Pos {
|
||||||
|
line: number;
|
||||||
|
column: number;
|
||||||
|
}
|
||||||
|
export interface OriginalPos extends Pos {
|
||||||
|
source: string;
|
||||||
|
}
|
||||||
|
export interface BindingExpressionRange {
|
||||||
|
start: Pos;
|
||||||
|
expression: string;
|
||||||
|
}
|
||||||
|
export type Mapping = {
|
||||||
|
generated: Pos;
|
||||||
|
source: undefined;
|
||||||
|
original: undefined;
|
||||||
|
name: undefined;
|
||||||
|
} | {
|
||||||
|
generated: Pos;
|
||||||
|
source: string;
|
||||||
|
original: Pos;
|
||||||
|
name: string;
|
||||||
|
} | {
|
||||||
|
generated: Pos;
|
||||||
|
source: string;
|
||||||
|
original: Pos;
|
||||||
|
name: undefined;
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=types.d.ts.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACpC,cAAc,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAC5C,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,MAAM,CAAC;CAGlB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,QAAQ,EAAE,SAAS,gBAAgB,EAAE,EAAE,CAAC;CAGzC;AAED,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAY,SAAQ,GAAG;IACtC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;CACpB;AAKD,MAAM,MAAM,OAAO,GACf;IACE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC;CACjB,GACD;IACE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC"}
|
|
@ -0,0 +1,19 @@
|
||||||
|
Copyright 2019 Justin Ridgewell <jridgewell@google.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -0,0 +1,40 @@
|
||||||
|
# @jridgewell/resolve-uri
|
||||||
|
|
||||||
|
> Resolve a URI relative to an optional base URI
|
||||||
|
|
||||||
|
Resolve any combination of absolute URIs, protocol-realtive URIs, absolute paths, or relative paths.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install @jridgewell/resolve-uri
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
function resolve(input: string, base?: string): string;
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
import resolve from '@jridgewell/resolve-uri';
|
||||||
|
|
||||||
|
resolve('foo', 'https://example.com'); // => 'https://example.com/foo'
|
||||||
|
```
|
||||||
|
|
||||||
|
| Input | Base | Resolution | Explanation |
|
||||||
|
|-----------------------|-------------------------|--------------------------------|--------------------------------------------------------------|
|
||||||
|
| `https://example.com` | _any_ | `https://example.com/` | Input is normalized only |
|
||||||
|
| `//example.com` | `https://base.com/` | `https://example.com/` | Input inherits the base's protocol |
|
||||||
|
| `//example.com` | _rest_ | `//example.com/` | Input is normalized only |
|
||||||
|
| `/example` | `https://base.com/` | `https://base.com/example` | Input inherits the base's origin |
|
||||||
|
| `/example` | `//base.com/` | `//base.com/example` | Input inherits the base's host and remains protocol relative |
|
||||||
|
| `/example` | _rest_ | `/example` | Input is normalized only |
|
||||||
|
| `example` | `https://base.com/dir/` | `https://base.com/dir/example` | Input is joined with the base |
|
||||||
|
| `example` | `https://base.com/file` | `https://base.com/example` | Input is joined with the base without its file |
|
||||||
|
| `example` | `//base.com/dir/` | `//base.com/dir/example` | Input is joined with the base's last directory |
|
||||||
|
| `example` | `//base.com/file` | `//base.com/example` | Input is joined with the base without its file |
|
||||||
|
| `example` | `/base/dir/` | `/base/dir/example` | Input is joined with the base's last directory |
|
||||||
|
| `example` | `/base/file` | `/base/example` | Input is joined with the base without its file |
|
||||||
|
| `example` | `base/dir/` | `base/dir/example` | Input is joined with the base's last directory |
|
||||||
|
| `example` | `base/file` | `base/example` | Input is joined with the base without its file |
|
|
@ -0,0 +1,232 @@
|
||||||
|
// Matches the scheme of a URL, eg "http://"
|
||||||
|
const schemeRegex = /^[\w+.-]+:\/\//;
|
||||||
|
/**
|
||||||
|
* Matches the parts of a URL:
|
||||||
|
* 1. Scheme, including ":", guaranteed.
|
||||||
|
* 2. User/password, including "@", optional.
|
||||||
|
* 3. Host, guaranteed.
|
||||||
|
* 4. Port, including ":", optional.
|
||||||
|
* 5. Path, including "/", optional.
|
||||||
|
* 6. Query, including "?", optional.
|
||||||
|
* 7. Hash, including "#", optional.
|
||||||
|
*/
|
||||||
|
const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
|
||||||
|
/**
|
||||||
|
* File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start
|
||||||
|
* with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).
|
||||||
|
*
|
||||||
|
* 1. Host, optional.
|
||||||
|
* 2. Path, which may include "/", guaranteed.
|
||||||
|
* 3. Query, including "?", optional.
|
||||||
|
* 4. Hash, including "#", optional.
|
||||||
|
*/
|
||||||
|
const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
|
||||||
|
function isAbsoluteUrl(input) {
|
||||||
|
return schemeRegex.test(input);
|
||||||
|
}
|
||||||
|
function isSchemeRelativeUrl(input) {
|
||||||
|
return input.startsWith('//');
|
||||||
|
}
|
||||||
|
function isAbsolutePath(input) {
|
||||||
|
return input.startsWith('/');
|
||||||
|
}
|
||||||
|
function isFileUrl(input) {
|
||||||
|
return input.startsWith('file:');
|
||||||
|
}
|
||||||
|
function isRelative(input) {
|
||||||
|
return /^[.?#]/.test(input);
|
||||||
|
}
|
||||||
|
function parseAbsoluteUrl(input) {
|
||||||
|
const match = urlRegex.exec(input);
|
||||||
|
return makeUrl(match[1], match[2] || '', match[3], match[4] || '', match[5] || '/', match[6] || '', match[7] || '');
|
||||||
|
}
|
||||||
|
function parseFileUrl(input) {
|
||||||
|
const match = fileRegex.exec(input);
|
||||||
|
const path = match[2];
|
||||||
|
return makeUrl('file:', '', match[1] || '', '', isAbsolutePath(path) ? path : '/' + path, match[3] || '', match[4] || '');
|
||||||
|
}
|
||||||
|
function makeUrl(scheme, user, host, port, path, query, hash) {
|
||||||
|
return {
|
||||||
|
scheme,
|
||||||
|
user,
|
||||||
|
host,
|
||||||
|
port,
|
||||||
|
path,
|
||||||
|
query,
|
||||||
|
hash,
|
||||||
|
type: 7 /* Absolute */,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function parseUrl(input) {
|
||||||
|
if (isSchemeRelativeUrl(input)) {
|
||||||
|
const url = parseAbsoluteUrl('http:' + input);
|
||||||
|
url.scheme = '';
|
||||||
|
url.type = 6 /* SchemeRelative */;
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
if (isAbsolutePath(input)) {
|
||||||
|
const url = parseAbsoluteUrl('http://foo.com' + input);
|
||||||
|
url.scheme = '';
|
||||||
|
url.host = '';
|
||||||
|
url.type = 5 /* AbsolutePath */;
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
if (isFileUrl(input))
|
||||||
|
return parseFileUrl(input);
|
||||||
|
if (isAbsoluteUrl(input))
|
||||||
|
return parseAbsoluteUrl(input);
|
||||||
|
const url = parseAbsoluteUrl('http://foo.com/' + input);
|
||||||
|
url.scheme = '';
|
||||||
|
url.host = '';
|
||||||
|
url.type = input
|
||||||
|
? input.startsWith('?')
|
||||||
|
? 3 /* Query */
|
||||||
|
: input.startsWith('#')
|
||||||
|
? 2 /* Hash */
|
||||||
|
: 4 /* RelativePath */
|
||||||
|
: 1 /* Empty */;
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
function stripPathFilename(path) {
|
||||||
|
// If a path ends with a parent directory "..", then it's a relative path with excess parent
|
||||||
|
// paths. It's not a file, so we can't strip it.
|
||||||
|
if (path.endsWith('/..'))
|
||||||
|
return path;
|
||||||
|
const index = path.lastIndexOf('/');
|
||||||
|
return path.slice(0, index + 1);
|
||||||
|
}
|
||||||
|
function mergePaths(url, base) {
|
||||||
|
normalizePath(base, base.type);
|
||||||
|
// If the path is just a "/", then it was an empty path to begin with (remember, we're a relative
|
||||||
|
// path).
|
||||||
|
if (url.path === '/') {
|
||||||
|
url.path = base.path;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Resolution happens relative to the base path's directory, not the file.
|
||||||
|
url.path = stripPathFilename(base.path) + url.path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The path can have empty directories "//", unneeded parents "foo/..", or current directory
|
||||||
|
* "foo/.". We need to normalize to a standard representation.
|
||||||
|
*/
|
||||||
|
function normalizePath(url, type) {
|
||||||
|
const rel = type <= 4 /* RelativePath */;
|
||||||
|
const pieces = url.path.split('/');
|
||||||
|
// We need to preserve the first piece always, so that we output a leading slash. The item at
|
||||||
|
// pieces[0] is an empty string.
|
||||||
|
let pointer = 1;
|
||||||
|
// Positive is the number of real directories we've output, used for popping a parent directory.
|
||||||
|
// Eg, "foo/bar/.." will have a positive 2, and we can decrement to be left with just "foo".
|
||||||
|
let positive = 0;
|
||||||
|
// We need to keep a trailing slash if we encounter an empty directory (eg, splitting "foo/" will
|
||||||
|
// generate `["foo", ""]` pieces). And, if we pop a parent directory. But once we encounter a
|
||||||
|
// real directory, we won't need to append, unless the other conditions happen again.
|
||||||
|
let addTrailingSlash = false;
|
||||||
|
for (let i = 1; i < pieces.length; i++) {
|
||||||
|
const piece = pieces[i];
|
||||||
|
// An empty directory, could be a trailing slash, or just a double "//" in the path.
|
||||||
|
if (!piece) {
|
||||||
|
addTrailingSlash = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// If we encounter a real directory, then we don't need to append anymore.
|
||||||
|
addTrailingSlash = false;
|
||||||
|
// A current directory, which we can always drop.
|
||||||
|
if (piece === '.')
|
||||||
|
continue;
|
||||||
|
// A parent directory, we need to see if there are any real directories we can pop. Else, we
|
||||||
|
// have an excess of parents, and we'll need to keep the "..".
|
||||||
|
if (piece === '..') {
|
||||||
|
if (positive) {
|
||||||
|
addTrailingSlash = true;
|
||||||
|
positive--;
|
||||||
|
pointer--;
|
||||||
|
}
|
||||||
|
else if (rel) {
|
||||||
|
// If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute
|
||||||
|
// URL, protocol relative URL, or an absolute path, we don't need to keep excess.
|
||||||
|
pieces[pointer++] = piece;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// We've encountered a real directory. Move it to the next insertion pointer, which accounts for
|
||||||
|
// any popped or dropped directories.
|
||||||
|
pieces[pointer++] = piece;
|
||||||
|
positive++;
|
||||||
|
}
|
||||||
|
let path = '';
|
||||||
|
for (let i = 1; i < pointer; i++) {
|
||||||
|
path += '/' + pieces[i];
|
||||||
|
}
|
||||||
|
if (!path || (addTrailingSlash && !path.endsWith('/..'))) {
|
||||||
|
path += '/';
|
||||||
|
}
|
||||||
|
url.path = path;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Attempts to resolve `input` URL/path relative to `base`.
|
||||||
|
*/
|
||||||
|
function resolve(input, base) {
|
||||||
|
if (!input && !base)
|
||||||
|
return '';
|
||||||
|
const url = parseUrl(input);
|
||||||
|
let inputType = url.type;
|
||||||
|
if (base && inputType !== 7 /* Absolute */) {
|
||||||
|
const baseUrl = parseUrl(base);
|
||||||
|
const baseType = baseUrl.type;
|
||||||
|
switch (inputType) {
|
||||||
|
case 1 /* Empty */:
|
||||||
|
url.hash = baseUrl.hash;
|
||||||
|
// fall through
|
||||||
|
case 2 /* Hash */:
|
||||||
|
url.query = baseUrl.query;
|
||||||
|
// fall through
|
||||||
|
case 3 /* Query */:
|
||||||
|
case 4 /* RelativePath */:
|
||||||
|
mergePaths(url, baseUrl);
|
||||||
|
// fall through
|
||||||
|
case 5 /* AbsolutePath */:
|
||||||
|
// The host, user, and port are joined, you can't copy one without the others.
|
||||||
|
url.user = baseUrl.user;
|
||||||
|
url.host = baseUrl.host;
|
||||||
|
url.port = baseUrl.port;
|
||||||
|
// fall through
|
||||||
|
case 6 /* SchemeRelative */:
|
||||||
|
// The input doesn't have a schema at least, so we need to copy at least that over.
|
||||||
|
url.scheme = baseUrl.scheme;
|
||||||
|
}
|
||||||
|
if (baseType > inputType)
|
||||||
|
inputType = baseType;
|
||||||
|
}
|
||||||
|
normalizePath(url, inputType);
|
||||||
|
const queryHash = url.query + url.hash;
|
||||||
|
switch (inputType) {
|
||||||
|
// This is impossible, because of the empty checks at the start of the function.
|
||||||
|
// case UrlType.Empty:
|
||||||
|
case 2 /* Hash */:
|
||||||
|
case 3 /* Query */:
|
||||||
|
return queryHash;
|
||||||
|
case 4 /* RelativePath */: {
|
||||||
|
// The first char is always a "/", and we need it to be relative.
|
||||||
|
const path = url.path.slice(1);
|
||||||
|
if (!path)
|
||||||
|
return queryHash || '.';
|
||||||
|
if (isRelative(base || input) && !isRelative(path)) {
|
||||||
|
// If base started with a leading ".", or there is no base and input started with a ".",
|
||||||
|
// then we need to ensure that the relative path starts with a ".". We don't know if
|
||||||
|
// relative starts with a "..", though, so check before prepending.
|
||||||
|
return './' + path + queryHash;
|
||||||
|
}
|
||||||
|
return path + queryHash;
|
||||||
|
}
|
||||||
|
case 5 /* AbsolutePath */:
|
||||||
|
return url.path + queryHash;
|
||||||
|
default:
|
||||||
|
return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { resolve as default };
|
||||||
|
//# sourceMappingURL=resolve-uri.mjs.map
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,240 @@
|
||||||
|
(function (global, factory) {
|
||||||
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||||
|
typeof define === 'function' && define.amd ? define(factory) :
|
||||||
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.resolveURI = factory());
|
||||||
|
})(this, (function () { 'use strict';
|
||||||
|
|
||||||
|
// Matches the scheme of a URL, eg "http://"
|
||||||
|
const schemeRegex = /^[\w+.-]+:\/\//;
|
||||||
|
/**
|
||||||
|
* Matches the parts of a URL:
|
||||||
|
* 1. Scheme, including ":", guaranteed.
|
||||||
|
* 2. User/password, including "@", optional.
|
||||||
|
* 3. Host, guaranteed.
|
||||||
|
* 4. Port, including ":", optional.
|
||||||
|
* 5. Path, including "/", optional.
|
||||||
|
* 6. Query, including "?", optional.
|
||||||
|
* 7. Hash, including "#", optional.
|
||||||
|
*/
|
||||||
|
const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
|
||||||
|
/**
|
||||||
|
* File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start
|
||||||
|
* with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).
|
||||||
|
*
|
||||||
|
* 1. Host, optional.
|
||||||
|
* 2. Path, which may include "/", guaranteed.
|
||||||
|
* 3. Query, including "?", optional.
|
||||||
|
* 4. Hash, including "#", optional.
|
||||||
|
*/
|
||||||
|
const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
|
||||||
|
function isAbsoluteUrl(input) {
|
||||||
|
return schemeRegex.test(input);
|
||||||
|
}
|
||||||
|
function isSchemeRelativeUrl(input) {
|
||||||
|
return input.startsWith('//');
|
||||||
|
}
|
||||||
|
function isAbsolutePath(input) {
|
||||||
|
return input.startsWith('/');
|
||||||
|
}
|
||||||
|
function isFileUrl(input) {
|
||||||
|
return input.startsWith('file:');
|
||||||
|
}
|
||||||
|
function isRelative(input) {
|
||||||
|
return /^[.?#]/.test(input);
|
||||||
|
}
|
||||||
|
function parseAbsoluteUrl(input) {
|
||||||
|
const match = urlRegex.exec(input);
|
||||||
|
return makeUrl(match[1], match[2] || '', match[3], match[4] || '', match[5] || '/', match[6] || '', match[7] || '');
|
||||||
|
}
|
||||||
|
function parseFileUrl(input) {
|
||||||
|
const match = fileRegex.exec(input);
|
||||||
|
const path = match[2];
|
||||||
|
return makeUrl('file:', '', match[1] || '', '', isAbsolutePath(path) ? path : '/' + path, match[3] || '', match[4] || '');
|
||||||
|
}
|
||||||
|
function makeUrl(scheme, user, host, port, path, query, hash) {
|
||||||
|
return {
|
||||||
|
scheme,
|
||||||
|
user,
|
||||||
|
host,
|
||||||
|
port,
|
||||||
|
path,
|
||||||
|
query,
|
||||||
|
hash,
|
||||||
|
type: 7 /* Absolute */,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function parseUrl(input) {
|
||||||
|
if (isSchemeRelativeUrl(input)) {
|
||||||
|
const url = parseAbsoluteUrl('http:' + input);
|
||||||
|
url.scheme = '';
|
||||||
|
url.type = 6 /* SchemeRelative */;
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
if (isAbsolutePath(input)) {
|
||||||
|
const url = parseAbsoluteUrl('http://foo.com' + input);
|
||||||
|
url.scheme = '';
|
||||||
|
url.host = '';
|
||||||
|
url.type = 5 /* AbsolutePath */;
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
if (isFileUrl(input))
|
||||||
|
return parseFileUrl(input);
|
||||||
|
if (isAbsoluteUrl(input))
|
||||||
|
return parseAbsoluteUrl(input);
|
||||||
|
const url = parseAbsoluteUrl('http://foo.com/' + input);
|
||||||
|
url.scheme = '';
|
||||||
|
url.host = '';
|
||||||
|
url.type = input
|
||||||
|
? input.startsWith('?')
|
||||||
|
? 3 /* Query */
|
||||||
|
: input.startsWith('#')
|
||||||
|
? 2 /* Hash */
|
||||||
|
: 4 /* RelativePath */
|
||||||
|
: 1 /* Empty */;
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
function stripPathFilename(path) {
|
||||||
|
// If a path ends with a parent directory "..", then it's a relative path with excess parent
|
||||||
|
// paths. It's not a file, so we can't strip it.
|
||||||
|
if (path.endsWith('/..'))
|
||||||
|
return path;
|
||||||
|
const index = path.lastIndexOf('/');
|
||||||
|
return path.slice(0, index + 1);
|
||||||
|
}
|
||||||
|
function mergePaths(url, base) {
|
||||||
|
normalizePath(base, base.type);
|
||||||
|
// If the path is just a "/", then it was an empty path to begin with (remember, we're a relative
|
||||||
|
// path).
|
||||||
|
if (url.path === '/') {
|
||||||
|
url.path = base.path;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Resolution happens relative to the base path's directory, not the file.
|
||||||
|
url.path = stripPathFilename(base.path) + url.path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The path can have empty directories "//", unneeded parents "foo/..", or current directory
|
||||||
|
* "foo/.". We need to normalize to a standard representation.
|
||||||
|
*/
|
||||||
|
function normalizePath(url, type) {
|
||||||
|
const rel = type <= 4 /* RelativePath */;
|
||||||
|
const pieces = url.path.split('/');
|
||||||
|
// We need to preserve the first piece always, so that we output a leading slash. The item at
|
||||||
|
// pieces[0] is an empty string.
|
||||||
|
let pointer = 1;
|
||||||
|
// Positive is the number of real directories we've output, used for popping a parent directory.
|
||||||
|
// Eg, "foo/bar/.." will have a positive 2, and we can decrement to be left with just "foo".
|
||||||
|
let positive = 0;
|
||||||
|
// We need to keep a trailing slash if we encounter an empty directory (eg, splitting "foo/" will
|
||||||
|
// generate `["foo", ""]` pieces). And, if we pop a parent directory. But once we encounter a
|
||||||
|
// real directory, we won't need to append, unless the other conditions happen again.
|
||||||
|
let addTrailingSlash = false;
|
||||||
|
for (let i = 1; i < pieces.length; i++) {
|
||||||
|
const piece = pieces[i];
|
||||||
|
// An empty directory, could be a trailing slash, or just a double "//" in the path.
|
||||||
|
if (!piece) {
|
||||||
|
addTrailingSlash = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// If we encounter a real directory, then we don't need to append anymore.
|
||||||
|
addTrailingSlash = false;
|
||||||
|
// A current directory, which we can always drop.
|
||||||
|
if (piece === '.')
|
||||||
|
continue;
|
||||||
|
// A parent directory, we need to see if there are any real directories we can pop. Else, we
|
||||||
|
// have an excess of parents, and we'll need to keep the "..".
|
||||||
|
if (piece === '..') {
|
||||||
|
if (positive) {
|
||||||
|
addTrailingSlash = true;
|
||||||
|
positive--;
|
||||||
|
pointer--;
|
||||||
|
}
|
||||||
|
else if (rel) {
|
||||||
|
// If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute
|
||||||
|
// URL, protocol relative URL, or an absolute path, we don't need to keep excess.
|
||||||
|
pieces[pointer++] = piece;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// We've encountered a real directory. Move it to the next insertion pointer, which accounts for
|
||||||
|
// any popped or dropped directories.
|
||||||
|
pieces[pointer++] = piece;
|
||||||
|
positive++;
|
||||||
|
}
|
||||||
|
let path = '';
|
||||||
|
for (let i = 1; i < pointer; i++) {
|
||||||
|
path += '/' + pieces[i];
|
||||||
|
}
|
||||||
|
if (!path || (addTrailingSlash && !path.endsWith('/..'))) {
|
||||||
|
path += '/';
|
||||||
|
}
|
||||||
|
url.path = path;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Attempts to resolve `input` URL/path relative to `base`.
|
||||||
|
*/
|
||||||
|
function resolve(input, base) {
|
||||||
|
if (!input && !base)
|
||||||
|
return '';
|
||||||
|
const url = parseUrl(input);
|
||||||
|
let inputType = url.type;
|
||||||
|
if (base && inputType !== 7 /* Absolute */) {
|
||||||
|
const baseUrl = parseUrl(base);
|
||||||
|
const baseType = baseUrl.type;
|
||||||
|
switch (inputType) {
|
||||||
|
case 1 /* Empty */:
|
||||||
|
url.hash = baseUrl.hash;
|
||||||
|
// fall through
|
||||||
|
case 2 /* Hash */:
|
||||||
|
url.query = baseUrl.query;
|
||||||
|
// fall through
|
||||||
|
case 3 /* Query */:
|
||||||
|
case 4 /* RelativePath */:
|
||||||
|
mergePaths(url, baseUrl);
|
||||||
|
// fall through
|
||||||
|
case 5 /* AbsolutePath */:
|
||||||
|
// The host, user, and port are joined, you can't copy one without the others.
|
||||||
|
url.user = baseUrl.user;
|
||||||
|
url.host = baseUrl.host;
|
||||||
|
url.port = baseUrl.port;
|
||||||
|
// fall through
|
||||||
|
case 6 /* SchemeRelative */:
|
||||||
|
// The input doesn't have a schema at least, so we need to copy at least that over.
|
||||||
|
url.scheme = baseUrl.scheme;
|
||||||
|
}
|
||||||
|
if (baseType > inputType)
|
||||||
|
inputType = baseType;
|
||||||
|
}
|
||||||
|
normalizePath(url, inputType);
|
||||||
|
const queryHash = url.query + url.hash;
|
||||||
|
switch (inputType) {
|
||||||
|
// This is impossible, because of the empty checks at the start of the function.
|
||||||
|
// case UrlType.Empty:
|
||||||
|
case 2 /* Hash */:
|
||||||
|
case 3 /* Query */:
|
||||||
|
return queryHash;
|
||||||
|
case 4 /* RelativePath */: {
|
||||||
|
// The first char is always a "/", and we need it to be relative.
|
||||||
|
const path = url.path.slice(1);
|
||||||
|
if (!path)
|
||||||
|
return queryHash || '.';
|
||||||
|
if (isRelative(base || input) && !isRelative(path)) {
|
||||||
|
// If base started with a leading ".", or there is no base and input started with a ".",
|
||||||
|
// then we need to ensure that the relative path starts with a ".". We don't know if
|
||||||
|
// relative starts with a "..", though, so check before prepending.
|
||||||
|
return './' + path + queryHash;
|
||||||
|
}
|
||||||
|
return path + queryHash;
|
||||||
|
}
|
||||||
|
case 5 /* AbsolutePath */:
|
||||||
|
return url.path + queryHash;
|
||||||
|
default:
|
||||||
|
return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return resolve;
|
||||||
|
|
||||||
|
}));
|
||||||
|
//# sourceMappingURL=resolve-uri.umd.js.map
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,4 @@
|
||||||
|
/**
|
||||||
|
* Attempts to resolve `input` URL/path relative to `base`.
|
||||||
|
*/
|
||||||
|
export default function resolve(input: string, base: string | undefined): string;
|
|
@ -0,0 +1,69 @@
|
||||||
|
{
|
||||||
|
"name": "@jridgewell/resolve-uri",
|
||||||
|
"version": "3.1.2",
|
||||||
|
"description": "Resolve a URI relative to an optional base URI",
|
||||||
|
"keywords": [
|
||||||
|
"resolve",
|
||||||
|
"uri",
|
||||||
|
"url",
|
||||||
|
"path"
|
||||||
|
],
|
||||||
|
"author": "Justin Ridgewell <justin@ridgewell.name>",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "https://github.com/jridgewell/resolve-uri",
|
||||||
|
"main": "dist/resolve-uri.umd.js",
|
||||||
|
"module": "dist/resolve-uri.mjs",
|
||||||
|
"types": "dist/types/resolve-uri.d.ts",
|
||||||
|
"exports": {
|
||||||
|
".": [
|
||||||
|
{
|
||||||
|
"types": "./dist/types/resolve-uri.d.ts",
|
||||||
|
"browser": "./dist/resolve-uri.umd.js",
|
||||||
|
"require": "./dist/resolve-uri.umd.js",
|
||||||
|
"import": "./dist/resolve-uri.mjs"
|
||||||
|
},
|
||||||
|
"./dist/resolve-uri.umd.js"
|
||||||
|
],
|
||||||
|
"./package.json": "./package.json"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"prebuild": "rm -rf dist",
|
||||||
|
"build": "run-s -n build:*",
|
||||||
|
"build:rollup": "rollup -c rollup.config.js",
|
||||||
|
"build:ts": "tsc --project tsconfig.build.json",
|
||||||
|
"lint": "run-s -n lint:*",
|
||||||
|
"lint:prettier": "npm run test:lint:prettier -- --write",
|
||||||
|
"lint:ts": "npm run test:lint:ts -- --fix",
|
||||||
|
"pretest": "run-s build:rollup",
|
||||||
|
"test": "run-s -n test:lint test:only",
|
||||||
|
"test:debug": "mocha --inspect-brk",
|
||||||
|
"test:lint": "run-s -n test:lint:*",
|
||||||
|
"test:lint:prettier": "prettier --check '{src,test}/**/*.ts'",
|
||||||
|
"test:lint:ts": "eslint '{src,test}/**/*.ts'",
|
||||||
|
"test:only": "mocha",
|
||||||
|
"test:coverage": "c8 mocha",
|
||||||
|
"test:watch": "mocha --watch",
|
||||||
|
"prepublishOnly": "npm run preversion",
|
||||||
|
"preversion": "run-s test build"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@jridgewell/resolve-uri-latest": "npm:@jridgewell/resolve-uri@*",
|
||||||
|
"@rollup/plugin-typescript": "8.3.0",
|
||||||
|
"@typescript-eslint/eslint-plugin": "5.10.0",
|
||||||
|
"@typescript-eslint/parser": "5.10.0",
|
||||||
|
"c8": "7.11.0",
|
||||||
|
"eslint": "8.7.0",
|
||||||
|
"eslint-config-prettier": "8.3.0",
|
||||||
|
"mocha": "9.2.0",
|
||||||
|
"npm-run-all": "4.1.5",
|
||||||
|
"prettier": "2.5.1",
|
||||||
|
"rollup": "2.66.0",
|
||||||
|
"typescript": "4.5.5"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
Copyright 2024 Justin Ridgewell <justin@ridgewell.name>
|
||||||
|
|
||||||
|
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.
|
|
@ -0,0 +1,264 @@
|
||||||
|
# @jridgewell/sourcemap-codec
|
||||||
|
|
||||||
|
Encode/decode the `mappings` property of a [sourcemap](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit).
|
||||||
|
|
||||||
|
|
||||||
|
## Why?
|
||||||
|
|
||||||
|
Sourcemaps are difficult to generate and manipulate, because the `mappings` property – the part that actually links the generated code back to the original source – is encoded using an obscure method called [Variable-length quantity](https://en.wikipedia.org/wiki/Variable-length_quantity). On top of that, each segment in the mapping contains offsets rather than absolute indices, which means that you can't look at a segment in isolation – you have to understand the whole sourcemap.
|
||||||
|
|
||||||
|
This package makes the process slightly easier.
|
||||||
|
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install @jridgewell/sourcemap-codec
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { encode, decode } from '@jridgewell/sourcemap-codec';
|
||||||
|
|
||||||
|
var decoded = decode( ';EAEEA,EAAE,EAAC,CAAE;ECQY,UACC' );
|
||||||
|
|
||||||
|
assert.deepEqual( decoded, [
|
||||||
|
// the first line (of the generated code) has no mappings,
|
||||||
|
// as shown by the starting semi-colon (which separates lines)
|
||||||
|
[],
|
||||||
|
|
||||||
|
// the second line contains four (comma-separated) segments
|
||||||
|
[
|
||||||
|
// segments are encoded as you'd expect:
|
||||||
|
// [ generatedCodeColumn, sourceIndex, sourceCodeLine, sourceCodeColumn, nameIndex ]
|
||||||
|
|
||||||
|
// i.e. the first segment begins at column 2, and maps back to the second column
|
||||||
|
// of the second line (both zero-based) of the 0th source, and uses the 0th
|
||||||
|
// name in the `map.names` array
|
||||||
|
[ 2, 0, 2, 2, 0 ],
|
||||||
|
|
||||||
|
// the remaining segments are 4-length rather than 5-length,
|
||||||
|
// because they don't map a name
|
||||||
|
[ 4, 0, 2, 4 ],
|
||||||
|
[ 6, 0, 2, 5 ],
|
||||||
|
[ 7, 0, 2, 7 ]
|
||||||
|
],
|
||||||
|
|
||||||
|
// the final line contains two segments
|
||||||
|
[
|
||||||
|
[ 2, 1, 10, 19 ],
|
||||||
|
[ 12, 1, 11, 20 ]
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
var encoded = encode( decoded );
|
||||||
|
assert.equal( encoded, ';EAEEA,EAAE,EAAC,CAAE;ECQY,UACC' );
|
||||||
|
```
|
||||||
|
|
||||||
|
## Benchmarks
|
||||||
|
|
||||||
|
```
|
||||||
|
node v20.10.0
|
||||||
|
|
||||||
|
amp.js.map - 45120 segments
|
||||||
|
|
||||||
|
Decode Memory Usage:
|
||||||
|
local code 5815135 bytes
|
||||||
|
@jridgewell/sourcemap-codec 1.4.15 5868160 bytes
|
||||||
|
sourcemap-codec 5492584 bytes
|
||||||
|
source-map-0.6.1 13569984 bytes
|
||||||
|
source-map-0.8.0 6390584 bytes
|
||||||
|
chrome dev tools 8011136 bytes
|
||||||
|
Smallest memory usage is sourcemap-codec
|
||||||
|
|
||||||
|
Decode speed:
|
||||||
|
decode: local code x 492 ops/sec ±1.22% (90 runs sampled)
|
||||||
|
decode: @jridgewell/sourcemap-codec 1.4.15 x 499 ops/sec ±1.16% (89 runs sampled)
|
||||||
|
decode: sourcemap-codec x 376 ops/sec ±1.66% (89 runs sampled)
|
||||||
|
decode: source-map-0.6.1 x 34.99 ops/sec ±0.94% (48 runs sampled)
|
||||||
|
decode: source-map-0.8.0 x 351 ops/sec ±0.07% (95 runs sampled)
|
||||||
|
chrome dev tools x 165 ops/sec ±0.91% (86 runs sampled)
|
||||||
|
Fastest is decode: @jridgewell/sourcemap-codec 1.4.15
|
||||||
|
|
||||||
|
Encode Memory Usage:
|
||||||
|
local code 444248 bytes
|
||||||
|
@jridgewell/sourcemap-codec 1.4.15 623024 bytes
|
||||||
|
sourcemap-codec 8696280 bytes
|
||||||
|
source-map-0.6.1 8745176 bytes
|
||||||
|
source-map-0.8.0 8736624 bytes
|
||||||
|
Smallest memory usage is local code
|
||||||
|
|
||||||
|
Encode speed:
|
||||||
|
encode: local code x 796 ops/sec ±0.11% (97 runs sampled)
|
||||||
|
encode: @jridgewell/sourcemap-codec 1.4.15 x 795 ops/sec ±0.25% (98 runs sampled)
|
||||||
|
encode: sourcemap-codec x 231 ops/sec ±0.83% (86 runs sampled)
|
||||||
|
encode: source-map-0.6.1 x 166 ops/sec ±0.57% (86 runs sampled)
|
||||||
|
encode: source-map-0.8.0 x 203 ops/sec ±0.45% (88 runs sampled)
|
||||||
|
Fastest is encode: local code,encode: @jridgewell/sourcemap-codec 1.4.15
|
||||||
|
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
|
||||||
|
babel.min.js.map - 347793 segments
|
||||||
|
|
||||||
|
Decode Memory Usage:
|
||||||
|
local code 35424960 bytes
|
||||||
|
@jridgewell/sourcemap-codec 1.4.15 35424696 bytes
|
||||||
|
sourcemap-codec 36033464 bytes
|
||||||
|
source-map-0.6.1 62253704 bytes
|
||||||
|
source-map-0.8.0 43843920 bytes
|
||||||
|
chrome dev tools 45111400 bytes
|
||||||
|
Smallest memory usage is @jridgewell/sourcemap-codec 1.4.15
|
||||||
|
|
||||||
|
Decode speed:
|
||||||
|
decode: local code x 38.18 ops/sec ±5.44% (52 runs sampled)
|
||||||
|
decode: @jridgewell/sourcemap-codec 1.4.15 x 38.36 ops/sec ±5.02% (52 runs sampled)
|
||||||
|
decode: sourcemap-codec x 34.05 ops/sec ±4.45% (47 runs sampled)
|
||||||
|
decode: source-map-0.6.1 x 4.31 ops/sec ±2.76% (15 runs sampled)
|
||||||
|
decode: source-map-0.8.0 x 55.60 ops/sec ±0.13% (73 runs sampled)
|
||||||
|
chrome dev tools x 16.94 ops/sec ±3.78% (46 runs sampled)
|
||||||
|
Fastest is decode: source-map-0.8.0
|
||||||
|
|
||||||
|
Encode Memory Usage:
|
||||||
|
local code 2606016 bytes
|
||||||
|
@jridgewell/sourcemap-codec 1.4.15 2626440 bytes
|
||||||
|
sourcemap-codec 21152576 bytes
|
||||||
|
source-map-0.6.1 25023928 bytes
|
||||||
|
source-map-0.8.0 25256448 bytes
|
||||||
|
Smallest memory usage is local code
|
||||||
|
|
||||||
|
Encode speed:
|
||||||
|
encode: local code x 127 ops/sec ±0.18% (83 runs sampled)
|
||||||
|
encode: @jridgewell/sourcemap-codec 1.4.15 x 128 ops/sec ±0.26% (83 runs sampled)
|
||||||
|
encode: sourcemap-codec x 29.31 ops/sec ±2.55% (53 runs sampled)
|
||||||
|
encode: source-map-0.6.1 x 18.85 ops/sec ±3.19% (36 runs sampled)
|
||||||
|
encode: source-map-0.8.0 x 19.34 ops/sec ±1.97% (36 runs sampled)
|
||||||
|
Fastest is encode: @jridgewell/sourcemap-codec 1.4.15
|
||||||
|
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
|
||||||
|
preact.js.map - 1992 segments
|
||||||
|
|
||||||
|
Decode Memory Usage:
|
||||||
|
local code 261696 bytes
|
||||||
|
@jridgewell/sourcemap-codec 1.4.15 244296 bytes
|
||||||
|
sourcemap-codec 302816 bytes
|
||||||
|
source-map-0.6.1 939176 bytes
|
||||||
|
source-map-0.8.0 336 bytes
|
||||||
|
chrome dev tools 587368 bytes
|
||||||
|
Smallest memory usage is source-map-0.8.0
|
||||||
|
|
||||||
|
Decode speed:
|
||||||
|
decode: local code x 17,782 ops/sec ±0.32% (97 runs sampled)
|
||||||
|
decode: @jridgewell/sourcemap-codec 1.4.15 x 17,863 ops/sec ±0.40% (100 runs sampled)
|
||||||
|
decode: sourcemap-codec x 12,453 ops/sec ±0.27% (101 runs sampled)
|
||||||
|
decode: source-map-0.6.1 x 1,288 ops/sec ±1.05% (96 runs sampled)
|
||||||
|
decode: source-map-0.8.0 x 9,289 ops/sec ±0.27% (101 runs sampled)
|
||||||
|
chrome dev tools x 4,769 ops/sec ±0.18% (100 runs sampled)
|
||||||
|
Fastest is decode: @jridgewell/sourcemap-codec 1.4.15
|
||||||
|
|
||||||
|
Encode Memory Usage:
|
||||||
|
local code 262944 bytes
|
||||||
|
@jridgewell/sourcemap-codec 1.4.15 25544 bytes
|
||||||
|
sourcemap-codec 323048 bytes
|
||||||
|
source-map-0.6.1 507808 bytes
|
||||||
|
source-map-0.8.0 507480 bytes
|
||||||
|
Smallest memory usage is @jridgewell/sourcemap-codec 1.4.15
|
||||||
|
|
||||||
|
Encode speed:
|
||||||
|
encode: local code x 24,207 ops/sec ±0.79% (95 runs sampled)
|
||||||
|
encode: @jridgewell/sourcemap-codec 1.4.15 x 24,288 ops/sec ±0.48% (96 runs sampled)
|
||||||
|
encode: sourcemap-codec x 6,761 ops/sec ±0.21% (100 runs sampled)
|
||||||
|
encode: source-map-0.6.1 x 5,374 ops/sec ±0.17% (99 runs sampled)
|
||||||
|
encode: source-map-0.8.0 x 5,633 ops/sec ±0.32% (99 runs sampled)
|
||||||
|
Fastest is encode: @jridgewell/sourcemap-codec 1.4.15,encode: local code
|
||||||
|
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
|
||||||
|
react.js.map - 5726 segments
|
||||||
|
|
||||||
|
Decode Memory Usage:
|
||||||
|
local code 678816 bytes
|
||||||
|
@jridgewell/sourcemap-codec 1.4.15 678816 bytes
|
||||||
|
sourcemap-codec 816400 bytes
|
||||||
|
source-map-0.6.1 2288864 bytes
|
||||||
|
source-map-0.8.0 721360 bytes
|
||||||
|
chrome dev tools 1012512 bytes
|
||||||
|
Smallest memory usage is local code
|
||||||
|
|
||||||
|
Decode speed:
|
||||||
|
decode: local code x 6,178 ops/sec ±0.19% (98 runs sampled)
|
||||||
|
decode: @jridgewell/sourcemap-codec 1.4.15 x 6,261 ops/sec ±0.22% (100 runs sampled)
|
||||||
|
decode: sourcemap-codec x 4,472 ops/sec ±0.90% (99 runs sampled)
|
||||||
|
decode: source-map-0.6.1 x 449 ops/sec ±0.31% (95 runs sampled)
|
||||||
|
decode: source-map-0.8.0 x 3,219 ops/sec ±0.13% (100 runs sampled)
|
||||||
|
chrome dev tools x 1,743 ops/sec ±0.20% (99 runs sampled)
|
||||||
|
Fastest is decode: @jridgewell/sourcemap-codec 1.4.15
|
||||||
|
|
||||||
|
Encode Memory Usage:
|
||||||
|
local code 140960 bytes
|
||||||
|
@jridgewell/sourcemap-codec 1.4.15 159808 bytes
|
||||||
|
sourcemap-codec 969304 bytes
|
||||||
|
source-map-0.6.1 930520 bytes
|
||||||
|
source-map-0.8.0 930248 bytes
|
||||||
|
Smallest memory usage is local code
|
||||||
|
|
||||||
|
Encode speed:
|
||||||
|
encode: local code x 8,013 ops/sec ±0.19% (100 runs sampled)
|
||||||
|
encode: @jridgewell/sourcemap-codec 1.4.15 x 7,989 ops/sec ±0.20% (101 runs sampled)
|
||||||
|
encode: sourcemap-codec x 2,472 ops/sec ±0.21% (99 runs sampled)
|
||||||
|
encode: source-map-0.6.1 x 2,200 ops/sec ±0.17% (99 runs sampled)
|
||||||
|
encode: source-map-0.8.0 x 2,220 ops/sec ±0.37% (99 runs sampled)
|
||||||
|
Fastest is encode: local code
|
||||||
|
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
|
||||||
|
vscode.map - 2141001 segments
|
||||||
|
|
||||||
|
Decode Memory Usage:
|
||||||
|
local code 198955264 bytes
|
||||||
|
@jridgewell/sourcemap-codec 1.4.15 199175352 bytes
|
||||||
|
sourcemap-codec 199102688 bytes
|
||||||
|
source-map-0.6.1 386323432 bytes
|
||||||
|
source-map-0.8.0 244116432 bytes
|
||||||
|
chrome dev tools 293734280 bytes
|
||||||
|
Smallest memory usage is local code
|
||||||
|
|
||||||
|
Decode speed:
|
||||||
|
decode: local code x 3.90 ops/sec ±22.21% (15 runs sampled)
|
||||||
|
decode: @jridgewell/sourcemap-codec 1.4.15 x 3.95 ops/sec ±23.53% (15 runs sampled)
|
||||||
|
decode: sourcemap-codec x 3.82 ops/sec ±17.94% (14 runs sampled)
|
||||||
|
decode: source-map-0.6.1 x 0.61 ops/sec ±7.81% (6 runs sampled)
|
||||||
|
decode: source-map-0.8.0 x 9.54 ops/sec ±0.28% (28 runs sampled)
|
||||||
|
chrome dev tools x 2.18 ops/sec ±10.58% (10 runs sampled)
|
||||||
|
Fastest is decode: source-map-0.8.0
|
||||||
|
|
||||||
|
Encode Memory Usage:
|
||||||
|
local code 13509880 bytes
|
||||||
|
@jridgewell/sourcemap-codec 1.4.15 13537648 bytes
|
||||||
|
sourcemap-codec 32540104 bytes
|
||||||
|
source-map-0.6.1 127531040 bytes
|
||||||
|
source-map-0.8.0 127535312 bytes
|
||||||
|
Smallest memory usage is local code
|
||||||
|
|
||||||
|
Encode speed:
|
||||||
|
encode: local code x 20.10 ops/sec ±0.19% (38 runs sampled)
|
||||||
|
encode: @jridgewell/sourcemap-codec 1.4.15 x 20.26 ops/sec ±0.32% (38 runs sampled)
|
||||||
|
encode: sourcemap-codec x 5.44 ops/sec ±1.64% (18 runs sampled)
|
||||||
|
encode: source-map-0.6.1 x 2.30 ops/sec ±4.79% (10 runs sampled)
|
||||||
|
encode: source-map-0.8.0 x 2.46 ops/sec ±6.53% (10 runs sampled)
|
||||||
|
Fastest is encode: @jridgewell/sourcemap-codec 1.4.15
|
||||||
|
```
|
||||||
|
|
||||||
|
# License
|
||||||
|
|
||||||
|
MIT
|
|
@ -0,0 +1,423 @@
|
||||||
|
// src/vlq.ts
|
||||||
|
var comma = ",".charCodeAt(0);
|
||||||
|
var semicolon = ";".charCodeAt(0);
|
||||||
|
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
|
var intToChar = new Uint8Array(64);
|
||||||
|
var charToInt = new Uint8Array(128);
|
||||||
|
for (let i = 0; i < chars.length; i++) {
|
||||||
|
const c = chars.charCodeAt(i);
|
||||||
|
intToChar[i] = c;
|
||||||
|
charToInt[c] = i;
|
||||||
|
}
|
||||||
|
function decodeInteger(reader, relative) {
|
||||||
|
let value = 0;
|
||||||
|
let shift = 0;
|
||||||
|
let integer = 0;
|
||||||
|
do {
|
||||||
|
const c = reader.next();
|
||||||
|
integer = charToInt[c];
|
||||||
|
value |= (integer & 31) << shift;
|
||||||
|
shift += 5;
|
||||||
|
} while (integer & 32);
|
||||||
|
const shouldNegate = value & 1;
|
||||||
|
value >>>= 1;
|
||||||
|
if (shouldNegate) {
|
||||||
|
value = -2147483648 | -value;
|
||||||
|
}
|
||||||
|
return relative + value;
|
||||||
|
}
|
||||||
|
function encodeInteger(builder, num, relative) {
|
||||||
|
let delta = num - relative;
|
||||||
|
delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
|
||||||
|
do {
|
||||||
|
let clamped = delta & 31;
|
||||||
|
delta >>>= 5;
|
||||||
|
if (delta > 0) clamped |= 32;
|
||||||
|
builder.write(intToChar[clamped]);
|
||||||
|
} while (delta > 0);
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
function hasMoreVlq(reader, max) {
|
||||||
|
if (reader.pos >= max) return false;
|
||||||
|
return reader.peek() !== comma;
|
||||||
|
}
|
||||||
|
|
||||||
|
// src/strings.ts
|
||||||
|
var bufLength = 1024 * 16;
|
||||||
|
var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
|
||||||
|
decode(buf) {
|
||||||
|
const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
||||||
|
return out.toString();
|
||||||
|
}
|
||||||
|
} : {
|
||||||
|
decode(buf) {
|
||||||
|
let out = "";
|
||||||
|
for (let i = 0; i < buf.length; i++) {
|
||||||
|
out += String.fromCharCode(buf[i]);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var StringWriter = class {
|
||||||
|
constructor() {
|
||||||
|
this.pos = 0;
|
||||||
|
this.out = "";
|
||||||
|
this.buffer = new Uint8Array(bufLength);
|
||||||
|
}
|
||||||
|
write(v) {
|
||||||
|
const { buffer } = this;
|
||||||
|
buffer[this.pos++] = v;
|
||||||
|
if (this.pos === bufLength) {
|
||||||
|
this.out += td.decode(buffer);
|
||||||
|
this.pos = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
flush() {
|
||||||
|
const { buffer, out, pos } = this;
|
||||||
|
return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var StringReader = class {
|
||||||
|
constructor(buffer) {
|
||||||
|
this.pos = 0;
|
||||||
|
this.buffer = buffer;
|
||||||
|
}
|
||||||
|
next() {
|
||||||
|
return this.buffer.charCodeAt(this.pos++);
|
||||||
|
}
|
||||||
|
peek() {
|
||||||
|
return this.buffer.charCodeAt(this.pos);
|
||||||
|
}
|
||||||
|
indexOf(char) {
|
||||||
|
const { buffer, pos } = this;
|
||||||
|
const idx = buffer.indexOf(char, pos);
|
||||||
|
return idx === -1 ? buffer.length : idx;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// src/scopes.ts
|
||||||
|
var EMPTY = [];
|
||||||
|
function decodeOriginalScopes(input) {
|
||||||
|
const { length } = input;
|
||||||
|
const reader = new StringReader(input);
|
||||||
|
const scopes = [];
|
||||||
|
const stack = [];
|
||||||
|
let line = 0;
|
||||||
|
for (; reader.pos < length; reader.pos++) {
|
||||||
|
line = decodeInteger(reader, line);
|
||||||
|
const column = decodeInteger(reader, 0);
|
||||||
|
if (!hasMoreVlq(reader, length)) {
|
||||||
|
const last = stack.pop();
|
||||||
|
last[2] = line;
|
||||||
|
last[3] = column;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const kind = decodeInteger(reader, 0);
|
||||||
|
const fields = decodeInteger(reader, 0);
|
||||||
|
const hasName = fields & 1;
|
||||||
|
const scope = hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind];
|
||||||
|
let vars = EMPTY;
|
||||||
|
if (hasMoreVlq(reader, length)) {
|
||||||
|
vars = [];
|
||||||
|
do {
|
||||||
|
const varsIndex = decodeInteger(reader, 0);
|
||||||
|
vars.push(varsIndex);
|
||||||
|
} while (hasMoreVlq(reader, length));
|
||||||
|
}
|
||||||
|
scope.vars = vars;
|
||||||
|
scopes.push(scope);
|
||||||
|
stack.push(scope);
|
||||||
|
}
|
||||||
|
return scopes;
|
||||||
|
}
|
||||||
|
function encodeOriginalScopes(scopes) {
|
||||||
|
const writer = new StringWriter();
|
||||||
|
for (let i = 0; i < scopes.length; ) {
|
||||||
|
i = _encodeOriginalScopes(scopes, i, writer, [0]);
|
||||||
|
}
|
||||||
|
return writer.flush();
|
||||||
|
}
|
||||||
|
function _encodeOriginalScopes(scopes, index, writer, state) {
|
||||||
|
const scope = scopes[index];
|
||||||
|
const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope;
|
||||||
|
if (index > 0) writer.write(comma);
|
||||||
|
state[0] = encodeInteger(writer, startLine, state[0]);
|
||||||
|
encodeInteger(writer, startColumn, 0);
|
||||||
|
encodeInteger(writer, kind, 0);
|
||||||
|
const fields = scope.length === 6 ? 1 : 0;
|
||||||
|
encodeInteger(writer, fields, 0);
|
||||||
|
if (scope.length === 6) encodeInteger(writer, scope[5], 0);
|
||||||
|
for (const v of vars) {
|
||||||
|
encodeInteger(writer, v, 0);
|
||||||
|
}
|
||||||
|
for (index++; index < scopes.length; ) {
|
||||||
|
const next = scopes[index];
|
||||||
|
const { 0: l, 1: c } = next;
|
||||||
|
if (l > endLine || l === endLine && c >= endColumn) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index = _encodeOriginalScopes(scopes, index, writer, state);
|
||||||
|
}
|
||||||
|
writer.write(comma);
|
||||||
|
state[0] = encodeInteger(writer, endLine, state[0]);
|
||||||
|
encodeInteger(writer, endColumn, 0);
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
function decodeGeneratedRanges(input) {
|
||||||
|
const { length } = input;
|
||||||
|
const reader = new StringReader(input);
|
||||||
|
const ranges = [];
|
||||||
|
const stack = [];
|
||||||
|
let genLine = 0;
|
||||||
|
let definitionSourcesIndex = 0;
|
||||||
|
let definitionScopeIndex = 0;
|
||||||
|
let callsiteSourcesIndex = 0;
|
||||||
|
let callsiteLine = 0;
|
||||||
|
let callsiteColumn = 0;
|
||||||
|
let bindingLine = 0;
|
||||||
|
let bindingColumn = 0;
|
||||||
|
do {
|
||||||
|
const semi = reader.indexOf(";");
|
||||||
|
let genColumn = 0;
|
||||||
|
for (; reader.pos < semi; reader.pos++) {
|
||||||
|
genColumn = decodeInteger(reader, genColumn);
|
||||||
|
if (!hasMoreVlq(reader, semi)) {
|
||||||
|
const last = stack.pop();
|
||||||
|
last[2] = genLine;
|
||||||
|
last[3] = genColumn;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const fields = decodeInteger(reader, 0);
|
||||||
|
const hasDefinition = fields & 1;
|
||||||
|
const hasCallsite = fields & 2;
|
||||||
|
const hasScope = fields & 4;
|
||||||
|
let callsite = null;
|
||||||
|
let bindings = EMPTY;
|
||||||
|
let range;
|
||||||
|
if (hasDefinition) {
|
||||||
|
const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex);
|
||||||
|
definitionScopeIndex = decodeInteger(
|
||||||
|
reader,
|
||||||
|
definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0
|
||||||
|
);
|
||||||
|
definitionSourcesIndex = defSourcesIndex;
|
||||||
|
range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex];
|
||||||
|
} else {
|
||||||
|
range = [genLine, genColumn, 0, 0];
|
||||||
|
}
|
||||||
|
range.isScope = !!hasScope;
|
||||||
|
if (hasCallsite) {
|
||||||
|
const prevCsi = callsiteSourcesIndex;
|
||||||
|
const prevLine = callsiteLine;
|
||||||
|
callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex);
|
||||||
|
const sameSource = prevCsi === callsiteSourcesIndex;
|
||||||
|
callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0);
|
||||||
|
callsiteColumn = decodeInteger(
|
||||||
|
reader,
|
||||||
|
sameSource && prevLine === callsiteLine ? callsiteColumn : 0
|
||||||
|
);
|
||||||
|
callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn];
|
||||||
|
}
|
||||||
|
range.callsite = callsite;
|
||||||
|
if (hasMoreVlq(reader, semi)) {
|
||||||
|
bindings = [];
|
||||||
|
do {
|
||||||
|
bindingLine = genLine;
|
||||||
|
bindingColumn = genColumn;
|
||||||
|
const expressionsCount = decodeInteger(reader, 0);
|
||||||
|
let expressionRanges;
|
||||||
|
if (expressionsCount < -1) {
|
||||||
|
expressionRanges = [[decodeInteger(reader, 0)]];
|
||||||
|
for (let i = -1; i > expressionsCount; i--) {
|
||||||
|
const prevBl = bindingLine;
|
||||||
|
bindingLine = decodeInteger(reader, bindingLine);
|
||||||
|
bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0);
|
||||||
|
const expression = decodeInteger(reader, 0);
|
||||||
|
expressionRanges.push([expression, bindingLine, bindingColumn]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
expressionRanges = [[expressionsCount]];
|
||||||
|
}
|
||||||
|
bindings.push(expressionRanges);
|
||||||
|
} while (hasMoreVlq(reader, semi));
|
||||||
|
}
|
||||||
|
range.bindings = bindings;
|
||||||
|
ranges.push(range);
|
||||||
|
stack.push(range);
|
||||||
|
}
|
||||||
|
genLine++;
|
||||||
|
reader.pos = semi + 1;
|
||||||
|
} while (reader.pos < length);
|
||||||
|
return ranges;
|
||||||
|
}
|
||||||
|
function encodeGeneratedRanges(ranges) {
|
||||||
|
if (ranges.length === 0) return "";
|
||||||
|
const writer = new StringWriter();
|
||||||
|
for (let i = 0; i < ranges.length; ) {
|
||||||
|
i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]);
|
||||||
|
}
|
||||||
|
return writer.flush();
|
||||||
|
}
|
||||||
|
function _encodeGeneratedRanges(ranges, index, writer, state) {
|
||||||
|
const range = ranges[index];
|
||||||
|
const {
|
||||||
|
0: startLine,
|
||||||
|
1: startColumn,
|
||||||
|
2: endLine,
|
||||||
|
3: endColumn,
|
||||||
|
isScope,
|
||||||
|
callsite,
|
||||||
|
bindings
|
||||||
|
} = range;
|
||||||
|
if (state[0] < startLine) {
|
||||||
|
catchupLine(writer, state[0], startLine);
|
||||||
|
state[0] = startLine;
|
||||||
|
state[1] = 0;
|
||||||
|
} else if (index > 0) {
|
||||||
|
writer.write(comma);
|
||||||
|
}
|
||||||
|
state[1] = encodeInteger(writer, range[1], state[1]);
|
||||||
|
const fields = (range.length === 6 ? 1 : 0) | (callsite ? 2 : 0) | (isScope ? 4 : 0);
|
||||||
|
encodeInteger(writer, fields, 0);
|
||||||
|
if (range.length === 6) {
|
||||||
|
const { 4: sourcesIndex, 5: scopesIndex } = range;
|
||||||
|
if (sourcesIndex !== state[2]) {
|
||||||
|
state[3] = 0;
|
||||||
|
}
|
||||||
|
state[2] = encodeInteger(writer, sourcesIndex, state[2]);
|
||||||
|
state[3] = encodeInteger(writer, scopesIndex, state[3]);
|
||||||
|
}
|
||||||
|
if (callsite) {
|
||||||
|
const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite;
|
||||||
|
if (sourcesIndex !== state[4]) {
|
||||||
|
state[5] = 0;
|
||||||
|
state[6] = 0;
|
||||||
|
} else if (callLine !== state[5]) {
|
||||||
|
state[6] = 0;
|
||||||
|
}
|
||||||
|
state[4] = encodeInteger(writer, sourcesIndex, state[4]);
|
||||||
|
state[5] = encodeInteger(writer, callLine, state[5]);
|
||||||
|
state[6] = encodeInteger(writer, callColumn, state[6]);
|
||||||
|
}
|
||||||
|
if (bindings) {
|
||||||
|
for (const binding of bindings) {
|
||||||
|
if (binding.length > 1) encodeInteger(writer, -binding.length, 0);
|
||||||
|
const expression = binding[0][0];
|
||||||
|
encodeInteger(writer, expression, 0);
|
||||||
|
let bindingStartLine = startLine;
|
||||||
|
let bindingStartColumn = startColumn;
|
||||||
|
for (let i = 1; i < binding.length; i++) {
|
||||||
|
const expRange = binding[i];
|
||||||
|
bindingStartLine = encodeInteger(writer, expRange[1], bindingStartLine);
|
||||||
|
bindingStartColumn = encodeInteger(writer, expRange[2], bindingStartColumn);
|
||||||
|
encodeInteger(writer, expRange[0], 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (index++; index < ranges.length; ) {
|
||||||
|
const next = ranges[index];
|
||||||
|
const { 0: l, 1: c } = next;
|
||||||
|
if (l > endLine || l === endLine && c >= endColumn) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index = _encodeGeneratedRanges(ranges, index, writer, state);
|
||||||
|
}
|
||||||
|
if (state[0] < endLine) {
|
||||||
|
catchupLine(writer, state[0], endLine);
|
||||||
|
state[0] = endLine;
|
||||||
|
state[1] = 0;
|
||||||
|
} else {
|
||||||
|
writer.write(comma);
|
||||||
|
}
|
||||||
|
state[1] = encodeInteger(writer, endColumn, state[1]);
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
function catchupLine(writer, lastLine, line) {
|
||||||
|
do {
|
||||||
|
writer.write(semicolon);
|
||||||
|
} while (++lastLine < line);
|
||||||
|
}
|
||||||
|
|
||||||
|
// src/sourcemap-codec.ts
|
||||||
|
function decode(mappings) {
|
||||||
|
const { length } = mappings;
|
||||||
|
const reader = new StringReader(mappings);
|
||||||
|
const decoded = [];
|
||||||
|
let genColumn = 0;
|
||||||
|
let sourcesIndex = 0;
|
||||||
|
let sourceLine = 0;
|
||||||
|
let sourceColumn = 0;
|
||||||
|
let namesIndex = 0;
|
||||||
|
do {
|
||||||
|
const semi = reader.indexOf(";");
|
||||||
|
const line = [];
|
||||||
|
let sorted = true;
|
||||||
|
let lastCol = 0;
|
||||||
|
genColumn = 0;
|
||||||
|
while (reader.pos < semi) {
|
||||||
|
let seg;
|
||||||
|
genColumn = decodeInteger(reader, genColumn);
|
||||||
|
if (genColumn < lastCol) sorted = false;
|
||||||
|
lastCol = genColumn;
|
||||||
|
if (hasMoreVlq(reader, semi)) {
|
||||||
|
sourcesIndex = decodeInteger(reader, sourcesIndex);
|
||||||
|
sourceLine = decodeInteger(reader, sourceLine);
|
||||||
|
sourceColumn = decodeInteger(reader, sourceColumn);
|
||||||
|
if (hasMoreVlq(reader, semi)) {
|
||||||
|
namesIndex = decodeInteger(reader, namesIndex);
|
||||||
|
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
|
||||||
|
} else {
|
||||||
|
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
seg = [genColumn];
|
||||||
|
}
|
||||||
|
line.push(seg);
|
||||||
|
reader.pos++;
|
||||||
|
}
|
||||||
|
if (!sorted) sort(line);
|
||||||
|
decoded.push(line);
|
||||||
|
reader.pos = semi + 1;
|
||||||
|
} while (reader.pos <= length);
|
||||||
|
return decoded;
|
||||||
|
}
|
||||||
|
function sort(line) {
|
||||||
|
line.sort(sortComparator);
|
||||||
|
}
|
||||||
|
function sortComparator(a, b) {
|
||||||
|
return a[0] - b[0];
|
||||||
|
}
|
||||||
|
function encode(decoded) {
|
||||||
|
const writer = new StringWriter();
|
||||||
|
let sourcesIndex = 0;
|
||||||
|
let sourceLine = 0;
|
||||||
|
let sourceColumn = 0;
|
||||||
|
let namesIndex = 0;
|
||||||
|
for (let i = 0; i < decoded.length; i++) {
|
||||||
|
const line = decoded[i];
|
||||||
|
if (i > 0) writer.write(semicolon);
|
||||||
|
if (line.length === 0) continue;
|
||||||
|
let genColumn = 0;
|
||||||
|
for (let j = 0; j < line.length; j++) {
|
||||||
|
const segment = line[j];
|
||||||
|
if (j > 0) writer.write(comma);
|
||||||
|
genColumn = encodeInteger(writer, segment[0], genColumn);
|
||||||
|
if (segment.length === 1) continue;
|
||||||
|
sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
|
||||||
|
sourceLine = encodeInteger(writer, segment[2], sourceLine);
|
||||||
|
sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
|
||||||
|
if (segment.length === 4) continue;
|
||||||
|
namesIndex = encodeInteger(writer, segment[4], namesIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return writer.flush();
|
||||||
|
}
|
||||||
|
export {
|
||||||
|
decode,
|
||||||
|
decodeGeneratedRanges,
|
||||||
|
decodeOriginalScopes,
|
||||||
|
encode,
|
||||||
|
encodeGeneratedRanges,
|
||||||
|
encodeOriginalScopes
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=sourcemap-codec.mjs.map
|
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue