This commit is contained in:
2026-10-22 16:06:51 +07:00
commit 25158e780f
2897 changed files with 569062 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
# CodeGraph data files — local to each machine, not for committing.
# Ignore everything in .codegraph/ except this file itself, so transient
# files (the database, daemon.pid, sockets, logs) never show up in git.
*
!.gitignore
+237
View File
@@ -0,0 +1,237 @@
# Generator PDF Label QR Code - EPPOS RP-4610B
Generator label barcode QR Code untuk printer label **EPPOS RP-4610B**.
Halaman PDF berukuran **100 x 150 mm** (portrait), **3 kolom x 6 baris**
= **18 label per halaman**. Enam baris mengisi tinggi halaman; isi tiap label
rata tengah.
Semua isi (teks + QR) digambar langsung sebagai **vektor** ke dalam PDF -
bukan hasil screenshot - sehingga tetap tajam saat dicetak pada skala 100%.
Tata letak tiap label (sesuai referensi):
```
+------------------------------+
| ONT-1910 +---------+ |
| 26-3BA3 | QR Code | |
| SN: - 12345678 +---------+ |
+------------------------------+
```
Teks barcode dua baris (`ONT-1910` lalu `26-3BA3`), SN di baris ketiga.
Teks rata kiri, QR di area kanan. Posisi QR selalu dihitung dari pusat area
barcode (bukan dari tepi kanan label), lalu dipusatkan secara vertikal.
---
## 1. Struktur proyek
```
src/
layout.js engine layout (mm -> pt, grid, fitting teks) - dipakai PDF & browser
data.js parser input (TXT/JSON + SN per barcode) - dipakai PDF & browser
svg.js QR Code -> SVG vektor - dipakai browser
qr.js matriks QR Code (paket npm "qrcode")
pdf.js generator PDF (pdfkit, custom page size)
cli.js command line interface
input.js pembaca file/stdin
template_label_qr_eppos_rp4610b_100mm_3kolom.html
aplikasi browser: preview, cetak, unduh PDF
assets/
qrcode-core.js bundel core QR Code (offline, tanpa CDN)
helvetica-metrics.js tabel lebar glif Helvetica (dari AFM pdfkit)
scripts/
generate-samples.js membuat PDF contoh (1, 10, 13, 18, 25 label)
verify-pdf.js cek ukuran halaman fisik + pindai QR hasil PDF
verify-browser-print.js cek hasil cetak dari browser (headless Chrome/Edge)
build-browser-assets.js rebuild bundel browser
data/
labels.sample.txt / labels.sample.json
labels.contoh-10.txt contoh 10 label format gabungan ONT-191026-3BA3
test/ 36 pengujian otomatis
```
## 2. Menjalankan
```bash
npm install # sekali saja
npm test # 36 pengujian otomatis
npm run sample # membuat output/labels-01, -10, -13, -18, -25.pdf
node src/cli.js -i data/labels.sample.txt -o output/labels.pdf
node src/cli.js -i data/labels.sample.txt -o output/labels-contoh-18.pdf
node src/cli.js -i data/labels.contoh-10.txt -o output/labels-contoh-10.pdf
```
### Format input
Satu baris satu barcode, SN opsional dipisah `|` (atau TAB):
```
ONT-191026-3BA3 | 12345678
ONT-191026-3D0F | 12345679
```
- Isi **QR Code tetap kode persis seperti diketik** (SN tidak ikut dikodekan),
sama seperti implementasi aplikasi awal.
- Kode gabungan tanpa spasi otomatis ditampilkan dua baris:
`ONT-191026-3BA3` -> `ONT-1910` / `26-3BA3`.
- Format lama dengan spasi juga tetap didukung dan dipecah pada **spasi
terakhir** -> `ONT-0910` / `26-5BD9`.
- Baris tanpa SN tetap dicetak `SN: -`; dengan SN -> `SN: - 12345678`.
- Format JSON juga didukung:
```json
[ { "code": "ONT-191026-3BA3", "sn": "12345678" } ]
```
JSON dengan kode dan kode unik terpisah tetap diterima:
`{ "code": "ONT-1910", "unique": "26-3BA3", "sn": "12345678" }`.
### Opsi CLI
| Opsi | Arti | Bawaan |
|---|---|---|
| `-i, --input <file>` | file data, `-` = stdin | wajib |
| `-o, --out <file>` | file PDF | `output/labels.pdf` |
| `--page-w`, `--page-h` | ukuran halaman (mm) | 100, 150 |
| `--cols` | jumlah kolom | 3 |
| `--rows` | jumlah baris per halaman | 6 (otomatis bila `--label-h` dipakai) |
| `--strip` | 1 baris label per halaman (roll, tinggi label 18 mm) | - |
| `--label-h <mm>` | tinggi satu label dipatok, baris dihitung otomatis | 0 (isi tinggi halaman) |
| `--fill` | baris membagi rata tinggi halaman (abaikan tinggi label) | - |
| `--margin` | margin halaman (mm) | 2.5 kiri/kanan, 2.5 atas/bawah |
| `--gap` | jarak horizontal antar label (mm) | 4.5 |
| `--gap-y` | jarak vertikal antar baris (mm) | 5 |
| `--right-gap` | ruang putih di kanan tiap sel label (mm) | 0 |
| `--padding` | jarak teks/QR dari tepi sel (mm) | 1.0 |
| `--qr <mm>` | ukuran QR | 13.5 |
| `--ec <L\|M\|Q\|H>` | koreksi kesalahan QR | M |
| `--guides` | garis bantu kotak label | - |
| `--json` | ringkasan keluaran JSON | - |
### Format 2 baris (roll)
```
node src/cli.js -i data/labels.sample.txt -o output/strip.pdf --rows 2 --page-h 43.6 --fill
```
Menghasilkan halaman 100 x 43,6 mm berisi 3 kolom x 2 baris label (6 label/halaman).
Untuk mencetak roll label terus-menerus (1 baris per halaman):
```
node src/cli.js -i data/labels.sample.txt -o output/roll.pdf --strip
```
## 3. Aplikasi browser
Buka `template_label_qr_eppos_rp4610b_100mm_3kolom.html` (double click, `file://`
sudah cukup; tidak perlu server).
- **Buat / Perbarui Label** - preview label di layar, posisi dihitung memakai
engine layout yang sama dengan PDF.
- **Pratinjau PDF** - PDF dibuat lalu **ditampilkan di dalam halaman** (viewer
bawaan browser), **tidak langsung diunduh**. Setelah dicek, tekan
*Unduh PDF* di dalam pratinjau. Modal bisa ditutup dengan tombol *Tutup*
atau tombol `Esc`.
- **Hapus** - mengosongkan daftar.
- **Sembunyikan keterangan** - menyembunyikan/menampilkan seluruh panel
panduan. Tiap bagian (Format input, Pratinjau PDF, Pengaturan cetak,
Catatan) juga bisa dibuka/tutup lewat judulnya.
> `assets/` dan `src/*.js` harus tetap berada di folder yang sama dengan file
> HTML. Kalau `assets/` hilang, jalankan `npm run build:assets`.
> Pratinjau PDF memakai jsPDF (CDN, butuh internet); untuk PDF presisi tanpa
> internet, pakai CLI Node.
### Deploy ke Vercel
Repo ini adalah aplikasi statis; Vercel hanya perlu menyajikan UI browser.
Konfigurasi `vercel.json` menjalankan `build:static`, lalu memublikasikan
folder `dist/` dengan `index.html` sebagai halaman utama.
```bash
npm install
npm run build:static
npx vercel login
npx vercel # preview
npx vercel --prod # production
```
Alternatif: hubungkan repo ke Vercel lewat dashboard. Vercel membaca
`vercel.json`; tidak perlu mengatur build command secara manual.
Yang tidak bisa berjalan di Vercel static: `node src/cli.js` untuk membuat PDF
ke filesystem lokal. Untuk pembuatan PDF di server, perlu Vercel Function
terpisah yang mengembalikan PDF sebagai response.
## 4. Pengaturan cetak (Chrome Print Preview)
| Setelan | Nilai |
|---|---|
| Destination | Label Printer |
| Paper size | 100 x 150 mm (Custom) |
| Pages | All |
| Color mode | Black and White |
| Scale | **100% / Actual size** (jangan "Fit to page") |
| Margins | None |
| Header/Footer | matikan |
Ukuran halaman PDF sudah dikunci di dalam file (MediaBox 283.4646 x 425.1969 pt),
jadi hasil tidak bergantung pada zoom browser, ukuran monitor, atau DPI layar.
Yang tersisa adalah kalibrasi driver printer (media dan tinggi label) - bagian
itu sepenuhnya di sisi driver/perangkat.
## 5. Rumus satuan
```
1 mm = 72 / 25.4 point
100 mm = 283.4646 pt
150 mm = 425.1969 pt
```
Semua koordinat, ukuran font, jarak, dan ukuran QR dihitung dalam milimeter,
lalu dikonversi ke point saat menulis PDF. Ukuran halaman PDF di-*custom*
langsung, bukan A4 yang dikecilkan.
## 6. Pengujian
```bash
npm test
```
36 pengujian otomatis, antara lain:
- ukuran halaman PDF tepat 100 x 150 mm pada semua halaman (dibaca dari MediaBox)
- 18 label = tepat 1 halaman penuh (3 kolom x 6 baris)
- jumlah halaman otomatis: 19 label -> 2 halaman, 25 label -> 2 halaman, 30 -> 2
- format 2 baris (100 x 43,6 mm, 6 label/halaman)
- isi tiap label rata tengah; 6 baris mengisi tinggi halaman
- QR tepat di pusat area barcode pada seluruh label, termasuk halaman kedua;
offset hasil render diverifikasi maksimal 0,5 mm
- kode gabungan `ONT-191026-3BA3` tampil dua baris tanpa mengubah payload QR
- semua kotak label di dalam halaman dan tidak saling tumpang tindih
- teks tidak pernah keluar area (font mengecil otomatis, teks panjang dipecah baris)
- **QR hasil PDF dipindai ulang** (render 300 dpi + 203 dpi lalu decode dengan jsQR)
dan payload-nya dibandingkan dengan data sumber
- teks hasil PDF dibandingkan dengan data sumber
- tepi halaman bebas tinta (tidak ada elemen terpotong)
Verifikasi manual:
```bash
node scripts/verify-pdf.js output/labels-18.pdf 300
node scripts/verify-browser-preview.js # menguji alur pratinjau PDF di browser
node scripts/verify-browser-print.js # menguji jalur cetak browser
```
## 7. Catatan
- Jumlah label tidak dibatasi 10; layout berlanjut ke halaman berikutnya.
- Jumlah baris bawaan 6 (18 label per halaman); tinggi baris otomatis mengisi
halaman. Gunakan `--label-h` bila ingin tinggi label dipatok.
- Lebar halaman 100 mm sudah sama dengan media roll printer; tetap cetak
**100% / Actual size** dan matikan *Fit to page*.
- QR Code memakai koreksi kesalahan **M**, quiet zone 2 modul di dalam kotak QR,
ditambah padding sel label sebagai ruang putih tambahan.
- Pemisahan modul QR memakai overlap 0.006 mm supaya tidak muncul garis putih
di antara modul saat dicetak.
+21
View File
@@ -0,0 +1,21 @@
/* Metrik lebar glif Helvetica & Helvetica-Bold (dari AFM PDFKit) - untuk pengukuran teks di browser. */
(function (root) {
"use strict";
var REGULAR = {32:278,33:278,34:355,35:556,36:556,37:889,38:667,39:222,40:333,41:333,42:389,43:584,44:278,45:333,46:278,47:278,48:556,49:556,50:556,51:556,52:556,53:556,54:556,55:556,56:556,57:556,58:278,59:278,60:584,61:584,62:584,63:556,64:1015,65:667,66:667,67:722,68:722,69:667,70:611,71:778,72:722,73:278,74:500,75:667,76:556,77:833,78:722,79:778,80:667,81:778,82:722,83:667,84:611,85:722,86:667,87:944,88:667,89:667,90:611,91:278,92:278,93:278,94:469,95:556,96:222,97:556,98:556,99:500,100:556,101:556,102:278,103:556,104:556,105:222,106:222,107:500,108:222,109:833,110:556,111:556,112:556,113:556,114:333,115:500,116:278,117:556,118:500,119:722,120:500,121:500,122:500,123:334,124:260,125:334,126:584};
var BOLD = {32:278,33:333,34:474,35:556,36:556,37:889,38:722,39:278,40:333,41:333,42:389,43:584,44:278,45:333,46:278,47:278,48:556,49:556,50:556,51:556,52:556,53:556,54:556,55:556,56:556,57:556,58:333,59:333,60:584,61:584,62:584,63:611,64:975,65:722,66:722,67:722,68:722,69:667,70:611,71:778,72:722,73:278,74:556,75:722,76:611,77:833,78:722,79:778,80:667,81:778,82:722,83:667,84:611,85:722,86:667,87:944,88:667,89:667,90:611,91:333,92:278,93:333,94:584,95:556,96:278,97:556,98:611,99:556,100:611,101:556,102:333,103:611,104:611,105:278,106:278,107:556,108:278,109:889,110:611,111:611,112:611,113:611,114:389,115:556,116:333,117:611,118:556,119:778,120:556,121:556,122:500,123:389,124:280,125:389,126:584};
var FALLBACK = 556;
function widthOf(code, weight) {
var table = weight === "bold" ? BOLD : REGULAR;
var value = table[code];
return value === undefined ? FALLBACK : value;
}
function measure(text, sizeMm, weight) {
var str = String(text === undefined || text === null ? "" : text);
var total = 0;
for (var i = 0; i < str.length; i++) {
total += widthOf(str.charCodeAt(i), weight);
}
return total / 1000 * sizeMm;
}
root.HelveticaMetrics = { measure: measure, widthOf: widthOf, CAP_HEIGHT: 0.717 };
})(typeof self !== "undefined" ? self : this);
File diff suppressed because it is too large Load Diff
+10
View File
@@ -0,0 +1,10 @@
ONT-191026-3BA3 | 12345678
ONT-191026-3D0F | 12345679
ONT-191026-1118 | 12345680
ONT-191026-4472 | 12345681
ONT-191026-90AB | 12345682
ONT-191026-C3D1 | 12345683
ONT-191026-77E5 | 12345684
ONT-191026-2F09 | 12345685
ONT-191026-6B44 | 12345686
ONT-191026-08D7 | 12345687
+20
View File
@@ -0,0 +1,20 @@
[
{ "code": "ONT-191026-3BA3", "sn": "12345678" },
{ "code": "ONT-191026-3D0F", "sn": "12345679" },
{ "code": "ONT-191026-1118", "sn": "12345680" },
{ "code": "ONT-191026-4472", "sn": "12345681" },
{ "code": "ONT-191026-90AB", "sn": "12345682" },
{ "code": "ONT-191026-C3D1", "sn": "12345683" },
{ "code": "ONT-191026-77E5", "sn": "12345684" },
{ "code": "ONT-191026-2F09", "sn": "12345685" },
{ "code": "ONT-191026-6B44", "sn": "12345686" },
{ "code": "ONT-191026-08D7", "sn": "12345687" },
{ "code": "ONT-191026-E5A2", "sn": "12345688" },
{ "code": "ONT-191026-31BC", "sn": "12345689" },
{ "code": "ONT-191026-9F03", "sn": "12345690" },
{ "code": "ONT-191026-4D68", "sn": "12345691" },
{ "code": "ONT-191026-7A21", "sn": "12345692" },
{ "code": "ONT-191026-B6C0", "sn": "12345693" },
{ "code": "ONT-191026-52E8", "sn": "12345694" },
{ "code": "ONT-191026-9D34", "sn": "12345695" }
]
+18
View File
@@ -0,0 +1,18 @@
ONT-191026-3BA3 | 12345678
ONT-191026-3D0F | 12345679
ONT-191026-1118 | 12345680
ONT-191026-4472 | 12345681
ONT-191026-90AB | 12345682
ONT-191026-C3D1 | 12345683
ONT-191026-77E5 | 12345684
ONT-191026-2F09 | 12345685
ONT-191026-6B44 | 12345686
ONT-191026-08D7 | 12345687
ONT-191026-E5A2 | 12345688
ONT-191026-31BC | 12345689
ONT-191026-9F03 | 12345690
ONT-191026-4D68 | 12345691
ONT-191026-7A21 | 12345692
ONT-191026-B6C0 | 12345693
ONT-191026-52E8 | 12345694
ONT-191026-9D34 | 12345695
+21
View File
@@ -0,0 +1,21 @@
/* Metrik lebar glif Helvetica & Helvetica-Bold (dari AFM PDFKit) - untuk pengukuran teks di browser. */
(function (root) {
"use strict";
var REGULAR = {32:278,33:278,34:355,35:556,36:556,37:889,38:667,39:222,40:333,41:333,42:389,43:584,44:278,45:333,46:278,47:278,48:556,49:556,50:556,51:556,52:556,53:556,54:556,55:556,56:556,57:556,58:278,59:278,60:584,61:584,62:584,63:556,64:1015,65:667,66:667,67:722,68:722,69:667,70:611,71:778,72:722,73:278,74:500,75:667,76:556,77:833,78:722,79:778,80:667,81:778,82:722,83:667,84:611,85:722,86:667,87:944,88:667,89:667,90:611,91:278,92:278,93:278,94:469,95:556,96:222,97:556,98:556,99:500,100:556,101:556,102:278,103:556,104:556,105:222,106:222,107:500,108:222,109:833,110:556,111:556,112:556,113:556,114:333,115:500,116:278,117:556,118:500,119:722,120:500,121:500,122:500,123:334,124:260,125:334,126:584};
var BOLD = {32:278,33:333,34:474,35:556,36:556,37:889,38:722,39:278,40:333,41:333,42:389,43:584,44:278,45:333,46:278,47:278,48:556,49:556,50:556,51:556,52:556,53:556,54:556,55:556,56:556,57:556,58:333,59:333,60:584,61:584,62:584,63:611,64:975,65:722,66:722,67:722,68:722,69:667,70:611,71:778,72:722,73:278,74:556,75:722,76:611,77:833,78:722,79:778,80:667,81:778,82:722,83:667,84:611,85:722,86:667,87:944,88:667,89:667,90:611,91:333,92:278,93:333,94:584,95:556,96:278,97:556,98:611,99:556,100:611,101:556,102:333,103:611,104:611,105:278,106:278,107:556,108:278,109:889,110:611,111:611,112:611,113:611,114:389,115:556,116:333,117:611,118:556,119:778,120:556,121:556,122:500,123:389,124:280,125:389,126:584};
var FALLBACK = 556;
function widthOf(code, weight) {
var table = weight === "bold" ? BOLD : REGULAR;
var value = table[code];
return value === undefined ? FALLBACK : value;
}
function measure(text, sizeMm, weight) {
var str = String(text === undefined || text === null ? "" : text);
var total = 0;
for (var i = 0; i < str.length; i++) {
total += widthOf(str.charCodeAt(i), weight);
}
return total / 1000 * sizeMm;
}
root.HelveticaMetrics = { measure: measure, widthOf: widthOf, CAP_HEIGHT: 0.717 };
})(typeof self !== "undefined" ? self : this);
+1820
View File
File diff suppressed because it is too large Load Diff
+630
View File
@@ -0,0 +1,630 @@
<!doctype html>
<html lang="id">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Label QR 3 Kolom 100 x 150 mm - EPPOS RP-4610B</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<style>
:root{
--orange:#F05A22;
--orange-deep:#C8420F;
--orange-soft:#FFF0E7;
--orange-line:#F4C6AF;
--white:#FFFFFF;
--wash:#FFF9F5;
--ink:#1A1613;
--muted:#71645B;
--line:#E9DFD7;
--display:"Bahnschrift SemiCondensed","Bahnschrift","Arial Narrow",Arial,sans-serif;
--body:"Segoe UI",Arial,Helvetica,sans-serif;
--mono:Consolas,"Courier New",monospace;
}
*{box-sizing:border-box}
html{background:var(--white)}
body{margin:0;min-height:100vh;background:var(--white);color:var(--ink);font-family:var(--body);-webkit-font-smoothing:antialiased}
button,textarea{font:inherit}
button{cursor:pointer}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
/* ---------- Top bar ---------- */
.topbar{position:sticky;top:0;z-index:20;display:flex;align-items:center;justify-content:space-between;gap:24px;padding:16px clamp(18px,3vw,44px);border-bottom:1px solid var(--line);background:rgba(255,255,255,.94);backdrop-filter:blur(12px)}
.brand{display:flex;align-items:center;gap:12px;color:inherit;text-decoration:none}
.brand-mark{display:block;width:38px;height:38px;flex:0 0 auto;border-radius:9px;box-shadow:0 5px 14px rgba(240,90,34,.22)}
.brand-copy{display:flex;flex-direction:column;line-height:1.05}
.brand-copy strong{font-family:var(--display);font-size:22px;letter-spacing:.035em;text-transform:uppercase}
.brand-copy small{margin-top:4px;color:var(--muted);font-family:var(--mono);font-size:9px;letter-spacing:.14em;text-transform:uppercase}
.topbar-meta{display:flex;align-items:center;gap:12px;color:var(--muted);font-family:var(--mono);font-size:10px;letter-spacing:.08em;text-transform:uppercase;white-space:nowrap}
.topbar-meta .live{display:inline-flex;align-items:center;gap:8px;color:var(--ink)}
.live::before{content:"";width:7px;height:7px;border-radius:50%;background:var(--orange);box-shadow:0 0 0 4px var(--orange-soft)}
.topbar-divider{width:1px;height:15px;background:var(--line)}
/* ---------- Workbench ---------- */
.workspace{display:grid;grid-template-columns:minmax(340px,420px) minmax(0,1fr);grid-template-areas:"intro preview" "editor preview" "guide preview";align-items:start;column-gap:clamp(24px,3vw,48px);row-gap:26px;width:100%;max-width:1500px;margin:0 auto;padding:clamp(22px,3vw,44px)}
.intro{grid-area:intro;min-width:0}
.editor{grid-area:editor;min-width:0}
.guide{grid-area:guide;min-width:0}
.preview-panel{grid-area:preview}
.intro,.editor,.guide{animation:rise .5s cubic-bezier(.2,.8,.2,1) both}
.intro .eyebrow{margin:0 0 13px}
.eyebrow{display:flex;align-items:center;gap:9px;margin:0;color:var(--orange-deep);font-family:var(--mono);font-size:10px;font-weight:700;line-height:1.4;letter-spacing:.14em;text-transform:uppercase}
.eyebrow::before{content:"";width:24px;height:2px;background:var(--orange);flex:0 0 auto}
h1{margin:0;font-family:var(--display);font-size:clamp(48px,5vw,76px);font-weight:700;line-height:.88;letter-spacing:-.01em;text-transform:uppercase}
h1 span{color:var(--orange);white-space:nowrap}
.lede{max-width:38ch;margin:20px 0 0;color:var(--muted);font-size:14px;line-height:1.65}
.spec-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));margin-top:28px;border-top:1px solid var(--line);border-bottom:1px solid var(--line)}
.spec{min-width:0;padding:14px 12px 15px;border-right:1px solid var(--line)}
.spec:first-child{padding-left:0}
.spec:last-child{border-right:0}
.spec span{display:block;margin-bottom:7px;color:var(--muted);font-family:var(--mono);font-size:9px;letter-spacing:.12em;text-transform:uppercase}
.spec strong{display:block;font-family:var(--display);font-size:30px;font-weight:700;line-height:.9;letter-spacing:.01em}
.spec small{display:block;margin-top:5px;color:var(--muted);font-size:10px;line-height:1.3}
/* ---------- Editor ---------- */
.editor{padding:18px;border:1px solid var(--line);border-radius:16px;background:var(--white);box-shadow:0 12px 32px rgba(70,38,18,.06)}
.panel-head{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;margin-bottom:13px}
.panel-head > div{display:flex;align-items:baseline;gap:10px;min-width:0}
.panel-head h2{margin:0;font-family:var(--display);font-size:24px;font-weight:700;line-height:1;letter-spacing:.02em;text-transform:uppercase}
.step{color:var(--orange-deep);font-family:var(--mono);font-size:10px;font-weight:700;letter-spacing:.08em}
.micro{color:var(--muted);font-family:var(--mono);font-size:9px;line-height:1.45;letter-spacing:.07em;text-align:right;text-transform:uppercase}
textarea{display:block;width:100%;height:260px;resize:vertical;border:1px solid var(--line);border-radius:10px;background:var(--wash);color:var(--ink);padding:13px 14px;font-family:var(--mono);font-size:12px;line-height:1.65;outline:none;caret-color:var(--orange);transition:border-color .18s,box-shadow .18s,background .18s}
textarea:hover{border-color:#D8C7BA}
textarea:focus{border-color:var(--orange);background:var(--white);box-shadow:0 0 0 4px var(--orange-soft)}
.actions{display:flex;flex-wrap:wrap;gap:9px;margin-top:13px}
.btn{border:1px solid transparent;border-radius:9px;padding:11px 15px;font-size:12px;font-weight:700;line-height:1.1;transition:transform .16s,background .16s,border-color .16s,box-shadow .16s}
.btn:hover{transform:translateY(-1px)}
.btn:active{transform:translateY(0)}
.btn:focus-visible,.btn-text:focus-visible,summary:focus-visible{outline:3px solid rgba(240,90,34,.34);outline-offset:2px}
.btn-primary{background:var(--orange-deep);color:var(--white);box-shadow:0 2px 0 #8F2F08}
.btn-primary:hover{background:#B43809}
.btn-secondary{border-color:var(--orange-line);background:var(--white);color:var(--orange-deep)}
.btn-secondary:hover{border-color:var(--orange);background:var(--orange-soft)}
.btn-ghost{border-color:transparent;background:transparent;color:var(--muted)}
.btn-ghost:hover{background:var(--wash);color:var(--ink)}
#status{display:flex;align-items:flex-start;gap:8px;min-height:18px;margin-top:12px;color:var(--muted);font-family:var(--mono);font-size:10px;line-height:1.5}
#status::before{content:"";width:6px;height:6px;flex:0 0 auto;margin-top:4px;border-radius:50%;background:var(--orange)}
#status:empty{display:none}
#status.error{color:#A42B00;font-weight:700}
#status.error::before{background:#A42B00}
/* ---------- Guide ---------- */
.guide{padding-top:18px;border-top:1px solid var(--line)}
.guide .panel-head{align-items:center;margin-bottom:0}
.btn-text{border:0;background:none;padding:5px 0;color:var(--orange-deep);font-family:var(--mono);font-size:10px;font-weight:700;letter-spacing:.06em;text-transform:uppercase}
.btn-text:hover{text-decoration:underline}
#help{margin-top:12px}
#help[hidden]{display:none}
details.hint{margin:0 0 8px;border:1px solid var(--line);border-radius:10px;background:var(--white);color:var(--muted);font-size:12px;line-height:1.6;overflow:hidden}
details.hint summary{position:relative;list-style:none;cursor:pointer;padding:11px 34px 11px 13px;color:var(--ink);font-family:var(--display);font-size:17px;font-weight:700;line-height:1.15;letter-spacing:.02em;text-transform:uppercase}
details.hint summary::-webkit-details-marker{display:none}
details.hint summary::after{content:"+";position:absolute;right:13px;top:50%;transform:translateY(-50%);color:var(--orange-deep);font-family:var(--mono);font-size:16px;line-height:1}
details.hint[open] summary{border-bottom:1px solid var(--line)}
details.hint[open] summary::after{content:"−"}
details.hint > div{padding:12px 13px 13px}
details.hint code{padding:1px 5px;border-radius:4px;background:var(--orange-soft);color:var(--orange-deep);font-family:var(--mono);font-size:.92em;word-break:break-word}
details.hint b{color:var(--ink)}
/* ---------- Preview stage ---------- */
.preview-panel{min-width:0;display:flex;flex-direction:column;gap:14px;animation:rise .55s .06s cubic-bezier(.2,.8,.2,1) both}
.preview-head{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;padding:0 4px}
.preview-head .eyebrow{margin-bottom:7px}
.preview-head h2{margin:0;font-family:var(--display);font-size:32px;font-weight:700;line-height:.95;letter-spacing:.01em;text-transform:uppercase}
.preview-tags{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:6px}
.tag{padding:6px 9px;border:1px solid var(--line);border-radius:999px;background:var(--white);color:var(--muted);font-family:var(--mono);font-size:9px;letter-spacing:.08em;text-transform:uppercase;white-space:nowrap}
.tag-strong{border-color:var(--orange-deep);background:var(--orange-deep);color:var(--white)}
.stage{position:relative;display:flex;flex:1 1 auto;min-height:620px;padding:clamp(22px,4vw,54px);border-radius:18px;background-color:var(--orange);background-image:linear-gradient(rgba(255,255,255,.15) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.15) 1px,transparent 1px);background-size:10mm 10mm;box-shadow:inset 0 0 0 1px rgba(255,255,255,.18),0 20px 45px rgba(92,36,9,.16);overflow:auto;isolation:isolate}
.stage::before{content:"";position:absolute;inset:14px;border:1px dashed rgba(255,255,255,.42);border-radius:10px;pointer-events:none}
#preview{position:relative;z-index:1;display:flex;flex-direction:column;align-items:center;gap:10mm;width:100%;min-width:max-content;margin:auto 0}
.page{position:relative;width:100mm;height:150mm;background:#fff;box-shadow:0 16px 38px rgba(74,28,8,.26);overflow:hidden}
.label{position:absolute}
.qr{position:absolute;line-height:0}
.qr svg{display:block;width:100%;height:100%}
.tx{position:absolute;white-space:nowrap;line-height:1;font-family:Helvetica,Arial,sans-serif;transform:translateY(-0.13em)}
.tx.bold{font-weight:700}
.stage-note{display:flex;align-items:flex-start;gap:8px;margin:0 4px;color:var(--muted);font-size:11px;line-height:1.5}
.note-dot{width:6px;height:6px;flex:0 0 auto;margin-top:5px;border-radius:50%;background:var(--orange)}
/* ---------- PDF modal ---------- */
.modal{position:fixed;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(26,22,19,.58);backdrop-filter:blur(8px)}
.modal[hidden]{display:none}
.modal-box{display:flex;flex-direction:column;width:min(96vw,900px);height:min(92vh,920px);overflow:hidden;border-radius:16px;background:var(--white);box-shadow:0 28px 80px rgba(0,0,0,.35)}
.modal-head{display:flex;align-items:center;gap:10px;flex:0 0 auto;padding:12px 14px;background:var(--orange-deep);color:var(--white);font-size:12px}
.modal-head b{font-family:var(--display);font-size:20px;letter-spacing:.03em;text-transform:uppercase}
.modal-head #pdf-info{color:rgba(255,255,255,.95);font-family:var(--mono);font-size:10px;letter-spacing:.04em}
.modal-head .spacer{flex:1 1 auto}
.modal-head button{padding:8px 12px;border:1px solid rgba(255,255,255,.68);border-radius:7px;background:transparent;color:var(--white);font-size:11px;font-weight:700}
.modal-head button:hover{background:var(--white);color:var(--orange-deep)}
.modal-head button:focus-visible{outline:3px solid var(--white);outline-offset:2px}
.modal-head #btn-download{border-color:var(--white);background:var(--white);color:var(--orange-deep)}
.modal-head #btn-download:hover{background:var(--orange-soft)}
#pdf-frame{flex:1 1 auto;width:100%;border:0;background:var(--wash)}
@keyframes rise{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}
@media (max-width:1040px){
.workspace{grid-template-columns:minmax(300px,360px) minmax(0,1fr);column-gap:24px;row-gap:24px;padding:26px}
h1{font-size:56px}
.stage{min-height:560px;padding:30px}
}
@media (max-width:820px){
.workspace{grid-template-columns:minmax(0,1fr);grid-template-areas:"intro" "editor" "preview" "guide";max-width:760px;column-gap:0;row-gap:28px;padding:24px}
.stage{min-height:0}
}
@media (min-width:821px) and (min-height:900px){
.preview-panel.is-single{position:sticky;top:87px}
}
@media (max-width:560px){
.topbar{padding:14px 16px}
.brand-mark{width:34px;height:34px}
.brand-copy strong{font-size:20px}
.topbar-meta{gap:8px;font-size:9px}
.topbar-meta .live,.topbar-divider{display:none}
.workspace{padding:20px 14px 30px;gap:24px}
h1{font-size:48px}
.lede{font-size:13px}
.spec{padding:12px 8px 13px}
.spec strong{font-size:26px}
.spec small{font-size:9px}
.editor{padding:14px;border-radius:12px}
textarea{height:220px}
.actions .btn{flex:1 1 calc(50% - 5px)}
.actions .btn-ghost{flex-basis:100%}
.preview-head{flex-direction:column;align-items:flex-start}
.preview-tags{justify-content:flex-start}
.preview-head h2{font-size:28px}
.stage{padding:16px;border-radius:14px;background-size:8mm 8mm}
#preview{gap:8mm;zoom:.82}
.modal-head{flex-wrap:wrap}
.modal-head .spacer{display:none}
}
@media (prefers-reduced-motion:reduce){
*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important;scroll-behavior:auto!important}
}
@page{size:100mm 150mm;margin:0}
@media print{
html,body{margin:0;padding:0;background:#fff}
.topbar,.intro,.editor,.guide,.preview-head,.stage-note,.modal{display:none!important}
.workspace{display:block;max-width:none;margin:0;padding:0}
.preview-panel{display:block;padding:0}
.stage{min-height:0;margin:0;padding:0;border-radius:0;background:#fff;box-shadow:none;overflow:visible}
.stage::before{display:none}
#preview{display:block;width:auto;min-width:0;margin:0;padding:0;gap:0;zoom:1}
.page{margin:0;box-shadow:none;page-break-after:always;break-after:page}
.page:last-child{page-break-after:auto;break-after:auto}
}
</style>
</head>
<body>
<header class="topbar">
<div class="brand">
<svg class="brand-mark" viewBox="0 0 40 40" aria-hidden="true" focusable="false">
<rect width="40" height="40" rx="9" fill="#F05A22"/>
<rect x="8" y="8" width="10" height="10" rx="1" fill="#FFFFFF"/>
<rect x="10" y="10" width="6" height="6" fill="#F05A22"/>
<rect x="22" y="8" width="10" height="10" rx="1" fill="#FFFFFF"/>
<rect x="24" y="10" width="6" height="6" fill="#F05A22"/>
<rect x="8" y="22" width="10" height="10" rx="1" fill="#FFFFFF"/>
<rect x="10" y="24" width="6" height="6" fill="#F05A22"/>
<rect x="22" y="22" width="4" height="4" fill="#FFFFFF"/>
<rect x="28" y="22" width="4" height="4" fill="#FFFFFF"/>
<rect x="22" y="28" width="4" height="4" fill="#FFFFFF"/>
<rect x="28" y="28" width="4" height="4" fill="#FFFFFF"/>
</svg>
<span class="brand-copy">
<strong>Label QR</strong>
<small>EPPOS RP-4610B</small>
</span>
</div>
<div class="topbar-meta">
<span class="live">Vektor</span>
<span>203 dpi</span>
<span class="topbar-divider" aria-hidden="true"></span>
<span>100 × 150 mm</span>
</div>
</header>
<main class="workspace">
<section class="intro" aria-label="Ringkasan label">
<p class="eyebrow">Produksi label / EPPOS RP-4610B</p>
<h1>Label QR<br><span>siap tempel.</span></h1>
<p class="lede">Masukkan kode, periksa halaman, lalu cetak 100%. Teks dan QR rata tengah di setiap label.</p>
<div class="spec-grid" aria-label="Spesifikasi label">
<div class="spec">
<span>Per halaman</span>
<strong>18</strong>
<small>label</small>
</div>
<div class="spec">
<span>Grid</span>
<strong>3 × 6</strong>
<small>kolom × baris</small>
</div>
<div class="spec">
<span>Media</span>
<strong>100 × 150</strong>
<small>milimeter</small>
</div>
</div>
</section>
<section class="editor" aria-label="Data label">
<div class="panel-head">
<div>
<span class="step">01</span>
<h2>Data label</h2>
</div>
<span class="micro">Satu baris<br>satu QR</span>
</div>
<label class="sr-only" for="codes">Data label</label>
<textarea id="codes" spellcheck="false">ONT-191026-3BA3 | 12345678
ONT-191026-3D0F | 12345679
ONT-191026-1118 | 12345680
ONT-191026-4472 | 12345681
ONT-191026-90AB | 12345682
ONT-191026-C3D1 | 12345683
ONT-191026-77E5 | 12345684
ONT-191026-2F09 | 12345685
ONT-191026-6B44 | 12345686
ONT-191026-08D7 | 12345687
ONT-191026-E5A2 | 12345688
ONT-191026-31BC | 12345689
ONT-191026-9F03 | 12345690
ONT-191026-4D68 | 12345691
ONT-191026-7A21 | 12345692
ONT-191026-B6C0 | 12345693
ONT-191026-52E8 | 12345694
ONT-191026-9D34 | 12345695</textarea>
<div class="actions">
<button class="btn btn-primary" id="btn-build" type="button">Buat label</button>
<button class="btn btn-secondary" id="btn-pdf" type="button">Pratinjau PDF</button>
<button class="btn btn-ghost" id="btn-clear" type="button">Kosongkan</button>
</div>
<div id="status" role="status" aria-live="polite"></div>
</section>
<section class="guide" aria-label="Panduan">
<div class="panel-head">
<div>
<span class="step">INFO</span>
<h2>Panduan</h2>
</div>
<button class="btn-text" id="btn-help" type="button" aria-expanded="true" aria-controls="help" aria-label="Sembunyikan keterangan">Sembunyikan</button>
</div>
<div id="help">
<details class="hint" open>
<summary>Format input</summary>
<div>
<code>KODE | SN</code> atau <code>KODE KODE-UNIK | SN</code> — SN opsional.
Contoh: <code>ONT-191026-3BA3 | 12345678</code> tampil dua baris
<code>ONT-1910</code> / <code>26-3BA3</code>. QR tetap memakai kode lengkap
seperti yang diketik; SN tidak ikut dikodekan.
</div>
</details>
<details class="hint" open>
<summary>Pratinjau PDF</summary>
<div>
Tombol <i>Pratinjau PDF</i> menampilkan file 100 × 150 mm, 3 kolom × 6 baris
(<b>18 label per halaman</b>) di dalam halaman ini. Periksa dulu, lalu tekan
<i>Unduh PDF</i> di dalam pratinjau.
</div>
</details>
<details class="hint" open>
<summary>Pengaturan cetak</summary>
<div>
Di Chrome Print Preview: Destination <i>Label Printer</i> · Paper size
<i>100 × 150 mm</i> (Custom) · Pages <i>All</i> · Color mode
<i>Black and White</i> · Scale <i>100% / Actual Size</i> (jangan “Fit to page”) ·
matikan Header/Footer · margin <i>None</i>. Ukuran halaman sudah dikunci di PDF.
</div>
</details>
<details class="hint" open>
<summary>Catatan</summary>
<div>
PDF presisi tanpa browser: <code>node src/cli.js -i data/labels.sample.txt -o output/labels.pdf</code>.<br><br>
Kalibrasi driver printer (lebar media 100 mm, tinggi label) tetap memengaruhi hasil fisik.
</div>
</details>
</div>
</section>
<section class="preview-panel" id="preview-panel" aria-label="Pratinjau halaman">
<div class="preview-head">
<div>
<p class="eyebrow">02 / Pratinjau</p>
<h2>Halaman cetak</h2>
</div>
<div class="preview-tags">
<span class="tag tag-strong">18 / halaman</span>
<span class="tag">100 × 150 mm</span>
</div>
</div>
<div class="stage">
<div id="preview"></div>
</div>
<p class="stage-note">
<span class="note-dot" aria-hidden="true"></span>
<span>Area putih adalah halaman cetak 100 × 150 mm. Gunakan skala 100% / Actual Size saat mencetak.</span>
</p>
</section>
</main>
<div id="pdf-modal" class="modal" hidden>
<div class="modal-box" role="dialog" aria-modal="true" aria-labelledby="pdf-title">
<div class="modal-head">
<b id="pdf-title">Cetak Label Barcode</b>
<span id="pdf-info"></span>
<span class="spacer"></span>
<button id="btn-download" type="button">Unduh PDF</button>
<button id="btn-close" type="button">Tutup</button>
</div>
<iframe id="pdf-frame" title="Pratinjau PDF"></iframe>
</div>
</div>
<script src="src/data.js"></script>
<script src="src/layout.js"></script>
<script src="src/svg.js"></script>
<script src="assets/helvetica-metrics.js"></script>
<script src="assets/qrcode-core.js"></script>
<script>
(function () {
'use strict';
var CONFIG = LabelLayout.mergeConfig({
pageWidthMm: 100,
pageHeightMm: 150,
columns: 3,
rows: 6,
labelHeightMm: 0,
marginXMm: 2.5,
marginYMm: 2.5,
gapXMm: 4.5,
gapYMm: 5,
paddingMm: 1.0,
innerGapMm: 1.0,
rightGapMm: 0,
qrSizeMm: 13.5,
quietZoneModules: 2,
errorCorrectionLevel: 'M',
mainFontMm: 2.5,
uniqueFontMm: 2.3,
snFontMm: 1.7,
lineHeightRatio: 1.3,
verticalAlign: 'center'
});
var items = [];
function measure(text, sizeMm, weight) {
return HelveticaMetrics.measure(text, sizeMm, weight);
}
function buildMatrix(payload) {
var qr = QRCodeCore.create(payload, { errorCorrectionLevel: CONFIG.errorCorrectionLevel });
return {
size: qr.modules.size,
get: function (row, col) { return qr.modules.get(row, col); }
};
}
function setStatus(message, isError) {
var el = document.getElementById('status');
el.textContent = message || '';
el.className = isError ? 'error' : '';
}
function build() {
var raw = document.getElementById('codes').value;
try {
items = LabelData.parseText(raw);
} catch (err) {
items = [];
setStatus('Input tidak valid: ' + err.message, true);
return;
}
render();
var layout = LabelLayout.create(CONFIG);
var pages = Math.ceil(items.length / layout.perPage);
setStatus(items.length + ' label siap cetak (' + (pages || 0) + ' halaman, ' + layout.perPage + ' label per halaman).');
}
function render() {
var layout = LabelLayout.create(CONFIG);
var preview = document.getElementById('preview');
preview.innerHTML = '';
var perPage = layout.perPage;
var pageCount = Math.max(1, Math.ceil(items.length / perPage));
var panel = document.getElementById('preview-panel');
if (panel) { panel.classList.toggle('is-single', pageCount === 1); }
for (var p = 0; p < pageCount; p++) {
var page = document.createElement('div');
page.className = 'page';
var start = p * perPage;
var end = Math.min(items.length, start + perPage);
for (var i = start; i < end; i++) {
page.appendChild(renderLabel(layout, items[i], i));
}
preview.appendChild(page);
}
}
function renderLabel(layout, item, index) {
var box = layout.labelBox(index);
var boxes = layout.contentBoxes(index);
var label = document.createElement('div');
label.className = 'label';
label.style.left = box.xMm + 'mm';
label.style.top = box.yMm + 'mm';
label.style.width = box.widthMm + 'mm';
label.style.height = box.heightMm + 'mm';
var qr = document.createElement('div');
qr.className = 'qr';
qr.style.left = (boxes.qrBox.xMm - box.xMm) + 'mm';
qr.style.top = (boxes.qrBox.yMm - box.yMm) + 'mm';
qr.style.width = boxes.qrBox.widthMm + 'mm';
qr.style.height = boxes.qrBox.heightMm + 'mm';
qr.innerHTML = LabelSvg.matrixToSvg(buildMatrix(item.payload), {
quietZone: CONFIG.quietZoneModules,
sizeMm: boxes.qrBox.widthMm
});
label.appendChild(qr);
var text = LabelLayout.composeText(item, boxes.textBox, CONFIG, measure);
text.blocks.forEach(function (block) {
var div = document.createElement('div');
div.className = 'tx' + (block.weight === 'bold' ? ' bold' : '');
div.style.left = (block.xMm - box.xMm) + 'mm';
div.style.top = (block.yMm - box.yMm) + 'mm';
div.style.fontSize = block.sizeMm + 'mm';
div.textContent = block.text;
label.appendChild(div);
});
return label;
}
/* ---------- Pratinjau PDF (jsPDF) ---------- */
var lastPdfDoc = null;
var lastPdfUrl = null;
function drawPdfLabel(doc, layout, item, index) {
var boxes = layout.contentBoxes(index);
var text = LabelLayout.composeText(item, boxes.textBox, CONFIG, measure);
text.blocks.forEach(function (block) {
doc.setFont('helvetica', block.weight === 'bold' ? 'bold' : 'normal');
doc.setFontSize(block.sizeMm * 72 / 25.4);
doc.setTextColor(0);
// jsPDF memakai baseline sebagai titik acuan, PDF memakai posisi cap-top.
doc.text(block.text, block.xMm, block.yMm + HelveticaMetrics.CAP_HEIGHT * block.sizeMm);
});
var matrix = buildMatrix(item.payload);
var total = matrix.size + CONFIG.quietZoneModules * 2;
var qrSizeMm = Math.min(boxes.qrBox.widthMm, boxes.qrBox.heightMm);
var moduleMm = qrSizeMm / total;
var originX = boxes.qrBox.xMm + (boxes.qrBox.widthMm - qrSizeMm) / 2 +
CONFIG.quietZoneModules * moduleMm;
var originY = boxes.qrBox.yMm + (boxes.qrBox.heightMm - qrSizeMm) / 2 +
CONFIG.quietZoneModules * moduleMm;
var bleed = 0.006;
doc.setFillColor(0);
for (var row = 0; row < matrix.size; row++) {
var col = 0;
while (col < matrix.size) {
if (matrix.get(row, col)) {
var start = col;
while (col < matrix.size && matrix.get(row, col)) { col++; }
doc.rect(
originX + start * moduleMm - bleed,
originY + row * moduleMm - bleed,
(col - start) * moduleMm + bleed * 2,
moduleMm + bleed * 2,
'F'
);
} else {
col++;
}
}
}
}
function buildPdf() {
if (!window.jspdf || !window.jspdf.jsPDF) {
setStatus('Pustaka jsPDF belum termuat (memerlukan koneksi internet). Gunakan CLI Node untuk PDF presisi.', true);
return null;
}
if (!items.length) {
setStatus('Tidak ada data label.', true);
return null;
}
var layout = LabelLayout.create(CONFIG);
var perPage = layout.perPage;
var pageCount = Math.ceil(items.length / perPage);
var doc = new window.jspdf.jsPDF({
unit: 'mm',
format: [CONFIG.pageWidthMm, CONFIG.pageHeightMm],
orientation: 'portrait'
});
for (var p = 0; p < pageCount; p++) {
if (p > 0) { doc.addPage([CONFIG.pageWidthMm, CONFIG.pageHeightMm], 'portrait'); }
var start = p * perPage;
var end = Math.min(items.length, start + perPage);
for (var i = start; i < end; i++) {
drawPdfLabel(doc, layout, items[i], i);
}
}
return { doc: doc, pageCount: pageCount, layout: layout };
}
function openPdfPreview() {
var built = buildPdf();
if (!built) { return; }
lastPdfDoc = built.doc;
if (lastPdfUrl) { URL.revokeObjectURL(lastPdfUrl); }
var blob = built.doc.output('blob');
lastPdfUrl = URL.createObjectURL(blob);
document.getElementById('pdf-frame').src = lastPdfUrl;
document.getElementById('pdf-info').textContent =
built.pageCount + ' halaman · ' + built.layout.page.widthMm + ' × ' + built.layout.page.heightMm +
' mm · ' + items.length + ' label';
document.getElementById('pdf-modal').hidden = false;
}
function closePdfPreview() {
document.getElementById('pdf-modal').hidden = true;
}
function downloadPdf() {
if (!lastPdfDoc) { return; }
lastPdfDoc.save('label-qr-' + CONFIG.pageWidthMm + 'x' + CONFIG.pageHeightMm + 'mm.pdf');
}
document.getElementById('btn-build').addEventListener('click', build);
document.getElementById('btn-pdf').addEventListener('click', openPdfPreview);
document.getElementById('btn-download').addEventListener('click', downloadPdf);
document.getElementById('btn-close').addEventListener('click', closePdfPreview);
document.getElementById('pdf-modal').addEventListener('click', function (event) {
if (event.target === event.currentTarget) { closePdfPreview(); }
});
document.addEventListener('keydown', function (event) {
if (event.key === 'Escape' && !document.getElementById('pdf-modal').hidden) {
closePdfPreview();
}
});
document.addEventListener('keydown', function (event) {
if (event.key === 'Escape') { closePdfPreview(); }
});
document.getElementById('btn-clear').addEventListener('click', function () {
document.getElementById('codes').value = '';
items = [];
render();
setStatus('Daftar dikosongkan.');
});
var help = document.getElementById('help');
var btnHelp = document.getElementById('btn-help');
btnHelp.addEventListener('click', function () {
help.hidden = !help.hidden;
btnHelp.textContent = help.hidden ? 'Tampilkan' : 'Sembunyikan';
btnHelp.setAttribute('aria-label', help.hidden ? 'Tampilkan keterangan' : 'Sembunyikan keterangan');
btnHelp.setAttribute('aria-expanded', String(!help.hidden));
});
var timer = null;
document.getElementById('codes').addEventListener('input', function () {
if (timer) { clearTimeout(timer); }
timer = setTimeout(build, 250);
});
window.addEventListener('load', build);
})();
</script>
</body>
</html>
+168
View File
@@ -0,0 +1,168 @@
/**
* Parsing data label (UMD, tanpa dependensi) sehingga format input yang
* sama dipakai oleh CLI Node maupun aplikasi HTML.
*
* Format baris teks : "KODE BARU | SN"
* - pemisah SN boleh "|" atau TAB
* - "SN: 12345678" juga diterima, label "SN:" dibuang otomatis
* - baris kosong dan baris komentar "#..." dilewati
* - kode gabungan "ONT-191026-3BA3" otomatis ditampilkan
* menjadi dua baris: "ONT-1910" / "26-3BA3"
*
* Format JSON : [{ "code": "ONT-1910", "unique": "26-5BD9", "sn": "12345678" }]
* - kunci alternatif: payload/kode, unique/uniqueCode, sn/serial
*/
(function (root, factory) {
if (typeof module === 'object' && module.exports) {
module.exports = factory();
} else {
root.LabelData = factory();
}
})(typeof self !== 'undefined' ? self : this, function () {
'use strict';
function stripQuotes(value) {
return String(value).replace(/^["']/, '').replace(/["']$/, '').trim();
}
/** Bersihkan nilai SN: buang prefix "SN:" dan tanda kutip. */
function normalizeSn(value) {
if (value === undefined || value === null) { return ''; }
var sn = String(value).trim();
sn = sn.replace(/^SN\s*:\s*/i, '');
sn = stripQuotes(sn);
return sn;
}
/** Pecah satu baris menjadi payload (isi QR) dan SN. */
function parseLine(line) {
var raw = String(line === undefined || line === null ? '' : line);
var text = raw.replace(/^\uFEFF/, '').trim();
if (!text) { return null; }
if (text.charAt(0) === '#') { return null; }
var sn = '';
var cut = text.indexOf('|');
if (cut >= 0) {
sn = text.slice(cut + 1);
text = text.slice(0, cut);
} else {
var tab = text.indexOf('\t');
if (tab >= 0) {
sn = text.slice(tab + 1);
text = text.slice(0, tab);
}
}
var payload = text.trim();
if (!payload) { return null; }
return buildItem(payload, normalizeSn(sn), raw);
}
/**
* Pisahkan payload menjadi kode utama dan kode unik.
* - "ONT-0910 26-5BD9" -> dipecah pada spasi terakhir.
* - "ONT-191026-3BA3" -> kode gabungan 8 karakter + kode unik
* "26-3BA3"; payload QR tetap memakai teks lengkap tanpa spasi.
*/
function splitPayload(payload) {
var text = String(payload || '');
var cut = text.lastIndexOf(' ');
if (cut > 0) {
return { main: text.slice(0, cut), unique: text.slice(cut + 1) };
}
var compact = /^([A-Za-z]{3}-\d{4})(\d{2}-[A-Za-z0-9]{4})$/.exec(text);
if (compact) {
return { main: compact[1], unique: compact[2] };
}
return { main: text, unique: '' };
}
function buildItem(payload, sn, source) {
var parts = splitPayload(payload);
return {
payload: payload,
sn: sn || '',
main: parts.main,
unique: parts.unique,
snText: 'SN: -' + (sn ? ' ' + sn : ''),
source: source === undefined ? payload : source
};
}
function itemFromObject(raw) {
var code = raw.code || raw.payload || raw.kode || raw.item || '';
var unique = raw.unique || raw.uniqueCode || raw.kode_unik || raw.serial_code || '';
var sn = normalizeSn(raw.sn || raw.serial || raw.SN || raw.snCode || '');
code = String(code).trim();
if (!code) { return null; }
var payload = unique ? code + ' ' + String(unique).trim() : code;
var item = buildItem(payload, sn, payload);
if (unique) {
item.main = code;
item.unique = String(unique).trim();
}
return item;
}
function itemsFromJson(data) {
var list;
if (Array.isArray(data)) {
list = data;
} else if (data && Array.isArray(data.items)) {
list = data.items;
} else if (data && Array.isArray(data.labels)) {
list = data.labels;
} else if (data && Array.isArray(data.data)) {
list = data.data;
} else {
list = [data];
}
var items = [];
for (var i = 0; i < list.length; i++) {
var raw = list[i];
var item = null;
if (typeof raw === 'string' || typeof raw === 'number') {
item = parseLine(String(raw));
} else if (raw && typeof raw === 'object') {
item = itemFromObject(raw);
}
if (item) { items.push(item); }
}
return items;
}
/** Parse teks mentah (JSON atau daftar baris) menjadi daftar item label. */
function parseText(raw) {
var text = String(raw === undefined || raw === null ? '' : raw);
var trimmed = text.replace(/^\uFEFF/, '').trim();
if (!trimmed) { return []; }
var first = trimmed.charAt(0);
if (first === '[' || first === '{') {
try {
return itemsFromJson(JSON.parse(trimmed));
} catch (err) {
throw new Error('Input JSON tidak valid: ' + err.message);
}
}
var lines = text.split(/\r?\n/);
var items = [];
for (var i = 0; i < lines.length; i++) {
var item = parseLine(lines[i]);
if (item) { items.push(item); }
}
return items;
}
return {
parseText: parseText,
parseLine: parseLine,
splitPayload: splitPayload,
normalizeSn: normalizeSn,
buildItem: buildItem
};
});
+391
View File
@@ -0,0 +1,391 @@
/**
* Layout engine bersama untuk label QR 3 kolom.
*
* Semua perhitungan memakai satuan milimeter sebagai acuan desain.
* Konversi ke point PDF memakai rumus 1 mm = 72 / 25.4 pt.
*
* Modul ini sengaja dibuat tanpa dependensi (UMD) supaya file yang sama
* dipakai oleh:
* - src/pdf.js (generator PDF, Node)
* - file HTML (preview + cetak langsung dari browser)
*/
(function (root, factory) {
if (typeof module === 'object' && module.exports) {
module.exports = factory();
} else {
root.LabelLayout = factory();
}
})(typeof self !== 'undefined' ? self : this, function () {
'use strict';
var MM_TO_PT = 72 / 25.4;
var PT_TO_MM = 25.4 / 72;
// Ruang aman 1% saat menghitung lebar teks, supaya pembulatan lebar font
// tidak menyebabkan teks terpecah atau terpotong.
var WIDTH_TOLERANCE = 0.99;
// Toleransi absolut kecil untuk kasus teks yang pas di batas (mis. hasil
// interpolasi ukuran font). Tanpa ini, pembulatan float bisa membuat
// wrapText menganggap teks tidak muat lalu memecahnya.
var WIDTH_EPSILON_MM = 0.001;
// Jumlah baris bawaan untuk mode sheet (tinggi sel mengisi halaman).
var DEFAULT_ROWS = 4;
var DEFAULT_CONFIG = {
// Format 18 label: halaman 100 x 150 mm, 3 kolom x 6 baris.
// Tinggi sel mengisi halaman: (150 - 2*2.5 - 5*5) / 6 = 20 mm.
pageWidthMm: 100,
pageHeightMm: 150,
columns: 3,
// Jumlah baris per halaman. 0 = hitung otomatis dari tinggi label.
rows: 6,
// Tinggi fisik satu label (roll label EPPOS RP-4610B).
// 0 / null = tinggi sel label ikut mengisi tinggi halaman (baris dibagi rata),
// diisi = tinggi sel dipatok dan baris disusun dari atas ke bawah.
labelHeightMm: 0,
marginXMm: 2.5,
marginYMm: 2.5,
gapXMm: 4.5,
gapYMm: 5,
paddingMm: 1.0,
innerGapMm: 1.0,
// Ruang kosong di sisi kanan setiap sel label.
rightGapMm: 0,
qrSizeMm: 13.5,
// 2 modul di dalam kotak QR + padding sel sudah memberi quiet zone cukup.
quietZoneModules: 2,
errorCorrectionLevel: 'M',
mainFontMm: 2.5,
uniqueFontMm: 2.3,
snFontMm: 1.7,
// Jarak tambahan sebelum baris SN (seperti gambar referensi).
snGapMm: 3.5,
minFontMm: 1.2,
lineHeightRatio: 1.3,
// 'center' = teks dan QR rata tengah di dalam sel label.
// 'top' = teks dan QR rata atas (opsional).
verticalAlign: 'center',
guides: false
};
function mergeConfig(config) {
var merged = {};
var key;
for (key in DEFAULT_CONFIG) {
if (Object.prototype.hasOwnProperty.call(DEFAULT_CONFIG, key)) {
merged[key] = DEFAULT_CONFIG[key];
}
}
if (config) {
for (key in config) {
if (Object.prototype.hasOwnProperty.call(config, key) &&
config[key] !== undefined && config[key] !== null) {
merged[key] = config[key];
}
}
}
return merged;
}
/**
* Hitung grid halaman: lebar sel, tinggi sel, jumlah baris dan kolom.
* Bila labelHeightMm diisi, baris disusun dari atas dan sisa halaman
* dibiarkan kosong. Bila 0/null, baris dibagi rata memenuhi halaman.
*/
function computeGrid(config) {
var c = mergeConfig(config);
var columns = Math.max(1, Math.round(c.columns));
var usableWidthMm = c.pageWidthMm - 2 * c.marginXMm - c.gapXMm * (columns - 1);
if (usableWidthMm <= 0) {
throw new Error('Lebar halaman tidak cukup untuk ' + columns + ' kolom.');
}
var cellWidthMm = usableWidthMm / columns;
var rows;
var cellHeightMm;
var offsetYMm;
if (c.labelHeightMm) {
// Tinggi label dipatok: baris disusun dari atas ke bawah, sisa ruang
// dibiarkan kosong di bawah (format referensi).
cellHeightMm = c.labelHeightMm;
var maxRows = Math.max(1, Math.floor(
(c.pageHeightMm - 2 * c.marginYMm + c.gapYMm) / (cellHeightMm + c.gapYMm)
));
// rows = 0 berarti hitung otomatis dari tinggi halaman.
rows = (!c.rows)
? maxRows
: Math.min(Math.max(1, Math.round(c.rows)), maxRows);
offsetYMm = c.marginYMm;
} else {
rows = Math.max(1, Math.round(c.rows === null || c.rows === undefined ? DEFAULT_ROWS : c.rows));
cellHeightMm = (c.pageHeightMm - 2 * c.marginYMm - c.gapYMm * (rows - 1)) / rows;
if (cellHeightMm <= 0) {
throw new Error('Tinggi halaman tidak cukup untuk ' + rows + ' baris.');
}
offsetYMm = c.marginYMm;
}
return {
config: c,
columns: columns,
rows: rows,
cellWidthMm: cellWidthMm,
cellHeightMm: cellHeightMm,
offsetYMm: offsetYMm,
perPage: columns * rows
};
}
/** Kotak label (sel) untuk index label ke-n (0 = label pertama). */
function labelBox(grid, index) {
var perPage = grid.perPage;
var pageIndex = Math.floor(index / perPage);
var pos = index % perPage;
var row = Math.floor(pos / grid.columns);
var col = pos % grid.columns;
var c = grid.config;
return {
index: index,
pageIndex: pageIndex,
row: row,
col: col,
xMm: c.marginXMm + col * (grid.cellWidthMm + c.gapXMm),
yMm: grid.offsetYMm + row * (grid.cellHeightMm + c.gapYMm),
widthMm: grid.cellWidthMm,
heightMm: grid.cellHeightMm
};
}
/**
* Tempatkan kotak berukuran widthMm x heightMm tepat di tengah area.
* Origin kiri-atas dipakai sama oleh PDFKit dan CSS browser.
*/
function centerBox(area, widthMm, heightMm) {
return {
xMm: area.xMm + (area.widthMm - widthMm) / 2,
yMm: area.yMm + (area.heightMm - heightMm) / 2,
widthMm: widthMm,
heightMm: heightMm
};
}
/** Area teks (kiri) dan area QR (kanan) di dalam sebuah sel label. */
function contentBoxes(grid, box) {
var c = grid.config;
var pad = c.paddingMm;
var content = {
xMm: box.xMm + pad,
yMm: box.yMm + pad,
widthMm: box.widthMm - 2 * pad - c.rightGapMm,
heightMm: box.heightMm - 2 * pad
};
var qrSizeMm = Math.min(c.qrSizeMm, content.widthMm, content.heightMm);
// Area barcode adalah slot di sisi kanan area konten. QR selalu
// dihitung dari pusat area ini, bukan dari tepi kanan label.
var barcodeArea = {
xMm: content.xMm + content.widthMm - qrSizeMm,
yMm: content.yMm,
widthMm: qrSizeMm,
heightMm: content.heightMm
};
if (c.verticalAlign === 'top') {
barcodeArea.heightMm = qrSizeMm;
}
var qrBox = centerBox(barcodeArea, qrSizeMm, qrSizeMm);
var textBox = {
xMm: content.xMm,
yMm: content.yMm,
widthMm: content.widthMm - qrSizeMm - c.innerGapMm,
heightMm: content.heightMm
};
if (textBox.widthMm <= 0) {
textBox.widthMm = Math.max(1, content.widthMm * 0.45);
}
return {
content: content,
barcodeArea: barcodeArea,
textBox: textBox,
qrBox: qrBox
};
}
/**
* Turunkan ukuran font agar teks muat pada lebar maksimum.
* Lebar teks berskala linear terhadap ukuran font, jadi interpolasi linear tepat.
*/
function fitFontSize(measure, text, desiredMm, maxWidthMm, minMm) {
if (!text) { return desiredMm; }
var widthMm = measure(text, desiredMm);
if (!isFinite(widthMm) || widthMm <= 0) { return desiredMm; }
if (widthMm <= maxWidthMm * WIDTH_TOLERANCE) { return desiredMm; }
return Math.max(minMm, desiredMm * (maxWidthMm * WIDTH_TOLERANCE / widthMm));
}
/** Apakah teks muat pada lebar maksimum (dengan toleransi pembulatan). */
function fits(measure, text, sizeMm, maxWidthMm) {
return measure(text, sizeMm) <= maxWidthMm * WIDTH_TOLERANCE + WIDTH_EPSILON_MM;
}
/** Pecah teks panjang menjadi beberapa baris tanpa memotong karakter. */
function wrapText(measure, text, sizeMm, maxWidthMm) {
if (!text) { return []; }
if (fits(measure, text, sizeMm, maxWidthMm)) { return [text]; }
var words = String(text).split(/\s+/);
var lines = [];
var current = '';
function pushCurrent() {
if (current) { lines.push(current); current = ''; }
}
for (var i = 0; i < words.length; i++) {
var word = words[i];
if (!word) { continue; }
if (!fits(measure, word, sizeMm, maxWidthMm)) {
pushCurrent();
var chunk = '';
for (var j = 0; j < word.length; j++) {
if (chunk && !fits(measure, chunk + word.charAt(j), sizeMm, maxWidthMm)) {
lines.push(chunk);
chunk = '';
}
chunk += word.charAt(j);
}
current = chunk;
continue;
}
var candidate = current ? current + ' ' + word : word;
if (fits(measure, candidate, sizeMm, maxWidthMm)) {
current = candidate;
} else {
pushCurrent();
current = word;
}
}
pushCurrent();
return lines.length ? lines : [text];
}
/**
* Susun blok teks (kode utama, kode unik, SN) di dalam textBox.
* `measure(text, sizeMm, weight)` harus mengembalikan lebar teks dalam mm.
*/
function composeText(item, textBox, config, measure) {
var c = mergeConfig(config);
var parts = [];
if (item.main) {
parts.push({ text: String(item.main), desiredMm: c.mainFontMm, weight: 'bold' });
}
if (item.unique) {
parts.push({ text: String(item.unique), desiredMm: c.uniqueFontMm, weight: 'bold' });
}
var snText = item.snText !== undefined && item.snText !== null
? String(item.snText)
: 'SN: -' + (item.sn ? ' ' + item.sn : '');
if (snText) {
parts.push({
text: snText,
desiredMm: c.snFontMm,
weight: 'normal',
gapBeforeMm: c.snGapMm
});
}
var i;
var p;
for (i = 0; i < parts.length; i++) {
p = parts[i];
p.sizeMm = fitFontSize(measure, p.text, p.desiredMm, textBox.widthMm, c.minFontMm);
p.lines = wrapText(measure, p.text, p.sizeMm, textBox.widthMm);
}
function totalHeightMm(list) {
var total = 0;
for (var k = 0; k < list.length; k++) {
total += (list[k].gapBeforeMm || 0) +
list[k].lines.length * list[k].sizeMm * c.lineHeightRatio;
}
return total;
}
var guard = 0;
while (totalHeightMm(parts) > textBox.heightMm && guard < 16) {
var currentHeight = totalHeightMm(parts);
var scale = (textBox.heightMm / currentHeight) * 0.98;
for (i = 0; i < parts.length; i++) {
p = parts[i];
p.sizeMm = Math.max(c.minFontMm, p.sizeMm * scale);
p.lines = wrapText(measure, p.text, p.sizeMm, textBox.widthMm);
}
guard++;
}
var blockHeightMm = totalHeightMm(parts);
var cursorMm = c.verticalAlign === 'top'
? textBox.yMm
: textBox.yMm + Math.max(0, (textBox.heightMm - blockHeightMm) / 2);
var blocks = [];
for (i = 0; i < parts.length; i++) {
p = parts[i];
cursorMm += p.gapBeforeMm || 0;
for (var li = 0; li < p.lines.length; li++) {
blocks.push({
text: p.lines[li],
sizeMm: p.sizeMm,
weight: p.weight,
xMm: textBox.xMm,
yMm: cursorMm,
heightMm: p.sizeMm * c.lineHeightRatio
});
cursorMm += p.sizeMm * c.lineHeightRatio;
}
}
return { blocks: blocks, heightMm: blockHeightMm };
}
/**
* Buat objek layout lengkap: grid + kotak per label.
*/
function create(config) {
var grid = computeGrid(config);
return {
config: grid.config,
grid: grid,
page: {
widthMm: grid.config.pageWidthMm,
heightMm: grid.config.pageHeightMm,
widthPt: grid.config.pageWidthMm * MM_TO_PT,
heightPt: grid.config.pageHeightMm * MM_TO_PT
},
perPage: grid.perPage,
labelBox: function (index) { return labelBox(grid, index); },
contentBoxes: function (index) { return contentBoxes(grid, labelBox(grid, index)); }
};
}
/** Jumlah halaman yang dibutuhkan untuk N label. */
function pageCount(layout, itemCount) {
if (!itemCount) { return 0; }
return Math.ceil(itemCount / layout.perPage);
}
return {
MM_TO_PT: MM_TO_PT,
PT_TO_MM: PT_TO_MM,
DEFAULT_CONFIG: DEFAULT_CONFIG,
mergeConfig: mergeConfig,
computeGrid: computeGrid,
labelBox: labelBox,
centerBox: centerBox,
contentBoxes: contentBoxes,
fitFontSize: fitFontSize,
fits: fits,
wrapText: wrapText,
composeText: composeText,
create: create,
pageCount: pageCount
};
});
+52
View File
@@ -0,0 +1,52 @@
/**
* Pembuat SVG untuk QR Code dari matriks modul (UMD, tanpa dependensi).
*
* QR digambar sebagai path vektor (bukan raster) supaya modul tetap tajam
* baik di layar maupun ketika halaman dicetak pada skala 100%.
*/
(function (root, factory) {
if (typeof module === 'object' && module.exports) {
module.exports = factory();
} else {
root.LabelSvg = factory();
}
})(typeof self !== 'undefined' ? self : this, function () {
'use strict';
/**
* @param {{size:number, get:function(number,number):boolean}} matrix
* @param {{quietZone?:number, sizeMm?:number, background?:string, foreground?:string, id?:string}} options
*/
function matrixToSvg(matrix, options) {
var opts = options || {};
var quiet = opts.quietZone === undefined ? 4 : opts.quietZone;
var total = matrix.size + quiet * 2;
var bg = opts.background || '#ffffff';
var fg = opts.foreground || '#000000';
var sizeAttr = opts.sizeMm ? ' width="' + opts.sizeMm + 'mm" height="' + opts.sizeMm + 'mm"' : '';
var idAttr = opts.id ? ' id="' + opts.id + '"' : '';
var parts = [];
for (var r = 0; r < matrix.size; r++) {
var c = 0;
while (c < matrix.size) {
if (matrix.get(r, c)) {
var start = c;
while (c < matrix.size && matrix.get(r, c)) { c++; }
var w = c - start;
parts.push('M' + (quiet + start) + ' ' + (quiet + r) + 'h' + w + 'v1h-' + w + 'z');
} else {
c++;
}
}
}
return '<svg xmlns="http://www.w3.org/2000/svg"' + idAttr + ' viewBox="0 0 ' + total + ' ' + total + '"' +
sizeAttr + ' shape-rendering="crispEdges">' +
'<rect x="0" y="0" width="' + total + '" height="' + total + '" fill="' + bg + '"/>' +
'<path d="' + parts.join('') + '" fill="' + fg + '"/>' +
'</svg>';
}
return { matrixToSvg: matrixToSvg };
});
Generated Vendored
+16
View File
@@ -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/../esbuild/bin/esbuild" "$@"
else
exec node "$basedir/../esbuild/bin/esbuild" "$@"
fi
+17
View File
@@ -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%\..\esbuild\bin\esbuild" %*
+28
View File
@@ -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/../esbuild/bin/esbuild" $args
} else {
& "$basedir/node$exe" "$basedir/../esbuild/bin/esbuild" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../esbuild/bin/esbuild" $args
} else {
& "node$exe" "$basedir/../esbuild/bin/esbuild" $args
}
$ret=$LASTEXITCODE
}
exit $ret
Generated Vendored
+16
View File
@@ -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/../qrcode/bin/qrcode" "$@"
else
exec node "$basedir/../qrcode/bin/qrcode" "$@"
fi
+17
View File
@@ -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%\..\qrcode\bin\qrcode" %*
+28
View File
@@ -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/../qrcode/bin/qrcode" $args
} else {
& "$basedir/node$exe" "$basedir/../qrcode/bin/qrcode" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../qrcode/bin/qrcode" $args
} else {
& "node$exe" "$basedir/../qrcode/bin/qrcode" $args
}
$ret=$LASTEXITCODE
}
exit $ret
+615
View File
@@ -0,0 +1,615 @@
{
"name": "generate-qr-code",
"version": "1.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"node_modules/@esbuild/win32-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz",
"integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@pdf-lib/standard-fonts": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@pdf-lib/standard-fonts/-/standard-fonts-1.0.0.tgz",
"integrity": "sha512-hU30BK9IUN/su0Mn9VdlVKsWBS6GyhVfqjwl1FjZN4TxP6cCw0jP2w7V3Hf5uX7M0AZJ16vey9yE0ny7Sa59ZA==",
"dev": true,
"license": "MIT",
"dependencies": {
"pako": "^1.0.6"
}
},
"node_modules/@pdf-lib/upng": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@pdf-lib/upng/-/upng-1.0.1.tgz",
"integrity": "sha512-dQK2FUMQtowVP00mtIksrlZhdFXQZPC+taih1q4CvPZ5vqdxR/LKBaFg0oAfzd1GlHZXXSPdQfzQnt+ViGvEIQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"pako": "^1.0.10"
}
},
"node_modules/@swc/helpers": {
"version": "0.5.23",
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.23.tgz",
"integrity": "sha512-5lSsMOTXURePglDfvuAQUqkGek9Hg2kksOYay2m0+XR++b2NWYL/4sWyuvVBIs8oKnJaxkdi9whaL/sqN13afw==",
"license": "Apache-2.0",
"dependencies": {
"tslib": "^2.8.0"
}
},
"node_modules/@swc/helpers/node_modules/tslib": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
"license": "0BSD"
},
"node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"license": "MIT",
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/brotli": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/brotli/-/brotli-1.3.3.tgz",
"integrity": "sha512-oTKjJdShmDuGW94SyyaoQvAjf30dZaHnjJ8uAF+u2/vGJkJbJPJAT1gDiOJP5v1Zb6f9KEyW/1HpuaWIXtGHPg==",
"license": "MIT",
"dependencies": {
"base64-js": "^1.1.2"
}
},
"node_modules/browserify-zlib": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz",
"integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==",
"license": "MIT",
"dependencies": {
"pako": "~1.0.5"
}
},
"node_modules/camelcase": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
"integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/cliui": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",
"integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==",
"license": "ISC",
"dependencies": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0",
"wrap-ansi": "^6.2.0"
}
},
"node_modules/clone": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
"integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==",
"license": "MIT",
"engines": {
"node": ">=0.8"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"license": "MIT",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"license": "MIT"
},
"node_modules/crypto-js": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz",
"integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==",
"deprecated": "Active development of CryptoJS has been discontinued. This library is no longer maintained.",
"license": "MIT"
},
"node_modules/decamelize": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
"integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/dfa": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/dfa/-/dfa-1.2.0.tgz",
"integrity": "sha512-ED3jP8saaweFTjeGX8HQPjeC1YYyZs98jGNZx6IiBvxW7JG5v492kamAQB3m2wop07CvU/RQmzcKr6bgcC5D/Q==",
"license": "MIT"
},
"node_modules/dijkstrajs": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz",
"integrity": "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==",
"license": "MIT"
},
"node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"license": "MIT"
},
"node_modules/esbuild": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz",
"integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"bin": {
"esbuild": "bin/esbuild"
},
"engines": {
"node": ">=18"
},
"optionalDependencies": {
"@esbuild/aix-ppc64": "0.28.2",
"@esbuild/android-arm": "0.28.2",
"@esbuild/android-arm64": "0.28.2",
"@esbuild/android-x64": "0.28.2",
"@esbuild/darwin-arm64": "0.28.2",
"@esbuild/darwin-x64": "0.28.2",
"@esbuild/freebsd-arm64": "0.28.2",
"@esbuild/freebsd-x64": "0.28.2",
"@esbuild/linux-arm": "0.28.2",
"@esbuild/linux-arm64": "0.28.2",
"@esbuild/linux-ia32": "0.28.2",
"@esbuild/linux-loong64": "0.28.2",
"@esbuild/linux-mips64el": "0.28.2",
"@esbuild/linux-ppc64": "0.28.2",
"@esbuild/linux-riscv64": "0.28.2",
"@esbuild/linux-s390x": "0.28.2",
"@esbuild/linux-x64": "0.28.2",
"@esbuild/netbsd-arm64": "0.28.2",
"@esbuild/netbsd-x64": "0.28.2",
"@esbuild/openbsd-arm64": "0.28.2",
"@esbuild/openbsd-x64": "0.28.2",
"@esbuild/openharmony-arm64": "0.28.2",
"@esbuild/sunos-x64": "0.28.2",
"@esbuild/win32-arm64": "0.28.2",
"@esbuild/win32-ia32": "0.28.2",
"@esbuild/win32-x64": "0.28.2"
}
},
"node_modules/fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"license": "MIT"
},
"node_modules/find-up": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
"integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
"license": "MIT",
"dependencies": {
"locate-path": "^5.0.0",
"path-exists": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/fontkit": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/fontkit/-/fontkit-2.0.4.tgz",
"integrity": "sha512-syetQadaUEDNdxdugga9CpEYVaQIxOwk7GlwZWWZ19//qW4zE5bknOKeMBDYAASwnpaSHKJITRLMF9m1fp3s6g==",
"license": "MIT",
"dependencies": {
"@swc/helpers": "^0.5.12",
"brotli": "^1.3.2",
"clone": "^2.1.2",
"dfa": "^1.2.0",
"fast-deep-equal": "^3.1.3",
"restructure": "^3.0.0",
"tiny-inflate": "^1.0.3",
"unicode-properties": "^1.4.0",
"unicode-trie": "^2.0.0"
}
},
"node_modules/get-caller-file": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
"license": "ISC",
"engines": {
"node": "6.* || 8.* || >= 10.*"
}
},
"node_modules/is-fullwidth-code-point": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/jpeg-exif": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/jpeg-exif/-/jpeg-exif-1.1.4.tgz",
"integrity": "sha512-a+bKEcCjtuW5WTdgeXFzswSrdqi0jk4XlEtZlx5A94wCoBpFjfFTbo/Tra5SpNCl/YFZPvcV1dJc+TAYeg6ROQ==",
"deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.",
"license": "MIT"
},
"node_modules/jsqr": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/jsqr/-/jsqr-1.4.0.tgz",
"integrity": "sha512-dxLob7q65Xg2DvstYkRpkYtmKm2sPJ9oFhrhmudT1dZvNFFTlroai3AWSpLey/w5vMcLBXRgOJsbXpdN9HzU/A==",
"dev": true,
"license": "Apache-2.0"
},
"node_modules/linebreak": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/linebreak/-/linebreak-1.1.0.tgz",
"integrity": "sha512-MHp03UImeVhB7XZtjd0E4n6+3xr5Dq/9xI/5FptGk5FrbDR3zagPa2DS6U8ks/3HjbKWG9Q1M2ufOzxV2qLYSQ==",
"license": "MIT",
"dependencies": {
"base64-js": "0.0.8",
"unicode-trie": "^2.0.0"
}
},
"node_modules/linebreak/node_modules/base64-js": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-0.0.8.tgz",
"integrity": "sha512-3XSA2cR/h/73EzlXXdU6YNycmYI7+kicTxks4eJg2g39biHR84slg2+des+p7iHYhbRg/udIS4TD53WabcOUkw==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/locate-path": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
"integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
"license": "MIT",
"dependencies": {
"p-locate": "^4.1.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/mupdf": {
"version": "1.28.1",
"resolved": "https://registry.npmjs.org/mupdf/-/mupdf-1.28.1.tgz",
"integrity": "sha512-Gi11Ow2G1SlrXKJNZBL1eAIGFVih5+4ZKqjptamTVaj/5hnlrcVrVbyb7lHE2lfFKdxZPyv9ZtfOOq7XgjzEig==",
"dev": true,
"license": "AGPL-3.0-or-later"
},
"node_modules/p-limit": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
"license": "MIT",
"dependencies": {
"p-try": "^2.0.0"
},
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/p-locate": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
"integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
"license": "MIT",
"dependencies": {
"p-limit": "^2.2.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/p-try": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
"integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/pako": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz",
"integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==",
"license": "(MIT AND Zlib)"
},
"node_modules/path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/pdf-lib": {
"version": "1.17.1",
"resolved": "https://registry.npmjs.org/pdf-lib/-/pdf-lib-1.17.1.tgz",
"integrity": "sha512-V/mpyJAoTsN4cnP31vc0wfNA1+p20evqqnap0KLoRUN0Yk/p3wN52DOEsL4oBFcLdb76hlpKPtzJIgo67j/XLw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@pdf-lib/standard-fonts": "^1.0.0",
"@pdf-lib/upng": "^1.0.1",
"pako": "^1.0.11",
"tslib": "^1.11.1"
}
},
"node_modules/pdfkit": {
"version": "0.17.2",
"resolved": "https://registry.npmjs.org/pdfkit/-/pdfkit-0.17.2.tgz",
"integrity": "sha512-UnwF5fXy08f0dnp4jchFYAROKMNTaPqb/xgR8GtCzIcqoTnbOqtp3bwKvO4688oHI6vzEEs8Q6vqqEnC5IUELw==",
"license": "MIT",
"dependencies": {
"crypto-js": "^4.2.0",
"fontkit": "^2.0.4",
"jpeg-exif": "^1.1.4",
"linebreak": "^1.1.0",
"png-js": "^1.0.0"
}
},
"node_modules/png-js": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/png-js/-/png-js-1.1.0.tgz",
"integrity": "sha512-PM/uYGzGdNSzqeOgly68+6wKQDL1SY0a/N+OEa/+br6LnHWOAJB0Npiamnodfq3jd2LS/i2fMeOKSAILjA+m5Q==",
"dependencies": {
"browserify-zlib": "^0.2.0"
}
},
"node_modules/pngjs": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz",
"integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==",
"license": "MIT",
"engines": {
"node": ">=10.13.0"
}
},
"node_modules/qrcode": {
"version": "1.5.4",
"resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz",
"integrity": "sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg==",
"license": "MIT",
"dependencies": {
"dijkstrajs": "^1.0.1",
"pngjs": "^5.0.0",
"yargs": "^15.3.1"
},
"bin": {
"qrcode": "bin/qrcode"
},
"engines": {
"node": ">=10.13.0"
}
},
"node_modules/require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/require-main-filename": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
"license": "ISC"
},
"node_modules/restructure": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/restructure/-/restructure-3.0.2.tgz",
"integrity": "sha512-gSfoiOEA0VPE6Tukkrr7I0RBdE0s7H1eFCDBk05l1KIQT1UIKNc5JZy6jdyW6eYH3aR3g5b3PuL77rq0hvwtAw==",
"license": "MIT"
},
"node_modules/set-blocking": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
"integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==",
"license": "ISC"
},
"node_modules/string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/tiny-inflate": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/tiny-inflate/-/tiny-inflate-1.0.3.tgz",
"integrity": "sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==",
"license": "MIT"
},
"node_modules/tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true,
"license": "0BSD"
},
"node_modules/unicode-properties": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/unicode-properties/-/unicode-properties-1.4.1.tgz",
"integrity": "sha512-CLjCCLQ6UuMxWnbIylkisbRj31qxHPAurvena/0iwSVbQ2G1VY5/HjV0IRabOEbDHlzZlRdCrD4NhB0JtU40Pg==",
"license": "MIT",
"dependencies": {
"base64-js": "^1.3.0",
"unicode-trie": "^2.0.0"
}
},
"node_modules/unicode-trie": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/unicode-trie/-/unicode-trie-2.0.0.tgz",
"integrity": "sha512-x7bc76x0bm4prf1VLg79uhAzKw8DVboClSN5VxJuQ+LKDOVEW9CdH+VY7SP+vX7xCYQqzzgQpFqz15zeLvAtZQ==",
"license": "MIT",
"dependencies": {
"pako": "^0.2.5",
"tiny-inflate": "^1.0.0"
}
},
"node_modules/unicode-trie/node_modules/pako": {
"version": "0.2.9",
"resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz",
"integrity": "sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA==",
"license": "MIT"
},
"node_modules/which-module": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz",
"integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==",
"license": "ISC"
},
"node_modules/wrap-ansi": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
"integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
"license": "MIT",
"dependencies": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/y18n": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
"integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",
"license": "ISC"
},
"node_modules/yargs": {
"version": "15.4.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz",
"integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==",
"license": "MIT",
"dependencies": {
"cliui": "^6.0.0",
"decamelize": "^1.2.0",
"find-up": "^4.1.0",
"get-caller-file": "^2.0.1",
"require-directory": "^2.1.1",
"require-main-filename": "^2.0.0",
"set-blocking": "^2.0.0",
"string-width": "^4.2.0",
"which-module": "^2.0.0",
"y18n": "^4.0.0",
"yargs-parser": "^18.1.2"
},
"engines": {
"node": ">=8"
}
},
"node_modules/yargs-parser": {
"version": "18.1.3",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz",
"integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==",
"license": "ISC",
"dependencies": {
"camelcase": "^5.0.0",
"decamelize": "^1.2.0"
},
"engines": {
"node": ">=6"
}
}
}
}
+3
View File
@@ -0,0 +1,3 @@
# esbuild
This is the Windows 64-bit binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild for details.
BIN
View File
Binary file not shown.
+20
View File
@@ -0,0 +1,20 @@
{
"name": "@esbuild/win32-x64",
"version": "0.28.2",
"description": "The Windows 64-bit binary for esbuild, a JavaScript bundler.",
"repository": {
"type": "git",
"url": "git+https://github.com/evanw/esbuild.git"
},
"license": "MIT",
"preferUnplugged": true,
"engines": {
"node": ">=18"
},
"os": [
"win32"
],
"cpu": [
"x64"
]
}
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Andrew Dillon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+83
View File
@@ -0,0 +1,83 @@
<h1>
standard-fonts
<br />
<!-- NPM Version -->
<a href="https://www.npmjs.com/package/standard-fonts">
<img
src="https://img.shields.io/npm/v/@pdf-lib/standard-fonts.svg?style=flat-square"
alt="NPM Version"
/>
</a>
<!-- Prettier Badge -->
<a href="https://prettier.io/">
<img
src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square"
alt="Prettier Badge"
/>
</a>
</h1>
> Collection of metrics and encodings for the standard 14 PDF fonts
This project is a fork of [`afm`](https://github.com/chbrown/afm) and was created for use in [`pdf-lib`](https://github.com/Hopding/pdf-lib). This forks exists for two primary reasons:
1. The original project did not include mappings from Unicode to WinAnsi/ZapfDingbats/Symbol encodings.
2. The font metrics included in the original project were uncompressed (not ideal for usage in `pdf-lib`).
## Usage
```js
import { Font, FontNames, Encodings } from '@pdf-lib/standard-fonts';
const codePoint = '∑'.charCodeAt(0);
const glyph = Encodings.Symbol.encodeUnicodeCodePoint(codePoint);
glyph // => { code: 229, name: 'summation' }
const font = Font.load(FontNames.Symbol);
const width = font.getWidthOfGlyph(glyph.name);
width // => 713
```
## Installation
### NPM Module
To install the latest stable version:
```bash
# With npm
npm install --save @pdf-lib/standard-fonts
# With yarn
yarn add @pdf-lib/standard-fonts
```
This assumes you're using [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/lang/en/) as your package manager.
### UMD Module
You can also download `@pdf-lib/standard-fonts` as a UMD module from [unpkg](https://unpkg.com/#/). The UMD builds have been compiled to ES5, so they should work [in any modern browser](https://caniuse.com/#feat=es5). UMD builds are useful if you aren't using a package manager or module bundler. For example, you can use them directly in the `<script>` tag of an HTML page.
The following builds are available:
* https://unpkg.com/@pdf-lib/standard-fonts/dist/standard-fonts.js
* https://unpkg.com/@pdf-lib/standard-fonts/dist/standard-fonts.min.js
When using a UMD build, you will have access to a global `window.StandardFonts` variable. This variable contains the classes and enums exported by `@pdf-lib/standard-fonts`. For example:
```javascript
// NPM module
import { Font, FontNames, Encodings } from '@pdf-lib/standard-fonts';
const font = Font.load(FontNames.HelveticaBold);
const encoding = Encodings.WinAnsi;
// UMD module
var font = StandardFonts.Font.load(StandardFonts.FontNames.HelveticaBold);
var encoding = StandardFonts.Encodings.WinAnsi;
```
## License
[MIT](https://choosealicense.com/licenses/mit/)
## Original Repo's License
Copyright 2015–2018 Christopher Brown.
[MIT Licensed](https://chbrown.github.io/licenses/MIT/#2015-2018).
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
"eJyFWdtyGjkQ/RVqnnar8Bb4lpg3jEnCxgEvGDtxKg9iphm01oyILrZxKv++mrGd3az6KC8UnNa0+nrUGr5lI11VVLtskF198FaU1Dns9w9OOkf7/ePDrJu90bWbiorCgpH2RpLZO9WqaCReqZ8lnReJqKTa/SwL8DXJctPs9Lxs4oSS+bAuVVjXC7/tG/lAxYV0+SYbOOOpm402wojckVlQ8+T4wVFdUDHXlaifrTs91Q/Z4PNeMLu7t3/U6746POm+7vW/dLNlWGuUrOlCW+mkrrPBXr/X+4/gciPz25qszQbhyeyKjG2XZb3ewR+9Xi/sMdVO5k+ebHemcaHzW/57p3/y+qQbPk967We//TxoP191hoVeUWexs44q25nUuTZbbYSj4o9OZ6hUZ97osZ05WTJ3AQ37jMOqQtblIt9QG7lWycKJuhCmeJGGhSOxffccyqPj/W728eXX4cFJNxvavAmRyQbH++HnGf34vdc/etXNFq54d50NXh+2X6/C137v+CnQH8gZmYdQfP6WXX8MCppQTYMlditCBL53/wfTQ65EFeNfvQ6erlQsqX21akJc1rGs0EoJE+NbMnlToZFAVEFkQ3iABW2uGH3CUK1ojUTgMWEbjfaWeUp5G6N5aCwRw5vddkOM98EVqRlPrBJ2E8OPZHSM6prJkrtnVrqNIWbtOjQrg8o7Zq2VDwxId5x3xMe0lpzBuVaa0WGpkkCkmgaON/3qBVODpaHQiIybXz3ZliTi3DO2D2PoNIZGMXQWQ+MYehNDb2PoXQxNYujPGHofQ+cx9CGGpjE0i6GLGPorhuYxtIihyxhaxtBVD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03EH+CIxqsktFl+MTQqEaH4f2O+TXfvGBbHMulG2/Hn/98Q/b2xEO"
+24
View File
@@ -0,0 +1,24 @@
declare type EncodingCharCode = number;
declare type EncodingCharName = string;
interface UnicodeMappings {
[unicodeCodePoint: number]: [EncodingCharCode, EncodingCharName];
}
declare type EncodingNames = 'Symbol' | 'ZapfDingbats' | 'WinAnsi';
declare class Encoding {
name: EncodingNames;
supportedCodePoints: number[];
private unicodeMappings;
constructor(name: EncodingNames, unicodeMappings: UnicodeMappings);
canEncodeUnicodeCodePoint: (codePoint: number) => boolean;
encodeUnicodeCodePoint: (codePoint: number) => {
code: number;
name: string;
};
}
export declare type EncodingType = Encoding;
export declare const Encodings: {
Symbol: Encoding;
ZapfDingbats: Encoding;
WinAnsi: Encoding;
};
export {};
+34
View File
@@ -0,0 +1,34 @@
/* tslint:disable max-classes-per-file */
import { decompressJson, padStart } from './utils';
import AllEncodingsCompressed from './all-encodings.compressed.json';
var decompressedEncodings = decompressJson(AllEncodingsCompressed);
var allUnicodeMappings = JSON.parse(decompressedEncodings);
var Encoding = /** @class */ (function () {
function Encoding(name, unicodeMappings) {
var _this = this;
this.canEncodeUnicodeCodePoint = function (codePoint) {
return codePoint in _this.unicodeMappings;
};
this.encodeUnicodeCodePoint = function (codePoint) {
var mapped = _this.unicodeMappings[codePoint];
if (!mapped) {
var str = String.fromCharCode(codePoint);
var hexCode = "0x" + padStart(codePoint.toString(16), 4, '0');
var msg = _this.name + " cannot encode \"" + str + "\" (" + hexCode + ")";
throw new Error(msg);
}
return { code: mapped[0], name: mapped[1] };
};
this.name = name;
this.supportedCodePoints = Object.keys(unicodeMappings)
.map(Number)
.sort(function (a, b) { return a - b; });
this.unicodeMappings = unicodeMappings;
}
return Encoding;
}());
export var Encodings = {
Symbol: new Encoding('Symbol', allUnicodeMappings.symbol),
ZapfDingbats: new Encoding('ZapfDingbats', allUnicodeMappings.zapfdingbats),
WinAnsi: new Encoding('WinAnsi', allUnicodeMappings.win1252),
};
+83
View File
@@ -0,0 +1,83 @@
declare const compressedJsonForFontName: {
'Courier': string;
'Courier-Bold': string;
'Courier-Oblique': string;
'Courier-BoldOblique': string;
'Helvetica': string;
'Helvetica-Bold': string;
'Helvetica-Oblique': string;
'Helvetica-BoldOblique': string;
'Times-Roman': string;
'Times-Bold': string;
'Times-Italic': string;
'Times-BoldItalic': string;
'Symbol': string;
'ZapfDingbats': string;
};
export declare enum FontNames {
Courier = "Courier",
CourierBold = "Courier-Bold",
CourierOblique = "Courier-Oblique",
CourierBoldOblique = "Courier-BoldOblique",
Helvetica = "Helvetica",
HelveticaBold = "Helvetica-Bold",
HelveticaOblique = "Helvetica-Oblique",
HelveticaBoldOblique = "Helvetica-BoldOblique",
TimesRoman = "Times-Roman",
TimesRomanBold = "Times-Bold",
TimesRomanItalic = "Times-Italic",
TimesRomanBoldItalic = "Times-BoldItalic",
Symbol = "Symbol",
ZapfDingbats = "ZapfDingbats"
}
export declare type IFontNames = FontNames | keyof typeof compressedJsonForFontName;
export interface ICharMetrics {
/** Decimal value of default character code (-1 if not encoded) */
/** Width of character */
WX: number;
/** Character name (aka Glyph name) */
N: string;
}
/**
* [name_1 name_2 number_x]:
* Name of the first character in the kerning pair followed by the name of the
* second character followed by the kerning amount in the x direction
* (y is zero). The kerning amount is specified in the units of the character
* coordinate system.
*/
export declare type IKernPair = [string, string, number];
export declare class Font {
static load: (fontName: IFontNames) => Font;
Comment: string;
FontName: string;
FullName: string;
FamilyName: string;
Weight: string;
CharacterSet: string;
Version: string;
Notice: string;
EncodingScheme: string;
ItalicAngle: number;
UnderlinePosition: number;
UnderlineThickness: number;
CapHeight: number | void;
XHeight: number | void;
Ascender: number | void;
Descender: number | void;
StdHW: number;
StdVW: number;
IsFixedPitch: boolean;
/**
* [llx lly urx ury]:
* Font bounding box where llx, lly, urx, and ury are all numbers.
*/
FontBBox: [number, number, number, number];
CharMetrics: ICharMetrics[];
KernPairs: IKernPair[];
private CharWidths;
private KernPairXAmounts;
private constructor();
getWidthOfGlyph: (glyphName: string) => number | void;
getXAxisKerningForPair: (leftGlyphName: string, rightGlyphName: string) => number | void;
}
export {};
+83
View File
@@ -0,0 +1,83 @@
import { decompressJson } from './utils';
import CourierBoldCompressed from './Courier-Bold.compressed.json';
import CourierBoldObliqueCompressed from './Courier-BoldOblique.compressed.json';
import CourierObliqueCompressed from './Courier-Oblique.compressed.json';
import CourierCompressed from './Courier.compressed.json';
import HelveticaBoldCompressed from './Helvetica-Bold.compressed.json';
import HelveticaBoldObliqueCompressed from './Helvetica-BoldOblique.compressed.json';
import HelveticaObliqueCompressed from './Helvetica-Oblique.compressed.json';
import HelveticaCompressed from './Helvetica.compressed.json';
import TimesBoldCompressed from './Times-Bold.compressed.json';
import TimesBoldItalicCompressed from './Times-BoldItalic.compressed.json';
import TimesItalicCompressed from './Times-Italic.compressed.json';
import TimesRomanCompressed from './Times-Roman.compressed.json';
import SymbolCompressed from './Symbol.compressed.json';
import ZapfDingbatsCompressed from './ZapfDingbats.compressed.json';
// prettier-ignore
var compressedJsonForFontName = {
'Courier': CourierCompressed,
'Courier-Bold': CourierBoldCompressed,
'Courier-Oblique': CourierObliqueCompressed,
'Courier-BoldOblique': CourierBoldObliqueCompressed,
'Helvetica': HelveticaCompressed,
'Helvetica-Bold': HelveticaBoldCompressed,
'Helvetica-Oblique': HelveticaObliqueCompressed,
'Helvetica-BoldOblique': HelveticaBoldObliqueCompressed,
'Times-Roman': TimesRomanCompressed,
'Times-Bold': TimesBoldCompressed,
'Times-Italic': TimesItalicCompressed,
'Times-BoldItalic': TimesBoldItalicCompressed,
'Symbol': SymbolCompressed,
'ZapfDingbats': ZapfDingbatsCompressed,
};
export var FontNames;
(function (FontNames) {
FontNames["Courier"] = "Courier";
FontNames["CourierBold"] = "Courier-Bold";
FontNames["CourierOblique"] = "Courier-Oblique";
FontNames["CourierBoldOblique"] = "Courier-BoldOblique";
FontNames["Helvetica"] = "Helvetica";
FontNames["HelveticaBold"] = "Helvetica-Bold";
FontNames["HelveticaOblique"] = "Helvetica-Oblique";
FontNames["HelveticaBoldOblique"] = "Helvetica-BoldOblique";
FontNames["TimesRoman"] = "Times-Roman";
FontNames["TimesRomanBold"] = "Times-Bold";
FontNames["TimesRomanItalic"] = "Times-Italic";
FontNames["TimesRomanBoldItalic"] = "Times-BoldItalic";
FontNames["Symbol"] = "Symbol";
FontNames["ZapfDingbats"] = "ZapfDingbats";
})(FontNames || (FontNames = {}));
var fontCache = {};
var Font = /** @class */ (function () {
function Font() {
var _this = this;
this.getWidthOfGlyph = function (glyphName) {
return _this.CharWidths[glyphName];
};
this.getXAxisKerningForPair = function (leftGlyphName, rightGlyphName) {
return (_this.KernPairXAmounts[leftGlyphName] || {})[rightGlyphName];
};
}
Font.load = function (fontName) {
var cachedFont = fontCache[fontName];
if (cachedFont)
return cachedFont;
var json = decompressJson(compressedJsonForFontName[fontName]);
var font = Object.assign(new Font(), JSON.parse(json));
font.CharWidths = font.CharMetrics.reduce(function (acc, metric) {
acc[metric.N] = metric.WX;
return acc;
}, {});
font.KernPairXAmounts = font.KernPairs.reduce(function (acc, _a) {
var name1 = _a[0], name2 = _a[1], width = _a[2];
if (!acc[name1])
acc[name1] = {};
acc[name1][name2] = width;
return acc;
}, {});
fontCache[fontName] = font;
return font;
};
return Font;
}());
export { Font };
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
"eJx9WFlv2zgQ/iuGnnYBt5DkS85bmk13g27SoEkPbNEHWqIlIhSpklSuov99R7JIkSLtFyGZjxzN8c0h/4oueF1jpqKz6Mt1K1GJZ4s4S+PZYrvdbqJ59J4zdYNqDAfuXuodp52spdSToZrQl6n0KyZl1Sm/xgVpa5BcKURJfs5KCgdj+F++J8+4uCUqr6IzJVo8jy4qJFCusLjD3d27BucE0cGYd+/4c3T2/U2SxfM36XYxT+JtDI8k/jGPPrMCC0oYvuWSKMJZdPYmiWMLuK9I/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m0RCQEf9pxa3Xpds4RcpJhqNVDbXPkzqTpOJcK/mT1VO17gUtn57C3J3cpMlUucW77Px3hRwZ83VJFGvriJ6YRHJboLmnWPUNXWAC7FbQg+/0IrjUL4RMFBxhYkEdSBLxiXB0xD8TkEZorywPXoP0I/jxhXGzWKEoJUFgeiTvs3srq2eO9Hq2Aeq92S9eDIgeYwIeawKoVY+KyVOumuBmpY0r+CgrgQVn7ohl9n6aIoc4TJjB0lEDWvmaGa05ETrGfPRd3lm1jI64b9SKtBJlbhAFTgEhuqWoUvlhCFdwRBW613cNWqnGYyDAdj+OQfdnugpBWHUa14jAKbbN2tlDrfR6mXUT9p7F3peyGvHNBb0UCl933GHgmyN6Hc/0R6+KZxiG7Ba6ReJjg6RiAos0DpTRsHWNz1s284Mr58DI+UF52N8B7vyIGzP4+nGJcWLXiNMtiR0/0S0BPtExAj3ZNwE42zh11e6duTZS/YlZaK6DebfrkOsb4aURMnsqiA+viHpPowDrwsoX1y6moRTZ20cMXtmpOgFYf8sGd8kFrRw4ptuCQagu2lJvwmpXEUu2DNSlOoEf12vY4aXOZkG6WY8OC4hzrwHRcjVhWepjd4KdYKK7jrx5H89WjRxPWoycydlS3jZ/I2VS/G9yp9gB6PG1T1aY4YAp3LfPHPPqABbtFRHS/jf34/T82FAfb"
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
"eJxtmNtu20YQhl+F4FULyMGeD7pz3AY1ChtG7NpFA18w1NomIlECSRcxgrx7SVk7+wOdG8H5OJydf2Z2d5gf9cV+t0v9VK/r+6vXsXlOlbHe28paq229qj/t++m62aXZ4J/m8PRb1z9/baZxefK63Z6eXN5dVMvTCh83u277xr/6kLrnl2XNq7TpXnczuZyabdee98/b2VzM/x4/dd/T5qab2pd6PQ2vaVVfvDRD005puE3Lu7eH1HbN9hTjx4/77/X6y5lcnUmjVzHIVVDicVX/1W/SsO36dLM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2W1QYjQCh7E2aAQHeGhCFgPoNoy8KNb2wxBhmGKBxoUZXlLGsLI6AsftEDHV0wIURVbANLcTKlGGBIKPOAxCmhePCKUwFzAmpDFRQvjA9R06Hq8TONvshgKDCuRAZTXigUxjxNFfKRo3CLhnIJBMFRvMZpqpNBMlQJzGT5WFQMVQI/AikPMIhEU1aDjqJvQwmjSHB05cC9jbYwc5UtAHNLhDw41ha+lEqF4JaH3gmB61SYcqInxTDmQK8v08vjqv4zDf1N0w3Lf4A8/vwPpfK11w=="
File diff suppressed because one or more lines are too long
+2
View File
@@ -0,0 +1,2 @@
export * from './Font';
export * from './Encoding';
+2
View File
@@ -0,0 +1,2 @@
export * from './Font';
export * from './Encoding';
+3
View File
@@ -0,0 +1,3 @@
export declare const decodeFromBase64: (base64: string) => Uint8Array;
export declare const decompressJson: (compressedJson: string) => string;
export declare const padStart: (value: string, length: number, padChar: string) => string;
+62
View File
@@ -0,0 +1,62 @@
/*
* The `chars`, `lookup`, and `decodeFromBase64` members of this file are
* licensed under the following:
*
* base64-arraybuffer
* https://github.com/niklasvh/base64-arraybuffer
*
* Copyright (c) 2012 Niklas von Hertzen
* Licensed under the MIT license.
*
*/
import pako from 'pako';
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
// Use a lookup table to find the index.
var lookup = new Uint8Array(256);
for (var i = 0; i < chars.length; i++) {
lookup[chars.charCodeAt(i)] = i;
}
export var decodeFromBase64 = function (base64) {
var bufferLength = base64.length * 0.75;
var len = base64.length;
var i;
var p = 0;
var encoded1;
var encoded2;
var encoded3;
var encoded4;
if (base64[base64.length - 1] === '=') {
bufferLength--;
if (base64[base64.length - 2] === '=') {
bufferLength--;
}
}
var bytes = new Uint8Array(bufferLength);
for (i = 0; i < len; i += 4) {
encoded1 = lookup[base64.charCodeAt(i)];
encoded2 = lookup[base64.charCodeAt(i + 1)];
encoded3 = lookup[base64.charCodeAt(i + 2)];
encoded4 = lookup[base64.charCodeAt(i + 3)];
bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
}
return bytes;
};
var arrayToString = function (array) {
var str = '';
for (var i = 0; i < array.length; i++) {
str += String.fromCharCode(array[i]);
}
return str;
};
export var decompressJson = function (compressedJson) {
return arrayToString(pako.inflate(decodeFromBase64(compressedJson)));
};
export var padStart = function (value, length, padChar) {
var padding = '';
for (var idx = 0, len = length - value.length; idx < len; idx++) {
padding += padChar;
}
return padding + value;
};
@@ -0,0 +1 @@
"eJyFWdtyGjkQ/RVqnnar8Bb4lpg3jEnCxgEvGDtxKg9iphm01oyILrZxKv++mrGd3az6KC8UnNa0+nrUGr5lI11VVLtskF198FaU1Dns9w9OOkf7/ePDrJu90bWbiorCgpH2RpLZO9WqaCReqZ8lnReJqKTa/SwL8DXJctPs9Lxs4oSS+bAuVVjXC7/tG/lAxYV0+SYbOOOpm402wojckVlQ8+T4wVFdUDHXlaifrTs91Q/Z4PNeMLu7t3/U6746POm+7vW/dLNlWGuUrOlCW+mkrrPBXr/X+4/gciPz25qszQbhyeyKjG2XZb3ewR+9Xi/sMdVO5k+ebHemcaHzW/57p3/y+qQbPk967We//TxoP191hoVeUWexs44q25nUuTZbbYSj4o9OZ6hUZ97osZ05WTJ3AQ37jMOqQtblIt9QG7lWycKJuhCmeJGGhSOxffccyqPj/W728eXX4cFJNxvavAmRyQbH++HnGf34vdc/etXNFq54d50NXh+2X6/C137v+CnQH8gZmYdQfP6WXX8MCppQTYMlditCBL53/wfTQ65EFeNfvQ6erlQsqX21akJc1rGs0EoJE+NbMnlToZFAVEFkQ3iABW2uGH3CUK1ojUTgMWEbjfaWeUp5G6N5aCwRw5vddkOM98EVqRlPrBJ2E8OPZHSM6prJkrtnVrqNIWbtOjQrg8o7Zq2VDwxId5x3xMe0lpzBuVaa0WGpkkCkmgaON/3qBVODpaHQiIybXz3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rpiA+BuAX+bTOSodgzSHkaL7nmoF1HjMVMkanPdr7NmsKaAQm2VIAKvj85cZUbbwbw70fwVwasCguhb5W5S+03EH+CIxqsktFl+MTQqEaH4f2O+TXfvGBbHMulG2/Hn/98Q/b2xEO"
+24
View File
@@ -0,0 +1,24 @@
declare type EncodingCharCode = number;
declare type EncodingCharName = string;
interface UnicodeMappings {
[unicodeCodePoint: number]: [EncodingCharCode, EncodingCharName];
}
declare type EncodingNames = 'Symbol' | 'ZapfDingbats' | 'WinAnsi';
declare class Encoding {
name: EncodingNames;
supportedCodePoints: number[];
private unicodeMappings;
constructor(name: EncodingNames, unicodeMappings: UnicodeMappings);
canEncodeUnicodeCodePoint: (codePoint: number) => boolean;
encodeUnicodeCodePoint: (codePoint: number) => {
code: number;
name: string;
};
}
export declare type EncodingType = Encoding;
export declare const Encodings: {
Symbol: Encoding;
ZapfDingbats: Encoding;
WinAnsi: Encoding;
};
export {};
+39
View File
@@ -0,0 +1,39 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/* tslint:disable max-classes-per-file */
var utils_1 = require("./utils");
var all_encodings_compressed_json_1 = __importDefault(require("./all-encodings.compressed.json"));
var decompressedEncodings = utils_1.decompressJson(all_encodings_compressed_json_1.default);
var allUnicodeMappings = JSON.parse(decompressedEncodings);
var Encoding = /** @class */ (function () {
function Encoding(name, unicodeMappings) {
var _this = this;
this.canEncodeUnicodeCodePoint = function (codePoint) {
return codePoint in _this.unicodeMappings;
};
this.encodeUnicodeCodePoint = function (codePoint) {
var mapped = _this.unicodeMappings[codePoint];
if (!mapped) {
var str = String.fromCharCode(codePoint);
var hexCode = "0x" + utils_1.padStart(codePoint.toString(16), 4, '0');
var msg = _this.name + " cannot encode \"" + str + "\" (" + hexCode + ")";
throw new Error(msg);
}
return { code: mapped[0], name: mapped[1] };
};
this.name = name;
this.supportedCodePoints = Object.keys(unicodeMappings)
.map(Number)
.sort(function (a, b) { return a - b; });
this.unicodeMappings = unicodeMappings;
}
return Encoding;
}());
exports.Encodings = {
Symbol: new Encoding('Symbol', allUnicodeMappings.symbol),
ZapfDingbats: new Encoding('ZapfDingbats', allUnicodeMappings.zapfdingbats),
WinAnsi: new Encoding('WinAnsi', allUnicodeMappings.win1252),
};
+83
View File
@@ -0,0 +1,83 @@
declare const compressedJsonForFontName: {
'Courier': string;
'Courier-Bold': string;
'Courier-Oblique': string;
'Courier-BoldOblique': string;
'Helvetica': string;
'Helvetica-Bold': string;
'Helvetica-Oblique': string;
'Helvetica-BoldOblique': string;
'Times-Roman': string;
'Times-Bold': string;
'Times-Italic': string;
'Times-BoldItalic': string;
'Symbol': string;
'ZapfDingbats': string;
};
export declare enum FontNames {
Courier = "Courier",
CourierBold = "Courier-Bold",
CourierOblique = "Courier-Oblique",
CourierBoldOblique = "Courier-BoldOblique",
Helvetica = "Helvetica",
HelveticaBold = "Helvetica-Bold",
HelveticaOblique = "Helvetica-Oblique",
HelveticaBoldOblique = "Helvetica-BoldOblique",
TimesRoman = "Times-Roman",
TimesRomanBold = "Times-Bold",
TimesRomanItalic = "Times-Italic",
TimesRomanBoldItalic = "Times-BoldItalic",
Symbol = "Symbol",
ZapfDingbats = "ZapfDingbats"
}
export declare type IFontNames = FontNames | keyof typeof compressedJsonForFontName;
export interface ICharMetrics {
/** Decimal value of default character code (-1 if not encoded) */
/** Width of character */
WX: number;
/** Character name (aka Glyph name) */
N: string;
}
/**
* [name_1 name_2 number_x]:
* Name of the first character in the kerning pair followed by the name of the
* second character followed by the kerning amount in the x direction
* (y is zero). The kerning amount is specified in the units of the character
* coordinate system.
*/
export declare type IKernPair = [string, string, number];
export declare class Font {
static load: (fontName: IFontNames) => Font;
Comment: string;
FontName: string;
FullName: string;
FamilyName: string;
Weight: string;
CharacterSet: string;
Version: string;
Notice: string;
EncodingScheme: string;
ItalicAngle: number;
UnderlinePosition: number;
UnderlineThickness: number;
CapHeight: number | void;
XHeight: number | void;
Ascender: number | void;
Descender: number | void;
StdHW: number;
StdVW: number;
IsFixedPitch: boolean;
/**
* [llx lly urx ury]:
* Font bounding box where llx, lly, urx, and ury are all numbers.
*/
FontBBox: [number, number, number, number];
CharMetrics: ICharMetrics[];
KernPairs: IKernPair[];
private CharWidths;
private KernPairXAmounts;
private constructor();
getWidthOfGlyph: (glyphName: string) => number | void;
getXAxisKerningForPair: (leftGlyphName: string, rightGlyphName: string) => number | void;
}
export {};
+88
View File
@@ -0,0 +1,88 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var Courier_Bold_compressed_json_1 = __importDefault(require("./Courier-Bold.compressed.json"));
var Courier_BoldOblique_compressed_json_1 = __importDefault(require("./Courier-BoldOblique.compressed.json"));
var Courier_Oblique_compressed_json_1 = __importDefault(require("./Courier-Oblique.compressed.json"));
var Courier_compressed_json_1 = __importDefault(require("./Courier.compressed.json"));
var Helvetica_Bold_compressed_json_1 = __importDefault(require("./Helvetica-Bold.compressed.json"));
var Helvetica_BoldOblique_compressed_json_1 = __importDefault(require("./Helvetica-BoldOblique.compressed.json"));
var Helvetica_Oblique_compressed_json_1 = __importDefault(require("./Helvetica-Oblique.compressed.json"));
var Helvetica_compressed_json_1 = __importDefault(require("./Helvetica.compressed.json"));
var Times_Bold_compressed_json_1 = __importDefault(require("./Times-Bold.compressed.json"));
var Times_BoldItalic_compressed_json_1 = __importDefault(require("./Times-BoldItalic.compressed.json"));
var Times_Italic_compressed_json_1 = __importDefault(require("./Times-Italic.compressed.json"));
var Times_Roman_compressed_json_1 = __importDefault(require("./Times-Roman.compressed.json"));
var Symbol_compressed_json_1 = __importDefault(require("./Symbol.compressed.json"));
var ZapfDingbats_compressed_json_1 = __importDefault(require("./ZapfDingbats.compressed.json"));
// prettier-ignore
var compressedJsonForFontName = {
'Courier': Courier_compressed_json_1.default,
'Courier-Bold': Courier_Bold_compressed_json_1.default,
'Courier-Oblique': Courier_Oblique_compressed_json_1.default,
'Courier-BoldOblique': Courier_BoldOblique_compressed_json_1.default,
'Helvetica': Helvetica_compressed_json_1.default,
'Helvetica-Bold': Helvetica_Bold_compressed_json_1.default,
'Helvetica-Oblique': Helvetica_Oblique_compressed_json_1.default,
'Helvetica-BoldOblique': Helvetica_BoldOblique_compressed_json_1.default,
'Times-Roman': Times_Roman_compressed_json_1.default,
'Times-Bold': Times_Bold_compressed_json_1.default,
'Times-Italic': Times_Italic_compressed_json_1.default,
'Times-BoldItalic': Times_BoldItalic_compressed_json_1.default,
'Symbol': Symbol_compressed_json_1.default,
'ZapfDingbats': ZapfDingbats_compressed_json_1.default,
};
var FontNames;
(function (FontNames) {
FontNames["Courier"] = "Courier";
FontNames["CourierBold"] = "Courier-Bold";
FontNames["CourierOblique"] = "Courier-Oblique";
FontNames["CourierBoldOblique"] = "Courier-BoldOblique";
FontNames["Helvetica"] = "Helvetica";
FontNames["HelveticaBold"] = "Helvetica-Bold";
FontNames["HelveticaOblique"] = "Helvetica-Oblique";
FontNames["HelveticaBoldOblique"] = "Helvetica-BoldOblique";
FontNames["TimesRoman"] = "Times-Roman";
FontNames["TimesRomanBold"] = "Times-Bold";
FontNames["TimesRomanItalic"] = "Times-Italic";
FontNames["TimesRomanBoldItalic"] = "Times-BoldItalic";
FontNames["Symbol"] = "Symbol";
FontNames["ZapfDingbats"] = "ZapfDingbats";
})(FontNames = exports.FontNames || (exports.FontNames = {}));
var fontCache = {};
var Font = /** @class */ (function () {
function Font() {
var _this = this;
this.getWidthOfGlyph = function (glyphName) {
return _this.CharWidths[glyphName];
};
this.getXAxisKerningForPair = function (leftGlyphName, rightGlyphName) {
return (_this.KernPairXAmounts[leftGlyphName] || {})[rightGlyphName];
};
}
Font.load = function (fontName) {
var cachedFont = fontCache[fontName];
if (cachedFont)
return cachedFont;
var json = utils_1.decompressJson(compressedJsonForFontName[fontName]);
var font = Object.assign(new Font(), JSON.parse(json));
font.CharWidths = font.CharMetrics.reduce(function (acc, metric) {
acc[metric.N] = metric.WX;
return acc;
}, {});
font.KernPairXAmounts = font.KernPairs.reduce(function (acc, _a) {
var name1 = _a[0], name2 = _a[1], width = _a[2];
if (!acc[name1])
acc[name1] = {};
acc[name1][name2] = width;
return acc;
}, {});
fontCache[fontName] = font;
return font;
};
return Font;
}());
exports.Font = Font;
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
"eJx9WFlv2zgQ/iuGnnYBt5DkS85bmk13g27SoEkPbNEHWqIlIhSpklSuov99R7JIkSLtFyGZjxzN8c0h/4oueF1jpqKz6Mt1K1GJZ4s4S+PZYrvdbqJ59J4zdYNqDAfuXuodp52spdSToZrQl6n0KyZl1Sm/xgVpa5BcKURJfs5KCgdj+F++J8+4uCUqr6IzJVo8jy4qJFCusLjD3d27BucE0cGYd+/4c3T2/U2SxfM36XYxT+JtDI8k/jGPPrMCC0oYvuWSKMJZdPYmiWMLuK9I/sCwlNHZCuRfsJD9sSiOk7dxnMFbbrgieefGBW9eROfA7I/8z1myzVbz7rnpn9vuCW/unpvZecF3eHb3IhWu5eyK5Vw0XCCFi7ezc0pnvRo5E1hi8QhCeM0lHCoIK+/yCvdR67zrfd2THPA7VfzzNTrbpv2fX+BPeH8fm2usBMnBg++/oq/forO08+QGNMgGgeG/5wfxYrE4iPFzTlFt5JtkkLeMPIL/EFoNreJBE2vrXReako3YcqvVEXCTKWJdzPS7Gizyjk/mZZvsAKC66d7FCgMtF4NC2eaVqpDyLW+QwIzi/TGoD6tvPQL7BJEPNVKVb39DW2mkJnY5FALyD9eEhU6DL4SPrqTaS0mRrHyDXrHgvpQz7AvVU+CkqgQOnN3zVgSkkFVfKslzQIgfMfPFOBxWRiyDjcs5p5wFIoFr4kImprQrP59WP1ubiVpcCgxlNLq5XC4PwM8Wy77EvSs5Z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wE42zh11e6duTZS/YlZaK6DebfrkOsb4aURMnsqiA+viHpPowDrwsoX1y6moRTZ20cMXtmpOgFYf8sGd8kFrRw4ptuCQagu2lJvwmpXEUu2DNSlOoEf12vY4aXOZkG6WY8OC4hzrwHRcjVhWepjd4KdYKK7jrx5H89WjRxPWoycydlS3jZ/I2VS/G9yp9gB6PG1T1aY4YAp3LfPHPPqABbtFRHS/jf34/T82FAfb"
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
"eJxtmNtu20YQhl+F4FULyMGeD7pz3AY1ChtG7NpFA18w1NomIlECSRcxgrx7SVk7+wOdG8H5OJydf2Z2d5gf9cV+t0v9VK/r+6vXsXlOlbHe28paq229qj/t++m62aXZ4J/m8PRb1z9/baZxefK63Z6eXN5dVMvTCh83u277xr/6kLrnl2XNq7TpXnczuZyabdee98/b2VzM/x4/dd/T5qab2pd6PQ2vaVVfvDRD005puE3Lu7eH1HbN9hTjx4/77/X6y5lcnUmjVzHIVVDicVX/1W/SsO36dLMfu6nb9/X6TAoBD+5euvZbn8axXtuZ36dhPJrVQqgPQoh5hev91LWLkIv94W1Ygq9+aX+tZAx2tfz64284/sblN/rqfLP/mqrbt3FKu7G67Nv9cNgPzZQ2H6rz7bb6vLgZq89pTMO/M/xfEqturJpqSM/d7GJIm2oamk3aNcO3av80O5xh3yyKmm1193ZIT02bqovTKjP+MAf++7zsZvZ3276kYyWWXB0z99S18/PbafPHQ71W4fjn/fxnFO+ZvkrT0LVzTr78qB/+nk38bHM9exgP8zr1z9U7jt6840YW5uSJKcZOCaBBnKgm5mU8MVNYyMwWFvO7Ukagkmgg6sDWQ5yFFqjzUrLEaQ3BEmiwNsMSaZS0vgWfOkPHWQowNeTUc0kumnxZvsgPxlGai6VTGUqAVCTQ6QkWnc77DKEiLktSUBJKqHIQZ86d8gCpHYoiEzMsb1ubYy8vW50DChB5ZhGqrijD0EqUIeiaEHIfCg5Kpuu0ApiToaGPSY0uaQsyr65L2oKi1yFt1PLaQ3lzfXTgXodGoJYzglndSLDMPg1sTPJpQJHJigw0QrGERqD9YhyTOgONQDUyuF1zaxuokc/BW2ztXCMrGZ9WMW1oQZHIXWNBkSCfRZEL5BMUiZw6CzVSFCfUSGZFNjIldoKDkonTKQiJIGzWmFd3BizJJ9SINoLDriOfUCOZS+zg+KGD1qGiLNMLxtJD1/ns00ON6EzyUCM6vbxhoBKaqbG3DFQCNiL1iHccBPV0DHhQH/JW8EW90dkyFKGywCJU0WkVSvSGeiSUODWFFD0HYdPQVoiRgfPMA+/nnRgiAyNYSjpWNQcNSMrtFCUH4ZIRpSCWocFCSuhCEY6hoUClc0WC52BJlCYYLQdhN+hygRRRlo5BKRRLS6oihSqh+ZzzRGG1Mo4Iz1LoP0qsxDGFzk0JE42ji0jCPejomJKCuwil4m5CiRMEUMVSzVLDUstSx1Juc0oVWMpqY295qVltmtWmWW2a1aZZbZrVplltmtWmWW2G1WZYbYbVZlhthtVmWG2G1WZYbYbVZlhtltVmWW2W1WZZbZbVZlltltVmWW2W1QYjQCh7E2aAQHeGhCFgPoNoy8KNb2wxBhmGKBxoUZXlLGsLI6AsftEDHV0wIURVbANLcTKlGGBIKPOAxCmhePCKUwFzAmpDFRQvjA9R06Hq8TONvshgKDCuRAZTXigUxjxNFfKRo3CLhnIJBMFRvMZpqpNBMlQJzGT5WFQMVQI/AikPMIhEU1aDjqJvQwmjSHB05cC9jbYwc5UtAHNLhDw41ha+lEqF4JaH3gmB61SYcqInxTDmQK8v08vjqv4zDf1N0w3Lf4A8/vwPpfK11w=="
File diff suppressed because one or more lines are too long
+2
View File
@@ -0,0 +1,2 @@
export * from './Font';
export * from './Encoding';
+7
View File
@@ -0,0 +1,7 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./Font"));
__export(require("./Encoding"));
+3
View File
@@ -0,0 +1,3 @@
export declare const decodeFromBase64: (base64: string) => Uint8Array;
export declare const decompressJson: (compressedJson: string) => string;
export declare const padStart: (value: string, length: number, padChar: string) => string;
+67
View File
@@ -0,0 +1,67 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/*
* The `chars`, `lookup`, and `decodeFromBase64` members of this file are
* licensed under the following:
*
* base64-arraybuffer
* https://github.com/niklasvh/base64-arraybuffer
*
* Copyright (c) 2012 Niklas von Hertzen
* Licensed under the MIT license.
*
*/
var pako_1 = __importDefault(require("pako"));
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
// Use a lookup table to find the index.
var lookup = new Uint8Array(256);
for (var i = 0; i < chars.length; i++) {
lookup[chars.charCodeAt(i)] = i;
}
exports.decodeFromBase64 = function (base64) {
var bufferLength = base64.length * 0.75;
var len = base64.length;
var i;
var p = 0;
var encoded1;
var encoded2;
var encoded3;
var encoded4;
if (base64[base64.length - 1] === '=') {
bufferLength--;
if (base64[base64.length - 2] === '=') {
bufferLength--;
}
}
var bytes = new Uint8Array(bufferLength);
for (i = 0; i < len; i += 4) {
encoded1 = lookup[base64.charCodeAt(i)];
encoded2 = lookup[base64.charCodeAt(i + 1)];
encoded3 = lookup[base64.charCodeAt(i + 2)];
encoded4 = lookup[base64.charCodeAt(i + 3)];
bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
}
return bytes;
};
var arrayToString = function (array) {
var str = '';
for (var i = 0; i < array.length; i++) {
str += String.fromCharCode(array[i]);
}
return str;
};
exports.decompressJson = function (compressedJson) {
return arrayToString(pako_1.default.inflate(exports.decodeFromBase64(compressedJson)));
};
exports.padStart = function (value, length, padChar) {
var padding = '';
for (var idx = 0, len = length - value.length; idx < len; idx++) {
padding += padChar;
}
return padding + value;
};
+55
View File
@@ -0,0 +1,55 @@
{
"name": "@pdf-lib/standard-fonts",
"version": "1.0.0",
"description": "Metrics for the Standard 14 PDF fonts and their encodings",
"main": "lib/index.js",
"unpkg": "dist/standard-fonts.min.js",
"module": "es/index.js",
"types": "lib/index.d.ts",
"scripts": {
"make": "node Makefile.js",
"lint": "node Makefile.js lint",
"clean": "node Makefile.js clean",
"typecheck": "tsc --noEmit",
"afmToJson": "node Makefile.js afmToJson",
"encodingsToJson": "node Makefile.js encodingsToJson",
"releaseNext": "node Makefile.js releaseNext",
"releaseLatest": "node Makefile.js releaseLatest"
},
"repository": "https://github.com/Hopding/standard-fonts.git",
"keywords": [
"afm",
"adobe",
"font",
"metrics",
"ascii",
"pdf"
],
"author": "Andrew Dillon <andrew.dillon.j@gmail.com>",
"contributors": [
"Christopher Brown <io@henrian.com> (http://henrian.com)"
],
"license": "MIT",
"homepage": "https://github.com/Hopding/standard-fonts",
"dependencies": {
"pako": "^1.0.6"
},
"devDependencies": {
"@types/mz": "^0.0.32",
"@types/node": "^10.5.1",
"@types/pako": "^1.0.0",
"base64-arraybuffer": "^0.1.5",
"mz": "^2.7.0",
"prettier": "^1.15.3",
"rollup": "^0.68.2",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-json": "^3.1.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-terser": "^3.0.0",
"shelljs": "^0.8.3",
"ts-node": "^7.0.1",
"tslint": "^5.12.0",
"tslint-config-prettier": "^1.17.0",
"typescript": "^2.9.2"
}
}
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Photopea
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+143
View File
@@ -0,0 +1,143 @@
<h1>
upng
<br />
<!-- NPM Version -->
<a href="https://www.npmjs.com/package/@pdf-lib/upng">
<img
src="https://img.shields.io/npm/v/png-ts.svg?style=flat-square"
alt="NPM Version"
/>
</a>
</h1>
> A small, fast and advanced PNG / APNG encoder and decoder
This project is a fork of [`UPNG.js`](https://github.com/photopea/UPNG.js) and was created for use in [`pdf-lib`](https://github.com/Hopding/pdf-lib). The maintainer of the original repo does not publish it to NPM. That is the primary purpose of this fork. In addition, an `index.d.ts` file has been added (copied directly from [`@types/upng-js`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/upng-js/index.d.ts)) to makes TypeScript definitions available without requiring additional packages to be installed.
## Example of `UPNG.toRGBA8`
```javascript
// Import the UPNG class
import UPNG from '@pdf-lib/upng';
// Create a UPNG object
const pngImage = UPNG.decode(/* Uint8Array containing bytes of PNG image */);
// `pixels` is a 1D array (in rgba order) of decoded pixel data
const pixels = pngImage.UPNG.toRGBA8();
```
## Installation
### NPM Module
To install the latest stable version:
```bash
# With npm
npm install --save @pdf-lib/upng
# With yarn
yarn add @pdf-lib/upng
```
This assumes you're using [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/lang/en/) as your package manager.
### UMD Module
You can also download `@pdf-lib/upng` as a UMD module from [unpkg](https://unpkg.com/#/). The UMD builds have been compiled to ES5, so they should work [in any modern browser](https://caniuse.com/#feat=es5). UMD builds are useful if you aren't using a package manager or module bundler. For example, you can use them directly in the `<script>` tag of an HTML page.
The following builds are available:
* https://unpkg.com/@pdf-lib/upng/dist/UPNG.js
* https://unpkg.com/@pdf-lib/upng/dist/UPNG.min.js
When using a UMD build, you will have access to a global `window.UPNG` variable. This variable contains the `UPNG` class exported by `@pdf-lib/upng`. For example:
```javascript
// NPM module
import UPNG from '@pdf-lib/upng';
const pngImage = UPNG.decode(/* ... */)
// UMD module
var pngImage = window.UPNG.decode(/* ... */)
```
## Encoder
UPNG.js supports APNG and the interface expects "frames". Regular PNG is just a single-frame animation (single-item array).
#### `UPNG.encode(imgs, w, h, cnum, [dels])`
* `imgs`: array of frames. A frame is an ArrayBuffer containing the pixel data (RGBA, 8 bits per channel)
* `w`, `h` : width and height of the image
* `cnum`: number of colors in the result; 0: all colors (lossless PNG)
* `dels`: array of millisecond delays for each frame (only when 2 or more frames)
* returns an ArrayBuffer with binary data of a PNG file
UPNG.js can do a lossy minification of PNG files, similar to [TinyPNG](https://tinypng.com/) and other tools. It performed quantization with [k-means algorithm](https://en.wikipedia.org/wiki/K-means_clustering) in the past, but now we use [K-d trees](https://en.wikipedia.org/wiki/K-d_tree).
Lossy compression is allowed by the last parameter `cnum`. Set it to zero for a lossless compression, or write the number of allowed colors in the image. Smaller values produce smaller files. **Or just use 0 for lossless / 256 for lossy.**
// Read RGBA from canvas and encode with UPNG
var dta = ctx.getImageData(0,0,200,300).data; // ctx is Context2D of a Canvas
// dta = new Uint8Array(200 * 300 * 4); // or generate pixels manually
var png = UPNG.encode([dta.buffer], 200, 300, 0); console.log(new Uint8Array(png));
#### `UPNG.encodeLL(imgs, w, h, cc, ac, depth, [dels])` - low-level encode
* `imgs`: array of frames. A frame is an ArrayBuffer containing the pixel data (corresponding to following parameters)
* `w`, `h` : width and height of the image
* `cc`, `ac`: number of color channels (1 or 3) and alpha channels (0 or 1)
* `depth`: bit depth of pixel data (1, 2, 4, 8, 16)
* `dels`: array of millisecond delays for each frame (only when 2 or more frames)
* returns an ArrayBuffer with binary data of a PNG file
This function does not do any optimizations, it just stores what you give it. There are two cases when it is useful:
* saving 16-bit colors (note, that PNG is big-endian, unlike Uint16Array in JS)
* your image is too large, and "expanding" to 8-bit RGBA would use too much memory (e.g. 4-bit grayscale 50,000 x 50,000 = 1.25 GB, 8-bit RGBA would be 10 GB)
## Decoder
Supports all color types (including Grayscale and Palettes), all channel depths (1, 2, 4, 8, 16), interlaced images etc. Opens PNGs which other libraries can not open (tested with [PngSuite](http://www.schaik.com/pngsuite/)).
#### `UPNG.decode(buffer)`
* `buffer`: ArrayBuffer containing the PNG file
* returns an image object with following properties:
* * `width`: the width of the image
* * `height`: the height of the image
* * `depth`: number of bits per channel
* * `ctype`: color type of the file (Truecolor, Grayscale, Palette ...)
* * `frames`: additional info about frames (frame delays etc.)
* * `tabs`: additional chunks of the PNG file
* * `data`: pixel data of the image
PNG files may have a various number of channels and a various color depth. The interpretation of `data` depends on the current color type and color depth (see the [PNG specification](https://www.w3.org/TR/PNG/)).
#### `UPNG.toRGBA8(img)`
* `img`: PNG image object (returned by UPNG.decode())
* returns an array of frames. A frame is ArrayBuffer of the image in RGBA format, 8 bits per channel.
### Example
var img = UPNG.decode(buff); // put ArrayBuffer of the PNG file into UPNG.decode
var rgba = UPNG.toRGBA8(img)[0]; // UPNG.toRGBA8 returns array of frames, size: width * height * 4 bytes.
PNG format uses the Inflate algorithm. Right now, UPNG.js calls [Pako.js](https://github.com/nodeca/pako) for the Inflate and Deflate method.
## Quantizer
UPNG.js contains a very good Quantizer of 4-component 8-bit vectors (i.e. pixels). It can be used to generate nice color palettes (e.g. Photopea uses UPNG.js to make palettes for GIF images).
Quantization consists of two important steps: Finding a nice palette and Finding the closest color in the palette for each sample (non-trivial for large palettes). UPNG perfroms both steps.
var res = UPNG.quantize(data, psize);
* `data`: ArrayBuffer of samples (byte length is a multiple of four)
* `psize` : Palette size (how many colors you want to have)
The result object "res" has following properties:
* `abuf`: ArrayBuffer corresponding to `data`, where colors are remapped by a palette
* `inds`: Uint8Array : the index of a color for each sample (only when `psize`<=256)
* `plte`: Array : the Palette - a list of colors, `plte[i].est.q` and `plte[i].est.rgba` is the color value
### FAQ
- To get one common palette for multiple images (e.g. frames of the animation), concatenate them into one array `data`.
- When working with less than four components, set the remaining components to a constant value (e.g. to zero)
- When working with transparency, premultiply color components by transparency (otherwise, rgba(1,1,1,0) would be closer to rgba(1,1,1,1) than to rgba(0,0,0,0) - transparent mapped to white instead of transparent)
+1027
View File
File diff suppressed because it is too large Load Diff
+2017
View File
File diff suppressed because it is too large Load Diff
+7832
View File
File diff suppressed because it is too large Load Diff
+7832
View File
File diff suppressed because it is too large Load Diff
+88
View File
@@ -0,0 +1,88 @@
// ------------------------------------------- //
// //
// Copied from: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/upng-js/index.d.ts
// //
// ------------------------------------------- //
// Type definitions for upng-js 2.1
// Project: https://github.com/photopea/UPNG.js
// Definitions by: York Yao <https://github.com/plantain-00>, Sophie Kirschner <https://github.com/pineapplemachine>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface ImageFrameRect {
x: number;
y: number;
width: number;
height: number;
}
export interface ImageFrame {
rect: ImageFrameRect;
delay: number;
dispose: number;
blend: number;
}
export interface ImageTabACTL {
num_frames: number;
num_plays: number;
}
export interface ImageTabText {
[key: string]: string;
}
export interface ImageTabs {
acTL?: ImageTabACTL;
pHYs?: number[];
cHRM?: number[];
tEXt?: ImageTabText;
iTXt?: ImageTabText;
PLTE?: number[];
hIST?: number[];
tRNS?: number | number[]; // Depends on ctype
gAMA?: number;
sRGB?: number;
bKGD?: number | number[]; // Depends on ctype
}
export interface Image {
width: number;
height: number;
depth: number;
ctype: number;
frames: ImageFrame[];
tabs: ImageTabs;
data: ArrayBuffer;
}
export interface QuantizeResult {
abuf: ArrayBuffer;
inds: Uint8Array;
// Type is complicated and I am too lazy to work it out right now, sorry!
plte: any[];
}
export function encode(
imgs: ArrayBuffer[],
w: number,
h: number,
cnum: number,
dels?: number[],
): ArrayBuffer;
export function encodeLL(
imgs: ArrayBuffer[],
w: number,
h: number,
cc: number,
ac: number,
depth: number,
dels?: number[],
): ArrayBuffer;
export function decode(buffer: ArrayBuffer): Image;
export function toRGBA8(out: Image): ArrayBuffer[];
export function quantize(data: ArrayBuffer, psize: number): QuantizeResult;
+54
View File
@@ -0,0 +1,54 @@
{
"name": "@pdf-lib/upng",
"license": "MIT",
"version": "1.0.1",
"description": "Small, fast and advanced PNG / APNG encoder and decoder",
"main": "cjs/UPNG.js",
"unpkg": "dist/UPNG.min.js",
"module": "UPNG.js",
"types": "index.d.ts",
"files": [
"cjs/",
"dist/",
"UPNG.js",
"index.d.ts",
"LICENSE.md",
"package.json",
"README.md",
"yarn.lock"
],
"scripts": {
"build": "yarn build:cjs && yarn build:umd && yarn build:umd:min",
"build:cjs": "babel --plugins @babel/plugin-transform-modules-commonjs --out-dir cjs UPNG.js",
"build:umd": "rollup --config rollup.config.js --file dist/UPNG.js",
"build:umd:min": "rollup --config rollup.config.js --file dist/UPNG.min.js --environment MINIFY"
},
"repository": {
"type": "git",
"url": "https://github.com/Hopding/upng"
},
"author": "photopea (https://github.com/photopea)",
"contributors": [
"Andrew Dillon (https://github.com/Hopding)",
"Scimonster (https://github.com/Scimonster)"
],
"bugs": "https://github.com/Hopding/upng/issues",
"keywords": [
"png",
"apng",
"image",
"conversion"
],
"dependencies": {
"pako": "^1.0.10"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.4",
"@babel/plugin-transform-modules-commonjs": "^7.8.3",
"@rollup/plugin-commonjs": "^11.0.0",
"@rollup/plugin-node-resolve": "^7.1.1",
"rollup": "^1.31.1",
"rollup-plugin-terser": "^5.1.3"
}
}
+1423
View File
File diff suppressed because it is too large Load Diff
+201
View File
@@ -0,0 +1,201 @@
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 2024 SWC contributors.
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.
+4
View File
@@ -0,0 +1,4 @@
{
"main": "../../cjs/_apply_decorated_descriptor.cjs",
"module": "../../esm/_apply_decorated_descriptor.js"
}
+4
View File
@@ -0,0 +1,4 @@
{
"main": "../../cjs/_apply_decs_2203_r.cjs",
"module": "../../esm/_apply_decs_2203_r.js"
}
+4
View File
@@ -0,0 +1,4 @@
{
"main": "../../cjs/_apply_decs_2311.cjs",
"module": "../../esm/_apply_decs_2311.js"
}
+4
View File
@@ -0,0 +1,4 @@
{
"main": "../../cjs/_array_like_to_array.cjs",
"module": "../../esm/_array_like_to_array.js"
}
+4
View File
@@ -0,0 +1,4 @@
{
"main": "../../cjs/_array_with_holes.cjs",
"module": "../../esm/_array_with_holes.js"
}
+4
View File
@@ -0,0 +1,4 @@
{
"main": "../../cjs/_array_without_holes.cjs",
"module": "../../esm/_array_without_holes.js"
}
+4
View File
@@ -0,0 +1,4 @@
{
"main": "../../cjs/_assert_this_initialized.cjs",
"module": "../../esm/_assert_this_initialized.js"
}
+4
View File
@@ -0,0 +1,4 @@
{
"main": "../../cjs/_async_generator.cjs",
"module": "../../esm/_async_generator.js"
}
+4
View File
@@ -0,0 +1,4 @@
{
"main": "../../cjs/_async_generator_delegate.cjs",
"module": "../../esm/_async_generator_delegate.js"
}
+4
View File
@@ -0,0 +1,4 @@
{
"main": "../../cjs/_async_iterator.cjs",
"module": "../../esm/_async_iterator.js"
}
+4
View File
@@ -0,0 +1,4 @@
{
"main": "../../cjs/_async_to_generator.cjs",
"module": "../../esm/_async_to_generator.js"
}
+4
View File
@@ -0,0 +1,4 @@
{
"main": "../../cjs/_await_async_generator.cjs",
"module": "../../esm/_await_async_generator.js"
}
+4
View File
@@ -0,0 +1,4 @@
{
"main": "../../cjs/_await_value.cjs",
"module": "../../esm/_await_value.js"
}
+4
View File
@@ -0,0 +1,4 @@
{
"main": "../../cjs/_call_super.cjs",
"module": "../../esm/_call_super.js"
}
@@ -0,0 +1,4 @@
{
"main": "../../cjs/_check_private_redeclaration.cjs",
"module": "../../esm/_check_private_redeclaration.js"
}
@@ -0,0 +1,4 @@
{
"main": "../../cjs/_class_apply_descriptor_destructure.cjs",
"module": "../../esm/_class_apply_descriptor_destructure.js"
}

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