gutterpress 0.11.20-alpha.3 → 0.11.20-alpha.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/api/index.js +2 -2
- package/dist/{build-a8ycsg80.js → build-8ffhvydf.js} +4 -4
- package/dist/{cli-hn9pk0hp.js → cli-553ce1d4.js} +1 -1
- package/dist/{cli-y9bcya7r.js → cli-6xym15vm.js} +2 -2
- package/dist/{cli-x4p99w8d.js → cli-cyej3p9v.js} +83 -41
- package/dist/{cli-9k2tb493.js → cli-sc5t7c74.js} +116 -43
- package/dist/cli.js +12 -12
- package/dist/{doctor-wbjkrcpc.js → doctor-gyes0hxt.js} +2 -2
- package/dist/engine/compiler/build.d.ts +1 -1
- package/dist/engine/shared/margin-box-support.d.ts +2 -2
- package/dist/engine/shared/pin-edges.d.ts +127 -0
- package/dist/engine/shared/print-area.d.ts +73 -0
- package/dist/{engine-yxnnp3hx.js → engine-4rkhv5ga.js} +1 -1
- package/dist/{engine-fdtv01a2.js → engine-5fw55dfb.js} +2 -2
- package/dist/{ext-pesyrs68.js → ext-x61yptd1.js} +4 -4
- package/dist/{gutterpress-agent-cazqstr1.js → gutterpress-agent-yvd8w8my.js} +79 -13
- package/dist/{gutterpress-viewer-1yse8cx3.js → gutterpress-viewer-w7njnkj7.js} +257 -71
- package/dist/{index-tjvrchxj.js → index-bta8hc2q.js} +225 -152
- package/dist/{index-zagagnwq.js → index-crys9951.js} +3 -3
- package/dist/{index-r87y7wzw.js → index-yw16cfm8.js} +82 -40
- package/dist/index.js +3 -3
- package/dist/lib/extension-manifest.d.ts +13 -0
- package/dist/lib/markdown/assemble.d.ts +13 -3
- package/dist/lib/markdown/gutterpress-css.d.ts +49 -33
- package/dist/lib/markdown/index.d.ts +5 -0
- package/dist/{manifest.schema-c9x8912a.json → manifest.schema-c4wfpg6g.json} +9 -3
- package/dist/{new-8yah8z91.js → new-87dqcxtn.js} +4 -4
- package/dist/{preflight-8ccx4kdc.js → preflight-nb4wndqf.js} +4 -4
- package/dist/preview/file-watcher.d.ts +5 -10
- package/dist/{preview-w7v9w36q.js → preview-7bcr5j2p.js} +4 -4
- package/dist/{publish-g5nh5myh.js → publish-4qfm5ch9.js} +4 -4
- package/dist/render.js +73 -13
- package/dist/schema/manifest.types.d.ts +25 -9
- package/dist/{validate-1yh59x0x.js → validate-dzht9qxk.js} +4 -4
- package/package.json +1 -1
- package/dist/engine/shared/flush.d.ts +0 -59
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The project's print area: the manifest's `page` block, carried into every
|
|
3
|
+
* assembled book (preview, build, publish) as ONE
|
|
4
|
+
* `<meta name="gp-print-area">` by the markdown assembly
|
|
5
|
+
* (lib/markdown/assemble.ts) and read back here by everything that needs it:
|
|
6
|
+
* the preview's print overlays (viewer/overlay.ts) and both engines' pinned
|
|
7
|
+
* art (pin-edges.ts — a pin sits on the printer's art-safe line).
|
|
8
|
+
*
|
|
9
|
+
* Only the manifest feeds it — `page.width` x `page.height` (the sheet),
|
|
10
|
+
* `page.bleed` (a bleed the sheet already contains on the top, bottom and
|
|
11
|
+
* OUTER edge; the binding edge has none, as DriveThruRPG cuts it),
|
|
12
|
+
* `page.safe` (the TEXT rule: its inset from the trim on every edge),
|
|
13
|
+
* `page.artSafe` (the ART rule: its inset on the top, bottom and outer edge;
|
|
14
|
+
* absent = `safe`) and `page.gutter` (the binding edge's inset, for text and
|
|
15
|
+
* art alike; absent = `safe`) — plus the preset's id and the printer spec it
|
|
16
|
+
* follows, which only word what the overlay finds.
|
|
17
|
+
* No book or plugin CSS feeds it: not the `@page` margins (they are where the
|
|
18
|
+
* author put the TEXT, which is not the printer's safe area), not
|
|
19
|
+
* `@page { bleed }`.
|
|
20
|
+
*
|
|
21
|
+
* The meta is metadata: it changes nothing a browser renders on its own.
|
|
22
|
+
* Node-safe: the writer is pure, and the reader takes the document it reads.
|
|
23
|
+
*/
|
|
24
|
+
/** The project's page geometry, in pt — the manifest's `page` block. */
|
|
25
|
+
export interface PrintArea {
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
/** in-sheet bleed on the top, bottom and outer edge; 0 = none */
|
|
29
|
+
bleed: number;
|
|
30
|
+
/** the TEXT rule: inset from the trim on every edge, the binding edge too unless `gutter` is set; 0 = none */
|
|
31
|
+
safe: number;
|
|
32
|
+
/** the ART rule: inset on the top, bottom and outer edge (the binding edge takes `gutter`) */
|
|
33
|
+
artSafe: number;
|
|
34
|
+
/** the binding allowance: inset from the trim at the binding edge, for text and art alike; absent in the manifest = `safe` */
|
|
35
|
+
gutter: number;
|
|
36
|
+
/** the manifest's preset id, and the printer spec it follows: they only word what is found */
|
|
37
|
+
preset?: string;
|
|
38
|
+
spec?: {
|
|
39
|
+
label: string;
|
|
40
|
+
url: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** Which side of the spread a page is: page 1 is a recto, so every odd page is one. */
|
|
44
|
+
export type PageSide = "recto" | "verso";
|
|
45
|
+
/** What a host knows from its resolved config: the `page` block, the preset and its spec. */
|
|
46
|
+
export interface PrintAreaSource {
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
bleed?: number;
|
|
50
|
+
safe?: number;
|
|
51
|
+
artSafe?: number;
|
|
52
|
+
gutter?: number;
|
|
53
|
+
preset?: string;
|
|
54
|
+
spec?: {
|
|
55
|
+
label: string;
|
|
56
|
+
url: string;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The `<meta>` tag for one book. An unset bleed or text rule is written as 0,
|
|
61
|
+
* never left out; an unset art rule or gutter stays out (the reader takes each
|
|
62
|
+
* as `safe`).
|
|
63
|
+
* Anything else the config's `page` block holds (`tolerance`) is not part of it.
|
|
64
|
+
*/
|
|
65
|
+
export declare function printAreaMeta(page: PrintAreaSource): string;
|
|
66
|
+
/** The one DOM call the reader makes: a `Document` satisfies it. */
|
|
67
|
+
export interface MetaDocument {
|
|
68
|
+
querySelector(selector: string): {
|
|
69
|
+
getAttribute(name: string): string | null;
|
|
70
|
+
} | null;
|
|
71
|
+
}
|
|
72
|
+
/** The book's print area from its `<meta name="gp-print-area">`; `null` without one. */
|
|
73
|
+
export declare function printAreaFromMeta(doc: MetaDocument): PrintArea | null;
|
|
@@ -12,17 +12,17 @@ import {
|
|
|
12
12
|
searchNpmExtensions,
|
|
13
13
|
setExtensionEnabled,
|
|
14
14
|
updateExtensions
|
|
15
|
-
} from "./cli-
|
|
16
|
-
import"./cli-
|
|
15
|
+
} from "./cli-sc5t7c74.js";
|
|
16
|
+
import"./cli-6xym15vm.js";
|
|
17
17
|
import {
|
|
18
18
|
UsageError,
|
|
19
19
|
exitForUsage,
|
|
20
20
|
rejectExtraPositionals,
|
|
21
21
|
rejectUnknownFlags,
|
|
22
22
|
resolveProjectDir
|
|
23
|
-
} from "./cli-
|
|
23
|
+
} from "./cli-553ce1d4.js";
|
|
24
24
|
import"./cli-ht1bcqdd.js";
|
|
25
|
-
import"./cli-
|
|
25
|
+
import"./cli-cyej3p9v.js";
|
|
26
26
|
import {
|
|
27
27
|
EXIT_CODES
|
|
28
28
|
} from "./cli-46ycxe6r.js";
|
|
@@ -43,11 +43,13 @@
|
|
|
43
43
|
xrefSites: () => xrefSites,
|
|
44
44
|
targetTexts: () => targetTexts,
|
|
45
45
|
stringSources: () => stringSources,
|
|
46
|
+
setPinGeometry: () => setPinGeometry,
|
|
47
|
+
setPinFurniture: () => setPinFurniture,
|
|
46
48
|
setGenerated: () => setGenerated,
|
|
47
|
-
|
|
49
|
+
printArea: () => printArea,
|
|
50
|
+
pinRoots: () => pinRoots,
|
|
48
51
|
instrument: () => instrument,
|
|
49
52
|
forcedBreakSites: () => forcedBreakSites,
|
|
50
|
-
flushRoots: () => flushRoots,
|
|
51
53
|
fillLeaders: () => fillLeaders,
|
|
52
54
|
counterResetSites: () => counterResetSites,
|
|
53
55
|
collectCss: () => collectCss,
|
|
@@ -302,6 +304,52 @@
|
|
|
302
304
|
return evaluateContent(parseContent(value), ctx);
|
|
303
305
|
}
|
|
304
306
|
|
|
307
|
+
// src/engine/shared/pin-edges.ts
|
|
308
|
+
var PIN_EDGES = ["top", "right", "bottom", "left"];
|
|
309
|
+
var EDGE_PIN_SELECTOR = PIN_EDGES.map((edge) => `.gp-pin.gp-${edge}`).join(", ");
|
|
310
|
+
function pinEdgesIn(root) {
|
|
311
|
+
const pins = Array.from(root.querySelectorAll(EDGE_PIN_SELECTOR)).filter((pin) => pin.offsetParent === root);
|
|
312
|
+
return PIN_EDGES.filter((edge) => pins.some((pin) => pin.classList.contains(`gp-${edge}`)));
|
|
313
|
+
}
|
|
314
|
+
function pinKey(edges) {
|
|
315
|
+
return PIN_EDGES.filter((e) => edges.includes(e)).map((e) => e[0]).join("");
|
|
316
|
+
}
|
|
317
|
+
function paddingOf(cs) {
|
|
318
|
+
return {
|
|
319
|
+
top: parseFloat(cs.paddingTop) || 0,
|
|
320
|
+
right: parseFloat(cs.paddingRight) || 0,
|
|
321
|
+
bottom: parseFloat(cs.paddingBottom) || 0,
|
|
322
|
+
left: parseFloat(cs.paddingLeft) || 0
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// src/engine/shared/print-area.ts
|
|
327
|
+
function printAreaFromMeta(doc) {
|
|
328
|
+
const raw = doc.querySelector('meta[name="gp-print-area"]')?.getAttribute("content");
|
|
329
|
+
if (!raw)
|
|
330
|
+
return null;
|
|
331
|
+
try {
|
|
332
|
+
const v = JSON.parse(raw);
|
|
333
|
+
const n = (x) => typeof x === "number" && Number.isFinite(x) && x > 0 ? x : 0;
|
|
334
|
+
if (!n(v.width) || !n(v.height))
|
|
335
|
+
return null;
|
|
336
|
+
const safe = n(v.safe);
|
|
337
|
+
const spec = v.spec && typeof v.spec.label === "string" && typeof v.spec.url === "string" && /^https?:\/\//i.test(v.spec.url) ? v.spec : undefined;
|
|
338
|
+
return {
|
|
339
|
+
width: n(v.width),
|
|
340
|
+
height: n(v.height),
|
|
341
|
+
bleed: n(v.bleed),
|
|
342
|
+
safe,
|
|
343
|
+
artSafe: typeof v.artSafe === "number" ? n(v.artSafe) : safe,
|
|
344
|
+
gutter: typeof v.gutter === "number" ? n(v.gutter) : safe,
|
|
345
|
+
preset: typeof v.preset === "string" ? v.preset : undefined,
|
|
346
|
+
spec
|
|
347
|
+
};
|
|
348
|
+
} catch {
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
305
353
|
// src/engine/compiler/agent.ts
|
|
306
354
|
var uid = 0;
|
|
307
355
|
function ensureAnchor(el) {
|
|
@@ -559,29 +607,45 @@
|
|
|
559
607
|
addCss("gp-generated-content", css);
|
|
560
608
|
return entries.length;
|
|
561
609
|
}
|
|
562
|
-
function
|
|
610
|
+
function pinRoots() {
|
|
563
611
|
const out = [];
|
|
564
612
|
for (const root of Array.from(document.querySelectorAll(".page, .spread"))) {
|
|
565
|
-
const edges =
|
|
613
|
+
const edges = pinEdgesIn(root);
|
|
566
614
|
if (!edges.length)
|
|
567
615
|
continue;
|
|
568
|
-
const
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
|
|
616
|
+
const cs = getComputedStyle(root);
|
|
617
|
+
const padding = paddingOf(cs);
|
|
618
|
+
const key = `${cs.page === "auto" ? "" : cs.page}|${pinKey(edges)}|${edges.map((e) => padding[e]).join(",")}`;
|
|
619
|
+
root.dataset.gpPin = key;
|
|
620
|
+
out.push({ id: ensureAnchor(root), page: cs.page, edges, padding, key });
|
|
572
621
|
}
|
|
573
622
|
return out;
|
|
574
623
|
}
|
|
575
|
-
function
|
|
624
|
+
function printArea() {
|
|
625
|
+
return printAreaFromMeta(document);
|
|
626
|
+
}
|
|
627
|
+
function setPinGeometry(items) {
|
|
628
|
+
let set = 0;
|
|
629
|
+
for (const item of items) {
|
|
630
|
+
const host = anchorHost(item.id);
|
|
631
|
+
if (!host)
|
|
632
|
+
continue;
|
|
633
|
+
for (const [prop, value] of Object.entries(item.style))
|
|
634
|
+
host.style.setProperty(prop, value);
|
|
635
|
+
set++;
|
|
636
|
+
}
|
|
637
|
+
return set;
|
|
638
|
+
}
|
|
639
|
+
function setPinFurniture(items) {
|
|
576
640
|
let painted = 0;
|
|
577
641
|
for (const item of items) {
|
|
578
642
|
const host = anchorHost(item.id);
|
|
579
643
|
if (!host)
|
|
580
644
|
continue;
|
|
581
|
-
let layer = host.querySelector(":scope > .gp-
|
|
645
|
+
let layer = host.querySelector(":scope > .gp-pin-furniture");
|
|
582
646
|
if (!layer) {
|
|
583
647
|
layer = document.createElement("div");
|
|
584
|
-
layer.className = "gp-
|
|
648
|
+
layer.className = "gp-pin-furniture";
|
|
585
649
|
layer.setAttribute("aria-hidden", "true");
|
|
586
650
|
layer.setAttribute("style", "position:absolute;inset:0;pointer-events:none;z-index:10;");
|
|
587
651
|
host.appendChild(layer);
|
|
@@ -616,8 +680,10 @@
|
|
|
616
680
|
instrument,
|
|
617
681
|
addCss,
|
|
618
682
|
setGenerated,
|
|
619
|
-
|
|
620
|
-
|
|
683
|
+
pinRoots,
|
|
684
|
+
printArea,
|
|
685
|
+
setPinGeometry,
|
|
686
|
+
setPinFurniture
|
|
621
687
|
};
|
|
622
688
|
if (typeof window !== "undefined")
|
|
623
689
|
window.__gp = api;
|