postext 1.91.2 → 1.93.0
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/__tests__/composed/corpus.test.js +3 -1
- package/dist/__tests__/composed/corpus.test.js.map +1 -1
- package/dist/__tests__/exports.test.js +96 -0
- package/dist/__tests__/exports.test.js.map +1 -1
- package/dist/__tests__/paint/cropMarks.test.js +31 -0
- package/dist/__tests__/paint/cropMarks.test.js.map +1 -1
- package/dist/__tests__/pipeline/pages/reliefPlates.test.d.ts +2 -0
- package/dist/__tests__/pipeline/pages/reliefPlates.test.d.ts.map +1 -0
- package/dist/__tests__/pipeline/pages/reliefPlates.test.js +92 -0
- package/dist/__tests__/pipeline/pages/reliefPlates.test.js.map +1 -0
- package/dist/__tests__/production/compose.test.d.ts +2 -0
- package/dist/__tests__/production/compose.test.d.ts.map +1 -0
- package/dist/__tests__/production/compose.test.js +178 -0
- package/dist/__tests__/production/compose.test.js.map +1 -0
- package/dist/__tests__/production/config.test.d.ts +2 -0
- package/dist/__tests__/production/config.test.d.ts.map +1 -0
- package/dist/__tests__/production/config.test.js +83 -0
- package/dist/__tests__/production/config.test.js.map +1 -0
- package/dist/__tests__/production/cover.test.d.ts +2 -0
- package/dist/__tests__/production/cover.test.d.ts.map +1 -0
- package/dist/__tests__/production/cover.test.js +273 -0
- package/dist/__tests__/production/cover.test.js.map +1 -0
- package/dist/__tests__/production/coverLayers.test.d.ts +2 -0
- package/dist/__tests__/production/coverLayers.test.d.ts.map +1 -0
- package/dist/__tests__/production/coverLayers.test.js +198 -0
- package/dist/__tests__/production/coverLayers.test.js.map +1 -0
- package/dist/__tests__/production/coverOutputs.test.d.ts +2 -0
- package/dist/__tests__/production/coverOutputs.test.d.ts.map +1 -0
- package/dist/__tests__/production/coverOutputs.test.js +104 -0
- package/dist/__tests__/production/coverOutputs.test.js.map +1 -0
- package/dist/__tests__/production/coverTextBoxes.test.d.ts +2 -0
- package/dist/__tests__/production/coverTextBoxes.test.d.ts.map +1 -0
- package/dist/__tests__/production/coverTextBoxes.test.js +127 -0
- package/dist/__tests__/production/coverTextBoxes.test.js.map +1 -0
- package/dist/__tests__/production/geometry.test.d.ts +2 -0
- package/dist/__tests__/production/geometry.test.d.ts.map +1 -0
- package/dist/__tests__/production/geometry.test.js +281 -0
- package/dist/__tests__/production/geometry.test.js.map +1 -0
- package/dist/__tests__/production/mirrorBleed.test.d.ts +2 -0
- package/dist/__tests__/production/mirrorBleed.test.d.ts.map +1 -0
- package/dist/__tests__/production/mirrorBleed.test.js +129 -0
- package/dist/__tests__/production/mirrorBleed.test.js.map +1 -0
- package/dist/__tests__/production/shapes.test.d.ts +2 -0
- package/dist/__tests__/production/shapes.test.d.ts.map +1 -0
- package/dist/__tests__/production/shapes.test.js +107 -0
- package/dist/__tests__/production/shapes.test.js.map +1 -0
- package/dist/__tests__/production/sheets.test.d.ts +2 -0
- package/dist/__tests__/production/sheets.test.d.ts.map +1 -0
- package/dist/__tests__/production/sheets.test.js +153 -0
- package/dist/__tests__/production/sheets.test.js.map +1 -0
- package/dist/bundle/api.d.ts +8 -0
- package/dist/bundle/api.d.ts.map +1 -1
- package/dist/bundle/api.js +3 -0
- package/dist/bundle/api.js.map +1 -1
- package/dist/bundle/codec/files.d.ts.map +1 -1
- package/dist/bundle/codec/files.js +2 -0
- package/dist/bundle/codec/files.js.map +1 -1
- package/dist/bundle/codec/plan.d.ts +12 -0
- package/dist/bundle/codec/plan.d.ts.map +1 -1
- package/dist/bundle/codec/plan.js +12 -1
- package/dist/bundle/codec/plan.js.map +1 -1
- package/dist/bundle/codec/read.d.ts +3 -0
- package/dist/bundle/codec/read.d.ts.map +1 -1
- package/dist/bundle/codec/read.js +14 -2
- package/dist/bundle/codec/read.js.map +1 -1
- package/dist/bundle/index.d.ts +1 -1
- package/dist/bundle/index.d.ts.map +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/index.js.map +1 -1
- package/dist/bundle/manifest/locale.d.ts +3 -0
- package/dist/bundle/manifest/locale.d.ts.map +1 -1
- package/dist/bundle/manifest/locale.js +5 -0
- package/dist/bundle/manifest/locale.js.map +1 -1
- package/dist/bundle/manifest/validation.d.ts.map +1 -1
- package/dist/bundle/manifest/validation.js +4 -0
- package/dist/bundle/manifest/validation.js.map +1 -1
- package/dist/bundle/manifest.d.ts +1 -1
- package/dist/bundle/manifest.d.ts.map +1 -1
- package/dist/bundle/manifest.js +1 -1
- package/dist/bundle/manifest.js.map +1 -1
- package/dist/bundle/types.d.ts +7 -0
- package/dist/bundle/types.d.ts.map +1 -1
- package/dist/checks/configWarnings/collect.d.ts +6 -1
- package/dist/checks/configWarnings/collect.d.ts.map +1 -1
- package/dist/checks/configWarnings/collect.js +9 -1
- package/dist/checks/configWarnings/collect.js.map +1 -1
- package/dist/checks/configWarnings/cover.d.ts +18 -0
- package/dist/checks/configWarnings/cover.d.ts.map +1 -0
- package/dist/checks/configWarnings/cover.js +206 -0
- package/dist/checks/configWarnings/cover.js.map +1 -0
- package/dist/checks/configWarnings/production.d.ts +12 -0
- package/dist/checks/configWarnings/production.d.ts.map +1 -0
- package/dist/checks/configWarnings/production.js +48 -0
- package/dist/checks/configWarnings/production.js.map +1 -0
- package/dist/checks/preflight.d.ts.map +1 -1
- package/dist/checks/preflight.js +5 -0
- package/dist/checks/preflight.js.map +1 -1
- package/dist/checks/preflightFolds.d.ts +19 -0
- package/dist/checks/preflightFolds.d.ts.map +1 -0
- package/dist/checks/preflightFolds.js +81 -0
- package/dist/checks/preflightFolds.js.map +1 -0
- package/dist/checks/preflightIssues.d.ts +24 -0
- package/dist/checks/preflightIssues.d.ts.map +1 -1
- package/dist/composed/paint.d.ts +2 -1
- package/dist/composed/paint.d.ts.map +1 -1
- package/dist/composed/paint.js +3 -2
- package/dist/composed/paint.js.map +1 -1
- package/dist/defaults/bookKeys.d.ts +2 -2
- package/dist/defaults/bookKeys.d.ts.map +1 -1
- package/dist/defaults/bookKeys.js +2 -2
- package/dist/defaults/bookKeys.js.map +1 -1
- package/dist/defaults/index.d.ts +1 -1
- package/dist/defaults/index.d.ts.map +1 -1
- package/dist/defaults/index.js +1 -1
- package/dist/defaults/index.js.map +1 -1
- package/dist/defaults/output/folio.d.ts +6 -1
- package/dist/defaults/output/folio.d.ts.map +1 -1
- package/dist/defaults/output/folio.js +10 -0
- package/dist/defaults/output/folio.js.map +1 -1
- package/dist/defaults/output/production.d.ts +13 -0
- package/dist/defaults/output/production.d.ts.map +1 -0
- package/dist/defaults/output/production.js +84 -0
- package/dist/defaults/output/production.js.map +1 -0
- package/dist/defaults/page.d.ts.map +1 -1
- package/dist/defaults/page.js +4 -1
- package/dist/defaults/page.js.map +1 -1
- package/dist/defaults/structure/headerFooter/resolve.d.ts.map +1 -1
- package/dist/defaults/structure/headerFooter/resolve.js +1 -0
- package/dist/defaults/structure/headerFooter/resolve.js.map +1 -1
- package/dist/design/elementKeys.d.ts +6 -0
- package/dist/design/elementKeys.d.ts.map +1 -1
- package/dist/design/elementKeys.js +5 -5
- package/dist/design/elementKeys.js.map +1 -1
- package/dist/designs/parts.d.ts +2 -1
- package/dist/designs/parts.d.ts.map +1 -1
- package/dist/designs/parts.js +2 -1
- package/dist/designs/parts.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/paint/cropMarks.d.ts +2 -1
- package/dist/paint/cropMarks.d.ts.map +1 -1
- package/dist/paint/cropMarks.js +7 -1
- package/dist/paint/cropMarks.js.map +1 -1
- package/dist/pipeline/config.d.ts.map +1 -1
- package/dist/pipeline/config.js +9 -2
- package/dist/pipeline/config.js.map +1 -1
- package/dist/pipeline/pages/dieCuts.d.ts +2 -1
- package/dist/pipeline/pages/dieCuts.d.ts.map +1 -1
- package/dist/pipeline/pages/dieCuts.js +18 -2
- package/dist/pipeline/pages/dieCuts.js.map +1 -1
- package/dist/pipeline/pages/headerFooter/pageDecoration.d.ts.map +1 -1
- package/dist/pipeline/pages/headerFooter/pageDecoration.js +8 -3
- package/dist/pipeline/pages/headerFooter/pageDecoration.js.map +1 -1
- package/dist/pipeline/pages/headerFooter/slotLayout.d.ts +3 -2
- package/dist/pipeline/pages/headerFooter/slotLayout.d.ts.map +1 -1
- package/dist/pipeline/pages/headerFooter/slotLayout.js +1 -1
- package/dist/pipeline/pages/headerFooter/slotLayout.js.map +1 -1
- package/dist/production/barcodeSvg.d.ts +28 -0
- package/dist/production/barcodeSvg.d.ts.map +1 -0
- package/dist/production/barcodeSvg.js +64 -0
- package/dist/production/barcodeSvg.js.map +1 -0
- package/dist/production/buildCover.d.ts +104 -0
- package/dist/production/buildCover.d.ts.map +1 -0
- package/dist/production/buildCover.js +169 -0
- package/dist/production/buildCover.js.map +1 -0
- package/dist/production/catalogue.d.ts +40 -0
- package/dist/production/catalogue.d.ts.map +1 -0
- package/dist/production/catalogue.js +106 -0
- package/dist/production/catalogue.js.map +1 -0
- package/dist/production/compose.d.ts +123 -0
- package/dist/production/compose.d.ts.map +1 -0
- package/dist/production/compose.js +264 -0
- package/dist/production/compose.js.map +1 -0
- package/dist/production/config.d.ts +15 -0
- package/dist/production/config.d.ts.map +1 -0
- package/dist/production/config.js +143 -0
- package/dist/production/config.js.map +1 -0
- package/dist/production/coverArt.d.ts +74 -0
- package/dist/production/coverArt.d.ts.map +1 -0
- package/dist/production/coverArt.js +355 -0
- package/dist/production/coverArt.js.map +1 -0
- package/dist/production/coverDesign.d.ts +22 -0
- package/dist/production/coverDesign.d.ts.map +1 -0
- package/dist/production/coverDesign.js +111 -0
- package/dist/production/coverDesign.js.map +1 -0
- package/dist/production/coverLabels.d.ts +8 -0
- package/dist/production/coverLabels.d.ts.map +1 -0
- package/dist/production/coverLabels.js +23 -0
- package/dist/production/coverLabels.js.map +1 -0
- package/dist/production/coverSource.d.ts +79 -0
- package/dist/production/coverSource.d.ts.map +1 -0
- package/dist/production/coverSource.js +142 -0
- package/dist/production/coverSource.js.map +1 -0
- package/dist/production/coverTextBoxes.d.ts +68 -0
- package/dist/production/coverTextBoxes.d.ts.map +1 -0
- package/dist/production/coverTextBoxes.js +187 -0
- package/dist/production/coverTextBoxes.js.map +1 -0
- package/dist/production/exchange.d.ts +38 -0
- package/dist/production/exchange.d.ts.map +1 -0
- package/dist/production/exchange.js +146 -0
- package/dist/production/exchange.js.map +1 -0
- package/dist/production/folio.d.ts +21 -0
- package/dist/production/folio.d.ts.map +1 -0
- package/dist/production/folio.js +35 -0
- package/dist/production/folio.js.map +1 -0
- package/dist/production/geometry.d.ts +84 -0
- package/dist/production/geometry.d.ts.map +1 -0
- package/dist/production/geometry.js +220 -0
- package/dist/production/geometry.js.map +1 -0
- package/dist/production/guards.d.ts +6 -0
- package/dist/production/guards.d.ts.map +1 -0
- package/dist/production/guards.js +6 -0
- package/dist/production/guards.js.map +1 -0
- package/dist/production/index.d.ts +27 -0
- package/dist/production/index.d.ts.map +1 -0
- package/dist/production/index.js +20 -0
- package/dist/production/index.js.map +1 -0
- package/dist/production/isbn.d.ts +67 -0
- package/dist/production/isbn.d.ts.map +1 -0
- package/dist/production/isbn.js +135 -0
- package/dist/production/isbn.js.map +1 -0
- package/dist/production/measures.d.ts +30 -0
- package/dist/production/measures.d.ts.map +1 -0
- package/dist/production/measures.js +54 -0
- package/dist/production/measures.js.map +1 -0
- package/dist/production/mirrorBleed.d.ts +54 -0
- package/dist/production/mirrorBleed.d.ts.map +1 -0
- package/dist/production/mirrorBleed.js +92 -0
- package/dist/production/mirrorBleed.js.map +1 -0
- package/dist/production/shapes.d.ts +65 -0
- package/dist/production/shapes.d.ts.map +1 -0
- package/dist/production/shapes.js +313 -0
- package/dist/production/shapes.js.map +1 -0
- package/dist/production/spine.d.ts +38 -0
- package/dist/production/spine.d.ts.map +1 -0
- package/dist/production/spine.js +48 -0
- package/dist/production/spine.js.map +1 -0
- package/dist/production/svgSafe.d.ts +25 -0
- package/dist/production/svgSafe.d.ts.map +1 -0
- package/dist/production/svgSafe.js +33 -0
- package/dist/production/svgSafe.js.map +1 -0
- package/dist/production/version.d.ts +66 -0
- package/dist/production/version.d.ts.map +1 -0
- package/dist/production/version.js +68 -0
- package/dist/production/version.js.map +1 -0
- package/dist/types/config.d.ts +12 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/designCut.d.ts +13 -1
- package/dist/types/designCut.d.ts.map +1 -1
- package/dist/types/designElements.d.ts +15 -0
- package/dist/types/designElements.d.ts.map +1 -1
- package/dist/types/output/cover.d.ts +269 -0
- package/dist/types/output/cover.d.ts.map +1 -0
- package/dist/types/output/cover.js +2 -0
- package/dist/types/output/cover.js.map +1 -0
- package/dist/types/output/production.d.ts +186 -0
- package/dist/types/output/production.d.ts.map +1 -0
- package/dist/types/output/production.js +2 -0
- package/dist/types/output/production.js.map +1 -0
- package/dist/types/page.d.ts +5 -0
- package/dist/types/page.d.ts.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/util/base64.d.ts +3 -0
- package/dist/util/base64.d.ts.map +1 -0
- package/dist/util/base64.js +48 -0
- package/dist/util/base64.js.map +1 -0
- package/dist/util/png.d.ts +10 -0
- package/dist/util/png.d.ts.map +1 -0
- package/dist/util/png.js +60 -0
- package/dist/util/png.js.map +1 -0
- package/dist/util/xmlEscape.d.ts +6 -0
- package/dist/util/xmlEscape.d.ts.map +1 -0
- package/dist/util/xmlEscape.js +15 -0
- package/dist/util/xmlEscape.js.map +1 -0
- package/dist/vdt/design.d.ts +10 -1
- package/dist/vdt/design.d.ts.map +1 -1
- package/dist/vdt/design.js.map +1 -1
- package/dist/vdt/pages.d.ts +13 -0
- package/dist/vdt/pages.d.ts.map +1 -1
- package/dist/vdt.d.ts +1 -1
- package/dist/vdt.d.ts.map +1 -1
- package/dist/word/anchors/base64.d.ts +1 -2
- package/dist/word/anchors/base64.d.ts.map +1 -1
- package/dist/word/anchors/base64.js +2 -46
- package/dist/word/anchors/base64.js.map +1 -1
- package/dist/word/semantic/design/ground.d.ts.map +1 -1
- package/dist/word/semantic/design/ground.js +5 -47
- package/dist/word/semantic/design/ground.js.map +1 -1
- package/dist/word/xml.d.ts +1 -4
- package/dist/word/xml.d.ts.map +1 -1
- package/dist/word/xml.js +1 -13
- package/dist/word/xml.js.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words a cover prints of its own (#1667): the line naming the whole
|
|
3
|
+
* work's ISBN above a volume's barcode, in the book's language, as the
|
|
4
|
+
* ISBN agencies word it. A book in another language takes the English.
|
|
5
|
+
*/
|
|
6
|
+
/** The caption of the whole work's ISBN in `locale` (a BCP 47 tag). */
|
|
7
|
+
export declare function workIsbnCaption(isbn: string, locale?: string): string;
|
|
8
|
+
//# sourceMappingURL=coverLabels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverLabels.d.ts","sourceRoot":"","sources":["../../src/production/coverLabels.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAeH,uEAAuE;AACvE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAGrE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words a cover prints of its own (#1667): the line naming the whole
|
|
3
|
+
* work's ISBN above a volume's barcode, in the book's language, as the
|
|
4
|
+
* ISBN agencies word it. A book in another language takes the English.
|
|
5
|
+
*/
|
|
6
|
+
const WORK_ISBN = {
|
|
7
|
+
en: 'ISBN of the complete work',
|
|
8
|
+
es: 'ISBN obra completa',
|
|
9
|
+
ca: 'ISBN obra completa',
|
|
10
|
+
fr: 'ISBN de l’ouvrage complet',
|
|
11
|
+
it: 'ISBN opera completa',
|
|
12
|
+
de: 'ISBN Gesamtwerk',
|
|
13
|
+
pt: 'ISBN da obra completa',
|
|
14
|
+
ja: '全巻 ISBN',
|
|
15
|
+
zh: '全套书 ISBN',
|
|
16
|
+
ar: 'ردمك العمل الكامل',
|
|
17
|
+
};
|
|
18
|
+
/** The caption of the whole work's ISBN in `locale` (a BCP 47 tag). */
|
|
19
|
+
export function workIsbnCaption(isbn, locale) {
|
|
20
|
+
const lang = (locale ?? 'en').toLowerCase().split(/[-_]/)[0];
|
|
21
|
+
return `${WORK_ISBN[lang] ?? WORK_ISBN.en} ${isbn.trim()}`;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=coverLabels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverLabels.js","sourceRoot":"","sources":["../../src/production/coverLabels.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,SAAS,GAAqC;IAClD,EAAE,EAAE,2BAA2B;IAC/B,EAAE,EAAE,oBAAoB;IACxB,EAAE,EAAE,oBAAoB;IACxB,EAAE,EAAE,2BAA2B;IAC/B,EAAE,EAAE,qBAAqB;IACzB,EAAE,EAAE,iBAAiB;IACrB,EAAE,EAAE,uBAAuB;IAC3B,EAAE,EAAE,SAAS;IACb,EAAE,EAAE,UAAU;IACd,EAAE,EAAE,mBAAmB;CACxB,CAAC;AAEF,uEAAuE;AACvE,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,MAAe;IAC3D,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,CAAC;IAC9D,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cover's Markdown (#1667): a document of the book, one
|
|
3
|
+
* `:::frame{slot="…"}` per zone or text box (the back cover's blurb, a
|
|
4
|
+
* flap's biography), laid out on the cover's page template. The front and
|
|
5
|
+
* the spine the Markdown leaves empty take the book's title, subtitle and
|
|
6
|
+
* author, read from its metadata on every build (never copied into the
|
|
7
|
+
* cover), each in a paragraph style of its own the book may redefine.
|
|
8
|
+
*/
|
|
9
|
+
import type { DocumentMetadata } from '../types/content.js';
|
|
10
|
+
import type { ParagraphStyleConfig } from '../types/text/paragraphStyles.js';
|
|
11
|
+
/** The paragraph styles the front and the spine are set in when the
|
|
12
|
+
* cover's Markdown leaves them to the metadata. */
|
|
13
|
+
export declare const COVER_PARAGRAPH_STYLES: readonly ["cover-title", "cover-subtitle", "cover-author", "cover-spine"];
|
|
14
|
+
/** Something in the cover's Markdown the cover cannot lay out. */
|
|
15
|
+
export type CoverSourceIssue =
|
|
16
|
+
/** A frame names a slot the cover has not (`slots`, an endpaper has no
|
|
17
|
+
* back cover): its text is left out. */
|
|
18
|
+
{
|
|
19
|
+
kind: 'coverSlotUnknown';
|
|
20
|
+
slot: string;
|
|
21
|
+
sourceStart: number;
|
|
22
|
+
sourceEnd: number;
|
|
23
|
+
}
|
|
24
|
+
/** Two frames fill one slot: only the first is laid out, the others
|
|
25
|
+
* are left out. */
|
|
26
|
+
| {
|
|
27
|
+
kind: 'coverSlotRepeated';
|
|
28
|
+
slot: string;
|
|
29
|
+
sourceStart: number;
|
|
30
|
+
sourceEnd: number;
|
|
31
|
+
}
|
|
32
|
+
/** A frame names a sheet no version has (`sheet="…"`): left out. */
|
|
33
|
+
| {
|
|
34
|
+
kind: 'coverFrameSheetUnknown';
|
|
35
|
+
sheet: string;
|
|
36
|
+
sourceStart: number;
|
|
37
|
+
sourceEnd: number;
|
|
38
|
+
};
|
|
39
|
+
/** The sheet names a frame's `sheet` attribute may give (#1673). */
|
|
40
|
+
export declare const COVER_FRAME_SHEETS: ReadonlySet<string>;
|
|
41
|
+
/** The slots the cover's Markdown fills, in order, with where each frame
|
|
42
|
+
* opens and the sheets it is for (`sheet="case jacket"`; absent: every
|
|
43
|
+
* sheet). */
|
|
44
|
+
export declare function coverFrames(markdown: string): {
|
|
45
|
+
slot: string;
|
|
46
|
+
start: number;
|
|
47
|
+
end: number;
|
|
48
|
+
sheets?: string[];
|
|
49
|
+
}[];
|
|
50
|
+
/** Text as Markdown that reads as written: the inline marks escaped, line
|
|
51
|
+
* breaks as spaces. */
|
|
52
|
+
export declare function markdownLiteral(text: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* The Markdown the cover is laid out from: the cover's own frames inside
|
|
55
|
+
* the cover's page fence, and a frame for the front and one for the spine
|
|
56
|
+
* when the cover has the slot, the Markdown leaves it empty and the
|
|
57
|
+
* metadata has something to put there. `slots` are the cover page's
|
|
58
|
+
* (`CoverPage.slots`); `sheets`, the names of the sheet being laid out
|
|
59
|
+
* (`case`, `endpaperFront` and `endpapers`…): a frame for other sheets is
|
|
60
|
+
* left out, and one for this sheet takes its slot over a frame for every
|
|
61
|
+
* sheet.
|
|
62
|
+
*/
|
|
63
|
+
export declare function coverSource(markdown: string | undefined, slots: readonly string[], metadata?: DocumentMetadata, sheets?: readonly string[]): {
|
|
64
|
+
markdown: string;
|
|
65
|
+
issues: CoverSourceIssue[];
|
|
66
|
+
};
|
|
67
|
+
/** Where the cover's Markdown starts in `coverSource`'s: its offsets
|
|
68
|
+
* minus this are the cover's own. */
|
|
69
|
+
export declare const coverSourceOffset: () => number;
|
|
70
|
+
/**
|
|
71
|
+
* The paragraph styles the cover sets its metadata text in, from the
|
|
72
|
+
* book's body text: the book's own style of each id goes over its
|
|
73
|
+
* default, field by field. The title and
|
|
74
|
+
* subtitle are centred at 2.4 and 1.4 times the body size, the author at
|
|
75
|
+
* 1.2, the spine's line at the body size, a catalogue's titles at the body
|
|
76
|
+
* size from the left; none hyphenated.
|
|
77
|
+
*/
|
|
78
|
+
export declare function coverParagraphStyles(own: readonly ParagraphStyleConfig[] | undefined, bodySizePt?: number): ParagraphStyleConfig[];
|
|
79
|
+
//# sourceMappingURL=coverSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverSource.d.ts","sourceR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AAE,gBAAqB,EAC/B,MAAM,GAAE,SAAS,MAAM,EAAO,GAC7B;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,gBAAgB,EAAE,CAAA;CAAE,CAiDlD;AAED;sCACsC;AACtC,eAAO,MAAM,iBAAiB,QAAO,MAA8D,CAAC;AAEpG;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,SAAS,oBAAoB,EAAE,GAAG,SAAS,EAAE,UAAU,SAAK,GAAG,oBAAoB,EAAE,CAmB9H"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cover's Markdown (#1667): a document of the book, one
|
|
3
|
+
* `:::frame{slot="…"}` per zone or text box (the back cover's blurb, a
|
|
4
|
+
* flap's biography), laid out on the cover's page template. The front and
|
|
5
|
+
* the spine the Markdown leaves empty take the book's title, subtitle and
|
|
6
|
+
* author, read from its metadata on every build (never copied into the
|
|
7
|
+
* cover), each in a paragraph style of its own the book may redefine.
|
|
8
|
+
*/
|
|
9
|
+
import { COVER_TEMPLATE_ID } from './compose.js';
|
|
10
|
+
/** The paragraph styles the front and the spine are set in when the
|
|
11
|
+
* cover's Markdown leaves them to the metadata. */
|
|
12
|
+
export const COVER_PARAGRAPH_STYLES = ['cover-title', 'cover-subtitle', 'cover-author', 'cover-spine'];
|
|
13
|
+
/** The sheet names a frame's `sheet` attribute may give (#1673). */
|
|
14
|
+
export const COVER_FRAME_SHEETS = new Set(['cover', 'case', 'jacket', 'endpapers', 'endpaperFront', 'endpaperBack']);
|
|
15
|
+
const FRAME_OPEN = /^[ \t]{0,3}(:{3,})[ \t]*frame[ \t]*\{([^}\n]*)\}[ \t]*$/gm;
|
|
16
|
+
const SLOT_ATTR = /(?:^|\s)slot\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"']+))/;
|
|
17
|
+
const SHEET_ATTR = /(?:^|\s)sheet\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"']+))/;
|
|
18
|
+
/** The slots the cover's Markdown fills, in order, with where each frame
|
|
19
|
+
* opens and the sheets it is for (`sheet="case jacket"`; absent: every
|
|
20
|
+
* sheet). */
|
|
21
|
+
export function coverFrames(markdown) {
|
|
22
|
+
const out = [];
|
|
23
|
+
for (const m of markdown.matchAll(FRAME_OPEN)) {
|
|
24
|
+
const attr = SLOT_ATTR.exec(m[2]);
|
|
25
|
+
if (!attr)
|
|
26
|
+
continue;
|
|
27
|
+
const sheet = SHEET_ATTR.exec(m[2]);
|
|
28
|
+
const sheets = sheet ? (sheet[1] ?? sheet[2] ?? sheet[3] ?? '').split(/[\s,]+/).filter(Boolean) : undefined;
|
|
29
|
+
out.push({ slot: attr[1] ?? attr[2] ?? attr[3] ?? '', start: m.index, end: m.index + m[0].length, ...(sheets ? { sheets } : {}) });
|
|
30
|
+
}
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
/** The marks the inline parser reads back after a backslash: emphasis,
|
|
34
|
+
* strikethrough, super- and subscript, code, cross-references and maths.
|
|
35
|
+
* Any other mark escaped would print its backslash. */
|
|
36
|
+
const LITERAL_MARKS = /[*_^~+`@$]/g;
|
|
37
|
+
/** Text as Markdown that reads as written: the inline marks escaped, line
|
|
38
|
+
* breaks as spaces. */
|
|
39
|
+
export function markdownLiteral(text) {
|
|
40
|
+
return text.replace(/\s+/g, ' ').trim().replace(LITERAL_MARKS, (c) => `\\${c}`);
|
|
41
|
+
}
|
|
42
|
+
const metaText = (v) => (typeof v === 'string' ? v.trim() : typeof v === 'number' ? String(v) : '');
|
|
43
|
+
function styled(style, text) {
|
|
44
|
+
return `:::paragraphs{style="${style}"}\n${markdownLiteral(text)}\n:::`;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The Markdown the cover is laid out from: the cover's own frames inside
|
|
48
|
+
* the cover's page fence, and a frame for the front and one for the spine
|
|
49
|
+
* when the cover has the slot, the Markdown leaves it empty and the
|
|
50
|
+
* metadata has something to put there. `slots` are the cover page's
|
|
51
|
+
* (`CoverPage.slots`); `sheets`, the names of the sheet being laid out
|
|
52
|
+
* (`case`, `endpaperFront` and `endpapers`…): a frame for other sheets is
|
|
53
|
+
* left out, and one for this sheet takes its slot over a frame for every
|
|
54
|
+
* sheet.
|
|
55
|
+
*/
|
|
56
|
+
export function coverSource(markdown, slots, metadata = {}, sheets = []) {
|
|
57
|
+
const own = (markdown ?? '').replace(/\r\n?/g, '\n').trim();
|
|
58
|
+
const issues = [];
|
|
59
|
+
const known = new Set(slots);
|
|
60
|
+
const here = new Set(sheets);
|
|
61
|
+
const filled = new Set();
|
|
62
|
+
const frames = coverFrames(own);
|
|
63
|
+
const forHere = (f) => !f.sheets || f.sheets.some((s) => here.has(s));
|
|
64
|
+
// The slots a frame of this sheet's own fills.
|
|
65
|
+
const ownSlots = new Set(frames.filter((f) => f.sheets && forHere(f)).map((f) => f.slot));
|
|
66
|
+
// A frame the cover cannot take is blanked, its text and its fence up to
|
|
67
|
+
// the next frame, so that nothing spills onto a page of its own and the
|
|
68
|
+
// offsets of what follows stay the Markdown's.
|
|
69
|
+
let kept = own;
|
|
70
|
+
const blank = (i) => {
|
|
71
|
+
const to = frames[i + 1]?.start ?? own.length;
|
|
72
|
+
kept = kept.slice(0, frames[i].start) + kept.slice(frames[i].start, to).replace(/[^\n]/g, ' ') + kept.slice(to);
|
|
73
|
+
};
|
|
74
|
+
frames.forEach((f, i) => {
|
|
75
|
+
const strange = f.sheets?.find((s) => !COVER_FRAME_SHEETS.has(s));
|
|
76
|
+
if (strange !== undefined)
|
|
77
|
+
issues.push({ kind: 'coverFrameSheetUnknown', sheet: strange, sourceStart: f.start, sourceEnd: f.end });
|
|
78
|
+
// Another sheet's frame, or a frame for every sheet where this one
|
|
79
|
+
// has its own: no mistake, only not this sheet's.
|
|
80
|
+
if (!forHere(f) || (!f.sheets && ownSlots.has(f.slot)))
|
|
81
|
+
return blank(i);
|
|
82
|
+
const unknown = !known.has(f.slot);
|
|
83
|
+
if (unknown)
|
|
84
|
+
issues.push({ kind: 'coverSlotUnknown', slot: f.slot, sourceStart: f.start, sourceEnd: f.end });
|
|
85
|
+
else if (filled.has(f.slot))
|
|
86
|
+
issues.push({ kind: 'coverSlotRepeated', slot: f.slot, sourceStart: f.start, sourceEnd: f.end });
|
|
87
|
+
if (unknown || filled.has(f.slot))
|
|
88
|
+
blank(i);
|
|
89
|
+
filled.add(f.slot);
|
|
90
|
+
});
|
|
91
|
+
const title = metaText(metadata.title);
|
|
92
|
+
const subtitle = metaText(metadata.subtitle);
|
|
93
|
+
const author = metaText(metadata.author);
|
|
94
|
+
const added = [];
|
|
95
|
+
if (known.has('front') && !filled.has('front') && (title || subtitle || author)) {
|
|
96
|
+
const parts = [
|
|
97
|
+
...(title ? [styled('cover-title', title)] : []),
|
|
98
|
+
...(subtitle ? [styled('cover-subtitle', subtitle)] : []),
|
|
99
|
+
...(author ? [styled('cover-author', author)] : []),
|
|
100
|
+
];
|
|
101
|
+
added.push(`:::frame{slot="front"}\n${parts.join('\n\n')}\n:::`);
|
|
102
|
+
}
|
|
103
|
+
if (known.has('spine') && !filled.has('spine') && (title || author)) {
|
|
104
|
+
added.push(`:::frame{slot="spine"}\n${styled('cover-spine', [title, author].filter(Boolean).join(' · '))}\n:::`);
|
|
105
|
+
}
|
|
106
|
+
// The cover's own text first, so its source offsets inside the page are
|
|
107
|
+
// the Markdown's shifted by the fence alone.
|
|
108
|
+
const body = [kept.trim() ? kept : '', ...added].filter(Boolean).join('\n\n');
|
|
109
|
+
return { markdown: `::::page{template="${COVER_TEMPLATE_ID}"}\n${body}\n::::`, issues };
|
|
110
|
+
}
|
|
111
|
+
/** Where the cover's Markdown starts in `coverSource`'s: its offsets
|
|
112
|
+
* minus this are the cover's own. */
|
|
113
|
+
export const coverSourceOffset = () => `::::page{template="${COVER_TEMPLATE_ID}"}\n`.length;
|
|
114
|
+
/**
|
|
115
|
+
* The paragraph styles the cover sets its metadata text in, from the
|
|
116
|
+
* book's body text: the book's own style of each id goes over its
|
|
117
|
+
* default, field by field. The title and
|
|
118
|
+
* subtitle are centred at 2.4 and 1.4 times the body size, the author at
|
|
119
|
+
* 1.2, the spine's line at the body size, a catalogue's titles at the body
|
|
120
|
+
* size from the left; none hyphenated.
|
|
121
|
+
*/
|
|
122
|
+
export function coverParagraphStyles(own, bodySizePt = 10) {
|
|
123
|
+
const have = new Set((own ?? []).map((s) => s.id));
|
|
124
|
+
const pt = (k) => ({ value: Math.round(bodySizePt * k * 10) / 10, unit: 'pt' });
|
|
125
|
+
const defaults = [
|
|
126
|
+
{ id: 'cover-title', fontSize: pt(2.4), lineHeight: pt(2.8), fontWeight: 700, textAlign: 'center', hyphenation: false },
|
|
127
|
+
{ id: 'cover-subtitle', fontSize: pt(1.4), lineHeight: pt(1.8), textAlign: 'center', hyphenation: false },
|
|
128
|
+
{ id: 'cover-author', fontSize: pt(1.2), lineHeight: pt(1.6), textAlign: 'center', hyphenation: false },
|
|
129
|
+
{ id: 'cover-spine', fontSize: pt(1), lineHeight: pt(1.2), textAlign: 'center', hyphenation: false },
|
|
130
|
+
// A collection's titles (`::catalogue`), the book's own in bold.
|
|
131
|
+
{ id: 'cover-catalogue', fontSize: pt(1), lineHeight: pt(1.4), textAlign: 'left', hyphenation: false },
|
|
132
|
+
{ id: 'cover-catalogue-current', fontSize: pt(1), lineHeight: pt(1.4), fontWeight: 700, textAlign: 'left', hyphenation: false },
|
|
133
|
+
];
|
|
134
|
+
// A style of the book's with one of these ids keeps the defaults it
|
|
135
|
+
// leaves out (a colour alone keeps the size and the centring).
|
|
136
|
+
const byId = new Map(defaults.map((d) => [d.id, d]));
|
|
137
|
+
return [
|
|
138
|
+
...(own ?? []).map((s) => (byId.has(s.id) ? { ...byId.get(s.id), ...s } : s)),
|
|
139
|
+
...defaults.filter((d) => !have.has(d.id)),
|
|
140
|
+
];
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=coverSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAE,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9E,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;KAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A cover's text boxes as frames of the cover's page template (#1679): a
|
|
3
|
+
* box anchored to a zone or to another box, continued in another box,
|
|
4
|
+
* grown up to a height and with its text shrunk, all of it the composed
|
|
5
|
+
* page's own frame features (`placement.anchor`, `next`, `maxHeight`,
|
|
6
|
+
* `fit`), which `layoutComposedPage` lays out. This file only writes the
|
|
7
|
+
* frames, and works out where each box stands for the Sandbox's designer
|
|
8
|
+
* and for a box a frame anchor cannot place (a turned one).
|
|
9
|
+
*/
|
|
10
|
+
import type { FrameConfig } from '../composed/types/frames.js';
|
|
11
|
+
import type { CoverAnchorEdge, CoverTextFrame } from '../types/output/cover.js';
|
|
12
|
+
import type { ProductionSheet, SheetRect } from './geometry.js';
|
|
13
|
+
/** The nine points of a zone's or a box's grid. */
|
|
14
|
+
export declare const COVER_GRID_EDGES: readonly CoverAnchorEdge[];
|
|
15
|
+
/** The points beside another box. */
|
|
16
|
+
export declare const COVER_BESIDE_EDGES: readonly CoverAnchorEdge[];
|
|
17
|
+
/** Something a text box asks that the cover cannot do. */
|
|
18
|
+
export type CoverTextBoxIssue =
|
|
19
|
+
/** An anchor to nothing the sheet has, to the box itself, through a
|
|
20
|
+
* loop of boxes, or at a point the zone has not (`below` a zone): the
|
|
21
|
+
* box stands on its `rect`. */
|
|
22
|
+
{
|
|
23
|
+
kind: 'coverTextBoxAnchor';
|
|
24
|
+
name: string;
|
|
25
|
+
to: string;
|
|
26
|
+
}
|
|
27
|
+
/** A continuation into no other box, into itself or back into a box of
|
|
28
|
+
* its own chain: the box's text does not go on. */
|
|
29
|
+
| {
|
|
30
|
+
kind: 'coverTextBoxNext';
|
|
31
|
+
name: string;
|
|
32
|
+
next: string;
|
|
33
|
+
};
|
|
34
|
+
/** The text boxes the cover keeps: named as ids, once, and not as a zone
|
|
35
|
+
* (`zones`); and the names of the ones it leaves out. */
|
|
36
|
+
export declare function keptCoverTextBoxes(boxes: readonly CoverTextFrame[] | undefined, zones: Iterable<string>): {
|
|
37
|
+
boxes: CoverTextFrame[];
|
|
38
|
+
dropped: string[];
|
|
39
|
+
};
|
|
40
|
+
export interface ResolvedCoverTextBoxes {
|
|
41
|
+
/** Where each box stands on the sheet, mm from its bleed's corner, at
|
|
42
|
+
* its own size (before it grows): its `rect`, or where its anchor puts
|
|
43
|
+
* it. */
|
|
44
|
+
rects: Map<string, SheetRect>;
|
|
45
|
+
/** The anchors kept, by box name. */
|
|
46
|
+
anchors: Map<string, {
|
|
47
|
+
to: string;
|
|
48
|
+
zone: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
/** The continuations kept, by box name. */
|
|
51
|
+
next: Map<string, string>;
|
|
52
|
+
issues: CoverTextBoxIssue[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Where the text boxes of a sheet stand and which of their anchors and
|
|
56
|
+
* continuations hold. `boxes` are the ones the cover keeps (named once,
|
|
57
|
+
* as ids, no zone's name).
|
|
58
|
+
*/
|
|
59
|
+
export declare function resolveCoverTextBoxes(sheet: ProductionSheet, boxes: readonly CoverTextFrame[]): ResolvedCoverTextBoxes;
|
|
60
|
+
/** The frame of a text box. A box placed by an anchor the frame can take
|
|
61
|
+
* (neither it nor the box it hangs from turned) keeps it, so it moves when
|
|
62
|
+
* that box grows; any other stands where its anchor put it. */
|
|
63
|
+
export declare function coverTextBoxFrame(box: CoverTextFrame, sheet: ProductionSheet, resolved: ResolvedCoverTextBoxes, byName: ReadonlyMap<string, CoverTextFrame>): FrameConfig;
|
|
64
|
+
/** A frame on a right-to-left page, whose flow is painted mirrored: its
|
|
65
|
+
* anchor's sides swapped and its offset across turned round, so it lands
|
|
66
|
+
* where it was placed on the sheet. */
|
|
67
|
+
export declare function mirrorFrame(frame: FrameConfig): FrameConfig;
|
|
68
|
+
//# sourceMappingURL=coverTextBoxes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverTextBoxes.d.ts","sourceRoot":"","sources":["../../src/production/coverTextBoxes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG/D,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAKhE,mDAAmD;AACnD,eAAO,MAAM,gBAAgB,EAAE,SAAS,eAAe,EAAyG,CAAC;AACjK,qCAAqC;AACrC,eAAO,MAAM,kBAAkB,EAAE,SAAS,eAAe,EAA8C,CAAC;AAIxG,0DAA0D;AAC1D,MAAM,MAAM,iBAAiB;AAC3B;;gCAEgC;AAC9B;IAAE,IAAI,EAAE,oBAAoB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE;AAC1D;oDACoD;GAClD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AA0B7D;0DAC0D;AAC1D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,GAAG,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG;IAAE,KAAK,EAAE,cAAc,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAaxJ;AAED,MAAM,WAAW,sBAAsB;IACrC;;cAEU;IACV,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC9B,qCAAqC;IACrC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACpD,2CAA2C;IAC3C,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,MAAM,EAAE,iBAAiB,EAAE,CAAC;CAC7B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,SAAS,cAAc,EAAE,GAAG,sBAAsB,CAiDtH;AAED;;gEAEgE;AAChE,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,WAAW,CA0CzK;AAOD;;wCAEwC;AACxC,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,CAY3D"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A cover's text boxes as frames of the cover's page template (#1679): a
|
|
3
|
+
* box anchored to a zone or to another box, continued in another box,
|
|
4
|
+
* grown up to a height and with its text shrunk, all of it the composed
|
|
5
|
+
* page's own frame features (`placement.anchor`, `next`, `maxHeight`,
|
|
6
|
+
* `fit`), which `layoutComposedPage` lays out. This file only writes the
|
|
7
|
+
* frames, and works out where each box stands for the Sandbox's designer
|
|
8
|
+
* and for a box a frame anchor cannot place (a turned one).
|
|
9
|
+
*/
|
|
10
|
+
import { anchorOn } from '../composed/geometry.js';
|
|
11
|
+
import { finite, isSafeId } from './svgSafe.js';
|
|
12
|
+
const mm = (value) => ({ value: Math.round(finite(value) * 1000) / 1000, unit: 'mm' });
|
|
13
|
+
/** The nine points of a zone's or a box's grid. */
|
|
14
|
+
export const COVER_GRID_EDGES = ['top-left', 'top', 'top-right', 'left', 'center', 'right', 'bottom-left', 'bottom', 'bottom-right'];
|
|
15
|
+
/** The points beside another box. */
|
|
16
|
+
export const COVER_BESIDE_EDGES = ['right-of', 'left-of', 'below', 'above'];
|
|
17
|
+
const GRID = new Set(COVER_GRID_EDGES);
|
|
18
|
+
const BESIDE = new Set(COVER_BESIDE_EDGES);
|
|
19
|
+
/** A box whose rotation the frame takes. */
|
|
20
|
+
const turnOf = (box) => (box.rotate === 90 || box.rotate === -90 ? box.rotate : undefined);
|
|
21
|
+
const rectOf = (box) => ({
|
|
22
|
+
x: finite(box.rect?.x),
|
|
23
|
+
y: finite(box.rect?.y),
|
|
24
|
+
width: Math.max(0, finite(box.rect?.width)),
|
|
25
|
+
height: Math.max(0, finite(box.rect?.height)),
|
|
26
|
+
});
|
|
27
|
+
/** `w` × `h` placed at `edge` of `ref` (another box when `beside`), moved
|
|
28
|
+
* by `x`, `y`: the composed page's own anchor rule. */
|
|
29
|
+
function placedAt(edge, ref, beside, w, h, x, y) {
|
|
30
|
+
const a = anchorOn(edge, ref, beside);
|
|
31
|
+
const ax = a.x + x;
|
|
32
|
+
const ay = a.y + y;
|
|
33
|
+
return {
|
|
34
|
+
x: a.pinX === 'start' ? ax : a.pinX === 'end' ? ax - w : ax - w / 2,
|
|
35
|
+
y: a.pinY === 'start' ? ay : a.pinY === 'end' ? ay - h : ay - h / 2,
|
|
36
|
+
width: w,
|
|
37
|
+
height: h,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** The text boxes the cover keeps: named as ids, once, and not as a zone
|
|
41
|
+
* (`zones`); and the names of the ones it leaves out. */
|
|
42
|
+
export function keptCoverTextBoxes(boxes, zones) {
|
|
43
|
+
const names = new Set(zones);
|
|
44
|
+
const kept = [];
|
|
45
|
+
const dropped = [];
|
|
46
|
+
for (const box of boxes ?? []) {
|
|
47
|
+
if (!isSafeId(box?.name) || names.has(box.name)) {
|
|
48
|
+
dropped.push(String(box?.name ?? ''));
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
names.add(box.name);
|
|
52
|
+
kept.push(box);
|
|
53
|
+
}
|
|
54
|
+
return { boxes: kept, dropped };
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Where the text boxes of a sheet stand and which of their anchors and
|
|
58
|
+
* continuations hold. `boxes` are the ones the cover keeps (named once,
|
|
59
|
+
* as ids, no zone's name).
|
|
60
|
+
*/
|
|
61
|
+
export function resolveCoverTextBoxes(sheet, boxes) {
|
|
62
|
+
const byName = new Map(boxes.map((b) => [b.name, b]));
|
|
63
|
+
const zones = new Map(sheet.zones.map((z) => [z.name, z]));
|
|
64
|
+
const rects = new Map();
|
|
65
|
+
const anchors = new Map();
|
|
66
|
+
const issues = [];
|
|
67
|
+
const visiting = new Set();
|
|
68
|
+
const place = (box) => {
|
|
69
|
+
const known = rects.get(box.name);
|
|
70
|
+
if (known)
|
|
71
|
+
return known;
|
|
72
|
+
const own = rectOf(box);
|
|
73
|
+
const a = box.anchor;
|
|
74
|
+
let out = own;
|
|
75
|
+
if (a && typeof a.to === 'string') {
|
|
76
|
+
const zone = zones.get(a.to);
|
|
77
|
+
const other = byName.get(a.to);
|
|
78
|
+
const edge = a.edge;
|
|
79
|
+
const ok = zone ? GRID.has(edge) : other ? GRID.has(edge) || BESIDE.has(edge) : false;
|
|
80
|
+
if (!ok || a.to === box.name || visiting.has(a.to) || (!zone && !other)) {
|
|
81
|
+
issues.push({ kind: 'coverTextBoxAnchor', name: box.name, to: a.to });
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
visiting.add(box.name);
|
|
85
|
+
const ref = zone ? zone.safe : place(other);
|
|
86
|
+
visiting.delete(box.name);
|
|
87
|
+
out = placedAt(edge, ref, !zone, own.width, own.height, finite(a.x), finite(a.y));
|
|
88
|
+
anchors.set(box.name, { to: a.to, zone: !!zone });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
rects.set(box.name, out);
|
|
92
|
+
return out;
|
|
93
|
+
};
|
|
94
|
+
// In a loop, the box that closes it is reported and stands on its
|
|
95
|
+
// `rect`; the others hang from it.
|
|
96
|
+
for (const box of boxes)
|
|
97
|
+
place(box);
|
|
98
|
+
const next = new Map();
|
|
99
|
+
for (const box of boxes) {
|
|
100
|
+
if (box.next === undefined)
|
|
101
|
+
continue;
|
|
102
|
+
const to = box.next;
|
|
103
|
+
let loop = false;
|
|
104
|
+
for (let at = to, n = 0; at !== undefined && n <= boxes.length; at = next.get(at), n++) {
|
|
105
|
+
if (at === box.name)
|
|
106
|
+
loop = true;
|
|
107
|
+
}
|
|
108
|
+
if (typeof to !== 'string' || to === box.name || !byName.has(to) || loop || [...next.values()].includes(to)) {
|
|
109
|
+
issues.push({ kind: 'coverTextBoxNext', name: box.name, next: String(to) });
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
next.set(box.name, to);
|
|
113
|
+
}
|
|
114
|
+
return { rects, anchors, next, issues };
|
|
115
|
+
}
|
|
116
|
+
/** The frame of a text box. A box placed by an anchor the frame can take
|
|
117
|
+
* (neither it nor the box it hangs from turned) keeps it, so it moves when
|
|
118
|
+
* that box grows; any other stands where its anchor put it. */
|
|
119
|
+
export function coverTextBoxFrame(box, sheet, resolved, byName) {
|
|
120
|
+
const r = resolved.rects.get(box.name) ?? rectOf(box);
|
|
121
|
+
const rotate = turnOf(box);
|
|
122
|
+
// A turned box is laid out with its sides swapped, then turned about
|
|
123
|
+
// its centre into the rectangle it was given.
|
|
124
|
+
const w = rotate ? r.height : r.width;
|
|
125
|
+
const h = rotate ? r.width : r.height;
|
|
126
|
+
const anchor = resolved.anchors.get(box.name);
|
|
127
|
+
const a = box.anchor;
|
|
128
|
+
const trim = { x: 0, y: 0, width: sheet.trim.width, height: sheet.trim.height };
|
|
129
|
+
let placement;
|
|
130
|
+
if (anchor && a && !rotate && anchor.zone) {
|
|
131
|
+
// A zone is no frame: the anchor is the template area's same point,
|
|
132
|
+
// moved onto the zone's, so the box grows away from it as a frame
|
|
133
|
+
// anchored there would.
|
|
134
|
+
const zone = sheet.zones.find((z) => z.name === anchor.to);
|
|
135
|
+
const onZone = anchorOn(a.edge, { ...zone.safe, x: zone.safe.x - sheet.trim.x, y: zone.safe.y - sheet.trim.y }, false);
|
|
136
|
+
const onArea = anchorOn(a.edge, trim, false);
|
|
137
|
+
placement = { anchor: { to: 'container', edge: a.edge }, offset: { x: mm(onZone.x - onArea.x + finite(a.x)), y: mm(onZone.y - onArea.y + finite(a.y)) } };
|
|
138
|
+
}
|
|
139
|
+
else if (anchor && a && !rotate && !anchor.zone && !turnOf(byName.get(anchor.to))) {
|
|
140
|
+
placement = { anchor: { to: `#${anchor.to}`, edge: a.edge }, offset: { x: mm(finite(a.x)), y: mm(finite(a.y)) } };
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
placement = { anchor: { to: 'container', edge: 'top-left' }, offset: { x: mm(r.x + r.width / 2 - w / 2 - sheet.trim.x), y: mm(r.y + r.height / 2 - h / 2 - sheet.trim.y) } };
|
|
144
|
+
}
|
|
145
|
+
const maxHeight = !rotate && typeof box.maxHeight === 'number' && Number.isFinite(box.maxHeight) && box.maxHeight > h ? box.maxHeight : undefined;
|
|
146
|
+
const fit = {};
|
|
147
|
+
if (box.fit?.shrinkText === false)
|
|
148
|
+
fit.shrinkText = false;
|
|
149
|
+
const minScale = box.fit?.minScale;
|
|
150
|
+
if (typeof minScale === 'number' && minScale > 0 && minScale <= 1)
|
|
151
|
+
fit.minScale = minScale;
|
|
152
|
+
const next = resolved.next.get(box.name);
|
|
153
|
+
return {
|
|
154
|
+
name: box.name,
|
|
155
|
+
width: mm(w),
|
|
156
|
+
height: mm(h),
|
|
157
|
+
...(rotate ? { rotate } : {}),
|
|
158
|
+
...(box.verticalAlign === 'middle' || box.verticalAlign === 'bottom' ? { verticalAlign: box.verticalAlign } : {}),
|
|
159
|
+
placement,
|
|
160
|
+
...(maxHeight !== undefined ? { maxHeight: mm(maxHeight) } : {}),
|
|
161
|
+
...(Object.keys(fit).length ? { fit } : {}),
|
|
162
|
+
...(next ? { next } : {}),
|
|
163
|
+
optional: true,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
const MIRROR_EDGE = {
|
|
167
|
+
'top-left': 'top-right', 'top-right': 'top-left', left: 'right', right: 'left', 'bottom-left': 'bottom-right', 'bottom-right': 'bottom-left',
|
|
168
|
+
'right-of': 'left-of', 'left-of': 'right-of', 'align-left': 'align-right', 'align-right': 'align-left',
|
|
169
|
+
};
|
|
170
|
+
/** A frame on a right-to-left page, whose flow is painted mirrored: its
|
|
171
|
+
* anchor's sides swapped and its offset across turned round, so it lands
|
|
172
|
+
* where it was placed on the sheet. */
|
|
173
|
+
export function mirrorFrame(frame) {
|
|
174
|
+
const at = frame.placement;
|
|
175
|
+
if (!at)
|
|
176
|
+
return frame;
|
|
177
|
+
const x = at.offset?.x;
|
|
178
|
+
return {
|
|
179
|
+
...frame,
|
|
180
|
+
placement: {
|
|
181
|
+
...at,
|
|
182
|
+
anchor: { ...at.anchor, edge: MIRROR_EDGE[at.anchor.edge] ?? at.anchor.edge },
|
|
183
|
+
offset: { ...at.offset, ...(x ? { x: { ...x, value: -x.value || 0 } } : {}) },
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=coverTextBoxes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverTextBoxes.js","sourceRoot":"","sources":["../../src/production/coverTextBoxes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAInD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,EAAE,GAAG,CAAC,KAAa,EAAa,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CA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AAC;IAC3B,IAAI,CAAC,EAAE;QAAE,OAAO,KAAK,CAAC;IACtB,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAA0B,CAAC;IAChD,OAAO;QACL,GAAG,KAAK;QACR,SAAS,EAAE;YACT,GAAG,EAAE;YACL,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE;YAC7E,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;SAC9E;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paper and binding profiles as a file one user exports and another
|
|
3
|
+
* imports (`.postext-production.json`), as design templates travel.
|
|
4
|
+
*/
|
|
5
|
+
import type { BindingProfile, PaperProfile } from '../types/output/production.js';
|
|
6
|
+
export declare const PRODUCTION_FILE_FORMAT = "postext-production";
|
|
7
|
+
export declare const PRODUCTION_FILE_VERSION = 1;
|
|
8
|
+
export interface ProductionFile {
|
|
9
|
+
format: typeof PRODUCTION_FILE_FORMAT;
|
|
10
|
+
version: number;
|
|
11
|
+
papers: PaperProfile[];
|
|
12
|
+
bindings: BindingProfile[];
|
|
13
|
+
}
|
|
14
|
+
/** Something in an imported file that was left out, and why. */
|
|
15
|
+
export interface ProductionImportIssue {
|
|
16
|
+
where: string;
|
|
17
|
+
reason: 'notAProductionFile' | 'newerVersion' | 'missingId' | 'unknownStyle' | 'badMeasure' | 'badNumber' | 'badText';
|
|
18
|
+
}
|
|
19
|
+
/** The file for these profiles. */
|
|
20
|
+
export declare function exportProductionProfiles(papers: readonly PaperProfile[], bindings: readonly BindingProfile[]): ProductionFile;
|
|
21
|
+
/** A paper profile as read from untrusted data, or undefined when it has
|
|
22
|
+
* no id. Fields that do not read are dropped and listed in `issues`. */
|
|
23
|
+
export declare function readPaperProfile(p: unknown, where: string, issues: ProductionImportIssue[]): PaperProfile | undefined;
|
|
24
|
+
/** A binding profile as read from untrusted data, or undefined when it has
|
|
25
|
+
* no id or an unknown style. Fields that do not read are dropped and
|
|
26
|
+
* listed in `issues`. */
|
|
27
|
+
export declare function readBindingProfile(b: unknown, where: string, issues: ProductionImportIssue[]): BindingProfile | undefined;
|
|
28
|
+
/** The profiles of a file (parsed JSON), each one checked: a profile
|
|
29
|
+
* without an id or with an unknown binding style is left out; a measure
|
|
30
|
+
* that is unknown or unreadable is dropped from its profile. What was left
|
|
31
|
+
* out is listed in `issues`. Ids are kept as written: the caller decides
|
|
32
|
+
* what to do with one the library already has. */
|
|
33
|
+
export declare function importProductionProfiles(data: unknown): {
|
|
34
|
+
papers: PaperProfile[];
|
|
35
|
+
bindings: BindingProfile[];
|
|
36
|
+
issues: ProductionImportIssue[];
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=exchange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exchange.d.ts","sourceRoot":"","sources":["../../src/production/exchange.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAmB,cAAc,EAAgB,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAGjH,eAAO,MAAM,sBAAsB,uBAAuB,CAAC;AAC3D,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,OAAO,sBAAsB,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,QAAQ,EAAE,cAAc,EAAE,CAAC;CAC5B;AAED,gEAAgE;AA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