@patterkit/ops 0.3.3 → 0.3.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/index.js +30 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1360,6 +1360,7 @@ async function runReportXlsx(data) {
|
|
|
1360
1360
|
const totalRow = scenes.addRow(sceneRow("TOTAL", totals));
|
|
1361
1361
|
totalRow.font = { bold: true };
|
|
1362
1362
|
scenes.getRow(1).font = { bold: true };
|
|
1363
|
+
scenes.views = [{ state: "frozen", ySplit: 1 }];
|
|
1363
1364
|
const chars = wb.addWorksheet("Characters");
|
|
1364
1365
|
chars.columns = [
|
|
1365
1366
|
{ header: "Character", key: "character", width: 20 },
|
|
@@ -1378,6 +1379,7 @@ async function runReportXlsx(data) {
|
|
|
1378
1379
|
});
|
|
1379
1380
|
}
|
|
1380
1381
|
chars.getRow(1).font = { bold: true };
|
|
1382
|
+
chars.views = [{ state: "frozen", ySplit: 1 }];
|
|
1381
1383
|
if (data.locales.length > 0) {
|
|
1382
1384
|
const loc = wb.addWorksheet("Localisation");
|
|
1383
1385
|
loc.columns = [
|
|
@@ -1389,6 +1391,7 @@ async function runReportXlsx(data) {
|
|
|
1389
1391
|
];
|
|
1390
1392
|
for (const l of data.locales) loc.addRow(l);
|
|
1391
1393
|
loc.getRow(1).font = { bold: true };
|
|
1394
|
+
loc.views = [{ state: "frozen", ySplit: 1 }];
|
|
1392
1395
|
}
|
|
1393
1396
|
if (data.estimating && data.coverage.estimated > 0) {
|
|
1394
1397
|
const plan = wb.addWorksheet("Estimates");
|
|
@@ -1401,6 +1404,7 @@ async function runReportXlsx(data) {
|
|
|
1401
1404
|
const coverageRow = plan.addRow({ name: `coverage: ${data.coverage.estimated}/${data.coverage.totalScenes} scenes estimated` });
|
|
1402
1405
|
coverageRow.font = { italic: true };
|
|
1403
1406
|
plan.getRow(1).font = { bold: true };
|
|
1407
|
+
plan.views = [{ state: "frozen", ySplit: 1 }];
|
|
1404
1408
|
}
|
|
1405
1409
|
return Buffer.from(await wb.xlsx.writeBuffer());
|
|
1406
1410
|
}
|
|
@@ -1735,6 +1739,7 @@ async function catalogToXlsx(catalog) {
|
|
|
1735
1739
|
{ header: "Gender", key: "gender", width: 12 }
|
|
1736
1740
|
];
|
|
1737
1741
|
ws.getRow(1).font = { bold: true };
|
|
1742
|
+
ws.views = [{ state: "frozen", ySplit: 1 }];
|
|
1738
1743
|
for (const e of entries) {
|
|
1739
1744
|
ws.addRow({
|
|
1740
1745
|
id: e.id,
|
|
@@ -1865,6 +1870,7 @@ async function voiceScriptToXlsx(data) {
|
|
|
1865
1870
|
{ header: "Status", key: "status", width: 12 }
|
|
1866
1871
|
];
|
|
1867
1872
|
ws.getRow(1).font = { bold: true };
|
|
1873
|
+
ws.views = [{ state: "frozen", ySplit: 1 }];
|
|
1868
1874
|
for (const l of data.lines) {
|
|
1869
1875
|
const row = ws.addRow({
|
|
1870
1876
|
scope: l.scope,
|
|
@@ -1966,7 +1972,7 @@ function targetLabel(to, sceneOf, blockTrail) {
|
|
|
1966
1972
|
function gameEventLabel(beat) {
|
|
1967
1973
|
const gd = beat.gameData;
|
|
1968
1974
|
if (gd && typeof gd === "object") {
|
|
1969
|
-
const parts = Object.entries(gd).
|
|
1975
|
+
const parts = Object.entries(gd).map(([k, v]) => {
|
|
1970
1976
|
const val = v == null ? "" : typeof v === "object" ? JSON.stringify(v) : String(v);
|
|
1971
1977
|
return val === "" ? k : `${k}: ${val}`;
|
|
1972
1978
|
});
|
|
@@ -2194,7 +2200,7 @@ var isEmoji = (cp) => cp >= 126976 || cp >= 9728 && cp <= 10175;
|
|
|
2194
2200
|
async function scriptToPdf(doc) {
|
|
2195
2201
|
const { scriptFont } = await import("./script-fonts-AQNQOADI.js");
|
|
2196
2202
|
return new Promise((resolve5, reject) => {
|
|
2197
|
-
const pdf = new PDFDocument({ size: "A4", margins: { top: MARGIN, bottom: MARGIN, left: MARGIN, right: MARGIN }, info: { Title: doc.project, Author: "Patter" } });
|
|
2203
|
+
const pdf = new PDFDocument({ size: "A4", margins: { top: MARGIN, bottom: MARGIN, left: MARGIN, right: MARGIN }, info: { Title: doc.project, Author: "Patter" }, font: null });
|
|
2198
2204
|
pdf.registerFont("Serif", scriptFont("serif"));
|
|
2199
2205
|
pdf.registerFont("Serif-Bold", scriptFont("serifBold"));
|
|
2200
2206
|
pdf.registerFont("Serif-Italic", scriptFont("serifItalic"));
|
|
@@ -2291,13 +2297,12 @@ async function scriptToPdf(doc) {
|
|
|
2291
2297
|
bodyX = cueX + pdf.widthOfString(el.character.toUpperCase()) + CUE_GAP;
|
|
2292
2298
|
}
|
|
2293
2299
|
const yTop = pdf.y;
|
|
2294
|
-
pdf.fontSize(BODY);
|
|
2295
|
-
draw([...el.direction ? split(`(${el.direction}) `, "Serif-Italic", MUTED) : [], ...bodyPieces(el.runs, INK_READ)], bodyX, { width: Math.max(120, pageRight - bodyX), lineGap: LEAD });
|
|
2296
|
-
const yEnd = pdf.y;
|
|
2297
2300
|
if (el.character) {
|
|
2298
2301
|
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 });
|
|
2302
|
+
pdf.y = yTop;
|
|
2299
2303
|
}
|
|
2300
|
-
pdf.
|
|
2304
|
+
pdf.fontSize(BODY);
|
|
2305
|
+
draw([...el.direction ? split(`(${el.direction}) `, "Serif-Italic", MUTED) : [], ...bodyPieces(el.runs, INK_READ)], bodyX, { width: Math.max(120, pageRight - bodyX), lineGap: LEAD });
|
|
2301
2306
|
break;
|
|
2302
2307
|
}
|
|
2303
2308
|
case "narration":
|
|
@@ -2321,21 +2326,29 @@ async function scriptToPdf(doc) {
|
|
|
2321
2326
|
const tag = el.tag ? el.tag.toUpperCase() : "";
|
|
2322
2327
|
const tagW = tag ? pdf.font("Sans").fontSize(7.5).widthOfString(tag) + 8 : 0;
|
|
2323
2328
|
const yStart = pdf.y;
|
|
2324
|
-
|
|
2325
|
-
draw([...split("\u25C7 ", "Serif", ACCENT), ...bodyPieces(el.runs, INK)], ox, { width: Math.max(80, pageRight - ox - tagW), indent: -HANG2, lineGap: LEAD });
|
|
2326
|
-
const yEnd = pdf.y;
|
|
2327
|
-
if (tag && yEnd >= yStart) {
|
|
2329
|
+
if (tag) {
|
|
2328
2330
|
pdf.font("Sans").fontSize(7.5).fillColor(MUTED).text(tag, pageRight - tagW, yStart, { width: tagW, align: "right", lineBreak: false });
|
|
2329
|
-
pdf.y =
|
|
2331
|
+
pdf.y = yStart;
|
|
2330
2332
|
}
|
|
2333
|
+
pdf.fontSize(BODY);
|
|
2334
|
+
draw([...split("\u25C7 ", "Serif", ACCENT), ...bodyPieces(el.runs, INK)], ox, { width: Math.max(80, pageRight - ox - tagW), indent: -HANG2, lineGap: LEAD });
|
|
2331
2335
|
break;
|
|
2332
2336
|
}
|
|
2333
2337
|
case "jump":
|
|
2334
2338
|
drawRight(split(`\u21AA ${el.text}`, "Sans-Bold", ACCENT), 9.5);
|
|
2335
2339
|
break;
|
|
2336
|
-
case "gameEvent":
|
|
2337
|
-
|
|
2340
|
+
case "gameEvent": {
|
|
2341
|
+
const pieces = split(`\u2699 ${el.text}`, "Mono", ACCENT);
|
|
2342
|
+
pdf.fontSize(9);
|
|
2343
|
+
let total = 0;
|
|
2344
|
+
for (const p of pieces) {
|
|
2345
|
+
pdf.font(p.font);
|
|
2346
|
+
total += pdf.widthOfString(p.text);
|
|
2347
|
+
}
|
|
2348
|
+
if (total <= pageRight - cx) drawRight(pieces, 9);
|
|
2349
|
+
else draw(pieces, cx, { width: pageRight - cx });
|
|
2338
2350
|
break;
|
|
2351
|
+
}
|
|
2339
2352
|
}
|
|
2340
2353
|
};
|
|
2341
2354
|
const leadOf = (k) => k === "scene" ? 24 : k === "block" ? 16 : k === "group" ? 13 : k === "else" ? 9 : 0;
|
|
@@ -2349,10 +2362,12 @@ async function scriptToPdf(doc) {
|
|
|
2349
2362
|
const sameNext = sid !== void 0 && next !== void 0 && "snippet" in next && next.snippet === sid;
|
|
2350
2363
|
if (el.kind === "scene") ensure(90);
|
|
2351
2364
|
else if (el.kind === "block") ensure(70);
|
|
2365
|
+
else ensure(leadOf(el.kind) + BODY + LEAD + 14);
|
|
2352
2366
|
pdf.y += leadOf(el.kind);
|
|
2353
2367
|
const base = "indent" in el ? MARGIN + el.indent * INDENT_STEP : MARGIN;
|
|
2354
2368
|
const cx = base + (sid !== void 0 ? EDGE_INSET : 0);
|
|
2355
2369
|
const yTop = pdf.y;
|
|
2370
|
+
const pageBefore = pdf.page;
|
|
2356
2371
|
drawContent(el, cx);
|
|
2357
2372
|
const bottom = pdf.y;
|
|
2358
2373
|
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;
|
|
@@ -2362,7 +2377,8 @@ async function scriptToPdf(doc) {
|
|
|
2362
2377
|
curBase = "indent" in el ? el.indent : 0;
|
|
2363
2378
|
}
|
|
2364
2379
|
const ex = MARGIN + curBase * INDENT_STEP + EDGE_OFF;
|
|
2365
|
-
pdf.
|
|
2380
|
+
const top = pdf.page === pageBefore ? yTop : MARGIN;
|
|
2381
|
+
pdf.strokeColor(EDGE).lineWidth(0.75).moveTo(ex, top).lineTo(ex, bottom + (sameNext ? trail : 0)).stroke();
|
|
2366
2382
|
}
|
|
2367
2383
|
pdf.y = bottom + trail;
|
|
2368
2384
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patterkit/ops",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "The shared operations layer: every project operation (load, validate, export, format, play, ...) as a pure function, consumed by the patter CLI and Patterpad alike.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|