@patterkit/cli 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +24 -14
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -197579,7 +197579,7 @@ function targetLabel(to, sceneOf, blockTrail) {
|
|
|
197579
197579
|
function gameEventLabel(beat) {
|
|
197580
197580
|
const gd = beat.gameData;
|
|
197581
197581
|
if (gd && typeof gd === "object") {
|
|
197582
|
-
const parts = Object.entries(gd).
|
|
197582
|
+
const parts = Object.entries(gd).map(([k, v]) => {
|
|
197583
197583
|
const val = v == null ? "" : typeof v === "object" ? JSON.stringify(v) : String(v);
|
|
197584
197584
|
return val === "" ? k : `${k}: ${val}`;
|
|
197585
197585
|
});
|
|
@@ -237376,7 +237376,7 @@ var isEmoji = (cp) => cp >= 126976 || cp >= 9728 && cp <= 10175;
|
|
|
237376
237376
|
async function scriptToPdf(doc) {
|
|
237377
237377
|
const { scriptFont: scriptFont2 } = await Promise.resolve().then(() => (init_script_fonts(), script_fonts_exports));
|
|
237378
237378
|
return new Promise((resolve6, reject2) => {
|
|
237379
|
-
const pdf = new PDFDocument({ size: "A4", margins: { top: MARGIN, bottom: MARGIN, left: MARGIN, right: MARGIN }, info: { Title: doc.project, Author: "Patter" } });
|
|
237379
|
+
const pdf = new PDFDocument({ size: "A4", margins: { top: MARGIN, bottom: MARGIN, left: MARGIN, right: MARGIN }, info: { Title: doc.project, Author: "Patter" }, font: null });
|
|
237380
237380
|
pdf.registerFont("Serif", scriptFont2("serif"));
|
|
237381
237381
|
pdf.registerFont("Serif-Bold", scriptFont2("serifBold"));
|
|
237382
237382
|
pdf.registerFont("Serif-Italic", scriptFont2("serifItalic"));
|
|
@@ -237473,13 +237473,12 @@ async function scriptToPdf(doc) {
|
|
|
237473
237473
|
bodyX = cueX + pdf.widthOfString(el.character.toUpperCase()) + CUE_GAP;
|
|
237474
237474
|
}
|
|
237475
237475
|
const yTop = pdf.y;
|
|
237476
|
-
pdf.fontSize(BODY);
|
|
237477
|
-
draw([...el.direction ? split(`(${el.direction}) `, "Serif-Italic", MUTED) : [], ...bodyPieces(el.runs, INK_READ)], bodyX, { width: Math.max(120, pageRight - bodyX), lineGap: LEAD });
|
|
237478
|
-
const yEnd = pdf.y;
|
|
237479
237476
|
if (el.character) {
|
|
237480
237477
|
pdf.font("Sans-Bold").fontSize(CUE).fillColor(hex(characterColour(el.character))).text(el.character.toUpperCase(), cueX, yTop + ascentPt("Serif", BODY) - ascentPt("Sans-Bold", CUE), { lineBreak: false });
|
|
237478
|
+
pdf.y = yTop;
|
|
237481
237479
|
}
|
|
237482
|
-
pdf.
|
|
237480
|
+
pdf.fontSize(BODY);
|
|
237481
|
+
draw([...el.direction ? split(`(${el.direction}) `, "Serif-Italic", MUTED) : [], ...bodyPieces(el.runs, INK_READ)], bodyX, { width: Math.max(120, pageRight - bodyX), lineGap: LEAD });
|
|
237483
237482
|
break;
|
|
237484
237483
|
}
|
|
237485
237484
|
case "narration":
|
|
@@ -237503,21 +237502,29 @@ async function scriptToPdf(doc) {
|
|
|
237503
237502
|
const tag = el.tag ? el.tag.toUpperCase() : "";
|
|
237504
237503
|
const tagW = tag ? pdf.font("Sans").fontSize(7.5).widthOfString(tag) + 8 : 0;
|
|
237505
237504
|
const yStart = pdf.y;
|
|
237506
|
-
|
|
237507
|
-
draw([...split("\u25C7 ", "Serif", ACCENT), ...bodyPieces(el.runs, INK)], ox, { width: Math.max(80, pageRight - ox - tagW), indent: -HANG2, lineGap: LEAD });
|
|
237508
|
-
const yEnd = pdf.y;
|
|
237509
|
-
if (tag && yEnd >= yStart) {
|
|
237505
|
+
if (tag) {
|
|
237510
237506
|
pdf.font("Sans").fontSize(7.5).fillColor(MUTED).text(tag, pageRight - tagW, yStart, { width: tagW, align: "right", lineBreak: false });
|
|
237511
|
-
pdf.y =
|
|
237507
|
+
pdf.y = yStart;
|
|
237512
237508
|
}
|
|
237509
|
+
pdf.fontSize(BODY);
|
|
237510
|
+
draw([...split("\u25C7 ", "Serif", ACCENT), ...bodyPieces(el.runs, INK)], ox, { width: Math.max(80, pageRight - ox - tagW), indent: -HANG2, lineGap: LEAD });
|
|
237513
237511
|
break;
|
|
237514
237512
|
}
|
|
237515
237513
|
case "jump":
|
|
237516
237514
|
drawRight(split(`\u21AA ${el.text}`, "Sans-Bold", ACCENT), 9.5);
|
|
237517
237515
|
break;
|
|
237518
|
-
case "gameEvent":
|
|
237519
|
-
|
|
237516
|
+
case "gameEvent": {
|
|
237517
|
+
const pieces = split(`\u2699 ${el.text}`, "Mono", ACCENT);
|
|
237518
|
+
pdf.fontSize(9);
|
|
237519
|
+
let total = 0;
|
|
237520
|
+
for (const p of pieces) {
|
|
237521
|
+
pdf.font(p.font);
|
|
237522
|
+
total += pdf.widthOfString(p.text);
|
|
237523
|
+
}
|
|
237524
|
+
if (total <= pageRight - cx2) drawRight(pieces, 9);
|
|
237525
|
+
else draw(pieces, cx2, { width: pageRight - cx2 });
|
|
237520
237526
|
break;
|
|
237527
|
+
}
|
|
237521
237528
|
}
|
|
237522
237529
|
};
|
|
237523
237530
|
const leadOf = (k) => k === "scene" ? 24 : k === "block" ? 16 : k === "group" ? 13 : k === "else" ? 9 : 0;
|
|
@@ -237531,10 +237538,12 @@ async function scriptToPdf(doc) {
|
|
|
237531
237538
|
const sameNext = sid !== void 0 && next !== void 0 && "snippet" in next && next.snippet === sid;
|
|
237532
237539
|
if (el.kind === "scene") ensure2(90);
|
|
237533
237540
|
else if (el.kind === "block") ensure2(70);
|
|
237541
|
+
else ensure2(leadOf(el.kind) + BODY + LEAD + 14);
|
|
237534
237542
|
pdf.y += leadOf(el.kind);
|
|
237535
237543
|
const base = "indent" in el ? MARGIN + el.indent * INDENT_STEP : MARGIN;
|
|
237536
237544
|
const cx2 = base + (sid !== void 0 ? EDGE_INSET : 0);
|
|
237537
237545
|
const yTop = pdf.y;
|
|
237546
|
+
const pageBefore = pdf.page;
|
|
237538
237547
|
drawContent(el, cx2);
|
|
237539
237548
|
const bottom = pdf.y;
|
|
237540
237549
|
const trail = el.kind === "condition" ? TIGHT : el.kind === "scene" ? 12 : el.kind === "block" ? 11 : el.kind === "group" ? 7 : el.kind === "else" ? 4 : sid !== void 0 ? sameNext ? WITHIN2 : BETWEEN : BEAT;
|
|
@@ -237544,7 +237553,8 @@ async function scriptToPdf(doc) {
|
|
|
237544
237553
|
curBase = "indent" in el ? el.indent : 0;
|
|
237545
237554
|
}
|
|
237546
237555
|
const ex = MARGIN + curBase * INDENT_STEP + EDGE_OFF;
|
|
237547
|
-
pdf.
|
|
237556
|
+
const top = pdf.page === pageBefore ? yTop : MARGIN;
|
|
237557
|
+
pdf.strokeColor(EDGE).lineWidth(0.75).moveTo(ex, top).lineTo(ex, bottom + (sameNext ? trail : 0)).stroke();
|
|
237548
237558
|
}
|
|
237549
237559
|
pdf.y = bottom + trail;
|
|
237550
237560
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patterkit/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "The `patter` CLI: validate, format, export, and play a Patter project.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@patterkit/core": "0.2.0",
|
|
33
|
-
"@patterkit/ops": "0.3.
|
|
33
|
+
"@patterkit/ops": "0.3.5",
|
|
34
34
|
"@wildwinter/simple-vc-lib": "^0.4.1"
|
|
35
35
|
}
|
|
36
36
|
}
|